Skip to content

Commit 29c74d5

Browse files
Don't ICE on bound var in reject_fn_ptr_impls
1 parent 9397862 commit 29c74d5

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
417417
// Fast path to avoid evaluating an obligation that trivially holds.
418418
// There may be more bounds, but these are checked by the regular path.
419419
ty::FnPtr(..) => return false,
420+
420421
// These may potentially implement `FnPtr`
421422
ty::Placeholder(..)
422423
| ty::Dynamic(_, _, _)
423424
| ty::Alias(_, _)
424425
| ty::Infer(_)
425-
| ty::Param(..) => {}
426+
| ty::Param(..)
427+
| ty::Bound(_, _) => {}
426428

427-
ty::Bound(_, _) => span_bug!(
428-
obligation.cause.span(),
429-
"cannot have escaping bound var in self type of {obligation:#?}"
430-
),
431429
// These can't possibly implement `FnPtr` as they are concrete types
432430
// and not `FnPtr`
433431
ty::Bool
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(non_lifetime_binders)]
2+
//~^ WARN the feature `non_lifetime_binders` is incomplete
3+
4+
fn auto_trait()
5+
where
6+
for<T> T: PartialEq + PartialOrd,
7+
{}
8+
9+
fn main() {
10+
auto_trait();
11+
//~^ ERROR can't compare `T` with `T`
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/foreach-partial-eq.rs:1:12
3+
|
4+
LL | #![feature(non_lifetime_binders)]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0277]: can't compare `T` with `T`
11+
--> $DIR/foreach-partial-eq.rs:10:5
12+
|
13+
LL | auto_trait();
14+
| ^^^^^^^^^^ no implementation for `T < T` and `T > T`
15+
|
16+
= help: the trait `PartialOrd` is not implemented for `T`
17+
note: required by a bound in `auto_trait`
18+
--> $DIR/foreach-partial-eq.rs:6:27
19+
|
20+
LL | fn auto_trait()
21+
| ---------- required by a bound in this function
22+
LL | where
23+
LL | for<T> T: PartialEq + PartialOrd,
24+
| ^^^^^^^^^^ required by this bound in `auto_trait`
25+
26+
error: aborting due to previous error; 1 warning emitted
27+
28+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)