Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use delay_span_bug for "Failed to unify obligation" #60644

Merged
merged 1 commit into from
May 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/librustc/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![],
}
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/issues/issue-60283.rs
Original file line number Diff line number Diff line change
@@ -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
}
34 changes: 34 additions & 0 deletions src/test/ui/issues/issue-60283.stderr
Original file line number Diff line number Diff line change
@@ -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`.