Skip to content

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

Closed

Description

@chinedufn

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

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 3, 2023
  2. 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[/+] on Aug 3, 2023
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 3, 2023
  4. fmease commented on Aug 4, 2023

    @fmease
    Member

    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

  5. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Aug 4, 2023
  6. added a commit that references this issue on Oct 4, 2023
    2bbb619
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.F-lint_reasons`#![feature(lint_reasons)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions