Skip to content

Commit 0fce5c1

Browse files
committed
Use delay_span_bug for "Failed to unify obligation"
1 parent 33cde4a commit 0fce5c1

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

src/librustc/traits/project.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1454,13 +1454,18 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>(
14541454
}
14551455
}
14561456
Err(e) => {
1457-
span_bug!(
1458-
obligation.cause.span,
1459-
"Failed to unify obligation `{:?}` \
1460-
with poly_projection `{:?}`: {:?}",
1457+
let msg = format!(
1458+
"Failed to unify obligation `{:?}` with poly_projection `{:?}`: {:?}",
14611459
obligation,
14621460
poly_cache_entry,
1463-
e);
1461+
e,
1462+
);
1463+
debug!("confirm_param_env_candidate: {}", msg);
1464+
infcx.tcx.sess.delay_span_bug(obligation.cause.span, &msg);
1465+
Progress {
1466+
ty: infcx.tcx.types.err,
1467+
obligations: vec![],
1468+
}
14641469
}
14651470
}
14661471
}

src/test/ui/issues/issue-60283.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pub trait Trait<'a> {
2+
type Item;
3+
}
4+
5+
impl<'a> Trait<'a> for () {
6+
type Item = ();
7+
}
8+
9+
pub fn foo<T, F>(_: T, _: F)
10+
where T: for<'a> Trait<'a>,
11+
F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
12+
13+
fn main() {
14+
foo((), drop)
15+
//~^ ERROR type mismatch in function arguments
16+
//~| ERROR type mismatch resolving
17+
}

src/test/ui/issues/issue-60283.stderr

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error[E0631]: type mismatch in function arguments
2+
--> $DIR/issue-60283.rs:14:5
3+
|
4+
LL | foo((), drop)
5+
| ^^^
6+
| |
7+
| expected signature of `for<'a> fn(<() as Trait<'a>>::Item) -> _`
8+
| found signature of `fn(_) -> _`
9+
|
10+
note: required by `foo`
11+
--> $DIR/issue-60283.rs:9:1
12+
|
13+
LL | / pub fn foo<T, F>(_: T, _: F)
14+
LL | | where T: for<'a> Trait<'a>,
15+
LL | | F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
16+
| |_________________________________________________^
17+
18+
error[E0271]: type mismatch resolving `for<'a> <fn(_) {std::mem::drop::<_>} as std::ops::FnOnce<(<() as Trait<'a>>::Item,)>>::Output == ()`
19+
--> $DIR/issue-60283.rs:14:5
20+
|
21+
LL | foo((), drop)
22+
| ^^^ expected bound lifetime parameter 'a, found concrete lifetime
23+
|
24+
note: required by `foo`
25+
--> $DIR/issue-60283.rs:9:1
26+
|
27+
LL | / pub fn foo<T, F>(_: T, _: F)
28+
LL | | where T: for<'a> Trait<'a>,
29+
LL | | F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
30+
| |_________________________________________________^
31+
32+
error: aborting due to 2 previous errors
33+
34+
For more information about this error, try `rustc --explain E0271`.

0 commit comments

Comments
 (0)