diff options
| author | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-05-06 15:45:04 +0800 |
|---|---|---|
| committer | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-05-07 22:56:14 +0800 |
| commit | b922da3586ce01a4bf174db09624a1d0a424d5d9 (patch) | |
| tree | 161065f1e979b81e232552847025831b7015d16d /compiler/rustc_parse/src/parser/path.rs | |
| parent | 896cf8029c6a87b920e05dd569482dad6adbddfc (diff) | |
| download | rust-b922da3586ce01a4bf174db09624a1d0a424d5d9.tar.gz rust-b922da3586ce01a4bf174db09624a1d0a424d5d9.zip | |
Use `parse_param_general` when parsing `(T, U)->R` in `parse_path_segment`
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn> Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
Diffstat (limited to 'compiler/rustc_parse/src/parser/path.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/path.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 1093e4f4af0..9bce2fa74ca 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -15,7 +15,11 @@ use tracing::debug; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{Parser, Restrictions, TokenType}; -use crate::errors::{self, PathSingleColon, PathTripleColon}; +use crate::ast::{PatKind, TyKind}; +use crate::errors::{ + self, FnPathFoundNamedParams, PathFoundAttributeInParams, PathFoundCVariadicParams, + PathSingleColon, PathTripleColon, +}; use crate::exp; use crate::parser::{CommaRecoveryMode, RecoverColon, RecoverComma}; @@ -396,7 +400,28 @@ impl<'a> Parser<'a> { snapshot = Some(self.create_snapshot_for_diagnostic()); } - let (inputs, _) = match self.parse_paren_comma_seq(|p| p.parse_ty()) { + let dcx = self.dcx(); + let parse_params_result = self.parse_paren_comma_seq(|p| { + let param = p.parse_param_general(|_| false, false, false); + param.map(move |param| { + if !matches!(param.pat.kind, PatKind::Missing) { + dcx.emit_err(FnPathFoundNamedParams { + named_param_span: param.pat.span, + }); + } + if matches!(param.ty.kind, TyKind::CVarArgs) { + dcx.emit_err(PathFoundCVariadicParams { span: param.pat.span }); + } + if !param.attrs.is_empty() { + dcx.emit_err(PathFoundAttributeInParams { + span: param.attrs[0].span, + }); + } + param.ty + }) + }); + + let (inputs, _) = match parse_params_result { Ok(output) => output, Err(mut error) if prev_token_before_parsing == token::PathSep => { error.span_label( |
