Allow calling dyn trait super trait methods without the super trait in scope

This also removes some vestiges of the old impl trait support which I think
aren't currently in use.
This commit is contained in:
Florian Diebold
2020-05-16 18:32:15 +02:00
parent 9322790066
commit 811d25b723
3 changed files with 40 additions and 15 deletions

View File

@@ -808,15 +808,13 @@ impl Ty {
}
}
/// If this is an `impl Trait` or `dyn Trait`, returns that trait.
pub fn inherent_trait(&self) -> Option<TraitId> {
/// If this is a `dyn Trait`, returns that trait.
pub fn dyn_trait(&self) -> Option<TraitId> {
match self {
Ty::Dyn(predicates) | Ty::Opaque(predicates) => {
predicates.iter().find_map(|pred| match pred {
GenericPredicate::Implemented(tr) => Some(tr.trait_),
_ => None,
})
}
Ty::Dyn(predicates) => predicates.iter().find_map(|pred| match pred {
GenericPredicate::Implemented(tr) => Some(tr.trait_),
_ => None,
}),
_ => None,
}
}