Skip to content

[ICE]: entered unreachable code: This method is not called in impls, as patterns are always allowed there #160490

Closed

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

struct S;

impl S {
    fn f(... a: u8) -> u8 {}
}

original:

struct S;

impl S {
    fn f(... a: u8) -> u8 {}
}

fn main() {}

Version information

rustc 1.99.0-nightly (c9ff49689 2026-08-03)
binary: rustc
commit-hash: c9ff496891c278ad660bc0ab85c1f0b72059464a
commit-date: 2026-08-03
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

Possibly related line of code:

self.dcx().emit_err(PatternMethodParamWithoutBody {
span: pat.span,
target: match context {
FnContext::Trait => "methods without bodies",
FnContext::FunctionPtrType => "function pointer types",
FnContext::Free => unreachable!("This method is not called in free functions, as patterns are always allowed there"),
FnContext::Impl => unreachable!("This method is not called in impls, as patterns are always allowed there"),
},
});
// Pretend the pattern is `_`, to avoid duplicate errors from AST validation.
let pat = Box::new(Pat { kind: PatKind::Wild, span: pat.span, id: ast::DUMMY_NODE_ID });
Ok((pat, ty))

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: range-to patterns with `...` are not allowed
 --> /tmp/icemaker_global_tempdir.xoIgQidNADMx/rustc_testrunner_tmpdir_reporting.SYwayaaFypGP/mvce.rs:4:10
  |
4 |     fn f(... a: u8) -> u8 {}
  |          ^^^
  |
help: use `..=` instead
  |
4 -     fn f(... a: u8) -> u8 {}
4 +     fn f(..= a: u8) -> u8 {}
  |


thread 'rustc' (3424648) panicked at /rustc-dev/c9ff496891c278ad660bc0ab85c1f0b72059464a/compiler/rustc_parse/src/parser/diagnostics.rs:2401:36:
internal error: entered unreachable code: This method is not called in impls, as patterns are always allowed there
stack backtrace:
   0:     0x7f0120ccdb86 - <<std[6680dfaa64cc66c5]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[f17540a71317f7a8]::fmt::Display>::fmt
   1:     0x7f012140a948 - core[f17540a71317f7a8]::fmt::write
   2:     0x7f0120ce2cac - <std[6680dfaa64cc66c5]::sys::stdio::unix::Stderr as core[f17540a71317f7a8]::io::write::Write>::write_fmt
   3:     0x7f0120ca109a - std[6680dfaa64cc66c5]::panicking::default_hook::{closure#0}
   4:     0x7f0120cc1b33 - std[6680dfaa64cc66c5]::panicking::default_hook
   5:     0x7f011fc2529b - std[6680dfaa64cc66c5]::panicking::update_hook::<alloc[d5bd4e042c235362]::boxed::Box<rustc_driver_impl[27b6e2229d67d5da]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f0120cc1fd2 - std[6680dfaa64cc66c5]::panicking::panic_with_hook
   7:     0x7f0120ca1184 - std[6680dfaa64cc66c5]::panicking::panic_handler::{closure#0}
   8:     0x7f0120c98d69 - std[6680dfaa64cc66c5]::sys::backtrace::__rust_end_short_backtrace::<std[6680dfaa64cc66c5]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f0120ca2b4d - __rustc[4d6acb9b5637ad95]::rust_begin_unwind
  10:     0x7f011da34fac - core[f17540a71317f7a8]::panicking::panic_fmt
  11:     0x7f01204d9a51 - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::recover_arg_parse
  12:     0x7f01214d00c6 - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::parse_param_general::{closure#0}
  13:     0x7f01214cc31a - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::parse_param_general
  14:     0x7f01214c7016 - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::parse_fn_params
  15:     0x7f012150c751 - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::parse_fn
  16:     0x7f0121591ced - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::parse_item_kind
  17:     0x7f012158d363 - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::parse_item_common
  18:     0x7f01214c057c - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::parse_item_impl
  19:     0x7f0121591efd - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::parse_item_kind
  20:     0x7f012158d363 - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::parse_item_common
  21:     0x7f0121540bd4 - <rustc_parse[5338ae46bc8a9eee]::parser::Parser>::parse_mod
  22:     0x7f01223c7f3d - rustc_interface[f3e11f48256f7348]::passes::parse
  23:     0x7f01225d0e0e - rustc_interface[f3e11f48256f7348]::interface::run_compiler::<(), rustc_driver_impl[27b6e2229d67d5da]::run_compiler::{closure#0}>::{closure#2}
  24:     0x7f012261a924 - std[6680dfaa64cc66c5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f3e11f48256f7348]::util::run_in_thread_with_globals<rustc_interface[f3e11f48256f7348]::util::run_in_thread_pool_with_globals<rustc_interface[f3e11f48256f7348]::interface::run_compiler<(), rustc_driver_impl[27b6e2229d67d5da]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  25:     0x7f012261a6ed - <std[6680dfaa64cc66c5]::thread::lifecycle::spawn_unchecked<rustc_interface[f3e11f48256f7348]::util::run_in_thread_with_globals<rustc_interface[f3e11f48256f7348]::util::run_in_thread_pool_with_globals<rustc_interface[f3e11f48256f7348]::interface::run_compiler<(), rustc_driver_impl[27b6e2229d67d5da]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f17540a71317f7a8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7f0122626986 - <std[6680dfaa64cc66c5]::sys::thread::unix::Thread>::new::thread_start
  27:     0x7f011ba97739 - <unknown>
  28:     0x7f011bb1bedc - <unknown>
  29:                0x0 - <unknown>

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: rustc 1.99.0-nightly (c9ff49689 2026-08-03) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 1 previous error


Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Aug 4, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 4, 2026
  3. self-assigned this
    on Aug 4, 2026
  4. cyrgani commented on Aug 25, 2026

    @cyrgani
    Contributor

    smaller:

    fn f(...: u8) {}
  5. added
    A-parserArea: The lexing & parsing of Rust source code to an AST
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 25, 2026
  6. added
    S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
    on Sep 9, 2026
  7. added a commit that references this issue on Sep 23, 2026
    547f9aa
  8. added a commit that references this issue on Sep 23, 2026
    3987530
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions