Remove Ty prefix from Ty{Adt|Array|Slice|RawPtr|Ref|FnDef|FnPtr|Dynamic|Closure|Generator|GeneratorWitness|Never|Tuple|Projection|Anon|Infer|Error}
This commit is contained in:
parent
d37cee3b0e
commit
6f637da50c
157 changed files with 1430 additions and 1430 deletions
|
@ -809,8 +809,8 @@ for ty::TyKind<'gcx>
|
|||
TyBool |
|
||||
TyChar |
|
||||
TyStr |
|
||||
TyError |
|
||||
TyNever => {
|
||||
Error |
|
||||
Never => {
|
||||
// Nothing more to hash.
|
||||
}
|
||||
TyInt(int_ty) => {
|
||||
|
@ -822,55 +822,55 @@ for ty::TyKind<'gcx>
|
|||
TyFloat(float_ty) => {
|
||||
float_ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyAdt(adt_def, substs) => {
|
||||
Adt(adt_def, substs) => {
|
||||
adt_def.hash_stable(hcx, hasher);
|
||||
substs.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyArray(inner_ty, len) => {
|
||||
Array(inner_ty, len) => {
|
||||
inner_ty.hash_stable(hcx, hasher);
|
||||
len.hash_stable(hcx, hasher);
|
||||
}
|
||||
TySlice(inner_ty) => {
|
||||
Slice(inner_ty) => {
|
||||
inner_ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyRawPtr(pointee_ty) => {
|
||||
RawPtr(pointee_ty) => {
|
||||
pointee_ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyRef(region, pointee_ty, mutbl) => {
|
||||
Ref(region, pointee_ty, mutbl) => {
|
||||
region.hash_stable(hcx, hasher);
|
||||
pointee_ty.hash_stable(hcx, hasher);
|
||||
mutbl.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyFnDef(def_id, substs) => {
|
||||
FnDef(def_id, substs) => {
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
substs.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyFnPtr(ref sig) => {
|
||||
FnPtr(ref sig) => {
|
||||
sig.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyDynamic(ref existential_predicates, region) => {
|
||||
Dynamic(ref existential_predicates, region) => {
|
||||
existential_predicates.hash_stable(hcx, hasher);
|
||||
region.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyClosure(def_id, closure_substs) => {
|
||||
Closure(def_id, closure_substs) => {
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
closure_substs.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyGenerator(def_id, generator_substs, movability) => {
|
||||
Generator(def_id, generator_substs, movability) => {
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
generator_substs.hash_stable(hcx, hasher);
|
||||
movability.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyGeneratorWitness(types) => {
|
||||
GeneratorWitness(types) => {
|
||||
types.hash_stable(hcx, hasher)
|
||||
}
|
||||
TyTuple(inner_tys) => {
|
||||
Tuple(inner_tys) => {
|
||||
inner_tys.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyProjection(ref projection_ty) => {
|
||||
Projection(ref projection_ty) => {
|
||||
projection_ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyAnon(def_id, substs) => {
|
||||
Anon(def_id, substs) => {
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
substs.hash_stable(hcx, hasher);
|
||||
}
|
||||
|
@ -880,7 +880,7 @@ for ty::TyKind<'gcx>
|
|||
TyForeign(def_id) => {
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyInfer(infer_ty) => {
|
||||
Infer(infer_ty) => {
|
||||
infer_ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -592,7 +592,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ReverseMapper<'cx, 'gcx, 'tcx>
|
|||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
ty::TyClosure(def_id, substs) => {
|
||||
ty::Closure(def_id, substs) => {
|
||||
// I am a horrible monster and I pray for death. When
|
||||
// we encounter a closure here, it is always a closure
|
||||
// from within the function that we are currently
|
||||
|
@ -655,7 +655,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
|
|||
tcx,
|
||||
reg_op: |reg| reg,
|
||||
fldop: |ty| {
|
||||
if let ty::TyAnon(def_id, substs) = ty.sty {
|
||||
if let ty::Anon(def_id, substs) = ty.sty {
|
||||
// Check that this is `impl Trait` type is
|
||||
// declared by `parent_def_id` -- i.e., one whose
|
||||
// value we are inferring. At present, this is
|
||||
|
@ -679,7 +679,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
|
|||
// ```
|
||||
//
|
||||
// Here, the return type of `foo` references a
|
||||
// `TyAnon` indeed, but not one whose value is
|
||||
// `Anon` indeed, but not one whose value is
|
||||
// presently being inferred. You can get into a
|
||||
// similar situation with closure return types
|
||||
// today:
|
||||
|
@ -755,11 +755,11 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
|
|||
let tcx = infcx.tcx;
|
||||
|
||||
debug!(
|
||||
"instantiate_anon_types: TyAnon(def_id={:?}, substs={:?})",
|
||||
"instantiate_anon_types: Anon(def_id={:?}, substs={:?})",
|
||||
def_id, substs
|
||||
);
|
||||
|
||||
// Use the same type variable if the exact same TyAnon appears more
|
||||
// Use the same type variable if the exact same Anon appears more
|
||||
// than once in the return type (e.g. if it's passed to a type alias).
|
||||
if let Some(anon_defn) = self.anon_types.get(&def_id) {
|
||||
return anon_defn.concrete_ty;
|
||||
|
@ -805,7 +805,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> {
|
|||
|
||||
for predicate in bounds.predicates {
|
||||
// Change the predicate to refer to the type variable,
|
||||
// which will be the concrete type, instead of the TyAnon.
|
||||
// which will be the concrete type, instead of the Anon.
|
||||
// This also instantiates nested `impl Trait`.
|
||||
let predicate = self.instantiate_anon_types_in_map(&predicate);
|
||||
|
||||
|
|
|
@ -246,46 +246,46 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
|
|||
|
||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match t.sty {
|
||||
ty::TyInfer(ty::TyVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::General, t),
|
||||
ty::Infer(ty::TyVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::General, t),
|
||||
|
||||
ty::TyInfer(ty::IntVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::Int, t),
|
||||
ty::Infer(ty::IntVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::Int, t),
|
||||
|
||||
ty::TyInfer(ty::FloatVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::Float, t),
|
||||
ty::Infer(ty::FloatVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::Float, t),
|
||||
|
||||
ty::TyInfer(ty::FreshTy(_))
|
||||
| ty::TyInfer(ty::FreshIntTy(_))
|
||||
| ty::TyInfer(ty::FreshFloatTy(_)) => {
|
||||
ty::Infer(ty::FreshTy(_))
|
||||
| ty::Infer(ty::FreshIntTy(_))
|
||||
| ty::Infer(ty::FreshFloatTy(_)) => {
|
||||
bug!("encountered a fresh type during canonicalization")
|
||||
}
|
||||
|
||||
ty::TyInfer(ty::CanonicalTy(_)) => {
|
||||
ty::Infer(ty::CanonicalTy(_)) => {
|
||||
bug!("encountered a canonical type during canonicalization")
|
||||
}
|
||||
|
||||
ty::TyClosure(..)
|
||||
| ty::TyGenerator(..)
|
||||
| ty::TyGeneratorWitness(..)
|
||||
ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::TyBool
|
||||
| ty::TyChar
|
||||
| ty::TyInt(..)
|
||||
| ty::TyUint(..)
|
||||
| ty::TyFloat(..)
|
||||
| ty::TyAdt(..)
|
||||
| ty::Adt(..)
|
||||
| ty::TyStr
|
||||
| ty::TyError
|
||||
| ty::TyArray(..)
|
||||
| ty::TySlice(..)
|
||||
| ty::TyRawPtr(..)
|
||||
| ty::TyRef(..)
|
||||
| ty::TyFnDef(..)
|
||||
| ty::TyFnPtr(_)
|
||||
| ty::TyDynamic(..)
|
||||
| ty::TyNever
|
||||
| ty::TyTuple(..)
|
||||
| ty::TyProjection(..)
|
||||
| ty::Error
|
||||
| ty::Array(..)
|
||||
| ty::Slice(..)
|
||||
| ty::RawPtr(..)
|
||||
| ty::Ref(..)
|
||||
| ty::FnDef(..)
|
||||
| ty::FnPtr(_)
|
||||
| ty::Dynamic(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(..)
|
||||
| ty::Projection(..)
|
||||
| ty::TyForeign(..)
|
||||
| ty::TyParam(..)
|
||||
| ty::TyAnon(..) => {
|
||||
| ty::Anon(..) => {
|
||||
if t.flags.intersects(self.needs_canonical_flags) {
|
||||
t.super_fold_with(self)
|
||||
} else {
|
||||
|
|
|
@ -421,7 +421,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
|||
match result_value.unpack() {
|
||||
UnpackedKind::Type(result_value) => {
|
||||
// e.g., here `result_value` might be `?0` in the example above...
|
||||
if let ty::TyInfer(ty::InferTy::CanonicalTy(index)) = result_value.sty {
|
||||
if let ty::Infer(ty::InferTy::CanonicalTy(index)) = result_value.sty {
|
||||
// in which case we would set `canonical_vars[0]` to `Some(?U)`.
|
||||
opt_values[index] = Some(*original_value);
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for CanonicalVarValuesSubst<'cx, 'g
|
|||
|
||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match t.sty {
|
||||
ty::TyInfer(ty::InferTy::CanonicalTy(c)) => {
|
||||
ty::Infer(ty::InferTy::CanonicalTy(c)) => {
|
||||
match self.var_values.var_values[c].unpack() {
|
||||
UnpackedKind::Type(ty) => ty,
|
||||
r => bug!("{:?} is a type but value is {:?}", c, r),
|
||||
|
|
|
@ -76,44 +76,44 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
|
|||
|
||||
match (&a.sty, &b.sty) {
|
||||
// Relate integral variables to other types
|
||||
(&ty::TyInfer(ty::IntVar(a_id)), &ty::TyInfer(ty::IntVar(b_id))) => {
|
||||
(&ty::Infer(ty::IntVar(a_id)), &ty::Infer(ty::IntVar(b_id))) => {
|
||||
self.int_unification_table
|
||||
.borrow_mut()
|
||||
.unify_var_var(a_id, b_id)
|
||||
.map_err(|e| int_unification_error(a_is_expected, e))?;
|
||||
Ok(a)
|
||||
}
|
||||
(&ty::TyInfer(ty::IntVar(v_id)), &ty::TyInt(v)) => {
|
||||
(&ty::Infer(ty::IntVar(v_id)), &ty::TyInt(v)) => {
|
||||
self.unify_integral_variable(a_is_expected, v_id, IntType(v))
|
||||
}
|
||||
(&ty::TyInt(v), &ty::TyInfer(ty::IntVar(v_id))) => {
|
||||
(&ty::TyInt(v), &ty::Infer(ty::IntVar(v_id))) => {
|
||||
self.unify_integral_variable(!a_is_expected, v_id, IntType(v))
|
||||
}
|
||||
(&ty::TyInfer(ty::IntVar(v_id)), &ty::TyUint(v)) => {
|
||||
(&ty::Infer(ty::IntVar(v_id)), &ty::TyUint(v)) => {
|
||||
self.unify_integral_variable(a_is_expected, v_id, UintType(v))
|
||||
}
|
||||
(&ty::TyUint(v), &ty::TyInfer(ty::IntVar(v_id))) => {
|
||||
(&ty::TyUint(v), &ty::Infer(ty::IntVar(v_id))) => {
|
||||
self.unify_integral_variable(!a_is_expected, v_id, UintType(v))
|
||||
}
|
||||
|
||||
// Relate floating-point variables to other types
|
||||
(&ty::TyInfer(ty::FloatVar(a_id)), &ty::TyInfer(ty::FloatVar(b_id))) => {
|
||||
(&ty::Infer(ty::FloatVar(a_id)), &ty::Infer(ty::FloatVar(b_id))) => {
|
||||
self.float_unification_table
|
||||
.borrow_mut()
|
||||
.unify_var_var(a_id, b_id)
|
||||
.map_err(|e| float_unification_error(relation.a_is_expected(), e))?;
|
||||
Ok(a)
|
||||
}
|
||||
(&ty::TyInfer(ty::FloatVar(v_id)), &ty::TyFloat(v)) => {
|
||||
(&ty::Infer(ty::FloatVar(v_id)), &ty::TyFloat(v)) => {
|
||||
self.unify_float_variable(a_is_expected, v_id, v)
|
||||
}
|
||||
(&ty::TyFloat(v), &ty::TyInfer(ty::FloatVar(v_id))) => {
|
||||
(&ty::TyFloat(v), &ty::Infer(ty::FloatVar(v_id))) => {
|
||||
self.unify_float_variable(!a_is_expected, v_id, v)
|
||||
}
|
||||
|
||||
// All other cases of inference are errors
|
||||
(&ty::TyInfer(_), _) |
|
||||
(_, &ty::TyInfer(_)) => {
|
||||
(&ty::Infer(_), _) |
|
||||
(_, &ty::Infer(_)) => {
|
||||
Err(TypeError::Sorts(ty::relate::expected_found(relation, &a, &b)))
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
|
|||
// subtyping. This is basically our "occurs check", preventing
|
||||
// us from creating infinitely sized types.
|
||||
match t.sty {
|
||||
ty::TyInfer(ty::TyVar(vid)) => {
|
||||
ty::Infer(ty::TyVar(vid)) => {
|
||||
let mut variables = self.infcx.type_variables.borrow_mut();
|
||||
let vid = variables.root_var(vid);
|
||||
let sub_vid = variables.sub_root_var(vid);
|
||||
|
@ -433,8 +433,8 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, '
|
|||
}
|
||||
}
|
||||
}
|
||||
ty::TyInfer(ty::IntVar(_)) |
|
||||
ty::TyInfer(ty::FloatVar(_)) => {
|
||||
ty::Infer(ty::IntVar(_)) |
|
||||
ty::Infer(ty::FloatVar(_)) => {
|
||||
// No matter what mode we are in,
|
||||
// integer/floating-point types must be equal to be
|
||||
// relatable.
|
||||
|
|
|
@ -75,17 +75,17 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
|
|||
let a = infcx.type_variables.borrow_mut().replace_if_possible(a);
|
||||
let b = infcx.type_variables.borrow_mut().replace_if_possible(b);
|
||||
match (&a.sty, &b.sty) {
|
||||
(&ty::TyInfer(TyVar(a_id)), &ty::TyInfer(TyVar(b_id))) => {
|
||||
(&ty::Infer(TyVar(a_id)), &ty::Infer(TyVar(b_id))) => {
|
||||
infcx.type_variables.borrow_mut().equate(a_id, b_id);
|
||||
Ok(a)
|
||||
}
|
||||
|
||||
(&ty::TyInfer(TyVar(a_id)), _) => {
|
||||
(&ty::Infer(TyVar(a_id)), _) => {
|
||||
self.fields.instantiate(b, RelationDir::EqTo, a_id, self.a_is_expected)?;
|
||||
Ok(a)
|
||||
}
|
||||
|
||||
(_, &ty::TyInfer(TyVar(b_id))) => {
|
||||
(_, &ty::Infer(TyVar(b_id))) => {
|
||||
self.fields.instantiate(a, RelationDir::EqTo, b_id, self.a_is_expected)?;
|
||||
Ok(a)
|
||||
}
|
||||
|
|
|
@ -484,7 +484,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
// if they are both "path types", there's a chance of ambiguity
|
||||
// due to different versions of the same crate
|
||||
match (&exp_found.expected.sty, &exp_found.found.sty) {
|
||||
(&ty::TyAdt(exp_adt, _), &ty::TyAdt(found_adt, _)) => {
|
||||
(&ty::Adt(exp_adt, _), &ty::Adt(found_adt, _)) => {
|
||||
report_path_match(err, exp_adt.did, found_adt.did);
|
||||
}
|
||||
_ => (),
|
||||
|
@ -636,7 +636,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
|
||||
return Some(());
|
||||
}
|
||||
if let &ty::TyAdt(def, _) = &ta.sty {
|
||||
if let &ty::Adt(def, _) = &ta.sty {
|
||||
let path_ = self.tcx.item_path_str(def.did.clone());
|
||||
if path_ == other_path {
|
||||
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
|
||||
|
@ -704,14 +704,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
fn equals<'tcx>(a: &Ty<'tcx>, b: &Ty<'tcx>) -> bool {
|
||||
match (&a.sty, &b.sty) {
|
||||
(a, b) if *a == *b => true,
|
||||
(&ty::TyInt(_), &ty::TyInfer(ty::InferTy::IntVar(_)))
|
||||
| (&ty::TyInfer(ty::InferTy::IntVar(_)), &ty::TyInt(_))
|
||||
| (&ty::TyInfer(ty::InferTy::IntVar(_)), &ty::TyInfer(ty::InferTy::IntVar(_)))
|
||||
| (&ty::TyFloat(_), &ty::TyInfer(ty::InferTy::FloatVar(_)))
|
||||
| (&ty::TyInfer(ty::InferTy::FloatVar(_)), &ty::TyFloat(_))
|
||||
(&ty::TyInt(_), &ty::Infer(ty::InferTy::IntVar(_)))
|
||||
| (&ty::Infer(ty::InferTy::IntVar(_)), &ty::TyInt(_))
|
||||
| (&ty::Infer(ty::InferTy::IntVar(_)), &ty::Infer(ty::InferTy::IntVar(_)))
|
||||
| (&ty::TyFloat(_), &ty::Infer(ty::InferTy::FloatVar(_)))
|
||||
| (&ty::Infer(ty::InferTy::FloatVar(_)), &ty::TyFloat(_))
|
||||
| (
|
||||
&ty::TyInfer(ty::InferTy::FloatVar(_)),
|
||||
&ty::TyInfer(ty::InferTy::FloatVar(_)),
|
||||
&ty::Infer(ty::InferTy::FloatVar(_)),
|
||||
&ty::Infer(ty::InferTy::FloatVar(_)),
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
@ -738,7 +738,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
match (&t1.sty, &t2.sty) {
|
||||
(&ty::TyAdt(def1, sub1), &ty::TyAdt(def2, sub2)) => {
|
||||
(&ty::Adt(def1, sub1), &ty::Adt(def2, sub2)) => {
|
||||
let sub_no_defaults_1 = self.strip_generic_default_params(def1.did, sub1);
|
||||
let sub_no_defaults_2 = self.strip_generic_default_params(def2.did, sub2);
|
||||
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
|
||||
|
@ -877,13 +877,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// When finding T != &T, highlight only the borrow
|
||||
(&ty::TyRef(r1, ref_ty1, mutbl1), _) if equals(&ref_ty1, &t2) => {
|
||||
(&ty::Ref(r1, ref_ty1, mutbl1), _) if equals(&ref_ty1, &t2) => {
|
||||
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
|
||||
push_ty_ref(&r1, ref_ty1, mutbl1, &mut values.0);
|
||||
values.1.push_normal(t2.to_string());
|
||||
values
|
||||
}
|
||||
(_, &ty::TyRef(r2, ref_ty2, mutbl2)) if equals(&t1, &ref_ty2) => {
|
||||
(_, &ty::Ref(r2, ref_ty2, mutbl2)) if equals(&t1, &ref_ty2) => {
|
||||
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
|
||||
values.0.push_normal(t1.to_string());
|
||||
push_ty_ref(&r2, ref_ty2, mutbl2, &mut values.1);
|
||||
|
@ -891,8 +891,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// When encountering &T != &mut T, highlight only the borrow
|
||||
(&ty::TyRef(r1, ref_ty1, mutbl1),
|
||||
&ty::TyRef(r2, ref_ty2, mutbl2)) if equals(&ref_ty1, &ref_ty2) => {
|
||||
(&ty::Ref(r1, ref_ty1, mutbl1),
|
||||
&ty::Ref(r2, ref_ty2, mutbl2)) if equals(&ref_ty1, &ref_ty2) => {
|
||||
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
|
||||
push_ty_ref(&r1, ref_ty1, mutbl1, &mut values.0);
|
||||
push_ty_ref(&r2, ref_ty2, mutbl2, &mut values.1);
|
||||
|
@ -979,14 +979,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
(_, false, _) => {
|
||||
if let Some(exp_found) = exp_found {
|
||||
let (def_id, ret_ty) = match exp_found.found.sty {
|
||||
TyKind::TyFnDef(def, _) => {
|
||||
TyKind::FnDef(def, _) => {
|
||||
(Some(def), Some(self.tcx.fn_sig(def).output()))
|
||||
}
|
||||
_ => (None, None),
|
||||
};
|
||||
|
||||
let exp_is_struct = match exp_found.expected.sty {
|
||||
TyKind::TyAdt(def, _) => def.is_struct(),
|
||||
TyKind::Adt(def, _) => def.is_struct(),
|
||||
_ => false,
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use hir::{self, Local, Pat, Body, HirId};
|
|||
use hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use infer::InferCtxt;
|
||||
use infer::type_variable::TypeVariableOrigin;
|
||||
use ty::{self, Ty, TyInfer, TyVar};
|
||||
use ty::{self, Ty, Infer, TyVar};
|
||||
use syntax::source_map::CompilerDesugaringKind;
|
||||
use syntax_pos::Span;
|
||||
use errors::DiagnosticBuilder;
|
||||
|
@ -35,7 +35,7 @@ impl<'a, 'gcx, 'tcx> FindLocalByTypeVisitor<'a, 'gcx, 'tcx> {
|
|||
let ty = self.infcx.resolve_type_vars_if_possible(&ty);
|
||||
ty.walk().any(|inner_ty| {
|
||||
inner_ty == *self.target_ty || match (&inner_ty.sty, &self.target_ty.sty) {
|
||||
(&TyInfer(TyVar(a_vid)), &TyInfer(TyVar(b_vid))) => {
|
||||
(&Infer(TyVar(a_vid)), &Infer(TyVar(b_vid))) => {
|
||||
self.infcx
|
||||
.type_variables
|
||||
.borrow_mut()
|
||||
|
@ -75,7 +75,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindLocalByTypeVisitor<'a, 'gcx, 'tcx> {
|
|||
|
||||
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
pub fn extract_type_name(&self, ty: &'a Ty<'tcx>) -> String {
|
||||
if let ty::TyInfer(ty::TyVar(ty_vid)) = (*ty).sty {
|
||||
if let ty::Infer(ty::TyVar(ty_vid)) = (*ty).sty {
|
||||
let ty_vars = self.type_variables.borrow();
|
||||
if let TypeVariableOrigin::TypeParameterDefinition(_, name) =
|
||||
*ty_vars.var_origin(ty_vid) {
|
||||
|
|
|
@ -162,7 +162,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
|
|||
) -> Option<Span> {
|
||||
let ret_ty = self.tcx.type_of(scope_def_id);
|
||||
match ret_ty.sty {
|
||||
ty::TyFnDef(_, _) => {
|
||||
ty::FnDef(_, _) => {
|
||||
let sig = ret_ty.fn_sig(self.tcx);
|
||||
let late_bound_regions = self.tcx
|
||||
.collect_referenced_late_bound_regions(&sig.output());
|
||||
|
@ -181,7 +181,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
|
|||
) -> bool {
|
||||
let ret_ty = self.tcx.type_of(scope_def_id);
|
||||
match ret_ty.sty {
|
||||
ty::TyFnDef(_, _) => {
|
||||
ty::FnDef(_, _) => {
|
||||
let sig = ret_ty.fn_sig(self.tcx);
|
||||
let output = self.tcx.erase_late_bound_regions(&sig.output());
|
||||
return output.is_impl_trait();
|
||||
|
|
|
@ -133,7 +133,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
|
|||
let tcx = self.infcx.tcx;
|
||||
|
||||
match t.sty {
|
||||
ty::TyInfer(ty::TyVar(v)) => {
|
||||
ty::Infer(ty::TyVar(v)) => {
|
||||
let opt_ty = self.infcx.type_variables.borrow_mut().probe(v).known();
|
||||
self.freshen(
|
||||
opt_ty,
|
||||
|
@ -141,7 +141,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
|
|||
ty::FreshTy)
|
||||
}
|
||||
|
||||
ty::TyInfer(ty::IntVar(v)) => {
|
||||
ty::Infer(ty::IntVar(v)) => {
|
||||
self.freshen(
|
||||
self.infcx.int_unification_table.borrow_mut()
|
||||
.probe_value(v)
|
||||
|
@ -150,7 +150,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
|
|||
ty::FreshIntTy)
|
||||
}
|
||||
|
||||
ty::TyInfer(ty::FloatVar(v)) => {
|
||||
ty::Infer(ty::FloatVar(v)) => {
|
||||
self.freshen(
|
||||
self.infcx.float_unification_table.borrow_mut()
|
||||
.probe_value(v)
|
||||
|
@ -159,9 +159,9 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
|
|||
ty::FreshFloatTy)
|
||||
}
|
||||
|
||||
ty::TyInfer(ty::FreshTy(c)) |
|
||||
ty::TyInfer(ty::FreshIntTy(c)) |
|
||||
ty::TyInfer(ty::FreshFloatTy(c)) => {
|
||||
ty::Infer(ty::FreshTy(c)) |
|
||||
ty::Infer(ty::FreshIntTy(c)) |
|
||||
ty::Infer(ty::FreshFloatTy(c)) => {
|
||||
if c >= self.freshen_count {
|
||||
bug!("Encountered a freshend type with id {} \
|
||||
but our counter is only at {}",
|
||||
|
@ -171,33 +171,33 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
|
|||
t
|
||||
}
|
||||
|
||||
ty::TyInfer(ty::CanonicalTy(..)) =>
|
||||
ty::Infer(ty::CanonicalTy(..)) =>
|
||||
bug!("encountered canonical ty during freshening"),
|
||||
|
||||
ty::TyGenerator(..) |
|
||||
ty::Generator(..) |
|
||||
ty::TyBool |
|
||||
ty::TyChar |
|
||||
ty::TyInt(..) |
|
||||
ty::TyUint(..) |
|
||||
ty::TyFloat(..) |
|
||||
ty::TyAdt(..) |
|
||||
ty::Adt(..) |
|
||||
ty::TyStr |
|
||||
ty::TyError |
|
||||
ty::TyArray(..) |
|
||||
ty::TySlice(..) |
|
||||
ty::TyRawPtr(..) |
|
||||
ty::TyRef(..) |
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyFnPtr(_) |
|
||||
ty::TyDynamic(..) |
|
||||
ty::TyNever |
|
||||
ty::TyTuple(..) |
|
||||
ty::TyProjection(..) |
|
||||
ty::Error |
|
||||
ty::Array(..) |
|
||||
ty::Slice(..) |
|
||||
ty::RawPtr(..) |
|
||||
ty::Ref(..) |
|
||||
ty::FnDef(..) |
|
||||
ty::FnPtr(_) |
|
||||
ty::Dynamic(..) |
|
||||
ty::Never |
|
||||
ty::Tuple(..) |
|
||||
ty::Projection(..) |
|
||||
ty::TyForeign(..) |
|
||||
ty::TyParam(..) |
|
||||
ty::TyClosure(..) |
|
||||
ty::TyGeneratorWitness(..) |
|
||||
ty::TyAnon(..) => {
|
||||
ty::Closure(..) |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Anon(..) => {
|
||||
t.super_fold_with(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFudger<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.sty {
|
||||
ty::TyInfer(ty::InferTy::TyVar(vid)) => {
|
||||
ty::Infer(ty::InferTy::TyVar(vid)) => {
|
||||
match self.type_variables.get(&vid) {
|
||||
None => {
|
||||
// This variable was created before the
|
||||
|
|
|
@ -88,12 +88,12 @@ pub fn super_lattice_tys<'a, 'gcx, 'tcx, L>(this: &mut L,
|
|||
// is (e.g.) `Box<i32>`. A more obvious solution might be to
|
||||
// iterate on the subtype obligations that are returned, but I
|
||||
// think this suffices. -nmatsakis
|
||||
(&ty::TyInfer(TyVar(..)), _) => {
|
||||
(&ty::Infer(TyVar(..)), _) => {
|
||||
let v = infcx.next_ty_var(TypeVariableOrigin::LatticeVariable(this.cause().span));
|
||||
this.relate_bound(v, b, a)?;
|
||||
Ok(v)
|
||||
}
|
||||
(_, &ty::TyInfer(TyVar(..))) => {
|
||||
(_, &ty::Infer(TyVar(..))) => {
|
||||
let v = infcx.next_ty_var(TypeVariableOrigin::LatticeVariable(this.cause().span));
|
||||
this.relate_bound(v, a, b)?;
|
||||
Ok(v)
|
||||
|
|
|
@ -546,7 +546,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
pub fn type_var_diverges(&'a self, ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyInfer(ty::TyVar(vid)) => self.type_variables.borrow().var_diverges(vid),
|
||||
ty::Infer(ty::TyVar(vid)) => self.type_variables.borrow().var_diverges(vid),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -559,14 +559,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
use ty::error::UnconstrainedNumeric::Neither;
|
||||
use ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat};
|
||||
match ty.sty {
|
||||
ty::TyInfer(ty::IntVar(vid)) => {
|
||||
ty::Infer(ty::IntVar(vid)) => {
|
||||
if self.int_unification_table.borrow_mut().probe_value(vid).is_some() {
|
||||
Neither
|
||||
} else {
|
||||
UnconstrainedInt
|
||||
}
|
||||
},
|
||||
ty::TyInfer(ty::FloatVar(vid)) => {
|
||||
ty::Infer(ty::FloatVar(vid)) => {
|
||||
if self.float_unification_table.borrow_mut().probe_value(vid).is_some() {
|
||||
Neither
|
||||
} else {
|
||||
|
@ -1118,7 +1118,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match typ.sty {
|
||||
ty::TyInfer(ty::TyVar(v)) => {
|
||||
ty::Infer(ty::TyVar(v)) => {
|
||||
// Not entirely obvious: if `typ` is a type variable,
|
||||
// it can be resolved to an int/float variable, which
|
||||
// can then be recursively resolved, hence the
|
||||
|
@ -1135,7 +1135,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
.unwrap_or(typ)
|
||||
}
|
||||
|
||||
ty::TyInfer(ty::IntVar(v)) => {
|
||||
ty::Infer(ty::IntVar(v)) => {
|
||||
self.int_unification_table
|
||||
.borrow_mut()
|
||||
.probe_value(v)
|
||||
|
@ -1143,7 +1143,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
.unwrap_or(typ)
|
||||
}
|
||||
|
||||
ty::TyInfer(ty::FloatVar(v)) => {
|
||||
ty::Infer(ty::FloatVar(v)) => {
|
||||
self.float_unification_table
|
||||
.borrow_mut()
|
||||
.probe_value(v)
|
||||
|
@ -1210,12 +1210,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// [Note-Type-error-reporting]
|
||||
// An invariant is that anytime the expected or actual type is TyError (the special
|
||||
// An invariant is that anytime the expected or actual type is Error (the special
|
||||
// error type, meaning that an error occurred when typechecking this expression),
|
||||
// this is a derived error. The error cascaded from another error (that was already
|
||||
// reported), so it's not useful to display it to the user.
|
||||
// The following methods implement this logic.
|
||||
// They check if either the actual or expected type is TyError, and don't print the error
|
||||
// They check if either the actual or expected type is Error, and don't print the error
|
||||
// in this case. The typechecker should only ever report type errors involving mismatched
|
||||
// types using one of these methods, and should not call span_err directly for such
|
||||
// errors.
|
||||
|
@ -1230,7 +1230,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
let actual_ty = self.resolve_type_vars_if_possible(&actual_ty);
|
||||
debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty);
|
||||
|
||||
// Don't report an error if actual type is TyError.
|
||||
// Don't report an error if actual type is Error.
|
||||
if actual_ty.references_error() {
|
||||
return self.tcx.sess.diagnostic().struct_dummy();
|
||||
}
|
||||
|
|
|
@ -451,7 +451,7 @@ where
|
|||
fn type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
|
||||
match ty.sty {
|
||||
ty::TyParam(p) => self.param_bound(p),
|
||||
ty::TyProjection(data) => {
|
||||
ty::Projection(data) => {
|
||||
let declared_bounds = self.projection_declared_bounds(data);
|
||||
self.projection_bound(declared_bounds, data)
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'gcx, 'tcx>
|
|||
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
|
||||
let t = self.infcx.shallow_resolve(t);
|
||||
if t.has_infer_types() {
|
||||
if let ty::TyInfer(_) = t.sty {
|
||||
if let ty::Infer(_) = t.sty {
|
||||
// Since we called `shallow_resolve` above, this must
|
||||
// be an (as yet...) unresolved inference variable.
|
||||
true
|
||||
|
@ -158,19 +158,19 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for FullTypeResolver<'a, 'gcx, 'tcx>
|
|||
} else {
|
||||
let t = self.infcx.shallow_resolve(t);
|
||||
match t.sty {
|
||||
ty::TyInfer(ty::TyVar(vid)) => {
|
||||
ty::Infer(ty::TyVar(vid)) => {
|
||||
self.err = Some(FixupError::UnresolvedTy(vid));
|
||||
self.tcx().types.err
|
||||
}
|
||||
ty::TyInfer(ty::IntVar(vid)) => {
|
||||
ty::Infer(ty::IntVar(vid)) => {
|
||||
self.err = Some(FixupError::UnresolvedIntTy(vid));
|
||||
self.tcx().types.err
|
||||
}
|
||||
ty::TyInfer(ty::FloatVar(vid)) => {
|
||||
ty::Infer(ty::FloatVar(vid)) => {
|
||||
self.err = Some(FixupError::UnresolvedFloatTy(vid));
|
||||
self.tcx().types.err
|
||||
}
|
||||
ty::TyInfer(_) => {
|
||||
ty::Infer(_) => {
|
||||
bug!("Unexpected type in full type resolver: {:?}", t);
|
||||
}
|
||||
_ => {
|
||||
|
|
|
@ -80,7 +80,7 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
|
|||
let a = infcx.type_variables.borrow_mut().replace_if_possible(a);
|
||||
let b = infcx.type_variables.borrow_mut().replace_if_possible(b);
|
||||
match (&a.sty, &b.sty) {
|
||||
(&ty::TyInfer(TyVar(a_vid)), &ty::TyInfer(TyVar(b_vid))) => {
|
||||
(&ty::Infer(TyVar(a_vid)), &ty::Infer(TyVar(b_vid))) => {
|
||||
// Shouldn't have any LBR here, so we can safely put
|
||||
// this under a binder below without fear of accidental
|
||||
// capture.
|
||||
|
@ -106,17 +106,17 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
|
|||
|
||||
Ok(a)
|
||||
}
|
||||
(&ty::TyInfer(TyVar(a_id)), _) => {
|
||||
(&ty::Infer(TyVar(a_id)), _) => {
|
||||
self.fields
|
||||
.instantiate(b, RelationDir::SupertypeOf, a_id, !self.a_is_expected)?;
|
||||
Ok(a)
|
||||
}
|
||||
(_, &ty::TyInfer(TyVar(b_id))) => {
|
||||
(_, &ty::Infer(TyVar(b_id))) => {
|
||||
self.fields.instantiate(a, RelationDir::SubtypeOf, b_id, self.a_is_expected)?;
|
||||
Ok(a)
|
||||
}
|
||||
|
||||
(&ty::TyError, _) | (_, &ty::TyError) => {
|
||||
(&ty::Error, _) | (_, &ty::Error) => {
|
||||
infcx.set_tainted_by_errors();
|
||||
Ok(self.tcx().types.err)
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
|
|||
/// instantiated. Otherwise, returns `t`.
|
||||
pub fn replace_if_possible(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match t.sty {
|
||||
ty::TyInfer(ty::TyVar(v)) => {
|
||||
ty::Infer(ty::TyVar(v)) => {
|
||||
match self.probe(v) {
|
||||
TypeVariableValue::Unknown { .. } => t,
|
||||
TypeVariableValue::Known { value } => value,
|
||||
|
|
|
@ -105,11 +105,11 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
|
||||
fn handle_field_access(&mut self, lhs: &hir::Expr, node_id: ast::NodeId) {
|
||||
match self.tables.expr_ty_adjusted(lhs).sty {
|
||||
ty::TyAdt(def, _) => {
|
||||
ty::Adt(def, _) => {
|
||||
let index = self.tcx.field_index(node_id, self.tables);
|
||||
self.insert_def_id(def.non_enum_variant().fields[index].did);
|
||||
}
|
||||
ty::TyTuple(..) => {}
|
||||
ty::Tuple(..) => {}
|
||||
_ => span_bug!(lhs.span, "named field access on non-ADT"),
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
fn handle_field_pattern_match(&mut self, lhs: &hir::Pat, def: Def,
|
||||
pats: &[source_map::Spanned<hir::FieldPat>]) {
|
||||
let variant = match self.tables.node_id_to_type(lhs.hir_id).sty {
|
||||
ty::TyAdt(adt, _) => adt.variant_of_def(def),
|
||||
ty::Adt(adt, _) => adt.variant_of_def(def),
|
||||
_ => span_bug!(lhs.span, "non-ADT in struct pattern")
|
||||
};
|
||||
for pat in pats {
|
||||
|
@ -236,7 +236,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
|||
self.handle_field_access(&lhs, expr.id);
|
||||
}
|
||||
hir::ExprKind::Struct(_, ref fields, _) => {
|
||||
if let ty::TyKind::TyAdt(ref adt, _) = self.tables.expr_ty(expr).sty {
|
||||
if let ty::TyKind::Adt(ref adt, _) = self.tables.expr_ty(expr).sty {
|
||||
self.mark_as_used_if_union(adt, fields);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -457,7 +457,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
|||
// make sure that the thing we are pointing out stays valid
|
||||
// for the lifetime `scope_r` of the resulting ptr:
|
||||
let expr_ty = return_if_err!(self.mc.expr_ty(expr));
|
||||
if let ty::TyRef(r, _, _) = expr_ty.sty {
|
||||
if let ty::Ref(r, _, _) = expr_ty.sty {
|
||||
let bk = ty::BorrowKind::from_mutbl(m);
|
||||
self.borrow_expr(&base, r, bk, AddrOf);
|
||||
}
|
||||
|
@ -551,10 +551,10 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
|||
debug!("walk_callee: callee={:?} callee_ty={:?}",
|
||||
callee, callee_ty);
|
||||
match callee_ty.sty {
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
self.consume_expr(callee);
|
||||
}
|
||||
ty::TyError => { }
|
||||
ty::Error => { }
|
||||
_ => {
|
||||
if let Some(def) = self.mc.tables.type_dependent_defs().get(call.hir_id) {
|
||||
let def_id = def.def_id();
|
||||
|
@ -659,7 +659,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
|||
// Select just those fields of the `with`
|
||||
// expression that will actually be used
|
||||
match with_cmt.ty.sty {
|
||||
ty::TyAdt(adt, substs) if adt.is_struct() => {
|
||||
ty::Adt(adt, substs) if adt.is_struct() => {
|
||||
// Consume those fields of the with expression that are needed.
|
||||
for (f_index, with_field) in adt.non_enum_variant().fields.iter().enumerate() {
|
||||
let is_mentioned = fields.iter().any(|f| {
|
||||
|
@ -867,7 +867,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
|||
// It is also a borrow or copy/move of the value being matched.
|
||||
match bm {
|
||||
ty::BindByReference(m) => {
|
||||
if let ty::TyRef(r, _, _) = pat_ty.sty {
|
||||
if let ty::Ref(r, _, _) = pat_ty.sty {
|
||||
let bk = ty::BorrowKind::from_mutbl(m);
|
||||
delegate.borrow(pat.id, pat.span, &cmt_pat, r, bk, RefBinding);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ fn unpack_option_like<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
ty: Ty<'tcx>)
|
||||
-> Ty<'tcx> {
|
||||
let (def, substs) = match ty.sty {
|
||||
ty::TyAdt(def, substs) => (def, substs),
|
||||
ty::Adt(def, substs) => (def, substs),
|
||||
_ => return ty
|
||||
};
|
||||
|
||||
|
@ -83,7 +83,7 @@ impl<'a, 'tcx> ExprVisitor<'a, 'tcx> {
|
|||
// Special-case transmutting from `typeof(function)` and
|
||||
// `Option<typeof(function)>` to present a clearer error.
|
||||
let from = unpack_option_like(self.tcx.global_tcx(), from);
|
||||
if let (&ty::TyFnDef(..), SizeSkeleton::Known(size_to)) = (&from.sty, sk_to) {
|
||||
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (&from.sty, sk_to) {
|
||||
if size_to == Pointer.size(self.tcx) {
|
||||
struct_span_err!(self.tcx.sess, span, E0591,
|
||||
"can't transmute zero-sized type")
|
||||
|
|
|
@ -214,8 +214,8 @@ impl<'tcx> cmt_<'tcx> {
|
|||
fn resolve_field(&self, field_index: usize) -> Option<(&'tcx ty::AdtDef, &'tcx ty::FieldDef)>
|
||||
{
|
||||
let adt_def = match self.ty.sty {
|
||||
ty::TyAdt(def, _) => def,
|
||||
ty::TyTuple(..) => return None,
|
||||
ty::Adt(def, _) => def,
|
||||
ty::Tuple(..) => return None,
|
||||
// closures get `Categorization::Upvar` rather than `Categorization::Interior`
|
||||
_ => bug!("interior cmt {:?} is not an ADT", self)
|
||||
};
|
||||
|
@ -783,8 +783,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
// FnOnce | copied | upvar -> &'up bk
|
||||
|
||||
let kind = match self.node_ty(fn_hir_id)?.sty {
|
||||
ty::TyGenerator(..) => ty::ClosureKind::FnOnce,
|
||||
ty::TyClosure(closure_def_id, closure_substs) => {
|
||||
ty::Generator(..) => ty::ClosureKind::FnOnce,
|
||||
ty::Closure(closure_def_id, closure_substs) => {
|
||||
match self.infcx {
|
||||
// During upvar inference we may not know the
|
||||
// closure kind, just use the LATTICE_BOTTOM value.
|
||||
|
@ -893,7 +893,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
// that the above is actually immutable and
|
||||
// has a ref type. However, nothing should
|
||||
// actually look at the type, so we can get
|
||||
// away with stuffing a `TyError` in there
|
||||
// away with stuffing a `Error` in there
|
||||
// instead of bothering to construct a proper
|
||||
// one.
|
||||
let cmt_result = cmt_ {
|
||||
|
@ -956,7 +956,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
|
||||
// Always promote `[T; 0]` (even when e.g. borrowed mutably).
|
||||
let promotable = match expr_ty.sty {
|
||||
ty::TyArray(_, len) if len.assert_usize(self.tcx) == Some(0) => true,
|
||||
ty::Array(_, len) if len.assert_usize(self.tcx) == Some(0) => true,
|
||||
_ => promotable,
|
||||
};
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
let base_ty = self.expr_ty_adjusted(base)?;
|
||||
|
||||
let (region, mutbl) = match base_ty.sty {
|
||||
ty::TyRef(region, _, mutbl) => (region, mutbl),
|
||||
ty::Ref(region, _, mutbl) => (region, mutbl),
|
||||
_ => {
|
||||
span_bug!(expr.span, "cat_overloaded_place: base is not a reference")
|
||||
}
|
||||
|
@ -1068,9 +1068,9 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
};
|
||||
|
||||
let ptr = match base_cmt.ty.sty {
|
||||
ty::TyAdt(def, ..) if def.is_box() => Unique,
|
||||
ty::TyRawPtr(ref mt) => UnsafePtr(mt.mutbl),
|
||||
ty::TyRef(r, _, mutbl) => {
|
||||
ty::Adt(def, ..) if def.is_box() => Unique,
|
||||
ty::RawPtr(ref mt) => UnsafePtr(mt.mutbl),
|
||||
ty::Ref(r, _, mutbl) => {
|
||||
let bk = ty::BorrowKind::from_mutbl(mutbl);
|
||||
BorrowedPtr(bk, r)
|
||||
}
|
||||
|
@ -1290,7 +1290,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
Def::StructCtor(_, CtorKind::Fn) => {
|
||||
match self.pat_ty_unadjusted(&pat)?.sty {
|
||||
ty::TyAdt(adt_def, _) => {
|
||||
ty::Adt(adt_def, _) => {
|
||||
(cmt, adt_def.non_enum_variant().fields.len())
|
||||
}
|
||||
ref ty => {
|
||||
|
@ -1343,7 +1343,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
PatKind::Tuple(ref subpats, ddpos) => {
|
||||
// (p1, ..., pN)
|
||||
let expected_len = match self.pat_ty_unadjusted(&pat)?.sty {
|
||||
ty::TyTuple(ref tys) => tys.len(),
|
||||
ty::Tuple(ref tys) => tys.len(),
|
||||
ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty),
|
||||
};
|
||||
for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) {
|
||||
|
|
|
@ -2248,14 +2248,14 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const) -> fmt::Result {
|
|||
}
|
||||
}
|
||||
// print function definitons
|
||||
if let TyFnDef(did, _) = ty.sty {
|
||||
if let FnDef(did, _) = ty.sty {
|
||||
return write!(f, "{}", item_path_str(did));
|
||||
}
|
||||
// print string literals
|
||||
if let ConstValue::ScalarPair(ptr, len) = value {
|
||||
if let Scalar::Ptr(ptr) = ptr {
|
||||
if let ScalarMaybeUndef::Scalar(Scalar::Bits { bits: len, .. }) = len {
|
||||
if let TyRef(_, &ty::TyS { sty: TyStr, .. }, _) = ty.sty {
|
||||
if let Ref(_, &ty::TyS { sty: TyStr, .. }, _) = ty.sty {
|
||||
return ty::tls::with(|tcx| {
|
||||
let alloc = tcx.alloc_map.lock().get(ptr.alloc_id);
|
||||
if let Some(interpret::AllocType::Memory(alloc)) = alloc {
|
||||
|
|
|
@ -68,12 +68,12 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
|
|||
let ty = self.to_ty(tcx);
|
||||
PlaceTy::Ty {
|
||||
ty: match ty.sty {
|
||||
ty::TyArray(inner, size) => {
|
||||
ty::Array(inner, size) => {
|
||||
let size = size.unwrap_usize(tcx);
|
||||
let len = size - (from as u64) - (to as u64);
|
||||
tcx.mk_array(inner, len)
|
||||
}
|
||||
ty::TySlice(..) => ty,
|
||||
ty::Slice(..) => ty,
|
||||
_ => {
|
||||
bug!("cannot subslice non-array type: `{:?}`", self)
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
|
|||
}
|
||||
ProjectionElem::Downcast(adt_def1, index) =>
|
||||
match self.to_ty(tcx).sty {
|
||||
ty::TyAdt(adt_def, substs) => {
|
||||
ty::Adt(adt_def, substs) => {
|
||||
assert!(adt_def.is_enum());
|
||||
assert!(index < adt_def.variants.len());
|
||||
assert_eq!(adt_def, adt_def1);
|
||||
|
@ -199,7 +199,7 @@ impl<'tcx> Rvalue<'tcx> {
|
|||
}
|
||||
Rvalue::Discriminant(ref place) => {
|
||||
let ty = place.ty(local_decls, tcx).to_ty(tcx);
|
||||
if let ty::TyAdt(adt_def, _) = ty.sty {
|
||||
if let ty::Adt(adt_def, _) = ty.sty {
|
||||
adt_def.repr.discr_type().to_ty(tcx)
|
||||
} else {
|
||||
// This can only be `0`, for now, so `u8` will suffice.
|
||||
|
|
|
@ -607,7 +607,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
|||
|
||||
return match substs.type_at(0).sty {
|
||||
ty::TyParam(_) => true,
|
||||
ty::TyProjection(p) => self.is_of_param(p.substs),
|
||||
ty::Projection(p) => self.is_of_param(p.substs),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -407,7 +407,7 @@ fn uncovered_tys<'tcx>(tcx: TyCtxt, ty: Ty<'tcx>, in_crate: InCrate)
|
|||
|
||||
fn is_possibly_remote_type(ty: Ty, _in_crate: InCrate) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyProjection(..) | ty::TyParam(..) => true,
|
||||
ty::Projection(..) | ty::TyParam(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -419,9 +419,9 @@ fn ty_is_local(tcx: TyCtxt, ty: Ty, in_crate: InCrate) -> bool {
|
|||
|
||||
fn fundamental_ty(tcx: TyCtxt, ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyRef(..) => true,
|
||||
ty::TyAdt(def, _) => def.is_fundamental(),
|
||||
ty::TyDynamic(ref data, ..) => {
|
||||
ty::Ref(..) => true,
|
||||
ty::Adt(def, _) => def.is_fundamental(),
|
||||
ty::Dynamic(ref data, ..) => {
|
||||
data.principal().map_or(false, |p| tcx.has_attr(p.def_id(), "fundamental"))
|
||||
}
|
||||
_ => false
|
||||
|
@ -447,43 +447,43 @@ fn ty_is_local_constructor(ty: Ty, in_crate: InCrate) -> bool {
|
|||
ty::TyUint(..) |
|
||||
ty::TyFloat(..) |
|
||||
ty::TyStr |
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyFnPtr(_) |
|
||||
ty::TyArray(..) |
|
||||
ty::TySlice(..) |
|
||||
ty::TyRawPtr(..) |
|
||||
ty::TyRef(..) |
|
||||
ty::TyNever |
|
||||
ty::TyTuple(..) |
|
||||
ty::FnDef(..) |
|
||||
ty::FnPtr(_) |
|
||||
ty::Array(..) |
|
||||
ty::Slice(..) |
|
||||
ty::RawPtr(..) |
|
||||
ty::Ref(..) |
|
||||
ty::Never |
|
||||
ty::Tuple(..) |
|
||||
ty::TyParam(..) |
|
||||
ty::TyProjection(..) => {
|
||||
ty::Projection(..) => {
|
||||
false
|
||||
}
|
||||
|
||||
ty::TyInfer(..) => match in_crate {
|
||||
ty::Infer(..) => match in_crate {
|
||||
InCrate::Local => false,
|
||||
// The inference variable might be unified with a local
|
||||
// type in that remote crate.
|
||||
InCrate::Remote => true,
|
||||
},
|
||||
|
||||
ty::TyAdt(def, _) => def_id_is_local(def.did, in_crate),
|
||||
ty::Adt(def, _) => def_id_is_local(def.did, in_crate),
|
||||
ty::TyForeign(did) => def_id_is_local(did, in_crate),
|
||||
|
||||
ty::TyDynamic(ref tt, ..) => {
|
||||
ty::Dynamic(ref tt, ..) => {
|
||||
tt.principal().map_or(false, |p| {
|
||||
def_id_is_local(p.def_id(), in_crate)
|
||||
})
|
||||
}
|
||||
|
||||
ty::TyError => {
|
||||
ty::Error => {
|
||||
true
|
||||
}
|
||||
|
||||
ty::TyClosure(..) |
|
||||
ty::TyGenerator(..) |
|
||||
ty::TyGeneratorWitness(..) |
|
||||
ty::TyAnon(..) => {
|
||||
ty::Closure(..) |
|
||||
ty::Generator(..) |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Anon(..) => {
|
||||
bug!("ty_is_local invoked on unexpected type: {:?}", ty)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,33 +247,33 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
ty::TyBool => Some(0),
|
||||
ty::TyChar => Some(1),
|
||||
ty::TyStr => Some(2),
|
||||
ty::TyInt(..) | ty::TyUint(..) | ty::TyInfer(ty::IntVar(..)) => Some(3),
|
||||
ty::TyFloat(..) | ty::TyInfer(ty::FloatVar(..)) => Some(4),
|
||||
ty::TyRef(..) | ty::TyRawPtr(..) => Some(5),
|
||||
ty::TyArray(..) | ty::TySlice(..) => Some(6),
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(..) => Some(7),
|
||||
ty::TyDynamic(..) => Some(8),
|
||||
ty::TyClosure(..) => Some(9),
|
||||
ty::TyTuple(..) => Some(10),
|
||||
ty::TyProjection(..) => Some(11),
|
||||
ty::TyInt(..) | ty::TyUint(..) | ty::Infer(ty::IntVar(..)) => Some(3),
|
||||
ty::TyFloat(..) | ty::Infer(ty::FloatVar(..)) => Some(4),
|
||||
ty::Ref(..) | ty::RawPtr(..) => Some(5),
|
||||
ty::Array(..) | ty::Slice(..) => Some(6),
|
||||
ty::FnDef(..) | ty::FnPtr(..) => Some(7),
|
||||
ty::Dynamic(..) => Some(8),
|
||||
ty::Closure(..) => Some(9),
|
||||
ty::Tuple(..) => Some(10),
|
||||
ty::Projection(..) => Some(11),
|
||||
ty::TyParam(..) => Some(12),
|
||||
ty::TyAnon(..) => Some(13),
|
||||
ty::TyNever => Some(14),
|
||||
ty::TyAdt(adt, ..) => match adt.adt_kind() {
|
||||
ty::Anon(..) => Some(13),
|
||||
ty::Never => Some(14),
|
||||
ty::Adt(adt, ..) => match adt.adt_kind() {
|
||||
AdtKind::Struct => Some(15),
|
||||
AdtKind::Union => Some(16),
|
||||
AdtKind::Enum => Some(17),
|
||||
},
|
||||
ty::TyGenerator(..) => Some(18),
|
||||
ty::Generator(..) => Some(18),
|
||||
ty::TyForeign(..) => Some(19),
|
||||
ty::TyGeneratorWitness(..) => Some(20),
|
||||
ty::TyInfer(..) | ty::TyError => None
|
||||
ty::GeneratorWitness(..) => Some(20),
|
||||
ty::Infer(..) | ty::Error => None
|
||||
}
|
||||
}
|
||||
|
||||
match (type_category(a), type_category(b)) {
|
||||
(Some(cat_a), Some(cat_b)) => match (&a.sty, &b.sty) {
|
||||
(&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) => def_a == def_b,
|
||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => def_a == def_b,
|
||||
_ => cat_a == cat_b
|
||||
},
|
||||
// infer and error can be equated to all types
|
||||
|
@ -784,10 +784,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
let found_trait_ty = found_trait_ref.self_ty();
|
||||
|
||||
let found_did = match found_trait_ty.sty {
|
||||
ty::TyClosure(did, _) |
|
||||
ty::Closure(did, _) |
|
||||
ty::TyForeign(did) |
|
||||
ty::TyFnDef(did, _) => Some(did),
|
||||
ty::TyAdt(def, _) => Some(def.did),
|
||||
ty::FnDef(did, _) => Some(did),
|
||||
ty::Adt(def, _) => Some(def.did),
|
||||
_ => None,
|
||||
};
|
||||
let found_span = found_did.and_then(|did| {
|
||||
|
@ -795,14 +795,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}).map(|sp| self.tcx.sess.source_map().def_span(sp)); // the sp could be an fn def
|
||||
|
||||
let found = match found_trait_ref.skip_binder().substs.type_at(1).sty {
|
||||
ty::TyTuple(ref tys) => tys.iter()
|
||||
ty::Tuple(ref tys) => tys.iter()
|
||||
.map(|_| ArgKind::empty()).collect::<Vec<_>>(),
|
||||
_ => vec![ArgKind::empty()],
|
||||
};
|
||||
let expected = match expected_trait_ref.skip_binder().substs.type_at(1).sty {
|
||||
ty::TyTuple(ref tys) => tys.iter()
|
||||
ty::Tuple(ref tys) => tys.iter()
|
||||
.map(|t| match t.sty {
|
||||
ty::TyKind::TyTuple(ref tys) => ArgKind::Tuple(
|
||||
ty::TyKind::Tuple(ref tys) => ArgKind::Tuple(
|
||||
Some(span),
|
||||
tys.iter()
|
||||
.map(|ty| ("_".to_owned(), ty.sty.to_string()))
|
||||
|
@ -899,7 +899,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
let mut trait_type = trait_ref.self_ty();
|
||||
|
||||
for refs_remaining in 0..refs_number {
|
||||
if let ty::TyKind::TyRef(_, t_type, _) = trait_type.sty {
|
||||
if let ty::TyKind::Ref(_, t_type, _) = trait_type.sty {
|
||||
trait_type = t_type;
|
||||
|
||||
let substs = self.tcx.mk_substs_trait(trait_type, &[]);
|
||||
|
@ -1143,7 +1143,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
fn build_fn_sig_string<'a, 'gcx, 'tcx>(tcx: ty::TyCtxt<'a, 'gcx, 'tcx>,
|
||||
trait_ref: &ty::TraitRef<'tcx>) -> String {
|
||||
let inputs = trait_ref.substs.type_at(1);
|
||||
let sig = if let ty::TyTuple(inputs) = inputs.sty {
|
||||
let sig = if let ty::Tuple(inputs) = inputs.sty {
|
||||
tcx.mk_fn_sig(
|
||||
inputs.iter().map(|&x| x),
|
||||
tcx.mk_infer(ty::TyVar(ty::TyVid { index: 0 })),
|
||||
|
@ -1594,7 +1594,7 @@ impl ArgKind {
|
|||
/// argument. This has no name (`_`) and no source spans..
|
||||
pub fn from_expected_ty(t: Ty<'_>) -> ArgKind {
|
||||
match t.sty {
|
||||
ty::TyTuple(ref tys) => ArgKind::Tuple(
|
||||
ty::Tuple(ref tys) => ArgKind::Tuple(
|
||||
None,
|
||||
tys.iter()
|
||||
.map(|ty| ("_".to_owned(), ty.sty.to_string()))
|
||||
|
|
|
@ -540,7 +540,7 @@ fn trait_ref_type_vars<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 't
|
|||
.map(|t| selcx.infcx().resolve_type_vars_if_possible(&t))
|
||||
.filter(|t| t.has_infer_types())
|
||||
.flat_map(|t| t.walk())
|
||||
.filter(|t| match t.sty { ty::TyInfer(_) => true, _ => false })
|
||||
.filter(|t| match t.sty { ty::Infer(_) => true, _ => false })
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
false // no contained types to walk
|
||||
}
|
||||
|
||||
ty::TyProjection(ref data) => {
|
||||
ty::Projection(ref data) => {
|
||||
// This is a projected type `<Foo as SomeTrait>::X`.
|
||||
|
||||
// Compute supertraits of current trait lazily.
|
||||
|
|
|
@ -366,7 +366,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a,
|
|||
|
||||
let ty = ty.super_fold_with(self);
|
||||
match ty.sty {
|
||||
ty::TyAnon(def_id, substs) if !substs.has_escaping_regions() => { // (*)
|
||||
ty::Anon(def_id, substs) if !substs.has_escaping_regions() => { // (*)
|
||||
// Only normalize `impl Trait` after type-checking, usually in codegen.
|
||||
match self.param_env.reveal {
|
||||
Reveal::UserFacing => ty,
|
||||
|
@ -393,7 +393,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a,
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyProjection(ref data) if !data.has_escaping_regions() => { // (*)
|
||||
ty::Projection(ref data) if !data.has_escaping_regions() => { // (*)
|
||||
|
||||
// (*) This is kind of hacky -- we need to be able to
|
||||
// handle normalization within binders because
|
||||
|
@ -812,10 +812,10 @@ fn get_paranoid_cache_value_obligation<'a, 'gcx, 'tcx>(
|
|||
/// return an associated obligation that, when fulfilled, will lead to
|
||||
/// an error.
|
||||
///
|
||||
/// Note that we used to return `TyError` here, but that was quite
|
||||
/// Note that we used to return `Error` here, but that was quite
|
||||
/// dubious -- the premise was that an error would *eventually* be
|
||||
/// reported, when the obligation was processed. But in general once
|
||||
/// you see a `TyError` you are supposed to be able to assume that an
|
||||
/// you see a `Error` you are supposed to be able to assume that an
|
||||
/// error *has been* reported, so that you can take whatever heuristic
|
||||
/// paths you want to take. To make things worse, it was possible for
|
||||
/// cycles to arise, where you basically had a setup like `<MyType<$0>
|
||||
|
@ -983,11 +983,11 @@ fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>(
|
|||
let tcx = selcx.tcx();
|
||||
// Check whether the self-type is itself a projection.
|
||||
let (def_id, substs) = match obligation_trait_ref.self_ty().sty {
|
||||
ty::TyProjection(ref data) => {
|
||||
ty::Projection(ref data) => {
|
||||
(data.trait_ref(tcx).def_id, data.substs)
|
||||
}
|
||||
ty::TyAnon(def_id, substs) => (def_id, substs),
|
||||
ty::TyInfer(ty::TyVar(_)) => {
|
||||
ty::Anon(def_id, substs) => (def_id, substs),
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
// If the self-type is an inference variable, then it MAY wind up
|
||||
// being a projected type, so induce an ambiguity.
|
||||
candidate_set.mark_ambiguous();
|
||||
|
@ -1265,7 +1265,7 @@ fn confirm_object_candidate<'cx, 'gcx, 'tcx>(
|
|||
debug!("confirm_object_candidate(object_ty={:?})",
|
||||
object_ty);
|
||||
let data = match object_ty.sty {
|
||||
ty::TyDynamic(ref data, ..) => data,
|
||||
ty::Dynamic(ref data, ..) => data,
|
||||
_ => {
|
||||
span_bug!(
|
||||
obligation.cause.span,
|
||||
|
@ -1506,7 +1506,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
|
|||
// This means that the impl is missing a definition for the
|
||||
// associated type. This error will be reported by the type
|
||||
// checker method `check_impl_items_against_trait`, so here we
|
||||
// just return TyError.
|
||||
// just return Error.
|
||||
debug!("confirm_impl_candidate: no associated type {:?} for {:?}",
|
||||
assoc_ty.item.ident,
|
||||
obligation.predicate);
|
||||
|
|
|
@ -214,34 +214,34 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
|
|||
// None of these types have a destructor and hence they do not
|
||||
// require anything in particular to outlive the dtor's
|
||||
// execution.
|
||||
ty::TyInfer(ty::FreshIntTy(_))
|
||||
| ty::TyInfer(ty::FreshFloatTy(_))
|
||||
ty::Infer(ty::FreshIntTy(_))
|
||||
| ty::Infer(ty::FreshFloatTy(_))
|
||||
| ty::TyBool
|
||||
| ty::TyInt(_)
|
||||
| ty::TyUint(_)
|
||||
| ty::TyFloat(_)
|
||||
| ty::TyNever
|
||||
| ty::TyFnDef(..)
|
||||
| ty::TyFnPtr(_)
|
||||
| ty::Never
|
||||
| ty::FnDef(..)
|
||||
| ty::FnPtr(_)
|
||||
| ty::TyChar
|
||||
| ty::TyGeneratorWitness(..)
|
||||
| ty::TyRawPtr(_)
|
||||
| ty::TyRef(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::RawPtr(_)
|
||||
| ty::Ref(..)
|
||||
| ty::TyStr
|
||||
| ty::TyForeign(..)
|
||||
| ty::TyError => true,
|
||||
| ty::Error => true,
|
||||
|
||||
// [T; N] and [T] have same properties as T.
|
||||
ty::TyArray(ty, _) | ty::TySlice(ty) => trivial_dropck_outlives(tcx, ty),
|
||||
ty::Array(ty, _) | ty::Slice(ty) => trivial_dropck_outlives(tcx, ty),
|
||||
|
||||
// (T1..Tn) and closures have same properties as T1..Tn --
|
||||
// check if *any* of those are trivial.
|
||||
ty::TyTuple(ref tys) => tys.iter().cloned().all(|t| trivial_dropck_outlives(tcx, t)),
|
||||
ty::TyClosure(def_id, ref substs) => substs
|
||||
ty::Tuple(ref tys) => tys.iter().cloned().all(|t| trivial_dropck_outlives(tcx, t)),
|
||||
ty::Closure(def_id, ref substs) => substs
|
||||
.upvar_tys(def_id, tcx)
|
||||
.all(|t| trivial_dropck_outlives(tcx, t)),
|
||||
|
||||
ty::TyAdt(def, _) => {
|
||||
ty::Adt(def, _) => {
|
||||
if Some(def.did) == tcx.lang_items().manually_drop() {
|
||||
// `ManuallyDrop` never has a dtor.
|
||||
true
|
||||
|
@ -255,11 +255,11 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
|
|||
}
|
||||
|
||||
// The following *might* require a destructor: it would deeper inspection to tell.
|
||||
ty::TyDynamic(..)
|
||||
| ty::TyProjection(..)
|
||||
ty::Dynamic(..)
|
||||
| ty::Projection(..)
|
||||
| ty::TyParam(_)
|
||||
| ty::TyAnon(..)
|
||||
| ty::TyInfer(_)
|
||||
| ty::TyGenerator(..) => false,
|
||||
| ty::Anon(..)
|
||||
| ty::Infer(_)
|
||||
| ty::Generator(..) => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx
|
|||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let ty = ty.super_fold_with(self);
|
||||
match ty.sty {
|
||||
ty::TyAnon(def_id, substs) if !substs.has_escaping_regions() => {
|
||||
ty::Anon(def_id, substs) if !substs.has_escaping_regions() => {
|
||||
// (*)
|
||||
// Only normalize `impl Trait` after type-checking, usually in codegen.
|
||||
match self.param_env.reveal {
|
||||
|
@ -159,7 +159,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyProjection(ref data) if !data.has_escaping_regions() => {
|
||||
ty::Projection(ref data) if !data.has_escaping_regions() => {
|
||||
// (*)
|
||||
// (*) This is kind of hacky -- we need to be able to
|
||||
// handle normalization within binders because
|
||||
|
|
|
@ -1128,7 +1128,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
-> SelectionResult<'tcx, SelectionCandidate<'tcx>>
|
||||
{
|
||||
if stack.obligation.predicate.references_error() {
|
||||
// If we encounter a `TyError`, we generally prefer the
|
||||
// If we encounter a `Error`, we generally prefer the
|
||||
// most "optimistic" result in response -- that is, the
|
||||
// one least likely to report downstream errors. But
|
||||
// because this routine is shared by coherence and by
|
||||
|
@ -1492,8 +1492,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// before we go into the whole skolemization thing, just
|
||||
// quickly check if the self-type is a projection at all.
|
||||
match obligation.predicate.skip_binder().trait_ref.self_ty().sty {
|
||||
ty::TyProjection(_) | ty::TyAnon(..) => {}
|
||||
ty::TyInfer(ty::TyVar(_)) => {
|
||||
ty::Projection(_) | ty::Anon(..) => {}
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
span_bug!(obligation.cause.span,
|
||||
"Self=_ should have been handled by assemble_candidates");
|
||||
}
|
||||
|
@ -1526,9 +1526,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
skol_map);
|
||||
|
||||
let (def_id, substs) = match skol_trait_predicate.trait_ref.self_ty().sty {
|
||||
ty::TyProjection(ref data) =>
|
||||
ty::Projection(ref data) =>
|
||||
(data.trait_ref(self.tcx()).def_id, data.substs),
|
||||
ty::TyAnon(def_id, substs) => (def_id, substs),
|
||||
ty::Anon(def_id, substs) => (def_id, substs),
|
||||
_ => {
|
||||
span_bug!(
|
||||
obligation.cause.span,
|
||||
|
@ -1661,7 +1661,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// type/region parameters
|
||||
let self_ty = *obligation.self_ty().skip_binder();
|
||||
match self_ty.sty {
|
||||
ty::TyGenerator(..) => {
|
||||
ty::Generator(..) => {
|
||||
debug!("assemble_generator_candidates: self_ty={:?} obligation={:?}",
|
||||
self_ty,
|
||||
obligation);
|
||||
|
@ -1669,7 +1669,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
candidates.vec.push(GeneratorCandidate);
|
||||
Ok(())
|
||||
}
|
||||
ty::TyInfer(ty::TyVar(_)) => {
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
debug!("assemble_generator_candidates: ambiguous self-type");
|
||||
candidates.ambiguous = true;
|
||||
return Ok(());
|
||||
|
@ -1698,7 +1698,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// touch bound regions, they just capture the in-scope
|
||||
// type/region parameters
|
||||
match obligation.self_ty().skip_binder().sty {
|
||||
ty::TyClosure(closure_def_id, closure_substs) => {
|
||||
ty::Closure(closure_def_id, closure_substs) => {
|
||||
debug!("assemble_unboxed_candidates: kind={:?} obligation={:?}",
|
||||
kind, obligation);
|
||||
match self.infcx.closure_kind(closure_def_id, closure_substs) {
|
||||
|
@ -1715,7 +1715,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
};
|
||||
Ok(())
|
||||
}
|
||||
ty::TyInfer(ty::TyVar(_)) => {
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
debug!("assemble_unboxed_closure_candidates: ambiguous self-type");
|
||||
candidates.ambiguous = true;
|
||||
return Ok(());
|
||||
|
@ -1738,13 +1738,13 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// ok to skip binder because what we are inspecting doesn't involve bound regions
|
||||
let self_ty = *obligation.self_ty().skip_binder();
|
||||
match self_ty.sty {
|
||||
ty::TyInfer(ty::TyVar(_)) => {
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
debug!("assemble_fn_pointer_candidates: ambiguous self-type");
|
||||
candidates.ambiguous = true; // could wind up being a fn() type
|
||||
}
|
||||
|
||||
// provide an impl, but only for suitable `fn` pointers
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
if let ty::FnSig {
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
abi: Abi::Rust,
|
||||
|
@ -1804,7 +1804,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
|
||||
if self.tcx().trait_is_auto(def_id) {
|
||||
match self_ty.sty {
|
||||
ty::TyDynamic(..) => {
|
||||
ty::Dynamic(..) => {
|
||||
// For object types, we don't know what the closed
|
||||
// over types are. This means we conservatively
|
||||
// say nothing; a candidate may be added by
|
||||
|
@ -1817,7 +1817,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// this trait and type.
|
||||
}
|
||||
ty::TyParam(..) |
|
||||
ty::TyProjection(..) => {
|
||||
ty::Projection(..) => {
|
||||
// In these cases, we don't know what the actual
|
||||
// type is. Therefore, we cannot break it down
|
||||
// into its constituent types. So we don't
|
||||
|
@ -1832,7 +1832,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// for an example of a test case that exercises
|
||||
// this path.
|
||||
}
|
||||
ty::TyInfer(ty::TyVar(_)) => {
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
// the auto impl might apply, we don't know
|
||||
candidates.ambiguous = true;
|
||||
}
|
||||
|
@ -1871,7 +1871,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// any LBR.
|
||||
let self_ty = this.tcx().erase_late_bound_regions(&obligation.self_ty());
|
||||
let poly_trait_ref = match self_ty.sty {
|
||||
ty::TyDynamic(ref data, ..) => {
|
||||
ty::Dynamic(ref data, ..) => {
|
||||
if data.auto_traits().any(|did| did == obligation.predicate.def_id()) {
|
||||
debug!("assemble_candidates_from_object_ty: matched builtin bound, \
|
||||
pushing candidate");
|
||||
|
@ -1884,7 +1884,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
None => return,
|
||||
}
|
||||
}
|
||||
ty::TyInfer(ty::TyVar(_)) => {
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
debug!("assemble_candidates_from_object_ty: ambiguous");
|
||||
candidates.ambiguous = true; // could wind up being an object type
|
||||
return;
|
||||
|
@ -1953,7 +1953,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
|
||||
let may_apply = match (&source.sty, &target.sty) {
|
||||
// Trait+Kx+'a -> Trait+Ky+'b (upcasts).
|
||||
(&ty::TyDynamic(ref data_a, ..), &ty::TyDynamic(ref data_b, ..)) => {
|
||||
(&ty::Dynamic(ref data_a, ..), &ty::Dynamic(ref data_b, ..)) => {
|
||||
// Upcasts permit two things:
|
||||
//
|
||||
// 1. Dropping builtin bounds, e.g. `Foo+Send` to `Foo`
|
||||
|
@ -1975,28 +1975,28 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// T -> Trait.
|
||||
(_, &ty::TyDynamic(..)) => true,
|
||||
(_, &ty::Dynamic(..)) => true,
|
||||
|
||||
// Ambiguous handling is below T -> Trait, because inference
|
||||
// variables can still implement Unsize<Trait> and nested
|
||||
// obligations will have the final say (likely deferred).
|
||||
(&ty::TyInfer(ty::TyVar(_)), _) |
|
||||
(_, &ty::TyInfer(ty::TyVar(_))) => {
|
||||
(&ty::Infer(ty::TyVar(_)), _) |
|
||||
(_, &ty::Infer(ty::TyVar(_))) => {
|
||||
debug!("assemble_candidates_for_unsizing: ambiguous");
|
||||
candidates.ambiguous = true;
|
||||
false
|
||||
}
|
||||
|
||||
// [T; n] -> [T].
|
||||
(&ty::TyArray(..), &ty::TySlice(_)) => true,
|
||||
(&ty::Array(..), &ty::Slice(_)) => true,
|
||||
|
||||
// Struct<T> -> Struct<U>.
|
||||
(&ty::TyAdt(def_id_a, _), &ty::TyAdt(def_id_b, _)) if def_id_a.is_struct() => {
|
||||
(&ty::Adt(def_id_a, _), &ty::Adt(def_id_b, _)) if def_id_a.is_struct() => {
|
||||
def_id_a == def_id_b
|
||||
}
|
||||
|
||||
// (.., T) -> (.., U).
|
||||
(&ty::TyTuple(tys_a), &ty::TyTuple(tys_b)) => {
|
||||
(&ty::Tuple(tys_a), &ty::Tuple(tys_b)) => {
|
||||
tys_a.len() == tys_b.len()
|
||||
}
|
||||
|
||||
|
@ -2179,23 +2179,23 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
obligation.predicate.skip_binder().self_ty());
|
||||
|
||||
match self_ty.sty {
|
||||
ty::TyInfer(ty::IntVar(_)) | ty::TyInfer(ty::FloatVar(_)) |
|
||||
ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) |
|
||||
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyRawPtr(..) |
|
||||
ty::TyChar | ty::TyRef(..) | ty::TyGenerator(..) |
|
||||
ty::TyGeneratorWitness(..) | ty::TyArray(..) | ty::TyClosure(..) |
|
||||
ty::TyNever | ty::TyError => {
|
||||
ty::FnDef(..) | ty::FnPtr(_) | ty::RawPtr(..) |
|
||||
ty::TyChar | ty::Ref(..) | ty::Generator(..) |
|
||||
ty::GeneratorWitness(..) | ty::Array(..) | ty::Closure(..) |
|
||||
ty::Never | ty::Error => {
|
||||
// safe for everything
|
||||
Where(ty::Binder::dummy(Vec::new()))
|
||||
}
|
||||
|
||||
ty::TyStr | ty::TySlice(_) | ty::TyDynamic(..) | ty::TyForeign(..) => None,
|
||||
ty::TyStr | ty::Slice(_) | ty::Dynamic(..) | ty::TyForeign(..) => None,
|
||||
|
||||
ty::TyTuple(tys) => {
|
||||
ty::Tuple(tys) => {
|
||||
Where(ty::Binder::bind(tys.last().into_iter().cloned().collect()))
|
||||
}
|
||||
|
||||
ty::TyAdt(def, substs) => {
|
||||
ty::Adt(def, substs) => {
|
||||
let sized_crit = def.sized_constraint(self.tcx());
|
||||
// (*) binder moved here
|
||||
Where(ty::Binder::bind(
|
||||
|
@ -2203,13 +2203,13 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
))
|
||||
}
|
||||
|
||||
ty::TyProjection(_) | ty::TyParam(_) | ty::TyAnon(..) => None,
|
||||
ty::TyInfer(ty::TyVar(_)) => Ambiguous,
|
||||
ty::Projection(_) | ty::TyParam(_) | ty::Anon(..) => None,
|
||||
ty::Infer(ty::TyVar(_)) => Ambiguous,
|
||||
|
||||
ty::TyInfer(ty::CanonicalTy(_)) |
|
||||
ty::TyInfer(ty::FreshTy(_)) |
|
||||
ty::TyInfer(ty::FreshIntTy(_)) |
|
||||
ty::TyInfer(ty::FreshFloatTy(_)) => {
|
||||
ty::Infer(ty::CanonicalTy(_)) |
|
||||
ty::Infer(ty::FreshTy(_)) |
|
||||
ty::Infer(ty::FreshIntTy(_)) |
|
||||
ty::Infer(ty::FreshFloatTy(_)) => {
|
||||
bug!("asked to assemble builtin bounds of unexpected type: {:?}",
|
||||
self_ty);
|
||||
}
|
||||
|
@ -2226,35 +2226,35 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
use self::BuiltinImplConditions::{Ambiguous, None, Where};
|
||||
|
||||
match self_ty.sty {
|
||||
ty::TyInfer(ty::IntVar(_)) | ty::TyInfer(ty::FloatVar(_)) |
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyError => {
|
||||
ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) |
|
||||
ty::FnDef(..) | ty::FnPtr(_) | ty::Error => {
|
||||
Where(ty::Binder::dummy(Vec::new()))
|
||||
}
|
||||
|
||||
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
|
||||
ty::TyChar | ty::TyRawPtr(..) | ty::TyNever |
|
||||
ty::TyRef(_, _, hir::MutImmutable) => {
|
||||
ty::TyChar | ty::RawPtr(..) | ty::Never |
|
||||
ty::Ref(_, _, hir::MutImmutable) => {
|
||||
// Implementations provided in libcore
|
||||
None
|
||||
}
|
||||
|
||||
ty::TyDynamic(..) | ty::TyStr | ty::TySlice(..) |
|
||||
ty::TyGenerator(..) | ty::TyGeneratorWitness(..) | ty::TyForeign(..) |
|
||||
ty::TyRef(_, _, hir::MutMutable) => {
|
||||
ty::Dynamic(..) | ty::TyStr | ty::Slice(..) |
|
||||
ty::Generator(..) | ty::GeneratorWitness(..) | ty::TyForeign(..) |
|
||||
ty::Ref(_, _, hir::MutMutable) => {
|
||||
None
|
||||
}
|
||||
|
||||
ty::TyArray(element_ty, _) => {
|
||||
ty::Array(element_ty, _) => {
|
||||
// (*) binder moved here
|
||||
Where(ty::Binder::bind(vec![element_ty]))
|
||||
}
|
||||
|
||||
ty::TyTuple(tys) => {
|
||||
ty::Tuple(tys) => {
|
||||
// (*) binder moved here
|
||||
Where(ty::Binder::bind(tys.to_vec()))
|
||||
}
|
||||
|
||||
ty::TyClosure(def_id, substs) => {
|
||||
ty::Closure(def_id, substs) => {
|
||||
let trait_id = obligation.predicate.def_id();
|
||||
let is_copy_trait = Some(trait_id) == self.tcx().lang_items().copy_trait();
|
||||
let is_clone_trait = Some(trait_id) == self.tcx().lang_items().clone_trait();
|
||||
|
@ -2265,22 +2265,22 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyAdt(..) | ty::TyProjection(..) | ty::TyParam(..) | ty::TyAnon(..) => {
|
||||
ty::Adt(..) | ty::Projection(..) | ty::TyParam(..) | ty::Anon(..) => {
|
||||
// Fallback to whatever user-defined impls exist in this case.
|
||||
None
|
||||
}
|
||||
|
||||
ty::TyInfer(ty::TyVar(_)) => {
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
// Unbound type variable. Might or might not have
|
||||
// applicable impls and so forth, depending on what
|
||||
// those type variables wind up being bound to.
|
||||
Ambiguous
|
||||
}
|
||||
|
||||
ty::TyInfer(ty::CanonicalTy(_)) |
|
||||
ty::TyInfer(ty::FreshTy(_)) |
|
||||
ty::TyInfer(ty::FreshIntTy(_)) |
|
||||
ty::TyInfer(ty::FreshFloatTy(_)) => {
|
||||
ty::Infer(ty::CanonicalTy(_)) |
|
||||
ty::Infer(ty::FreshTy(_)) |
|
||||
ty::Infer(ty::FreshIntTy(_)) |
|
||||
ty::Infer(ty::FreshFloatTy(_)) => {
|
||||
bug!("asked to assemble builtin bounds of unexpected type: {:?}",
|
||||
self_ty);
|
||||
}
|
||||
|
@ -2304,54 +2304,54 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
ty::TyInt(_) |
|
||||
ty::TyBool |
|
||||
ty::TyFloat(_) |
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyFnPtr(_) |
|
||||
ty::FnDef(..) |
|
||||
ty::FnPtr(_) |
|
||||
ty::TyStr |
|
||||
ty::TyError |
|
||||
ty::TyInfer(ty::IntVar(_)) |
|
||||
ty::TyInfer(ty::FloatVar(_)) |
|
||||
ty::TyNever |
|
||||
ty::Error |
|
||||
ty::Infer(ty::IntVar(_)) |
|
||||
ty::Infer(ty::FloatVar(_)) |
|
||||
ty::Never |
|
||||
ty::TyChar => {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
ty::TyDynamic(..) |
|
||||
ty::Dynamic(..) |
|
||||
ty::TyParam(..) |
|
||||
ty::TyForeign(..) |
|
||||
ty::TyProjection(..) |
|
||||
ty::TyInfer(ty::CanonicalTy(_)) |
|
||||
ty::TyInfer(ty::TyVar(_)) |
|
||||
ty::TyInfer(ty::FreshTy(_)) |
|
||||
ty::TyInfer(ty::FreshIntTy(_)) |
|
||||
ty::TyInfer(ty::FreshFloatTy(_)) => {
|
||||
ty::Projection(..) |
|
||||
ty::Infer(ty::CanonicalTy(_)) |
|
||||
ty::Infer(ty::TyVar(_)) |
|
||||
ty::Infer(ty::FreshTy(_)) |
|
||||
ty::Infer(ty::FreshIntTy(_)) |
|
||||
ty::Infer(ty::FreshFloatTy(_)) => {
|
||||
bug!("asked to assemble constituent types of unexpected type: {:?}",
|
||||
t);
|
||||
}
|
||||
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty: element_ty, ..}) |
|
||||
ty::TyRef(_, element_ty, _) => {
|
||||
ty::RawPtr(ty::TypeAndMut { ty: element_ty, ..}) |
|
||||
ty::Ref(_, element_ty, _) => {
|
||||
vec![element_ty]
|
||||
},
|
||||
|
||||
ty::TyArray(element_ty, _) | ty::TySlice(element_ty) => {
|
||||
ty::Array(element_ty, _) | ty::Slice(element_ty) => {
|
||||
vec![element_ty]
|
||||
}
|
||||
|
||||
ty::TyTuple(ref tys) => {
|
||||
ty::Tuple(ref tys) => {
|
||||
// (T1, ..., Tn) -- meets any bound that all of T1...Tn meet
|
||||
tys.to_vec()
|
||||
}
|
||||
|
||||
ty::TyClosure(def_id, ref substs) => {
|
||||
ty::Closure(def_id, ref substs) => {
|
||||
substs.upvar_tys(def_id, self.tcx()).collect()
|
||||
}
|
||||
|
||||
ty::TyGenerator(def_id, ref substs, _) => {
|
||||
ty::Generator(def_id, ref substs, _) => {
|
||||
let witness = substs.witness(def_id, self.tcx());
|
||||
substs.upvar_tys(def_id, self.tcx()).chain(iter::once(witness)).collect()
|
||||
}
|
||||
|
||||
ty::TyGeneratorWitness(types) => {
|
||||
ty::GeneratorWitness(types) => {
|
||||
// This is sound because no regions in the witness can refer to
|
||||
// the binder outside the witness. So we'll effectivly reuse
|
||||
// the implicit binder around the witness.
|
||||
|
@ -2359,17 +2359,17 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// for `PhantomData<T>`, we pass `T`
|
||||
ty::TyAdt(def, substs) if def.is_phantom_data() => {
|
||||
ty::Adt(def, substs) if def.is_phantom_data() => {
|
||||
substs.types().collect()
|
||||
}
|
||||
|
||||
ty::TyAdt(def, substs) => {
|
||||
ty::Adt(def, substs) => {
|
||||
def.all_fields()
|
||||
.map(|f| f.ty(self.tcx(), substs))
|
||||
.collect()
|
||||
}
|
||||
|
||||
ty::TyAnon(def_id, substs) => {
|
||||
ty::Anon(def_id, substs) => {
|
||||
// We can resolve the `impl Trait` to its concrete type,
|
||||
// which enforces a DAG between the functions requiring
|
||||
// the auto trait bounds in question.
|
||||
|
@ -2728,7 +2728,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// case that results. -nmatsakis
|
||||
let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder());
|
||||
let poly_trait_ref = match self_ty.sty {
|
||||
ty::TyDynamic(ref data, ..) => {
|
||||
ty::Dynamic(ref data, ..) => {
|
||||
data.principal().unwrap().with_self_ty(self.tcx(), self_ty)
|
||||
}
|
||||
_ => {
|
||||
|
@ -2823,7 +2823,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// type/region parameters
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
|
||||
let (generator_def_id, substs) = match self_ty.sty {
|
||||
ty::TyGenerator(id, substs, _) => (id, substs),
|
||||
ty::Generator(id, substs, _) => (id, substs),
|
||||
_ => bug!("closure candidate for non-closure {:?}", obligation)
|
||||
};
|
||||
|
||||
|
@ -2879,7 +2879,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// type/region parameters
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
|
||||
let (closure_def_id, substs) = match self_ty.sty {
|
||||
ty::TyClosure(id, substs) => (id, substs),
|
||||
ty::Closure(id, substs) => (id, substs),
|
||||
_ => bug!("closure candidate for non-closure {:?}", obligation)
|
||||
};
|
||||
|
||||
|
@ -2976,7 +2976,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
let mut nested = vec![];
|
||||
match (&source.sty, &target.sty) {
|
||||
// Trait+Kx+'a -> Trait+Ky+'b (upcasts).
|
||||
(&ty::TyDynamic(ref data_a, r_a), &ty::TyDynamic(ref data_b, r_b)) => {
|
||||
(&ty::Dynamic(ref data_a, r_a), &ty::Dynamic(ref data_b, r_b)) => {
|
||||
// See assemble_candidates_for_unsizing for more info.
|
||||
let existential_predicates = data_a.map_bound(|data_a| {
|
||||
let principal = data_a.principal();
|
||||
|
@ -3005,7 +3005,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// T -> Trait.
|
||||
(_, &ty::TyDynamic(ref data, r)) => {
|
||||
(_, &ty::Dynamic(ref data, r)) => {
|
||||
let mut object_dids =
|
||||
data.auto_traits().chain(data.principal().map(|p| p.def_id()));
|
||||
if let Some(did) = object_dids.find(|did| {
|
||||
|
@ -3048,7 +3048,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// [T; n] -> [T].
|
||||
(&ty::TyArray(a, _), &ty::TySlice(b)) => {
|
||||
(&ty::Array(a, _), &ty::Slice(b)) => {
|
||||
let InferOk { obligations, .. } =
|
||||
self.infcx.at(&obligation.cause, obligation.param_env)
|
||||
.eq(b, a)
|
||||
|
@ -3057,7 +3057,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// Struct<T> -> Struct<U>.
|
||||
(&ty::TyAdt(def, substs_a), &ty::TyAdt(_, substs_b)) => {
|
||||
(&ty::Adt(def, substs_a), &ty::Adt(_, substs_b)) => {
|
||||
let fields = def
|
||||
.all_fields()
|
||||
.map(|f| tcx.type_of(f.did))
|
||||
|
@ -3082,7 +3082,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// Replace type parameters used in unsizing with
|
||||
// TyError and ensure they do not affect any other fields.
|
||||
// Error and ensure they do not affect any other fields.
|
||||
// This could be checked after type collection for any struct
|
||||
// with a potentially unsized trailing field.
|
||||
let params = substs_a.iter().enumerate().map(|(i, &k)| {
|
||||
|
@ -3130,7 +3130,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// (.., T) -> (.., U).
|
||||
(&ty::TyTuple(tys_a), &ty::TyTuple(tys_b)) => {
|
||||
(&ty::Tuple(tys_a), &ty::Tuple(tys_b)) => {
|
||||
assert_eq!(tys_a.len(), tys_b.len());
|
||||
|
||||
// The last field of the tuple has to exist.
|
||||
|
|
|
@ -67,18 +67,18 @@ impl<'a, 'gcx, 'tcx> TypeRelation<'a, 'gcx, 'tcx> for Match<'a, 'gcx, 'tcx> {
|
|||
if a == b { return Ok(a); }
|
||||
|
||||
match (&a.sty, &b.sty) {
|
||||
(_, &ty::TyInfer(ty::FreshTy(_))) |
|
||||
(_, &ty::TyInfer(ty::FreshIntTy(_))) |
|
||||
(_, &ty::TyInfer(ty::FreshFloatTy(_))) => {
|
||||
(_, &ty::Infer(ty::FreshTy(_))) |
|
||||
(_, &ty::Infer(ty::FreshIntTy(_))) |
|
||||
(_, &ty::Infer(ty::FreshFloatTy(_))) => {
|
||||
Ok(a)
|
||||
}
|
||||
|
||||
(&ty::TyInfer(_), _) |
|
||||
(_, &ty::TyInfer(_)) => {
|
||||
(&ty::Infer(_), _) |
|
||||
(_, &ty::Infer(_)) => {
|
||||
Err(TypeError::Sorts(relate::expected_found(self, &a, &b)))
|
||||
}
|
||||
|
||||
(&ty::TyError, _) | (_, &ty::TyError) => {
|
||||
(&ty::Error, _) | (_, &ty::Error) => {
|
||||
Ok(self.tcx().types.err)
|
||||
}
|
||||
|
||||
|
|
|
@ -63,15 +63,15 @@ impl<'tcx> CastTy<'tcx> {
|
|||
ty::TyBool => Some(CastTy::Int(IntTy::Bool)),
|
||||
ty::TyChar => Some(CastTy::Int(IntTy::Char)),
|
||||
ty::TyInt(_) => Some(CastTy::Int(IntTy::I)),
|
||||
ty::TyInfer(ty::InferTy::IntVar(_)) => Some(CastTy::Int(IntTy::I)),
|
||||
ty::TyInfer(ty::InferTy::FloatVar(_)) => Some(CastTy::Float),
|
||||
ty::Infer(ty::InferTy::IntVar(_)) => Some(CastTy::Int(IntTy::I)),
|
||||
ty::Infer(ty::InferTy::FloatVar(_)) => Some(CastTy::Float),
|
||||
ty::TyUint(u) => Some(CastTy::Int(IntTy::U(u))),
|
||||
ty::TyFloat(_) => Some(CastTy::Float),
|
||||
ty::TyAdt(d,_) if d.is_enum() && d.is_payloadfree() =>
|
||||
ty::Adt(d,_) if d.is_enum() && d.is_payloadfree() =>
|
||||
Some(CastTy::Int(IntTy::CEnum)),
|
||||
ty::TyRawPtr(mt) => Some(CastTy::Ptr(mt)),
|
||||
ty::TyRef(_, ty, mutbl) => Some(CastTy::RPtr(ty::TypeAndMut { ty, mutbl })),
|
||||
ty::TyFnPtr(..) => Some(CastTy::FnPtr),
|
||||
ty::RawPtr(mt) => Some(CastTy::Ptr(mt)),
|
||||
ty::Ref(_, ty, mutbl) => Some(CastTy::RPtr(ty::TypeAndMut { ty, mutbl })),
|
||||
ty::FnPtr(..) => Some(CastTy::FnPtr),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -819,8 +819,8 @@ impl<'tcx> CommonTypes<'tcx> {
|
|||
CommonTypes {
|
||||
bool: mk(TyBool),
|
||||
char: mk(TyChar),
|
||||
never: mk(TyNever),
|
||||
err: mk(TyError),
|
||||
never: mk(Never),
|
||||
err: mk(Error),
|
||||
isize: mk(TyInt(ast::IntTy::Isize)),
|
||||
i8: mk(TyInt(ast::IntTy::I8)),
|
||||
i16: mk(TyInt(ast::IntTy::I16)),
|
||||
|
@ -2036,8 +2036,8 @@ macro_rules! sty_debug_print {
|
|||
for &Interned(t) in tcx.interners.type_.borrow().iter() {
|
||||
let variant = match t.sty {
|
||||
ty::TyBool | ty::TyChar | ty::TyInt(..) | ty::TyUint(..) |
|
||||
ty::TyFloat(..) | ty::TyStr | ty::TyNever => continue,
|
||||
ty::TyError => /* unimportant */ continue,
|
||||
ty::TyFloat(..) | ty::TyStr | ty::Never => continue,
|
||||
ty::Error => /* unimportant */ continue,
|
||||
$(ty::$variant(..) => &mut $variant,)*
|
||||
};
|
||||
let region = t.flags.intersects(ty::TypeFlags::HAS_RE_INFER);
|
||||
|
@ -2076,9 +2076,9 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
|||
pub fn print_debug_stats(self) {
|
||||
sty_debug_print!(
|
||||
self,
|
||||
TyAdt, TyArray, TySlice, TyRawPtr, TyRef, TyFnDef, TyFnPtr,
|
||||
TyGenerator, TyGeneratorWitness, TyDynamic, TyClosure, TyTuple,
|
||||
TyParam, TyInfer, TyProjection, TyAnon, TyForeign);
|
||||
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr,
|
||||
Generator, GeneratorWitness, Dynamic, Closure, Tuple,
|
||||
TyParam, Infer, Projection, Anon, TyForeign);
|
||||
|
||||
println!("Substs interner: #{}", self.interners.substs.borrow().len());
|
||||
println!("Region interner: #{}", self.interners.region.borrow().len());
|
||||
|
@ -2323,7 +2323,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
pub fn coerce_closure_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx> {
|
||||
let converted_sig = sig.map_bound(|s| {
|
||||
let params_iter = match s.inputs()[0].sty {
|
||||
ty::TyTuple(params) => {
|
||||
ty::Tuple(params) => {
|
||||
params.into_iter().cloned()
|
||||
}
|
||||
_ => bug!(),
|
||||
|
@ -2383,7 +2383,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, '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
|
||||
self.mk_ty(TyAdt(def, substs))
|
||||
self.mk_ty(Adt(def, substs))
|
||||
}
|
||||
|
||||
pub fn mk_foreign(self, def_id: DefId) -> Ty<'tcx> {
|
||||
|
@ -2406,15 +2406,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
});
|
||||
self.mk_ty(TyAdt(adt_def, substs))
|
||||
self.mk_ty(Adt(adt_def, substs))
|
||||
}
|
||||
|
||||
pub fn mk_ptr(self, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyRawPtr(tm))
|
||||
self.mk_ty(RawPtr(tm))
|
||||
}
|
||||
|
||||
pub fn mk_ref(self, r: Region<'tcx>, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyRef(r, tm.ty, tm.mutbl))
|
||||
self.mk_ty(Ref(r, tm.ty, tm.mutbl))
|
||||
}
|
||||
|
||||
pub fn mk_mut_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
|
@ -2438,19 +2438,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> {
|
||||
self.mk_ty(TyArray(ty, ty::Const::from_usize(self, n)))
|
||||
self.mk_ty(Array(ty, ty::Const::from_usize(self, n)))
|
||||
}
|
||||
|
||||
pub fn mk_slice(self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TySlice(ty))
|
||||
self.mk_ty(Slice(ty))
|
||||
}
|
||||
|
||||
pub fn intern_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> {
|
||||
self.mk_ty(TyTuple(self.intern_type_list(ts)))
|
||||
self.mk_ty(Tuple(self.intern_type_list(ts)))
|
||||
}
|
||||
|
||||
pub fn mk_tup<I: InternAs<[Ty<'tcx>], Ty<'tcx>>>(self, iter: I) -> I::Output {
|
||||
iter.intern_with(|ts| self.mk_ty(TyTuple(self.intern_type_list(ts))))
|
||||
iter.intern_with(|ts| self.mk_ty(Tuple(self.intern_type_list(ts))))
|
||||
}
|
||||
|
||||
pub fn mk_nil(self) -> Ty<'tcx> {
|
||||
|
@ -2471,11 +2471,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
pub fn mk_fn_def(self, def_id: DefId,
|
||||
substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyFnDef(def_id, substs))
|
||||
self.mk_ty(FnDef(def_id, substs))
|
||||
}
|
||||
|
||||
pub fn mk_fn_ptr(self, fty: PolyFnSig<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyFnPtr(fty))
|
||||
self.mk_ty(FnPtr(fty))
|
||||
}
|
||||
|
||||
pub fn mk_dynamic(
|
||||
|
@ -2483,14 +2483,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
obj: ty::Binder<&'tcx List<ExistentialPredicate<'tcx>>>,
|
||||
reg: ty::Region<'tcx>
|
||||
) -> Ty<'tcx> {
|
||||
self.mk_ty(TyDynamic(obj, reg))
|
||||
self.mk_ty(Dynamic(obj, reg))
|
||||
}
|
||||
|
||||
pub fn mk_projection(self,
|
||||
item_def_id: DefId,
|
||||
substs: &'tcx Substs<'tcx>)
|
||||
-> Ty<'tcx> {
|
||||
self.mk_ty(TyProjection(ProjectionTy {
|
||||
self.mk_ty(Projection(ProjectionTy {
|
||||
item_def_id,
|
||||
substs,
|
||||
}))
|
||||
|
@ -2498,7 +2498,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
pub fn mk_closure(self, closure_id: DefId, closure_substs: ClosureSubsts<'tcx>)
|
||||
-> Ty<'tcx> {
|
||||
self.mk_ty(TyClosure(closure_id, closure_substs))
|
||||
self.mk_ty(Closure(closure_id, closure_substs))
|
||||
}
|
||||
|
||||
pub fn mk_generator(self,
|
||||
|
@ -2506,11 +2506,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
generator_substs: GeneratorSubsts<'tcx>,
|
||||
movability: hir::GeneratorMovability)
|
||||
-> Ty<'tcx> {
|
||||
self.mk_ty(TyGenerator(id, generator_substs, movability))
|
||||
self.mk_ty(Generator(id, generator_substs, movability))
|
||||
}
|
||||
|
||||
pub fn mk_generator_witness(self, types: ty::Binder<&'tcx List<Ty<'tcx>>>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyGeneratorWitness(types))
|
||||
self.mk_ty(GeneratorWitness(types))
|
||||
}
|
||||
|
||||
pub fn mk_var(self, v: TyVid) -> Ty<'tcx> {
|
||||
|
@ -2526,7 +2526,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn mk_infer(self, it: InferTy) -> Ty<'tcx> {
|
||||
self.mk_ty(TyInfer(it))
|
||||
self.mk_ty(Infer(it))
|
||||
}
|
||||
|
||||
pub fn mk_ty_param(self,
|
||||
|
@ -2549,7 +2549,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn mk_anon(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
self.mk_ty(TyAnon(def_id, substs))
|
||||
self.mk_ty(Anon(def_id, substs))
|
||||
}
|
||||
|
||||
pub fn intern_existential_predicates(self, eps: &[ExistentialPredicate<'tcx>])
|
||||
|
|
|
@ -176,20 +176,20 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
|
|||
pub fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> String {
|
||||
match self.sty {
|
||||
ty::TyBool | ty::TyChar | ty::TyInt(_) |
|
||||
ty::TyUint(_) | ty::TyFloat(_) | ty::TyStr | ty::TyNever => self.to_string(),
|
||||
ty::TyTuple(ref tys) if tys.is_empty() => self.to_string(),
|
||||
ty::TyUint(_) | ty::TyFloat(_) | ty::TyStr | ty::Never => self.to_string(),
|
||||
ty::Tuple(ref tys) if tys.is_empty() => self.to_string(),
|
||||
|
||||
ty::TyAdt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)),
|
||||
ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)),
|
||||
ty::TyForeign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)),
|
||||
ty::TyArray(_, n) => {
|
||||
ty::Array(_, n) => {
|
||||
match n.assert_usize(tcx) {
|
||||
Some(n) => format!("array of {} elements", n),
|
||||
None => "array".to_string(),
|
||||
}
|
||||
}
|
||||
ty::TySlice(_) => "slice".to_string(),
|
||||
ty::TyRawPtr(_) => "*-ptr".to_string(),
|
||||
ty::TyRef(region, ty, mutbl) => {
|
||||
ty::Slice(_) => "slice".to_string(),
|
||||
ty::RawPtr(_) => "*-ptr".to_string(),
|
||||
ty::Ref(region, ty, mutbl) => {
|
||||
let tymut = ty::TypeAndMut { ty, mutbl };
|
||||
let tymut_string = tymut.to_string();
|
||||
if tymut_string == "_" || //unknown type name,
|
||||
|
@ -204,24 +204,24 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
|
|||
format!("&{}", tymut_string)
|
||||
}
|
||||
}
|
||||
ty::TyFnDef(..) => "fn item".to_string(),
|
||||
ty::TyFnPtr(_) => "fn pointer".to_string(),
|
||||
ty::TyDynamic(ref inner, ..) => {
|
||||
ty::FnDef(..) => "fn item".to_string(),
|
||||
ty::FnPtr(_) => "fn pointer".to_string(),
|
||||
ty::Dynamic(ref inner, ..) => {
|
||||
inner.principal().map_or_else(|| "trait".to_string(),
|
||||
|p| format!("trait {}", tcx.item_path_str(p.def_id())))
|
||||
}
|
||||
ty::TyClosure(..) => "closure".to_string(),
|
||||
ty::TyGenerator(..) => "generator".to_string(),
|
||||
ty::TyGeneratorWitness(..) => "generator witness".to_string(),
|
||||
ty::TyTuple(..) => "tuple".to_string(),
|
||||
ty::TyInfer(ty::TyVar(_)) => "inferred type".to_string(),
|
||||
ty::TyInfer(ty::IntVar(_)) => "integral variable".to_string(),
|
||||
ty::TyInfer(ty::FloatVar(_)) => "floating-point variable".to_string(),
|
||||
ty::TyInfer(ty::CanonicalTy(_)) |
|
||||
ty::TyInfer(ty::FreshTy(_)) => "skolemized type".to_string(),
|
||||
ty::TyInfer(ty::FreshIntTy(_)) => "skolemized integral type".to_string(),
|
||||
ty::TyInfer(ty::FreshFloatTy(_)) => "skolemized floating-point type".to_string(),
|
||||
ty::TyProjection(_) => "associated type".to_string(),
|
||||
ty::Closure(..) => "closure".to_string(),
|
||||
ty::Generator(..) => "generator".to_string(),
|
||||
ty::GeneratorWitness(..) => "generator witness".to_string(),
|
||||
ty::Tuple(..) => "tuple".to_string(),
|
||||
ty::Infer(ty::TyVar(_)) => "inferred type".to_string(),
|
||||
ty::Infer(ty::IntVar(_)) => "integral variable".to_string(),
|
||||
ty::Infer(ty::FloatVar(_)) => "floating-point variable".to_string(),
|
||||
ty::Infer(ty::CanonicalTy(_)) |
|
||||
ty::Infer(ty::FreshTy(_)) => "skolemized type".to_string(),
|
||||
ty::Infer(ty::FreshIntTy(_)) => "skolemized integral type".to_string(),
|
||||
ty::Infer(ty::FreshFloatTy(_)) => "skolemized floating-point type".to_string(),
|
||||
ty::Projection(_) => "associated type".to_string(),
|
||||
ty::TyParam(ref p) => {
|
||||
if p.is_self() {
|
||||
"Self".to_string()
|
||||
|
@ -229,8 +229,8 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
|
|||
"type parameter".to_string()
|
||||
}
|
||||
}
|
||||
ty::TyAnon(..) => "anonymized type".to_string(),
|
||||
ty::TyError => "type error".to_string(),
|
||||
ty::Anon(..) => "anonymized type".to_string(),
|
||||
ty::Error => "type error".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
db.help("consider boxing your closure and/or using it as a trait object");
|
||||
}
|
||||
match (&values.found.sty, &values.expected.sty) { // Issue #53280
|
||||
(ty::TyInfer(ty::IntVar(_)), ty::TyFloat(_)) => {
|
||||
(ty::Infer(ty::IntVar(_)), ty::TyFloat(_)) => {
|
||||
if let Ok(snippet) = self.sess.source_map().span_to_snippet(sp) {
|
||||
if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') {
|
||||
db.span_suggestion_with_applicability(
|
||||
|
|
|
@ -73,37 +73,37 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
|||
ty::TyInt(int_type) => Some(IntSimplifiedType(int_type)),
|
||||
ty::TyUint(uint_type) => Some(UintSimplifiedType(uint_type)),
|
||||
ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)),
|
||||
ty::TyAdt(def, _) => Some(AdtSimplifiedType(def.did)),
|
||||
ty::Adt(def, _) => Some(AdtSimplifiedType(def.did)),
|
||||
ty::TyStr => Some(StrSimplifiedType),
|
||||
ty::TyArray(..) | ty::TySlice(_) => Some(ArraySimplifiedType),
|
||||
ty::TyRawPtr(_) => Some(PtrSimplifiedType),
|
||||
ty::TyDynamic(ref trait_info, ..) => {
|
||||
ty::Array(..) | ty::Slice(_) => Some(ArraySimplifiedType),
|
||||
ty::RawPtr(_) => Some(PtrSimplifiedType),
|
||||
ty::Dynamic(ref trait_info, ..) => {
|
||||
trait_info.principal().map(|p| TraitSimplifiedType(p.def_id()))
|
||||
}
|
||||
ty::TyRef(_, ty, _) => {
|
||||
ty::Ref(_, ty, _) => {
|
||||
// since we introduce auto-refs during method lookup, we
|
||||
// just treat &T and T as equivalent from the point of
|
||||
// view of possibly unifying
|
||||
simplify_type(tcx, ty, can_simplify_params)
|
||||
}
|
||||
ty::TyFnDef(def_id, _) |
|
||||
ty::TyClosure(def_id, _) => {
|
||||
ty::FnDef(def_id, _) |
|
||||
ty::Closure(def_id, _) => {
|
||||
Some(ClosureSimplifiedType(def_id))
|
||||
}
|
||||
ty::TyGenerator(def_id, _, _) => {
|
||||
ty::Generator(def_id, _, _) => {
|
||||
Some(GeneratorSimplifiedType(def_id))
|
||||
}
|
||||
ty::TyGeneratorWitness(ref tys) => {
|
||||
ty::GeneratorWitness(ref tys) => {
|
||||
Some(GeneratorWitnessSimplifiedType(tys.skip_binder().len()))
|
||||
}
|
||||
ty::TyNever => Some(NeverSimplifiedType),
|
||||
ty::TyTuple(ref tys) => {
|
||||
ty::Never => Some(NeverSimplifiedType),
|
||||
ty::Tuple(ref tys) => {
|
||||
Some(TupleSimplifiedType(tys.len()))
|
||||
}
|
||||
ty::TyFnPtr(ref f) => {
|
||||
ty::FnPtr(ref f) => {
|
||||
Some(FunctionSimplifiedType(f.skip_binder().inputs().len()))
|
||||
}
|
||||
ty::TyProjection(_) | ty::TyParam(_) => {
|
||||
ty::Projection(_) | ty::TyParam(_) => {
|
||||
if can_simplify_params {
|
||||
// In normalized types, projections don't unify with
|
||||
// anything. when lazy normalization happens, this
|
||||
|
@ -115,13 +115,13 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
|||
None
|
||||
}
|
||||
}
|
||||
ty::TyAnon(def_id, _) => {
|
||||
ty::Anon(def_id, _) => {
|
||||
Some(AnonSimplifiedType(def_id))
|
||||
}
|
||||
ty::TyForeign(def_id) => {
|
||||
Some(ForeignSimplifiedType(def_id))
|
||||
}
|
||||
ty::TyInfer(_) | ty::TyError => None,
|
||||
ty::Infer(_) | ty::Error => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,19 +74,19 @@ impl FlagComputation {
|
|||
&ty::TyInt(_) |
|
||||
&ty::TyFloat(_) |
|
||||
&ty::TyUint(_) |
|
||||
&ty::TyNever |
|
||||
&ty::Never |
|
||||
&ty::TyStr |
|
||||
&ty::TyForeign(..) => {
|
||||
}
|
||||
|
||||
// You might think that we could just return TyError for
|
||||
// any type containing TyError as a component, and get
|
||||
// You might think that we could just return Error for
|
||||
// any type containing Error as a component, and get
|
||||
// rid of the TypeFlags::HAS_TY_ERR flag -- likewise for ty_bot (with
|
||||
// the exception of function types that return bot).
|
||||
// But doing so caused sporadic memory corruption, and
|
||||
// neither I (tjc) nor nmatsakis could figure out why,
|
||||
// so we're doing it this way.
|
||||
&ty::TyError => {
|
||||
&ty::Error => {
|
||||
self.add_flags(TypeFlags::HAS_TY_ERR)
|
||||
}
|
||||
|
||||
|
@ -99,25 +99,25 @@ impl FlagComputation {
|
|||
}
|
||||
}
|
||||
|
||||
&ty::TyGenerator(_, ref substs, _) => {
|
||||
&ty::Generator(_, ref substs, _) => {
|
||||
self.add_flags(TypeFlags::HAS_TY_CLOSURE);
|
||||
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES);
|
||||
self.add_substs(&substs.substs);
|
||||
}
|
||||
|
||||
&ty::TyGeneratorWitness(ref ts) => {
|
||||
&ty::GeneratorWitness(ref ts) => {
|
||||
let mut computation = FlagComputation::new();
|
||||
computation.add_tys(&ts.skip_binder()[..]);
|
||||
self.add_bound_computation(&computation);
|
||||
}
|
||||
|
||||
&ty::TyClosure(_, ref substs) => {
|
||||
&ty::Closure(_, ref substs) => {
|
||||
self.add_flags(TypeFlags::HAS_TY_CLOSURE);
|
||||
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES);
|
||||
self.add_substs(&substs.substs);
|
||||
}
|
||||
|
||||
&ty::TyInfer(infer) => {
|
||||
&ty::Infer(infer) => {
|
||||
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES); // it might, right?
|
||||
self.add_flags(TypeFlags::HAS_TY_INFER);
|
||||
match infer {
|
||||
|
@ -136,11 +136,11 @@ impl FlagComputation {
|
|||
}
|
||||
}
|
||||
|
||||
&ty::TyAdt(_, substs) => {
|
||||
&ty::Adt(_, substs) => {
|
||||
self.add_substs(substs);
|
||||
}
|
||||
|
||||
&ty::TyProjection(ref data) => {
|
||||
&ty::Projection(ref data) => {
|
||||
// currently we can't normalize projections that
|
||||
// include bound regions, so track those separately.
|
||||
if !data.has_escaping_regions() {
|
||||
|
@ -150,12 +150,12 @@ impl FlagComputation {
|
|||
self.add_projection_ty(data);
|
||||
}
|
||||
|
||||
&ty::TyAnon(_, substs) => {
|
||||
&ty::Anon(_, substs) => {
|
||||
self.add_flags(TypeFlags::HAS_PROJECTION);
|
||||
self.add_substs(substs);
|
||||
}
|
||||
|
||||
&ty::TyDynamic(ref obj, r) => {
|
||||
&ty::Dynamic(ref obj, r) => {
|
||||
let mut computation = FlagComputation::new();
|
||||
for predicate in obj.skip_binder().iter() {
|
||||
match *predicate {
|
||||
|
@ -172,33 +172,33 @@ impl FlagComputation {
|
|||
self.add_region(r);
|
||||
}
|
||||
|
||||
&ty::TyArray(tt, len) => {
|
||||
&ty::Array(tt, len) => {
|
||||
self.add_ty(tt);
|
||||
self.add_const(len);
|
||||
}
|
||||
|
||||
&ty::TySlice(tt) => {
|
||||
&ty::Slice(tt) => {
|
||||
self.add_ty(tt)
|
||||
}
|
||||
|
||||
&ty::TyRawPtr(ref m) => {
|
||||
&ty::RawPtr(ref m) => {
|
||||
self.add_ty(m.ty);
|
||||
}
|
||||
|
||||
&ty::TyRef(r, ty, _) => {
|
||||
&ty::Ref(r, ty, _) => {
|
||||
self.add_region(r);
|
||||
self.add_ty(ty);
|
||||
}
|
||||
|
||||
&ty::TyTuple(ref ts) => {
|
||||
&ty::Tuple(ref ts) => {
|
||||
self.add_tys(&ts[..]);
|
||||
}
|
||||
|
||||
&ty::TyFnDef(_, substs) => {
|
||||
&ty::FnDef(_, substs) => {
|
||||
self.add_substs(substs);
|
||||
}
|
||||
|
||||
&ty::TyFnPtr(f) => {
|
||||
&ty::FnPtr(f) => {
|
||||
self.add_fn_sig(f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -771,7 +771,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
|
|||
// in the normalized form
|
||||
if self.just_constrained {
|
||||
match t.sty {
|
||||
ty::TyProjection(..) | ty::TyAnon(..) => { return false; }
|
||||
ty::Projection(..) | ty::Anon(..) => { return false; }
|
||||
_ => { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
tcx: TyCtxt<'a, 'gcx, 'tcx>) -> DefIdForest
|
||||
{
|
||||
match self.sty {
|
||||
TyAdt(def, substs) => {
|
||||
Adt(def, substs) => {
|
||||
{
|
||||
let substs_set = visited.entry(def.did).or_default();
|
||||
if !substs_set.insert(substs) {
|
||||
|
@ -255,13 +255,13 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
ret
|
||||
},
|
||||
|
||||
TyNever => DefIdForest::full(tcx),
|
||||
TyTuple(ref tys) => {
|
||||
Never => DefIdForest::full(tcx),
|
||||
Tuple(ref tys) => {
|
||||
DefIdForest::union(tcx, tys.iter().map(|ty| {
|
||||
ty.uninhabited_from(visited, tcx)
|
||||
}))
|
||||
},
|
||||
TyArray(ty, len) => {
|
||||
Array(ty, len) => {
|
||||
match len.assert_usize(tcx) {
|
||||
// If the array is definitely non-empty, it's uninhabited if
|
||||
// the type of its elements is uninhabited.
|
||||
|
@ -269,7 +269,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
_ => DefIdForest::empty()
|
||||
}
|
||||
}
|
||||
TyRef(_, ty, _) => {
|
||||
Ref(_, ty, _) => {
|
||||
ty.uninhabited_from(visited, tcx)
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
|
|||
);
|
||||
|
||||
let def = match item_type.sty {
|
||||
ty::TyFnDef(..) if {
|
||||
ty::FnDef(..) if {
|
||||
let f = item_type.fn_sig(tcx);
|
||||
f.abi() == Abi::RustIntrinsic ||
|
||||
f.abi() == Abi::PlatformIntrinsic
|
||||
|
|
|
@ -299,7 +299,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
// impl on `Foo`, but fallback to `<Foo>::bar` if self-type is
|
||||
// anything other than a simple path.
|
||||
match self_ty.sty {
|
||||
ty::TyAdt(adt_def, substs) => {
|
||||
ty::Adt(adt_def, substs) => {
|
||||
if substs.types().next().is_none() { // ignore regions
|
||||
self.push_item_path(buffer, adt_def.did);
|
||||
} else {
|
||||
|
@ -357,24 +357,24 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
/// decisions and we may want to adjust it later.
|
||||
pub fn characteristic_def_id_of_type(ty: Ty) -> Option<DefId> {
|
||||
match ty.sty {
|
||||
ty::TyAdt(adt_def, _) => Some(adt_def.did),
|
||||
ty::Adt(adt_def, _) => Some(adt_def.did),
|
||||
|
||||
ty::TyDynamic(data, ..) => data.principal().map(|p| p.def_id()),
|
||||
ty::Dynamic(data, ..) => data.principal().map(|p| p.def_id()),
|
||||
|
||||
ty::TyArray(subty, _) |
|
||||
ty::TySlice(subty) => characteristic_def_id_of_type(subty),
|
||||
ty::Array(subty, _) |
|
||||
ty::Slice(subty) => characteristic_def_id_of_type(subty),
|
||||
|
||||
ty::TyRawPtr(mt) => characteristic_def_id_of_type(mt.ty),
|
||||
ty::RawPtr(mt) => characteristic_def_id_of_type(mt.ty),
|
||||
|
||||
ty::TyRef(_, ty, _) => characteristic_def_id_of_type(ty),
|
||||
ty::Ref(_, ty, _) => characteristic_def_id_of_type(ty),
|
||||
|
||||
ty::TyTuple(ref tys) => tys.iter()
|
||||
ty::Tuple(ref tys) => tys.iter()
|
||||
.filter_map(|ty| characteristic_def_id_of_type(ty))
|
||||
.next(),
|
||||
|
||||
ty::TyFnDef(def_id, _) |
|
||||
ty::TyClosure(def_id, _) |
|
||||
ty::TyGenerator(def_id, _, _) |
|
||||
ty::FnDef(def_id, _) |
|
||||
ty::Closure(def_id, _) |
|
||||
ty::Generator(def_id, _, _) |
|
||||
ty::TyForeign(def_id) => Some(def_id),
|
||||
|
||||
ty::TyBool |
|
||||
|
@ -382,14 +382,14 @@ pub fn characteristic_def_id_of_type(ty: Ty) -> Option<DefId> {
|
|||
ty::TyInt(_) |
|
||||
ty::TyUint(_) |
|
||||
ty::TyStr |
|
||||
ty::TyFnPtr(_) |
|
||||
ty::TyProjection(_) |
|
||||
ty::FnPtr(_) |
|
||||
ty::Projection(_) |
|
||||
ty::TyParam(_) |
|
||||
ty::TyAnon(..) |
|
||||
ty::TyInfer(_) |
|
||||
ty::TyError |
|
||||
ty::TyGeneratorWitness(..) |
|
||||
ty::TyNever |
|
||||
ty::Anon(..) |
|
||||
ty::Infer(_) |
|
||||
ty::Error |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Never |
|
||||
ty::TyFloat(_) => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -489,14 +489,14 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
|
||||
}
|
||||
ty::TyFloat(fty) => scalar(Float(fty)),
|
||||
ty::TyFnPtr(_) => {
|
||||
ty::FnPtr(_) => {
|
||||
let mut ptr = scalar_unit(Pointer);
|
||||
ptr.valid_range = 1..=*ptr.valid_range.end();
|
||||
tcx.intern_layout(LayoutDetails::scalar(self, ptr))
|
||||
}
|
||||
|
||||
// The never type.
|
||||
ty::TyNever => {
|
||||
ty::Never => {
|
||||
tcx.intern_layout(LayoutDetails {
|
||||
variants: Variants::Single { index: 0 },
|
||||
fields: FieldPlacement::Union(0),
|
||||
|
@ -507,8 +507,8 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
}
|
||||
|
||||
// Potentially-fat pointers.
|
||||
ty::TyRef(_, pointee, _) |
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
|
||||
ty::Ref(_, pointee, _) |
|
||||
ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
|
||||
let mut data_ptr = scalar_unit(Pointer);
|
||||
if !ty.is_unsafe_ptr() {
|
||||
data_ptr.valid_range = 1..=*data_ptr.valid_range.end();
|
||||
|
@ -524,10 +524,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
ty::TyForeign(..) => {
|
||||
return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr)));
|
||||
}
|
||||
ty::TySlice(_) | ty::TyStr => {
|
||||
ty::Slice(_) | ty::TyStr => {
|
||||
scalar_unit(Int(dl.ptr_sized_integer(), false))
|
||||
}
|
||||
ty::TyDynamic(..) => {
|
||||
ty::Dynamic(..) => {
|
||||
let mut vtable = scalar_unit(Pointer);
|
||||
vtable.valid_range = 1..=*vtable.valid_range.end();
|
||||
vtable
|
||||
|
@ -540,7 +540,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
}
|
||||
|
||||
// Arrays and slices.
|
||||
ty::TyArray(element, mut count) => {
|
||||
ty::Array(element, mut count) => {
|
||||
if count.has_projections() {
|
||||
count = tcx.normalize_erasing_regions(param_env, count);
|
||||
if count.has_projections() {
|
||||
|
@ -564,7 +564,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
size
|
||||
})
|
||||
}
|
||||
ty::TySlice(element) => {
|
||||
ty::Slice(element) => {
|
||||
let element = self.layout_of(element)?;
|
||||
tcx.intern_layout(LayoutDetails {
|
||||
variants: Variants::Single { index: 0 },
|
||||
|
@ -591,10 +591,10 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
}
|
||||
|
||||
// Odd unit types.
|
||||
ty::TyFnDef(..) => {
|
||||
ty::FnDef(..) => {
|
||||
univariant(&[], &ReprOptions::default(), StructKind::AlwaysSized)?
|
||||
}
|
||||
ty::TyDynamic(..) | ty::TyForeign(..) => {
|
||||
ty::Dynamic(..) | ty::TyForeign(..) => {
|
||||
let mut unit = univariant_uninterned(&[], &ReprOptions::default(),
|
||||
StructKind::AlwaysSized)?;
|
||||
match unit.abi {
|
||||
|
@ -605,21 +605,21 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
}
|
||||
|
||||
// Tuples, generators and closures.
|
||||
ty::TyGenerator(def_id, ref substs, _) => {
|
||||
ty::Generator(def_id, ref substs, _) => {
|
||||
let tys = substs.field_tys(def_id, tcx);
|
||||
univariant(&tys.map(|ty| self.layout_of(ty)).collect::<Result<Vec<_>, _>>()?,
|
||||
&ReprOptions::default(),
|
||||
StructKind::AlwaysSized)?
|
||||
}
|
||||
|
||||
ty::TyClosure(def_id, ref substs) => {
|
||||
ty::Closure(def_id, ref substs) => {
|
||||
let tys = substs.upvar_tys(def_id, tcx);
|
||||
univariant(&tys.map(|ty| self.layout_of(ty)).collect::<Result<Vec<_>, _>>()?,
|
||||
&ReprOptions::default(),
|
||||
StructKind::AlwaysSized)?
|
||||
}
|
||||
|
||||
ty::TyTuple(tys) => {
|
||||
ty::Tuple(tys) => {
|
||||
let kind = if tys.len() == 0 {
|
||||
StructKind::AlwaysSized
|
||||
} else {
|
||||
|
@ -631,7 +631,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
}
|
||||
|
||||
// SIMD vector types.
|
||||
ty::TyAdt(def, ..) if def.repr.simd() => {
|
||||
ty::Adt(def, ..) if def.repr.simd() => {
|
||||
let element = self.layout_of(ty.simd_type(tcx))?;
|
||||
let count = ty.simd_size(tcx) as u64;
|
||||
assert!(count > 0);
|
||||
|
@ -664,7 +664,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
}
|
||||
|
||||
// ADTs.
|
||||
ty::TyAdt(def, substs) => {
|
||||
ty::Adt(def, substs) => {
|
||||
// Cache the field layouts.
|
||||
let variants = def.variants.iter().map(|v| {
|
||||
v.fields.iter().map(|field| {
|
||||
|
@ -1103,17 +1103,17 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
}
|
||||
|
||||
// Types with no meaningful known layout.
|
||||
ty::TyProjection(_) | ty::TyAnon(..) => {
|
||||
ty::Projection(_) | ty::Anon(..) => {
|
||||
let normalized = tcx.normalize_erasing_regions(param_env, ty);
|
||||
if ty == normalized {
|
||||
return Err(LayoutError::Unknown(ty));
|
||||
}
|
||||
tcx.layout_raw(param_env.and(normalized))?
|
||||
}
|
||||
ty::TyGeneratorWitness(..) | ty::TyInfer(_) => {
|
||||
ty::GeneratorWitness(..) | ty::Infer(_) => {
|
||||
bug!("LayoutDetails::compute: unexpected type `{}`", ty)
|
||||
}
|
||||
ty::TyParam(_) | ty::TyError => {
|
||||
ty::TyParam(_) | ty::Error => {
|
||||
return Err(LayoutError::Unknown(ty));
|
||||
}
|
||||
})
|
||||
|
@ -1153,12 +1153,12 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
};
|
||||
|
||||
let adt_def = match layout.ty.sty {
|
||||
ty::TyAdt(ref adt_def, _) => {
|
||||
ty::Adt(ref adt_def, _) => {
|
||||
debug!("print-type-size t: `{:?}` process adt", layout.ty);
|
||||
adt_def
|
||||
}
|
||||
|
||||
ty::TyClosure(..) => {
|
||||
ty::Closure(..) => {
|
||||
debug!("print-type-size t: `{:?}` record closure", layout.ty);
|
||||
record(DataTypeKind::Closure, false, None, vec![]);
|
||||
return;
|
||||
|
@ -1294,12 +1294,12 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> {
|
|||
};
|
||||
|
||||
match ty.sty {
|
||||
ty::TyRef(_, pointee, _) |
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
|
||||
ty::Ref(_, pointee, _) |
|
||||
ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
|
||||
let non_zero = !ty.is_unsafe_ptr();
|
||||
let tail = tcx.struct_tail(pointee);
|
||||
match tail.sty {
|
||||
ty::TyParam(_) | ty::TyProjection(_) => {
|
||||
ty::TyParam(_) | ty::Projection(_) => {
|
||||
debug_assert!(tail.has_param_types() || tail.has_self_ty());
|
||||
Ok(SizeSkeleton::Pointer {
|
||||
non_zero,
|
||||
|
@ -1314,7 +1314,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyAdt(def, substs) => {
|
||||
ty::Adt(def, substs) => {
|
||||
// Only newtypes and enums w/ nullable pointer optimization.
|
||||
if def.is_union() || def.variants.is_empty() || def.variants.len() > 2 {
|
||||
return Err(err);
|
||||
|
@ -1373,7 +1373,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyProjection(_) | ty::TyAnon(..) => {
|
||||
ty::Projection(_) | ty::Anon(..) => {
|
||||
let normalized = tcx.normalize_erasing_regions(param_env, ty);
|
||||
if ty == normalized {
|
||||
Err(err)
|
||||
|
@ -1552,7 +1552,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
|||
});
|
||||
|
||||
let fields = match this.ty.sty {
|
||||
ty::TyAdt(def, _) => def.variants[variant_index].fields.len(),
|
||||
ty::Adt(def, _) => def.variants[variant_index].fields.len(),
|
||||
_ => bug!()
|
||||
};
|
||||
let tcx = cx.tcx();
|
||||
|
@ -1587,18 +1587,18 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
|||
ty::TyInt(_) |
|
||||
ty::TyUint(_) |
|
||||
ty::TyFloat(_) |
|
||||
ty::TyFnPtr(_) |
|
||||
ty::TyNever |
|
||||
ty::TyFnDef(..) |
|
||||
ty::TyGeneratorWitness(..) |
|
||||
ty::FnPtr(_) |
|
||||
ty::Never |
|
||||
ty::FnDef(..) |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::TyForeign(..) |
|
||||
ty::TyDynamic(..) => {
|
||||
ty::Dynamic(..) => {
|
||||
bug!("TyLayout::field_type({:?}): not applicable", this)
|
||||
}
|
||||
|
||||
// Potentially-fat pointers.
|
||||
ty::TyRef(_, pointee, _) |
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
|
||||
ty::Ref(_, pointee, _) |
|
||||
ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
|
||||
assert!(i < this.fields.count());
|
||||
|
||||
// Reuse the fat *T type as its own thin pointer data field.
|
||||
|
@ -1619,9 +1619,9 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
|||
}
|
||||
|
||||
match tcx.struct_tail(pointee).sty {
|
||||
ty::TySlice(_) |
|
||||
ty::Slice(_) |
|
||||
ty::TyStr => tcx.types.usize,
|
||||
ty::TyDynamic(data, _) => {
|
||||
ty::Dynamic(data, _) => {
|
||||
let trait_def_id = data.principal().unwrap().def_id();
|
||||
let num_fns: u64 = crate::traits::supertrait_def_ids(tcx, trait_def_id)
|
||||
.map(|trait_def_id| {
|
||||
|
@ -1646,28 +1646,28 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
|||
}
|
||||
|
||||
// Arrays and slices.
|
||||
ty::TyArray(element, _) |
|
||||
ty::TySlice(element) => element,
|
||||
ty::Array(element, _) |
|
||||
ty::Slice(element) => element,
|
||||
ty::TyStr => tcx.types.u8,
|
||||
|
||||
// Tuples, generators and closures.
|
||||
ty::TyClosure(def_id, ref substs) => {
|
||||
ty::Closure(def_id, ref substs) => {
|
||||
substs.upvar_tys(def_id, tcx).nth(i).unwrap()
|
||||
}
|
||||
|
||||
ty::TyGenerator(def_id, ref substs, _) => {
|
||||
ty::Generator(def_id, ref substs, _) => {
|
||||
substs.field_tys(def_id, tcx).nth(i).unwrap()
|
||||
}
|
||||
|
||||
ty::TyTuple(tys) => tys[i],
|
||||
ty::Tuple(tys) => tys[i],
|
||||
|
||||
// SIMD vector types.
|
||||
ty::TyAdt(def, ..) if def.repr.simd() => {
|
||||
ty::Adt(def, ..) if def.repr.simd() => {
|
||||
this.ty.simd_type(tcx)
|
||||
}
|
||||
|
||||
// ADTs.
|
||||
ty::TyAdt(def, substs) => {
|
||||
ty::Adt(def, substs) => {
|
||||
match this.variants {
|
||||
Variants::Single { index } => {
|
||||
def.variants[index].fields[i].ty(tcx, substs)
|
||||
|
@ -1686,8 +1686,8 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyProjection(_) | ty::TyAnon(..) | ty::TyParam(_) |
|
||||
ty::TyInfer(_) | ty::TyError => {
|
||||
ty::Projection(_) | ty::Anon(..) | ty::TyParam(_) |
|
||||
ty::Infer(_) | ty::Error => {
|
||||
bug!("TyLayout::field_type: unexpected type `{}`", this.ty)
|
||||
}
|
||||
})
|
||||
|
@ -1749,7 +1749,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
// Locals variables which live across yields are stored
|
||||
// in the generator type as fields. These may be uninitialized
|
||||
// so we don't look for niches there.
|
||||
if let ty::TyGenerator(..) = layout.ty.sty {
|
||||
if let ty::Generator(..) = layout.ty.sty {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
|
|
|
@ -450,7 +450,7 @@ bitflags! {
|
|||
const HAS_FREE_LOCAL_NAMES = 1 << 10;
|
||||
|
||||
// Present if the type belongs in a local type context.
|
||||
// Only set for TyInfer other than Fresh.
|
||||
// Only set for Infer other than Fresh.
|
||||
const KEEP_IN_LOCAL_TCX = 1 << 11;
|
||||
|
||||
// Is there a projection that does not involve a bound region?
|
||||
|
@ -547,24 +547,24 @@ impl<'tcx> TyS<'tcx> {
|
|||
TyKind::TyInt(_) |
|
||||
TyKind::TyUint(_) |
|
||||
TyKind::TyFloat(_) |
|
||||
TyKind::TyInfer(InferTy::IntVar(_)) |
|
||||
TyKind::TyInfer(InferTy::FloatVar(_)) |
|
||||
TyKind::TyInfer(InferTy::FreshIntTy(_)) |
|
||||
TyKind::TyInfer(InferTy::FreshFloatTy(_)) => true,
|
||||
TyKind::TyRef(_, x, _) => x.is_primitive_ty(),
|
||||
TyKind::Infer(InferTy::IntVar(_)) |
|
||||
TyKind::Infer(InferTy::FloatVar(_)) |
|
||||
TyKind::Infer(InferTy::FreshIntTy(_)) |
|
||||
TyKind::Infer(InferTy::FreshFloatTy(_)) => true,
|
||||
TyKind::Ref(_, x, _) => x.is_primitive_ty(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_suggestable(&self) -> bool {
|
||||
match self.sty {
|
||||
TyKind::TyAnon(..) |
|
||||
TyKind::TyFnDef(..) |
|
||||
TyKind::TyFnPtr(..) |
|
||||
TyKind::TyDynamic(..) |
|
||||
TyKind::TyClosure(..) |
|
||||
TyKind::TyInfer(..) |
|
||||
TyKind::TyProjection(..) => false,
|
||||
TyKind::Anon(..) |
|
||||
TyKind::FnDef(..) |
|
||||
TyKind::FnPtr(..) |
|
||||
TyKind::Dynamic(..) |
|
||||
TyKind::Closure(..) |
|
||||
TyKind::Infer(..) |
|
||||
TyKind::Projection(..) => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
@ -2231,29 +2231,29 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
|||
-> Vec<Ty<'tcx>> {
|
||||
let result = match ty.sty {
|
||||
TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
|
||||
TyRawPtr(..) | TyRef(..) | TyFnDef(..) | TyFnPtr(_) |
|
||||
TyArray(..) | TyClosure(..) | TyGenerator(..) | TyNever => {
|
||||
RawPtr(..) | Ref(..) | FnDef(..) | FnPtr(_) |
|
||||
Array(..) | Closure(..) | Generator(..) | Never => {
|
||||
vec![]
|
||||
}
|
||||
|
||||
TyStr |
|
||||
TyDynamic(..) |
|
||||
TySlice(_) |
|
||||
Dynamic(..) |
|
||||
Slice(_) |
|
||||
TyForeign(..) |
|
||||
TyError |
|
||||
TyGeneratorWitness(..) => {
|
||||
Error |
|
||||
GeneratorWitness(..) => {
|
||||
// these are never sized - return the target type
|
||||
vec![ty]
|
||||
}
|
||||
|
||||
TyTuple(ref tys) => {
|
||||
Tuple(ref tys) => {
|
||||
match tys.last() {
|
||||
None => vec![],
|
||||
Some(ty) => self.sized_constraint_for_ty(tcx, ty)
|
||||
}
|
||||
}
|
||||
|
||||
TyAdt(adt, substs) => {
|
||||
Adt(adt, substs) => {
|
||||
// recursive case
|
||||
let adt_tys = adt.sized_constraint(tcx);
|
||||
debug!("sized_constraint_for_ty({:?}) intermediate = {:?}",
|
||||
|
@ -2264,7 +2264,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
|||
.collect()
|
||||
}
|
||||
|
||||
TyProjection(..) | TyAnon(..) => {
|
||||
Projection(..) | Anon(..) => {
|
||||
// must calculate explicitly.
|
||||
// FIXME: consider special-casing always-Sized projections
|
||||
vec![ty]
|
||||
|
@ -2291,7 +2291,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
|||
}
|
||||
}
|
||||
|
||||
TyInfer(..) => {
|
||||
Infer(..) => {
|
||||
bug!("unexpected type `{:?}` in sized_constraint_for_ty",
|
||||
ty)
|
||||
}
|
||||
|
@ -2833,7 +2833,7 @@ fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
|||
/// - a type parameter or projection whose Sizedness can't be known
|
||||
/// - a tuple of type parameters or projections, if there are multiple
|
||||
/// such.
|
||||
/// - a TyError, if a type contained itself. The representability
|
||||
/// - a Error, if a type contained itself. The representability
|
||||
/// check should catch this case.
|
||||
fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId)
|
||||
|
|
|
@ -72,14 +72,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
// in the `subtys` iterator (e.g., when encountering a
|
||||
// projection).
|
||||
match ty.sty {
|
||||
ty::TyClosure(def_id, ref substs) => {
|
||||
ty::Closure(def_id, ref substs) => {
|
||||
|
||||
for upvar_ty in substs.upvar_tys(def_id, *self) {
|
||||
self.compute_components(upvar_ty, out);
|
||||
}
|
||||
}
|
||||
|
||||
ty::TyGenerator(def_id, ref substs, _) => {
|
||||
ty::Generator(def_id, ref substs, _) => {
|
||||
// Same as the closure case
|
||||
for upvar_ty in substs.upvar_tys(def_id, *self) {
|
||||
self.compute_components(upvar_ty, out);
|
||||
|
@ -90,7 +90,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
// All regions are bound inside a witness
|
||||
ty::TyGeneratorWitness(..) => (),
|
||||
ty::GeneratorWitness(..) => (),
|
||||
|
||||
// OutlivesTypeParameterEnv -- the actual checking that `X:'a`
|
||||
// is implied by the environment is done in regionck.
|
||||
|
@ -106,7 +106,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
// trait-ref. Therefore, if we see any higher-ranke regions,
|
||||
// we simply fallback to the most restrictive rule, which
|
||||
// requires that `Pi: 'a` for all `i`.
|
||||
ty::TyProjection(ref data) => {
|
||||
ty::Projection(ref data) => {
|
||||
if !data.has_escaping_regions() {
|
||||
// best case: no escaping regions, so push the
|
||||
// projection and skip the subtree (thus generating no
|
||||
|
@ -127,7 +127,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
// We assume that inference variables are fully resolved.
|
||||
// So, if we encounter an inference variable, just record
|
||||
// the unresolved variable as a component.
|
||||
ty::TyInfer(infer_ty) => {
|
||||
ty::Infer(infer_ty) => {
|
||||
out.push(Component::UnresolvedInferenceVariable(infer_ty));
|
||||
}
|
||||
|
||||
|
@ -142,20 +142,20 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
ty::TyInt(..) | // OutlivesScalar
|
||||
ty::TyUint(..) | // OutlivesScalar
|
||||
ty::TyFloat(..) | // OutlivesScalar
|
||||
ty::TyNever | // ...
|
||||
ty::TyAdt(..) | // OutlivesNominalType
|
||||
ty::TyAnon(..) | // OutlivesNominalType (ish)
|
||||
ty::Never | // ...
|
||||
ty::Adt(..) | // OutlivesNominalType
|
||||
ty::Anon(..) | // OutlivesNominalType (ish)
|
||||
ty::TyForeign(..) | // OutlivesNominalType
|
||||
ty::TyStr | // OutlivesScalar (ish)
|
||||
ty::TyArray(..) | // ...
|
||||
ty::TySlice(..) | // ...
|
||||
ty::TyRawPtr(..) | // ...
|
||||
ty::TyRef(..) | // OutlivesReference
|
||||
ty::TyTuple(..) | // ...
|
||||
ty::TyFnDef(..) | // OutlivesFunction (*)
|
||||
ty::TyFnPtr(_) | // OutlivesFunction (*)
|
||||
ty::TyDynamic(..) | // OutlivesObject, OutlivesFragment (*)
|
||||
ty::TyError => {
|
||||
ty::Array(..) | // ...
|
||||
ty::Slice(..) | // ...
|
||||
ty::RawPtr(..) | // ...
|
||||
ty::Ref(..) | // OutlivesReference
|
||||
ty::Tuple(..) | // ...
|
||||
ty::FnDef(..) | // OutlivesFunction (*)
|
||||
ty::FnPtr(_) | // OutlivesFunction (*)
|
||||
ty::Dynamic(..) | // OutlivesObject, OutlivesFragment (*)
|
||||
ty::Error => {
|
||||
// (*) Bare functions and traits are both binders. In the
|
||||
// RFC, this means we would add the bound regions to the
|
||||
// "bound regions list". In our representation, no such
|
||||
|
|
|
@ -363,19 +363,19 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
|||
let b_sty = &b.sty;
|
||||
debug!("super_tys: a_sty={:?} b_sty={:?}", a_sty, b_sty);
|
||||
match (a_sty, b_sty) {
|
||||
(&ty::TyInfer(_), _) |
|
||||
(_, &ty::TyInfer(_)) =>
|
||||
(&ty::Infer(_), _) |
|
||||
(_, &ty::Infer(_)) =>
|
||||
{
|
||||
// The caller should handle these cases!
|
||||
bug!("var types encountered in super_relate_tys")
|
||||
}
|
||||
|
||||
(&ty::TyError, _) | (_, &ty::TyError) =>
|
||||
(&ty::Error, _) | (_, &ty::Error) =>
|
||||
{
|
||||
Ok(tcx.types.err)
|
||||
}
|
||||
|
||||
(&ty::TyNever, _) |
|
||||
(&ty::Never, _) |
|
||||
(&ty::TyChar, _) |
|
||||
(&ty::TyBool, _) |
|
||||
(&ty::TyInt(_), _) |
|
||||
|
@ -393,7 +393,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
|||
Ok(a)
|
||||
}
|
||||
|
||||
(&ty::TyAdt(a_def, a_substs), &ty::TyAdt(b_def, b_substs))
|
||||
(&ty::Adt(a_def, a_substs), &ty::Adt(b_def, b_substs))
|
||||
if a_def == b_def =>
|
||||
{
|
||||
let substs = relation.relate_item_substs(a_def.did, a_substs, b_substs)?;
|
||||
|
@ -406,7 +406,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
|||
Ok(tcx.mk_foreign(a_id))
|
||||
}
|
||||
|
||||
(&ty::TyDynamic(ref a_obj, ref a_region), &ty::TyDynamic(ref b_obj, ref b_region)) => {
|
||||
(&ty::Dynamic(ref a_obj, ref a_region), &ty::Dynamic(ref b_obj, ref b_region)) => {
|
||||
let region_bound = relation.with_cause(Cause::ExistentialRegionBound,
|
||||
|relation| {
|
||||
relation.relate_with_variance(
|
||||
|
@ -417,18 +417,18 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
|||
Ok(tcx.mk_dynamic(relation.relate(a_obj, b_obj)?, region_bound))
|
||||
}
|
||||
|
||||
(&ty::TyGenerator(a_id, a_substs, movability),
|
||||
&ty::TyGenerator(b_id, b_substs, _))
|
||||
(&ty::Generator(a_id, a_substs, movability),
|
||||
&ty::Generator(b_id, b_substs, _))
|
||||
if a_id == b_id =>
|
||||
{
|
||||
// All TyGenerator types with the same id represent
|
||||
// All Generator types with the same id represent
|
||||
// the (anonymous) type of the same generator expression. So
|
||||
// all of their regions should be equated.
|
||||
let substs = relation.relate(&a_substs, &b_substs)?;
|
||||
Ok(tcx.mk_generator(a_id, substs, movability))
|
||||
}
|
||||
|
||||
(&ty::TyGeneratorWitness(a_types), &ty::TyGeneratorWitness(b_types)) =>
|
||||
(&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) =>
|
||||
{
|
||||
// Wrap our types with a temporary GeneratorWitness struct
|
||||
// inside the binder so we can related them
|
||||
|
@ -439,24 +439,24 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
|||
Ok(tcx.mk_generator_witness(types))
|
||||
}
|
||||
|
||||
(&ty::TyClosure(a_id, a_substs),
|
||||
&ty::TyClosure(b_id, b_substs))
|
||||
(&ty::Closure(a_id, a_substs),
|
||||
&ty::Closure(b_id, b_substs))
|
||||
if a_id == b_id =>
|
||||
{
|
||||
// All TyClosure types with the same id represent
|
||||
// All Closure types with the same id represent
|
||||
// the (anonymous) type of the same closure expression. So
|
||||
// all of their regions should be equated.
|
||||
let substs = relation.relate(&a_substs, &b_substs)?;
|
||||
Ok(tcx.mk_closure(a_id, substs))
|
||||
}
|
||||
|
||||
(&ty::TyRawPtr(ref a_mt), &ty::TyRawPtr(ref b_mt)) =>
|
||||
(&ty::RawPtr(ref a_mt), &ty::RawPtr(ref b_mt)) =>
|
||||
{
|
||||
let mt = relation.relate(a_mt, b_mt)?;
|
||||
Ok(tcx.mk_ptr(mt))
|
||||
}
|
||||
|
||||
(&ty::TyRef(a_r, a_ty, a_mutbl), &ty::TyRef(b_r, b_ty, b_mutbl)) =>
|
||||
(&ty::Ref(a_r, a_ty, a_mutbl), &ty::Ref(b_r, b_ty, b_mutbl)) =>
|
||||
{
|
||||
let r = relation.relate_with_variance(ty::Contravariant, &a_r, &b_r)?;
|
||||
let a_mt = ty::TypeAndMut { ty: a_ty, mutbl: a_mutbl };
|
||||
|
@ -465,7 +465,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
|||
Ok(tcx.mk_ref(r, mt))
|
||||
}
|
||||
|
||||
(&ty::TyArray(a_t, sz_a), &ty::TyArray(b_t, sz_b)) =>
|
||||
(&ty::Array(a_t, sz_a), &ty::Array(b_t, sz_b)) =>
|
||||
{
|
||||
let t = relation.relate(&a_t, &b_t)?;
|
||||
assert_eq!(sz_a.ty, tcx.types.usize);
|
||||
|
@ -514,26 +514,26 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
|||
match (to_u64(sz_a), to_u64(sz_b)) {
|
||||
(Ok(sz_a_u64), Ok(sz_b_u64)) => {
|
||||
if sz_a_u64 == sz_b_u64 {
|
||||
Ok(tcx.mk_ty(ty::TyArray(t, sz_a)))
|
||||
Ok(tcx.mk_ty(ty::Array(t, sz_a)))
|
||||
} else {
|
||||
Err(TypeError::FixedArraySize(
|
||||
expected_found(relation, &sz_a_u64, &sz_b_u64)))
|
||||
}
|
||||
}
|
||||
// We reported an error or will ICE, so we can return TyError.
|
||||
// We reported an error or will ICE, so we can return Error.
|
||||
(Err(ErrorReported), _) | (_, Err(ErrorReported)) => {
|
||||
Ok(tcx.types.err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(&ty::TySlice(a_t), &ty::TySlice(b_t)) =>
|
||||
(&ty::Slice(a_t), &ty::Slice(b_t)) =>
|
||||
{
|
||||
let t = relation.relate(&a_t, &b_t)?;
|
||||
Ok(tcx.mk_slice(t))
|
||||
}
|
||||
|
||||
(&ty::TyTuple(as_), &ty::TyTuple(bs)) =>
|
||||
(&ty::Tuple(as_), &ty::Tuple(bs)) =>
|
||||
{
|
||||
if as_.len() == bs.len() {
|
||||
Ok(tcx.mk_tup(as_.iter().zip(bs).map(|(a, b)| relation.relate(a, b)))?)
|
||||
|
@ -545,26 +545,26 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
|||
}
|
||||
}
|
||||
|
||||
(&ty::TyFnDef(a_def_id, a_substs), &ty::TyFnDef(b_def_id, b_substs))
|
||||
(&ty::FnDef(a_def_id, a_substs), &ty::FnDef(b_def_id, b_substs))
|
||||
if a_def_id == b_def_id =>
|
||||
{
|
||||
let substs = relation.relate_item_substs(a_def_id, a_substs, b_substs)?;
|
||||
Ok(tcx.mk_fn_def(a_def_id, substs))
|
||||
}
|
||||
|
||||
(&ty::TyFnPtr(a_fty), &ty::TyFnPtr(b_fty)) =>
|
||||
(&ty::FnPtr(a_fty), &ty::FnPtr(b_fty)) =>
|
||||
{
|
||||
let fty = relation.relate(&a_fty, &b_fty)?;
|
||||
Ok(tcx.mk_fn_ptr(fty))
|
||||
}
|
||||
|
||||
(&ty::TyProjection(ref a_data), &ty::TyProjection(ref b_data)) =>
|
||||
(&ty::Projection(ref a_data), &ty::Projection(ref b_data)) =>
|
||||
{
|
||||
let projection_ty = relation.relate(a_data, b_data)?;
|
||||
Ok(tcx.mk_projection(projection_ty.item_def_id, projection_ty.substs))
|
||||
}
|
||||
|
||||
(&ty::TyAnon(a_def_id, a_substs), &ty::TyAnon(b_def_id, b_substs))
|
||||
(&ty::Anon(a_def_id, a_substs), &ty::Anon(b_def_id, b_substs))
|
||||
if a_def_id == b_def_id =>
|
||||
{
|
||||
let substs = relate_substs(relation, None, a_substs, b_substs)?;
|
||||
|
|
|
@ -836,33 +836,33 @@ impl<'tcx> TypeFoldable<'tcx> for interpret::GlobalId<'tcx> {
|
|||
impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
||||
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
|
||||
let sty = match self.sty {
|
||||
ty::TyRawPtr(tm) => ty::TyRawPtr(tm.fold_with(folder)),
|
||||
ty::TyArray(typ, sz) => ty::TyArray(typ.fold_with(folder), sz.fold_with(folder)),
|
||||
ty::TySlice(typ) => ty::TySlice(typ.fold_with(folder)),
|
||||
ty::TyAdt(tid, substs) => ty::TyAdt(tid, substs.fold_with(folder)),
|
||||
ty::TyDynamic(ref trait_ty, ref region) =>
|
||||
ty::TyDynamic(trait_ty.fold_with(folder), region.fold_with(folder)),
|
||||
ty::TyTuple(ts) => ty::TyTuple(ts.fold_with(folder)),
|
||||
ty::TyFnDef(def_id, substs) => {
|
||||
ty::TyFnDef(def_id, substs.fold_with(folder))
|
||||
ty::RawPtr(tm) => ty::RawPtr(tm.fold_with(folder)),
|
||||
ty::Array(typ, sz) => ty::Array(typ.fold_with(folder), sz.fold_with(folder)),
|
||||
ty::Slice(typ) => ty::Slice(typ.fold_with(folder)),
|
||||
ty::Adt(tid, substs) => ty::Adt(tid, substs.fold_with(folder)),
|
||||
ty::Dynamic(ref trait_ty, ref region) =>
|
||||
ty::Dynamic(trait_ty.fold_with(folder), region.fold_with(folder)),
|
||||
ty::Tuple(ts) => ty::Tuple(ts.fold_with(folder)),
|
||||
ty::FnDef(def_id, substs) => {
|
||||
ty::FnDef(def_id, substs.fold_with(folder))
|
||||
}
|
||||
ty::TyFnPtr(f) => ty::TyFnPtr(f.fold_with(folder)),
|
||||
ty::TyRef(ref r, ty, mutbl) => {
|
||||
ty::TyRef(r.fold_with(folder), ty.fold_with(folder), mutbl)
|
||||
ty::FnPtr(f) => ty::FnPtr(f.fold_with(folder)),
|
||||
ty::Ref(ref r, ty, mutbl) => {
|
||||
ty::Ref(r.fold_with(folder), ty.fold_with(folder), mutbl)
|
||||
}
|
||||
ty::TyGenerator(did, substs, movability) => {
|
||||
ty::TyGenerator(
|
||||
ty::Generator(did, substs, movability) => {
|
||||
ty::Generator(
|
||||
did,
|
||||
substs.fold_with(folder),
|
||||
movability)
|
||||
}
|
||||
ty::TyGeneratorWitness(types) => ty::TyGeneratorWitness(types.fold_with(folder)),
|
||||
ty::TyClosure(did, substs) => ty::TyClosure(did, substs.fold_with(folder)),
|
||||
ty::TyProjection(ref data) => ty::TyProjection(data.fold_with(folder)),
|
||||
ty::TyAnon(did, substs) => ty::TyAnon(did, substs.fold_with(folder)),
|
||||
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)),
|
||||
ty::Closure(did, substs) => ty::Closure(did, substs.fold_with(folder)),
|
||||
ty::Projection(ref data) => ty::Projection(data.fold_with(folder)),
|
||||
ty::Anon(did, substs) => ty::Anon(did, substs.fold_with(folder)),
|
||||
ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) |
|
||||
ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) |
|
||||
ty::TyParam(..) | ty::TyNever | ty::TyForeign(..) => return self
|
||||
ty::TyUint(_) | ty::TyFloat(_) | ty::Error | ty::Infer(_) |
|
||||
ty::TyParam(..) | ty::Never | ty::TyForeign(..) => return self
|
||||
};
|
||||
|
||||
if self.sty == sty {
|
||||
|
@ -878,26 +878,26 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
|||
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
||||
match self.sty {
|
||||
ty::TyRawPtr(ref tm) => tm.visit_with(visitor),
|
||||
ty::TyArray(typ, sz) => typ.visit_with(visitor) || sz.visit_with(visitor),
|
||||
ty::TySlice(typ) => typ.visit_with(visitor),
|
||||
ty::TyAdt(_, substs) => substs.visit_with(visitor),
|
||||
ty::TyDynamic(ref trait_ty, ref reg) =>
|
||||
ty::RawPtr(ref tm) => tm.visit_with(visitor),
|
||||
ty::Array(typ, sz) => typ.visit_with(visitor) || sz.visit_with(visitor),
|
||||
ty::Slice(typ) => typ.visit_with(visitor),
|
||||
ty::Adt(_, substs) => substs.visit_with(visitor),
|
||||
ty::Dynamic(ref trait_ty, ref reg) =>
|
||||
trait_ty.visit_with(visitor) || reg.visit_with(visitor),
|
||||
ty::TyTuple(ts) => ts.visit_with(visitor),
|
||||
ty::TyFnDef(_, substs) => substs.visit_with(visitor),
|
||||
ty::TyFnPtr(ref f) => f.visit_with(visitor),
|
||||
ty::TyRef(r, ty, _) => r.visit_with(visitor) || ty.visit_with(visitor),
|
||||
ty::TyGenerator(_did, ref substs, _) => {
|
||||
ty::Tuple(ts) => ts.visit_with(visitor),
|
||||
ty::FnDef(_, substs) => substs.visit_with(visitor),
|
||||
ty::FnPtr(ref f) => f.visit_with(visitor),
|
||||
ty::Ref(r, ty, _) => r.visit_with(visitor) || ty.visit_with(visitor),
|
||||
ty::Generator(_did, ref substs, _) => {
|
||||
substs.visit_with(visitor)
|
||||
}
|
||||
ty::TyGeneratorWitness(ref types) => types.visit_with(visitor),
|
||||
ty::TyClosure(_did, ref substs) => substs.visit_with(visitor),
|
||||
ty::TyProjection(ref data) => data.visit_with(visitor),
|
||||
ty::TyAnon(_, ref substs) => substs.visit_with(visitor),
|
||||
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
|
||||
ty::Closure(_did, ref substs) => substs.visit_with(visitor),
|
||||
ty::Projection(ref data) => data.visit_with(visitor),
|
||||
ty::Anon(_, ref substs) => substs.visit_with(visitor),
|
||||
ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) |
|
||||
ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) |
|
||||
ty::TyParam(..) | ty::TyNever | ty::TyForeign(..) => false,
|
||||
ty::TyUint(_) | ty::TyFloat(_) | ty::Error | ty::Infer(_) |
|
||||
ty::TyParam(..) | ty::Never | ty::TyForeign(..) => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,9 +103,9 @@ pub enum TyKind<'tcx> {
|
|||
///
|
||||
/// Substs here, possibly against intuition, *may* contain `TyParam`s.
|
||||
/// That is, even after substitution it is possible that there are type
|
||||
/// variables. This happens when the `TyAdt` corresponds to an ADT
|
||||
/// variables. This happens when the `Adt` corresponds to an ADT
|
||||
/// definition and not a concrete use of it.
|
||||
TyAdt(&'tcx AdtDef, &'tcx Substs<'tcx>),
|
||||
Adt(&'tcx AdtDef, &'tcx Substs<'tcx>),
|
||||
|
||||
TyForeign(DefId),
|
||||
|
||||
|
@ -113,49 +113,49 @@ pub enum TyKind<'tcx> {
|
|||
TyStr,
|
||||
|
||||
/// An array with the given length. Written as `[T; n]`.
|
||||
TyArray(Ty<'tcx>, &'tcx ty::Const<'tcx>),
|
||||
Array(Ty<'tcx>, &'tcx ty::Const<'tcx>),
|
||||
|
||||
/// The pointee of an array slice. Written as `[T]`.
|
||||
TySlice(Ty<'tcx>),
|
||||
Slice(Ty<'tcx>),
|
||||
|
||||
/// A raw pointer. Written as `*mut T` or `*const T`
|
||||
TyRawPtr(TypeAndMut<'tcx>),
|
||||
RawPtr(TypeAndMut<'tcx>),
|
||||
|
||||
/// A reference; a pointer with an associated lifetime. Written as
|
||||
/// `&'a mut T` or `&'a T`.
|
||||
TyRef(Region<'tcx>, Ty<'tcx>, hir::Mutability),
|
||||
Ref(Region<'tcx>, Ty<'tcx>, hir::Mutability),
|
||||
|
||||
/// The anonymous type of a function declaration/definition. Each
|
||||
/// function has a unique type.
|
||||
TyFnDef(DefId, &'tcx Substs<'tcx>),
|
||||
FnDef(DefId, &'tcx Substs<'tcx>),
|
||||
|
||||
/// A pointer to a function. Written as `fn() -> i32`.
|
||||
TyFnPtr(PolyFnSig<'tcx>),
|
||||
FnPtr(PolyFnSig<'tcx>),
|
||||
|
||||
/// A trait, defined with `trait`.
|
||||
TyDynamic(Binder<&'tcx List<ExistentialPredicate<'tcx>>>, ty::Region<'tcx>),
|
||||
Dynamic(Binder<&'tcx List<ExistentialPredicate<'tcx>>>, ty::Region<'tcx>),
|
||||
|
||||
/// The anonymous type of a closure. Used to represent the type of
|
||||
/// `|a| a`.
|
||||
TyClosure(DefId, ClosureSubsts<'tcx>),
|
||||
Closure(DefId, ClosureSubsts<'tcx>),
|
||||
|
||||
/// The anonymous type of a generator. Used to represent the type of
|
||||
/// `|a| yield a`.
|
||||
TyGenerator(DefId, GeneratorSubsts<'tcx>, hir::GeneratorMovability),
|
||||
Generator(DefId, GeneratorSubsts<'tcx>, hir::GeneratorMovability),
|
||||
|
||||
/// A type representin the types stored inside a generator.
|
||||
/// This should only appear in GeneratorInteriors.
|
||||
TyGeneratorWitness(Binder<&'tcx List<Ty<'tcx>>>),
|
||||
GeneratorWitness(Binder<&'tcx List<Ty<'tcx>>>),
|
||||
|
||||
/// The never type `!`
|
||||
TyNever,
|
||||
Never,
|
||||
|
||||
/// A tuple type. For example, `(i32, bool)`.
|
||||
TyTuple(&'tcx List<Ty<'tcx>>),
|
||||
Tuple(&'tcx List<Ty<'tcx>>),
|
||||
|
||||
/// The projection of an associated type. For example,
|
||||
/// `<T as Trait<..>>::N`.
|
||||
TyProjection(ProjectionTy<'tcx>),
|
||||
Projection(ProjectionTy<'tcx>),
|
||||
|
||||
/// Anonymized (`impl Trait`) type found in a return type.
|
||||
/// The DefId comes either from
|
||||
|
@ -163,17 +163,17 @@ pub enum TyKind<'tcx> {
|
|||
/// * or the `existential type` declaration
|
||||
/// The substitutions are for the generics of the function in question.
|
||||
/// After typeck, the concrete type can be found in the `types` map.
|
||||
TyAnon(DefId, &'tcx Substs<'tcx>),
|
||||
Anon(DefId, &'tcx Substs<'tcx>),
|
||||
|
||||
/// A type parameter; for example, `T` in `fn f<T>(x: T) {}
|
||||
TyParam(ParamTy),
|
||||
|
||||
/// A type variable used during type-checking.
|
||||
TyInfer(InferTy),
|
||||
Infer(InferTy),
|
||||
|
||||
/// A placeholder for a type which could not be computed; this is
|
||||
/// propagated to avoid useless error messages.
|
||||
TyError,
|
||||
Error,
|
||||
}
|
||||
|
||||
/// A closure can be modeled as a struct that looks like:
|
||||
|
@ -348,7 +348,7 @@ impl<'tcx> ClosureSubsts<'tcx> {
|
|||
/// If you have an inference context, use `infcx.closure_sig()`.
|
||||
pub fn closure_sig(self, def_id: DefId, tcx: TyCtxt<'_, 'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> {
|
||||
match self.closure_sig_ty(def_id, tcx).sty {
|
||||
ty::TyFnPtr(sig) => sig,
|
||||
ty::FnPtr(sig) => sig,
|
||||
ref t => bug!("closure_sig_ty is not a fn-ptr: {:?}", t),
|
||||
}
|
||||
}
|
||||
|
@ -1469,14 +1469,14 @@ impl RegionKind {
|
|||
impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
pub fn is_nil(&self) -> bool {
|
||||
match self.sty {
|
||||
TyTuple(ref tys) => tys.is_empty(),
|
||||
Tuple(ref tys) => tys.is_empty(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_never(&self) -> bool {
|
||||
match self.sty {
|
||||
TyNever => true,
|
||||
Never => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -1490,20 +1490,20 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
|
||||
pub fn is_ty_var(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(TyVar(_)) => true,
|
||||
Infer(TyVar(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_ty_infer(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(_) => true,
|
||||
Infer(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_phantom_data(&self) -> bool {
|
||||
if let TyAdt(def, _) = self.sty {
|
||||
if let Adt(def, _) = self.sty {
|
||||
def.is_phantom_data()
|
||||
} else {
|
||||
false
|
||||
|
@ -1528,8 +1528,8 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
|
||||
pub fn is_slice(&self) -> bool {
|
||||
match self.sty {
|
||||
TyRawPtr(TypeAndMut { ty, .. }) | TyRef(_, ty, _) => match ty.sty {
|
||||
TySlice(_) | TyStr => true,
|
||||
RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => match ty.sty {
|
||||
Slice(_) | TyStr => true,
|
||||
_ => false,
|
||||
},
|
||||
_ => false
|
||||
|
@ -1539,14 +1539,14 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
#[inline]
|
||||
pub fn is_simd(&self) -> bool {
|
||||
match self.sty {
|
||||
TyAdt(def, _) => def.repr.simd(),
|
||||
Adt(def, _) => def.repr.simd(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sequence_element_type(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
TyArray(ty, _) | TySlice(ty) => ty,
|
||||
Array(ty, _) | Slice(ty) => ty,
|
||||
TyStr => tcx.mk_mach_uint(ast::UintTy::U8),
|
||||
_ => bug!("sequence_element_type called on non-sequence value: {}", self),
|
||||
}
|
||||
|
@ -1554,7 +1554,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
|
||||
pub fn simd_type(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
TyAdt(def, substs) => {
|
||||
Adt(def, substs) => {
|
||||
def.non_enum_variant().fields[0].ty(tcx, substs)
|
||||
}
|
||||
_ => bug!("simd_type called on invalid type")
|
||||
|
@ -1563,36 +1563,36 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
|
||||
pub fn simd_size(&self, _cx: TyCtxt) -> usize {
|
||||
match self.sty {
|
||||
TyAdt(def, _) => def.non_enum_variant().fields.len(),
|
||||
Adt(def, _) => def.non_enum_variant().fields.len(),
|
||||
_ => bug!("simd_size called on invalid type")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_region_ptr(&self) -> bool {
|
||||
match self.sty {
|
||||
TyRef(..) => true,
|
||||
Ref(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_mutable_pointer(&self) -> bool {
|
||||
match self.sty {
|
||||
TyRawPtr(TypeAndMut { mutbl: hir::Mutability::MutMutable, .. }) |
|
||||
TyRef(_, _, hir::Mutability::MutMutable) => true,
|
||||
RawPtr(TypeAndMut { mutbl: hir::Mutability::MutMutable, .. }) |
|
||||
Ref(_, _, hir::Mutability::MutMutable) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_unsafe_ptr(&self) -> bool {
|
||||
match self.sty {
|
||||
TyRawPtr(_) => return true,
|
||||
RawPtr(_) => return true,
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_box(&self) -> bool {
|
||||
match self.sty {
|
||||
TyAdt(def, _) => def.is_box(),
|
||||
Adt(def, _) => def.is_box(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -1600,19 +1600,19 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
/// panics if called on any type other than `Box<T>`
|
||||
pub fn boxed_ty(&self) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
TyAdt(def, substs) if def.is_box() => substs.type_at(0),
|
||||
Adt(def, substs) if def.is_box() => substs.type_at(0),
|
||||
_ => bug!("`boxed_ty` is called on non-box type {:?}", self),
|
||||
}
|
||||
}
|
||||
|
||||
/// A scalar type is one that denotes an atomic datum, with no sub-components.
|
||||
/// (A TyRawPtr is scalar because it represents a non-managed pointer, so its
|
||||
/// (A RawPtr is scalar because it represents a non-managed pointer, so its
|
||||
/// contents are abstract to rustc.)
|
||||
pub fn is_scalar(&self) -> bool {
|
||||
match self.sty {
|
||||
TyBool | TyChar | TyInt(_) | TyFloat(_) | TyUint(_) |
|
||||
TyInfer(IntVar(_)) | TyInfer(FloatVar(_)) |
|
||||
TyFnDef(..) | TyFnPtr(_) | TyRawPtr(_) => true,
|
||||
Infer(IntVar(_)) | Infer(FloatVar(_)) |
|
||||
FnDef(..) | FnPtr(_) | RawPtr(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -1621,21 +1621,21 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
pub fn is_floating_point(&self) -> bool {
|
||||
match self.sty {
|
||||
TyFloat(_) |
|
||||
TyInfer(FloatVar(_)) => true,
|
||||
Infer(FloatVar(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_trait(&self) -> bool {
|
||||
match self.sty {
|
||||
TyDynamic(..) => true,
|
||||
Dynamic(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_enum(&self) -> bool {
|
||||
match self.sty {
|
||||
TyAdt(adt_def, _) => {
|
||||
Adt(adt_def, _) => {
|
||||
adt_def.is_enum()
|
||||
}
|
||||
_ => false,
|
||||
|
@ -1644,37 +1644,37 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
|
||||
pub fn is_closure(&self) -> bool {
|
||||
match self.sty {
|
||||
TyClosure(..) => true,
|
||||
Closure(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_generator(&self) -> bool {
|
||||
match self.sty {
|
||||
TyGenerator(..) => true,
|
||||
Generator(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_integral(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(IntVar(_)) | TyInt(_) | TyUint(_) => true,
|
||||
Infer(IntVar(_)) | TyInt(_) | TyUint(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_fresh_ty(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(FreshTy(_)) => true,
|
||||
Infer(FreshTy(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_fresh(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(FreshTy(_)) => true,
|
||||
TyInfer(FreshIntTy(_)) => true,
|
||||
TyInfer(FreshFloatTy(_)) => true,
|
||||
Infer(FreshTy(_)) => true,
|
||||
Infer(FreshIntTy(_)) => true,
|
||||
Infer(FreshFloatTy(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -1688,7 +1688,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
|
||||
pub fn is_fp(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInfer(FloatVar(_)) | TyFloat(_) => true,
|
||||
Infer(FloatVar(_)) | TyFloat(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -1714,7 +1714,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
|
||||
pub fn has_concrete_skeleton(&self) -> bool {
|
||||
match self.sty {
|
||||
TyParam(_) | TyInfer(_) | TyError => false,
|
||||
TyParam(_) | Infer(_) | Error => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
@ -1725,14 +1725,14 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
/// Some types---notably unsafe ptrs---can only be dereferenced explicitly.
|
||||
pub fn builtin_deref(&self, explicit: bool) -> Option<TypeAndMut<'tcx>> {
|
||||
match self.sty {
|
||||
TyAdt(def, _) if def.is_box() => {
|
||||
Adt(def, _) if def.is_box() => {
|
||||
Some(TypeAndMut {
|
||||
ty: self.boxed_ty(),
|
||||
mutbl: hir::MutImmutable,
|
||||
})
|
||||
},
|
||||
TyRef(_, ty, mutbl) => Some(TypeAndMut { ty, mutbl }),
|
||||
TyRawPtr(mt) if explicit => Some(mt),
|
||||
Ref(_, ty, mutbl) => Some(TypeAndMut { ty, mutbl }),
|
||||
RawPtr(mt) if explicit => Some(mt),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -1740,38 +1740,38 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
/// Returns the type of `ty[i]`.
|
||||
pub fn builtin_index(&self) -> Option<Ty<'tcx>> {
|
||||
match self.sty {
|
||||
TyArray(ty, _) | TySlice(ty) => Some(ty),
|
||||
Array(ty, _) | Slice(ty) => Some(ty),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fn_sig(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> PolyFnSig<'tcx> {
|
||||
match self.sty {
|
||||
TyFnDef(def_id, substs) => {
|
||||
FnDef(def_id, substs) => {
|
||||
tcx.fn_sig(def_id).subst(tcx, substs)
|
||||
}
|
||||
TyFnPtr(f) => f,
|
||||
FnPtr(f) => f,
|
||||
_ => bug!("Ty::fn_sig() called on non-fn type: {:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_fn(&self) -> bool {
|
||||
match self.sty {
|
||||
TyFnDef(..) | TyFnPtr(_) => true,
|
||||
FnDef(..) | FnPtr(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_impl_trait(&self) -> bool {
|
||||
match self.sty {
|
||||
TyAnon(..) => true,
|
||||
Anon(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> {
|
||||
match self.sty {
|
||||
TyAdt(adt, _) => Some(adt),
|
||||
Adt(adt, _) => Some(adt),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -1781,44 +1781,44 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
/// ignores late-bound regions binders.
|
||||
pub fn regions(&self) -> Vec<ty::Region<'tcx>> {
|
||||
match self.sty {
|
||||
TyRef(region, _, _) => {
|
||||
Ref(region, _, _) => {
|
||||
vec![region]
|
||||
}
|
||||
TyDynamic(ref obj, region) => {
|
||||
Dynamic(ref obj, region) => {
|
||||
let mut v = vec![region];
|
||||
if let Some(p) = obj.principal() {
|
||||
v.extend(p.skip_binder().substs.regions());
|
||||
}
|
||||
v
|
||||
}
|
||||
TyAdt(_, substs) | TyAnon(_, substs) => {
|
||||
Adt(_, substs) | Anon(_, substs) => {
|
||||
substs.regions().collect()
|
||||
}
|
||||
TyClosure(_, ClosureSubsts { ref substs }) |
|
||||
TyGenerator(_, GeneratorSubsts { ref substs }, _) => {
|
||||
Closure(_, ClosureSubsts { ref substs }) |
|
||||
Generator(_, GeneratorSubsts { ref substs }, _) => {
|
||||
substs.regions().collect()
|
||||
}
|
||||
TyProjection(ref data) => {
|
||||
Projection(ref data) => {
|
||||
data.substs.regions().collect()
|
||||
}
|
||||
TyFnDef(..) |
|
||||
TyFnPtr(_) |
|
||||
TyGeneratorWitness(..) |
|
||||
FnDef(..) |
|
||||
FnPtr(_) |
|
||||
GeneratorWitness(..) |
|
||||
TyBool |
|
||||
TyChar |
|
||||
TyInt(_) |
|
||||
TyUint(_) |
|
||||
TyFloat(_) |
|
||||
TyStr |
|
||||
TyArray(..) |
|
||||
TySlice(_) |
|
||||
TyRawPtr(_) |
|
||||
TyNever |
|
||||
TyTuple(..) |
|
||||
Array(..) |
|
||||
Slice(_) |
|
||||
RawPtr(_) |
|
||||
Never |
|
||||
Tuple(..) |
|
||||
TyForeign(..) |
|
||||
TyParam(_) |
|
||||
TyInfer(_) |
|
||||
TyError => {
|
||||
Infer(_) |
|
||||
Error => {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
@ -1845,9 +1845,9 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
_ => bug!("cannot convert type `{:?}` to a closure kind", self),
|
||||
},
|
||||
|
||||
TyInfer(_) => None,
|
||||
Infer(_) => None,
|
||||
|
||||
TyError => Some(ty::ClosureKind::Fn),
|
||||
Error => Some(ty::ClosureKind::Fn),
|
||||
|
||||
_ => bug!("cannot convert type `{:?}` to a closure kind", self),
|
||||
}
|
||||
|
@ -1859,31 +1859,31 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
/// `false` means nothing -- could be sized, might not be.
|
||||
pub fn is_trivially_sized(&self, tcx: TyCtxt<'_, '_, 'tcx>) -> bool {
|
||||
match self.sty {
|
||||
ty::TyInfer(ty::IntVar(_)) | ty::TyInfer(ty::FloatVar(_)) |
|
||||
ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) |
|
||||
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyRawPtr(..) |
|
||||
ty::TyChar | ty::TyRef(..) | ty::TyGenerator(..) |
|
||||
ty::TyGeneratorWitness(..) | ty::TyArray(..) | ty::TyClosure(..) |
|
||||
ty::TyNever | ty::TyError =>
|
||||
ty::FnDef(..) | ty::FnPtr(_) | ty::RawPtr(..) |
|
||||
ty::TyChar | ty::Ref(..) | ty::Generator(..) |
|
||||
ty::GeneratorWitness(..) | ty::Array(..) | ty::Closure(..) |
|
||||
ty::Never | ty::Error =>
|
||||
true,
|
||||
|
||||
ty::TyStr | ty::TySlice(_) | ty::TyDynamic(..) | ty::TyForeign(..) =>
|
||||
ty::TyStr | ty::Slice(_) | ty::Dynamic(..) | ty::TyForeign(..) =>
|
||||
false,
|
||||
|
||||
ty::TyTuple(tys) =>
|
||||
ty::Tuple(tys) =>
|
||||
tys.iter().all(|ty| ty.is_trivially_sized(tcx)),
|
||||
|
||||
ty::TyAdt(def, _substs) =>
|
||||
ty::Adt(def, _substs) =>
|
||||
def.sized_constraint(tcx).is_empty(),
|
||||
|
||||
ty::TyProjection(_) | ty::TyParam(_) | ty::TyAnon(..) => false,
|
||||
ty::Projection(_) | ty::TyParam(_) | ty::Anon(..) => false,
|
||||
|
||||
ty::TyInfer(ty::TyVar(_)) => false,
|
||||
ty::Infer(ty::TyVar(_)) => false,
|
||||
|
||||
ty::TyInfer(ty::CanonicalTy(_)) |
|
||||
ty::TyInfer(ty::FreshTy(_)) |
|
||||
ty::TyInfer(ty::FreshIntTy(_)) |
|
||||
ty::TyInfer(ty::FreshFloatTy(_)) =>
|
||||
ty::Infer(ty::CanonicalTy(_)) |
|
||||
ty::Infer(ty::FreshTy(_)) |
|
||||
ty::Infer(ty::FreshIntTy(_)) |
|
||||
ty::Infer(ty::FreshFloatTy(_)) =>
|
||||
bug!("is_trivially_sized applied to unexpected type: {:?}", self),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,10 +194,10 @@ impl<'tcx> ty::ParamEnv<'tcx> {
|
|||
// These types used to have a builtin impl.
|
||||
// Now libcore provides that impl.
|
||||
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
|
||||
ty::TyChar | ty::TyRawPtr(..) | ty::TyNever |
|
||||
ty::TyRef(_, _, hir::MutImmutable) => return Ok(()),
|
||||
ty::TyChar | ty::RawPtr(..) | ty::Never |
|
||||
ty::Ref(_, _, hir::MutImmutable) => return Ok(()),
|
||||
|
||||
ty::TyAdt(adt, substs) => (adt, substs),
|
||||
ty::Adt(adt, substs) => (adt, substs),
|
||||
|
||||
_ => return Err(CopyImplementationError::NotAnAdt),
|
||||
};
|
||||
|
@ -258,10 +258,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
|||
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
pub fn has_error_field(self, ty: Ty<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyAdt(def, substs) => {
|
||||
ty::Adt(def, substs) => {
|
||||
for field in def.all_fields() {
|
||||
let field_ty = field.ty(self, substs);
|
||||
if let TyError = field_ty.sty {
|
||||
if let Error = field_ty.sty {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
pub fn struct_tail(self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
loop {
|
||||
match ty.sty {
|
||||
ty::TyAdt(def, substs) => {
|
||||
ty::Adt(def, substs) => {
|
||||
if !def.is_struct() {
|
||||
break;
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyTuple(tys) => {
|
||||
ty::Tuple(tys) => {
|
||||
if let Some((&last_ty, _)) = tys.split_last() {
|
||||
ty = last_ty;
|
||||
} else {
|
||||
|
@ -315,7 +315,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
let (mut a, mut b) = (source, target);
|
||||
loop {
|
||||
match (&a.sty, &b.sty) {
|
||||
(&TyAdt(a_def, a_substs), &TyAdt(b_def, b_substs))
|
||||
(&Adt(a_def, a_substs), &Adt(b_def, b_substs))
|
||||
if a_def == b_def && a_def.is_struct() => {
|
||||
if let Some(f) = a_def.non_enum_variant().fields.last() {
|
||||
a = f.ty(self, a_substs);
|
||||
|
@ -324,7 +324,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
break;
|
||||
}
|
||||
},
|
||||
(&TyTuple(a_tys), &TyTuple(b_tys))
|
||||
(&Tuple(a_tys), &Tuple(b_tys))
|
||||
if a_tys.len() == b_tys.len() => {
|
||||
if let Some(a_last) = a_tys.last() {
|
||||
a = a_last;
|
||||
|
@ -487,12 +487,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
// parameters marked as pure.
|
||||
|
||||
let impl_substs = match self.type_of(impl_def_id).sty {
|
||||
ty::TyAdt(def_, substs) if def_ == def => substs,
|
||||
ty::Adt(def_, substs) if def_ == def => substs,
|
||||
_ => bug!()
|
||||
};
|
||||
|
||||
let item_substs = match self.type_of(def.did).sty {
|
||||
ty::TyAdt(def_, substs) if def_ == def => substs,
|
||||
ty::Adt(def_, substs) if def_ == def => substs,
|
||||
_ => bug!()
|
||||
};
|
||||
|
||||
|
@ -697,7 +697,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
-> Representability
|
||||
{
|
||||
match ty.sty {
|
||||
TyTuple(ref ts) => {
|
||||
Tuple(ref ts) => {
|
||||
// Find non representable
|
||||
fold_repr(ts.iter().map(|ty| {
|
||||
is_type_structurally_recursive(tcx, sp, seen, representable_cache, ty)
|
||||
|
@ -705,10 +705,10 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
}
|
||||
// Fixed-length vectors.
|
||||
// FIXME(#11924) Behavior undecided for zero-length vectors.
|
||||
TyArray(ty, _) => {
|
||||
Array(ty, _) => {
|
||||
is_type_structurally_recursive(tcx, sp, seen, representable_cache, ty)
|
||||
}
|
||||
TyAdt(def, substs) => {
|
||||
Adt(def, substs) => {
|
||||
// Find non representable fields with their spans
|
||||
fold_repr(def.all_fields().map(|field| {
|
||||
let ty = field.ty(tcx, substs);
|
||||
|
@ -723,7 +723,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
}
|
||||
}))
|
||||
}
|
||||
TyClosure(..) => {
|
||||
Closure(..) => {
|
||||
// this check is run on type definitions, so we don't expect
|
||||
// to see closure types
|
||||
bug!("requires check invoked on inapplicable type: {:?}", ty)
|
||||
|
@ -734,7 +734,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
|
||||
fn same_struct_or_enum<'tcx>(ty: Ty<'tcx>, def: &'tcx ty::AdtDef) -> bool {
|
||||
match ty.sty {
|
||||
TyAdt(ty_def, _) => {
|
||||
Adt(ty_def, _) => {
|
||||
ty_def == def
|
||||
}
|
||||
_ => false
|
||||
|
@ -743,7 +743,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
|
||||
fn same_type<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
|
||||
match (&a.sty, &b.sty) {
|
||||
(&TyAdt(did_a, substs_a), &TyAdt(did_b, substs_b)) => {
|
||||
(&Adt(did_a, substs_a), &Adt(did_b, substs_b)) => {
|
||||
if did_a != did_b {
|
||||
return false;
|
||||
}
|
||||
|
@ -785,7 +785,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> {
|
|||
ty: Ty<'tcx>) -> Representability
|
||||
{
|
||||
match ty.sty {
|
||||
TyAdt(def, _) => {
|
||||
Adt(def, _) => {
|
||||
{
|
||||
// Iterate through stack of previously seen types.
|
||||
let mut iter = seen.iter();
|
||||
|
@ -924,16 +924,16 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
match ty.sty {
|
||||
// Fast-path for primitive types
|
||||
ty::TyInfer(ty::FreshIntTy(_)) | ty::TyInfer(ty::FreshFloatTy(_)) |
|
||||
ty::TyBool | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::TyNever |
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyChar | ty::TyGeneratorWitness(..) |
|
||||
ty::TyRawPtr(_) | ty::TyRef(..) | ty::TyStr => false,
|
||||
ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshFloatTy(_)) |
|
||||
ty::TyBool | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::Never |
|
||||
ty::FnDef(..) | ty::FnPtr(_) | ty::TyChar | ty::GeneratorWitness(..) |
|
||||
ty::RawPtr(_) | ty::Ref(..) | ty::TyStr => false,
|
||||
|
||||
// Foreign types can never have destructors
|
||||
ty::TyForeign(..) => false,
|
||||
|
||||
// `ManuallyDrop` doesn't have a destructor regardless of field types.
|
||||
ty::TyAdt(def, _) if Some(def.did) == tcx.lang_items().manually_drop() => false,
|
||||
ty::Adt(def, _) if Some(def.did) == tcx.lang_items().manually_drop() => false,
|
||||
|
||||
// Issue #22536: We first query type_moves_by_default. It sees a
|
||||
// normalized version of the type, and therefore will definitely
|
||||
|
@ -951,30 +951,30 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// (see above), it is sound to treat it as having a destructor.
|
||||
|
||||
// User destructors are the only way to have concrete drop types.
|
||||
ty::TyAdt(def, _) if def.has_dtor(tcx) => true,
|
||||
ty::Adt(def, _) if def.has_dtor(tcx) => true,
|
||||
|
||||
// Can refer to a type which may drop.
|
||||
// FIXME(eddyb) check this against a ParamEnv.
|
||||
ty::TyDynamic(..) | ty::TyProjection(..) | ty::TyParam(_) |
|
||||
ty::TyAnon(..) | ty::TyInfer(_) | ty::TyError => true,
|
||||
ty::Dynamic(..) | ty::Projection(..) | ty::TyParam(_) |
|
||||
ty::Anon(..) | ty::Infer(_) | ty::Error => true,
|
||||
|
||||
// Structural recursion.
|
||||
ty::TyArray(ty, _) | ty::TySlice(ty) => needs_drop(ty),
|
||||
ty::Array(ty, _) | ty::Slice(ty) => needs_drop(ty),
|
||||
|
||||
ty::TyClosure(def_id, ref substs) => substs.upvar_tys(def_id, tcx).any(needs_drop),
|
||||
ty::Closure(def_id, ref substs) => substs.upvar_tys(def_id, tcx).any(needs_drop),
|
||||
|
||||
// Pessimistically assume that all generators will require destructors
|
||||
// as we don't know if a destructor is a noop or not until after the MIR
|
||||
// state transformation pass
|
||||
ty::TyGenerator(..) => true,
|
||||
ty::Generator(..) => true,
|
||||
|
||||
ty::TyTuple(ref tys) => tys.iter().cloned().any(needs_drop),
|
||||
ty::Tuple(ref tys) => tys.iter().cloned().any(needs_drop),
|
||||
|
||||
// unions don't have destructors because of the child types,
|
||||
// only if they manually implement `Drop` (handled above).
|
||||
ty::TyAdt(def, _) if def.is_union() => false,
|
||||
ty::Adt(def, _) if def.is_union() => false,
|
||||
|
||||
ty::TyAdt(def, substs) =>
|
||||
ty::Adt(def, substs) =>
|
||||
def.variants.iter().any(
|
||||
|variant| variant.fields.iter().any(
|
||||
|field| needs_drop(field.ty(tcx, substs)))),
|
||||
|
@ -1025,13 +1025,13 @@ impl<'tcx> ExplicitSelf<'tcx> {
|
|||
|
||||
match self_arg_ty.sty {
|
||||
_ if is_self_ty(self_arg_ty) => ByValue,
|
||||
ty::TyRef(region, ty, mutbl) if is_self_ty(ty) => {
|
||||
ty::Ref(region, ty, mutbl) if is_self_ty(ty) => {
|
||||
ByReference(region, mutbl)
|
||||
}
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty, mutbl }) if is_self_ty(ty) => {
|
||||
ty::RawPtr(ty::TypeAndMut { ty, mutbl }) if is_self_ty(ty) => {
|
||||
ByRawPointer(mutbl)
|
||||
}
|
||||
ty::TyAdt(def, _) if def.is_box() && is_self_ty(self_arg_ty.boxed_ty()) => {
|
||||
ty::Adt(def, _) if def.is_box() && is_self_ty(self_arg_ty.boxed_ty()) => {
|
||||
ByBox
|
||||
}
|
||||
_ => Other
|
||||
|
|
|
@ -82,26 +82,26 @@ pub fn walk_shallow<'tcx>(ty: Ty<'tcx>) -> AccIntoIter<TypeWalkerArray<'tcx>> {
|
|||
fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
|
||||
match parent_ty.sty {
|
||||
ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) |
|
||||
ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyNever | ty::TyError |
|
||||
ty::TyStr | ty::Infer(_) | ty::TyParam(_) | ty::Never | ty::Error |
|
||||
ty::TyForeign(..) => {
|
||||
}
|
||||
ty::TyArray(ty, len) => {
|
||||
ty::Array(ty, len) => {
|
||||
push_const(stack, len);
|
||||
stack.push(ty);
|
||||
}
|
||||
ty::TySlice(ty) => {
|
||||
ty::Slice(ty) => {
|
||||
stack.push(ty);
|
||||
}
|
||||
ty::TyRawPtr(ref mt) => {
|
||||
ty::RawPtr(ref mt) => {
|
||||
stack.push(mt.ty);
|
||||
}
|
||||
ty::TyRef(_, ty, _) => {
|
||||
ty::Ref(_, ty, _) => {
|
||||
stack.push(ty);
|
||||
}
|
||||
ty::TyProjection(ref data) => {
|
||||
ty::Projection(ref data) => {
|
||||
stack.extend(data.substs.types().rev());
|
||||
}
|
||||
ty::TyDynamic(ref obj, ..) => {
|
||||
ty::Dynamic(ref obj, ..) => {
|
||||
stack.extend(obj.iter().rev().flat_map(|predicate| {
|
||||
let (substs, opt_ty) = match *predicate.skip_binder() {
|
||||
ty::ExistentialPredicate::Trait(tr) => (tr.substs, None),
|
||||
|
@ -115,25 +115,25 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
|
|||
substs.types().rev().chain(opt_ty)
|
||||
}));
|
||||
}
|
||||
ty::TyAdt(_, substs) | ty::TyAnon(_, substs) => {
|
||||
ty::Adt(_, substs) | ty::Anon(_, substs) => {
|
||||
stack.extend(substs.types().rev());
|
||||
}
|
||||
ty::TyClosure(_, ref substs) => {
|
||||
ty::Closure(_, ref substs) => {
|
||||
stack.extend(substs.substs.types().rev());
|
||||
}
|
||||
ty::TyGenerator(_, ref substs, _) => {
|
||||
ty::Generator(_, ref substs, _) => {
|
||||
stack.extend(substs.substs.types().rev());
|
||||
}
|
||||
ty::TyGeneratorWitness(ts) => {
|
||||
ty::GeneratorWitness(ts) => {
|
||||
stack.extend(ts.skip_binder().iter().cloned().rev());
|
||||
}
|
||||
ty::TyTuple(ts) => {
|
||||
ty::Tuple(ts) => {
|
||||
stack.extend(ts.iter().cloned().rev());
|
||||
}
|
||||
ty::TyFnDef(_, substs) => {
|
||||
ty::FnDef(_, substs) => {
|
||||
stack.extend(substs.types().rev());
|
||||
}
|
||||
ty::TyFnPtr(sig) => {
|
||||
ty::FnPtr(sig) => {
|
||||
stack.push(sig.skip_binder().output());
|
||||
stack.extend(sig.skip_binder().inputs().iter().cloned().rev());
|
||||
}
|
||||
|
|
|
@ -253,26 +253,26 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
|||
ty::TyInt(..) |
|
||||
ty::TyUint(..) |
|
||||
ty::TyFloat(..) |
|
||||
ty::TyError |
|
||||
ty::Error |
|
||||
ty::TyStr |
|
||||
ty::TyGeneratorWitness(..) |
|
||||
ty::TyNever |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Never |
|
||||
ty::TyParam(_) |
|
||||
ty::TyForeign(..) => {
|
||||
// WfScalar, WfParameter, etc
|
||||
}
|
||||
|
||||
ty::TySlice(subty) => {
|
||||
ty::Slice(subty) => {
|
||||
self.require_sized(subty, traits::SliceOrArrayElem);
|
||||
}
|
||||
|
||||
ty::TyArray(subty, len) => {
|
||||
ty::Array(subty, len) => {
|
||||
self.require_sized(subty, traits::SliceOrArrayElem);
|
||||
assert_eq!(len.ty, self.infcx.tcx.types.usize);
|
||||
self.compute_const(len);
|
||||
}
|
||||
|
||||
ty::TyTuple(ref tys) => {
|
||||
ty::Tuple(ref tys) => {
|
||||
if let Some((_last, rest)) = tys.split_last() {
|
||||
for elem in rest {
|
||||
self.require_sized(elem, traits::TupleElem);
|
||||
|
@ -280,22 +280,22 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyRawPtr(_) => {
|
||||
ty::RawPtr(_) => {
|
||||
// simple cases that are WF if their type args are WF
|
||||
}
|
||||
|
||||
ty::TyProjection(data) => {
|
||||
ty::Projection(data) => {
|
||||
subtys.skip_current_subtree(); // subtree handled by compute_projection
|
||||
self.compute_projection(data);
|
||||
}
|
||||
|
||||
ty::TyAdt(def, substs) => {
|
||||
ty::Adt(def, substs) => {
|
||||
// WfNominalType
|
||||
let obligations = self.nominal_obligations(def.did, substs);
|
||||
self.out.extend(obligations);
|
||||
}
|
||||
|
||||
ty::TyRef(r, rty, _) => {
|
||||
ty::Ref(r, rty, _) => {
|
||||
// WfReference
|
||||
if !r.has_escaping_regions() && !rty.has_escaping_regions() {
|
||||
let cause = self.cause(traits::ReferenceOutlivesReferent(ty));
|
||||
|
@ -309,7 +309,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyGenerator(..) => {
|
||||
ty::Generator(..) => {
|
||||
// Walk ALL the types in the generator: this will
|
||||
// include the upvar types as well as the yield
|
||||
// type. Note that this is mildly distinct from
|
||||
|
@ -319,7 +319,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
|||
// generators don't take arguments.
|
||||
}
|
||||
|
||||
ty::TyClosure(def_id, substs) => {
|
||||
ty::Closure(def_id, substs) => {
|
||||
// Only check the upvar types for WF, not the rest
|
||||
// of the types within. This is needed because we
|
||||
// capture the signature and it may not be WF
|
||||
|
@ -355,12 +355,12 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
// let the loop iterate into the argument/return
|
||||
// types appearing in the fn signature
|
||||
}
|
||||
|
||||
ty::TyAnon(did, substs) => {
|
||||
ty::Anon(did, substs) => {
|
||||
// all of the requirements on type parameters
|
||||
// should've been checked by the instantiation
|
||||
// of whatever returned this exact `impl Trait`.
|
||||
|
@ -372,7 +372,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyDynamic(data, r) => {
|
||||
ty::Dynamic(data, r) => {
|
||||
// WfObject
|
||||
//
|
||||
// Here, we defer WF checking due to higher-ranked
|
||||
|
@ -408,9 +408,9 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
|||
// register a pending obligation and keep
|
||||
// moving. (Goal is that an "inductive hypothesis"
|
||||
// is satisfied to ensure termination.)
|
||||
ty::TyInfer(_) => {
|
||||
ty::Infer(_) => {
|
||||
let ty = self.infcx.shallow_resolve(ty);
|
||||
if let ty::TyInfer(_) = ty.sty { // not yet resolved...
|
||||
if let ty::Infer(_) = ty.sty { // not yet resolved...
|
||||
if ty == ty0 { // ...this is the type we started from! no progress.
|
||||
return false;
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
|||
} else {
|
||||
// Yes, resolved, proceed with the
|
||||
// result. Should never return false because
|
||||
// `ty` is not a TyInfer.
|
||||
// `ty` is not a Infer.
|
||||
assert!(self.compute(ty));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ use mir::interpret::ConstValue;
|
|||
use middle::region::{self, BlockRemainder};
|
||||
use ty::subst::{self, Subst};
|
||||
use ty::{BrAnon, BrEnv, BrFresh, BrNamed};
|
||||
use ty::{TyBool, TyChar, TyAdt};
|
||||
use ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyFnDef, TyFnPtr};
|
||||
use ty::{TyParam, TyRawPtr, TyRef, TyNever, TyTuple};
|
||||
use ty::{TyClosure, TyGenerator, TyGeneratorWitness, TyForeign, TyProjection, TyAnon};
|
||||
use ty::{TyDynamic, TyInt, TyUint, TyInfer};
|
||||
use ty::{TyBool, TyChar, Adt};
|
||||
use ty::{Error, TyStr, Array, Slice, TyFloat, FnDef, FnPtr};
|
||||
use ty::{TyParam, RawPtr, Ref, Never, Tuple};
|
||||
use ty::{Closure, Generator, GeneratorWitness, TyForeign, Projection, Anon};
|
||||
use ty::{Dynamic, TyInt, TyUint, Infer};
|
||||
use ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind};
|
||||
use util::nodemap::FxHashSet;
|
||||
|
||||
|
@ -371,7 +371,7 @@ impl PrintContext {
|
|||
|
||||
if !verbose && fn_trait_kind.is_some() && projections.len() == 1 {
|
||||
let projection_ty = projections[0].ty;
|
||||
if let TyTuple(ref args) = substs.type_at(1).sty {
|
||||
if let Tuple(ref args) = substs.type_at(1).sty {
|
||||
return self.fn_sig(f, args, false, projection_ty);
|
||||
}
|
||||
}
|
||||
|
@ -1037,14 +1037,14 @@ define_print! {
|
|||
TyInt(t) => write!(f, "{}", t.ty_to_string()),
|
||||
TyUint(t) => write!(f, "{}", t.ty_to_string()),
|
||||
TyFloat(t) => write!(f, "{}", t.ty_to_string()),
|
||||
TyRawPtr(ref tm) => {
|
||||
RawPtr(ref tm) => {
|
||||
write!(f, "*{} ", match tm.mutbl {
|
||||
hir::MutMutable => "mut",
|
||||
hir::MutImmutable => "const",
|
||||
})?;
|
||||
tm.ty.print(f, cx)
|
||||
}
|
||||
TyRef(r, ty, mutbl) => {
|
||||
Ref(r, ty, mutbl) => {
|
||||
write!(f, "&")?;
|
||||
let s = r.print_to_string(cx);
|
||||
if s != "'_" {
|
||||
|
@ -1055,8 +1055,8 @@ define_print! {
|
|||
}
|
||||
ty::TypeAndMut { ty, mutbl }.print(f, cx)
|
||||
}
|
||||
TyNever => write!(f, "!"),
|
||||
TyTuple(ref tys) => {
|
||||
Never => write!(f, "!"),
|
||||
Tuple(ref tys) => {
|
||||
write!(f, "(")?;
|
||||
let mut tys = tys.iter();
|
||||
if let Some(&ty) = tys.next() {
|
||||
|
@ -1070,7 +1070,7 @@ define_print! {
|
|||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
TyFnDef(def_id, substs) => {
|
||||
FnDef(def_id, substs) => {
|
||||
ty::tls::with(|tcx| {
|
||||
let mut sig = tcx.fn_sig(def_id);
|
||||
if let Some(substs) = tcx.lift(&substs) {
|
||||
|
@ -1081,14 +1081,14 @@ define_print! {
|
|||
cx.parameterized(f, substs, def_id, &[])?;
|
||||
write!(f, "}}")
|
||||
}
|
||||
TyFnPtr(ref bare_fn) => {
|
||||
FnPtr(ref bare_fn) => {
|
||||
bare_fn.print(f, cx)
|
||||
}
|
||||
TyInfer(infer_ty) => write!(f, "{}", infer_ty),
|
||||
TyError => write!(f, "[type error]"),
|
||||
Infer(infer_ty) => write!(f, "{}", infer_ty),
|
||||
Error => write!(f, "[type error]"),
|
||||
TyParam(ref param_ty) => write!(f, "{}", param_ty),
|
||||
TyAdt(def, substs) => cx.parameterized(f, substs, def.did, &[]),
|
||||
TyDynamic(data, r) => {
|
||||
Adt(def, substs) => cx.parameterized(f, substs, def.did, &[]),
|
||||
Dynamic(data, r) => {
|
||||
let r = r.print_to_string(cx);
|
||||
if !r.is_empty() {
|
||||
write!(f, "(")?;
|
||||
|
@ -1102,10 +1102,10 @@ define_print! {
|
|||
}
|
||||
}
|
||||
TyForeign(def_id) => parameterized(f, subst::Substs::empty(), def_id, &[]),
|
||||
TyProjection(ref data) => data.print(f, cx),
|
||||
TyAnon(def_id, substs) => {
|
||||
Projection(ref data) => data.print(f, cx),
|
||||
Anon(def_id, substs) => {
|
||||
if cx.is_verbose {
|
||||
return write!(f, "TyAnon({:?}, {:?})", def_id, substs);
|
||||
return write!(f, "Anon({:?}, {:?})", def_id, substs);
|
||||
}
|
||||
|
||||
ty::tls::with(|tcx| {
|
||||
|
@ -1155,7 +1155,7 @@ define_print! {
|
|||
})
|
||||
}
|
||||
TyStr => write!(f, "str"),
|
||||
TyGenerator(did, substs, movability) => ty::tls::with(|tcx| {
|
||||
Generator(did, substs, movability) => ty::tls::with(|tcx| {
|
||||
let upvar_tys = substs.upvar_tys(did, tcx);
|
||||
let witness = substs.witness(did, tcx);
|
||||
if movability == hir::GeneratorMovability::Movable {
|
||||
|
@ -1193,10 +1193,10 @@ define_print! {
|
|||
|
||||
print!(f, cx, write(" "), print(witness), write("]"))
|
||||
}),
|
||||
TyGeneratorWitness(types) => {
|
||||
GeneratorWitness(types) => {
|
||||
ty::tls::with(|tcx| cx.in_binder(f, tcx, &types, tcx.lift(&types)))
|
||||
}
|
||||
TyClosure(did, substs) => ty::tls::with(|tcx| {
|
||||
Closure(did, substs) => ty::tls::with(|tcx| {
|
||||
let upvar_tys = substs.upvar_tys(did, tcx);
|
||||
write!(f, "[closure")?;
|
||||
|
||||
|
@ -1233,7 +1233,7 @@ define_print! {
|
|||
|
||||
write!(f, "]")
|
||||
}),
|
||||
TyArray(ty, sz) => {
|
||||
Array(ty, sz) => {
|
||||
print!(f, cx, write("["), print(ty), write("; "))?;
|
||||
match sz.val {
|
||||
ConstValue::Unevaluated(_def_id, _substs) => {
|
||||
|
@ -1245,7 +1245,7 @@ define_print! {
|
|||
}
|
||||
write!(f, "]")
|
||||
}
|
||||
TySlice(ty) => {
|
||||
Slice(ty) => {
|
||||
print!(f, cx, write("["), print(ty), write("]"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -843,7 +843,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
}
|
||||
LpExtend(ref lp_base, _, LpInterior(_, InteriorField(_))) => {
|
||||
match lp_base.to_type().sty {
|
||||
ty::TyAdt(def, _) if def.has_dtor(self.tcx()) => {
|
||||
ty::Adt(def, _) if def.has_dtor(self.tcx()) => {
|
||||
// In the case where the owner implements drop, then
|
||||
// the path must be initialized to prevent a case of
|
||||
// partial reinitialization
|
||||
|
|
|
@ -191,14 +191,14 @@ fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
|||
Categorization::Interior(ref b, mc::InteriorField(_)) |
|
||||
Categorization::Interior(ref b, mc::InteriorElement(Kind::Pattern)) => {
|
||||
match b.ty.sty {
|
||||
ty::TyAdt(def, _) => {
|
||||
ty::Adt(def, _) => {
|
||||
if def.has_dtor(bccx.tcx) {
|
||||
Some(cmt.clone())
|
||||
} else {
|
||||
check_and_get_illegal_move_origin(bccx, b)
|
||||
}
|
||||
}
|
||||
ty::TySlice(..) => Some(cmt.clone()),
|
||||
ty::Slice(..) => Some(cmt.clone()),
|
||||
_ => {
|
||||
check_and_get_illegal_move_origin(bccx, b)
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &'a BorrowckCtxt<'a, 'tcx>,
|
|||
Categorization::Downcast(ref b, _) |
|
||||
Categorization::Interior(ref b, mc::InteriorField(_)) => {
|
||||
match b.ty.sty {
|
||||
ty::TyAdt(def, _) if def.has_dtor(bccx.tcx) => {
|
||||
ty::Adt(def, _) if def.has_dtor(bccx.tcx) => {
|
||||
bccx.cannot_move_out_of_interior_of_drop(
|
||||
move_from.span, b.ty, Origin::Ast)
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
|
|||
let result = self.restrict(&cmt_base);
|
||||
// Borrowing one union field automatically borrows all its fields.
|
||||
match base_ty.sty {
|
||||
ty::TyAdt(adt_def, _) if adt_def.is_union() => match result {
|
||||
ty::Adt(adt_def, _) if adt_def.is_union() => match result {
|
||||
RestrictionResult::Safe => RestrictionResult::Safe,
|
||||
RestrictionResult::SafeIf(base_lp, mut base_vec) => {
|
||||
for (i, field) in adt_def.non_enum_variant().fields.iter().enumerate() {
|
||||
|
|
|
@ -697,7 +697,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
Some(nl.to_string()),
|
||||
Origin::Ast);
|
||||
let need_note = match lp.ty.sty {
|
||||
ty::TyKind::TyClosure(id, _) => {
|
||||
ty::TyKind::Closure(id, _) => {
|
||||
let node_id = self.tcx.hir.as_local_node_id(id).unwrap();
|
||||
let hir_id = self.tcx.hir.node_to_hir_id(node_id);
|
||||
if let Some((span, name)) = self.tables.closure_kind_origins().get(hir_id) {
|
||||
|
|
|
@ -329,7 +329,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
|
|||
// all parent union fields, moves do not propagate upwards automatically.
|
||||
let mut lp = orig_lp.clone();
|
||||
while let LpExtend(ref base_lp, mutbl, lp_elem) = lp.clone().kind {
|
||||
if let (&ty::TyAdt(adt_def, _), LpInterior(opt_variant_id, interior))
|
||||
if let (&ty::Adt(adt_def, _), LpInterior(opt_variant_id, interior))
|
||||
= (&base_lp.ty.sty, lp_elem) {
|
||||
if adt_def.is_union() {
|
||||
for (i, field) in adt_def.non_enum_variant().fields.iter().enumerate() {
|
||||
|
@ -381,7 +381,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
|
|||
span: Span) {
|
||||
// Assigning to one union field automatically assigns to all its fields.
|
||||
if let LpExtend(ref base_lp, mutbl, LpInterior(opt_variant_id, interior)) = lp.kind {
|
||||
if let ty::TyAdt(adt_def, _) = base_lp.ty.sty {
|
||||
if let ty::Adt(adt_def, _) = base_lp.ty.sty {
|
||||
if adt_def.is_union() {
|
||||
for (i, field) in adt_def.non_enum_variant().fields.iter().enumerate() {
|
||||
let field =
|
||||
|
|
|
@ -364,7 +364,7 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
|
|||
assert!(!sig.variadic && extra_args.is_empty());
|
||||
|
||||
match sig.inputs().last().unwrap().sty {
|
||||
ty::TyTuple(ref tupled_arguments) => {
|
||||
ty::Tuple(ref tupled_arguments) => {
|
||||
inputs = &sig.inputs()[0..sig.inputs().len() - 1];
|
||||
tupled_arguments
|
||||
}
|
||||
|
|
|
@ -197,16 +197,16 @@ pub fn unsized_info(
|
|||
) -> &'ll Value {
|
||||
let (source, target) = cx.tcx.struct_lockstep_tails(source, target);
|
||||
match (&source.sty, &target.sty) {
|
||||
(&ty::TyArray(_, len), &ty::TySlice(_)) => {
|
||||
(&ty::Array(_, len), &ty::Slice(_)) => {
|
||||
C_usize(cx, len.unwrap_usize(cx.tcx))
|
||||
}
|
||||
(&ty::TyDynamic(..), &ty::TyDynamic(..)) => {
|
||||
(&ty::Dynamic(..), &ty::Dynamic(..)) => {
|
||||
// For now, upcasts are limited to changes in marker
|
||||
// traits, and hence never actually require an actual
|
||||
// change to the vtable.
|
||||
old_info.expect("unsized_info: missing old info for trait upcast")
|
||||
}
|
||||
(_, &ty::TyDynamic(ref data, ..)) => {
|
||||
(_, &ty::Dynamic(ref data, ..)) => {
|
||||
let vtable_ptr = cx.layout_of(cx.tcx.mk_mut_ptr(target))
|
||||
.field(cx, abi::FAT_PTR_EXTRA);
|
||||
consts::ptrcast(meth::get_vtable(cx, source, data.principal()),
|
||||
|
@ -227,23 +227,23 @@ pub fn unsize_thin_ptr(
|
|||
) -> (&'ll Value, &'ll Value) {
|
||||
debug!("unsize_thin_ptr: {:?} => {:?}", src_ty, dst_ty);
|
||||
match (&src_ty.sty, &dst_ty.sty) {
|
||||
(&ty::TyRef(_, a, _),
|
||||
&ty::TyRef(_, b, _)) |
|
||||
(&ty::TyRef(_, a, _),
|
||||
&ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) |
|
||||
(&ty::TyRawPtr(ty::TypeAndMut { ty: a, .. }),
|
||||
&ty::TyRawPtr(ty::TypeAndMut { ty: b, .. })) => {
|
||||
(&ty::Ref(_, a, _),
|
||||
&ty::Ref(_, b, _)) |
|
||||
(&ty::Ref(_, a, _),
|
||||
&ty::RawPtr(ty::TypeAndMut { ty: b, .. })) |
|
||||
(&ty::RawPtr(ty::TypeAndMut { ty: a, .. }),
|
||||
&ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => {
|
||||
assert!(bx.cx.type_is_sized(a));
|
||||
let ptr_ty = bx.cx.layout_of(b).llvm_type(bx.cx).ptr_to();
|
||||
(bx.pointercast(src, ptr_ty), unsized_info(bx.cx, a, b, None))
|
||||
}
|
||||
(&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
|
||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
|
||||
let (a, b) = (src_ty.boxed_ty(), dst_ty.boxed_ty());
|
||||
assert!(bx.cx.type_is_sized(a));
|
||||
let ptr_ty = bx.cx.layout_of(b).llvm_type(bx.cx).ptr_to();
|
||||
(bx.pointercast(src, ptr_ty), unsized_info(bx.cx, a, b, None))
|
||||
}
|
||||
(&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) => {
|
||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
|
||||
assert_eq!(def_a, def_b);
|
||||
|
||||
let src_layout = bx.cx.layout_of(src_ty);
|
||||
|
@ -299,16 +299,16 @@ pub fn coerce_unsized_into(
|
|||
OperandValue::Pair(base, info).store(bx, dst);
|
||||
};
|
||||
match (&src_ty.sty, &dst_ty.sty) {
|
||||
(&ty::TyRef(..), &ty::TyRef(..)) |
|
||||
(&ty::TyRef(..), &ty::TyRawPtr(..)) |
|
||||
(&ty::TyRawPtr(..), &ty::TyRawPtr(..)) => {
|
||||
(&ty::Ref(..), &ty::Ref(..)) |
|
||||
(&ty::Ref(..), &ty::RawPtr(..)) |
|
||||
(&ty::RawPtr(..), &ty::RawPtr(..)) => {
|
||||
coerce_ptr()
|
||||
}
|
||||
(&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
|
||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
|
||||
coerce_ptr()
|
||||
}
|
||||
|
||||
(&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) => {
|
||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
|
||||
assert_eq!(def_a, def_b);
|
||||
|
||||
for i in 0..def_a.variants[0].fields.len() {
|
||||
|
|
|
@ -413,10 +413,10 @@ pub fn ty_fn_sig<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
-> ty::PolyFnSig<'tcx>
|
||||
{
|
||||
match ty.sty {
|
||||
ty::TyFnDef(..) |
|
||||
// Shims currently have type TyFnPtr. Not sure this should remain.
|
||||
ty::TyFnPtr(_) => ty.fn_sig(cx.tcx),
|
||||
ty::TyClosure(def_id, substs) => {
|
||||
ty::FnDef(..) |
|
||||
// Shims currently have type FnPtr. Not sure this should remain.
|
||||
ty::FnPtr(_) => ty.fn_sig(cx.tcx),
|
||||
ty::Closure(def_id, substs) => {
|
||||
let tcx = cx.tcx;
|
||||
let sig = substs.closure_sig(def_id, tcx);
|
||||
|
||||
|
@ -429,7 +429,7 @@ pub fn ty_fn_sig<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
sig.abi
|
||||
))
|
||||
}
|
||||
ty::TyGenerator(def_id, substs, _) => {
|
||||
ty::Generator(def_id, substs, _) => {
|
||||
let tcx = cx.tcx;
|
||||
let sig = substs.poly_sig(def_id, cx.tcx);
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ fn check_and_apply_linkage(
|
|||
// static and call it a day. Some linkages (like weak) will make it such
|
||||
// that the static actually has a null value.
|
||||
let llty2 = match ty.sty {
|
||||
ty::TyRawPtr(ref mt) => cx.layout_of(mt.ty).llvm_type(cx),
|
||||
ty::RawPtr(ref mt) => cx.layout_of(mt.ty).llvm_type(cx),
|
||||
_ => {
|
||||
if span.is_some() {
|
||||
cx.sess().span_fatal(span.unwrap(), "must have type `*const T` or `*mut T`")
|
||||
|
|
|
@ -435,7 +435,7 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
|
|||
let tail = self.tcx.struct_tail(ty);
|
||||
match tail.sty {
|
||||
ty::TyForeign(..) => false,
|
||||
ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true,
|
||||
ty::TyStr | ty::Slice(..) | ty::Dynamic(..) => true,
|
||||
_ => bug!("unexpected unsized tail: {:?}", tail.sty),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ fn fixed_vec_metadata(
|
|||
let (size, align) = cx.size_and_align_of(array_or_slice_type);
|
||||
|
||||
let upper_bound = match array_or_slice_type.sty {
|
||||
ty::TyArray(_, len) => {
|
||||
ty::Array(_, len) => {
|
||||
len.unwrap_usize(cx.tcx) as c_longlong
|
||||
}
|
||||
_ => -1
|
||||
|
@ -396,7 +396,7 @@ fn subroutine_type_metadata(
|
|||
let signature_metadata: Vec<_> = iter::once(
|
||||
// return type
|
||||
match signature.output().sty {
|
||||
ty::TyTuple(ref tys) if tys.is_empty() => None,
|
||||
ty::Tuple(ref tys) if tys.is_empty() => None,
|
||||
_ => Some(type_metadata(cx, signature.output(), span))
|
||||
}
|
||||
).chain(
|
||||
|
@ -435,7 +435,7 @@ fn trait_pointer_metadata(
|
|||
// But it does not describe the trait's methods.
|
||||
|
||||
let containing_scope = match trait_type.sty {
|
||||
ty::TyDynamic(ref data, ..) => if let Some(principal) = data.principal() {
|
||||
ty::Dynamic(ref data, ..) => if let Some(principal) = data.principal() {
|
||||
let def_id = principal.def_id();
|
||||
Some(get_namespace_for_item(cx, def_id))
|
||||
} else {
|
||||
|
@ -534,13 +534,13 @@ pub fn type_metadata(
|
|||
|
||||
let ptr_metadata = |ty: Ty<'tcx>| {
|
||||
match ty.sty {
|
||||
ty::TySlice(typ) => {
|
||||
ty::Slice(typ) => {
|
||||
Ok(vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span))
|
||||
}
|
||||
ty::TyStr => {
|
||||
Ok(vec_slice_metadata(cx, t, cx.tcx.types.u8, unique_type_id, usage_site_span))
|
||||
}
|
||||
ty::TyDynamic(..) => {
|
||||
ty::Dynamic(..) => {
|
||||
Ok(MetadataCreationResult::new(
|
||||
trait_pointer_metadata(cx, ty, Some(t), unique_type_id),
|
||||
false))
|
||||
|
@ -562,7 +562,7 @@ pub fn type_metadata(
|
|||
};
|
||||
|
||||
let MetadataCreationResult { metadata, already_stored_in_typemap } = match t.sty {
|
||||
ty::TyNever |
|
||||
ty::Never |
|
||||
ty::TyBool |
|
||||
ty::TyChar |
|
||||
ty::TyInt(_) |
|
||||
|
@ -570,17 +570,17 @@ pub fn type_metadata(
|
|||
ty::TyFloat(_) => {
|
||||
MetadataCreationResult::new(basic_type_metadata(cx, t), false)
|
||||
}
|
||||
ty::TyTuple(ref elements) if elements.is_empty() => {
|
||||
ty::Tuple(ref elements) if elements.is_empty() => {
|
||||
MetadataCreationResult::new(basic_type_metadata(cx, t), false)
|
||||
}
|
||||
ty::TyArray(typ, _) |
|
||||
ty::TySlice(typ) => {
|
||||
ty::Array(typ, _) |
|
||||
ty::Slice(typ) => {
|
||||
fixed_vec_metadata(cx, unique_type_id, t, typ, usage_site_span)
|
||||
}
|
||||
ty::TyStr => {
|
||||
fixed_vec_metadata(cx, unique_type_id, t, cx.tcx.types.i8, usage_site_span)
|
||||
}
|
||||
ty::TyDynamic(..) => {
|
||||
ty::Dynamic(..) => {
|
||||
MetadataCreationResult::new(
|
||||
trait_pointer_metadata(cx, t, None, unique_type_id),
|
||||
false)
|
||||
|
@ -590,20 +590,20 @@ pub fn type_metadata(
|
|||
foreign_type_metadata(cx, t, unique_type_id),
|
||||
false)
|
||||
}
|
||||
ty::TyRawPtr(ty::TypeAndMut{ty, ..}) |
|
||||
ty::TyRef(_, ty, _) => {
|
||||
ty::RawPtr(ty::TypeAndMut{ty, ..}) |
|
||||
ty::Ref(_, ty, _) => {
|
||||
match ptr_metadata(ty) {
|
||||
Ok(res) => res,
|
||||
Err(metadata) => return metadata,
|
||||
}
|
||||
}
|
||||
ty::TyAdt(def, _) if def.is_box() => {
|
||||
ty::Adt(def, _) if def.is_box() => {
|
||||
match ptr_metadata(t.boxed_ty()) {
|
||||
Ok(res) => res,
|
||||
Err(metadata) => return metadata,
|
||||
}
|
||||
}
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
let fn_metadata = subroutine_type_metadata(cx,
|
||||
unique_type_id,
|
||||
t.fn_sig(cx.tcx),
|
||||
|
@ -619,7 +619,7 @@ pub fn type_metadata(
|
|||
MetadataCreationResult::new(pointer_type_metadata(cx, t, fn_metadata), false)
|
||||
|
||||
}
|
||||
ty::TyClosure(def_id, substs) => {
|
||||
ty::Closure(def_id, substs) => {
|
||||
let upvar_tys : Vec<_> = substs.upvar_tys(def_id, cx.tcx).collect();
|
||||
prepare_tuple_metadata(cx,
|
||||
t,
|
||||
|
@ -627,7 +627,7 @@ pub fn type_metadata(
|
|||
unique_type_id,
|
||||
usage_site_span).finalize(cx)
|
||||
}
|
||||
ty::TyGenerator(def_id, substs, _) => {
|
||||
ty::Generator(def_id, substs, _) => {
|
||||
let upvar_tys : Vec<_> = substs.field_tys(def_id, cx.tcx).map(|t| {
|
||||
cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), t)
|
||||
}).collect();
|
||||
|
@ -637,7 +637,7 @@ pub fn type_metadata(
|
|||
unique_type_id,
|
||||
usage_site_span).finalize(cx)
|
||||
}
|
||||
ty::TyAdt(def, ..) => match def.adt_kind() {
|
||||
ty::Adt(def, ..) => match def.adt_kind() {
|
||||
AdtKind::Struct => {
|
||||
prepare_struct_metadata(cx,
|
||||
t,
|
||||
|
@ -658,7 +658,7 @@ pub fn type_metadata(
|
|||
usage_site_span).finalize(cx)
|
||||
}
|
||||
},
|
||||
ty::TyTuple(ref elements) => {
|
||||
ty::Tuple(ref elements) => {
|
||||
prepare_tuple_metadata(cx,
|
||||
t,
|
||||
&elements[..],
|
||||
|
@ -765,8 +765,8 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
|||
debug!("basic_type_metadata: {:?}", t);
|
||||
|
||||
let (name, encoding) = match t.sty {
|
||||
ty::TyNever => ("!", DW_ATE_unsigned),
|
||||
ty::TyTuple(ref elements) if elements.is_empty() =>
|
||||
ty::Never => ("!", DW_ATE_unsigned),
|
||||
ty::Tuple(ref elements) if elements.is_empty() =>
|
||||
("()", DW_ATE_unsigned),
|
||||
ty::TyBool => ("bool", DW_ATE_boolean),
|
||||
ty::TyChar => ("char", DW_ATE_unsigned_char),
|
||||
|
@ -1009,7 +1009,7 @@ fn prepare_struct_metadata(
|
|||
let struct_name = compute_debuginfo_type_name(cx, struct_type, false);
|
||||
|
||||
let (struct_def_id, variant) = match struct_type.sty {
|
||||
ty::TyAdt(def, _) => (def.did, def.non_enum_variant()),
|
||||
ty::Adt(def, _) => (def.did, def.non_enum_variant()),
|
||||
_ => bug!("prepare_struct_metadata on a non-ADT")
|
||||
};
|
||||
|
||||
|
@ -1126,7 +1126,7 @@ fn prepare_union_metadata(
|
|||
let union_name = compute_debuginfo_type_name(cx, union_type, false);
|
||||
|
||||
let (union_def_id, variant) = match union_type.sty {
|
||||
ty::TyAdt(def, _) => (def.did, def.non_enum_variant()),
|
||||
ty::Adt(def, _) => (def.did, def.non_enum_variant()),
|
||||
_ => bug!("prepare_union_metadata on a non-ADT")
|
||||
};
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ pub fn create_function_debug_context(
|
|||
|
||||
// Return type -- llvm::DIBuilder wants this at index 0
|
||||
signature.push(match sig.output().sty {
|
||||
ty::TyTuple(ref tys) if tys.is_empty() => None,
|
||||
ty::Tuple(ref tys) if tys.is_empty() => None,
|
||||
_ => Some(type_metadata(cx, sig.output(), syntax_pos::DUMMY_SP))
|
||||
});
|
||||
|
||||
|
@ -347,7 +347,7 @@ pub fn create_function_debug_context(
|
|||
// already inaccurate due to ABI adjustments (see #42800).
|
||||
signature.extend(inputs.iter().map(|&t| {
|
||||
let t = match t.sty {
|
||||
ty::TyArray(ct, _)
|
||||
ty::Array(ct, _)
|
||||
if (ct == cx.tcx.types.u8) || cx.layout_of(ct).is_zst() => {
|
||||
cx.tcx.mk_imm_ptr(ct)
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ pub fn create_function_debug_context(
|
|||
}
|
||||
|
||||
if sig.abi == Abi::RustCall && !sig.inputs().is_empty() {
|
||||
if let ty::TyTuple(args) = sig.inputs()[sig.inputs().len() - 1].sty {
|
||||
if let ty::Tuple(args) = sig.inputs()[sig.inputs().len() - 1].sty {
|
||||
signature.extend(
|
||||
args.iter().map(|argument_type| {
|
||||
Some(type_metadata(cx, argument_type, syntax_pos::DUMMY_SP))
|
||||
|
@ -460,7 +460,7 @@ pub fn create_function_debug_context(
|
|||
// Only "class" methods are generally understood by LLVM,
|
||||
// so avoid methods on other types (e.g. `<*mut T>::null`).
|
||||
match impl_self_ty.sty {
|
||||
ty::TyAdt(def, ..) if !def.is_box() => {
|
||||
ty::Adt(def, ..) if !def.is_box() => {
|
||||
Some(type_metadata(cx, impl_self_ty, syntax_pos::DUMMY_SP))
|
||||
}
|
||||
_ => None
|
||||
|
|
|
@ -44,16 +44,16 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
ty::TyBool => output.push_str("bool"),
|
||||
ty::TyChar => output.push_str("char"),
|
||||
ty::TyStr => output.push_str("str"),
|
||||
ty::TyNever => output.push_str("!"),
|
||||
ty::Never => output.push_str("!"),
|
||||
ty::TyInt(int_ty) => output.push_str(int_ty.ty_to_string()),
|
||||
ty::TyUint(uint_ty) => output.push_str(uint_ty.ty_to_string()),
|
||||
ty::TyFloat(float_ty) => output.push_str(float_ty.ty_to_string()),
|
||||
ty::TyForeign(def_id) => push_item_name(cx, def_id, qualified, output),
|
||||
ty::TyAdt(def, substs) => {
|
||||
ty::Adt(def, substs) => {
|
||||
push_item_name(cx, def.did, qualified, output);
|
||||
push_type_params(cx, substs, output);
|
||||
},
|
||||
ty::TyTuple(component_types) => {
|
||||
ty::Tuple(component_types) => {
|
||||
output.push('(');
|
||||
for &component_type in component_types {
|
||||
push_debuginfo_type_name(cx, component_type, true, output);
|
||||
|
@ -65,7 +65,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
}
|
||||
output.push(')');
|
||||
},
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => {
|
||||
ty::RawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => {
|
||||
if !cpp_like_names {
|
||||
output.push('*');
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
output.push('*');
|
||||
}
|
||||
},
|
||||
ty::TyRef(_, inner_type, mutbl) => {
|
||||
ty::Ref(_, inner_type, mutbl) => {
|
||||
if !cpp_like_names {
|
||||
output.push('&');
|
||||
}
|
||||
|
@ -94,13 +94,13 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
output.push('*');
|
||||
}
|
||||
},
|
||||
ty::TyArray(inner_type, len) => {
|
||||
ty::Array(inner_type, len) => {
|
||||
output.push('[');
|
||||
push_debuginfo_type_name(cx, inner_type, true, output);
|
||||
output.push_str(&format!("; {}", len.unwrap_usize(cx.tcx)));
|
||||
output.push(']');
|
||||
},
|
||||
ty::TySlice(inner_type) => {
|
||||
ty::Slice(inner_type) => {
|
||||
if cpp_like_names {
|
||||
output.push_str("slice<");
|
||||
} else {
|
||||
|
@ -115,7 +115,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
output.push(']');
|
||||
}
|
||||
},
|
||||
ty::TyDynamic(ref trait_data, ..) => {
|
||||
ty::Dynamic(ref trait_data, ..) => {
|
||||
if let Some(principal) = trait_data.principal() {
|
||||
let principal = cx.tcx.normalize_erasing_late_bound_regions(
|
||||
ty::ParamEnv::reveal_all(),
|
||||
|
@ -125,7 +125,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
push_type_params(cx, principal.substs, output);
|
||||
}
|
||||
},
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
|
||||
ty::FnDef(..) | ty::FnPtr(_) => {
|
||||
let sig = t.fn_sig(cx.tcx);
|
||||
if sig.unsafety() == hir::Unsafety::Unsafe {
|
||||
output.push_str("unsafe ");
|
||||
|
@ -165,17 +165,17 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
push_debuginfo_type_name(cx, sig.output(), true, output);
|
||||
}
|
||||
},
|
||||
ty::TyClosure(..) => {
|
||||
ty::Closure(..) => {
|
||||
output.push_str("closure");
|
||||
}
|
||||
ty::TyGenerator(..) => {
|
||||
ty::Generator(..) => {
|
||||
output.push_str("generator");
|
||||
}
|
||||
ty::TyError |
|
||||
ty::TyInfer(_) |
|
||||
ty::TyProjection(..) |
|
||||
ty::TyAnon(..) |
|
||||
ty::TyGeneratorWitness(..) |
|
||||
ty::Error |
|
||||
ty::Infer(_) |
|
||||
ty::Projection(..) |
|
||||
ty::Anon(..) |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::TyParam(_) => {
|
||||
bug!("debuginfo: Trying to create type name for \
|
||||
unexpected type: {:?}", t);
|
||||
|
|
|
@ -35,12 +35,12 @@ pub fn size_and_align_of_dst(bx: &Builder<'_, 'll, 'tcx>, t: Ty<'tcx>, info: Opt
|
|||
return (size, align);
|
||||
}
|
||||
match t.sty {
|
||||
ty::TyDynamic(..) => {
|
||||
ty::Dynamic(..) => {
|
||||
// load size/align from vtable
|
||||
let vtable = info.unwrap();
|
||||
(meth::SIZE.get_usize(bx, vtable), meth::ALIGN.get_usize(bx, vtable))
|
||||
}
|
||||
ty::TySlice(_) | ty::TyStr => {
|
||||
ty::Slice(_) | ty::TyStr => {
|
||||
let unit = t.sequence_element_type(bx.tcx());
|
||||
// The info in this case is the length of the str, so the size is that
|
||||
// times the unit size.
|
||||
|
@ -81,7 +81,7 @@ pub fn size_and_align_of_dst(bx: &Builder<'_, 'll, 'tcx>, t: Ty<'tcx>, info: Opt
|
|||
let size = bx.add(sized_size, unsized_size);
|
||||
|
||||
// Packed types ignore the alignment of their fields.
|
||||
if let ty::TyAdt(def, _) = t.sty {
|
||||
if let ty::Adt(def, _) = t.sty {
|
||||
if def.repr.packed() {
|
||||
unsized_align = sized_align;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ pub fn codegen_intrinsic_call(
|
|||
let tcx = cx.tcx;
|
||||
|
||||
let (def_id, substs) = match callee_ty.sty {
|
||||
ty::TyFnDef(def_id, substs) => (def_id, substs),
|
||||
ty::FnDef(def_id, substs) => (def_id, substs),
|
||||
_ => bug!("expected fn item type, found {}", callee_ty)
|
||||
};
|
||||
|
||||
|
@ -1343,7 +1343,7 @@ fn generic_simd_intrinsic(
|
|||
// This counts how many pointers
|
||||
fn ptr_count(t: ty::Ty) -> usize {
|
||||
match t.sty {
|
||||
ty::TyRawPtr(p) => 1 + ptr_count(p.ty),
|
||||
ty::RawPtr(p) => 1 + ptr_count(p.ty),
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
@ -1351,7 +1351,7 @@ fn generic_simd_intrinsic(
|
|||
// Non-ptr type
|
||||
fn non_ptr(t: ty::Ty) -> ty::Ty {
|
||||
match t.sty {
|
||||
ty::TyRawPtr(p) => non_ptr(p.ty),
|
||||
ty::RawPtr(p) => non_ptr(p.ty),
|
||||
_ => t,
|
||||
}
|
||||
}
|
||||
|
@ -1359,7 +1359,7 @@ fn generic_simd_intrinsic(
|
|||
// The second argument must be a simd vector with an element type that's a pointer
|
||||
// to the element type of the first argument
|
||||
let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).sty {
|
||||
ty::TyRawPtr(p) if p.ty == in_elem => (ptr_count(arg_tys[1].simd_type(tcx)),
|
||||
ty::RawPtr(p) if p.ty == in_elem => (ptr_count(arg_tys[1].simd_type(tcx)),
|
||||
non_ptr(arg_tys[1].simd_type(tcx))),
|
||||
_ => {
|
||||
require!(false, "expected element type `{}` of second argument `{}` \
|
||||
|
@ -1439,7 +1439,7 @@ fn generic_simd_intrinsic(
|
|||
// This counts how many pointers
|
||||
fn ptr_count(t: ty::Ty) -> usize {
|
||||
match t.sty {
|
||||
ty::TyRawPtr(p) => 1 + ptr_count(p.ty),
|
||||
ty::RawPtr(p) => 1 + ptr_count(p.ty),
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
@ -1447,7 +1447,7 @@ fn generic_simd_intrinsic(
|
|||
// Non-ptr type
|
||||
fn non_ptr(t: ty::Ty) -> ty::Ty {
|
||||
match t.sty {
|
||||
ty::TyRawPtr(p) => non_ptr(p.ty),
|
||||
ty::RawPtr(p) => non_ptr(p.ty),
|
||||
_ => t,
|
||||
}
|
||||
}
|
||||
|
@ -1455,7 +1455,7 @@ fn generic_simd_intrinsic(
|
|||
// The second argument must be a simd vector with an element type that's a pointer
|
||||
// to the element type of the first argument
|
||||
let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).sty {
|
||||
ty::TyRawPtr(p) if p.ty == in_elem && p.mutbl == hir::MutMutable
|
||||
ty::RawPtr(p) if p.ty == in_elem && p.mutbl == hir::MutMutable
|
||||
=> (ptr_count(arg_tys[1].simd_type(tcx)),
|
||||
non_ptr(arg_tys[1].simd_type(tcx))),
|
||||
_ => {
|
||||
|
|
|
@ -131,7 +131,7 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> {
|
|||
func: mir::Operand::Constant(ref c),
|
||||
ref args, ..
|
||||
} => match c.ty.sty {
|
||||
ty::TyFnDef(did, _) => Some((did, args)),
|
||||
ty::FnDef(did, _) => Some((did, args)),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
|
|
|
@ -296,7 +296,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
&args1[..]
|
||||
};
|
||||
let (drop_fn, fn_ty) = match ty.sty {
|
||||
ty::TyDynamic(..) => {
|
||||
ty::Dynamic(..) => {
|
||||
let fn_ty = drop_fn.ty(bx.cx.tcx);
|
||||
let sig = common::ty_fn_sig(bx.cx, fn_ty);
|
||||
let sig = bx.tcx().normalize_erasing_late_bound_regions(
|
||||
|
@ -417,14 +417,14 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
let callee = self.codegen_operand(&bx, func);
|
||||
|
||||
let (instance, mut llfn) = match callee.layout.ty.sty {
|
||||
ty::TyFnDef(def_id, substs) => {
|
||||
ty::FnDef(def_id, substs) => {
|
||||
(Some(ty::Instance::resolve(bx.cx.tcx,
|
||||
ty::ParamEnv::reveal_all(),
|
||||
def_id,
|
||||
substs).unwrap()),
|
||||
None)
|
||||
}
|
||||
ty::TyFnPtr(_) => {
|
||||
ty::FnPtr(_) => {
|
||||
(None, Some(callee.immediate()))
|
||||
}
|
||||
_ => bug!("{} is not callable", callee.layout.ty)
|
||||
|
|
|
@ -182,7 +182,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
.and_then(|c| {
|
||||
let field_ty = c.ty.builtin_index().unwrap();
|
||||
let fields = match c.ty.sty {
|
||||
ty::TyArray(_, n) => n.unwrap_usize(bx.tcx()),
|
||||
ty::Array(_, n) => n.unwrap_usize(bx.tcx()),
|
||||
ref other => bug!("invalid simd shuffle type: {}", other),
|
||||
};
|
||||
let values: Result<Vec<_>, Lrc<_>> = (0..fields).map(|field| {
|
||||
|
|
|
@ -467,7 +467,7 @@ fn arg_local_refs(
|
|||
|
||||
let arg_ty = fx.monomorphize(&arg_decl.ty);
|
||||
let tupled_arg_tys = match arg_ty.sty {
|
||||
ty::TyTuple(ref tys) => tys,
|
||||
ty::Tuple(ref tys) => tys,
|
||||
_ => bug!("spread argument isn't a tuple?!")
|
||||
};
|
||||
|
||||
|
@ -592,14 +592,14 @@ fn arg_local_refs(
|
|||
|
||||
// Or is it the closure environment?
|
||||
let (closure_layout, env_ref) = match arg.layout.ty.sty {
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty, .. }) |
|
||||
ty::TyRef(_, ty, _) => (bx.cx.layout_of(ty), true),
|
||||
ty::RawPtr(ty::TypeAndMut { ty, .. }) |
|
||||
ty::Ref(_, ty, _) => (bx.cx.layout_of(ty), true),
|
||||
_ => (arg.layout, false)
|
||||
};
|
||||
|
||||
let (def_id, upvar_substs) = match closure_layout.ty.sty {
|
||||
ty::TyClosure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)),
|
||||
ty::TyGenerator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)),
|
||||
ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)),
|
||||
ty::Generator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)),
|
||||
_ => bug!("upvar_decls with non-closure arg0 type `{}`", closure_layout.ty)
|
||||
};
|
||||
let upvar_tys = upvar_substs.upvar_tys(def_id, tcx);
|
||||
|
@ -639,7 +639,7 @@ fn arg_local_refs(
|
|||
// a pointer in an alloca for debuginfo atm.
|
||||
let mut ops = if env_ref || env_alloca { &ops[..] } else { &ops[1..] };
|
||||
|
||||
let ty = if let (true, &ty::TyRef(_, ty, _)) = (decl.by_ref, &ty.sty) {
|
||||
let ty = if let (true, &ty::Ref(_, ty, _)) = (decl.by_ref, &ty.sty) {
|
||||
ty
|
||||
} else {
|
||||
ops = &ops[..ops.len() - 1];
|
||||
|
|
|
@ -211,8 +211,8 @@ impl PlaceRef<'ll, 'tcx> {
|
|||
return simple();
|
||||
}
|
||||
_ if !field.is_unsized() => return simple(),
|
||||
ty::TySlice(..) | ty::TyStr | ty::TyForeign(..) => return simple(),
|
||||
ty::TyAdt(def, _) => {
|
||||
ty::Slice(..) | ty::TyStr | ty::TyForeign(..) => return simple(),
|
||||
ty::Adt(def, _) => {
|
||||
if def.repr.packed() {
|
||||
// FIXME(eddyb) generalize the adjustment when we
|
||||
// start supporting packing to larger alignments.
|
||||
|
|
|
@ -214,7 +214,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
let val = match *kind {
|
||||
mir::CastKind::ReifyFnPointer => {
|
||||
match operand.layout.ty.sty {
|
||||
ty::TyFnDef(def_id, substs) => {
|
||||
ty::FnDef(def_id, substs) => {
|
||||
if bx.cx.tcx.has_attr(def_id, "rustc_args_required_const") {
|
||||
bug!("reifying a fn ptr that requires \
|
||||
const arguments");
|
||||
|
@ -229,7 +229,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
}
|
||||
mir::CastKind::ClosureFnPointer => {
|
||||
match operand.layout.ty.sty {
|
||||
ty::TyClosure(def_id, substs) => {
|
||||
ty::Closure(def_id, substs) => {
|
||||
let instance = monomorphize::resolve_closure(
|
||||
bx.cx.tcx, def_id, substs, ty::ClosureKind::FnOnce);
|
||||
OperandValue::Immediate(callee::get_fn(bx.cx, instance))
|
||||
|
@ -545,7 +545,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
// because codegen_place() panics if Local is operand.
|
||||
if let mir::Place::Local(index) = *place {
|
||||
if let LocalRef::Operand(Some(op)) = self.locals[index] {
|
||||
if let ty::TyArray(_, n) = op.layout.ty.sty {
|
||||
if let ty::Array(_, n) = op.layout.ty.sty {
|
||||
let n = n.unwrap_usize(bx.cx.tcx);
|
||||
return common::C_usize(bx.cx, n);
|
||||
}
|
||||
|
|
|
@ -56,19 +56,19 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
}
|
||||
|
||||
let name = match layout.ty.sty {
|
||||
ty::TyClosure(..) |
|
||||
ty::TyGenerator(..) |
|
||||
ty::TyAdt(..) |
|
||||
ty::Closure(..) |
|
||||
ty::Generator(..) |
|
||||
ty::Adt(..) |
|
||||
// FIXME(eddyb) producing readable type names for trait objects can result
|
||||
// in problematically distinct types due to HRTB and subtyping (see #47638).
|
||||
// ty::TyDynamic(..) |
|
||||
// ty::Dynamic(..) |
|
||||
ty::TyForeign(..) |
|
||||
ty::TyStr => {
|
||||
let mut name = String::with_capacity(32);
|
||||
let printer = DefPathBasedNames::new(cx.tcx, true, true);
|
||||
printer.push_type_name(layout.ty, &mut name);
|
||||
match (&layout.ty.sty, &layout.variants) {
|
||||
(&ty::TyAdt(def, _), &layout::Variants::Single { index }) => {
|
||||
(&ty::Adt(def, _), &layout::Variants::Single { index }) => {
|
||||
if def.is_enum() && !def.variants.is_empty() {
|
||||
write!(&mut name, "::{}", def.variants[index].name).unwrap();
|
||||
}
|
||||
|
@ -252,14 +252,14 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
|||
return llty;
|
||||
}
|
||||
let llty = match self.ty.sty {
|
||||
ty::TyRef(_, ty, _) |
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty, .. }) => {
|
||||
ty::Ref(_, ty, _) |
|
||||
ty::RawPtr(ty::TypeAndMut { ty, .. }) => {
|
||||
cx.layout_of(ty).llvm_type(cx).ptr_to()
|
||||
}
|
||||
ty::TyAdt(def, _) if def.is_box() => {
|
||||
ty::Adt(def, _) if def.is_box() => {
|
||||
cx.layout_of(self.ty.boxed_ty()).llvm_type(cx).ptr_to()
|
||||
}
|
||||
ty::TyFnPtr(sig) => {
|
||||
ty::FnPtr(sig) => {
|
||||
let sig = cx.tcx.normalize_erasing_late_bound_regions(
|
||||
ty::ParamEnv::reveal_all(),
|
||||
&sig,
|
||||
|
@ -344,11 +344,11 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
|||
// HACK(eddyb) special-case fat pointers until LLVM removes
|
||||
// pointee types, to avoid bitcasting every `OperandRef::deref`.
|
||||
match self.ty.sty {
|
||||
ty::TyRef(..) |
|
||||
ty::TyRawPtr(_) => {
|
||||
ty::Ref(..) |
|
||||
ty::RawPtr(_) => {
|
||||
return self.field(cx, index).llvm_type(cx);
|
||||
}
|
||||
ty::TyAdt(def, _) if def.is_box() => {
|
||||
ty::Adt(def, _) if def.is_box() => {
|
||||
let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty());
|
||||
return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate);
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
|||
|
||||
let mut result = None;
|
||||
match self.ty.sty {
|
||||
ty::TyRawPtr(mt) if offset.bytes() == 0 => {
|
||||
ty::RawPtr(mt) if offset.bytes() == 0 => {
|
||||
let (size, align) = cx.size_and_align_of(mt.ty);
|
||||
result = Some(PointeeInfo {
|
||||
size,
|
||||
|
@ -419,7 +419,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
|||
});
|
||||
}
|
||||
|
||||
ty::TyRef(_, ty, mt) if offset.bytes() == 0 => {
|
||||
ty::Ref(_, ty, mt) if offset.bytes() == 0 => {
|
||||
let (size, align) = cx.size_and_align_of(ty);
|
||||
|
||||
let kind = match mt {
|
||||
|
@ -497,7 +497,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
|||
|
||||
// FIXME(eddyb) This should be for `ptr::Unique<T>`, not `Box<T>`.
|
||||
if let Some(ref mut pointee) = result {
|
||||
if let ty::TyAdt(def, _) = self.ty.sty {
|
||||
if let ty::Adt(def, _) = self.ty.sty {
|
||||
if def.is_box() && offset.bytes() == 0 {
|
||||
pointee.safe = Some(PointerKind::UniqueOwned);
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ fn get_symbol_hash<'a, 'tcx>(
|
|||
// If this is a function, we hash the signature as well.
|
||||
// This is not *strictly* needed, but it may help in some
|
||||
// situations, see the `run-make/a-b-a-linker-guard` test.
|
||||
if let ty::TyFnDef(..) = item_type.sty {
|
||||
if let ty::FnDef(..) = item_type.sty {
|
||||
item_type.fn_sig(tcx).hash_stable(&mut hcx, &mut hasher);
|
||||
}
|
||||
|
||||
|
|
|
@ -1320,7 +1320,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
|
|||
let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \
|
||||
consider instead using an UnsafeCell";
|
||||
match get_transmute_from_to(cx, expr) {
|
||||
Some((&ty::TyRef(_, _, from_mt), &ty::TyRef(_, _, to_mt))) => {
|
||||
Some((&ty::Ref(_, _, from_mt), &ty::Ref(_, _, to_mt))) => {
|
||||
if to_mt == hir::Mutability::MutMutable &&
|
||||
from_mt == hir::Mutability::MutImmutable {
|
||||
cx.span_lint(MUTABLE_TRANSMUTES, expr.span, msg);
|
||||
|
|
|
@ -460,10 +460,10 @@ fn is_repr_nullable_ptr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
|
||||
if def.variants[data_idx].fields.len() == 1 {
|
||||
match def.variants[data_idx].fields[0].ty(tcx, substs).sty {
|
||||
ty::TyFnPtr(_) => {
|
||||
ty::FnPtr(_) => {
|
||||
return true;
|
||||
}
|
||||
ty::TyRef(..) => {
|
||||
ty::Ref(..) => {
|
||||
return true;
|
||||
}
|
||||
_ => {}
|
||||
|
@ -492,7 +492,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
match ty.sty {
|
||||
ty::TyAdt(def, substs) => {
|
||||
ty::Adt(def, substs) => {
|
||||
if def.is_phantom_data() {
|
||||
return FfiPhantom(ty);
|
||||
}
|
||||
|
@ -646,15 +646,15 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
},
|
||||
|
||||
// Primitive types with a stable representation.
|
||||
ty::TyBool | ty::TyInt(..) | ty::TyUint(..) | ty::TyFloat(..) | ty::TyNever => FfiSafe,
|
||||
ty::TyBool | ty::TyInt(..) | ty::TyUint(..) | ty::TyFloat(..) | ty::Never => FfiSafe,
|
||||
|
||||
ty::TySlice(_) => FfiUnsafe {
|
||||
ty::Slice(_) => FfiUnsafe {
|
||||
ty: ty,
|
||||
reason: "slices have no C equivalent",
|
||||
help: Some("consider using a raw pointer instead"),
|
||||
},
|
||||
|
||||
ty::TyDynamic(..) => FfiUnsafe {
|
||||
ty::Dynamic(..) => FfiUnsafe {
|
||||
ty: ty,
|
||||
reason: "trait objects have no C equivalent",
|
||||
help: None,
|
||||
|
@ -666,18 +666,18 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
help: Some("consider using `*const u8` and a length instead"),
|
||||
},
|
||||
|
||||
ty::TyTuple(..) => FfiUnsafe {
|
||||
ty::Tuple(..) => FfiUnsafe {
|
||||
ty: ty,
|
||||
reason: "tuples have unspecified layout",
|
||||
help: Some("consider using a struct instead"),
|
||||
},
|
||||
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty, .. }) |
|
||||
ty::TyRef(_, ty, _) => self.check_type_for_ffi(cache, ty),
|
||||
ty::RawPtr(ty::TypeAndMut { ty, .. }) |
|
||||
ty::Ref(_, ty, _) => self.check_type_for_ffi(cache, ty),
|
||||
|
||||
ty::TyArray(ty, _) => self.check_type_for_ffi(cache, ty),
|
||||
ty::Array(ty, _) => self.check_type_for_ffi(cache, ty),
|
||||
|
||||
ty::TyFnPtr(sig) => {
|
||||
ty::FnPtr(sig) => {
|
||||
match sig.abi() {
|
||||
Abi::Rust | Abi::RustIntrinsic | Abi::PlatformIntrinsic | Abi::RustCall => {
|
||||
return FfiUnsafe {
|
||||
|
@ -715,14 +715,14 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
ty::TyForeign(..) => FfiSafe,
|
||||
|
||||
ty::TyParam(..) |
|
||||
ty::TyInfer(..) |
|
||||
ty::TyError |
|
||||
ty::TyClosure(..) |
|
||||
ty::TyGenerator(..) |
|
||||
ty::TyGeneratorWitness(..) |
|
||||
ty::TyProjection(..) |
|
||||
ty::TyAnon(..) |
|
||||
ty::TyFnDef(..) => bug!("Unexpected type in foreign function"),
|
||||
ty::Infer(..) |
|
||||
ty::Error |
|
||||
ty::Closure(..) |
|
||||
ty::Generator(..) |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Projection(..) |
|
||||
ty::Anon(..) |
|
||||
ty::FnDef(..) => bug!("Unexpected type in foreign function"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -746,7 +746,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
if let Some(s) = help {
|
||||
diag.help(s);
|
||||
}
|
||||
if let ty::TyAdt(def, _) = unsafe_ty.sty {
|
||||
if let ty::Adt(def, _) = unsafe_ty.sty {
|
||||
if let Some(sp) = self.cx.tcx.hir.span_if_local(def.did) {
|
||||
diag.span_note(sp, "type defined here");
|
||||
}
|
||||
|
|
|
@ -60,9 +60,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
|||
|
||||
let t = cx.tables.expr_ty(&expr);
|
||||
let ty_warned = match t.sty {
|
||||
ty::TyTuple(ref tys) if tys.is_empty() => return,
|
||||
ty::TyNever => return,
|
||||
ty::TyAdt(def, _) => {
|
||||
ty::Tuple(ref tys) if tys.is_empty() => return,
|
||||
ty::Never => return,
|
||||
ty::Adt(def, _) => {
|
||||
if def.variants.is_empty() {
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -1342,7 +1342,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
|||
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let hir_id = self.tcx.hir.node_to_hir_id(node_id);
|
||||
let kind = match tables.node_id_to_type(hir_id).sty {
|
||||
ty::TyGenerator(def_id, ..) => {
|
||||
ty::Generator(def_id, ..) => {
|
||||
let layout = self.tcx.generator_layout(def_id);
|
||||
let data = GeneratorData {
|
||||
layout: layout.clone(),
|
||||
|
@ -1350,7 +1350,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
|||
EntryKind::Generator(self.lazy(&data))
|
||||
}
|
||||
|
||||
ty::TyClosure(def_id, substs) => {
|
||||
ty::Closure(def_id, substs) => {
|
||||
let sig = substs.closure_sig(def_id, self.tcx);
|
||||
let data = ClosureData { sig: self.lazy(&sig) };
|
||||
EntryKind::Closure(self.lazy(&data))
|
||||
|
@ -1865,7 +1865,7 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
|
|||
pub fn get_repr_options<'a, 'tcx, 'gcx>(tcx: &TyCtxt<'a, 'tcx, 'gcx>, did: DefId) -> ReprOptions {
|
||||
let ty = tcx.type_of(did);
|
||||
match ty.sty {
|
||||
ty::TyAdt(ref def, _) => return def.repr,
|
||||
ty::Adt(ref def, _) => return def.repr,
|
||||
_ => bug!("{} is not an ADT", ty),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
|
||||
if let Some(ty) = self.retrieve_type_for_place(place) {
|
||||
let needs_note = match ty.sty {
|
||||
ty::TyKind::TyClosure(id, _) => {
|
||||
ty::TyKind::Closure(id, _) => {
|
||||
let tables = self.tcx.typeck_tables_of(id);
|
||||
let node_id = self.tcx.hir.as_local_node_id(id).unwrap();
|
||||
let hir_id = self.tcx.hir.node_to_hir_id(node_id);
|
||||
|
@ -834,19 +834,19 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
self.describe_field_from_ty(&ty.boxed_ty(), field)
|
||||
} else {
|
||||
match ty.sty {
|
||||
ty::TyAdt(def, _) => if def.is_enum() {
|
||||
ty::Adt(def, _) => if def.is_enum() {
|
||||
field.index().to_string()
|
||||
} else {
|
||||
def.non_enum_variant().fields[field.index()]
|
||||
.ident
|
||||
.to_string()
|
||||
},
|
||||
ty::TyTuple(_) => field.index().to_string(),
|
||||
ty::TyRef(_, ty, _) | ty::TyRawPtr(ty::TypeAndMut { ty, .. }) => {
|
||||
ty::Tuple(_) => field.index().to_string(),
|
||||
ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => {
|
||||
self.describe_field_from_ty(&ty, field)
|
||||
}
|
||||
ty::TyArray(ty, _) | ty::TySlice(ty) => self.describe_field_from_ty(&ty, field),
|
||||
ty::TyClosure(def_id, _) | ty::TyGenerator(def_id, _, _) => {
|
||||
ty::Array(ty, _) | ty::Slice(ty) => self.describe_field_from_ty(&ty, field),
|
||||
ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => {
|
||||
// Convert the def-id into a node-id. node-ids are only valid for
|
||||
// the local code in the current crate, so this returns an `Option` in case
|
||||
// the closure comes from another crate. But in that case we wouldn't
|
||||
|
|
|
@ -935,14 +935,14 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
// individual fields instead. This way if `foo` has a
|
||||
// destructor but `bar` does not, we will only check for
|
||||
// borrows of `x.foo` and not `x.bar`. See #47703.
|
||||
ty::TyAdt(def, substs) if def.is_struct() && !def.has_dtor(self.tcx) => {
|
||||
ty::Adt(def, substs) if def.is_struct() && !def.has_dtor(self.tcx) => {
|
||||
def.all_fields()
|
||||
.map(|field| field.ty(gcx, substs))
|
||||
.enumerate()
|
||||
.for_each(|field| drop_field(self, field));
|
||||
}
|
||||
// Same as above, but for tuples.
|
||||
ty::TyTuple(tys) => {
|
||||
ty::Tuple(tys) => {
|
||||
tys.iter()
|
||||
.cloned()
|
||||
.enumerate()
|
||||
|
@ -950,7 +950,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
// Closures also have disjoint fields, but they are only
|
||||
// directly accessed in the body of the closure.
|
||||
ty::TyClosure(def, substs)
|
||||
ty::Closure(def, substs)
|
||||
if *drop_place == Place::Local(Local::new(1))
|
||||
&& !self.mir.upvar_decls.is_empty() =>
|
||||
{
|
||||
|
@ -961,7 +961,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
// Generators also have disjoint fields, but they are only
|
||||
// directly accessed in the body of the generator.
|
||||
ty::TyGenerator(def, substs, _)
|
||||
ty::Generator(def, substs, _)
|
||||
if *drop_place == Place::Local(Local::new(1))
|
||||
&& !self.mir.upvar_decls.is_empty() =>
|
||||
{
|
||||
|
@ -978,7 +978,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
// the base case below, we would have a Deep Write due to
|
||||
// the box being `needs_drop`, and that Deep Write would
|
||||
// touch `&mut` data in the box.
|
||||
ty::TyAdt(def, _) if def.is_box() => {
|
||||
ty::Adt(def, _) if def.is_box() => {
|
||||
// When/if we add a `&own T` type, this action would
|
||||
// be like running the destructor of the `&own T`.
|
||||
// (And the owner of backing storage referenced by the
|
||||
|
@ -1818,7 +1818,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
// be already initialized
|
||||
let tcx = self.tcx;
|
||||
match base.ty(self.mir, tcx).to_ty(tcx).sty {
|
||||
ty::TyAdt(def, _) if def.has_dtor(tcx) => {
|
||||
ty::Adt(def, _) if def.has_dtor(tcx) => {
|
||||
|
||||
// FIXME: analogous code in
|
||||
// check_loans.rs first maps
|
||||
|
@ -2062,7 +2062,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
|
||||
// Check the kind of deref to decide
|
||||
match base_ty.sty {
|
||||
ty::TyRef(_, _, mutbl) => {
|
||||
ty::Ref(_, _, mutbl) => {
|
||||
match mutbl {
|
||||
// Shared borrowed data is never mutable
|
||||
hir::MutImmutable => Err(place),
|
||||
|
@ -2086,7 +2086,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
ty::TyRawPtr(tnm) => {
|
||||
ty::RawPtr(tnm) => {
|
||||
match tnm.mutbl {
|
||||
// `*const` raw pointers are not mutable
|
||||
hir::MutImmutable => return Err(place),
|
||||
|
|
|
@ -261,10 +261,10 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
|
|||
.any(|p| p.is_upvar_field_projection(self.mir, &self.tcx)
|
||||
.is_some());
|
||||
match ty.sty {
|
||||
ty::TyArray(..) | ty::TySlice(..) => self
|
||||
ty::Array(..) | ty::Slice(..) => self
|
||||
.tcx
|
||||
.cannot_move_out_of_interior_noncopy(span, ty, None, origin),
|
||||
ty::TyClosure(def_id, closure_substs)
|
||||
ty::Closure(def_id, closure_substs)
|
||||
if !self.mir.upvar_decls.is_empty() && is_upvar_field_projection
|
||||
=> {
|
||||
let closure_kind_ty =
|
||||
|
|
|
@ -312,26 +312,26 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cg, 'cx, 'tcx, 'gcx> {
|
|||
// individual fields instead. This way if `foo` has a
|
||||
// destructor but `bar` does not, we will only check for
|
||||
// borrows of `x.foo` and not `x.bar`. See #47703.
|
||||
ty::TyAdt(def, substs) if def.is_struct() && !def.has_dtor(self.infcx.tcx) => {
|
||||
ty::Adt(def, substs) if def.is_struct() && !def.has_dtor(self.infcx.tcx) => {
|
||||
def.all_fields()
|
||||
.map(|field| field.ty(gcx, substs))
|
||||
.enumerate()
|
||||
.for_each(|field| drop_field(self, field));
|
||||
}
|
||||
// Same as above, but for tuples.
|
||||
ty::TyTuple(tys) => {
|
||||
ty::Tuple(tys) => {
|
||||
tys.iter().cloned().enumerate()
|
||||
.for_each(|field| drop_field(self, field));
|
||||
}
|
||||
// Closures and generators also have disjoint fields, but they are only
|
||||
// directly accessed in the body of the closure/generator.
|
||||
ty::TyGenerator(def, substs, ..)
|
||||
ty::Generator(def, substs, ..)
|
||||
if *drop_place == Place::Local(Local::new(1)) && !self.mir.upvar_decls.is_empty()
|
||||
=> {
|
||||
substs.upvar_tys(def, self.infcx.tcx).enumerate()
|
||||
.for_each(|field| drop_field(self, field));
|
||||
}
|
||||
ty::TyClosure(def, substs)
|
||||
ty::Closure(def, substs)
|
||||
if *drop_place == Place::Local(Local::new(1)) && !self.mir.upvar_decls.is_empty()
|
||||
=> {
|
||||
substs.upvar_tys(def, self.infcx.tcx).enumerate()
|
||||
|
|
|
@ -376,7 +376,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
// &
|
||||
// - let's call the lifetime of this reference `'1`
|
||||
(
|
||||
ty::TyRef(region, referent_ty, _),
|
||||
ty::Ref(region, referent_ty, _),
|
||||
hir::TyKind::Rptr(_lifetime, referent_hir_ty),
|
||||
) => {
|
||||
if region.to_region_vid() == needle_fr {
|
||||
|
@ -403,7 +403,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
|
||||
// Match up something like `Foo<'1>`
|
||||
(
|
||||
ty::TyAdt(_adt_def, substs),
|
||||
ty::Adt(_adt_def, substs),
|
||||
hir::TyKind::Path(hir::QPath::Resolved(None, path)),
|
||||
) => {
|
||||
if let Some(last_segment) = path.segments.last() {
|
||||
|
@ -423,16 +423,16 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
// The following cases don't have lifetimes, so we
|
||||
// just worry about trying to match up the rustc type
|
||||
// with the HIR types:
|
||||
(ty::TyTuple(elem_tys), hir::TyKind::Tup(elem_hir_tys)) => {
|
||||
(ty::Tuple(elem_tys), hir::TyKind::Tup(elem_hir_tys)) => {
|
||||
search_stack.extend(elem_tys.iter().cloned().zip(elem_hir_tys));
|
||||
}
|
||||
|
||||
(ty::TySlice(elem_ty), hir::TyKind::Slice(elem_hir_ty))
|
||||
| (ty::TyArray(elem_ty, _), hir::TyKind::Array(elem_hir_ty, _)) => {
|
||||
(ty::Slice(elem_ty), hir::TyKind::Slice(elem_hir_ty))
|
||||
| (ty::Array(elem_ty, _), hir::TyKind::Array(elem_hir_ty, _)) => {
|
||||
search_stack.push((elem_ty, elem_hir_ty));
|
||||
}
|
||||
|
||||
(ty::TyRawPtr(mut_ty), hir::TyKind::Ptr(mut_hir_ty)) => {
|
||||
(ty::RawPtr(mut_ty), hir::TyKind::Ptr(mut_hir_ty)) => {
|
||||
search_stack.push((mut_ty.ty, &mut_hir_ty.ty));
|
||||
}
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||
// constraints on `'a` and `'b`. These constraints
|
||||
// would be lost if we just look at the normalized
|
||||
// value.
|
||||
if let ty::TyFnDef(def_id, substs) = constant.literal.ty.sty {
|
||||
if let ty::FnDef(def_id, substs) = constant.literal.ty.sty {
|
||||
let tcx = self.tcx();
|
||||
let type_checker = &mut self.cx;
|
||||
|
||||
|
@ -483,7 +483,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||
}
|
||||
ProjectionElem::Subslice { from, to } => PlaceTy::Ty {
|
||||
ty: match base_ty.sty {
|
||||
ty::TyArray(inner, size) => {
|
||||
ty::Array(inner, size) => {
|
||||
let size = size.unwrap_usize(tcx);
|
||||
let min_size = (from as u64) + (to as u64);
|
||||
if let Some(rest_size) = size.checked_sub(min_size) {
|
||||
|
@ -497,12 +497,12 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||
)
|
||||
}
|
||||
}
|
||||
ty::TySlice(..) => base_ty,
|
||||
ty::Slice(..) => base_ty,
|
||||
_ => span_mirbug_and_err!(self, place, "slice of non-array {:?}", base_ty),
|
||||
},
|
||||
},
|
||||
ProjectionElem::Downcast(adt_def1, index) => match base_ty.sty {
|
||||
ty::TyAdt(adt_def, substs) if adt_def.is_enum() && adt_def == adt_def1 => {
|
||||
ty::Adt(adt_def, substs) if adt_def.is_enum() && adt_def == adt_def1 => {
|
||||
if index >= adt_def.variants.len() {
|
||||
PlaceTy::Ty {
|
||||
ty: span_mirbug_and_err!(
|
||||
|
@ -578,8 +578,8 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||
variant_index,
|
||||
} => (&adt_def.variants[variant_index], substs),
|
||||
PlaceTy::Ty { ty } => match ty.sty {
|
||||
ty::TyAdt(adt_def, substs) if !adt_def.is_enum() => (&adt_def.variants[0], substs),
|
||||
ty::TyClosure(def_id, substs) => {
|
||||
ty::Adt(adt_def, substs) if !adt_def.is_enum() => (&adt_def.variants[0], substs),
|
||||
ty::Closure(def_id, substs) => {
|
||||
return match substs.upvar_tys(def_id, tcx).nth(field.index()) {
|
||||
Some(ty) => Ok(ty),
|
||||
None => Err(FieldAccessError::OutOfRange {
|
||||
|
@ -587,7 +587,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||
}),
|
||||
}
|
||||
}
|
||||
ty::TyGenerator(def_id, substs, _) => {
|
||||
ty::Generator(def_id, substs, _) => {
|
||||
// Try pre-transform fields first (upvars and current state)
|
||||
if let Some(ty) = substs.pre_transforms_tys(def_id, tcx).nth(field.index()) {
|
||||
return Ok(ty);
|
||||
|
@ -602,7 +602,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||
}),
|
||||
};
|
||||
}
|
||||
ty::TyTuple(tys) => {
|
||||
ty::Tuple(tys) => {
|
||||
return match tys.get(field.index()) {
|
||||
Some(&ty) => Ok(ty),
|
||||
None => Err(FieldAccessError::OutOfRange {
|
||||
|
@ -917,7 +917,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
} => {
|
||||
let place_type = place.ty(mir, tcx).to_ty(tcx);
|
||||
let adt = match place_type.sty {
|
||||
TyKind::TyAdt(adt, _) if adt.is_enum() => adt,
|
||||
TyKind::Adt(adt, _) if adt.is_enum() => adt,
|
||||
_ => {
|
||||
span_bug!(
|
||||
stmt.source_info.span,
|
||||
|
@ -1032,7 +1032,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
let func_ty = func.ty(mir, tcx);
|
||||
debug!("check_terminator: call, func_ty={:?}", func_ty);
|
||||
let sig = match func_ty.sty {
|
||||
ty::TyFnDef(..) | ty::TyFnPtr(_) => func_ty.fn_sig(tcx),
|
||||
ty::FnDef(..) | ty::FnPtr(_) => func_ty.fn_sig(tcx),
|
||||
_ => {
|
||||
span_mirbug!(self, term, "call to non-function {:?}", func_ty);
|
||||
return;
|
||||
|
@ -1472,7 +1472,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
|
||||
CastKind::ClosureFnPointer => {
|
||||
let sig = match op.ty(mir, tcx).sty {
|
||||
ty::TyClosure(def_id, substs) => {
|
||||
ty::Closure(def_id, substs) => {
|
||||
substs.closure_sig_ty(def_id, tcx).fn_sig(tcx)
|
||||
}
|
||||
_ => bug!(),
|
||||
|
@ -1650,7 +1650,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
|
||||
debug!("add_reborrow_constraint - base_ty = {:?}", base_ty);
|
||||
match base_ty.sty {
|
||||
ty::TyRef(ref_region, _, mutbl) => {
|
||||
ty::Ref(ref_region, _, mutbl) => {
|
||||
constraints.outlives_constraints.push(OutlivesConstraint {
|
||||
sup: ref_region.to_region_vid(),
|
||||
sub: borrow_region.to_region_vid(),
|
||||
|
@ -1697,11 +1697,11 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
ty::TyRawPtr(..) => {
|
||||
ty::RawPtr(..) => {
|
||||
// deref of raw pointer, guaranteed to be valid
|
||||
break;
|
||||
}
|
||||
ty::TyAdt(def, _) if def.is_box() => {
|
||||
ty::Adt(def, _) if def.is_box() => {
|
||||
// deref of `Box`, need the base to be valid - propagate
|
||||
}
|
||||
_ => bug!("unexpected deref ty {:?} in {:?}", base_ty, borrowed_place),
|
||||
|
|
|
@ -325,7 +325,7 @@ impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx>
|
|||
fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
|
||||
// Watch out for the case that we are matching a `?T` against the
|
||||
// right-hand side.
|
||||
if let ty::TyInfer(ty::CanonicalTy(var)) = a.sty {
|
||||
if let ty::Infer(ty::CanonicalTy(var)) = a.sty {
|
||||
self.equate_var(var, b.into())?;
|
||||
Ok(a)
|
||||
} else {
|
||||
|
|
|
@ -64,7 +64,7 @@ pub struct UniversalRegions<'tcx> {
|
|||
|
||||
/// The "defining" type for this function, with all universal
|
||||
/// regions instantiated. For a closure or generator, this is the
|
||||
/// closure type, but for a top-level function it's the `TyFnDef`.
|
||||
/// closure type, but for a top-level function it's the `FnDef`.
|
||||
pub defining_ty: DefiningTy<'tcx>,
|
||||
|
||||
/// The return type of this function, with all regions replaced by
|
||||
|
@ -437,11 +437,11 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
|
|||
.replace_free_regions_with_nll_infer_vars(FR, &defining_ty);
|
||||
|
||||
match defining_ty.sty {
|
||||
ty::TyClosure(def_id, substs) => DefiningTy::Closure(def_id, substs),
|
||||
ty::TyGenerator(def_id, substs, movability) => {
|
||||
ty::Closure(def_id, substs) => DefiningTy::Closure(def_id, substs),
|
||||
ty::Generator(def_id, substs, movability) => {
|
||||
DefiningTy::Generator(def_id, substs, movability)
|
||||
}
|
||||
ty::TyFnDef(def_id, substs) => DefiningTy::FnDef(def_id, substs),
|
||||
ty::FnDef(def_id, substs) => DefiningTy::FnDef(def_id, substs),
|
||||
_ => span_bug!(
|
||||
tcx.def_span(self.mir_def_id),
|
||||
"expected defining type for `{:?}`: `{:?}`",
|
||||
|
@ -524,7 +524,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
|
|||
let (&output, tuplized_inputs) = inputs_and_output.split_last().unwrap();
|
||||
assert_eq!(tuplized_inputs.len(), 1, "multiple closure inputs");
|
||||
let inputs = match tuplized_inputs[0].sty {
|
||||
ty::TyTuple(inputs) => inputs,
|
||||
ty::Tuple(inputs) => inputs,
|
||||
_ => bug!("closure inputs not a tuple: {:?}", tuplized_inputs[0]),
|
||||
};
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> {
|
|||
// original path into a new variable and
|
||||
// borrowed *that* one, leaving the original
|
||||
// path unborrowed.
|
||||
ty::TyRawPtr(..) | ty::TyRef(_, _, hir::MutImmutable) => true,
|
||||
ty::RawPtr(..) | ty::Ref(_, _, hir::MutImmutable) => true,
|
||||
_ => proj.base.ignore_borrow(tcx, mir),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ fn place_components_conflict<'gcx, 'tcx>(
|
|||
debug!("places_conflict: shallow access behind ptr");
|
||||
return false;
|
||||
}
|
||||
(ProjectionElem::Deref, ty::TyRef(_, _, hir::MutImmutable), _) => {
|
||||
(ProjectionElem::Deref, ty::Ref(_, _, hir::MutImmutable), _) => {
|
||||
// the borrow goes through a dereference of a shared reference.
|
||||
//
|
||||
// I'm not sure why we are tracking these borrows - shared
|
||||
|
@ -329,7 +329,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
|
|||
}
|
||||
(Place::Promoted(p1), Place::Promoted(p2)) => {
|
||||
if p1.0 == p2.0 {
|
||||
if let ty::TyArray(_, size) = p1.1.sty {
|
||||
if let ty::Array(_, size) = p1.1.sty {
|
||||
if size.unwrap_usize(tcx) == 0 {
|
||||
// Ignore conflicts with promoted [T; 0].
|
||||
debug!("place_element_conflict: IGNORE-LEN-0-PROMOTED");
|
||||
|
@ -366,7 +366,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
|
|||
} else {
|
||||
let ty = pi1.base.ty(mir, tcx).to_ty(tcx);
|
||||
match ty.sty {
|
||||
ty::TyAdt(def, _) if def.is_union() => {
|
||||
ty::Adt(def, _) if def.is_union() => {
|
||||
// Different fields of a union, we are basically stuck.
|
||||
debug!("place_element_conflict: STUCK-UNION");
|
||||
Overlap::Arbitrary
|
||||
|
|
|
@ -155,8 +155,8 @@ impl<'cx, 'gcx, 'tcx> Iterator for Prefixes<'cx, 'gcx, 'tcx> {
|
|||
|
||||
let ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx);
|
||||
match ty.sty {
|
||||
ty::TyRawPtr(_) |
|
||||
ty::TyRef(
|
||||
ty::RawPtr(_) |
|
||||
ty::Ref(
|
||||
_, /*rgn*/
|
||||
_, /*ty*/
|
||||
hir::MutImmutable
|
||||
|
@ -166,7 +166,7 @@ impl<'cx, 'gcx, 'tcx> Iterator for Prefixes<'cx, 'gcx, 'tcx> {
|
|||
return Some(cursor);
|
||||
}
|
||||
|
||||
ty::TyRef(
|
||||
ty::Ref(
|
||||
_, /*rgn*/
|
||||
_, /*ty*/
|
||||
hir::MutMutable,
|
||||
|
@ -175,7 +175,7 @@ impl<'cx, 'gcx, 'tcx> Iterator for Prefixes<'cx, 'gcx, 'tcx> {
|
|||
return Some(cursor);
|
||||
}
|
||||
|
||||
ty::TyAdt(..) if ty.is_box() => {
|
||||
ty::Adt(..) if ty.is_box() => {
|
||||
self.next = Some(&proj.base);
|
||||
return Some(cursor);
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||
// FIXME(canndrew): This is_never should probably be an is_uninhabited
|
||||
let diverges = expr.ty.is_never();
|
||||
let intrinsic = match ty.sty {
|
||||
ty::TyFnDef(def_id, _) => {
|
||||
ty::FnDef(def_id, _) => {
|
||||
let f = ty.fn_sig(this.hir.tcx());
|
||||
if f.abi() == Abi::RustIntrinsic ||
|
||||
f.abi() == Abi::PlatformIntrinsic {
|
||||
|
|
|
@ -272,8 +272,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||
// array, so we can call `<[u8]>::eq` rather than having to find an
|
||||
// `<[u8; N]>::eq`.
|
||||
let unsize = |ty: Ty<'tcx>| match ty.sty {
|
||||
ty::TyRef(region, rty, _) => match rty.sty {
|
||||
ty::TyArray(inner_ty, n) => Some((region, inner_ty, n)),
|
||||
ty::Ref(region, rty, _) => match rty.sty {
|
||||
ty::Array(inner_ty, n) => Some((region, inner_ty, n)),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
|
|
|
@ -67,13 +67,13 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
|
|||
let ty = tcx.type_of(tcx.hir.local_def_id(id));
|
||||
let mut abi = fn_sig.abi;
|
||||
let implicit_argument = match ty.sty {
|
||||
ty::TyClosure(..) => {
|
||||
ty::Closure(..) => {
|
||||
// HACK(eddyb) Avoid having RustCall on closures,
|
||||
// as it adds unnecessary (and wrong) auto-tupling.
|
||||
abi = Abi::Rust;
|
||||
Some(ArgInfo(liberated_closure_env_ty(tcx, id, body_id), None, None, None))
|
||||
}
|
||||
ty::TyGenerator(..) => {
|
||||
ty::Generator(..) => {
|
||||
let gen_ty = tcx.body_tables(body_id).node_id_to_type(fn_hir_id);
|
||||
Some(ArgInfo(gen_ty, None, None, None))
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
|
|||
|
||||
let (yield_ty, return_ty) = if body.is_generator {
|
||||
let gen_sig = match ty.sty {
|
||||
ty::TyGenerator(gen_def_id, gen_substs, ..) =>
|
||||
ty::Generator(gen_def_id, gen_substs, ..) =>
|
||||
gen_substs.sig(gen_def_id, tcx),
|
||||
_ =>
|
||||
span_bug!(tcx.hir.span(id), "generator w/o generator type: {:?}", ty),
|
||||
|
@ -241,7 +241,7 @@ fn liberated_closure_env_ty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
|||
let closure_ty = tcx.body_tables(body_id).node_id_to_type(closure_expr_hir_id);
|
||||
|
||||
let (closure_def_id, closure_substs) = match closure_ty.sty {
|
||||
ty::TyClosure(closure_def_id, closure_substs) => (closure_def_id, closure_substs),
|
||||
ty::Closure(closure_def_id, closure_substs) => (closure_def_id, closure_substs),
|
||||
_ => bug!("closure expr does not have closure type: {:?}", closure_ty)
|
||||
};
|
||||
|
||||
|
|
|
@ -61,17 +61,17 @@ fn place_contents_drop_state_cannot_differ<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx,
|
|||
place: &mir::Place<'tcx>) -> bool {
|
||||
let ty = place.ty(mir, tcx).to_ty(tcx);
|
||||
match ty.sty {
|
||||
ty::TyArray(..) => {
|
||||
ty::Array(..) => {
|
||||
debug!("place_contents_drop_state_cannot_differ place: {:?} ty: {:?} => false",
|
||||
place, ty);
|
||||
false
|
||||
}
|
||||
ty::TySlice(..) | ty::TyRef(..) | ty::TyRawPtr(..) => {
|
||||
ty::Slice(..) | ty::Ref(..) | ty::RawPtr(..) => {
|
||||
debug!("place_contents_drop_state_cannot_differ place: {:?} ty: {:?} refd => true",
|
||||
place, ty);
|
||||
true
|
||||
}
|
||||
ty::TyAdt(def, _) if (def.has_dtor(tcx) && !def.is_box()) || def.is_union() => {
|
||||
ty::Adt(def, _) if (def.has_dtor(tcx) && !def.is_box()) || def.is_union() => {
|
||||
debug!("place_contents_drop_state_cannot_differ place: {:?} ty: {:?} Drop => true",
|
||||
place, ty);
|
||||
true
|
||||
|
|
|
@ -134,19 +134,19 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
|
|||
let tcx = self.builder.tcx;
|
||||
let place_ty = proj.base.ty(mir, tcx).to_ty(tcx);
|
||||
match place_ty.sty {
|
||||
ty::TyRef(..) | ty::TyRawPtr(..) =>
|
||||
ty::Ref(..) | ty::RawPtr(..) =>
|
||||
return Err(MoveError::cannot_move_out_of(
|
||||
self.loc,
|
||||
BorrowedContent { target_place: place.clone() })),
|
||||
ty::TyAdt(adt, _) if adt.has_dtor(tcx) && !adt.is_box() =>
|
||||
ty::Adt(adt, _) if adt.has_dtor(tcx) && !adt.is_box() =>
|
||||
return Err(MoveError::cannot_move_out_of(self.loc,
|
||||
InteriorOfTypeWithDestructor {
|
||||
container_ty: place_ty
|
||||
})),
|
||||
// move out of union - always move the entire union
|
||||
ty::TyAdt(adt, _) if adt.is_union() =>
|
||||
ty::Adt(adt, _) if adt.is_union() =>
|
||||
return Err(MoveError::UnionMove { path: base }),
|
||||
ty::TySlice(_) =>
|
||||
ty::Slice(_) =>
|
||||
return Err(MoveError::cannot_move_out_of(
|
||||
self.loc,
|
||||
InteriorOfSliceOrArray {
|
||||
|
@ -155,7 +155,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
|
|||
_ => false
|
||||
},
|
||||
})),
|
||||
ty::TyArray(..) => match proj.elem {
|
||||
ty::Array(..) => match proj.elem {
|
||||
ProjectionElem::Index(..) =>
|
||||
return Err(MoveError::cannot_move_out_of(
|
||||
self.loc,
|
||||
|
|
|
@ -284,7 +284,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||
|
||||
hir::ExprKind::AddrOf(mutbl, ref expr) => {
|
||||
let region = match expr_ty.sty {
|
||||
ty::TyRef(r, _, _) => r,
|
||||
ty::Ref(r, _, _) => r,
|
||||
_ => span_bug!(expr.span, "type of & not region"),
|
||||
};
|
||||
ExprKind::Borrow {
|
||||
|
@ -418,7 +418,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||
|
||||
hir::ExprKind::Struct(ref qpath, ref fields, ref base) => {
|
||||
match expr_ty.sty {
|
||||
ty::TyAdt(adt, substs) => {
|
||||
ty::Adt(adt, substs) => {
|
||||
match adt.adt_kind() {
|
||||
AdtKind::Struct | AdtKind::Union => {
|
||||
ExprKind::Adt {
|
||||
|
@ -472,8 +472,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||
hir::ExprKind::Closure(..) => {
|
||||
let closure_ty = cx.tables().expr_ty(expr);
|
||||
let (def_id, substs, movability) = match closure_ty.sty {
|
||||
ty::TyClosure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs), None),
|
||||
ty::TyGenerator(def_id, substs, movability) => {
|
||||
ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs), None),
|
||||
ty::Generator(def_id, substs, movability) => {
|
||||
(def_id, UpvarSubsts::Generator(substs), Some(movability))
|
||||
}
|
||||
_ => {
|
||||
|
@ -775,7 +775,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||
match cx.tables().node_id_to_type(expr.hir_id).sty {
|
||||
// A unit struct/variant which is used as a value.
|
||||
// We return a completely different ExprKind here to account for this special case.
|
||||
ty::TyAdt(adt_def, substs) => {
|
||||
ty::Adt(adt_def, substs) => {
|
||||
ExprKind::Adt {
|
||||
adt_def,
|
||||
variant_index: adt_def.variant_index_with_id(def_id),
|
||||
|
@ -827,7 +827,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||
});
|
||||
let region = cx.tcx.mk_region(region);
|
||||
|
||||
let self_expr = if let ty::TyClosure(_, closure_substs) = closure_ty.sty {
|
||||
let self_expr = if let ty::Closure(_, closure_substs) = closure_ty.sty {
|
||||
match cx.infcx.closure_kind(closure_def_id, closure_substs).unwrap() {
|
||||
ty::ClosureKind::Fn => {
|
||||
let ref_closure_ty = cx.tcx.mk_ref(region,
|
||||
|
@ -977,7 +977,7 @@ fn overloaded_place<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||
// same region and mutability as the receiver. This holds for
|
||||
// `Deref(Mut)::Deref(_mut)` and `Index(Mut)::index(_mut)`.
|
||||
let (region, mutbl) = match recv_ty.sty {
|
||||
ty::TyRef(region, _, mutbl) => (region, mutbl),
|
||||
ty::Ref(region, _, mutbl) => (region, mutbl),
|
||||
_ => span_bug!(expr.span, "overloaded_place: receiver is not a reference"),
|
||||
};
|
||||
let ref_ty = cx.tcx.mk_ref(region, ty::TypeAndMut {
|
||||
|
|
|
@ -206,7 +206,7 @@ struct LiteralExpander;
|
|||
impl<'tcx> PatternFolder<'tcx> for LiteralExpander {
|
||||
fn fold_pattern(&mut self, pat: &Pattern<'tcx>) -> Pattern<'tcx> {
|
||||
match (&pat.ty.sty, &*pat.kind) {
|
||||
(&ty::TyRef(_, rty, _), &PatternKind::Constant { ref value }) => {
|
||||
(&ty::Ref(_, rty, _), &PatternKind::Constant { ref value }) => {
|
||||
Pattern {
|
||||
ty: pat.ty,
|
||||
span: pat.span,
|
||||
|
@ -381,14 +381,14 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> {
|
|||
|
||||
fn is_non_exhaustive_enum(&self, ty: Ty<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyAdt(adt_def, ..) => adt_def.is_enum() && adt_def.is_non_exhaustive(),
|
||||
ty::Adt(adt_def, ..) => adt_def.is_enum() && adt_def.is_non_exhaustive(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_local(&self, ty: Ty<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyAdt(adt_def, ..) => adt_def.did.is_local(),
|
||||
ty::Adt(adt_def, ..) => adt_def.did.is_local(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -548,8 +548,8 @@ impl<'tcx> Witness<'tcx> {
|
|||
let mut pats = self.0.drain((len - arity) as usize..).rev();
|
||||
|
||||
match ty.sty {
|
||||
ty::TyAdt(..) |
|
||||
ty::TyTuple(..) => {
|
||||
ty::Adt(..) |
|
||||
ty::Tuple(..) => {
|
||||
let pats = pats.enumerate().map(|(i, p)| {
|
||||
FieldPattern {
|
||||
field: Field::new(i),
|
||||
|
@ -557,7 +557,7 @@ impl<'tcx> Witness<'tcx> {
|
|||
}
|
||||
}).collect();
|
||||
|
||||
if let ty::TyAdt(adt, substs) = ty.sty {
|
||||
if let ty::Adt(adt, substs) = ty.sty {
|
||||
if adt.is_enum() {
|
||||
PatternKind::Variant {
|
||||
adt_def: adt,
|
||||
|
@ -573,11 +573,11 @@ impl<'tcx> Witness<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::TyRef(..) => {
|
||||
ty::Ref(..) => {
|
||||
PatternKind::Deref { subpattern: pats.nth(0).unwrap() }
|
||||
}
|
||||
|
||||
ty::TySlice(_) | ty::TyArray(..) => {
|
||||
ty::Slice(_) | ty::Array(..) => {
|
||||
PatternKind::Slice {
|
||||
prefix: pats.collect(),
|
||||
slice: None,
|
||||
|
@ -624,7 +624,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
|||
ConstantValue(ty::Const::from_bool(cx.tcx, b))
|
||||
}).collect()
|
||||
}
|
||||
ty::TyArray(ref sub_ty, len) if len.assert_usize(cx.tcx).is_some() => {
|
||||
ty::Array(ref sub_ty, len) if len.assert_usize(cx.tcx).is_some() => {
|
||||
let len = len.unwrap_usize(cx.tcx);
|
||||
if len != 0 && cx.is_uninhabited(sub_ty) {
|
||||
vec![]
|
||||
|
@ -633,15 +633,15 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
|||
}
|
||||
}
|
||||
// Treat arrays of a constant but unknown length like slices.
|
||||
ty::TyArray(ref sub_ty, _) |
|
||||
ty::TySlice(ref sub_ty) => {
|
||||
ty::Array(ref sub_ty, _) |
|
||||
ty::Slice(ref sub_ty) => {
|
||||
if cx.is_uninhabited(sub_ty) {
|
||||
vec![Slice(0)]
|
||||
} else {
|
||||
(0..pcx.max_slice_length+1).map(|length| Slice(length)).collect()
|
||||
}
|
||||
}
|
||||
ty::TyAdt(def, substs) if def.is_enum() => {
|
||||
ty::Adt(def, substs) if def.is_enum() => {
|
||||
def.variants.iter()
|
||||
.filter(|v| !cx.is_variant_uninhabited(v, substs))
|
||||
.map(|v| Variant(v.did))
|
||||
|
@ -1243,7 +1243,7 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt,
|
|||
PatternKind::Constant { value } => Some(vec![ConstantValue(value)]),
|
||||
PatternKind::Range { lo, hi, end } => Some(vec![ConstantRange(lo, hi, end)]),
|
||||
PatternKind::Array { .. } => match pcx.ty.sty {
|
||||
ty::TyArray(_, length) => Some(vec![
|
||||
ty::Array(_, length) => Some(vec![
|
||||
Slice(length.unwrap_usize(cx.tcx))
|
||||
]),
|
||||
_ => span_bug!(pat.span, "bad ty {:?} for array pattern", pcx.ty)
|
||||
|
@ -1267,14 +1267,14 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt,
|
|||
fn constructor_arity(_cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> u64 {
|
||||
debug!("constructor_arity({:#?}, {:?})", ctor, ty);
|
||||
match ty.sty {
|
||||
ty::TyTuple(ref fs) => fs.len() as u64,
|
||||
ty::TySlice(..) | ty::TyArray(..) => match *ctor {
|
||||
ty::Tuple(ref fs) => fs.len() as u64,
|
||||
ty::Slice(..) | ty::Array(..) => match *ctor {
|
||||
Slice(length) => length,
|
||||
ConstantValue(_) => 0,
|
||||
_ => bug!("bad slice pattern {:?} {:?}", ctor, ty)
|
||||
},
|
||||
ty::TyRef(..) => 1,
|
||||
ty::TyAdt(adt, _) => {
|
||||
ty::Ref(..) => 1,
|
||||
ty::Adt(adt, _) => {
|
||||
adt.variants[ctor.variant_index_for_adt(adt)].fields.len() as u64
|
||||
}
|
||||
_ => 0
|
||||
|
@ -1291,14 +1291,14 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>,
|
|||
{
|
||||
debug!("constructor_sub_pattern_tys({:#?}, {:?})", ctor, ty);
|
||||
match ty.sty {
|
||||
ty::TyTuple(ref fs) => fs.into_iter().map(|t| *t).collect(),
|
||||
ty::TySlice(ty) | ty::TyArray(ty, _) => match *ctor {
|
||||
ty::Tuple(ref fs) => fs.into_iter().map(|t| *t).collect(),
|
||||
ty::Slice(ty) | ty::Array(ty, _) => match *ctor {
|
||||
Slice(length) => (0..length).map(|_| ty).collect(),
|
||||
ConstantValue(_) => vec![],
|
||||
_ => bug!("bad slice pattern {:?} {:?}", ctor, ty)
|
||||
},
|
||||
ty::TyRef(_, rty, _) => vec![rty],
|
||||
ty::TyAdt(adt, substs) => {
|
||||
ty::Ref(_, rty, _) => vec![rty],
|
||||
ty::Adt(adt, substs) => {
|
||||
if adt.is_box() {
|
||||
// Use T as the sub pattern type of Box<T>.
|
||||
vec![substs.type_at(0)]
|
||||
|
|
|
@ -258,8 +258,8 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
|
|||
fn conservative_is_uninhabited(&self, scrutinee_ty: Ty<'tcx>) -> bool {
|
||||
// "rustc-1.0-style" uncontentious uninhabitableness check
|
||||
match scrutinee_ty.sty {
|
||||
ty::TyNever => true,
|
||||
ty::TyAdt(def, _) => def.variants.is_empty(),
|
||||
ty::Never => true,
|
||||
ty::Adt(def, _) => def.variants.is_empty(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchVisitor, pat: &Pat) {
|
|||
return true;
|
||||
}
|
||||
let pat_ty = cx.tables.pat_ty(p);
|
||||
if let ty::TyAdt(edef, _) = pat_ty.sty {
|
||||
if let ty::Adt(edef, _) = pat_ty.sty {
|
||||
if edef.is_enum() && edef.variants.iter().any(|variant| {
|
||||
variant.name == ident.name && variant.ctor_kind == CtorKind::Const
|
||||
}) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue