Skip to content

do not lint redundant_lifetimes on items from external macros - #165818

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Albab-Hasan:redundant-lifetimes-external-macro
Nov 12, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Albab-Hasan:redundant-lifetimes-external-macro

Conversation

@Albab-Hasan

Copy link
Copy Markdown
Contributor

derived impls copy the lifetime spans from the derive input so the external macro check on the lint span never fires and the lint is reported on the generated impl. that also left #[expect(redundant_lifetimes)] on a derived struct unfulfillable. now the lint skips items whose own span is in an external macro.

fixes #150553
as suggested in #150553 (comment)

r? @petrochenkov

derived impls kept the lifetime spans of the derive input so the external macro check missed them and `#[expect(redundant_lifetimes)]` on a derived struct went unfulfilled. the lint now skips items whose own span is in an external macro.
@rustbot rustbot 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 Nov 11, 2026
@petrochenkov

petrochenkov commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Are there any other relevant tests from #158943 that can be copied to this PR?

@petrochenkov

Copy link
Copy Markdown
Contributor

Ok, looks like no, @bors r+

@rust-bors

rust-bors Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3a04685 has been tentatively approved by petrochenkov

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot 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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 11, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 11, 2026
…ternal-macro, r=petrochenkov

do not lint `redundant_lifetimes` on items from external macros

derived impls copy the lifetime spans from the derive input so the external macro check on the lint span never fires and the lint is reported on the generated impl. that also left `#[expect(redundant_lifetimes)]` on a derived struct unfulfillable. now the lint skips items whose own span is in an external macro.

fixes rust-lang#150553
as suggested in rust-lang#150553 (comment)

r? @petrochenkov
rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #165804 (cg_llvm: Use an invariant lifetime brand for LLVM values)
 - #165412 (Implement `core::ops::FnAddr`)
 - #165487 (Migrate built-in macros `pattern_type` & `view_type` to macros 2.0 that expand to internal syntax)
 - #165818 (do not lint `redundant_lifetimes` on items from external macros)
 - #164795 (Extend support of lint `explicit_outlives_requirements` to checked type aliases)
 - #165824 (Add regression test for HRTB projection bound with TryFrom error)
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 12, 2026
…ternal-macro, r=petrochenkov

do not lint `redundant_lifetimes` on items from external macros

derived impls copy the lifetime spans from the derive input so the external macro check on the lint span never fires and the lint is reported on the generated impl. that also left `#[expect(redundant_lifetimes)]` on a derived struct unfulfillable. now the lint skips items whose own span is in an external macro.

fixes rust-lang#150553
as suggested in rust-lang#150553 (comment)

r? @petrochenkov
rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
Rollup of 12 pull requests

Successful merges:

 - #165804 (cg_llvm: Use an invariant lifetime brand for LLVM values)
 - #165778 (Bump stage0 to 1.101.0-beta.1)
 - #165412 (Implement `core::ops::FnAddr`)
 - #165487 (Migrate built-in macros `pattern_type` & `view_type` to macros 2.0 that expand to internal syntax)
 - #165818 (do not lint `redundant_lifetimes` on items from external macros)
 - #163077 (feat: support nested functions with `#[offload_kernel]`)
 - #164795 (Extend support of lint `explicit_outlives_requirements` to checked type aliases)
 - #165578 (Avoid `Hash::hash` when stable-hashing various types)
 - #165729 (tests: Add regression test for infinite recursive dereference)
 - #165819 (Avoid redundant scans when extracting stage0 archives)
 - #165822 (Remove unused compiler modules and types)
 - #165824 (Add regression test for HRTB projection bound with TryFrom error)
rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
Rollup of 11 pull requests

Successful merges:

 - #165804 (cg_llvm: Use an invariant lifetime brand for LLVM values)
 - #165778 (Bump stage0 to 1.101.0-beta.1)
 - #165412 (Implement `core::ops::FnAddr`)
 - #165487 (Migrate built-in macros `pattern_type` & `view_type` to macros 2.0 that expand to internal syntax)
 - #165818 (do not lint `redundant_lifetimes` on items from external macros)
 - #163077 (feat: support nested functions with `#[offload_kernel]`)
 - #164795 (Extend support of lint `explicit_outlives_requirements` to checked type aliases)
 - #165578 (Avoid `Hash::hash` when stable-hashing various types)
 - #165729 (tests: Add regression test for infinite recursive dereference)
 - #165822 (Remove unused compiler modules and types)
 - #165824 (Add regression test for HRTB projection bound with TryFrom error)
@rust-bors
rust-bors Bot merged commit 4985df8 into rust-lang:main Nov 12, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 12, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
Rollup merge of #165818 - Albab-Hasan:redundant-lifetimes-external-macro, r=petrochenkov

do not lint `redundant_lifetimes` on items from external macros

derived impls copy the lifetime spans from the derive input so the external macro check on the lint span never fires and the lint is reported on the generated impl. that also left `#[expect(redundant_lifetimes)]` on a derived struct unfulfillable. now the lint skips items whose own span is in an external macro.

fixes #150553
as suggested in #150553 (comment)

r? @petrochenkov
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Nov 13, 2026
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#165804 (cg_llvm: Use an invariant lifetime brand for LLVM values)
 - rust-lang/rust#165778 (Bump stage0 to 1.101.0-beta.1)
 - rust-lang/rust#165412 (Implement `core::ops::FnAddr`)
 - rust-lang/rust#165487 (Migrate built-in macros `pattern_type` & `view_type` to macros 2.0 that expand to internal syntax)
 - rust-lang/rust#165818 (do not lint `redundant_lifetimes` on items from external macros)
 - rust-lang/rust#163077 (feat: support nested functions with `#[offload_kernel]`)
 - rust-lang/rust#164795 (Extend support of lint `explicit_outlives_requirements` to checked type aliases)
 - rust-lang/rust#165578 (Avoid `Hash::hash` when stable-hashing various types)
 - rust-lang/rust#165729 (tests: Add regression test for infinite recursive dereference)
 - rust-lang/rust#165822 (Remove unused compiler modules and types)
 - rust-lang/rust#165824 (Add regression test for HRTB projection bound with TryFrom error)
mehmettoplu-rs pushed a commit to mehmettoplu-rs/miri that referenced this pull request Nov 13, 2026
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#165804 (cg_llvm: Use an invariant lifetime brand for LLVM values)
 - rust-lang/rust#165778 (Bump stage0 to 1.101.0-beta.1)
 - rust-lang/rust#165412 (Implement `core::ops::FnAddr`)
 - rust-lang/rust#165487 (Migrate built-in macros `pattern_type` & `view_type` to macros 2.0 that expand to internal syntax)
 - rust-lang/rust#165818 (do not lint `redundant_lifetimes` on items from external macros)
 - rust-lang/rust#163077 (feat: support nested functions with `#[offload_kernel]`)
 - rust-lang/rust#164795 (Extend support of lint `explicit_outlives_requirements` to checked type aliases)
 - rust-lang/rust#165578 (Avoid `Hash::hash` when stable-hashing various types)
 - rust-lang/rust#165729 (tests: Add regression test for infinite recursive dereference)
 - rust-lang/rust#165822 (Remove unused compiler modules and types)
 - rust-lang/rust#165824 (Add regression test for HRTB projection bound with TryFrom error)
folkertdev pushed a commit to folkertdev/stdarch that referenced this pull request Nov 16, 2026
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#165804 (cg_llvm: Use an invariant lifetime brand for LLVM values)
 - rust-lang/rust#165778 (Bump stage0 to 1.101.0-beta.1)
 - rust-lang/rust#165412 (Implement `core::ops::FnAddr`)
 - rust-lang/rust#165487 (Migrate built-in macros `pattern_type` & `view_type` to macros 2.0 that expand to internal syntax)
 - rust-lang/rust#165818 (do not lint `redundant_lifetimes` on items from external macros)
 - rust-lang/rust#163077 (feat: support nested functions with `#[offload_kernel]`)
 - rust-lang/rust#164795 (Extend support of lint `explicit_outlives_requirements` to checked type aliases)
 - rust-lang/rust#165578 (Avoid `Hash::hash` when stable-hashing various types)
 - rust-lang/rust#165729 (tests: Add regression test for infinite recursive dereference)
 - rust-lang/rust#165822 (Remove unused compiler modules and types)
 - rust-lang/rust#165824 (Add regression test for HRTB projection bound with TryFrom error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant 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.

#[expect(redundant_lifetimes)] doesn't work when #[derive(Debug)] is present

3 participants