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

rustc book does not specify priority between lint options like -A and attributes #124088

Open
sourcefrog opened this issue Apr 17, 2024 · 2 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@sourcefrog
Copy link
Contributor

Location

https://doc.rust-lang.org/rustc/lints/levels.html

Summary

This page describes that you can configure the allow/warn/deny/etc level of various lints or groups using attributes and command-line options.

It does not currently specify whether options have priority above or below in-code attributes, and I think it would be helpful if it did.

If you like, I can look at what the current behavior is and send a PR documenting it.

@sourcefrog sourcefrog added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Apr 17, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 17, 2024
@jieyouxu
Copy link
Contributor

I agree that the priority for lint levels should be documented, especially because the priority is not trivial: level levels are affected by:

  • Command-line options for a specific lint: e.g. -A <lint-name> or -W <lint-name>
  • Command-line options for a specific lint group: e.g. -A <lint-group-name> or -W <lint-group-name>
  • Command-line options (allow/deny/warn) for the special warnings lint group: e.g. -D warnings
  • --cap-lints=<LEVEL>
  • Hierarchical in-source lint level attributes for specific lint/lint groups/warnings: #[allow(...)], #![warn(...)] etc.

@jieyouxu jieyouxu added T-lang Relevant to the language team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 17, 2024
@sourcefrog
Copy link
Contributor Author

sourcefrog commented Apr 17, 2024

In case it's interesting or helpful, the context for this is sourcefrog/cargo-mutants#322, where cargo-mutants wants to run cargo build making sure that most lints are not treated as errors, but still treating const_eval_long_running as an error. (If it injects a mutation that causes a variable to be unused, that shouldn't cause the compilation to fail, but if it cause a const function to hang then it would be better that the compiler does not hang.)

Currently we use --cap-lints but that has the drawback that it also turns off const_eval_long_running.

Probably some of this goes beyond just documentation into wishing for more detailed control from the command line, or suggesting that const eval hangs are more than just a lint, but having at least some authoritative docs on what the behavior is meant to be today would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants