Code up the new lifetime default rules, but leave them disabled

for now.
This commit is contained in:
Niko Matsakis 2015-06-17 10:02:32 -04:00
parent f027bdc1c8
commit ef85338175
7 changed files with 90 additions and 36 deletions

View file

@ -2245,6 +2245,9 @@ pub enum ObjectLifetimeDefault {
/// `T:'a` constraints are found.
Ambiguous,
/// Use the base default, typically 'static, but in a fn body it is a fresh variable
BaseDefault,
/// Use the given region as the default.
Specific(Region),
}
@ -2256,7 +2259,7 @@ pub struct TypeParameterDef<'tcx> {
pub space: subst::ParamSpace,
pub index: u32,
pub default: Option<Ty<'tcx>>,
pub object_lifetime_default: Option<ObjectLifetimeDefault>,
pub object_lifetime_default: ObjectLifetimeDefault,
}
#[derive(RustcEncodable, RustcDecodable, Clone, Debug)]
@ -7328,6 +7331,7 @@ impl<'tcx> fmt::Debug for ObjectLifetimeDefault {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ObjectLifetimeDefault::Ambiguous => write!(f, "Ambiguous"),
ObjectLifetimeDefault::BaseDefault => format!("BaseDefault"),
ObjectLifetimeDefault::Specific(ref r) => write!(f, "{:?}", r),
}
}

View file

@ -369,6 +369,9 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ObjectLifetimeDefault {
ty::ObjectLifetimeDefault::Ambiguous =>
ty::ObjectLifetimeDefault::Ambiguous,
ty::ObjectLifetimeDefault::BaseDefault =>
ty::ObjectLifetimeDefault::BaseDefault,
ty::ObjectLifetimeDefault::Specific(r) =>
ty::ObjectLifetimeDefault::Specific(r.fold_with(folder)),
}