mirror of
https://github.com/rust-lang/rust
synced 2024-10-14 12:33:57 +00:00
better error message for normalizes-to ambiguities
This commit is contained in:
parent
52b2c88bdf
commit
b0c1474381
|
@ -2705,6 +2705,22 @@ fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>) -> Erro
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term })
|
||||||
|
if term.is_infer() =>
|
||||||
|
{
|
||||||
|
if let Some(e) = self.tainted_by_errors() {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
struct_span_code_err!(
|
||||||
|
self.dcx(),
|
||||||
|
span,
|
||||||
|
E0284,
|
||||||
|
"type annotations needed: cannot normalize `{alias}`",
|
||||||
|
)
|
||||||
|
.with_span_label(span, format!("cannot normalize `{alias}`"))
|
||||||
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
if let Some(e) = self.tainted_by_errors() {
|
if let Some(e) = self.tainted_by_errors() {
|
||||||
return e;
|
return e;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0284]: type annotations needed: cannot satisfy `<dyn Object<U, Output = T> as Object<U>>::Output normalizes-to _`
|
error[E0284]: type annotations needed: cannot normalize `<dyn Object<U, Output = T> as Object<U>>::Output`
|
||||||
--> $DIR/indirect-impl-for-trait-obj-coherence.rs:25:41
|
--> $DIR/indirect-impl-for-trait-obj-coherence.rs:25:41
|
||||||
|
|
|
|
||||||
LL | foo::<dyn Object<U, Output = T>, U>(x)
|
LL | foo::<dyn Object<U, Output = T>, U>(x)
|
||||||
| ^ cannot satisfy `<dyn Object<U, Output = T> as Object<U>>::Output normalizes-to _`
|
| ^ cannot normalize `<dyn Object<U, Output = T> as Object<U>>::Output`
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ fn foo<T: ?Sized, U>(x: <T as Object<U>>::Output) -> U {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn transmute<T, U>(x: T) -> U {
|
fn transmute<T, U>(x: T) -> U {
|
||||||
foo::<dyn Object<U, Output = T>, U>(x)
|
foo::<dyn Object<U, Output = T>, U>(x)
|
||||||
//[next]~^ ERROR type annotations needed: cannot satisfy `<dyn Object<U, Output = T> as Object<U>>::Output normalizes-to _`
|
//[next]~^ ERROR type annotations needed: cannot normalize `<dyn Object<U, Output = T> as Object<U>>::Output`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -16,11 +16,11 @@ LL | | for<'a> *const T: ToUnit<'a>,
|
||||||
|
|
|
|
||||||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
|
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
|
||||||
|
|
||||||
error[E0284]: type annotations needed: cannot satisfy `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc normalizes-to _`
|
error[E0284]: type annotations needed: cannot normalize `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc`
|
||||||
--> $DIR/associated-type.rs:44:59
|
--> $DIR/associated-type.rs:44:59
|
||||||
|
|
|
|
||||||
LL | foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
|
LL | foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
|
||||||
| ^^^^^^ cannot satisfy `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc normalizes-to _`
|
| ^^^^^^ cannot normalize `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -42,5 +42,5 @@ fn foo<T: Overlap<U>, U>(x: T::Assoc) -> T::Assoc {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
|
foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
|
||||||
//[next]~^ ERROR: cannot satisfy
|
//[next]~^ ERROR: cannot normalize
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0284]: type annotations needed: cannot satisfy `X::{constant#0} normalizes-to _`
|
error[E0284]: type annotations needed: cannot normalize `X::{constant#0}`
|
||||||
--> $DIR/const-region-infer-to-static-in-binder.rs:4:10
|
--> $DIR/const-region-infer-to-static-in-binder.rs:4:10
|
||||||
|
|
|
|
||||||
LL | struct X<const FN: fn() = { || {} }>;
|
LL | struct X<const FN: fn() = { || {} }>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `X::{constant#0} normalizes-to _`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `X::{constant#0}`
|
||||||
|
|
||||||
error: using function pointers as const generic parameters is forbidden
|
error: using function pointers as const generic parameters is forbidden
|
||||||
--> $DIR/const-region-infer-to-static-in-binder.rs:4:20
|
--> $DIR/const-region-infer-to-static-in-binder.rs:4:20
|
||||||
|
|
|
@ -10,11 +10,11 @@ LL | #![feature(specialization)]
|
||||||
|
|
||||||
error: cannot normalize `<T as Default>::Id: '_`
|
error: cannot normalize `<T as Default>::Id: '_`
|
||||||
|
|
||||||
error[E0284]: type annotations needed: cannot satisfy `<T as Default>::Id normalizes-to _`
|
error[E0284]: type annotations needed: cannot normalize `<T as Default>::Id`
|
||||||
--> $DIR/specialization-transmute.rs:15:23
|
--> $DIR/specialization-transmute.rs:15:23
|
||||||
|
|
|
|
||||||
LL | fn intu(&self) -> &Self::Id {
|
LL | fn intu(&self) -> &Self::Id {
|
||||||
| ^^^^^^^^^ cannot satisfy `<T as Default>::Id normalizes-to _`
|
| ^^^^^^^^^ cannot normalize `<T as Default>::Id`
|
||||||
|
|
||||||
error[E0284]: type annotations needed: cannot satisfy `<T as Default>::Id normalizes-to T`
|
error[E0284]: type annotations needed: cannot satisfy `<T as Default>::Id normalizes-to T`
|
||||||
--> $DIR/specialization-transmute.rs:17:9
|
--> $DIR/specialization-transmute.rs:17:9
|
||||||
|
|
Loading…
Reference in a new issue