mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
rework region flags: 'static can be erased too
The existing flags did not consider `'static` to be "free". This then fed into what was "erasable" -- but `'static` is most certainly erasable.
This commit is contained in:
parent
02e65250e4
commit
154cd94197
@ -97,14 +97,19 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
|
||||
fn has_closure_types(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_TY_CLOSURE)
|
||||
}
|
||||
fn has_erasable_regions(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_RE_EARLY_BOUND |
|
||||
TypeFlags::HAS_RE_INFER |
|
||||
TypeFlags::HAS_FREE_REGIONS)
|
||||
/// "Free" regions in this context means that it has any region
|
||||
/// that is not (a) erased or (b) late-bound.
|
||||
fn has_free_regions(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_FREE_REGIONS)
|
||||
}
|
||||
|
||||
/// True if there any any un-erased free regions.
|
||||
fn has_erasable_regions(&self) -> bool {
|
||||
self.has_type_flags(TypeFlags::HAS_FREE_REGIONS)
|
||||
}
|
||||
|
||||
fn is_normalized_for_trans(&self) -> bool {
|
||||
!self.has_type_flags(TypeFlags::HAS_RE_EARLY_BOUND |
|
||||
TypeFlags::HAS_RE_INFER |
|
||||
!self.has_type_flags(TypeFlags::HAS_RE_INFER |
|
||||
TypeFlags::HAS_FREE_REGIONS |
|
||||
TypeFlags::HAS_TY_INFER |
|
||||
TypeFlags::HAS_PARAMS |
|
||||
|
@ -421,8 +421,18 @@ bitflags! {
|
||||
const HAS_TY_INFER = 1 << 2;
|
||||
const HAS_RE_INFER = 1 << 3;
|
||||
const HAS_RE_SKOL = 1 << 4;
|
||||
|
||||
/// Does this have any `ReEarlyBound` regions? Used to
|
||||
/// determine whether substitition is required, since those
|
||||
/// represent regions that are bound in a `ty::Generics` and
|
||||
/// hence may be substituted.
|
||||
const HAS_RE_EARLY_BOUND = 1 << 5;
|
||||
|
||||
/// Does this have any region that "appears free" in the type?
|
||||
/// Basically anything but `ReLateBound` and `ReErased`.
|
||||
const HAS_FREE_REGIONS = 1 << 6;
|
||||
|
||||
/// Is an error type reachable?
|
||||
const HAS_TY_ERR = 1 << 7;
|
||||
const HAS_PROJECTION = 1 << 8;
|
||||
|
||||
|
@ -1184,18 +1184,29 @@ impl RegionKind {
|
||||
|
||||
match *self {
|
||||
ty::ReVar(..) => {
|
||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||
flags = flags | TypeFlags::HAS_RE_INFER;
|
||||
flags = flags | TypeFlags::KEEP_IN_LOCAL_TCX;
|
||||
}
|
||||
ty::ReSkolemized(..) => {
|
||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||
flags = flags | TypeFlags::HAS_RE_INFER;
|
||||
flags = flags | TypeFlags::HAS_RE_SKOL;
|
||||
flags = flags | TypeFlags::KEEP_IN_LOCAL_TCX;
|
||||
}
|
||||
ty::ReLateBound(..) => { }
|
||||
ty::ReEarlyBound(..) => { flags = flags | TypeFlags::HAS_RE_EARLY_BOUND; }
|
||||
ty::ReStatic | ty::ReErased => { }
|
||||
_ => { flags = flags | TypeFlags::HAS_FREE_REGIONS; }
|
||||
ty::ReEarlyBound(..) => {
|
||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||
flags = flags | TypeFlags::HAS_RE_EARLY_BOUND;
|
||||
}
|
||||
ty::ReEmpty |
|
||||
ty::ReStatic |
|
||||
ty::ReFree { .. } |
|
||||
ty::ReScope { .. } => {
|
||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||
}
|
||||
ty::ReErased => {
|
||||
}
|
||||
}
|
||||
|
||||
match *self {
|
||||
|
Loading…
Reference in New Issue
Block a user