diff options
| author | bors <bors@rust-lang.org> | 2022-01-18 22:46:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-01-18 22:46:47 +0000 |
| commit | e5e2b0be26ea177527b60d355bd8f56cd473bd00 (patch) | |
| tree | d88fe7568bde7be8c68938dc717b0c01ead17cdf /compiler/rustc_parse/src/parser | |
| parent | 9ad5d82f822b3cb67637f11be2e65c5662b66ec0 (diff) | |
| parent | f851a849cb29db5eb761fe68abf1ccaf33b7d544 (diff) | |
| download | rust-e5e2b0be26ea177527b60d355bd8f56cd473bd00.tar.gz rust-e5e2b0be26ea177527b60d355bd8f56cd473bd00.zip | |
Auto merge of #93048 - matthiaskrgr:rollup-cz5ma34, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #90782 (Implement raw-dylib support for windows-gnu) - #91150 (Let qpath contain NtTy: `<$:ty as $:ty>::…`) - #92425 (Improve SIMD casts) - #92692 (Simplify and unify rustdoc sidebar styles) - #92780 (Directly use ConstValue for single literals in blocks) - #92924 (Delete pretty printer tracing) - #93018 (Remove some unused `Ord` derives based on `Span`) - #93026 (fix typo in `max` description for f32/f64) - #93035 (Fix stdarch submodule pointing to commit outside tree) Failed merges: - #92861 (Rustdoc mobile: put out-of-band info on its own line) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/path.rs | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 4e60b7593c6..48502112e3a 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -139,22 +139,46 @@ impl<'a> Parser<'a> { style: PathStyle, ty_generics: Option<&Generics>, ) -> PResult<'a, Path> { - maybe_whole!(self, NtPath, |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 { + // ($p:path) => { #[$p] struct S; } + // } + // + // m!(inline<u8>); //~ ERROR: unexpected generic arguments in path + // if style == PathStyle::Mod && path.segments.iter().any(|segment| segment.args.is_some()) { - self.struct_span_err( - path.segments - .iter() - .filter_map(|segment| segment.args.as_ref()) - .map(|arg| arg.span()) - .collect::<Vec<_>>(), - "unexpected generic arguments in path", - ) - .emit(); + parser + .struct_span_err( + path.segments + .iter() + .filter_map(|segment| segment.args.as_ref()) + .map(|arg| arg.span()) + .collect::<Vec<_>>(), + "unexpected generic arguments in path", + ) + .emit(); } + }; + + maybe_whole!(self, NtPath, |path| { + reject_generics_if_mod_style(self, &path); path }); + if let token::Interpolated(nt) = &self.token.kind { + if let token::NtTy(ty) = &**nt { + 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); + } + } + } + let lo = self.token.span; let mut segments = Vec::new(); let mod_sep_ctxt = self.token.span.ctxt(); |
