Use delay_span_bug for "Failed to unify obligation"

This commit is contained in:
Esteban Küber 2019-05-08 11:42:47 -07:00
parent 33cde4aac2
commit 0fce5c1bf0
3 changed files with 61 additions and 5 deletions

View File

@ -1454,13 +1454,18 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>(
} }
} }
Err(e) => { Err(e) => {
span_bug!( let msg = format!(
obligation.cause.span, "Failed to unify obligation `{:?}` with poly_projection `{:?}`: {:?}",
"Failed to unify obligation `{:?}` \
with poly_projection `{:?}`: {:?}",
obligation, obligation,
poly_cache_entry, 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![],
}
} }
} }
} }

View File

@ -0,0 +1,17 @@
pub trait Trait<'a> {
type Item;
}
impl<'a> Trait<'a> for () {
type Item = ();
}
pub fn foo<T, F>(_: T, _: F)
where T: for<'a> Trait<'a>,
F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
fn main() {
foo((), drop)
//~^ ERROR type mismatch in function arguments
//~| ERROR type mismatch resolving
}

View File

@ -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>(_: T, _: F)
LL | | where T: for<'a> Trait<'a>,
LL | | F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
| |_________________________________________________^
error[E0271]: type mismatch resolving `for<'a> <fn(_) {std::mem::drop::<_>} 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>(_: T, _: F)
LL | | where T: for<'a> Trait<'a>,
LL | | F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
| |_________________________________________________^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0271`.