Skip to content

Commit 9396ab2

Browse files
Rollup merge of #154293 - reddevilmidzy:type-diag, r=fmease
Use verbose span suggestion for type const close: #154214 r? fmease
2 parents ef18725 + e039838 commit 9396ab2

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2947,7 +2947,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
29472947
);
29482948
if def_id.is_local() {
29492949
let name = tcx.def_path_str(def_id);
2950-
err.span_suggestion(
2950+
err.span_suggestion_verbose(
29512951
tcx.def_span(def_id).shrink_to_lo(),
29522952
format!("add `type` before `const` for `{name}`"),
29532953
format!("type "),
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
error: use of `const` in the type system not defined as `type const`
22
--> $DIR/assoc-const-without-type_const.rs:8:35
33
|
4-
LL | const SIZE: usize;
5-
| - help: add `type` before `const` for `Tr::SIZE`: `type`
6-
...
74
LL | fn mk_array<T: Tr>(_x: T) -> [(); T::SIZE] {
85
| ^^^^^^^
6+
|
7+
help: add `type` before `const` for `Tr::SIZE`
8+
|
9+
LL | type const SIZE: usize;
10+
| ++++
911

1012
error: use of `const` in the type system not defined as `type const`
1113
--> $DIR/assoc-const-without-type_const.rs:10:10
1214
|
13-
LL | const SIZE: usize;
14-
| - help: add `type` before `const` for `Tr::SIZE`: `type`
15-
...
1615
LL | [(); T::SIZE]
1716
| ^^^^^^^
17+
|
18+
help: add `type` before `const` for `Tr::SIZE`
19+
|
20+
LL | type const SIZE: usize;
21+
| ++++
1822

1923
error: aborting due to 2 previous errors
2024

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
error: use of `const` in the type system not defined as `type const`
22
--> $DIR/unmarked-free-const.rs:9:18
33
|
4-
LL | const N: usize = 4;
5-
| - help: add `type` before `const` for `N`: `type`
6-
...
74
LL | let x = [(); N];
85
| ^
6+
|
7+
help: add `type` before `const` for `N`
8+
|
9+
LL | type const N: usize = 4;
10+
| ++++
911

1012
error: aborting due to 1 previous error
1113

0 commit comments

Comments
 (0)