Add inline attributes and add unit to CommonTypes
This commit is contained in:
parent
3dde9e1322
commit
4cce4ffdef
9 changed files with 57 additions and 1 deletions
|
@ -3614,6 +3614,7 @@ assert_eq!(3", stringify!($SelfT), ".checked_next_power_of_two(), Some(4));
|
||||||
assert_eq!(", stringify!($SelfT), "::max_value().checked_next_power_of_two(), None);",
|
assert_eq!(", stringify!($SelfT), "::max_value().checked_next_power_of_two(), None);",
|
||||||
$EndFeature, "
|
$EndFeature, "
|
||||||
```"),
|
```"),
|
||||||
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn checked_next_power_of_two(self) -> Option<Self> {
|
pub fn checked_next_power_of_two(self) -> Option<Self> {
|
||||||
self.one_less_than_next_power_of_two().checked_add(1)
|
self.one_less_than_next_power_of_two().checked_add(1)
|
||||||
|
|
|
@ -52,6 +52,7 @@ pub struct Trace<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
#[inline]
|
||||||
pub fn at(&'a self,
|
pub fn at(&'a self,
|
||||||
cause: &'a ObligationCause<'tcx>,
|
cause: &'a ObligationCause<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>)
|
param_env: ty::ParamEnv<'tcx>)
|
||||||
|
|
|
@ -25,6 +25,7 @@ pub struct OpportunisticTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> OpportunisticTypeResolver<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> OpportunisticTypeResolver<'a, 'gcx, 'tcx> {
|
||||||
|
#[inline]
|
||||||
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
|
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
|
||||||
OpportunisticTypeResolver { infcx }
|
OpportunisticTypeResolver { infcx }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1052,6 +1052,7 @@ impl<'tcx,O> Obligation<'tcx,O> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ObligationCause<'tcx> {
|
impl<'tcx> ObligationCause<'tcx> {
|
||||||
|
#[inline]
|
||||||
pub fn new(span: Span,
|
pub fn new(span: Span,
|
||||||
body_id: ast::NodeId,
|
body_id: ast::NodeId,
|
||||||
code: ObligationCauseCode<'tcx>)
|
code: ObligationCauseCode<'tcx>)
|
||||||
|
|
|
@ -155,6 +155,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Intern a type
|
/// Intern a type
|
||||||
|
#[inline(never)]
|
||||||
fn intern_ty(
|
fn intern_ty(
|
||||||
local: &CtxtInterners<'tcx>,
|
local: &CtxtInterners<'tcx>,
|
||||||
global: &CtxtInterners<'gcx>,
|
global: &CtxtInterners<'gcx>,
|
||||||
|
@ -216,6 +217,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CommonTypes<'tcx> {
|
pub struct CommonTypes<'tcx> {
|
||||||
|
pub unit: Ty<'tcx>,
|
||||||
pub bool: Ty<'tcx>,
|
pub bool: Ty<'tcx>,
|
||||||
pub char: Ty<'tcx>,
|
pub char: Ty<'tcx>,
|
||||||
pub isize: Ty<'tcx>,
|
pub isize: Ty<'tcx>,
|
||||||
|
@ -832,7 +834,9 @@ impl<'tcx> CommonTypes<'tcx> {
|
||||||
interners.region.borrow_mut().insert(Interned(r));
|
interners.region.borrow_mut().insert(Interned(r));
|
||||||
&*r
|
&*r
|
||||||
};
|
};
|
||||||
|
|
||||||
CommonTypes {
|
CommonTypes {
|
||||||
|
unit: mk(Tuple(List::empty())),
|
||||||
bool: mk(Bool),
|
bool: mk(Bool),
|
||||||
char: mk(Char),
|
char: mk(Char),
|
||||||
never: mk(Never),
|
never: mk(Never),
|
||||||
|
@ -885,6 +889,7 @@ pub struct TyCtxt<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> Deref for TyCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> Deref for TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
type Target = &'a GlobalCtxt<'gcx>;
|
type Target = &'a GlobalCtxt<'gcx>;
|
||||||
|
#[inline(always)]
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.gcx
|
&self.gcx
|
||||||
}
|
}
|
||||||
|
@ -2515,6 +2520,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.mk_fn_ptr(converted_sig)
|
self.mk_fn_ptr(converted_sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_ty(&self, st: TyKind<'tcx>) -> Ty<'tcx> {
|
pub fn mk_ty(&self, st: TyKind<'tcx>) -> Ty<'tcx> {
|
||||||
CtxtInterners::intern_ty(&self.interners, &self.global_interners, st)
|
CtxtInterners::intern_ty(&self.interners, &self.global_interners, st)
|
||||||
}
|
}
|
||||||
|
@ -2548,19 +2554,23 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_str(self) -> Ty<'tcx> {
|
pub fn mk_str(self) -> Ty<'tcx> {
|
||||||
self.mk_ty(Str)
|
self.mk_ty(Str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_static_str(self) -> Ty<'tcx> {
|
pub fn mk_static_str(self) -> Ty<'tcx> {
|
||||||
self.mk_imm_ref(self.types.re_static, self.mk_str())
|
self.mk_imm_ref(self.types.re_static, self.mk_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_adt(self, def: &'tcx AdtDef, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
pub fn mk_adt(self, def: &'tcx AdtDef, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||||
// take a copy of substs so that we own the vectors inside
|
// take a copy of substs so that we own the vectors inside
|
||||||
self.mk_ty(Adt(def, substs))
|
self.mk_ty(Adt(def, substs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_foreign(self, def_id: DefId) -> Ty<'tcx> {
|
pub fn mk_foreign(self, def_id: DefId) -> Ty<'tcx> {
|
||||||
self.mk_ty(Foreign(def_id))
|
self.mk_ty(Foreign(def_id))
|
||||||
}
|
}
|
||||||
|
@ -2584,42 +2594,52 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.mk_ty(Adt(adt_def, substs))
|
self.mk_ty(Adt(adt_def, substs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_ptr(self, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
|
pub fn mk_ptr(self, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ty(RawPtr(tm))
|
self.mk_ty(RawPtr(tm))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_ref(self, r: Region<'tcx>, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
|
pub fn mk_ref(self, r: Region<'tcx>, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ty(Ref(r, tm.ty, tm.mutbl))
|
self.mk_ty(Ref(r, tm.ty, tm.mutbl))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_mut_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
pub fn mk_mut_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ref(r, TypeAndMut {ty: ty, mutbl: hir::MutMutable})
|
self.mk_ref(r, TypeAndMut {ty: ty, mutbl: hir::MutMutable})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_imm_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
pub fn mk_imm_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ref(r, TypeAndMut {ty: ty, mutbl: hir::MutImmutable})
|
self.mk_ref(r, TypeAndMut {ty: ty, mutbl: hir::MutImmutable})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_mut_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
pub fn mk_mut_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ptr(TypeAndMut {ty: ty, mutbl: hir::MutMutable})
|
self.mk_ptr(TypeAndMut {ty: ty, mutbl: hir::MutMutable})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_imm_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
pub fn mk_imm_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ptr(TypeAndMut {ty: ty, mutbl: hir::MutImmutable})
|
self.mk_ptr(TypeAndMut {ty: ty, mutbl: hir::MutImmutable})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_nil_ptr(self) -> Ty<'tcx> {
|
pub fn mk_nil_ptr(self) -> Ty<'tcx> {
|
||||||
self.mk_imm_ptr(self.mk_unit())
|
self.mk_imm_ptr(self.mk_unit())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> {
|
pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> {
|
||||||
self.mk_ty(Array(ty, ty::Const::from_usize(self, n)))
|
self.mk_ty(Array(ty, ty::Const::from_usize(self, n)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_slice(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
pub fn mk_slice(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ty(Slice(ty))
|
self.mk_ty(Slice(ty))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn intern_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> {
|
pub fn intern_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> {
|
||||||
self.mk_ty(Tuple(self.intern_type_list(ts)))
|
self.mk_ty(Tuple(self.intern_type_list(ts)))
|
||||||
}
|
}
|
||||||
|
@ -2628,10 +2648,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
iter.intern_with(|ts| self.mk_ty(Tuple(self.intern_type_list(ts))))
|
iter.intern_with(|ts| self.mk_ty(Tuple(self.intern_type_list(ts))))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_unit(self) -> Ty<'tcx> {
|
pub fn mk_unit(self) -> Ty<'tcx> {
|
||||||
self.intern_tup(&[])
|
self.types.unit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_diverging_default(self) -> Ty<'tcx> {
|
pub fn mk_diverging_default(self) -> Ty<'tcx> {
|
||||||
if self.features().never_type {
|
if self.features().never_type {
|
||||||
self.types.never
|
self.types.never
|
||||||
|
@ -2640,19 +2662,23 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_bool(self) -> Ty<'tcx> {
|
pub fn mk_bool(self) -> Ty<'tcx> {
|
||||||
self.mk_ty(Bool)
|
self.mk_ty(Bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_fn_def(self, def_id: DefId,
|
pub fn mk_fn_def(self, def_id: DefId,
|
||||||
substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ty(FnDef(def_id, substs))
|
self.mk_ty(FnDef(def_id, substs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_fn_ptr(self, fty: PolyFnSig<'tcx>) -> Ty<'tcx> {
|
pub fn mk_fn_ptr(self, fty: PolyFnSig<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ty(FnPtr(fty))
|
self.mk_ty(FnPtr(fty))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_dynamic(
|
pub fn mk_dynamic(
|
||||||
self,
|
self,
|
||||||
obj: ty::Binder<&'tcx List<ExistentialPredicate<'tcx>>>,
|
obj: ty::Binder<&'tcx List<ExistentialPredicate<'tcx>>>,
|
||||||
|
@ -2661,6 +2687,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.mk_ty(Dynamic(obj, reg))
|
self.mk_ty(Dynamic(obj, reg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_projection(self,
|
pub fn mk_projection(self,
|
||||||
item_def_id: DefId,
|
item_def_id: DefId,
|
||||||
substs: &'tcx Substs<'tcx>)
|
substs: &'tcx Substs<'tcx>)
|
||||||
|
@ -2671,11 +2698,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_closure(self, closure_id: DefId, closure_substs: ClosureSubsts<'tcx>)
|
pub fn mk_closure(self, closure_id: DefId, closure_substs: ClosureSubsts<'tcx>)
|
||||||
-> Ty<'tcx> {
|
-> Ty<'tcx> {
|
||||||
self.mk_ty(Closure(closure_id, closure_substs))
|
self.mk_ty(Closure(closure_id, closure_substs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_generator(self,
|
pub fn mk_generator(self,
|
||||||
id: DefId,
|
id: DefId,
|
||||||
generator_substs: GeneratorSubsts<'tcx>,
|
generator_substs: GeneratorSubsts<'tcx>,
|
||||||
|
@ -2684,32 +2713,39 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.mk_ty(Generator(id, generator_substs, movability))
|
self.mk_ty(Generator(id, generator_substs, movability))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_generator_witness(self, types: ty::Binder<&'tcx List<Ty<'tcx>>>) -> Ty<'tcx> {
|
pub fn mk_generator_witness(self, types: ty::Binder<&'tcx List<Ty<'tcx>>>) -> Ty<'tcx> {
|
||||||
self.mk_ty(GeneratorWitness(types))
|
self.mk_ty(GeneratorWitness(types))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_var(self, v: TyVid) -> Ty<'tcx> {
|
pub fn mk_var(self, v: TyVid) -> Ty<'tcx> {
|
||||||
self.mk_infer(TyVar(v))
|
self.mk_infer(TyVar(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_int_var(self, v: IntVid) -> Ty<'tcx> {
|
pub fn mk_int_var(self, v: IntVid) -> Ty<'tcx> {
|
||||||
self.mk_infer(IntVar(v))
|
self.mk_infer(IntVar(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_float_var(self, v: FloatVid) -> Ty<'tcx> {
|
pub fn mk_float_var(self, v: FloatVid) -> Ty<'tcx> {
|
||||||
self.mk_infer(FloatVar(v))
|
self.mk_infer(FloatVar(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_infer(self, it: InferTy) -> Ty<'tcx> {
|
pub fn mk_infer(self, it: InferTy) -> Ty<'tcx> {
|
||||||
self.mk_ty(Infer(it))
|
self.mk_ty(Infer(it))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_ty_param(self,
|
pub fn mk_ty_param(self,
|
||||||
index: u32,
|
index: u32,
|
||||||
name: InternedString) -> Ty<'tcx> {
|
name: InternedString) -> Ty<'tcx> {
|
||||||
self.mk_ty(Param(ParamTy { idx: index, name: name }))
|
self.mk_ty(Param(ParamTy { idx: index, name: name }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_self_type(self) -> Ty<'tcx> {
|
pub fn mk_self_type(self) -> Ty<'tcx> {
|
||||||
self.mk_ty_param(0, keywords::SelfType.name().as_interned_str())
|
self.mk_ty_param(0, keywords::SelfType.name().as_interned_str())
|
||||||
}
|
}
|
||||||
|
@ -2723,6 +2759,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn mk_opaque(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
pub fn mk_opaque(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||||
self.mk_ty(Opaque(def_id, substs))
|
self.mk_ty(Opaque(def_id, substs))
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,6 +374,7 @@ pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
|
||||||
|
#[inline]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
skipped_regions: &'a mut bool,
|
skipped_regions: &'a mut bool,
|
||||||
|
|
|
@ -1275,6 +1275,7 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
|
||||||
self.skip_binder().projection_ty.item_def_id
|
self.skip_binder().projection_ty.item_def_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'_, '_, '_>) -> PolyTraitRef<'tcx> {
|
pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'_, '_, '_>) -> PolyTraitRef<'tcx> {
|
||||||
// Note: unlike with `TraitRef::to_poly_trait_ref()`,
|
// Note: unlike with `TraitRef::to_poly_trait_ref()`,
|
||||||
// `self.0.trait_ref` is permitted to have escaping regions.
|
// `self.0.trait_ref` is permitted to have escaping regions.
|
||||||
|
@ -1633,6 +1634,7 @@ impl<'tcx> ParamEnv<'tcx> {
|
||||||
/// there are no where clauses in scope. Hidden types (like `impl
|
/// there are no where clauses in scope. Hidden types (like `impl
|
||||||
/// Trait`) are left hidden, so this is suitable for ordinary
|
/// Trait`) are left hidden, so this is suitable for ordinary
|
||||||
/// type-checking.
|
/// type-checking.
|
||||||
|
#[inline]
|
||||||
pub fn empty() -> Self {
|
pub fn empty() -> Self {
|
||||||
Self::new(List::empty(), Reveal::UserFacing)
|
Self::new(List::empty(), Reveal::UserFacing)
|
||||||
}
|
}
|
||||||
|
@ -1644,11 +1646,13 @@ impl<'tcx> ParamEnv<'tcx> {
|
||||||
///
|
///
|
||||||
/// N.B. If you want to have predicates in scope, use `ParamEnv::new`,
|
/// N.B. If you want to have predicates in scope, use `ParamEnv::new`,
|
||||||
/// or invoke `param_env.with_reveal_all()`.
|
/// or invoke `param_env.with_reveal_all()`.
|
||||||
|
#[inline]
|
||||||
pub fn reveal_all() -> Self {
|
pub fn reveal_all() -> Self {
|
||||||
Self::new(List::empty(), Reveal::All)
|
Self::new(List::empty(), Reveal::All)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a trait environment with the given set of predicates.
|
/// Construct a trait environment with the given set of predicates.
|
||||||
|
#[inline]
|
||||||
pub fn new(caller_bounds: &'tcx List<ty::Predicate<'tcx>>,
|
pub fn new(caller_bounds: &'tcx List<ty::Predicate<'tcx>>,
|
||||||
reveal: Reveal)
|
reveal: Reveal)
|
||||||
-> Self {
|
-> Self {
|
||||||
|
@ -2148,6 +2152,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn variant_descr(&self) -> &'static str {
|
pub fn variant_descr(&self) -> &'static str {
|
||||||
match self.adt_kind() {
|
match self.adt_kind() {
|
||||||
AdtKind::Struct => "struct",
|
AdtKind::Struct => "struct",
|
||||||
|
|
|
@ -667,6 +667,7 @@ impl<'tcx> TraitRef<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn self_ty(&self) -> Ty<'tcx> {
|
pub fn self_ty(&self) -> Ty<'tcx> {
|
||||||
self.substs.type_at(0)
|
self.substs.type_at(0)
|
||||||
}
|
}
|
||||||
|
@ -978,15 +979,18 @@ impl<'tcx> FnSig<'tcx> {
|
||||||
pub type PolyFnSig<'tcx> = Binder<FnSig<'tcx>>;
|
pub type PolyFnSig<'tcx> = Binder<FnSig<'tcx>>;
|
||||||
|
|
||||||
impl<'tcx> PolyFnSig<'tcx> {
|
impl<'tcx> PolyFnSig<'tcx> {
|
||||||
|
#[inline]
|
||||||
pub fn inputs(&self) -> Binder<&'tcx [Ty<'tcx>]> {
|
pub fn inputs(&self) -> Binder<&'tcx [Ty<'tcx>]> {
|
||||||
self.map_bound_ref(|fn_sig| fn_sig.inputs())
|
self.map_bound_ref(|fn_sig| fn_sig.inputs())
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn input(&self, index: usize) -> ty::Binder<Ty<'tcx>> {
|
pub fn input(&self, index: usize) -> ty::Binder<Ty<'tcx>> {
|
||||||
self.map_bound_ref(|fn_sig| fn_sig.inputs()[index])
|
self.map_bound_ref(|fn_sig| fn_sig.inputs()[index])
|
||||||
}
|
}
|
||||||
pub fn inputs_and_output(&self) -> ty::Binder<&'tcx List<Ty<'tcx>>> {
|
pub fn inputs_and_output(&self) -> ty::Binder<&'tcx List<Ty<'tcx>>> {
|
||||||
self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output)
|
self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output)
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn output(&self) -> ty::Binder<Ty<'tcx>> {
|
pub fn output(&self) -> ty::Binder<Ty<'tcx>> {
|
||||||
self.map_bound_ref(|fn_sig| fn_sig.output())
|
self.map_bound_ref(|fn_sig| fn_sig.output())
|
||||||
}
|
}
|
||||||
|
@ -1548,6 +1552,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn is_ty_var(&self) -> bool {
|
pub fn is_ty_var(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
Infer(TyVar(_)) => true,
|
Infer(TyVar(_)) => true,
|
||||||
|
@ -1732,6 +1737,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn is_integral(&self) -> bool {
|
pub fn is_integral(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
Infer(IntVar(_)) | Int(_) | Uint(_) => true,
|
Infer(IntVar(_)) | Int(_) | Uint(_) => true,
|
||||||
|
@ -1762,6 +1768,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn is_fp(&self) -> bool {
|
pub fn is_fp(&self) -> bool {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
Infer(FloatVar(_)) | Float(_) => true,
|
Infer(FloatVar(_)) | Float(_) => true,
|
||||||
|
@ -1845,6 +1852,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> {
|
pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
Adt(adt, _) => Some(adt),
|
Adt(adt, _) => Some(adt),
|
||||||
|
|
|
@ -587,6 +587,7 @@ impl fmt::Debug for SpanData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MultiSpan {
|
impl MultiSpan {
|
||||||
|
#[inline]
|
||||||
pub fn new() -> MultiSpan {
|
pub fn new() -> MultiSpan {
|
||||||
MultiSpan {
|
MultiSpan {
|
||||||
primary_spans: vec![],
|
primary_spans: vec![],
|
||||||
|
|
Loading…
Add table
Reference in a new issue