From: Esteban Küber Date: Wed, 8 May 2019 18:42:47 +0000 (-0700) Subject: Use `delay_span_bug` for "Failed to unify obligation" X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=0fce5c1bf0b5f12d4e3efe8d31b1df576d5abf45;p=rust.git Use `delay_span_bug` for "Failed to unify obligation" --- diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index dabb8a72890..b5232e828c4 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -1454,13 +1454,18 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>( } } Err(e) => { - span_bug!( - obligation.cause.span, - "Failed to unify obligation `{:?}` \ - with poly_projection `{:?}`: {:?}", + let msg = format!( + "Failed to unify obligation `{:?}` with poly_projection `{:?}`: {:?}", obligation, poly_cache_entry, - e); + e, + ); + debug!("confirm_param_env_candidate: {}", msg); + infcx.tcx.sess.delay_span_bug(obligation.cause.span, &msg); + Progress { + ty: infcx.tcx.types.err, + obligations: vec![], + } } } } diff --git a/src/test/ui/issues/issue-60283.rs b/src/test/ui/issues/issue-60283.rs new file mode 100644 index 00000000000..e5a9caa32fa --- /dev/null +++ b/src/test/ui/issues/issue-60283.rs @@ -0,0 +1,17 @@ +pub trait Trait<'a> { + type Item; +} + +impl<'a> Trait<'a> for () { + type Item = (); +} + +pub fn foo(_: T, _: F) +where T: for<'a> Trait<'a>, + F: for<'a> FnMut(>::Item) {} + +fn main() { + foo((), drop) + //~^ ERROR type mismatch in function arguments + //~| ERROR type mismatch resolving +} diff --git a/src/test/ui/issues/issue-60283.stderr b/src/test/ui/issues/issue-60283.stderr new file mode 100644 index 00000000000..a79b1959dca --- /dev/null +++ b/src/test/ui/issues/issue-60283.stderr @@ -0,0 +1,34 @@ +error[E0631]: type mismatch in function arguments + --> $DIR/issue-60283.rs:14:5 + | +LL | foo((), drop) + | ^^^ + | | + | expected signature of `for<'a> fn(<() as Trait<'a>>::Item) -> _` + | found signature of `fn(_) -> _` + | +note: required by `foo` + --> $DIR/issue-60283.rs:9:1 + | +LL | / pub fn foo(_: T, _: F) +LL | | where T: for<'a> Trait<'a>, +LL | | F: for<'a> FnMut(>::Item) {} + | |_________________________________________________^ + +error[E0271]: type mismatch resolving `for<'a> } as std::ops::FnOnce<(<() as Trait<'a>>::Item,)>>::Output == ()` + --> $DIR/issue-60283.rs:14:5 + | +LL | foo((), drop) + | ^^^ expected bound lifetime parameter 'a, found concrete lifetime + | +note: required by `foo` + --> $DIR/issue-60283.rs:9:1 + | +LL | / pub fn foo(_: T, _: F) +LL | | where T: for<'a> Trait<'a>, +LL | | F: for<'a> FnMut(>::Item) {} + | |_________________________________________________^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`.