-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=dadc51025c06cf1f6d7dd68f793bb2c0
use tracing::{info_span, Span};
pub struct Blah {
pub span: Span,
}
impl Blah {
pub fn new(name: &str) -> Self {
Blah {
span: info_span!(name),
}
}
}
The current output is:
error[E0435]: attempt to use a non-constant value in a constant
--> ice/tests/blah.rs:10:30
|
10 | span: info_span!(name),
| -----------^^^^-
| | |
| | non-constant value
| help: consider using `let` instead of `static`: `let CALLSITE`
For more information about this error, try `rustc --explain E0435`
The help text is in this case not very helpful, potentially leading a user to try solutions that won't work. In this specific case, it would maybe be better to omit the help:
section. Or, if possible maybe something like help: This error happens inside the info_span macro, which might indicate you are using the macro in a way it wasn't intended to be used
.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.