You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent warning for macros that contain unexpected_cfgs #18461
mylib has no feature declared, so I got an unexpected_cfgs warning in the place where I called my_lib_macro!():
unexpected `cfg` condition value: `my_feature`
no expected values for `feature`
consider adding `my_feature` as a feature in `Cargo.toml`
see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
`#[warn(unexpected_cfgs)]` on by default [unexpected_cfgs]
This is great, exactly what I would expect.
However, if I use mylib in other packages, say I have another crate, myapp, that depends on mylib.
In myapp/main.rs, I have:
use mylib::my_lib_macro;
fn main() {
my_lib_macro!();
}
Rust-analyzer does not report anything in main(), which confuses me why that is the case.
Hopefully the example makes sense, happy to provide more information if needed.
And thanks for the help :).
Then rust-analyzer is functioning correctly, the warnings are reported by Cargo (and rustc), if they are missing it's at most a Cargo bug, not a rust-analyzer bug.
I believe this is because there is no way to state the expected features for a binary, so every feature is expected.
Activity
ChayimFriedman2 commentedon Nov 2, 2024
Is the same thing happening with
cargo check?funemy commentedon Nov 2, 2024
@ChayimFriedman2 I'm not sure if I did it correctly, but I didn't see any warning with
cargo check.ChayimFriedman2 commentedon Nov 2, 2024
Then rust-analyzer is functioning correctly, the warnings are reported by Cargo (and rustc), if they are missing it's at most a Cargo bug, not a rust-analyzer bug.
I believe this is because there is no way to state the expected features for a binary, so every feature is expected.