Skip to content

Honor field-level lint attributes in non_snake_case - #159332

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
chenyukang:yukang-fix-159323-field-lint-expectation
Jul 17, 2026
Merged

Honor field-level lint attributes in non_snake_case#159332
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
chenyukang:yukang-fix-159323-field-lint-expectation

Conversation

@chenyukang

@chenyukangchenyukang commented Jul 15, 2026

Copy link
Copy Markdown
Member

Fixes#159323

non_snake_case checked field names from the enclosing struct with check_struct_def, so field-level lint attributes such as #[expect(non_snake_case)] were not respected.

while

self.with_lint_attrs(s.hir_id, |cx| {
lint_callback!(cx, check_field_def, s);
hir_visit::walk_field_def(cx, s);
})
honor lint attributes.

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 15, 2026
@rustbot

Copy link
Copy Markdown
Collaborator

r? @hanna-kruppe

rustbot has assigned @hanna-kruppe.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 19 candidates

@hanna-kruppehanna-kruppe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, and the new code is a little cleaner than manually looping over fields, too. r=me with LateLintPass::check_struct_def removed.

View changes since this review

Comment threadcompiler/rustc_lint/src/nonstandard_style.rs
@hanna-kruppe

Copy link
Copy Markdown
Contributor

@rustbot author

@rustbotrustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 16, 2026
@chenyukang

Copy link
Copy Markdown
MemberAuthor

@rustbot r=hanna-kruppe

@chenyukang

Copy link
Copy Markdown
MemberAuthor

oops, wrong command.

@bors r=hanna-kruppe

@rust-bors

rust-borsBot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 353c194 has been approved by hanna-kruppe

It is now in the queue for this repository.

@rust-borsrust-borsBot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 17, 2026
@hanna-kruppe

Copy link
Copy Markdown
Contributor

@bors rollup

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 17, 2026
…-lint-expectation, r=hanna-kruppe
Honor field-level lint attributes in non_snake_case
Fixesrust-lang#159323
non_snake_case checked field names from the enclosing struct with `check_struct_def`, so field-level lint attributes such as `#[expect(non_snake_case)]` were not respected.
while https://github.com/rust-lang/rust/blob/e54776fbdb9c233ebbc164fbb9f97e82f879f28c/compiler/rustc_lint/src/late.rs#L206-L209 honor lint attributes.
rust-borsBot pushed a commit that referenced this pull request Jul 17, 2026
…uwer
Rollup of 16 pull requests
Successful merges:
- #150732 (Convert `-Ctarget-cpu` into a target-modifier for AVR, AMDGCN and NVPTX )
- #159301 (Update Enzyme to handle LLVM23)
- #159365 (fix: point at method call chain when a return-position `impl Trait` assoc type diverges)
- #159402 (Clarify safety requirements for SIMD shl/shr and masked load/store)
- #159410 (rustdoc: remove old `--emit` types)
- #158398 (Comment about empty run_passes, fixup of #158040)
- #158843 (Fix ICE in `write_interface` when the interface file can't be written)
- #159302 (Implement `Debug` helpers via `Cell`)
- #159332 (Honor field-level lint attributes in non_snake_case)
- #159386 (add a fallback for `fmuladdf*`)
- #159391 (Update tests for LLVM 23)
- #159400 (Update books)
- #159401 (Gate `tests/debuginfo/function-call.rs` on min GDB 15.1)
- #159404 ([aarch64][win] Pass oversized c-variadic args indirectly on Arm64EC)
- #159405 (Manually implement Clone for GrowableBitSet)
- #159415 (rustdoc: rename the doc parts metadata params)
rust-borsBot pushed a commit that referenced this pull request Jul 17, 2026
…uwer
Rollup of 17 pull requests
Successful merges:
- #159301 (Update Enzyme to handle LLVM23)
- #159365 (fix: point at method call chain when a return-position `impl Trait` assoc type diverges)
- #159402 (Clarify safety requirements for SIMD shl/shr and masked load/store)
- #159408 (rustc_data_structures: Expand documentation for rustc jobserver APIs)
- #159410 (rustdoc: remove old `--emit` types)
- #158398 (Comment about empty run_passes, fixup of #158040)
- #158843 (Fix ICE in `write_interface` when the interface file can't be written)
- #159302 (Implement `Debug` helpers via `Cell`)
- #159332 (Honor field-level lint attributes in non_snake_case)
- #159340 (Rename `errors.rs` file to `diagnostics.rs` (14/N))
- #159386 (add a fallback for `fmuladdf*`)
- #159391 (Update tests for LLVM 23)
- #159400 (Update books)
- #159401 (Gate `tests/debuginfo/function-call.rs` on min GDB 15.1)
- #159404 ([aarch64][win] Pass oversized c-variadic args indirectly on Arm64EC)
- #159405 (Manually implement Clone for GrowableBitSet)
- #159415 (rustdoc: rename the doc parts metadata params)
@rust-bors
rust-borsBot merged commit e5ec4d7 into rust-lang:mainJul 17, 2026
13 checks passed
@rustbotrustbot added this to the 1.99.0 milestone Jul 17, 2026
rust-timer added a commit that referenced this pull request Jul 17, 2026
Rollup merge of #159332 - chenyukang:yukang-fix-159323-field-lint-expectation, r=hanna-kruppe
Honor field-level lint attributes in non_snake_case
Fixes#159323
non_snake_case checked field names from the enclosing struct with `check_struct_def`, so field-level lint attributes such as `#[expect(non_snake_case)]` were not respected.
while https://github.com/rust-lang/rust/blob/e54776fbdb9c233ebbc164fbb9f97e82f879f28c/compiler/rustc_lint/src/late.rs#L206-L209 honor lint attributes.
Kobzol pushed a commit to Kobzol/rustc_codegen_cranelift that referenced this pull request Jul 23, 2026
…uwer
Rollup of 17 pull requests
Successful merges:
- rust-lang/rust#159301 (Update Enzyme to handle LLVM23)
- rust-lang/rust#159365 (fix: point at method call chain when a return-position `impl Trait` assoc type diverges)
- rust-lang/rust#159402 (Clarify safety requirements for SIMD shl/shr and masked load/store)
- rust-lang/rust#159408 (rustc_data_structures: Expand documentation for rustc jobserver APIs)
- rust-lang/rust#159410 (rustdoc: remove old `--emit` types)
- rust-lang/rust#158398 (Comment about empty run_passes, fixup of rust-lang/rust#158040)
- rust-lang/rust#158843 (Fix ICE in `write_interface` when the interface file can't be written)
- rust-lang/rust#159302 (Implement `Debug` helpers via `Cell`)
- rust-lang/rust#159332 (Honor field-level lint attributes in non_snake_case)
- rust-lang/rust#159340 (Rename `errors.rs` file to `diagnostics.rs` (14/N))
- rust-lang/rust#159386 (add a fallback for `fmuladdf*`)
- rust-lang/rust#159391 (Update tests for LLVM 23)
- rust-lang/rust#159400 (Update books)
- rust-lang/rust#159401 (Gate `tests/debuginfo/function-call.rs` on min GDB 15.1)
- rust-lang/rust#159404 ([aarch64][win] Pass oversized c-variadic args indirectly on Arm64EC)
- rust-lang/rust#159405 (Manually implement Clone for GrowableBitSet)
- rust-lang/rust#159415 (rustdoc: rename the doc parts metadata params)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False Positive unfulfilled_lint_expectations

3 participants

@chenyukang@rustbot@hanna-kruppe