diff options
| author | bors <bors@rust-lang.org> | 2024-05-11 00:31:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-11 00:31:30 +0000 |
| commit | f9a3fd966162b3c7386d90fe4626471f66ba3b8f (patch) | |
| tree | 08f5fa73d0a4a3ed1932786d885369d750349f4e /compiler/rustc_parse | |
| parent | 19dacee0d8820d42b34e21eae99ff41026413add (diff) | |
| parent | e7bb090d0ae67f355409213c800a73533b56301e (diff) | |
| download | rust-f9a3fd966162b3c7386d90fe4626471f66ba3b8f.tar.gz rust-f9a3fd966162b3c7386d90fe4626471f66ba3b8f.zip | |
Auto merge of #124993 - jieyouxu:rollup-u02aso7, r=jieyouxu
Rollup of 5 pull requests Successful merges: - #124233 (Add `-lmingwex` second time in `mingw_libs`) - #124318 (ignore generics args in attribute paths) - #124899 (bootstrap: add comments for the automatic dry run) - #124904 (reachable computation: extend explanation of what this does, and why) - #124930 (Make sure we consume a generic arg when checking mistyped turbofish) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/path.rs | 19 |
2 files changed, 17 insertions, 8 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 995803f9cd0..50698dbf9c1 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1223,7 +1223,11 @@ impl<'a> Parser<'a> { let x = self.parse_seq_to_before_end( &token::Gt, SeqSep::trailing_allowed(token::Comma), - |p| p.parse_generic_arg(None), + |p| match p.parse_generic_arg(None)? { + Some(arg) => Ok(arg), + // If we didn't eat a generic arg, then we should error. + None => p.unexpected_any(), + }, ); match x { Ok((_, _, Recovered::No)) => { diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index b97ec8c613d..3636a357978 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -160,7 +160,7 @@ impl<'a> Parser<'a> { style: PathStyle, ty_generics: Option<&Generics>, ) -> PResult<'a, Path> { - let reject_generics_if_mod_style = |parser: &Parser<'_>, path: &Path| { + let reject_generics_if_mod_style = |parser: &Parser<'_>, path: Path| { // Ensure generic arguments don't end up in attribute paths, such as: // // macro_rules! m { @@ -178,21 +178,26 @@ impl<'a> Parser<'a> { .map(|arg| arg.span()) .collect::<Vec<_>>(); parser.dcx().emit_err(errors::GenericsInPath { span }); + // Ignore these arguments to prevent unexpected behaviors. + let segments = path + .segments + .iter() + .map(|segment| PathSegment { ident: segment.ident, id: segment.id, args: None }) + .collect(); + Path { segments, ..path } + } else { + path } }; - maybe_whole!(self, NtPath, |path| { - reject_generics_if_mod_style(self, &path); - path.into_inner() - }); + maybe_whole!(self, NtPath, |path| reject_generics_if_mod_style(self, path.into_inner())); if let token::Interpolated(nt) = &self.token.kind { if let token::NtTy(ty) = &nt.0 { if let ast::TyKind::Path(None, path) = &ty.kind { let path = path.clone(); self.bump(); - reject_generics_if_mod_style(self, &path); - return Ok(path); + return Ok(reject_generics_if_mod_style(self, path)); } } } |
