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

Regression when using #[expect(unused)] more than once in an impl block #114416

Closed
chinedufn opened this issue Aug 3, 2023 · 1 comment · Fixed by #114417
Closed

Regression when using #[expect(unused)] more than once in an impl block #114416

chinedufn opened this issue Aug 3, 2023 · 1 comment · Fixed by #114417
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. F-lint_reasons `#![feature(lint_reasons)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chinedufn
Copy link
Contributor

chinedufn commented Aug 3, 2023

At some point between rustc nightly-2023-03-05 (works) and nightly-2023-07-01 (does not work) the following stopped compiling:

#![deny(warnings)]

struct X;
impl X {
    #[expect(unused)]
    fn unused();

    // This is failing with `warning: this lint expectation is unfulfilled`.
    // Only the first `#[expect(unused)]` in an impl block works as expected.
    #[expect(unused)]
    fn unused2();
}

fn main() {
    let _ = X;
}
RUSTFLAGS="-D warnings" cargo check

I have not bisected for the exact commit that broke this.

I have only tried to reproduce this error using #[expect(unused)]. It's possible that this is also broken for other lints.

PR: #114417

@chinedufn chinedufn added the C-bug Category: This is a bug. label Aug 3, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 3, 2023
@chinedufn chinedufn changed the title Regression when using #[expect(unused)] in more than one in an impl block Regression when using #[expect(unused)] more than once in an impl block Aug 3, 2023
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 3, 2023
@fmease
Copy link
Member

fmease commented Aug 4, 2023

Without properly double-checking this, I'm certain that this regressed in #110277 (merged April 14) which condensed multiple dead_code diagnostics triggered by methods into a single one for readability meddling with the affairs of lint_reasons.

I don't know how lint_reasons is implemented but if it only considers the first primary span of a (buffered) lint diagnostic, then one fix will be changing the relevant part of the code to consider all primary spans.

@rustbot label T-compiler A-lint F-lint_reasons

@rustbot rustbot added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. F-lint_reasons `#![feature(lint_reasons)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 4, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 4, 2023
…block-rust-issue-114416, r=cjgillot

Fix multiple `expect` attribs in impl block

Closes rust-lang#114416
@bors bors closed this as completed in b56a049 Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. F-lint_reasons `#![feature(lint_reasons)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants