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

Don't ICE on bound var in reject_fn_ptr_impls #112783

Merged
merged 1 commit into from
Jun 19, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// Fast path to avoid evaluating an obligation that trivially holds.
// There may be more bounds, but these are checked by the regular path.
ty::FnPtr(..) => return false,

// These may potentially implement `FnPtr`
ty::Placeholder(..)
| ty::Dynamic(_, _, _)
| ty::Alias(_, _)
| ty::Infer(_)
| ty::Param(..) => {}
| ty::Param(..)
| ty::Bound(_, _) => {}

ty::Bound(_, _) => span_bug!(
obligation.cause.span(),
"cannot have escaping bound var in self type of {obligation:#?}"
),
// These can't possibly implement `FnPtr` as they are concrete types
// and not `FnPtr`
ty::Bool
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/traits/non_lifetime_binders/foreach-partial-eq.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(non_lifetime_binders)]
//~^ WARN the feature `non_lifetime_binders` is incomplete

fn auto_trait()
where
for<T> T: PartialEq + PartialOrd,
{}

fn main() {
auto_trait();
//~^ ERROR can't compare `T` with `T`
}
28 changes: 28 additions & 0 deletions tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/foreach-partial-eq.rs:1:12
|
LL | #![feature(non_lifetime_binders)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
= note: `#[warn(incomplete_features)]` on by default

error[E0277]: can't compare `T` with `T`
--> $DIR/foreach-partial-eq.rs:10:5
|
LL | auto_trait();
| ^^^^^^^^^^ no implementation for `T < T` and `T > T`
|
= help: the trait `PartialOrd` is not implemented for `T`
note: required by a bound in `auto_trait`
--> $DIR/foreach-partial-eq.rs:6:27
|
LL | fn auto_trait()
| ---------- required by a bound in this function
LL | where
LL | for<T> T: PartialEq + PartialOrd,
| ^^^^^^^^^^ required by this bound in `auto_trait`

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.