Update w/ comments
Removes uses of ty() where a method is implemented on TypeFoldable, and also directly formats a Term.
This commit is contained in:
parent
e7529d6a38
commit
f396888c4d
@ -905,7 +905,13 @@ pub trait PrettyPrinter<'tcx>:
|
||||
}
|
||||
|
||||
for (assoc_item_def_id, term) in assoc_items {
|
||||
let ty = if let Term::Ty(ty) = term.skip_binder() { ty } else { continue };
|
||||
let ty = match term.skip_binder() {
|
||||
Term::Ty(ty) => ty,
|
||||
Term::Const(c) => {
|
||||
p!(print(c));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if !first {
|
||||
p!(", ");
|
||||
}
|
||||
|
@ -1580,10 +1580,9 @@ impl<'tcx> ExistentialProjection<'tcx> {
|
||||
) -> Self {
|
||||
// Assert there is a Self.
|
||||
projection_predicate.projection_ty.substs.type_at(0);
|
||||
let ty = if let Term::Ty(ty) = projection_predicate.term {
|
||||
ty
|
||||
} else {
|
||||
panic!("Only types are permitted here");
|
||||
let ty = match projection_predicate.term {
|
||||
Term::Ty(ty) => ty,
|
||||
Term::Const(_c) => unimplemented!(),
|
||||
};
|
||||
|
||||
Self {
|
||||
|
@ -128,10 +128,7 @@ where
|
||||
polarity: _,
|
||||
}) => self.visit_trait(trait_ref),
|
||||
ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, term }) => {
|
||||
match term {
|
||||
ty::Term::Ty(ty) => ty.visit_with(self)?,
|
||||
ty::Term::Const(ct) => ct.visit_with(self)?,
|
||||
}
|
||||
term.visit_with(self)?;
|
||||
self.visit_projection_ty(projection_ty)
|
||||
}
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty, _region)) => {
|
||||
@ -1189,10 +1186,7 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
|
||||
|
||||
for (poly_predicate, _) in bounds.projection_bounds {
|
||||
let pred = poly_predicate.skip_binder();
|
||||
let poly_pred_term = match pred.term {
|
||||
ty::Term::Ty(ty) => self.visit(ty),
|
||||
ty::Term::Const(ct) => self.visit(ct),
|
||||
};
|
||||
let poly_pred_term = self.visit(pred.term);
|
||||
if poly_pred_term.is_break()
|
||||
|| self.visit_projection_ty(pred.projection_ty).is_break()
|
||||
{
|
||||
|
@ -779,8 +779,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||
// However, we should always make progress (either by generating
|
||||
// subobligations or getting an error) when we started off with
|
||||
// inference variables
|
||||
if p.term().skip_binder().ty().map_or(false, |ty| ty.has_infer_types())
|
||||
{
|
||||
if p.term().skip_binder().ty().has_infer_types() {
|
||||
panic!("Unexpected result when selecting {:?} {:?}", ty, obligation)
|
||||
}
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// does not have any regions in it.
|
||||
let output_ty = self.resolve_vars_if_possible(predicate.term);
|
||||
debug!("deduce_future_output_from_projection: output_ty={:?}", output_ty);
|
||||
// FIXME(...): How to handle consts here? Will this always be a const?
|
||||
// This is a projection on a Fn trait so will always be a type.
|
||||
Some(output_ty.ty().unwrap())
|
||||
}
|
||||
|
||||
|
@ -789,13 +789,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
item_def_id: projection_ty.item_def_id,
|
||||
};
|
||||
|
||||
let fmt = match pred.skip_binder().term {
|
||||
ty::Term::Ty(ty) => format!("{}", ty),
|
||||
ty::Term::Const(c) => format!("{}", c),
|
||||
};
|
||||
let term = pred.skip_binder().term;
|
||||
|
||||
let obligation = format!("{} = {}", projection_ty, fmt);
|
||||
let quiet = format!("{} = {}", quiet_projection_ty, fmt);
|
||||
let obligation = format!("{} = {}", projection_ty, term);
|
||||
let quiet = format!("{} = {}", quiet_projection_ty, term);
|
||||
|
||||
bound_span_label(projection_ty.self_ty(), &obligation, &quiet);
|
||||
Some((obligation, projection_ty.self_ty()))
|
||||
|
@ -694,10 +694,7 @@ fn bounds_from_generic_predicates<'tcx>(
|
||||
where_clauses.push(format!(
|
||||
"{} = {}",
|
||||
tcx.def_path_str(p.projection_ty.item_def_id),
|
||||
match p.term {
|
||||
ty::Term::Ty(ty) => format!("{}", ty),
|
||||
ty::Term::Const(c) => format!("{}", c),
|
||||
}
|
||||
p.term,
|
||||
));
|
||||
}
|
||||
let where_clauses = if where_clauses.is_empty() {
|
||||
|
@ -199,7 +199,7 @@ fn unconstrained_parent_impl_substs<'tcx>(
|
||||
for (predicate, _) in impl_generic_predicates.predicates.iter() {
|
||||
if let ty::PredicateKind::Projection(proj) = predicate.kind().skip_binder() {
|
||||
let projection_ty = proj.projection_ty;
|
||||
let projected_ty = proj.term.ty();
|
||||
let projected_ty = proj.term;
|
||||
|
||||
let unbound_trait_ref = projection_ty.trait_ref(tcx);
|
||||
if Some(unbound_trait_ref) == impl_trait_ref {
|
||||
|
@ -1309,10 +1309,7 @@ impl FnDecl {
|
||||
GenericBound::TraitBound(PolyTrait { trait_, .. }, ..) => {
|
||||
let bindings = trait_.bindings().unwrap();
|
||||
let ret_ty = bindings[0].term();
|
||||
let ty = match ret_ty {
|
||||
Term::Type(ty) => ty,
|
||||
Term::Constant(_c) => unreachable!(),
|
||||
};
|
||||
let ty = ret_ty.ty().expect("Unexpected constant return term");
|
||||
FnRetTy::Return(ty.clone())
|
||||
}
|
||||
_ => panic!("unexpected desugaring of async function"),
|
||||
|
@ -2143,7 +2143,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
if let ty::PredicateKind::Projection(projection_predicate) = predicate.kind().skip_binder() {
|
||||
let assoc_ty = match projection_predicate.term {
|
||||
ty::Term::Ty(ty) => ty,
|
||||
ty::Term::Const(c) => c.ty,
|
||||
ty::Term::Const(_c) => continue,
|
||||
};
|
||||
// walk the associated type and check for Self
|
||||
if let Some(self_adt) = self_ty.ty_adt_def() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user