diff options
| author | Cameron Steffen <cam.steffen94@gmail.com> | 2025-07-21 20:05:16 -0500 |
|---|---|---|
| committer | Cameron Steffen <cam.steffen94@gmail.com> | 2025-08-11 17:05:36 -0500 |
| commit | 5bc23ce25548d7f4a9f6ceaa48cc3d8fe7629f58 (patch) | |
| tree | 014fb073862c20373460e0eaa6989eb50a70fabc /compiler/rustc_parse/src | |
| parent | 3aa0ac0a8af32f2c5da106c5e89bd9712d5a9655 (diff) | |
| download | rust-5bc23ce25548d7f4a9f6ceaa48cc3d8fe7629f58.tar.gz rust-5bc23ce25548d7f4a9f6ceaa48cc3d8fe7629f58.zip | |
Extract ast TraitImplHeader
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 75cb103d5d6..607adaf0829 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -663,7 +663,14 @@ impl<'a> Parser<'a> { }; let trait_ref = TraitRef { path, ref_id: ty_first.id }; - (Some(trait_ref), ty_second) + let of_trait = Some(Box::new(TraitImplHeader { + defaultness, + safety, + constness, + polarity, + trait_ref, + })); + (of_trait, ty_second) } None => { let self_ty = ty_first; @@ -692,16 +699,8 @@ impl<'a> Parser<'a> { (None, self_ty) } }; - Ok(ItemKind::Impl(Box::new(Impl { - safety, - polarity, - defaultness, - constness, - generics, - of_trait, - self_ty, - items: impl_items, - }))) + + Ok(ItemKind::Impl(Impl { generics, of_trait, self_ty, items: impl_items })) } fn parse_item_delegation(&mut self) -> PResult<'a, ItemKind> { @@ -1389,10 +1388,10 @@ impl<'a> Parser<'a> { }; match &mut item_kind { - ItemKind::Impl(box Impl { of_trait: Some(trai), constness, .. }) => { - *constness = Const::Yes(const_span); + ItemKind::Impl(Impl { of_trait: Some(of_trait), .. }) => { + of_trait.constness = Const::Yes(const_span); - let before_trait = trai.path.span.shrink_to_lo(); + let before_trait = of_trait.trait_ref.path.span.shrink_to_lo(); let const_up_to_impl = const_span.with_hi(impl_span.lo()); err.with_multipart_suggestion( "you might have meant to write a const trait impl", |
