Skip to content

Commit 344cd47

Browse files
committed
do not use <: in subtyping overflow msg
1 parent db052d6 commit 344cd47

15 files changed

+35
-22
lines changed

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

+20-7
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,26 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
299299
}
300300
OverflowCause::TraitSolver(predicate) => {
301301
let predicate = self.resolve_vars_if_possible(predicate);
302-
let pred_str = with_short_path(self.tcx, predicate);
303-
struct_span_code_err!(
304-
self.dcx(),
305-
span,
306-
E0275,
307-
"overflow evaluating the requirement `{pred_str}`",
308-
)
302+
match predicate.kind().skip_binder() {
303+
ty::PredicateKind::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ })
304+
| ty::PredicateKind::Coerce(ty::CoercePredicate { a, b }) => {
305+
struct_span_code_err!(
306+
self.dcx(),
307+
span,
308+
E0275,
309+
"overflow setting `{a}` to a subtype of `{b}`",
310+
)
311+
}
312+
_ => {
313+
let pred_str = with_short_path(self.tcx, predicate);
314+
struct_span_code_err!(
315+
self.dcx(),
316+
span,
317+
E0275,
318+
"overflow evaluating the requirement `{pred_str}`",
319+
)
320+
}
321+
}
309322
}
310323
};
311324

tests/ui/impl-trait/issues/issue-84073.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ where
2929
}
3030

3131
fn main() {
32-
Race::new(|race| race.when()); //~ ERROR overflow evaluating the requirement `_ <: Option<_>`
32+
Race::new(|race| race.when()); //~ ERROR overflow setting `_` to a subtype of `Option<_>`
3333
}

tests/ui/impl-trait/issues/issue-84073.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0275]: overflow evaluating the requirement `_ <: Option<_>`
1+
error[E0275]: overflow setting `_` to a subtype of `Option<_>`
22
--> $DIR/issue-84073.rs:32:22
33
|
44
LL | Race::new(|race| race.when());

tests/ui/infinite/infinite-autoderef.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn main() {
1414
let mut x;
1515
loop {
1616
x = Box::new(x);
17-
//~^ ERROR overflow evaluating the requirement `Box<_> <: _`
17+
//~^ ERROR overflow setting `Box<_>` to a subtype of `_`
1818
x.foo;
1919
x.bar();
2020
}

tests/ui/infinite/infinite-autoderef.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0275]: overflow evaluating the requirement `Box<_> <: _`
1+
error[E0275]: overflow setting `Box<_>` to a subtype of `_`
22
--> $DIR/infinite-autoderef.rs:16:13
33
|
44
LL | x = Box::new(x);

tests/ui/occurs-check-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ fn main() {
55

66
g = f;
77
f = Box::new(g);
8-
//~^ ERROR overflow evaluating the requirement `Box<_> <: _`
8+
//~^ ERROR overflow setting `Box<_>` to a subtype of `_`
99
}

tests/ui/occurs-check-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0275]: overflow evaluating the requirement `Box<_> <: _`
1+
error[E0275]: overflow setting `Box<_>` to a subtype of `_`
22
--> $DIR/occurs-check-2.rs:7:9
33
|
44
LL | f = Box::new(g);

tests/ui/occurs-check-3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ enum Clam<T> { A(T) }
44
fn main() {
55
let c;
66
c = Clam::A(c);
7-
//~^ ERROR overflow evaluating the requirement `Clam<_> <: _`
7+
//~^ ERROR overflow setting `Clam<_>` to a subtype of `_`
88
match c {
99
Clam::A::<isize>(_) => { }
1010
}

tests/ui/occurs-check-3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0275]: overflow evaluating the requirement `Clam<_> <: _`
1+
error[E0275]: overflow setting `Clam<_>` to a subtype of `_`
22
--> $DIR/occurs-check-3.rs:6:9
33
|
44
LL | c = Clam::A(c);

tests/ui/occurs-check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn main() {
22
let f;
33
f = Box::new(f);
4-
//~^ ERROR overflow evaluating the requirement `Box<_> <: _`
4+
//~^ ERROR overflow setting `Box<_>` to a subtype of `_`
55
}

tests/ui/occurs-check.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0275]: overflow evaluating the requirement `Box<_> <: _`
1+
error[E0275]: overflow setting `Box<_>` to a subtype of `_`
22
--> $DIR/occurs-check.rs:3:9
33
|
44
LL | f = Box::new(f);

tests/ui/traits/subtype-recursion-limit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010
let x = return;
1111
let y = return;
1212
let mut w = (x, y);
13-
//~^ ERROR overflow evaluating the requirement
13+
//~^ ERROR overflow setting `_` to a subtype of `*const _`
1414
// Avoid creating lifetimes, `Sized` bounds or function calls.
1515
let a = (ptr::addr_of!(y), ptr::addr_of!(x));
1616
w = a;

tests/ui/traits/subtype-recursion-limit.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0275]: overflow evaluating the requirement `_ <: *const _`
1+
error[E0275]: overflow setting `_` to a subtype of `*const _`
22
--> $DIR/subtype-recursion-limit.rs:12:17
33
|
44
LL | let mut w = (x, y);

tests/ui/traits/well-formed-recursion-limit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pub fn iso_un_option<A: 'static, B: 'static>(i: ISO<Option<A>, Option<B>>) -> IS
1313
//~^ ERROR no field `ab` on type
1414
//~| ERROR no field `ba` on type
1515
let left = move |o_a| match o_a {
16-
//~^ ERROR overflow evaluating the requirement
17-
None => panic!("absured"),
16+
//~^ ERROR overflow setting `_` to a subtype of `Option<_>`
17+
None => panic!("absurd"),
1818
Some(a) => a,
1919
};
2020
let right = move |o_b| match o_b {

tests/ui/traits/well-formed-recursion-limit.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0609]: no field `ba` on type `(Box<(dyn Fn(Option<A>) -> Option<B> + 'sta
1010
LL | let (ab, ba) = (i.ab, i.ba);
1111
| ^^ unknown field
1212

13-
error[E0275]: overflow evaluating the requirement `_ <: Option<_>`
13+
error[E0275]: overflow setting `_` to a subtype of `Option<_>`
1414
--> $DIR/well-formed-recursion-limit.rs:15:33
1515
|
1616
LL | let left = move |o_a| match o_a {

0 commit comments

Comments
 (0)