Skip to content

[ICE]: called Result::unwrap() on an Err value, in parser/diagnostics.rs's parameter_without_type #165690

Closed

Description

@cushionbadak

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.rs Line-2015

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

Activity

  1. added
    I-ICE
    T-compiler
    C-bug
    on Nov 9, 2026
  2. added
    needs-triage
    on Nov 9, 2026
  3. added
    S-found-by-fuzzing
    on Nov 9, 2026
  4. programskillforverification commented on Nov 13, 2026

    @programskillforverification
    Contributor

    @rustbot claim

  5. removed
    needs-triage
    on Nov 19, 2026
  6. added 2 commits that reference this issue on Nov 20, 2026
    cf58db9
    944870b
  7. added a commit that references this issue on Nov 20, 2026
    2b3f8cd
  8. added a commit that references this issue on Nov 22, 2026
    daf413a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

C-bugI-ICES-found-by-fuzzingT-compiler

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions