Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2947,7 +2947,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
);
if def_id.is_local() {
let name = tcx.def_path_str(def_id);
err.span_suggestion(
err.span_suggestion_verbose(
Copy link
Copy Markdown
Member

@fmease fmease Mar 24, 2026

Choose a reason for hiding this comment

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

Instead of a regression test, if you want to you can a short comment explaining why the suggestion is meant to be verbose (but you really don't need to).

In case you do want to a add a comment: I'm thinking of sth. like

Suggested change
err.span_suggestion_verbose(
// Verbose since an inline suggestion would look too confusing. See #154214.
err.span_suggestion_verbose(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks! I’ll skip the comment for now since the change is pretty small and clear.

tcx.def_span(def_id).shrink_to_lo(),
format!("add `type` before `const` for `{name}`"),
format!("type "),
Expand Down
16 changes: 10 additions & 6 deletions tests/ui/const-generics/mgca/assoc-const-without-type_const.stderr
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
error: use of `const` in the type system not defined as `type const`
--> $DIR/assoc-const-without-type_const.rs:8:35
|
LL | const SIZE: usize;
| - help: add `type` before `const` for `Tr::SIZE`: `type`
...
LL | fn mk_array<T: Tr>(_x: T) -> [(); T::SIZE] {
| ^^^^^^^
|
help: add `type` before `const` for `Tr::SIZE`
|
LL | type const SIZE: usize;
| ++++

error: use of `const` in the type system not defined as `type const`
--> $DIR/assoc-const-without-type_const.rs:10:10
|
LL | const SIZE: usize;
| - help: add `type` before `const` for `Tr::SIZE`: `type`
...
LL | [(); T::SIZE]
| ^^^^^^^
|
help: add `type` before `const` for `Tr::SIZE`
|
LL | type const SIZE: usize;
| ++++

error: aborting due to 2 previous errors

8 changes: 5 additions & 3 deletions tests/ui/const-generics/mgca/unmarked-free-const.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
error: use of `const` in the type system not defined as `type const`
--> $DIR/unmarked-free-const.rs:9:18
|
LL | const N: usize = 4;
| - help: add `type` before `const` for `N`: `type`
...
LL | let x = [(); N];
| ^
|
help: add `type` before `const` for `N`
|
LL | type const N: usize = 4;
| ++++

error: aborting due to 1 previous error

Loading