Skip to content

Commit

Permalink
do not use <: in subtyping overflow msg
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jan 19, 2024
1 parent d5e2221 commit 42a3816
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,26 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}
OverflowCause::TraitSolver(predicate) => {
let predicate = self.resolve_vars_if_possible(predicate);
let pred_str = with_short_path(self.tcx, predicate);
struct_span_code_err!(
self.dcx(),
span,
E0275,
"overflow evaluating the requirement `{pred_str}`",
)
match predicate.kind().skip_binder() {
ty::PredicateKind::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ })
| ty::PredicateKind::Coerce(ty::CoercePredicate { a, b }) => {
struct_span_code_err!(
self.dcx(),
span,
E0275,
"overflow setting `{a}` to a subtype of `{b}`",
)
}
_ => {
let pred_str = with_short_path(self.tcx, predicate);
struct_span_code_err!(
self.dcx(),
span,
E0275,
"overflow evaluating the requirement `{pred_str}`",
)
}
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/impl-trait/issues/issue-84073.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ where
}

fn main() {
Race::new(|race| race.when()); //~ ERROR overflow evaluating the requirement `_ <: Option<_>`
Race::new(|race| race.when()); //~ ERROR overflow setting `_` to a subtype of `Option<_>`
}
2 changes: 1 addition & 1 deletion tests/ui/impl-trait/issues/issue-84073.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0275]: overflow evaluating the requirement `_ <: Option<_>`
error[E0275]: overflow setting `_` to a subtype of `Option<_>`
--> $DIR/issue-84073.rs:32:22
|
LL | Race::new(|race| race.when());
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/infinite/infinite-autoderef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn main() {
let mut x;
loop {
x = Box::new(x);
//~^ ERROR overflow evaluating the requirement `Box<_> <: _`
//~^ ERROR overflow setting `Box<_>` to a subtype of `_`
x.foo;
x.bar();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/infinite/infinite-autoderef.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0275]: overflow evaluating the requirement `Box<_> <: _`
error[E0275]: overflow setting `Box<_>` to a subtype of `_`
--> $DIR/infinite-autoderef.rs:16:13
|
LL | x = Box::new(x);
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/occurs-check-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ fn main() {

g = f;
f = Box::new(g);
//~^ ERROR overflow evaluating the requirement `Box<_> <: _`
//~^ ERROR overflow setting `Box<_>` to a subtype of `_`
}
2 changes: 1 addition & 1 deletion tests/ui/occurs-check-2.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0275]: overflow evaluating the requirement `Box<_> <: _`
error[E0275]: overflow setting `Box<_>` to a subtype of `_`
--> $DIR/occurs-check-2.rs:7:9
|
LL | f = Box::new(g);
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/occurs-check-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ enum Clam<T> { A(T) }
fn main() {
let c;
c = Clam::A(c);
//~^ ERROR overflow evaluating the requirement `Clam<_> <: _`
//~^ ERROR overflow setting `Clam<_>` to a subtype of `_`
match c {
Clam::A::<isize>(_) => { }
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/occurs-check-3.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0275]: overflow evaluating the requirement `Clam<_> <: _`
error[E0275]: overflow setting `Clam<_>` to a subtype of `_`
--> $DIR/occurs-check-3.rs:6:9
|
LL | c = Clam::A(c);
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/occurs-check.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {
let f;
f = Box::new(f);
//~^ ERROR overflow evaluating the requirement `Box<_> <: _`
//~^ ERROR overflow setting `Box<_>` to a subtype of `_`
}
2 changes: 1 addition & 1 deletion tests/ui/occurs-check.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0275]: overflow evaluating the requirement `Box<_> <: _`
error[E0275]: overflow setting `Box<_>` to a subtype of `_`
--> $DIR/occurs-check.rs:3:9
|
LL | f = Box::new(f);
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/traits/subtype-recursion-limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() {
let x = return;
let y = return;
let mut w = (x, y);
//~^ ERROR overflow evaluating the requirement
//~^ ERROR overflow setting `_` to a subtype of `*const _`
// Avoid creating lifetimes, `Sized` bounds or function calls.
let a = (ptr::addr_of!(y), ptr::addr_of!(x));
w = a;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/traits/subtype-recursion-limit.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0275]: overflow evaluating the requirement `_ <: *const _`
error[E0275]: overflow setting `_` to a subtype of `*const _`
--> $DIR/subtype-recursion-limit.rs:12:17
|
LL | let mut w = (x, y);
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/traits/well-formed-recursion-limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub fn iso_un_option<A: 'static, B: 'static>(i: ISO<Option<A>, Option<B>>) -> IS
//~^ ERROR no field `ab` on type
//~| ERROR no field `ba` on type
let left = move |o_a| match o_a {
//~^ ERROR overflow evaluating the requirement
None => panic!("absured"),
//~^ ERROR overflow setting `_` to a subtype of `Option<_>`
None => panic!("absurd"),
Some(a) => a,
};
let right = move |o_b| match o_b {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/traits/well-formed-recursion-limit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error[E0609]: no field `ba` on type `(Box<(dyn Fn(Option<A>) -> Option<B> + 'sta
LL | let (ab, ba) = (i.ab, i.ba);
| ^^ unknown field

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

0 comments on commit 42a3816

Please sign in to comment.