rustc: don't call Kind::from directly, use .into() instead.
This commit is contained in:
parent
e3df729c25
commit
196b2e0d82
@ -256,11 +256,11 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
||||
|
||||
CanonicalTyVarKind::Float => self.tcx.mk_float_var(self.next_float_var_id()),
|
||||
};
|
||||
Kind::from(ty)
|
||||
ty.into()
|
||||
}
|
||||
|
||||
CanonicalVarKind::Region => {
|
||||
Kind::from(self.next_region_var(RegionVariableOrigin::MiscVariable(span)))
|
||||
self.next_region_var(RegionVariableOrigin::MiscVariable(span)).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -555,7 +555,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
|
||||
opportunistically resolved to {:?}",
|
||||
vid, r
|
||||
);
|
||||
let cvar = self.canonical_var(info, Kind::from(r));
|
||||
let cvar = self.canonical_var(info, r.into());
|
||||
self.tcx().mk_region(ty::ReCanonical(cvar))
|
||||
}
|
||||
|
||||
@ -570,7 +570,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
|
||||
let info = CanonicalVarInfo {
|
||||
kind: CanonicalVarKind::Region,
|
||||
};
|
||||
let cvar = self.canonical_var(info, Kind::from(r));
|
||||
let cvar = self.canonical_var(info, r.into());
|
||||
self.tcx().mk_region(ty::ReCanonical(cvar))
|
||||
} else {
|
||||
r
|
||||
@ -750,7 +750,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
|
||||
let info = CanonicalVarInfo {
|
||||
kind: CanonicalVarKind::Ty(ty_kind),
|
||||
};
|
||||
let cvar = self.canonical_var(info, Kind::from(ty_var));
|
||||
let cvar = self.canonical_var(info, ty_var.into());
|
||||
self.tcx().mk_infer(ty::InferTy::CanonicalTy(cvar))
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ use dep_graph::{DepNodeIndex, DepKind};
|
||||
use hir::def_id::DefId;
|
||||
use infer;
|
||||
use infer::{InferCtxt, InferOk, TypeFreshener};
|
||||
use ty::subst::{Kind, Subst, Substs};
|
||||
use ty::subst::{Subst, Substs};
|
||||
use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable};
|
||||
use ty::fast_reject;
|
||||
use ty::relate::TypeRelation;
|
||||
@ -3019,7 +3019,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||
// with a potentially unsized trailing field.
|
||||
let params = substs_a.iter().enumerate().map(|(i, &k)| {
|
||||
if ty_params.contains(i) {
|
||||
Kind::from(tcx.types.err)
|
||||
tcx.types.err.into()
|
||||
} else {
|
||||
k
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
// Type substitutions.
|
||||
|
||||
use hir::def_id::DefId;
|
||||
use ty::{self, Lift, Slice, Region, Ty, TyCtxt};
|
||||
use ty::{self, Lift, Slice, Ty, TyCtxt};
|
||||
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||
|
||||
use serialize::{self, Encodable, Encoder, Decodable, Decoder};
|
||||
@ -39,7 +39,7 @@ const TAG_MASK: usize = 0b11;
|
||||
const TYPE_TAG: usize = 0b00;
|
||||
const REGION_TAG: usize = 0b01;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, RustcEncodable, RustcDecodable)]
|
||||
pub enum UnpackedKind<'tcx> {
|
||||
Lifetime(ty::Region<'tcx>),
|
||||
Type(Ty<'tcx>),
|
||||
@ -142,34 +142,13 @@ impl<'tcx> TypeFoldable<'tcx> for Kind<'tcx> {
|
||||
|
||||
impl<'tcx> Encodable for Kind<'tcx> {
|
||||
fn encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> {
|
||||
e.emit_enum("Kind", |e| {
|
||||
match self.unpack() {
|
||||
UnpackedKind::Lifetime(lt) => {
|
||||
e.emit_enum_variant("Region", REGION_TAG, 1, |e| {
|
||||
e.emit_enum_variant_arg(0, |e| lt.encode(e))
|
||||
})
|
||||
}
|
||||
UnpackedKind::Type(ty) => {
|
||||
e.emit_enum_variant("Ty", TYPE_TAG, 1, |e| {
|
||||
e.emit_enum_variant_arg(0, |e| ty.encode(e))
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
self.unpack().encode(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Decodable for Kind<'tcx> {
|
||||
fn decode<D: Decoder>(d: &mut D) -> Result<Kind<'tcx>, D::Error> {
|
||||
d.read_enum("Kind", |d| {
|
||||
d.read_enum_variant(&["Ty", "Region"], |d, tag| {
|
||||
match tag {
|
||||
TYPE_TAG => Ty::decode(d).map(Kind::from),
|
||||
REGION_TAG => Region::decode(d).map(Kind::from),
|
||||
_ => Err(d.error("invalid Kind tag"))
|
||||
}
|
||||
})
|
||||
})
|
||||
Ok(UnpackedKind::decode(d)?.pack())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,6 @@ use rustc::ty::{self, Ty, TyCtxt};
|
||||
use rustc::ty::layout::{self, Align, TyLayout, LayoutOf};
|
||||
use rustc::ty::maps::Providers;
|
||||
use rustc::dep_graph::{DepNode, DepConstructor};
|
||||
use rustc::ty::subst::Kind;
|
||||
use rustc::middle::cstore::{self, LinkMeta, LinkagePreference};
|
||||
use rustc::middle::exported_symbols;
|
||||
use rustc::util::common::{time, print_time_passes_entry};
|
||||
@ -595,7 +594,7 @@ fn maybe_create_entry_wrapper(cx: &CodegenCx) {
|
||||
let start_fn = callee::resolve_and_get_fn(
|
||||
cx,
|
||||
start_def_id,
|
||||
cx.tcx.intern_substs(&[Kind::from(main_ret_ty)]),
|
||||
cx.tcx.intern_substs(&[main_ret_ty.into()]),
|
||||
);
|
||||
(start_fn, vec![bx.pointercast(rust_main, Type::i8p(cx).ptr_to()),
|
||||
arg_argc, arg_argv])
|
||||
|
@ -196,7 +196,7 @@ use rustc::hir::def_id::DefId;
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc::mir::interpret::{AllocId, ConstValue};
|
||||
use rustc::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem};
|
||||
use rustc::ty::subst::{Substs, Kind};
|
||||
use rustc::ty::subst::Substs;
|
||||
use rustc::ty::{self, TypeFoldable, Ty, TyCtxt, GenericParamDefKind};
|
||||
use rustc::ty::adjustment::CustomCoerceUnsized;
|
||||
use rustc::session::config;
|
||||
@ -1067,7 +1067,7 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
|
||||
self.tcx,
|
||||
ty::ParamEnv::reveal_all(),
|
||||
start_def_id,
|
||||
self.tcx.intern_substs(&[Kind::from(main_ret_ty)])
|
||||
self.tcx.intern_substs(&[main_ret_ty.into()])
|
||||
).unwrap();
|
||||
|
||||
self.output.push(create_fn_mono_item(start_instance));
|
||||
|
@ -13,7 +13,7 @@ use rustc::hir::def_id::DefId;
|
||||
use rustc::infer;
|
||||
use rustc::mir::*;
|
||||
use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind};
|
||||
use rustc::ty::subst::{Kind, Subst, Substs};
|
||||
use rustc::ty::subst::{Subst, Substs};
|
||||
use rustc::ty::maps::Providers;
|
||||
|
||||
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
|
||||
@ -170,7 +170,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
let substs = if let Some(ty) = ty {
|
||||
tcx.mk_substs(iter::once(Kind::from(ty)))
|
||||
tcx.mk_substs(iter::once(ty.into()))
|
||||
} else {
|
||||
Substs::identity_for_item(tcx, def_id)
|
||||
};
|
||||
|
@ -18,9 +18,9 @@ use hir::def::Def;
|
||||
use hir::def_id::DefId;
|
||||
use middle::resolve_lifetime as rl;
|
||||
use namespace::Namespace;
|
||||
use rustc::ty::subst::{Kind, UnpackedKind, Subst, Substs};
|
||||
use rustc::ty::subst::{UnpackedKind, Subst, Substs};
|
||||
use rustc::traits;
|
||||
use rustc::ty::{self, RegionKind, Ty, TyCtxt, ToPredicate, TypeFoldable};
|
||||
use rustc::ty::{self, Ty, TyCtxt, ToPredicate, TypeFoldable};
|
||||
use rustc::ty::GenericParamDefKind;
|
||||
use rustc::ty::wf::object_region_bounds;
|
||||
use rustc_target::spec::abi;
|
||||
@ -1164,7 +1164,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
// Replace all lifetimes with 'static
|
||||
for subst in &mut substs {
|
||||
if let UnpackedKind::Lifetime(_) = subst.unpack() {
|
||||
*subst = Kind::from(&RegionKind::ReStatic);
|
||||
*subst = tcx.types.re_static.into();
|
||||
}
|
||||
}
|
||||
debug!("impl_trait_ty_to_ty: substs from parent = {:?}", substs);
|
||||
@ -1173,7 +1173,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
|
||||
// Fill in our own generics with the resolved lifetimes
|
||||
assert_eq!(lifetimes.len(), generics.params.len());
|
||||
substs.extend(lifetimes.iter().map(|lt| Kind::from(self.ast_region_to_region(lt, None))));
|
||||
substs.extend(lifetimes.iter().map(|lt| self.ast_region_to_region(lt, None).into()));
|
||||
|
||||
debug!("impl_trait_ty_to_ty: final substs = {:?}", substs);
|
||||
|
||||
|
@ -94,7 +94,7 @@ use rustc::infer::anon_types::AnonTypeDecl;
|
||||
use rustc::infer::type_variable::{TypeVariableOrigin};
|
||||
use rustc::middle::region;
|
||||
use rustc::mir::interpret::{GlobalId};
|
||||
use rustc::ty::subst::{Kind, UnpackedKind, Subst, Substs};
|
||||
use rustc::ty::subst::{UnpackedKind, Subst, Substs};
|
||||
use rustc::traits::{self, ObligationCause, ObligationCauseCode, TraitEngine};
|
||||
use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind, Visibility, ToPredicate};
|
||||
use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
|
||||
@ -4754,7 +4754,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
if let GenericParamDefKind::Type(_) = param.kind {
|
||||
// Handle Self first, so we can adjust the index to match the AST.
|
||||
if has_self && i == 0 {
|
||||
return opt_self_ty.map(|ty| Kind::from(ty)).unwrap_or_else(|| {
|
||||
return opt_self_ty.map(|ty| ty.into()).unwrap_or_else(|| {
|
||||
self.var_for_def(span, param)
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user