Skip to content

Keep generic suggestion for macro-expanded missing-type items#157725

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Dnreikronos:infer_placeholder_macro_suggestion_determinism
Jun 12, 2026
Merged

Keep generic suggestion for macro-expanded missing-type items#157725
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Dnreikronos:infer_placeholder_macro_suggestion_determinism

Conversation

@Dnreikronos

@Dnreikronos Dnreikronos commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #157659

If a macro expands to a few missing-type items on the same span (think a $()* repeat of const A = ...;), they all land on the same stashed ItemNoType diagnostic. Only one item gets to steal it and stamp in its own inferred type, and under the parallel front-end which one wins is basically a coin flip. So the suggested type flips between runs: the original repro kept bouncing between usize and bool.

There isn't really a "right" type to show here anyway, imo. The items can infer different types, so there's no single one to suggest. When the placeholder span comes from a macro I now skip the inferred-type suggestion and keep the parser's generic <type> one instead. The fallback arm a few lines down already does the same thing, so it lines up.

Output is deterministic now, so in-macro no longer needs ignore-parallel-frontend. Checked it by hashing the stderr over a couple hundred -Z threads=8 runs (all identical) and the touched ui dirs still pass.

A macro can expand to several missing-type items (e.g. a `$()*`
repetition of `const A = ...;`) that all collide on one stashed
`ItemNoType` diagnostic. They can infer different types, so there is no
single concrete type to suggest, and which item wins the steal is not
even stable under the parallel front-end.

Skip the inferred-type suggestion when the placeholder span comes from a
macro expansion and keep the generic `<type>` suggestion from the parser
instead, mirroring the existing handling in the fallback arm. This makes
the diagnostic deterministic, so the `in-macro` test no longer needs
`ignore-parallel-frontend`.
@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 Jun 10, 2026
@rustbot

rustbot commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
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, types
  • compiler, types expanded to 73 candidates
  • Random selection from 17 candidates

@jieyouxu jieyouxu 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.

Comment on lines +440 to +448
// HACK(#69396): A macro can expand to several missing-type items that all
// collide on one stashed `(span, ItemNoType)` diagnostic. They can infer
// different types, so there is no single concrete type to suggest, and which
// one wins the steal is not even stable under the parallel front-end. Keep the
// parser's generic suggestion instead. The fallback arm below additionally
// checks `is_empty` for explicit `_` spans.
if ty_span.from_expansion() {
return;
}

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.

Remark: hm, this indeed feels a bit like papering over 🤔 I suppose it doesn't seem overly problematic 🤷

@rust-bors

rust-bors Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3f2e8af has been approved by jieyouxu

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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 11, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 11, 2026
…o_suggestion_determinism, r=jieyouxu

Keep generic suggestion for macro-expanded missing-type items

Fixes rust-lang#157659

If a macro expands to a few missing-type items on the same span (think a `$()*` repeat of `const A = ...;`), they all land on the same stashed `ItemNoType` diagnostic. Only one item gets to steal it and stamp in its own inferred type, and under the parallel front-end which one wins is basically a coin flip. So the suggested type flips between runs: the original repro kept bouncing between `usize` and `bool`.

There isn't really a "right" type to show here anyway, imo. The items can infer different types, so there's no single one to suggest. When the placeholder span comes from a macro I now skip the inferred-type suggestion and keep the parser's generic `<type>` one instead. The fallback arm a few lines down already does the same thing, so it lines up.

Output is deterministic now, so `in-macro` no longer needs `ignore-parallel-frontend`. Checked it by hashing the stderr over a couple hundred `-Z threads=8` runs (all identical) and the touched ui dirs still pass.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 11, 2026
…o_suggestion_determinism, r=jieyouxu

Keep generic suggestion for macro-expanded missing-type items

Fixes rust-lang#157659

If a macro expands to a few missing-type items on the same span (think a `$()*` repeat of `const A = ...;`), they all land on the same stashed `ItemNoType` diagnostic. Only one item gets to steal it and stamp in its own inferred type, and under the parallel front-end which one wins is basically a coin flip. So the suggested type flips between runs: the original repro kept bouncing between `usize` and `bool`.

There isn't really a "right" type to show here anyway, imo. The items can infer different types, so there's no single one to suggest. When the placeholder span comes from a macro I now skip the inferred-type suggestion and keep the parser's generic `<type>` one instead. The fallback arm a few lines down already does the same thing, so it lines up.

Output is deterministic now, so `in-macro` no longer needs `ignore-parallel-frontend`. Checked it by hashing the stderr over a couple hundred `-Z threads=8` runs (all identical) and the touched ui dirs still pass.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 11, 2026
…o_suggestion_determinism, r=jieyouxu

Keep generic suggestion for macro-expanded missing-type items

Fixes rust-lang#157659

If a macro expands to a few missing-type items on the same span (think a `$()*` repeat of `const A = ...;`), they all land on the same stashed `ItemNoType` diagnostic. Only one item gets to steal it and stamp in its own inferred type, and under the parallel front-end which one wins is basically a coin flip. So the suggested type flips between runs: the original repro kept bouncing between `usize` and `bool`.

There isn't really a "right" type to show here anyway, imo. The items can infer different types, so there's no single one to suggest. When the placeholder span comes from a macro I now skip the inferred-type suggestion and keep the parser's generic `<type>` one instead. The fallback arm a few lines down already does the same thing, so it lines up.

Output is deterministic now, so `in-macro` no longer needs `ignore-parallel-frontend`. Checked it by hashing the stderr over a couple hundred `-Z threads=8` runs (all identical) and the touched ui dirs still pass.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 11, 2026
…o_suggestion_determinism, r=jieyouxu

Keep generic suggestion for macro-expanded missing-type items

Fixes rust-lang#157659

If a macro expands to a few missing-type items on the same span (think a `$()*` repeat of `const A = ...;`), they all land on the same stashed `ItemNoType` diagnostic. Only one item gets to steal it and stamp in its own inferred type, and under the parallel front-end which one wins is basically a coin flip. So the suggested type flips between runs: the original repro kept bouncing between `usize` and `bool`.

There isn't really a "right" type to show here anyway, imo. The items can infer different types, so there's no single one to suggest. When the placeholder span comes from a macro I now skip the inferred-type suggestion and keep the parser's generic `<type>` one instead. The fallback arm a few lines down already does the same thing, so it lines up.

Output is deterministic now, so `in-macro` no longer needs `ignore-parallel-frontend`. Checked it by hashing the stderr over a couple hundred `-Z threads=8` runs (all identical) and the touched ui dirs still pass.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 11, 2026
…o_suggestion_determinism, r=jieyouxu

Keep generic suggestion for macro-expanded missing-type items

Fixes rust-lang#157659

If a macro expands to a few missing-type items on the same span (think a `$()*` repeat of `const A = ...;`), they all land on the same stashed `ItemNoType` diagnostic. Only one item gets to steal it and stamp in its own inferred type, and under the parallel front-end which one wins is basically a coin flip. So the suggested type flips between runs: the original repro kept bouncing between `usize` and `bool`.

There isn't really a "right" type to show here anyway, imo. The items can infer different types, so there's no single one to suggest. When the placeholder span comes from a macro I now skip the inferred-type suggestion and keep the parser's generic `<type>` one instead. The fallback arm a few lines down already does the same thing, so it lines up.

Output is deterministic now, so `in-macro` no longer needs `ignore-parallel-frontend`. Checked it by hashing the stderr over a couple hundred `-Z threads=8` runs (all identical) and the touched ui dirs still pass.
rust-bors Bot pushed a commit that referenced this pull request Jun 11, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #157716 (update Enzyme, June'26)
 - #149793 (Add inline asm support for amdgpu)
 - #152852 (Remove driver_lint_caps)
 - #155299 (make repr_transparent_non_zst_fields a hard error)
 - #155439 (Enable Cargo's new build-dir layout)
 - #157612 (Add a test where subtyping inhibits coercion.)
 - #157626 (Autogenerate unstable compiler flag stubs for unstable-book)
 - #157667 (Rename typing modes to better describe real usage)
 - #156212 (Additionally gate negative bounds behind new `-Zinternal-testing-features`)
 - #157342 (Reduce verbosity of cycle errors when possible)
 - #157366 (Add a regression test for an unconstrained TransmuteFrom ICE)
 - #157459 (rustc_target: callconv: powerpc64: Remove unreachable fallback code path)
 - #157658 (UnsafeCell: mention shared-ref-to-interior case, fix aliasing model inaccuracy)
 - #157698 (Remove an unnecessary cloning)
 - #157699 (Arg splat experiment - hir FnDecl impl)
 - #157713 (resolve: Remove exported imports from `maybe_unused_trait_imports`)
 - #157722 (Move create_scope_map to rustc_codegen_ssa.)
 - #157725 (Keep generic suggestion for macro-expanded missing-type items)
 - #157733 (Remove old FIXMEs about nocapture attribute)
 - #157737 (Reorganize `tests/ui/issues` [7/N])
 - #157746 (supports_c_variadic_definitions: extend checklist for new targets)
 - #157763 (Move unused target expression error to appropriate place and rename it)
 - #157768 (codegen_ssa: peel trans. wrappers on scalable vecs)
rust-bors Bot pushed a commit that referenced this pull request Jun 11, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #157716 (update Enzyme, June'26)
 - #149793 (Add inline asm support for amdgpu)
 - #152852 (Remove driver_lint_caps)
 - #155299 (make repr_transparent_non_zst_fields a hard error)
 - #155439 (Enable Cargo's new build-dir layout)
 - #157612 (Add a test where subtyping inhibits coercion.)
 - #157626 (Autogenerate unstable compiler flag stubs for unstable-book)
 - #157667 (Rename typing modes to better describe real usage)
 - #156212 (Additionally gate negative bounds behind new `-Zinternal-testing-features`)
 - #157342 (Reduce verbosity of cycle errors when possible)
 - #157366 (Add a regression test for an unconstrained TransmuteFrom ICE)
 - #157459 (rustc_target: callconv: powerpc64: Remove unreachable fallback code path)
 - #157658 (UnsafeCell: mention shared-ref-to-interior case, fix aliasing model inaccuracy)
 - #157698 (Remove an unnecessary cloning)
 - #157699 (Arg splat experiment - hir FnDecl impl)
 - #157713 (resolve: Remove exported imports from `maybe_unused_trait_imports`)
 - #157722 (Move create_scope_map to rustc_codegen_ssa.)
 - #157725 (Keep generic suggestion for macro-expanded missing-type items)
 - #157733 (Remove old FIXMEs about nocapture attribute)
 - #157737 (Reorganize `tests/ui/issues` [7/N])
 - #157746 (supports_c_variadic_definitions: extend checklist for new targets)
 - #157763 (Move unused target expression error to appropriate place and rename it)
 - #157768 (codegen_ssa: peel trans. wrappers on scalable vecs)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 11, 2026
…o_suggestion_determinism, r=jieyouxu

Keep generic suggestion for macro-expanded missing-type items

Fixes rust-lang#157659

If a macro expands to a few missing-type items on the same span (think a `$()*` repeat of `const A = ...;`), they all land on the same stashed `ItemNoType` diagnostic. Only one item gets to steal it and stamp in its own inferred type, and under the parallel front-end which one wins is basically a coin flip. So the suggested type flips between runs: the original repro kept bouncing between `usize` and `bool`.

There isn't really a "right" type to show here anyway, imo. The items can infer different types, so there's no single one to suggest. When the placeholder span comes from a macro I now skip the inferred-type suggestion and keep the parser's generic `<type>` one instead. The fallback arm a few lines down already does the same thing, so it lines up.

Output is deterministic now, so `in-macro` no longer needs `ignore-parallel-frontend`. Checked it by hashing the stderr over a couple hundred `-Z threads=8` runs (all identical) and the touched ui dirs still pass.
rust-bors Bot pushed a commit that referenced this pull request Jun 11, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #157716 (update Enzyme, June'26)
 - #149793 (Add inline asm support for amdgpu)
 - #155299 (make repr_transparent_non_zst_fields a hard error)
 - #155439 (Enable Cargo's new build-dir layout)
 - #157612 (Add a test where subtyping inhibits coercion.)
 - #157626 (Autogenerate unstable compiler flag stubs for unstable-book)
 - #157667 (Rename typing modes to better describe real usage)
 - #149749 (Make `BorrowedBuf` and `BorrowedCursor` generic over the data)
 - #156212 (Additionally gate negative bounds behind new `-Zinternal-testing-features`)
 - #157342 (Reduce verbosity of cycle errors when possible)
 - #157366 (Add a regression test for an unconstrained TransmuteFrom ICE)
 - #157459 (rustc_target: callconv: powerpc64: Remove unreachable fallback code path)
 - #157658 (UnsafeCell: mention shared-ref-to-interior case, fix aliasing model inaccuracy)
 - #157698 (Remove an unnecessary cloning)
 - #157699 (Arg splat experiment - hir FnDecl impl)
 - #157713 (resolve: Remove exported imports from `maybe_unused_trait_imports`)
 - #157722 (Move create_scope_map to rustc_codegen_ssa.)
 - #157725 (Keep generic suggestion for macro-expanded missing-type items)
 - #157733 (Remove old FIXMEs about nocapture attribute)
 - #157737 (Reorganize `tests/ui/issues` [7/N])
 - #157746 (supports_c_variadic_definitions: extend checklist for new targets)
 - #157763 (Move unused target expression error to appropriate place and rename it)
 - #157768 (codegen_ssa: peel trans. wrappers on scalable vecs)
rust-bors Bot pushed a commit that referenced this pull request Jun 12, 2026
Rollup of 24 pull requests

Successful merges:

 - #157716 (update Enzyme, June'26)
 - #149793 (Add inline asm support for amdgpu)
 - #155299 (make repr_transparent_non_zst_fields a hard error)
 - #157612 (Add a test where subtyping inhibits coercion.)
 - #157626 (Autogenerate unstable compiler flag stubs for unstable-book)
 - #157667 (Rename typing modes to better describe real usage)
 - #149749 (Make `BorrowedBuf` and `BorrowedCursor` generic over the data)
 - #155113 (Ensure Send/Sync impl for std::process::CommandArgs)
 - #156212 (Additionally gate negative bounds behind new `-Zinternal-testing-features`)
 - #157342 (Reduce verbosity of cycle errors when possible)
 - #157366 (Add a regression test for an unconstrained TransmuteFrom ICE)
 - #157459 (rustc_target: callconv: powerpc64: Remove unreachable fallback code path)
 - #157658 (UnsafeCell: mention shared-ref-to-interior case, fix aliasing model inaccuracy)
 - #157698 (Remove an unnecessary cloning)
 - #157699 (Arg splat experiment - hir FnDecl impl)
 - #157713 (resolve: Remove exported imports from `maybe_unused_trait_imports`)
 - #157722 (Move create_scope_map to rustc_codegen_ssa.)
 - #157723 (Move uninhabited unreachable code lint to rustc_mir_transform)
 - #157725 (Keep generic suggestion for macro-expanded missing-type items)
 - #157733 (Remove old FIXMEs about nocapture attribute)
 - #157737 (Reorganize `tests/ui/issues` [7/N])
 - #157746 (supports_c_variadic_definitions: extend checklist for new targets)
 - #157763 (Move unused target expression error to appropriate place and rename it)
 - #157768 (codegen_ssa: peel trans. wrappers on scalable vecs)
@rust-bors rust-bors Bot merged commit fa96d9a into rust-lang:main Jun 12, 2026
12 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 12, 2026
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jun 13, 2026
Rollup of 24 pull requests

Successful merges:

 - rust-lang/rust#157716 (update Enzyme, June'26)
 - rust-lang/rust#149793 (Add inline asm support for amdgpu)
 - rust-lang/rust#155299 (make repr_transparent_non_zst_fields a hard error)
 - rust-lang/rust#157612 (Add a test where subtyping inhibits coercion.)
 - rust-lang/rust#157626 (Autogenerate unstable compiler flag stubs for unstable-book)
 - rust-lang/rust#157667 (Rename typing modes to better describe real usage)
 - rust-lang/rust#149749 (Make `BorrowedBuf` and `BorrowedCursor` generic over the data)
 - rust-lang/rust#155113 (Ensure Send/Sync impl for std::process::CommandArgs)
 - rust-lang/rust#156212 (Additionally gate negative bounds behind new `-Zinternal-testing-features`)
 - rust-lang/rust#157342 (Reduce verbosity of cycle errors when possible)
 - rust-lang/rust#157366 (Add a regression test for an unconstrained TransmuteFrom ICE)
 - rust-lang/rust#157459 (rustc_target: callconv: powerpc64: Remove unreachable fallback code path)
 - rust-lang/rust#157658 (UnsafeCell: mention shared-ref-to-interior case, fix aliasing model inaccuracy)
 - rust-lang/rust#157698 (Remove an unnecessary cloning)
 - rust-lang/rust#157699 (Arg splat experiment - hir FnDecl impl)
 - rust-lang/rust#157713 (resolve: Remove exported imports from `maybe_unused_trait_imports`)
 - rust-lang/rust#157722 (Move create_scope_map to rustc_codegen_ssa.)
 - rust-lang/rust#157723 (Move uninhabited unreachable code lint to rustc_mir_transform)
 - rust-lang/rust#157725 (Keep generic suggestion for macro-expanded missing-type items)
 - rust-lang/rust#157733 (Remove old FIXMEs about nocapture attribute)
 - rust-lang/rust#157737 (Reorganize `tests/ui/issues` [7/N])
 - rust-lang/rust#157746 (supports_c_variadic_definitions: extend checklist for new targets)
 - rust-lang/rust#157763 (Move unused target expression error to appropriate place and rename it)
 - rust-lang/rust#157768 (codegen_ssa: peel trans. wrappers on scalable vecs)
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.

dcx.try_steal_modify_and_emit_err race

3 participants