diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-03-12 08:06:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-12 08:06:51 +0100 |
| commit | 4c6edb1df86ded6f83c7bfdee798f6d6f896e5a8 (patch) | |
| tree | 31c11caf8b878f5bd8fe3bf1d81e8d7f8cb74f07 /compiler/rustc_parse/src/parser | |
| parent | 2bdb10f1645472c3e064791830a1ba26dad8275c (diff) | |
| parent | ee9ef8279572ef9e3b47aa446b812c6e02e41572 (diff) | |
| download | rust-4c6edb1df86ded6f83c7bfdee798f6d6f896e5a8.tar.gz rust-4c6edb1df86ded6f83c7bfdee798f6d6f896e5a8.zip | |
Rollup merge of #138376 - nnethercote:hir-ItemKind-ident-precursors, r=compiler-errors
Item-related cleanups I have been looking at `hir::Item` closely and found a few minor cleanup opportunities. r? ```@spastorino```
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index e309f144b4f..9e6cdfe59bb 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -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)) } |
