Thread pure_wrt_drop
field through lifetime and type parameters.
This commit is contained in:
parent
4bb68be681
commit
e8ccc68254
6 changed files with 27 additions and 5 deletions
|
@ -408,6 +408,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
bounds: self.lower_bounds(&tp.bounds),
|
bounds: self.lower_bounds(&tp.bounds),
|
||||||
default: tp.default.as_ref().map(|x| self.lower_ty(x)),
|
default: tp.default.as_ref().map(|x| self.lower_ty(x)),
|
||||||
span: tp.span,
|
span: tp.span,
|
||||||
|
pure_wrt_drop: tp.attrs.iter().any(|attr| attr.check_name("may_dangle")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,6 +428,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
hir::LifetimeDef {
|
hir::LifetimeDef {
|
||||||
lifetime: self.lower_lifetime(&l.lifetime),
|
lifetime: self.lower_lifetime(&l.lifetime),
|
||||||
bounds: self.lower_lifetimes(&l.bounds),
|
bounds: self.lower_lifetimes(&l.bounds),
|
||||||
|
pure_wrt_drop: l.attrs.iter().any(|attr| attr.check_name("may_dangle")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ impl fmt::Debug for Lifetime {
|
||||||
pub struct LifetimeDef {
|
pub struct LifetimeDef {
|
||||||
pub lifetime: Lifetime,
|
pub lifetime: Lifetime,
|
||||||
pub bounds: HirVec<Lifetime>,
|
pub bounds: HirVec<Lifetime>,
|
||||||
|
pub pure_wrt_drop: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A "Path" is essentially Rust's notion of a name; for instance:
|
/// A "Path" is essentially Rust's notion of a name; for instance:
|
||||||
|
@ -290,6 +291,7 @@ pub struct TyParam {
|
||||||
pub bounds: TyParamBounds,
|
pub bounds: TyParamBounds,
|
||||||
pub default: Option<P<Ty>>,
|
pub default: Option<P<Ty>>,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
pub pure_wrt_drop: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents lifetimes and type parameters attached to a declaration
|
/// Represents lifetimes and type parameters attached to a declaration
|
||||||
|
|
|
@ -1226,16 +1226,17 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
|
||||||
lifetime: hir::Lifetime,
|
lifetime: hir::Lifetime,
|
||||||
region_names: &HashSet<ast::Name>)
|
region_names: &HashSet<ast::Name>)
|
||||||
-> hir::HirVec<hir::TyParam> {
|
-> hir::HirVec<hir::TyParam> {
|
||||||
ty_params.iter().map(|ty_param| {
|
ty_params.into_iter().map(|ty_param| {
|
||||||
let bounds = self.rebuild_ty_param_bounds(ty_param.bounds.clone(),
|
let bounds = self.rebuild_ty_param_bounds(ty_param.bounds,
|
||||||
lifetime,
|
lifetime,
|
||||||
region_names);
|
region_names);
|
||||||
hir::TyParam {
|
hir::TyParam {
|
||||||
name: ty_param.name,
|
name: ty_param.name,
|
||||||
id: ty_param.id,
|
id: ty_param.id,
|
||||||
bounds: bounds,
|
bounds: bounds,
|
||||||
default: ty_param.default.clone(),
|
default: ty_param.default,
|
||||||
span: ty_param.span,
|
span: ty_param.span,
|
||||||
|
pure_wrt_drop: ty_param.pure_wrt_drop,
|
||||||
}
|
}
|
||||||
}).collect()
|
}).collect()
|
||||||
}
|
}
|
||||||
|
@ -1295,7 +1296,9 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
|
||||||
let mut lifetimes = Vec::new();
|
let mut lifetimes = Vec::new();
|
||||||
for lt in add {
|
for lt in add {
|
||||||
lifetimes.push(hir::LifetimeDef { lifetime: *lt,
|
lifetimes.push(hir::LifetimeDef { lifetime: *lt,
|
||||||
bounds: hir::HirVec::new() });
|
bounds: hir::HirVec::new(),
|
||||||
|
pure_wrt_drop: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
for lt in &generics.lifetimes {
|
for lt in &generics.lifetimes {
|
||||||
if keep.contains(<.lifetime.name) ||
|
if keep.contains(<.lifetime.name) ||
|
||||||
|
|
|
@ -680,6 +680,11 @@ pub struct TypeParameterDef<'tcx> {
|
||||||
pub default_def_id: DefId, // for use in error reporing about defaults
|
pub default_def_id: DefId, // for use in error reporing about defaults
|
||||||
pub default: Option<Ty<'tcx>>,
|
pub default: Option<Ty<'tcx>>,
|
||||||
pub object_lifetime_default: ObjectLifetimeDefault<'tcx>,
|
pub object_lifetime_default: ObjectLifetimeDefault<'tcx>,
|
||||||
|
|
||||||
|
/// `pure_wrt_drop`, set by the (unsafe) `#[may_dangle]` attribute
|
||||||
|
/// on generic parameter `T`, asserts data behind the parameter
|
||||||
|
/// `T` won't be accessed during the parent type's `Drop` impl.
|
||||||
|
pub pure_wrt_drop: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||||
|
@ -688,6 +693,11 @@ pub struct RegionParameterDef<'tcx> {
|
||||||
pub def_id: DefId,
|
pub def_id: DefId,
|
||||||
pub index: u32,
|
pub index: u32,
|
||||||
pub bounds: Vec<&'tcx ty::Region>,
|
pub bounds: Vec<&'tcx ty::Region>,
|
||||||
|
|
||||||
|
/// `pure_wrt_drop`, set by the (unsafe) `#[may_dangle]` attribute
|
||||||
|
/// on generic parameter `'a`, asserts data of lifetime `'a`
|
||||||
|
/// won't be accessed during the parent type's `Drop` impl.
|
||||||
|
pub pure_wrt_drop: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> RegionParameterDef<'tcx> {
|
impl<'tcx> RegionParameterDef<'tcx> {
|
||||||
|
|
|
@ -716,6 +716,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::TypeParameterDef<'tcx> {
|
||||||
default: self.default.fold_with(folder),
|
default: self.default.fold_with(folder),
|
||||||
default_def_id: self.default_def_id,
|
default_def_id: self.default_def_id,
|
||||||
object_lifetime_default: self.object_lifetime_default.fold_with(folder),
|
object_lifetime_default: self.object_lifetime_default.fold_with(folder),
|
||||||
|
pure_wrt_drop: self.pure_wrt_drop,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,6 +755,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::RegionParameterDef<'tcx> {
|
||||||
def_id: self.def_id,
|
def_id: self.def_id,
|
||||||
index: self.index,
|
index: self.index,
|
||||||
bounds: self.bounds.fold_with(folder),
|
bounds: self.bounds.fold_with(folder),
|
||||||
|
pure_wrt_drop: self.pure_wrt_drop,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1482,6 +1482,7 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||||
default_def_id: tcx.map.local_def_id(parent),
|
default_def_id: tcx.map.local_def_id(parent),
|
||||||
default: None,
|
default: None,
|
||||||
object_lifetime_default: ty::ObjectLifetimeDefault::BaseDefault,
|
object_lifetime_default: ty::ObjectLifetimeDefault::BaseDefault,
|
||||||
|
pure_wrt_drop: false,
|
||||||
};
|
};
|
||||||
tcx.ty_param_defs.borrow_mut().insert(param_id, def.clone());
|
tcx.ty_param_defs.borrow_mut().insert(param_id, def.clone());
|
||||||
opt_self = Some(def);
|
opt_self = Some(def);
|
||||||
|
@ -1526,7 +1527,8 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||||
def_id: tcx.map.local_def_id(l.lifetime.id),
|
def_id: tcx.map.local_def_id(l.lifetime.id),
|
||||||
bounds: l.bounds.iter().map(|l| {
|
bounds: l.bounds.iter().map(|l| {
|
||||||
ast_region_to_region(tcx, l)
|
ast_region_to_region(tcx, l)
|
||||||
}).collect()
|
}).collect(),
|
||||||
|
pure_wrt_drop: l.pure_wrt_drop,
|
||||||
}
|
}
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
@ -1926,6 +1928,7 @@ fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
|
||||||
default_def_id: ccx.tcx.map.local_def_id(parent),
|
default_def_id: ccx.tcx.map.local_def_id(parent),
|
||||||
default: default,
|
default: default,
|
||||||
object_lifetime_default: object_lifetime_default,
|
object_lifetime_default: object_lifetime_default,
|
||||||
|
pure_wrt_drop: param.pure_wrt_drop,
|
||||||
};
|
};
|
||||||
|
|
||||||
if def.name == keywords::SelfType.name() {
|
if def.name == keywords::SelfType.name() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue