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

Expect doesn't work on struct field #138319

Closed
Mark-Simulacrum opened this issue Mar 10, 2025 · 1 comment · Fixed by #138460
Closed

Expect doesn't work on struct field #138319

Mark-Simulacrum opened this issue Mar 10, 2025 · 1 comment · Fixed by #138460
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

@Mark-Simulacrum
Copy link
Member

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

@Mark-Simulacrum Mark-Simulacrum 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 Mar 10, 2025
@xizheyin
Copy link
Contributor

It doesn't seem to be checking fields. if you annotate these attributes for Bar, it meets expectations. I need to dig deeper into this.

fmease added a commit to fmease/rust that referenced this issue Mar 14, 2025
Pass struct field HirId when check_expr_struct_fields

Fixes rust-lang#138319

r? compiler

cc `@Mark-Simulacrum`
@bors bors closed this as completed in 43c41a8 Mar 15, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 15, 2025
Rollup merge of rust-lang#138460 - xizheyin:issue-138319, r=petrochenkov

Pass struct field HirId when check_expr_struct_fields

Fixes rust-lang#138319

r? compiler

cc ``@Mark-Simulacrum``
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

Successfully merging a pull request may close this issue.

2 participants