diff options
| author | bors <bors@rust-lang.org> | 2024-07-25 18:05:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-07-25 18:05:00 +0000 |
| commit | aa877bc71c8c8082122bee23d17c8669f30f275d (patch) | |
| tree | 1ab3cc23cee9f3240950faa293515c9536120f33 /compiler/rustc_parse/src/parser | |
| parent | eb10639928a2781cf0a12440007fbcc1e3a6888f (diff) | |
| parent | cf1ce4becabf3f07b82c7dac4fd4aa3d544c3b21 (diff) | |
| download | rust-aa877bc71c8c8082122bee23d17c8669f30f275d.tar.gz rust-aa877bc71c8c8082122bee23d17c8669f30f275d.zip | |
Auto merge of #128195 - matthiaskrgr:rollup-195dfdf, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #126908 (Use Cow<'static, str> for InlineAsmTemplatePiece::String) - #127999 (Inject arm32 shims into Windows metadata generation) - #128137 (CStr: derive PartialEq, Eq; add test for Ord) - #128185 (Fix a span error when parsing a wrong param of function.) - #128187 (Fix 1.80.0 version in RELEASES.md) - #128189 (Turn an unreachable code path into an ICE) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index fbc5b914600..9aaf4b99243 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -2773,7 +2773,14 @@ impl<'a> Parser<'a> { let snapshot = p.create_snapshot_for_diagnostic(); let param = p.parse_param_general(req_name, first_param).or_else(|e| { let guar = e.emit(); - let lo = p.prev_token.span; + // When parsing a param failed, we should check to make the span of the param + // not contain '(' before it. + // For example when parsing `*mut Self` in function `fn oof(*mut Self)`. + let lo = if let TokenKind::OpenDelim(Delimiter::Parenthesis) = p.prev_token.kind { + p.prev_token.span.shrink_to_hi() + } else { + p.prev_token.span + }; p.restore_snapshot(snapshot); // Skip every token until next possible arg or end. p.eat_to_tokens(&[&token::Comma, &token::CloseDelim(Delimiter::Parenthesis)]); |
