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

Duplicate error for using allow inside forbid #131842

Open
Noratrieb opened this issue Oct 17, 2024 · 7 comments
Open

Duplicate error for using allow inside forbid #131842

Noratrieb opened this issue Oct 17, 2024 · 7 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Noratrieb
Copy link
Member

Noratrieb commented Oct 17, 2024

Code

// USE `-Zdeduplicate-diagnostics=false`
#[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
fn main() {
    {
        #[allow(unsafe_code)] // let's have some unsafe code in here
        {
        }
    }
}

Current output

error[E0453]: allow(unsafe_code) incompatible with previous forbid
 --> tests/ui/lint/deny-inside-forbid-ignored.rs:4:17
  |
1 | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
  |          ----------- `forbid` level set here
...
4 |         #[allow(unsafe_code)] // let's have some unsafe code in here
  |                 ^^^^^^^^^^^ overruled by previous forbid

error[E0453]: allow(unsafe_code) incompatible with previous forbid
 --> tests/ui/lint/deny-inside-forbid-ignored.rs:4:17
  |
1 | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
  |          ----------- `forbid` level set here
...
4 |         #[allow(unsafe_code)] // let's have some unsafe code in here
  |                 ^^^^^^^^^^^ overruled by previous forbid
  |
  = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0453`.

Desired output

error[E0453]: allow(unsafe_code) incompatible with previous forbid
 --> tests/ui/lint/deny-inside-forbid-ignored.rs:4:17
  |
1 | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
  |          ----------- `forbid` level set here
...
4 |         #[allow(unsafe_code)] // let's have some unsafe code in here
  |                 ^^^^^^^^^^^ overruled by previous forbid

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0453`.

Rationale and extra context

Use -Zdeduplicate-diagnostics=false

more context can be found in tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs

Other cases

No response

Rust Version

rustc 1.83.0-nightly (14f303b 2024-10-04)
binary: rustc
commit-hash: 14f303b
commit-date: 2024-10-04
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

Anything else?

No response

@Noratrieb Noratrieb added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 17, 2024
@ismailarilik

This comment has been minimized.

@Noratrieb

This comment has been minimized.

@ismailarilik

This comment has been minimized.

@Noratrieb

This comment has been minimized.

@ismailarilik
Copy link
Contributor

ismailarilik commented Oct 17, 2024

I didn't try the code yet but I also didn't get why the first output states that there were 2 errors; the second one is just a duplicate so shouldn't there just be 1 error in that case as well?

@ismailarilik

This comment has been minimized.

@Noratrieb
Copy link
Member Author

Noratrieb commented Oct 17, 2024

the code just counts the errors, and there are 2 errors, so it says there are 2 errors. that's fine, nothing wrong with that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants