let flags = super::flags::FlagComputation::for_sty(&st);
let ty_struct = TyS {
- sty: st,
+ kind: st,
flags: flags.flags,
outer_exclusive_binder: flags.outer_exclusive_binder,
};
fn validate_hir_id_for_typeck_tables(local_id_root: Option<DefId>,
hir_id: hir::HirId,
mut_access: bool) {
- if cfg!(debug_assertions) {
- if let Some(local_id_root) = local_id_root {
- if hir_id.owner != local_id_root.index {
- ty::tls::with(|tcx| {
- bug!("node {} with HirId::owner {:?} cannot be placed in \
- TypeckTables with local_id_root {:?}",
- tcx.hir().node_to_string(hir_id),
- DefId::local(hir_id.owner),
- local_id_root)
- });
- }
- } else {
- // We use "Null Object" TypeckTables in some of the analysis passes.
- // These are just expected to be empty and their `local_id_root` is
- // `None`. Therefore we cannot verify whether a given `HirId` would
- // be a valid key for the given table. Instead we make sure that
- // nobody tries to write to such a Null Object table.
- if mut_access {
- bug!("access to invalid TypeckTables")
- }
+ if let Some(local_id_root) = local_id_root {
+ if hir_id.owner != local_id_root.index {
+ ty::tls::with(|tcx| {
+ bug!("node {} with HirId::owner {:?} cannot be placed in \
+ TypeckTables with local_id_root {:?}",
+ tcx.hir().node_to_string(hir_id),
+ DefId::local(hir_id.owner),
+ local_id_root)
+ });
+ }
+ } else {
+ // We use "Null Object" TypeckTables in some of the analysis passes.
+ // These are just expected to be empty and their `local_id_root` is
+ // `None`. Therefore we cannot verify whether a given `HirId` would
+ // be a valid key for the given table. Instead we make sure that
+ // nobody tries to write to such a Null Object table.
+ if mut_access {
+ bug!("access to invalid TypeckTables")
}
}
}
user_substs.substs.iter().zip(BoundVar::new(0)..).all(|(kind, cvar)| {
match kind.unpack() {
- UnpackedKind::Type(ty) => match ty.sty {
+ UnpackedKind::Type(ty) => match ty.kind {
ty::Bound(debruijn, b) => {
// We only allow a `ty::INNERMOST` index in substitutions.
assert_eq!(debruijn, ty::INNERMOST);
impl<'tcx> CommonTypes<'tcx> {
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
- let mk = |sty| interners.intern_ty(sty);
+ let mk = |ty| interners.intern_ty(ty);
CommonTypes {
unit: mk(Tuple(List::empty())),
///
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/ty.html
#[derive(Copy, Clone)]
-#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "TyCtxt")]
+#[rustc_diagnostic_item = "TyCtxt"]
pub struct TyCtxt<'tcx> {
gcx: &'tcx GlobalCtxt<'tcx>,
}
CrateType::Executable |
CrateType::Staticlib |
CrateType::ProcMacro |
+ CrateType::Dylib |
CrateType::Cdylib => false,
- CrateType::Rlib |
- CrateType::Dylib => true,
+ CrateType::Rlib => true,
}
})
}
}
let ret_ty = self.type_of(scope_def_id);
- match ret_ty.sty {
+ match ret_ty.kind {
ty::FnDef(_, _) => {
let sig = ret_ty.fn_sig(*self);
let output = self.erase_late_bound_regions(&sig.output());
let shards = tcx.interners.type_.lock_shards();
let types = shards.iter().flat_map(|shard| shard.keys());
for &Interned(t) in types {
- let variant = match t.sty {
+ let variant = match t.kind {
ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) |
ty::Float(..) | ty::Str | ty::Never => continue,
ty::Error => /* unimportant */ continue,
}
impl<'tcx, T: 'tcx+?Sized> Copy for Interned<'tcx, T> {}
-// N.B., an `Interned<Ty>` compares and hashes as a sty.
+// N.B., an `Interned<Ty>` compares and hashes as a `TyKind`.
impl<'tcx> PartialEq for Interned<'tcx, TyS<'tcx>> {
fn eq(&self, other: &Interned<'tcx, TyS<'tcx>>) -> bool {
- self.0.sty == other.0.sty
+ self.0.kind == other.0.kind
}
}
impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> {
fn hash<H: Hasher>(&self, s: &mut H) {
- self.0.sty.hash(s)
+ self.0.kind.hash(s)
}
}
#[allow(rustc::usage_of_ty_tykind)]
impl<'tcx> Borrow<TyKind<'tcx>> for Interned<'tcx, TyS<'tcx>> {
fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> {
- &self.0.sty
+ &self.0.kind
}
}
/// It cannot convert a closure that requires unsafe.
pub fn coerce_closure_fn_ty(self, sig: PolyFnSig<'tcx>, unsafety: hir::Unsafety) -> Ty<'tcx> {
let converted_sig = sig.map_bound(|s| {
- let params_iter = match s.inputs()[0].sty {
+ let params_iter = match s.inputs()[0].kind {
ty::Tuple(params) => {
params.into_iter().map(|k| k.expect_ty())
}
}
#[inline]
- pub fn mk_lang_item(self, ty: Ty<'tcx>, item: lang_items::LangItem) -> Ty<'tcx> {
- let def_id = self.require_lang_item(item, None);
- self.mk_generic_adt(def_id, ty)
+ pub fn mk_lang_item(self, ty: Ty<'tcx>, item: lang_items::LangItem) -> Option<Ty<'tcx>> {
+ let def_id = self.lang_items().require(item).ok()?;
+ Some(self.mk_generic_adt(def_id, ty))
}
#[inline]