Skip to content

Commit 7275f7e

Browse files
authored
Rollup merge of #154564 - estebank:tweak-wf-errors, r=Kivooeo
Tweak wording of E0275 WF errors Modify the main error message to read better: ``` error[E0275]: overflow evaluating whether `&'a mut Bar` is well-formed ```
2 parents a2cc7a9 + dae0c01 commit 7275f7e

16 files changed

Lines changed: 34 additions & 25 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
9999
"overflow assigning `{a}` to `{b}`",
100100
)
101101
}
102+
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
103+
let term = with_short_path(self.tcx, term);
104+
struct_span_code_err!(
105+
self.dcx(),
106+
span,
107+
E0275,
108+
"overflow evaluating whether `{term}` is well-formed",
109+
)
110+
}
102111
_ => {
103112
let pred_str = with_short_path(self.tcx, predicate);
104113
struct_span_code_err!(

tests/ui/associated-types/issue-64855-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
// also inadvertently a test for the (non-)co-inductiveness of WF predicates.
44

55
pub struct Bar<'a>(&'a Self) where Self: ;
6-
//~^ ERROR overflow evaluating the requirement `Bar<'a> well-formed`
6+
//~^ ERROR overflow evaluating whether `Bar<'a>` is well-formed
77

88
fn main() {}

tests/ui/associated-types/issue-64855-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0275]: overflow evaluating the requirement `Bar<'a> well-formed`
1+
error[E0275]: overflow evaluating whether `Bar<'a>` is well-formed
22
--> $DIR/issue-64855-2.rs:5:36
33
|
44
LL | pub struct Bar<'a>(&'a Self) where Self: ;

tests/ui/associated-types/issue-64855.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ pub trait Foo {
88

99
pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
1010
//~^ ERROR the trait bound `Bar<T>: Foo` is not satisfied
11-
//~| ERROR overflow evaluating the requirement `Bar<T> well-formed`
11+
//~| ERROR overflow evaluating whether `Bar<T>` is well-formed
1212

1313
fn main() {}

tests/ui/associated-types/issue-64855.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ help: this trait has no implementations, consider adding one
1515
LL | pub trait Foo {
1616
| ^^^^^^^^^^^^^
1717

18-
error[E0275]: overflow evaluating the requirement `Bar<T> well-formed`
18+
error[E0275]: overflow evaluating whether `Bar<T>` is well-formed
1919
--> $DIR/issue-64855.rs:9:46
2020
|
2121
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;

tests/ui/const-generics/generic_const_exprs/adt_wf_hang.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ struct U;
99
struct S<const N: U>()
1010
where
1111
S<{ U }>:;
12-
//~^ ERROR: overflow evaluating the requirement `S<{ U }> well-formed`
12+
//~^ ERROR: overflow evaluating whether `S<{ U }>` is well-formed
1313

1414
fn main() {}

tests/ui/const-generics/generic_const_exprs/adt_wf_hang.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0275]: overflow evaluating the requirement `S<{ U }> well-formed`
1+
error[E0275]: overflow evaluating whether `S<{ U }>` is well-formed
22
--> $DIR/adt_wf_hang.rs:11:5
33
|
44
LL | S<{ U }>:;

tests/ui/const-generics/mgca/const-ctor-overflow-eval.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ use std::marker::ConstParamTy;
66
struct U;
77

88
#[derive(ConstParamTy, PartialEq, Eq)]
9-
//~^ ERROR overflow evaluating the requirement `S<U> well-formed`
10-
//~| ERROR overflow evaluating the requirement `S<U> well-formed`
9+
//~^ ERROR overflow evaluating whether `S<U>` is well-formed
10+
//~| ERROR overflow evaluating whether `S<U>` is well-formed
1111

1212
struct S<const N: U>()
1313
where
1414
S<{ U }>:;
15-
//~^ ERROR overflow evaluating the requirement `S<U> well-formed`
16-
//~| ERROR overflow evaluating the requirement `S<U> well-formed`
17-
//~| ERROR overflow evaluating the requirement `S<U> well-formed`
15+
//~^ ERROR overflow evaluating whether `S<U>` is well-formed
16+
//~| ERROR overflow evaluating whether `S<U>` is well-formed
17+
//~| ERROR overflow evaluating whether `S<U>` is well-formed
1818

1919
fn main() {}

tests/ui/const-generics/mgca/const-ctor-overflow-eval.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0275]: overflow evaluating the requirement `S<U> well-formed`
1+
error[E0275]: overflow evaluating whether `S<U>` is well-formed
22
--> $DIR/const-ctor-overflow-eval.rs:14:5
33
|
44
LL | S<{ U }>:;
@@ -13,7 +13,7 @@ LL | where
1313
LL | S<{ U }>:;
1414
| ^^^^^^^^ required by this bound in `S`
1515

16-
error[E0275]: overflow evaluating the requirement `S<U> well-formed`
16+
error[E0275]: overflow evaluating whether `S<U>` is well-formed
1717
--> $DIR/const-ctor-overflow-eval.rs:14:5
1818
|
1919
LL | S<{ U }>:;
@@ -29,7 +29,7 @@ LL | S<{ U }>:;
2929
| ^^^^^^^^ required by this bound in `S`
3030
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3131

32-
error[E0275]: overflow evaluating the requirement `S<U> well-formed`
32+
error[E0275]: overflow evaluating whether `S<U>` is well-formed
3333
--> $DIR/const-ctor-overflow-eval.rs:14:5
3434
|
3535
LL | S<{ U }>:;
@@ -45,7 +45,7 @@ LL | S<{ U }>:;
4545
| ^^^^^^^^ required by this bound in `S`
4646
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
4747

48-
error[E0275]: overflow evaluating the requirement `S<U> well-formed`
48+
error[E0275]: overflow evaluating whether `S<U>` is well-formed
4949
--> $DIR/const-ctor-overflow-eval.rs:8:24
5050
|
5151
LL | #[derive(ConstParamTy, PartialEq, Eq)]
@@ -60,7 +60,7 @@ LL | where
6060
LL | S<{ U }>:;
6161
| ^^^^^^^^ required by this bound in `S`
6262

63-
error[E0275]: overflow evaluating the requirement `S<U> well-formed`
63+
error[E0275]: overflow evaluating whether `S<U>` is well-formed
6464
--> $DIR/const-ctor-overflow-eval.rs:8:35
6565
|
6666
LL | #[derive(ConstParamTy, PartialEq, Eq)]

tests/ui/higher-ranked/trait-bounds/issue-95230.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
pub struct Bar
66
where
77
for<'a> &'a mut Self:;
8-
//~^ ERROR overflow evaluating the requirement `for<'a> &'a mut Bar well-formed`
8+
//~^ ERROR: overflow evaluating whether `&'a mut Bar` is well-formed
99

1010
fn main() {}

0 commit comments

Comments
 (0)