SizedSelf,
/// Supertrait reference references `Self` an in illegal location
- /// (e.g. `trait Foo : Bar<Self>`)
+ /// (e.g., `trait Foo : Bar<Self>`)
SupertraitSelf,
/// Method has something illegal
/// e.g., `fn foo(&self, x: Self)` or `fn foo(&self) -> Self`
ReferencesSelf,
- /// e.g. `fn foo(&self) where Self: Clone`
+ /// e.g., `fn foo(&self) where Self: Clone`
WhereClauseReferencesSelf(Span),
/// e.g., `fn foo<A>()`
}
};
- // e.g. Rc<()>
+ // e.g., Rc<()>
let unit_receiver_ty = self.receiver_for_self_ty(
receiver_ty, self.mk_unit(), method.def_id
);
trait_def_id, self.mk_region(ty::ReStatic)
);
- // e.g. Rc<dyn Trait>
+ // e.g., Rc<dyn Trait>
let trait_object_receiver = self.receiver_for_self_ty(
receiver_ty, trait_object_ty, method.def_id
);
}
/// performs a type substitution to produce the version of receiver_ty when `Self = self_ty`
- /// e.g. for receiver_ty = `Rc<Self>` and self_ty = `Foo`, returns `Rc<Foo>`
+ /// e.g., for receiver_ty = `Rc<Self>` and self_ty = `Foo`, returns `Rc<Foo>`
fn receiver_for_self_ty(
self, receiver_ty: Ty<'tcx>, self_ty: Ty<'tcx>, method_def_id: DefId
) -> Ty<'tcx> {
.collect::<Vec<_>>();
// existential predicates need to be in a specific order
- associated_types.sort_by_key(|item| self.def_path_hash(item.def_id));
+ associated_types.sort_by_cached_key(|item| self.def_path_hash(item.def_id));
let projection_predicates = associated_types.into_iter().map(|item| {
ty::ExistentialPredicate::Projection(ty::ExistentialProjection {
///
/// The only case where the receiver is not dispatchable, but is still a valid receiver
/// type (just not object-safe), is when there is more than one level of pointer indirection.
- /// e.g. `self: &&Self`, `self: &Rc<Self>`, `self: Box<Box<Self>>`. In these cases, there
+ /// e.g., `self: &&Self`, `self: &Rc<Self>`, `self: Box<Box<Self>>`. In these cases, there
/// is no way, or at least no inexpensive way, to coerce the receiver from the version where
/// `Self = dyn Trait` to the version where `Self = T`, where `T` is the unknown erased type
/// contained by the trait object, because the object that needs to be coerced is behind