Factor out some repeated code in parse_item_impl
.
This commit is contained in:
parent
ed10418363
commit
ee9ef82795
1 changed files with 13 additions and 24 deletions
|
@ -646,7 +646,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
let impl_items = self.parse_item_list(attrs, |p| p.parse_impl_item(ForceCollect::No))?;
|
||||
|
||||
let item_kind = match ty_second {
|
||||
let (of_trait, self_ty) = match ty_second {
|
||||
Some(ty_second) => {
|
||||
// impl Trait for Type
|
||||
if !has_for {
|
||||
|
@ -679,31 +679,20 @@ impl<'a> Parser<'a> {
|
|||
};
|
||||
let trait_ref = TraitRef { path, ref_id: ty_first.id };
|
||||
|
||||
ItemKind::Impl(Box::new(Impl {
|
||||
safety,
|
||||
polarity,
|
||||
defaultness,
|
||||
constness,
|
||||
generics,
|
||||
of_trait: Some(trait_ref),
|
||||
self_ty: ty_second,
|
||||
items: impl_items,
|
||||
}))
|
||||
}
|
||||
None => {
|
||||
// impl Type
|
||||
ItemKind::Impl(Box::new(Impl {
|
||||
safety,
|
||||
polarity,
|
||||
defaultness,
|
||||
constness,
|
||||
generics,
|
||||
of_trait: None,
|
||||
self_ty: ty_first,
|
||||
items: impl_items,
|
||||
}))
|
||||
(Some(trait_ref), ty_second)
|
||||
}
|
||||
None => (None, ty_first), // impl Type
|
||||
};
|
||||
let item_kind = ItemKind::Impl(Box::new(Impl {
|
||||
safety,
|
||||
polarity,
|
||||
defaultness,
|
||||
constness,
|
||||
generics,
|
||||
of_trait,
|
||||
self_ty,
|
||||
items: impl_items,
|
||||
}));
|
||||
|
||||
Ok((Ident::empty(), item_kind))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue