Skip to content

Commit a846615

Browse files
authored
Unrolled build for #146894
Rollup merge of #146894 - tiif:suggest_feature_attr, r=BoxyUwU Improve derive suggestion of const param Make the suggestion not to remove the adt and use the name of the adt variant in the diagnostic. r? `@BoxyUwU`
2 parents bbcbc78 + 3028935 commit a846615

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,17 +1305,20 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13051305
{
13061306
if ty.is_structural_eq_shallow(self.tcx) {
13071307
diag.span_suggestion(
1308-
span,
1309-
"add `#[derive(ConstParamTy)]` to the struct",
1308+
span.shrink_to_lo(),
1309+
format!("add `#[derive(ConstParamTy)]` to the {}", def.descr()),
13101310
"#[derive(ConstParamTy)]\n",
13111311
Applicability::MachineApplicable,
13121312
);
13131313
} else {
13141314
// FIXME(adt_const_params): We should check there's not already an
13151315
// overlapping `Eq`/`PartialEq` impl.
13161316
diag.span_suggestion(
1317-
span,
1318-
"add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct",
1317+
span.shrink_to_lo(),
1318+
format!(
1319+
"add `#[derive(ConstParamTy, PartialEq, Eq)]` to the {}",
1320+
def.descr()
1321+
),
13191322
"#[derive(ConstParamTy, PartialEq, Eq)]\n",
13201323
Applicability::MachineApplicable,
13211324
);

tests/ui/const-generics/forbid-non-structural_match-types.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ LL | struct D<const X: C>;
66
|
77
help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct
88
|
9-
LL - struct C;
109
LL + #[derive(ConstParamTy, PartialEq, Eq)]
10+
LL | struct C;
1111
|
1212

1313
error: aborting due to 1 previous error

tests/ui/const-generics/issue-80471.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ error[E0741]: `Nat` must implement `ConstParamTy` to be used as the type of a co
44
LL | fn foo<const N: Nat>() {}
55
| ^^^
66
|
7-
help: add `#[derive(ConstParamTy)]` to the struct
7+
help: add `#[derive(ConstParamTy)]` to the enum
88
|
9-
LL - enum Nat {
109
LL + #[derive(ConstParamTy)]
10+
LL | enum Nat {
1111
|
1212

1313
error: aborting due to 1 previous error

tests/ui/const-generics/issues/issue-97278.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ error[E0741]: `Bar` must implement `ConstParamTy` to be used as the type of a co
44
LL | fn test<const BAR: Bar>() {}
55
| ^^^
66
|
7-
help: add `#[derive(ConstParamTy)]` to the struct
7+
help: add `#[derive(ConstParamTy)]` to the enum
88
|
9-
LL - enum Bar {
109
LL + #[derive(ConstParamTy)]
10+
LL | enum Bar {
1111
|
1212

1313
error: aborting due to 1 previous error

tests/ui/consts/refs_check_const_eq-issue-88384.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ LL | struct Foo<const T: CompileTimeSettings>;
1515
|
1616
help: add `#[derive(ConstParamTy)]` to the struct
1717
|
18-
LL - struct CompileTimeSettings {
1918
LL + #[derive(ConstParamTy)]
19+
LL | struct CompileTimeSettings {
2020
|
2121

2222
error[E0741]: `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter
@@ -27,8 +27,8 @@ LL | impl<const T: CompileTimeSettings> Foo<T> {
2727
|
2828
help: add `#[derive(ConstParamTy)]` to the struct
2929
|
30-
LL - struct CompileTimeSettings {
3130
LL + #[derive(ConstParamTy)]
31+
LL | struct CompileTimeSettings {
3232
|
3333

3434
error: aborting due to 2 previous errors; 1 warning emitted

0 commit comments

Comments
 (0)