pub enum TraitBoundModifier {
None,
Maybe,
+ MaybeConst,
}
/// The AST represents all type param bounds as types.
}
impl GenericBound<'_> {
+ pub fn trait_def_id(&self) -> Option<DefId> {
+ match self {
+ GenericBound::Trait(data, _) => Some(data.trait_ref.trait_def_id()),
+ _ => None,
+ }
+ }
+
pub fn span(&self) -> Span {
match self {
&GenericBound::Trait(ref t, ..) => t.span,
TraitAlias(Generics<'hir>, GenericBounds<'hir>),
/// An implementation, e.g., `impl<A> Trait for Foo { .. }`.
- Impl(
- Unsafety,
- ImplPolarity,
- Defaultness,
- Generics<'hir>,
- Option<TraitRef<'hir>>, // (optional) trait this impl implements
- &'hir Ty<'hir>, // self
- &'hir [ImplItemRef<'hir>],
- ),
+ Impl {
+ unsafety: Unsafety,
+ polarity: ImplPolarity,
+ defaultness: Defaultness,
+ constness: Constness,
+ generics: Generics<'hir>,
+
+ /// The trait being implemented, if any.
+ of_trait: Option<TraitRef<'hir>>,
+
+ self_ty: &'hir Ty<'hir>,
+ items: &'hir [ImplItemRef<'hir>],
+ },
}
impl ItemKind<'_> {
ItemKind::Union(..) => "union",
ItemKind::Trait(..) => "trait",
ItemKind::TraitAlias(..) => "trait alias",
- ItemKind::Impl(..) => "impl",
+ ItemKind::Impl { .. } => "impl",
}
}
| ItemKind::Struct(_, ref generics)
| ItemKind::Union(_, ref generics)
| ItemKind::Trait(_, _, ref generics, _, _)
- | ItemKind::Impl(_, _, _, ref generics, _, _, _) => generics,
+ | ItemKind::Impl { ref generics, .. } => generics,
_ => return None,
})
}