1
Fork 0

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:
kadmin 2022-01-11 19:18:18 +00:00
parent e7529d6a38
commit f396888c4d
10 changed files with 21 additions and 32 deletions

View file

@ -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())
}

View file

@ -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()))

View file

@ -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() {

View file

@ -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 {