Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lints cannot be silenced / denied without going through hoops #88

Closed
BD103 opened this issue Sep 18, 2024 · 6 comments
Closed

Lints cannot be silenced / denied without going through hoops #88

BD103 opened this issue Sep 18, 2024 · 6 comments
Labels
A-Linter Related to the linter and custom lints C-Bug A bug in the program

Comments

@BD103
Copy link
Member

BD103 commented Sep 18, 2024

#[allow(bevy::main_return_without_appexit)], -A bevy::main_return_without_appexit, and adding main_return_without_appexit = "allow" to Cargo.toml all fail.

image

image

See Discord for original report.

@BD103 BD103 added A-Linter Related to the linter and custom lints C-Bug A bug in the program labels Sep 18, 2024
@janhohenheim janhohenheim changed the title Lints cannot be silenced / denied Lints cannot be silenced / denied without going through hoops Sep 19, 2024
@janhohenheim
Copy link
Member

Changed the title because the silencing works after adding #![feature(register_tool)] on nightly. It's just not an ideal situation to be in.

@BD103
Copy link
Member Author

BD103 commented Sep 20, 2024

Did a bit of digging into this.

In summary, while it could be possible to automatically register the bevy tool namespace from bevy_lint_driver, it would cause errors when not running the linter because the namespace would not be registered in those cases. (And, the only way I can think of registering from codegen is breaking Rust's exclusive mutability rules, so not a good idea.)

@BD103
Copy link
Member Author

BD103 commented Sep 20, 2024

I think we should just document how to use #![register_tool(...)], and recommend putting it behind a cfg flag.

@janhohenheim
Copy link
Member

Could you elaborate on the cfg? What kind of flag would that be and who passes it when?

@BD103
Copy link
Member Author

BD103 commented Sep 20, 2024

I was thinking we encourage users to add this to their crate root:

#![cfg_attr(bevy_lint, feature(register_tool), register_tool(bevy))]

And this to their Cargo.toml:

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(bevy_lint)"] }

And bevy_lint would pass --cfg bevy_lint to bevy_lint_driver.

But that wouldn't work because register_tool(...) is only available on nightly, so cargo check would still fail with the "unexpected tool name bevy" error on stable Rust.

If we really want to do this, our best course of action is probably getting #![register_tool(...)] stabilized.

@BD103
Copy link
Member Author

BD103 commented Sep 28, 2024

I'm going to close this as not planned. The RFC is way too far off in the horizon, and the hoops are an unfortunate fact of that. #117 will stand in as a temporary solution until then.

@BD103 BD103 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Related to the linter and custom lints C-Bug A bug in the program
Projects
None yet
Development

No branches or pull requests

2 participants