Skip to content

Improve generic parameters handling for #[diagnostic::on_const]#158347

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
rperier:diagnostic_on_const_format_arguments
Jul 10, 2026
Merged

Improve generic parameters handling for #[diagnostic::on_const]#158347
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
rperier:diagnostic_on_const_format_arguments

Conversation

@rperier

@rperier rperier commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

View all comments

cc #155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the Zparameter correctly. From what I have understood, it is an ty::Infer(ty::TyVar(_)) that is not correctly displayed via self.tcx.short_string() (in on_unimplemented_components()), or even not correctly inferred via self.infcx.ty_to_string().

EDIT: general descrition updated

@rustbot

rustbot commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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 24, 2026
@rustbot

rustbot commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
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 73 candidates
  • Random selection from 20 candidates

@rperier

rperier commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

cc @mejrs

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

r? me

This is a first proposal.

Can you explain this in words? We need to stabilize this at some point so we need to have this written down. There are three places that can have generics; the impl header, the trait and the type. And what about blanket impls?

For now it would be best if these rules are explained in the unstable book entry.

I will need some help for displaying the Z parameter correctly.

The thing is that I don't know myself what I'd expect 😆. I think I don't like _, but is it right to just print Z? Or is there some syntax to indicate that it's a non inferred type? Maybe like <Z>? 🤔 . I'm very open to ideas here. It's also an option to just lint against it and not display it at all.

View changes since this review

Comment thread compiler/rustc_passes/src/check_attr.rs Outdated
@rustbot rustbot assigned mejrs and unassigned TaKO8Ki Jun 24, 2026
@rperier

rperier commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

The thing is that I don't know myself what I'd expect 😆. I think I don't like _, but is it right to just print Z? Or is there some syntax to indicate that it's a non inferred type? Maybe like <Z>? 🤔 . I'm very open to ideas here. It's also an option to just lint against it and not display it at all.

Lint against it is a good idea, because it's verbose, you're probably not able to display the value for this generic parameter, so explaining why makes sense. Displaying _ as value is confusing, so I would display <Z>instead + lint against it. We cannot really "not display it at all", as it is already in the note field of the directive attribute (in the worst case it won't be expansed and left as is, in place).

My problem with the lint is that we should emit it from check_diagnostic_on_const (from rustc_passes), right? At this stage, we don't have much more informations about the GenericParam (in the sense of what it is really, inferred or not etc...), don't we ?

@mejrs

mejrs commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

IMO just printing Z is the least unsurprising behavior. I think in practice it boils down to how people use these attributes and what the error messages end up looking like.

@rperier

rperier commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

By "just printing Z" , you mean Z literrally or the value of Z ?

So the compiler output could be :

= note: Self = X<u8, &str>, Z = Z, A = u8, B = &str

or

= note: Self = X<u8, &str>, Z = _, A = u8, B = &str

plus a lint on the diagnostic attribute, highlighting the Z argument, explaining why it cannot be displayed. Without any lints, it could be confusing.

@mejrs

mejrs commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

By "just printing Z" , you mean Z literrally or the value of Z ?

We have been printing it literally for e.g. diagnostic::on_unimplemented if the generic isn't actually anywhere on the trait.

@rperier

rperier commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@rperier rperier force-pushed the diagnostic_on_const_format_arguments branch from c4dba6a to debf115 Compare July 1, 2026 07:02
@rustbot

This comment has been minimized.

@rperier

rperier commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

For now the lint part is under discussion on zulip (see my previous message).

@rperier

rperier commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

I have thought about it, I am taking a step back, I think we could do :

  1. Don't display Z at all, i.e remove it from the message, label and note attributes
  2. Replace Z=_ with Z=<Z>
  3. Leave Z=_ as is

1 and 2 are technically feasible, but are confusing for the user (he asks to display a generic parameter that is not shown). Lint against it from rustc_passes implies more work, as we don't know the right type informations at this stage. To be honest, 3. is not a problem, the type is not infered , so it is displayed as _ .

@rperier rperier force-pushed the diagnostic_on_const_format_arguments branch from debf115 to 4245bb5 Compare July 3, 2026 17:58
@rustbot

This comment has been minimized.

@mejrs

mejrs commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

In the absence of any convincing option, I think it would be best to just display Z. If someone pops up with a good argument for something else we can change it.

@rperier

rperier commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

We could display Z and... emit a lint from on_unimplemented_component (rustc_trait_selection) ? because at this stage we have all informations we need (which is not the case in rustc_passes) :)

@rust-log-analyzer

This comment has been minimized.

@mejrs

mejrs commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

We could display Z and... emit a lint from on_unimplemented_component (rustc_trait_selection) ? because at this stage we have all informations we need (which is not the case in rustc_passes) :)

on_unimplemented_component is called at error reporting time, which is when the user's code is compiled; not when the attribute is declared.

Also the user might write something like

#![feature(diagnostic_on_const, const_trait_impl)]

pub struct X<A, B> {
    field: (A, B),
}

pub const trait Y<Z> {
    fn blah(&self) {}
}

#[diagnostic::on_const(note = "Self = {Self}, Z = {Z}, A = {A}, B = {B}")]
impl<Z, A, B> Y<Z> for X<A, B> {}

const _: () = {
    Y::<u8>::blah(&X {
        field: (42_u8, "hello"),
    });
};

where there is a concrete type for Z. So we cannot know when the library (with the attribute) is compiled whether or not the generic parameter will have a concrete type or not.

@rperier rperier force-pushed the diagnostic_on_const_format_arguments branch from 4245bb5 to 2690be8 Compare July 7, 2026 16:43
@rustbot

This comment has been minimized.

@rperier

rperier commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

I am opened to suggestions and willing to help if there is anything else

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

The impl looks good to me, just some things need to be done w/r/t tests

@rustbot author

View changes since this review

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 7, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 8, 2026
…_arguments, r=mejrs

Improve generic parameters handling for #[diagnostic::on_const]

cc rust-lang#155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the `Z`parameter correctly. From what I have understood, it is an `ty::Infer(ty::TyVar(_))`  that is not correctly displayed via `self.tcx.short_string()` (in `on_unimplemented_components()`),  or even not correctly inferred via `self.infcx.ty_to_string()`.

EDIT: general descrition updated
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 8, 2026
…_arguments, r=mejrs

Improve generic parameters handling for #[diagnostic::on_const]

cc rust-lang#155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the `Z`parameter correctly. From what I have understood, it is an `ty::Infer(ty::TyVar(_))`  that is not correctly displayed via `self.tcx.short_string()` (in `on_unimplemented_components()`),  or even not correctly inferred via `self.infcx.ty_to_string()`.

EDIT: general descrition updated
rust-bors Bot pushed a commit that referenced this pull request Jul 8, 2026
…uwer

Rollup of 25 pull requests

Successful merges:

 - #158871 (add relnotes for 1.97.0)
 - #158968 (stdarch subtree update)
 - #154445 (rustdoc: Represent `--output-format=json` coverage and ir differently)
 - #156370 (Reject linked dylib EII default overrides)
 - #157153 (allow `Allocator`s to be used as `#[global_allocator]`s)
 - #158495 (Rename HAS_CT_PROJECTION to HAS_CONST_ALIAS)
 - #158617 (allow mGCA const arguments to fall back to anon consts)
 - #158645 (Fix splat ICEs and ban it in closures)
 - #158655 (Fix coroutine MIR saved local remapping)
 - #158666 (Carry the `b_offset` inside `BackendRepr::ScalarPair`)
 - #158912 (Introduce new bootstrap config section for PGO configuration)
 - #158920 (Update wasm-component-ld to 0.5.26)
 - #158926 (wrapping_sh* methods: clarify underspecified reference)
 - #158927 (add core test run with `-Zforce-intrinsic-fallback`)
 - #158932 (Do not build the compiler when invoking `x perf compare`)
 - #158937 (Emit the emscripten entry point as `__main_argc_argv`)
 - #151379 (Stabilize `VecDeque::retain_back` from `truncate_front`)
 - #156548 ( Library support for aarch64-unknown-linux-pauthtest target)
 - #158307 (CI job for parallel frontend ui tests)
 - #158347 (Improve generic parameters handling for #[diagnostic::on_const])
 - #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
 - #158741 (Simplify `Option::into_flat_iter` signature)
 - #158807 (Add regression test for CString::clone_into unwind safety)
 - #158862 (Fix the span for parameter suggestion )
 - #158883 (tests: fix enum-match.rs to handle LLVM 23)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 8, 2026
…_arguments, r=mejrs

Improve generic parameters handling for #[diagnostic::on_const]

cc rust-lang#155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the `Z`parameter correctly. From what I have understood, it is an `ty::Infer(ty::TyVar(_))`  that is not correctly displayed via `self.tcx.short_string()` (in `on_unimplemented_components()`),  or even not correctly inferred via `self.infcx.ty_to_string()`.

EDIT: general descrition updated
rust-bors Bot pushed a commit that referenced this pull request Jul 8, 2026
Rollup of 25 pull requests

Successful merges:

 - #158871 (add relnotes for 1.97.0)
 - #158968 (stdarch subtree update)
 - #157690 (codegen_ssa: pack small const aggregates into immediate stores)
 - #158541 (Move `std::io::Write` to `core::io`)
 - #154445 (rustdoc: Represent `--output-format=json` coverage and ir differently)
 - #156370 (Reject linked dylib EII default overrides)
 - #157153 (allow `Allocator`s to be used as `#[global_allocator]`s)
 - #158495 (Rename HAS_CT_PROJECTION to HAS_CONST_ALIAS)
 - #158617 (allow mGCA const arguments to fall back to anon consts)
 - #158645 (Fix splat ICEs and ban it in closures)
 - #158655 (Fix coroutine MIR saved local remapping)
 - #158666 (Carry the `b_offset` inside `BackendRepr::ScalarPair`)
 - #158870 (std: merge the unix-like io::error modules into one file)
 - #158920 (Update wasm-component-ld to 0.5.26)
 - #158926 (wrapping_sh* methods: clarify underspecified reference)
 - #158927 (add core test run with `-Zforce-intrinsic-fallback`)
 - #158932 (Do not build the compiler when invoking `x perf compare`)
 - #158937 (Emit the emscripten entry point as `__main_argc_argv`)
 - #151379 (Stabilize `VecDeque::retain_back` from `truncate_front`)
 - #156144 (Better docs for PartialEq (includes macro rename))
 - #156548 ( Library support for aarch64-unknown-linux-pauthtest target)
 - #158307 (CI job for parallel frontend ui tests)
 - #158347 (Improve generic parameters handling for #[diagnostic::on_const])
 - #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
 - #158741 (Simplify `Option::into_flat_iter` signature)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
…_arguments, r=mejrs

Improve generic parameters handling for #[diagnostic::on_const]

cc rust-lang#155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the `Z`parameter correctly. From what I have understood, it is an `ty::Infer(ty::TyVar(_))`  that is not correctly displayed via `self.tcx.short_string()` (in `on_unimplemented_components()`),  or even not correctly inferred via `self.infcx.ty_to_string()`.

EDIT: general descrition updated
rust-bors Bot pushed a commit that referenced this pull request Jul 9, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets)
 - #158541 (Move `std::io::Write` to `core::io`)
 - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`)
 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #156370 (Reject linked dylib EII default overrides)
 - #157153 (allow `Allocator`s to be used as `#[global_allocator]`s)
 - #158535 (Support `#[track_caller]` on EII declarations)
 - #158617 (allow mGCA const arguments to fall back to anon consts)
 - #158645 (Fix splat ICEs and ban it in closures)
 - #158988 (Redo `TokenStreamIter`)
 - #158347 (Improve generic parameters handling for #[diagnostic::on_const])
 - #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
 - #158739 (view-types: HIR lowering)
 - #158883 (tests: fix enum-match.rs to handle LLVM 23)
 - #158886 (Add documentation for the `no_std` attribute)
 - #158951 (Merge three `MaxUniverse`s into one)
 - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
…_arguments, r=mejrs

Improve generic parameters handling for #[diagnostic::on_const]

cc rust-lang#155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the `Z`parameter correctly. From what I have understood, it is an `ty::Infer(ty::TyVar(_))`  that is not correctly displayed via `self.tcx.short_string()` (in `on_unimplemented_components()`),  or even not correctly inferred via `self.infcx.ty_to_string()`.

EDIT: general descrition updated
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
…_arguments, r=mejrs

Improve generic parameters handling for #[diagnostic::on_const]

cc rust-lang#155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the `Z`parameter correctly. From what I have understood, it is an `ty::Infer(ty::TyVar(_))`  that is not correctly displayed via `self.tcx.short_string()` (in `on_unimplemented_components()`),  or even not correctly inferred via `self.infcx.ty_to_string()`.

EDIT: general descrition updated
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
…_arguments, r=mejrs

Improve generic parameters handling for #[diagnostic::on_const]

cc rust-lang#155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the `Z`parameter correctly. From what I have understood, it is an `ty::Infer(ty::TyVar(_))`  that is not correctly displayed via `self.tcx.short_string()` (in `on_unimplemented_components()`),  or even not correctly inferred via `self.infcx.ty_to_string()`.

EDIT: general descrition updated
rust-bors Bot pushed a commit that referenced this pull request Jul 9, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #150946 (intrinsics: Add a fallback for non-const libm float functions)
 - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets)
 - #158541 (Move `std::io::Write` to `core::io`)
 - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`)
 - #155429 (Support `u128`/`i128` c-variadic arguments)
 - #156370 (Reject linked dylib EII default overrides)
 - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`)
 - #158617 (allow mGCA const arguments to fall back to anon consts)
 - #158645 (Fix splat ICEs and ban it in closures)
 - #158859 (Improve `-Zls` diagnostic message on `.rs` files)
 - #158988 (Redo `TokenStreamIter`)
 - #158347 (Improve generic parameters handling for #[diagnostic::on_const])
 - #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
 - #158739 (view-types: HIR lowering)
 - #158883 (tests: fix enum-match.rs to handle LLVM 23)
 - #158886 (Add documentation for the `no_std` attribute)
 - #158940 (Implement feature `char_to_u32`)
 - #158951 (Merge three `MaxUniverse`s into one)
 - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
 - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
 - #159005 (Use `as_lang_item` instead of repeatedly matching)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 9, 2026
…_arguments, r=mejrs

Improve generic parameters handling for #[diagnostic::on_const]

cc rust-lang#155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the `Z`parameter correctly. From what I have understood, it is an `ty::Infer(ty::TyVar(_))`  that is not correctly displayed via `self.tcx.short_string()` (in `on_unimplemented_components()`),  or even not correctly inferred via `self.infcx.ty_to_string()`.

EDIT: general descrition updated
rust-bors Bot pushed a commit that referenced this pull request Jul 9, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #150946 (intrinsics: Add a fallback for non-const libm float functions)
 - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets)
 - #158541 (Move `std::io::Write` to `core::io`)
 - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`)
 - #156027 (Consider captured regions for opaque type region liveness.)
 - #156370 (Reject linked dylib EII default overrides)
 - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`)
 - #157561 (rustdoc: do not include extra stuff in span)
 - #158617 (allow mGCA const arguments to fall back to anon consts)
 - #158645 (Fix splat ICEs and ban it in closures)
 - #158859 (Improve `-Zls` diagnostic message on `.rs` files)
 - #158988 (Redo `TokenStreamIter`)
 - #158347 (Improve generic parameters handling for #[diagnostic::on_const])
 - #158384 (Allow BackwardIncompatibleDropHint in polonius legacy)
 - #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
 - #158739 (view-types: HIR lowering)
 - #158877 (borrowck: Keep returned `path` from `best_blame_constraint()` consistent)
 - #158883 (tests: fix enum-match.rs to handle LLVM 23)
 - #158886 (Add documentation for the `no_std` attribute)
 - #158940 (Implement feature `char_to_u32`)
 - #158951 (Merge three `MaxUniverse`s into one)
 - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
 - #158995 (Use REST API in linkchecker script)
 - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 9, 2026
…_arguments, r=mejrs

Improve generic parameters handling for #[diagnostic::on_const]

cc rust-lang#155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the `Z`parameter correctly. From what I have understood, it is an `ty::Infer(ty::TyVar(_))`  that is not correctly displayed via `self.tcx.short_string()` (in `on_unimplemented_components()`),  or even not correctly inferred via `self.infcx.ty_to_string()`.

EDIT: general descrition updated
rust-bors Bot pushed a commit that referenced this pull request Jul 10, 2026
Rollup of 24 pull requests

Successful merges:

 - #150946 (intrinsics: Add a fallback for non-const libm float functions)
 - #158541 (Move `std::io::Write` to `core::io`)
 - #156027 (Consider captured regions for opaque type region liveness.)
 - #156370 (Reject linked dylib EII default overrides)
 - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`)
 - #157561 (rustdoc: do not include extra stuff in span)
 - #158617 (allow mGCA const arguments to fall back to anon consts)
 - #158645 (Fix splat ICEs and ban it in closures)
 - #158859 (Improve `-Zls` diagnostic message on `.rs` files)
 - #158988 (Redo `TokenStreamIter`)
 - #158347 (Improve generic parameters handling for #[diagnostic::on_const])
 - #158384 (Allow BackwardIncompatibleDropHint in polonius legacy)
 - #158722 (delegation: do not always inherit `ConstArgHasType` predicates)
 - #158739 (view-types: HIR lowering)
 - #158877 (borrowck: Keep returned `path` from `best_blame_constraint()` consistent)
 - #158883 (tests: fix enum-match.rs to handle LLVM 23)
 - #158886 (Add documentation for the `no_std` attribute)
 - #158940 (Implement feature `char_to_u32`)
 - #158951 (Merge three `MaxUniverse`s into one)
 - #158960 (Fix bootstrap submodule path prefix matching)
 - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
 - #158995 (Use REST API in linkchecker script)
 - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
 - #159036 (bootstrap: expand '@argfile' arguments to rustc shim)
@rust-bors rust-bors Bot merged commit 343a91c into rust-lang:main Jul 10, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 10, 2026
rust-timer added a commit that referenced this pull request Jul 10, 2026
Rollup merge of #158347 - rperier:diagnostic_on_const_format_arguments, r=mejrs

Improve generic parameters handling for #[diagnostic::on_const]

cc #155570

This Improves generic parameters handling for #[diagnostic::on_const]
This is done by printing generics parameters when these are concrete Adt generics args.
A lint is emitted we try to format a generic that is found anywhere.
Moreover, generics parameters that are ty infer vars are no longer displayed
"as-is", it is not clear and might be confusing, in this specific case the
name of the generic parameter will be displayed instead.

I will need some help for displaying the `Z`parameter correctly. From what I have understood, it is an `ty::Infer(ty::TyVar(_))`  that is not correctly displayed via `self.tcx.short_string()` (in `on_unimplemented_components()`),  or even not correctly inferred via `self.infcx.ty_to_string()`.

EDIT: general descrition updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) 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.

5 participants