Skip to content
Permalink
Browse files

Avoid ICE on ReFree region from malformed code

  • Loading branch information...
estebank committed Oct 1, 2019
1 parent f2023ac commit a5cfc4011d6981437ea65ec5adc346b114e29a52
@@ -1,6 +1,7 @@
use rustc::ty::outlives::Component;
use rustc::ty::subst::{GenericArg, GenericArgKind};
use rustc::ty::{self, Region, RegionKind, Ty, TyCtxt};
use syntax_pos::DUMMY_SP;
use smallvec::smallvec;
use std::collections::BTreeSet;

@@ -161,9 +162,21 @@ fn is_free_region(tcx: TyCtxt<'_>, region: Region<'_>) -> bool {
// ignore it. We can't put it on the struct header anyway.
RegionKind::ReLateBound(..) => false,

// This can appear with malformed code (#64855):
//
// struct Bar<T>(<Self as Foo>::Type) where Self: ;
//
// We accept it only to avoid an ICE.
RegionKind::ReEmpty => {
tcx.sess.delay_span_bug(
DUMMY_SP,
&format!("unexpected region in outlives inference: {:?}", region),
);
false
}

// These regions don't appear in types from type declarations:
RegionKind::ReEmpty
| RegionKind::ReErased
RegionKind::ReErased
| RegionKind::ReClosureBound(..)
| RegionKind::ReScope(..)
| RegionKind::ReVar(..)
@@ -0,0 +1,8 @@
pub trait Foo {
type Type;
}

pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
//~^ ERROR the trait bound `Bar<T>: Foo` is not satisfied

fn main() {}
@@ -0,0 +1,9 @@
error[E0277]: the trait bound `Bar<T>: Foo` is not satisfied
--> $DIR/issue-64855.rs:5:19
|
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
| ^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bar<T>`

error: aborting due to previous error

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

0 comments on commit a5cfc40

Please sign in to comment.
You can’t perform that action at this time.