diff options
| author | lcnr <rust@lcnr.de> | 2024-01-15 15:31:30 +0100 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2024-02-22 17:43:59 +0100 |
| commit | 49dc0f22f43e54f6ddac568f3773d8cae63aeaac (patch) | |
| tree | 60d5ff249035a6104ca90800f8aecfb1d696546d | |
| parent | f7cdff825c9a8087406ce56792e07d19f2d04e17 (diff) | |
| download | rust-49dc0f22f43e54f6ddac568f3773d8cae63aeaac.tar.gz rust-49dc0f22f43e54f6ddac568f3773d8cae63aeaac.zip | |
do not use <: in subtyping overflow msg
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs | 27 | ||||
| -rw-r--r-- | tests/ui/impl-trait/issues/issue-84073.rs | 2 | ||||
| -rw-r--r-- | tests/ui/impl-trait/issues/issue-84073.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/infinite/infinite-autoderef.rs | 2 | ||||
| -rw-r--r-- | tests/ui/infinite/infinite-autoderef.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/occurs-check-2.rs | 2 | ||||
| -rw-r--r-- | tests/ui/occurs-check-2.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/occurs-check-3.rs | 2 | ||||
| -rw-r--r-- | tests/ui/occurs-check-3.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/occurs-check.rs | 2 | ||||
| -rw-r--r-- | tests/ui/occurs-check.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/traits/subtype-recursion-limit.rs | 2 | ||||
| -rw-r--r-- | tests/ui/traits/subtype-recursion-limit.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/traits/well-formed-recursion-limit.rs | 4 | ||||
| -rw-r--r-- | tests/ui/traits/well-formed-recursion-limit.stderr | 2 |
15 files changed, 35 insertions, 22 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index a5411a04d59..eaae900549e 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -239,13 +239,26 @@ impl<'tcx> 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}`", + ) + } + } } }; diff --git a/tests/ui/impl-trait/issues/issue-84073.rs b/tests/ui/impl-trait/issues/issue-84073.rs index 60f98a7c7b5..124b1d0eec8 100644 --- a/tests/ui/impl-trait/issues/issue-84073.rs +++ b/tests/ui/impl-trait/issues/issue-84073.rs @@ -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<_>` } diff --git a/tests/ui/impl-trait/issues/issue-84073.stderr b/tests/ui/impl-trait/issues/issue-84073.stderr index b9039211db6..2441e523684 100644 --- a/tests/ui/impl-trait/issues/issue-84073.stderr +++ b/tests/ui/impl-trait/issues/issue-84073.stderr @@ -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()); diff --git a/tests/ui/infinite/infinite-autoderef.rs b/tests/ui/infinite/infinite-autoderef.rs index cf5c9fe5678..ae854e1d204 100644 --- a/tests/ui/infinite/infinite-autoderef.rs +++ b/tests/ui/infinite/infinite-autoderef.rs @@ -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(); } diff --git a/tests/ui/infinite/infinite-autoderef.stderr b/tests/ui/infinite/infinite-autoderef.stderr index 24be1a11373..94ec00c591e 100644 --- a/tests/ui/infinite/infinite-autoderef.stderr +++ b/tests/ui/infinite/infinite-autoderef.stderr @@ -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); diff --git a/tests/ui/occurs-check-2.rs b/tests/ui/occurs-check-2.rs index 6cdb757d65b..80ae75632a5 100644 --- a/tests/ui/occurs-check-2.rs +++ b/tests/ui/occurs-check-2.rs @@ -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 `_` } diff --git a/tests/ui/occurs-check-2.stderr b/tests/ui/occurs-check-2.stderr index acc474319b0..cf5c95a1c42 100644 --- a/tests/ui/occurs-check-2.stderr +++ b/tests/ui/occurs-check-2.stderr @@ -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); diff --git a/tests/ui/occurs-check-3.rs b/tests/ui/occurs-check-3.rs index cdf8dc3bd16..f3d9a28b62d 100644 --- a/tests/ui/occurs-check-3.rs +++ b/tests/ui/occurs-check-3.rs @@ -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>(_) => { } } diff --git a/tests/ui/occurs-check-3.stderr b/tests/ui/occurs-check-3.stderr index 7bc28e61d9f..84197162c38 100644 --- a/tests/ui/occurs-check-3.stderr +++ b/tests/ui/occurs-check-3.stderr @@ -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); diff --git a/tests/ui/occurs-check.rs b/tests/ui/occurs-check.rs index 3fae3ff1238..dce0a41bce7 100644 --- a/tests/ui/occurs-check.rs +++ b/tests/ui/occurs-check.rs @@ -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 `_` } diff --git a/tests/ui/occurs-check.stderr b/tests/ui/occurs-check.stderr index 3f61d8fd08d..0454e6ddda6 100644 --- a/tests/ui/occurs-check.stderr +++ b/tests/ui/occurs-check.stderr @@ -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); diff --git a/tests/ui/traits/subtype-recursion-limit.rs b/tests/ui/traits/subtype-recursion-limit.rs index 5804748844e..c652e24644d 100644 --- a/tests/ui/traits/subtype-recursion-limit.rs +++ b/tests/ui/traits/subtype-recursion-limit.rs @@ -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; diff --git a/tests/ui/traits/subtype-recursion-limit.stderr b/tests/ui/traits/subtype-recursion-limit.stderr index 5310f822cc3..6544852bbf0 100644 --- a/tests/ui/traits/subtype-recursion-limit.stderr +++ b/tests/ui/traits/subtype-recursion-limit.stderr @@ -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); diff --git a/tests/ui/traits/well-formed-recursion-limit.rs b/tests/ui/traits/well-formed-recursion-limit.rs index 056cf947d4b..49713be3a79 100644 --- a/tests/ui/traits/well-formed-recursion-limit.rs +++ b/tests/ui/traits/well-formed-recursion-limit.rs @@ -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 { diff --git a/tests/ui/traits/well-formed-recursion-limit.stderr b/tests/ui/traits/well-formed-recursion-limit.stderr index 6f5fda02315..690d869b243 100644 --- a/tests/ui/traits/well-formed-recursion-limit.stderr +++ b/tests/ui/traits/well-formed-recursion-limit.stderr @@ -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 { |
