Repository navigation
Closed
Labels
C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-found-by-fuzzingStatus: This issue was found using fuzzing. It may not arise in practical cases.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
// struct S;
fn bar(S k#self) {}
fn main() {}Found by fuzzer, tests/ui/parser/forced-keywords/basic.rs involved.
Meta
rustc --version --verbose:
rustc 1.102.0-nightly (5b7b37aef 2026-11-08)
binary: rustc
commit-hash: 5b7b37aefcb5b2fba3c2392bc9065b9e4602d494
commit-date: 2026-11-08
host: x86_64-apple-darwin
release: 1.102.0-nightly
LLVM version: 23.1.5
Error output
Command: rustc --edition 2024
thread 'rustc' (70963765) panicked at /rustc-dev/5b7b37aefcb5b2fba3c2392bc9065b9e4602d494/compiler/rustc_parse/src/parser/diagnostics.rs:2015:55:
called `Result::unwrap()` on an `Err` value: Some(DiagInner { level: Error, messages: [(Inline("expected identifier, found keyword `{$token}`"), NoStyle)], code: None, span: MultiSpan { primary_spans: [asdf.rs:2:10: 2:16 (#0)], span_labels: [(asdf.rs:2:10: 2:16 (#0), Str("expected identifier, found keyword"))], span_context: [] }, children: [], suggestions: Enabled([]), args: {"token": Str("k#self")}, is_lint: None, long_ty_path: None, emitted_at: DiagLocation { file: "/rustc-dev/5b7b37aefcb5b2fba3c2392bc9065b9e4602d494/compiler/rustc_parse/src/parser/diagnostics.rs", line: 265, col: 34 } })
Backtrace
thread 'rustc' (70963765) panicked at /rustc-dev/5b7b37aefcb5b2fba3c2392bc9065b9e4602d494/compiler/rustc_parse/src/parser/diagnostics.rs:2015:55:
called `Result::unwrap()` on an `Err` value: Some(DiagInner { level: Error, messages: [(Inline("expected identifier, found keyword `{$token}`"), NoStyle)], code: None, span: MultiSpan { primary_spans: [asdf.rs:2:10: 2:16 (#0)], span_labels: [(asdf.rs:2:10: 2:16 (#0), Str("expected identifier, found keyword"))], span_context: [] }, children: [], suggestions: Enabled([]), args: {"token": Str("k#self")}, is_lint: None, long_ty_path: None, emitted_at: DiagLocation { file: "/rustc-dev/5b7b37aefcb5b2fba3c2392bc9065b9e4602d494/compiler/rustc_parse/src/parser/diagnostics.rs", line: 265, col: 34 } })
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: core::result::unwrap_failed::unwrap_failed_inner
3: core::result::unwrap_failed::<rustc_errors::diagnostic::Diag>
4: <rustc_parse::parser::Parser>::parse_param_general::{closure#0}
5: <rustc_parse::parser::Parser>::collect_tokens::<rustc_ast::ast::Param, <rustc_parse::parser::Parser>::parse_param_general::{closure#0}>
6: <rustc_parse::parser::Parser>::parse_fn_params
7: <rustc_parse::parser::Parser>::parse_fn_decl
8: <rustc_parse::parser::Parser>::parse_fn
9: <rustc_parse::parser::Parser>::parse_item_kind
10: <rustc_parse::parser::Parser>::parse_item_common
11: <rustc_parse::parser::Parser>::parse_item_
12: <rustc_parse::parser::Parser>::parse_mod
13: rustc_interface::passes::parse
14: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::compiler_entrypoint::{closure#0}>::{closure#2}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: the compiler unexpectedly panicked. This is a bug
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: please make sure that you have updated to the latest nightly
note: please attach the file at `/Volumes/T7/workspace/tmp/068/rustc-ice-2026-11-09T09_19_35-31573.txt` to your bug report
note: rustc 1.102.0-nightly (5b7b37aef 2026-11-08) running on x86_64-apple-darwin
query stack during panic:
end of query stack
Notes
- ICE location:
compiler/rustc_parse/src/parser/diagnostics.rsLine-2015
rust/compiler/rustc_parse/src/parser/diagnostics.rs
Lines 2001 to 2023 in 5b7b37a
| pub(super) fn parameter_without_type( | |
| &mut self, | |
| err: &mut Diag<'_>, | |
| pat: Box<ast::Pat>, | |
| require_name: bool, | |
| first_param: bool, | |
| fn_parse_mode: &crate::parser::FnParseMode, | |
| ) -> Option<Ident> { | |
| // If we find a pattern followed by an identifier, it could be an (incorrect) | |
| // C-style parameter declaration. | |
| if self.check_ident() | |
| && self.look_ahead(1, |t| *t == token::Comma || *t == token::CloseParen) | |
| { | |
| // `fn foo(String s) {}` | |
| let ident = self.parse_ident_common(true).unwrap(); | |
| let span = pat.span.with_hi(ident.span.hi()); | |
| err.span_suggestion_verbose( | |
| span, | |
| "declare the type after the parameter binding", | |
| "<identifier>: <type>", | |
| Applicability::HasPlaceholders, | |
| ); |
Duplication Check
- I see no issue with
parser/diagnostics.rs:query. (github query link)
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-found-by-fuzzingStatus: This issue was found using fuzzing. It may not arise in practical cases.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
Activity
programskillforverification commentedon Nov 13, 2026
@rustbot claim
Rollup merge of rust-lang#165906 - programskillforverification:forced…
Rollup merge of rust-lang#165906 - programskillforverification:forced…
Unrolled build for #165906 in rollup 166230
Rollup merge of #165906 - programskillforverification:forced-kw-param…