Skip to content

Expect doesn't work on struct field #138319

Closed
@Mark-Simulacrum

Description

@Mark-Simulacrum

Code

fn _foo() {
    Bar {
        #[expect(deprecated)]
        foo: 0,
    };
}

struct Bar {
    #[deprecated = "reason"]
    foo: u32,
}

Current output

warning: use of deprecated field `Bar::foo`: reason
 --> src/lib.rs:4:9
  |
4 |         foo: 0,
  |         ^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default

warning: this lint expectation is unfulfilled
 --> src/lib.rs:3:18
  |
3 |         #[expect(deprecated)]
  |                  ^^^^^^^^^^
  |
  = note: `#[warn(unfulfilled_lint_expectations)]` on by default

Desired output

n/a (empty)

Rationale and extra context

Expectation should be fulfilled, as the deprecated lint is actively being emitted from that field initialization. This works as expected if the expectation is moved elsewhere (e.g., to the function).

Other cases

Rust Version

Current stable (1.85)

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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