about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-04-10 12:18:24 +0000
committerbors <bors@rust-lang.org>2025-04-10 12:18:24 +0000
commit69b3959afec9b5468d5de15133b199553f6e55d2 (patch)
tree6084097535d0260d24f121b79feae309ddccee2f /compiler/rustc_parse/src
parent7d7de5bf3c3cbf9c2c5bbc5cbfb9197a8a427d35 (diff)
parentb14671e1bd42ef60ed115920d1df60d08c235fbe (diff)
downloadrust-69b3959afec9b5468d5de15133b199553f6e55d2.tar.gz
rust-69b3959afec9b5468d5de15133b199553f6e55d2.zip
Auto merge of #139622 - matthiaskrgr:rollup-8ri1vid, r=matthiaskrgr
Rollup of 13 pull requests

Successful merges:

 - #138167 (Small code improvement in rustdoc hidden stripper)
 - #138605 (Clean up librustdoc::html::render to be better encapsulated)
 - #139423 (Suppress missing field error when autoderef bottoms out in infer)
 - #139449 (match ergonomics: replace `peel_off_references` with a recursive call)
 - #139507 (compiletest: Trim whitespace from environment variable names)
 - #139530 (Remove some dead or leftover code related to rustc-intrinsic abi removal)
 - #139560 (fix title of offset_of_enum feature)
 - #139563 (emit a better error message for using the macro incorrectly)
 - #139568 (Don't use empty trait names)
 - #139580 (Temporarily leave the review rotation)
 - #139589 (saethlin is back from vacation)
 - #139592 (rustdoc: Enable Markdown extensions when looking for doctests)
 - #139599 (Tracking issue template: fine-grained information on style update status)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/parser/item.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs
index 3647bf2c378..06501816340 100644
--- a/compiler/rustc_parse/src/parser/item.rs
+++ b/compiler/rustc_parse/src/parser/item.rs
@@ -602,21 +602,13 @@ impl<'a> Parser<'a> {
         let polarity = self.parse_polarity();
 
         // Parse both types and traits as a type, then reinterpret if necessary.
-        let err_path = |span| ast::Path::from_ident(Ident::new(kw::Empty, span));
         let ty_first = if self.token.is_keyword(kw::For) && self.look_ahead(1, |t| t != &token::Lt)
         {
             let span = self.prev_token.span.between(self.token.span);
-            self.dcx().emit_err(errors::MissingTraitInTraitImpl {
+            return Err(self.dcx().create_err(errors::MissingTraitInTraitImpl {
                 span,
                 for_span: span.to(self.token.span),
-            });
-
-            P(Ty {
-                kind: TyKind::Path(None, err_path(span)),
-                span,
-                id: DUMMY_NODE_ID,
-                tokens: None,
-            })
+            }));
         } else {
             self.parse_ty_with_generics_recovery(&generics)?
         };
@@ -657,6 +649,7 @@ impl<'a> Parser<'a> {
                     other => {
                         if let TyKind::ImplTrait(_, bounds) = other
                             && let [bound] = bounds.as_slice()
+                            && let GenericBound::Trait(poly_trait_ref) = bound
                         {
                             // Suggest removing extra `impl` keyword:
                             // `impl<T: Default> impl Default for Wrapper<T>`
@@ -666,12 +659,12 @@ impl<'a> Parser<'a> {
                                 extra_impl_kw,
                                 impl_trait_span: ty_first.span,
                             });
+                            poly_trait_ref.trait_ref.path.clone()
                         } else {
-                            self.dcx().emit_err(errors::ExpectedTraitInTraitImplFoundType {
-                                span: ty_first.span,
-                            });
+                            return Err(self.dcx().create_err(
+                                errors::ExpectedTraitInTraitImplFoundType { span: ty_first.span },
+                            ));
                         }
-                        err_path(ty_first.span)
                     }
                 };
                 let trait_ref = TraitRef { path, ref_id: ty_first.id };