Skip to content

Add rustc::missing_generic_type_visitable lint - #163538

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
ada4a:missing-generic-type-visitable
Oct 8, 2026
Merged

rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
ada4a:missing-generic-type-visitable

Conversation

@ada4a

@ada4a ada4a commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

Best reviewed commit-by-commit.

The CI will probably complain about the TODOs, but I've added them deliberately, as a way to ask questions.

r? @JonathanBrouwer
cc @rust-lang/rust-analyzer

When `TypeVisitable` is implemented but `GenericTypeVisitable` isn't,
the lint (which we'll add soon) recommends adding
`#[derive(GenericTypeVisitable)]`. However, this suggestion is incorrect
for types whose impls ought to be trivial. There, the problem occurs
because the type was added to `TrivialTypeTraversalImpls!` in
`macros.rs`, which added the `TypeVisitable` impl, but wasn't added to
`trivial_impls!` in `generic_visit.rs`, such that the
`GenericTypeVisitable` impl wasn't added.

Imo, the root cause of this problem is that we have two separate macros
for adding trivial impls. So this commit merges them into one, by making
`TrivialTypeTraversalImpls!` add a `GenericTypeVisitable` impl as well.

RE: `Variance`: its `GenericTypeVisitable` impl is now provided by
`TrivialTypeTraversalImpls!`, making the derive unnecessary.

RE: `rustc_hash::FxBuildHasher`: its `GenericTypeVisitable` impl ended
up being removed, because `TypeVisitable` can't be implemented due to it
not implemnting `Debug`. This shouldn't be a problem however, as
`{Generic,}TypeVisitable` should always be implemented in pairs anyway.
I confirmed this by removing the impl from `ra-ap-rustc_type_ir` and
`cargo check`-ing r-a.
The missing impl for arrays was (indirectly) highlighted by the test
suite, the rest -- by the `#[deny]`
@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 Sep 30, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_lint/src/internal.rs Outdated
@ada4a
ada4a force-pushed the missing-generic-type-visitable branch from e09ae81 to 5fa40f8 Compare September 30, 2026 12:34
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 7, 2026
@rust-lang rust-lang deleted a comment from rustbot Oct 7, 2026
Comment thread compiler/rustc_type_ir/src/macros.rs
Comment thread compiler/rustc_type_ir/src/lib.rs Outdated
Comment thread compiler/rustc_lint/src/internal.rs
Comment thread compiler/rustc_lint/src/internal.rs Outdated
Comment thread compiler/rustc_lint/src/internal.rs
Comment thread compiler/rustc_lint/src/internal.rs Outdated
Comment thread compiler/rustc_lint/src/internal.rs
Comment thread compiler/rustc_lint/src/internal.rs
@rustbot rustbot 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 Oct 7, 2026
@JonathanBrouwer

JonathanBrouwer commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

A lot of comments but it's a lot of small things
I like the PR in general :3

@ada4a
ada4a force-pushed the missing-generic-type-visitable branch from 5fa40f8 to d91635d Compare October 7, 2026 15:22
@rust-log-analyzer

This comment has been minimized.

@ada4a
ada4a force-pushed the missing-generic-type-visitable branch from d91635d to 532fc7d Compare October 7, 2026 17:30
@ada4a

ada4a commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Everything should be addressed now:)

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 7, 2026
@rust-log-analyzer

This comment has been minimized.

@ada4a
ada4a force-pushed the missing-generic-type-visitable branch from 532fc7d to 6257faf Compare October 7, 2026 17:47

@JonathanBrouwer JonathanBrouwer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rust-bors

rust-bors Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 6257faf has been tentatively approved by JonathanBrouwer

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 Oct 7, 2026
@ada4a

ada4a commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author
  warning: unknown lint: `rustc::missing_generic_type_visitable_derive`
  Warning:   --> /checkout/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs:5:9
     |
  LL | #![deny(rustc::missing_generic_type_visitable_derive)]
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: `#[warn(unknown_lints)]` on by default
  
  warning: 1 warning emitted
  ------------------------------------------
  
  ---- [ui] tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs stdout end ----
  
  failures:
      [ui] tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs
  
  test result: FAILED. 30 passed; 1 failed; 54 ignored; 0 measured; 0 filtered out; finished in 3.57s
  
  Some tests failed in compiletest suite=ui-fulldeps mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
  Bootstrap failed while executing `--stage 1 test --skip src/tools/tidy --skip src/tools/linkchecker`

Well of course it failed – it was running a ui-fulldeps test in stage 1!

Do you have any idea how to fix this?..

@JonathanBrouwer

Copy link
Copy Markdown
Member

I think you just have to add //@ ignore-stage1 to the test

@ada4a
ada4a force-pushed the missing-generic-type-visitable branch from 6257faf to 19735e0 Compare October 8, 2026 08:09
@ada4a

ada4a commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Also added a FIXME to remove it again, like it's done in

// FIXME(bootstrap): Remove the ignore once we promote the next beta.
//@ ignore-stage1

Uhh let's see if I can get the syntax right?

@bors try test-x86_64-gnu-llvm-22-3

@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Unknown argument "test-x86_64-gnu-llvm-22-3". Did you mean to use @bors jobs=<jobs>|parent=<parent>? Run @bors help or go to https://bors.rust-lang.org/help to see available commands.

@ada4a

ada4a commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Ugh, does it not pick up message edits.

Okay let's try again.

@bors try jobs=test-x86_64-gnu-llvm-22-3

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
Add `rustc::missing_generic_type_visitable` lint


try-job: test-x86_64-gnu-llvm-22-3
@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 823963c (823963c46578469b01249c580a2345861e73cbb5)
Base parent: 42cfc04 (42cfc04deaa723bc21611f3f9d7c8651be6300df)

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 19735e0 has been approved by JonathanBrouwer

It is now in the queue for this repository.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 8, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 8, 2026
…le, r=JonathanBrouwer

Add `rustc::missing_generic_type_visitable` lint

Best reviewed commit-by-commit.

The CI will probably complain about the TODOs, but I've added them deliberately, as a way to ask questions.

r? @JonathanBrouwer
cc @rust-lang/rust-analyzer
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 8, 2026
…le, r=JonathanBrouwer

Add `rustc::missing_generic_type_visitable` lint

Best reviewed commit-by-commit.

The CI will probably complain about the TODOs, but I've added them deliberately, as a way to ask questions.

r? @JonathanBrouwer
cc @rust-lang/rust-analyzer
rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #163462 (Fix COFF renaming of decorated (stdcall/fastcall/vectorcall) exports)
 - #163855 (Include enclosing item's context on const errors)
 - #163861 (Run LLDB debuginfo tests on `x86_64-mingw`)
 - #163538 (Add `rustc::missing_generic_type_visitable` lint)
 - #163617 (mips: make `Complex<T>` ABI match GCC)
 - #163832 (reject non-async coroutine closures as async callables)
 - #163958 (only make `RustaceansAreAwesome` satisfy trait clauses)
 - #163974 (Condense AdtDef lang item checks into one match)
 - #163979 (Add `bf16` to arm features)

Failed merges:

 - #163972 (const-eval: ICE when we hit a non-const fn)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 8, 2026
…le, r=JonathanBrouwer

Add `rustc::missing_generic_type_visitable` lint

Best reviewed commit-by-commit.

The CI will probably complain about the TODOs, but I've added them deliberately, as a way to ask questions.

r? @JonathanBrouwer
cc @rust-lang/rust-analyzer
rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #163462 (Fix COFF renaming of decorated (stdcall/fastcall/vectorcall) exports)
 - #163855 (Include enclosing item's context on const errors)
 - #163861 (Run LLDB debuginfo tests on `x86_64-mingw`)
 - #161201 (Speed up tidy again)
 - #163538 (Add `rustc::missing_generic_type_visitable` lint)
 - #163617 (mips: make `Complex<T>` ABI match GCC)
 - #163772 (comptime fn error: suggest wrapping in const block)
 - #163832 (reject non-async coroutine closures as async callables)
 - #163958 (only make `RustaceansAreAwesome` satisfy trait clauses)
 - #163974 (Condense AdtDef lang item checks into one match)
 - #163979 (Add `bf16` to arm features)
 - #163989 (Revert "compiletest: stream output of executor process when --no-capture is set")

Failed merges:

 - #163972 (const-eval: ICE when we hit a non-const fn)
rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - #156112 (Distinguish `repr(C)` ZSTs from others in ABI computation)
 - #157941 (Deny partial `-Z stack-protector` by default in all editions)
 - #163462 (Fix COFF renaming of decorated (stdcall/fastcall/vectorcall) exports)
 - #163855 (Include enclosing item's context on const errors)
 - #163861 (Run LLDB debuginfo tests on `x86_64-mingw`)
 - #163913 ( Silence redundant failed obligations on the same statement)
 - #161201 (Speed up tidy again)
 - #163380 (Tweak "name not found" resolution error when it happens from within a derive expansion)
 - #163538 (Add `rustc::missing_generic_type_visitable` lint)
 - #163617 (mips: make `Complex<T>` ABI match GCC)
 - #163772 (comptime fn error: suggest wrapping in const block)
 - #163813 (use pre-borrowck typing env for early MIR validation)
 - #163924 (replace instances of NonNull::new(&mut x).expect("...") with NonNull::from_mut)
 - #163958 (only make `RustaceansAreAwesome` satisfy trait clauses)
 - #163960 (vexos: clear .bss from assembly)
 - #163974 (Condense AdtDef lang item checks into one match)
 - #163979 (Add `bf16` to arm features)
 - #163989 (Revert "compiletest: stream output of executor process when --no-capture is set")
 - #163995 (m68k-unknown-none-elf: Remove code model)

Failed merges:

 - #163832 (reject non-async coroutine closures as async callables)
 - #163972 (const-eval: ICE when we hit a non-const fn)
@rust-bors
rust-bors Bot merged commit 0a2f88c into rust-lang:main Oct 8, 2026
15 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
Rollup merge of #163538 - ada4a:missing-generic-type-visitable, r=JonathanBrouwer

Add `rustc::missing_generic_type_visitable` lint

Best reviewed commit-by-commit.

The CI will probably complain about the TODOs, but I've added them deliberately, as a way to ask questions.

r? @JonathanBrouwer
cc @rust-lang/rust-analyzer
@ada4a
ada4a deleted the missing-generic-type-visitable branch October 9, 2026 06:19
programskillforverification pushed a commit to programskillforverification/miri that referenced this pull request Oct 9, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#156112 (Distinguish `repr(C)` ZSTs from others in ABI computation)
 - rust-lang/rust#157941 (Deny partial `-Z stack-protector` by default in all editions)
 - rust-lang/rust#163462 (Fix COFF renaming of decorated (stdcall/fastcall/vectorcall) exports)
 - rust-lang/rust#163855 (Include enclosing item's context on const errors)
 - rust-lang/rust#163861 (Run LLDB debuginfo tests on `x86_64-mingw`)
 - rust-lang/rust#163913 ( Silence redundant failed obligations on the same statement)
 - rust-lang/rust#161201 (Speed up tidy again)
 - rust-lang/rust#163380 (Tweak "name not found" resolution error when it happens from within a derive expansion)
 - rust-lang/rust#163538 (Add `rustc::missing_generic_type_visitable` lint)
 - rust-lang/rust#163617 (mips: make `Complex<T>` ABI match GCC)
 - rust-lang/rust#163772 (comptime fn error: suggest wrapping in const block)
 - rust-lang/rust#163813 (use pre-borrowck typing env for early MIR validation)
 - rust-lang/rust#163924 (replace instances of NonNull::new(&mut x).expect("...") with NonNull::from_mut)
 - rust-lang/rust#163958 (only make `RustaceansAreAwesome` satisfy trait clauses)
 - rust-lang/rust#163960 (vexos: clear .bss from assembly)
 - rust-lang/rust#163974 (Condense AdtDef lang item checks into one match)
 - rust-lang/rust#163979 (Add `bf16` to arm features)
 - rust-lang/rust#163989 (Revert "compiletest: stream output of executor process when --no-capture is set")
 - rust-lang/rust#163995 (m68k-unknown-none-elf: Remove code model)

Failed merges:

 - rust-lang/rust#163832 (reject non-async coroutine closures as async callables)
 - rust-lang/rust#163972 (const-eval: ICE when we hit a non-const fn)
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.

4 participants