/// Intern a type. global_interners is Some only if this is
/// a local interner and global_interners is its counterpart.
Intern a type. global_interners is Some only if this is
a local interner and global_interners is its counterpart.
Intern a type . global_interners is Some only if this is a local interner and global_interners is its counterpart .
fn intern_ty(&self, st: TypeVariants<'tcx>,
                 global_interners: Option<&CtxtInterners<'gcx>>)
                 -> Ty<'tcx> {
        let ty = {
            let mut interner = self.type_.borrow_mut();
            let global_interner = global_interners.map(|interners| {
                interners.type_.borrow_mut()
            });
            if let Some(&Interned(ty)) = interner.get(&st) {
                return ty;
            }
            if let Some(ref interner) = global_interner {
                if let Some(&Interned(ty)) = interner.get(&st) {
                    return ty;
                }
            }
            let flags = super::flags::FlagComputation::for_sty(&st);
            let ty_struct = TyS {
                sty: st,
                flags: Cell::new(flags.flags),
                region_depth: flags.depth,
            };
            // HACK(eddyb) Depend on flags being accurate to
            // determine that all contents are in the global tcx.
            // See comments on Lift for why we can't use that.
            if !flags.flags.intersects(ty::TypeFlags::KEEP_IN_LOCAL_TCX) {
                if let Some(interner) = global_interners {
                    let ty_struct: TyS<'gcx> = unsafe {
                        mem::transmute(ty_struct)
                    };
                    let ty: Ty<'gcx> = interner.arena.alloc(ty_struct);
                    global_interner.unwrap().insert(Interned(ty));
                    return ty;
                }
            } else {
                // Make sure we don't end up with inference
                // types/regions in the global tcx.
                if global_interners.is_none() {
                    drop(interner);
                    bug!("Attempted to intern `{:?}` which contains \
                          inference types/regions in the global type context",
                         &ty_struct);
                }
            }
            // Don't be &mut TyS.
            let ty: Ty<'tcx> = self.arena.alloc(ty_struct);
            interner.insert(Interned(ty));
            ty
        };
        debug!("Interned type: {:?} Pointer: {:?}",
            ty, ty as *const TyS);
        ty
    }
fn intern_ty ( & self , st : TypeVariants < ' tcx > , global_interners : Option < & CtxtInterners < ' gcx > > ) -> Ty < ' tcx > { let ty = { let mut interner = self . type_ . borrow_mut ( ) ; let global_interner = global_interners . map ( | interners | { interners . type_ . borrow_mut ( ) } ) ; if let Some ( & Interned ( ty ) ) = interner . get ( & st ) { return ty ; } if let Some ( ref interner ) = global_interner { if let Some ( & Interned ( ty ) ) = interner . get ( & st ) { return ty ; } } let flags = super :: flags :: FlagComputation :: for_sty ( & st ) ; let ty_struct = TyS { sty : st , flags : Cell :: new ( flags . flags ) , region_depth : flags . depth , } ; // HACK(eddyb) Depend on flags being accurate to // determine that all contents are in the global tcx. // See comments on Lift for why we can't use that. if ! flags . flags . intersects ( ty :: TypeFlags :: KEEP_IN_LOCAL_TCX ) { if let Some ( interner ) = global_interners { let ty_struct : TyS < ' gcx > = unsafe { mem :: transmute ( ty_struct ) } ; let ty : Ty < ' gcx > = interner . arena . alloc ( ty_struct ) ; global_interner . unwrap ( ) . insert ( Interned ( ty ) ) ; return ty ; } } else { // Make sure we don't end up with inference // types/regions in the global tcx. if global_interners . is_none ( ) { drop ( interner ) ; bug ! ( " \
 " ty_struct ) ; } } // Don't be &mut TyS. let ty : Ty < ' tcx > = self . arena . alloc ( ty_struct ) ; interner . insert ( Interned ( ty ) ) ; ty } ; debug ! ( " " ty ty as const TyS ) ; ty }
Intern a type.
Intern a type .
&self
st
TypeVariants<'tcx>
global_interners
Option<&CtxtInterners<'gcx>>