-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Allow #[deny]
inside #[forbid]
as a no-op
#121560
Conversation
/// expanded output, which might get expanded into a context that is `forbid()` already, | ||
/// this is not a hard error. | ||
/// As lints in macros are suppressed, so this lint will not show up in these cases. | ||
pub UNOVERRIDABLE_LINT_LEVEL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better lint name ideas welcome
This comment has been minimized.
This comment has been minimized.
My understanding is that this allows this pattern: #![forbid(lint)]
#[deny(lint)]
fn something() {
// code
} Can this come with a test for this case? #![forbid(lint)]
#[deny(lint)]
fn something() {
#[allow(lint)]
{
// linted code
}
} Apologies if this test already exists and I just didn't notice it. |
@rustbot author |
When do people really want If people hit this, maybe the resolution instead would be to say "well use |
It seems completely fine to The thing that shouldn't be allowed is using |
@workingjubilee Agreed that we should have a test for allow-inside-deny-inside-forbid, as well as a test for warn-inside-deny-inside-forbid, both of which should be an error. (The test should check the case where that happens via a macro, as well.) |
We discussed this at the end of the lang triage call today and did not reach a resolution before running out of time. We'll leave this nominated so as to discuss in the meeting on a future week. |
We discussed this again in today's @rust-lang/lang meeting. Concrete proposal to get consensus on:
@rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
@Nilstrieb Could you please remove the warning, and silently allow |
@rustbot labels -I-lang-nominated As mentioned above, this was discussed today and the mood in the meeting was positive on doing what Josh proposed. Since it was discussed and there's now a propose FCP here, let's unnominate. |
Thanks! This will help me significantly for situations where a |
☔ The latest upstream changes (presumably #122483) made this pull request unmergeable. Please resolve the merge conflicts. |
@rfcbot reviewed Note that the PR still needs to be updated to reflect the lang team consensus (no warning on deny-in-forbid, but it's a no-op). Personally I'm in favor of going farther and allowing |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this LGTM with some additional test coverage. Though may need to fix the lint docs failure, not sure what's up with that, I haven't looked closely at it.
tests/ui/lint/deny-inside-forbid-ignored.cli_forbid_warnings.stderr
Outdated
Show resolved
Hide resolved
217e43d
to
43fc0c7
Compare
This comment has been minimized.
This comment has been minimized.
Forbid cannot be overriden. When someome tries to do this anyways, it results in a hard error. That makes sense. Except it doesn't, because macros. Macros may reasonably use `#[deny]` in their expansion to assert that their expanded code follows the lint. This is doesn't work when the output gets expanded into a `forbid()` context. This is pretty silly, since both the macros and the code agree on the lint! Therefore, we allow `#[deny(..)]`ing a lint that's already forbidden, keeping the level at forbid.
43fc0c7
to
1af9d11
Compare
the lint-docs failure was because the lint docs were relying on deny inside forbid being wrong, i changed that one to warn. |
oh @rustbot ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@bors r+ |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#121560 (Allow `#[deny]` inside `#[forbid]` as a no-op) - rust-lang#131365 (Fix missing rustfmt in msi installer rust-lang#101993) - rust-lang#131647 (Register `src/tools/unicode-table-generator` as a runnable tool) - rust-lang#131843 (compiler: Error on layout of enums with invalid reprs) - rust-lang#131926 (Align boolean option descriptions in `configure.py`) - rust-lang#131961 (compiletest: tidy up how `tidy` and `tidy` (html version) are disambiguated) - rust-lang#131962 (Make `llvm::set_section` take a `&CStr`) - rust-lang#131964 (add latest crash tests) - rust-lang#131965 (remove outdated comment) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#121560 - Noratrieb:stop-lint-macro-nonsense, r=jieyouxu Allow `#[deny]` inside `#[forbid]` as a no-op Forbid cannot be overriden. When someome tries to do this anyways, it results in a hard error. That makes sense. Except it doesn't, because macros. Macros may reasonably use `#[deny]` (or `#[warn]` for an allow-by-default lint) in their expansion to assert that their expanded code follows the lint. This is doesn't work when the output gets expanded into a `forbid()` context. This is pretty silly, since both the macros and the code agree on the lint! By making it a warning instead, we remove the problem with the macro, which is now nothing as warnings are suppressed in macro expanded code, while still telling users that something is up. fixes rust-lang#121483
Forbid cannot be overriden. When someome tries to do this anyways, it results in a hard error. That makes sense.
Except it doesn't, because macros. Macros may reasonably use
#[deny]
(or#[warn]
for an allow-by-default lint) in their expansion to assert that their expanded code follows the lint. This is doesn't work when the output gets expanded into aforbid()
context. This is pretty silly, since both the macros and the code agree on the lint!By making it a warning instead, we remove the problem with the macro, which is now nothing as warnings are suppressed in macro expanded code, while still telling users that something is up.
fixes #121483