maybe_unused_trait_imports: resolutions
.maybe_unused_trait_imports
.into_iter()
- .map(|id| definitions.local_def_id(id))
+ .map(|id| definitions.local_def_id(id).to_def_id())
.collect(),
maybe_unused_extern_crates: resolutions
.maybe_unused_extern_crates
.into_iter()
- .map(|(id, sp)| (definitions.local_def_id(id), sp))
+ .map(|(id, sp)| (definitions.local_def_id(id).to_def_id(), sp))
.collect(),
glob_map: resolutions
.glob_map
.into_iter()
- .map(|(id, names)| (definitions.local_def_id(id), names))
+ .map(|(id, names)| (definitions.local_def_id(id).to_def_id(), names))
.collect(),
extern_prelude: resolutions.extern_prelude,
untracked_crate: krate,
}
}
-pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
- x.has_type_flags(ty::TypeFlags::KEEP_IN_LOCAL_TCX)
-}
-
direct_interners!(
region: mk_region(RegionKind),
goal: mk_goal(GoalKind<'tcx>),
Some(self.mk_generic_adt(def_id, ty))
}
+ #[inline]
+ pub fn mk_diagnostic_item(self, ty: Ty<'tcx>, name: Symbol) -> Option<Ty<'tcx>> {
+ let def_id = self.get_diagnostic_item(name)?;
+ Some(self.mk_generic_adt(def_id, ty))
+ }
+
#[inline]
pub fn mk_maybe_uninit(self, ty: Ty<'tcx>) -> Ty<'tcx> {
let def_id = self.require_lang_item(lang_items::MaybeUninitLangItem, None);
pub use self::binding::BindingMode;
pub use self::binding::BindingMode::*;
-pub use self::context::{keep_local, tls, FreeRegionInfo, TyCtxt};
+pub use self::context::{tls, FreeRegionInfo, TyCtxt};
pub use self::context::{
CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, ResolvedOpaqueTy,
UserType, UserTypeAnnotationIndex,
| TypeFlags::HAS_TY_OPAQUE.bits
| TypeFlags::HAS_CT_PROJECTION.bits;
- /// Present if the type belongs in a local type context.
- /// Set for placeholders and inference variables that are not "Fresh".
- const KEEP_IN_LOCAL_TCX = 1 << 13;
-
/// Is an error type reachable?
- const HAS_TY_ERR = 1 << 14;
+ const HAS_TY_ERR = 1 << 13;
/// Does this have any region that "appears free" in the type?
/// Basically anything but [ReLateBound] and [ReErased].
- const HAS_FREE_REGIONS = 1 << 15;
+ const HAS_FREE_REGIONS = 1 << 14;
/// Does this have any [ReLateBound] regions? Used to check
/// if a global bound is safe to evaluate.
- const HAS_RE_LATE_BOUND = 1 << 16;
+ const HAS_RE_LATE_BOUND = 1 << 15;
/// Does this have any [ReErased] regions?
- const HAS_RE_ERASED = 1 << 17;
+ const HAS_RE_ERASED = 1 << 16;
/// Does this value have parameters/placeholders/inference variables which could be
/// replaced later, in a way that would change the results of `impl` specialization?
- const STILL_FURTHER_SPECIALIZABLE = 1 << 18;
-
- /// Flags representing the nominal content of a type,
- /// computed by FlagsComputation. If you add a new nominal
- /// flag, it should be added here too.
- const NOMINAL_FLAGS = TypeFlags::HAS_TY_PARAM.bits
- | TypeFlags::HAS_RE_PARAM.bits
- | TypeFlags::HAS_CT_PARAM.bits
- | TypeFlags::HAS_TY_INFER.bits
- | TypeFlags::HAS_RE_INFER.bits
- | TypeFlags::HAS_CT_INFER.bits
- | TypeFlags::HAS_TY_PLACEHOLDER.bits
- | TypeFlags::HAS_RE_PLACEHOLDER.bits
- | TypeFlags::HAS_CT_PLACEHOLDER.bits
- | TypeFlags::HAS_FREE_LOCAL_REGIONS.bits
- | TypeFlags::HAS_TY_PROJECTION.bits
- | TypeFlags::HAS_TY_OPAQUE.bits
- | TypeFlags::HAS_CT_PROJECTION.bits
- | TypeFlags::KEEP_IN_LOCAL_TCX.bits
- | TypeFlags::HAS_TY_ERR.bits
- | TypeFlags::HAS_FREE_REGIONS.bits
- | TypeFlags::HAS_RE_LATE_BOUND.bits
- | TypeFlags::HAS_RE_ERASED.bits
- | TypeFlags::STILL_FURTHER_SPECIALIZABLE.bits;
+ const STILL_FURTHER_SPECIALIZABLE = 1 << 17;
}
}
const IS_BOX = 1 << 6;
/// Indicates whether the type is `ManuallyDrop`.
const IS_MANUALLY_DROP = 1 << 7;
- // FIXME(matthewjasper) replace these with diagnostic items
- /// Indicates whether the type is an `Arc`.
- const IS_ARC = 1 << 8;
- /// Indicates whether the type is an `Rc`.
- const IS_RC = 1 << 9;
/// Indicates whether the variant list of this ADT is `#[non_exhaustive]`.
/// (i.e., this flag is never set unless this ADT is an enum).
- const IS_VARIANT_LIST_NON_EXHAUSTIVE = 1 << 10;
+ const IS_VARIANT_LIST_NON_EXHAUSTIVE = 1 << 8;
}
}
if Some(did) == tcx.lang_items().manually_drop() {
flags |= AdtFlags::IS_MANUALLY_DROP;
}
- if Some(did) == tcx.lang_items().arc() {
- flags |= AdtFlags::IS_ARC;
- }
- if Some(did) == tcx.lang_items().rc() {
- flags |= AdtFlags::IS_RC;
- }
AdtDef { did, variants, flags, repr }
}
self.flags.contains(AdtFlags::IS_PHANTOM_DATA)
}
- /// Returns `true` if this is `Arc<T>`.
- pub fn is_arc(&self) -> bool {
- self.flags.contains(AdtFlags::IS_ARC)
- }
-
- /// Returns `true` if this is `Rc<T>`.
- pub fn is_rc(&self) -> bool {
- self.flags.contains(AdtFlags::IS_RC)
- }
-
/// Returns `true` if this is Box<T>.
#[inline]
pub fn is_box(&self) -> bool {
flags = flags | TypeFlags::HAS_FREE_REGIONS;
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
flags = flags | TypeFlags::HAS_RE_INFER;
- flags = flags | TypeFlags::KEEP_IN_LOCAL_TCX;
flags = flags | TypeFlags::STILL_FURTHER_SPECIALIZABLE;
}
ty::RePlaceholder(..) => {
self.is_region_ptr() || self.is_unsafe_ptr() || self.is_fn_ptr()
}
- /// Returns `true` if this type is an `Arc<T>`.
- #[inline]
- pub fn is_arc(&self) -> bool {
- match self.kind {
- Adt(def, _) => def.is_arc(),
- _ => false,
- }
- }
-
- /// Returns `true` if this type is an `Rc<T>`.
- #[inline]
- pub fn is_rc(&self) -> bool {
- match self.kind {
- Adt(def, _) => def.is_rc(),
- _ => false,
- }
- }
-
#[inline]
pub fn is_box(&self) -> bool {
match self.kind {
let try_const_eval = |did, param_env: ParamEnv<'tcx>, substs, promoted| {
let param_env_and_substs = param_env.with_reveal_all().and(substs);
- // Avoid querying `tcx.const_eval(...)` with any e.g. inference vars.
- if param_env_and_substs.has_local_value() {
+ // Avoid querying `tcx.const_eval(...)` with any inference vars.
+ if param_env_and_substs.needs_infer() {
return None;
}
match self.val {
ConstKind::Unevaluated(did, substs, promoted) => {
- // HACK(eddyb) when substs contain e.g. inference variables,
+ // HACK(eddyb) when substs contain inference variables,
// attempt using identity substs instead, that will succeed
// when the expression doesn't depend on any parameters.
// FIXME(eddyb, skinny121) pass `InferCtxt` into here when it's available, so that
// we can call `infcx.const_eval_resolve` which handles inference variables.
- if substs.has_local_value() {
+ if substs.needs_infer() {
let identity_substs = InternalSubsts::identity_for_item(tcx, did);
// The `ParamEnv` needs to match the `identity_substs`.
let identity_param_env = tcx.param_env(did);