Skip to content

[ICE]: expected type for param #1 in [u8, '?0, '?1, (&'?2 u8,)] #153853

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(unboxed_closures)]
#[rustc_paren_sugar]
trait Tr<'a, 'b, T> {
    fn method() {}
}

fn main() {
    <u8 as Tr(&u8)>::method;
}

original:

#![rustc_paren_sugar]
#![feature(unboxed_closures)]

#[rustc_paren_sugar]
trait Tr<'a, 'b, T> {
    type Output = u8;
    fn method() {}
}

impl<T> Tr<(), Output = &u8> for u8 {}

fn main() {
    <u8 as Tr(&u8)>::method; // Sugared, ICE
    <u8 as Tr<(), Output = &u8>>::method; // Desugared, no ICE
}

Version information

rustc 1.96.0-nightly (a0e206b56 2026-03-13)
binary: rustc
commit-hash: a0e206b5665d7c075cdc0ca5f3637a697e8ff55a
commit-date: 2026-03-13
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Possibly related line of code:

p.print_def_path(self.0.def_id, self.0.args)?;
}
TraitRefPrintSugared<'tcx> {
if !with_reduced_queries()
&& p.tcx().trait_def(self.0.def_id).paren_sugar
&& let ty::Tuple(args) = self.0.args.type_at(1).kind()
{
write!(p, "{}(", p.tcx().item_name(self.0.def_id))?;
for (i, arg) in args.iter().enumerate() {
if i > 0 {
write!(p, ", ")?;
}

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

Program output

error[E0658]: unboxed_closures are still evolving
 --> /tmp/icemaker_global_tempdir.ZbGwHYjJtpvR/rustc_testrunner_tmpdir_reporting.UM5umR6Iy6zW/mvce.rs:1:1
  |
1 | #[rustc_paren_sugar]
  | ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
  = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
  = note: this compiler was built on 2026-03-13; consider upgrading it if it is out of date

error: the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation
 --> /tmp/icemaker_global_tempdir.ZbGwHYjJtpvR/rustc_testrunner_tmpdir_reporting.UM5umR6Iy6zW/mvce.rs:2:1
  |
2 | / trait Tr<'a, 'b, T> {
3 | |     fn method() {}
4 | | }
  | |_^
  |
  = help: add `#![feature(unboxed_closures)]` to the crate attributes to use it

error[E0229]: associated item constraints are not allowed here
 --> /tmp/icemaker_global_tempdir.ZbGwHYjJtpvR/rustc_testrunner_tmpdir_reporting.UM5umR6Iy6zW/mvce.rs:7:12
  |
7 |     <u8 as Tr(&u8)>::method;
  |            ^^^^^^^ associated item constraint not allowed here

error: internal compiler error: /rustc-dev/a0e206b5665d7c075cdc0ca5f3637a697e8ff55a/compiler/rustc_middle/src/ty/print/pretty.rs:3316:50: expected type for param #1 in [u8, '?0, '?1, (&'?2 u8,)]


thread 'rustc' (71058) panicked at /rustc-dev/a0e206b5665d7c075cdc0ca5f3637a697e8ff55a/compiler/rustc_middle/src/ty/print/pretty.rs:3316:50:
Box<dyn Any>
stack backtrace:
   0:     0x7fdb9173012b - <<std[f332ca7ac2aab280]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[caaf70a19b46f696]::fmt::Display>::fmt
   1:     0x7fdb91e1ccc8 - core[caaf70a19b46f696]::fmt::write
   2:     0x7fdb91747136 - <std[f332ca7ac2aab280]::sys::stdio::unix::Stderr as std[f332ca7ac2aab280]::io::Write>::write_fmt
   3:     0x7fdb91706218 - std[f332ca7ac2aab280]::panicking::default_hook::{closure#0}
   4:     0x7fdb917235a3 - std[f332ca7ac2aab280]::panicking::default_hook
   5:     0x7fdb9071f9bc - std[f332ca7ac2aab280]::panicking::update_hook::<alloc[4f779a1cfcd17fd2]::boxed::Box<rustc_driver_impl[12052c784fa38642]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fdb91723882 - std[f332ca7ac2aab280]::panicking::panic_with_hook
   7:     0x7fdb9074f051 - std[f332ca7ac2aab280]::panicking::begin_panic::<rustc_errors[85a4c2af6d2ff10c]::ExplicitBug>::{closure#0}
   8:     0x7fdb90747d36 - std[f332ca7ac2aab280]::sys::backtrace::__rust_end_short_backtrace::<std[f332ca7ac2aab280]::panicking::begin_panic<rustc_errors[85a4c2af6d2ff10c]::ExplicitBug>::{closure#0}, !>
   9:     0x7fdb90747a9b - std[f332ca7ac2aab280]::panicking::begin_panic::<rustc_errors[85a4c2af6d2ff10c]::ExplicitBug>
  10:     0x7fdb9075a6c1 - <rustc_errors[85a4c2af6d2ff10c]::diagnostic::BugAbort as rustc_errors[85a4c2af6d2ff10c]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fdb90d37e49 - rustc_middle[1620aa76878d0fde]::util::bug::opt_span_bug_fmt::<rustc_span[5c41c3a85b90e419]::span_encoding::Span>::{closure#0}
  12:     0x7fdb90d37fd2 - rustc_middle[1620aa76878d0fde]::ty::context::tls::with_opt::<rustc_middle[1620aa76878d0fde]::util::bug::opt_span_bug_fmt<rustc_span[5c41c3a85b90e419]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fdb90d285ab - rustc_middle[1620aa76878d0fde]::ty::context::tls::with_context_opt::<rustc_middle[1620aa76878d0fde]::ty::context::tls::with_opt<rustc_middle[1620aa76878d0fde]::util::bug::opt_span_bug_fmt<rustc_span[5c41c3a85b90e419]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fdb8effcbe4 - rustc_middle[1620aa76878d0fde]::util::bug::bug_fmt
  15:     0x7fdb90d88da3 - <rustc_middle[1620aa76878d0fde]::ty::print::pretty::TraitRefPrintSugared as rustc_middle[1620aa76878d0fde]::ty::print::Print<rustc_middle[1620aa76878d0fde]::ty::print::pretty::FmtPrinter>>::print
  16:     0x7fdb90d8aa4a - <rustc_middle[1620aa76878d0fde]::ty::print::pretty::TraitRefPrintSugared as core[caaf70a19b46f696]::fmt::Display>::fmt
  17:     0x7fdb914ffb39 - <rustc_trait_selection[9f54bb3d479049cd]::error_reporting::TypeErrCtxt>::on_unimplemented_components
  18:     0x7fdb914fed5d - <rustc_trait_selection[9f54bb3d479049cd]::error_reporting::TypeErrCtxt>::on_unimplemented_note
  19:     0x7fdb915046e7 - <rustc_trait_selection[9f54bb3d479049cd]::error_reporting::TypeErrCtxt>::report_selection_error
  20:     0x7fdb9000b3a6 - <rustc_trait_selection[9f54bb3d479049cd]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  21:     0x7fdb9309fe7c - rustc_hir_typeck[e7143c23707bf68d]::typeck_with_inspect::{closure#0}
  22:     0x7fdb93095eb0 - rustc_query_impl[c3886bc306851868]::query_impl::typeck::invoke_provider_fn::__rust_begin_short_backtrace
  23:     0x7fdb91f05066 - rustc_query_impl[c3886bc306851868]::execution::try_execute_query::<rustc_data_structures[672205533455fe64]::vec_cache::VecCache<rustc_span[5c41c3a85b90e419]::def_id::LocalDefId, rustc_middle[1620aa76878d0fde]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[1620aa76878d0fde]::dep_graph::graph::DepNodeIndex>, false>
  24:     0x7fdb91f04a03 - rustc_query_impl[c3886bc306851868]::query_impl::typeck::execute_query_non_incr::__rust_end_short_backtrace
  25:     0x7fdb92884f3e - <rustc_middle[1620aa76878d0fde]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[4c40a9e8caa59823]::check_crate::{closure#2}>::{closure#0}
  26:     0x7fdb92884993 - rustc_hir_analysis[4c40a9e8caa59823]::check_crate
  27:     0x7fdb91f06413 - rustc_interface[593877ef20606c3d]::passes::analysis
  28:     0x7fdb93071309 - rustc_query_impl[c3886bc306851868]::execution::try_execute_query::<rustc_middle[1620aa76878d0fde]::query::caches::SingleCache<rustc_middle[1620aa76878d0fde]::query::erase::ErasedData<[u8; 0usize]>>, false>
  29:     0x7fdb93070f75 - rustc_query_impl[c3886bc306851868]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  30:     0x7fdb93019a08 - rustc_interface[593877ef20606c3d]::interface::run_compiler::<(), rustc_driver_impl[12052c784fa38642]::run_compiler::{closure#0}>::{closure#1}
  31:     0x7fdb9304533e - std[f332ca7ac2aab280]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[593877ef20606c3d]::util::run_in_thread_with_globals<rustc_interface[593877ef20606c3d]::util::run_in_thread_pool_with_globals<rustc_interface[593877ef20606c3d]::interface::run_compiler<(), rustc_driver_impl[12052c784fa38642]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x7fdb93045be0 - <std[f332ca7ac2aab280]::thread::lifecycle::spawn_unchecked<rustc_interface[593877ef20606c3d]::util::run_in_thread_with_globals<rustc_interface[593877ef20606c3d]::util::run_in_thread_pool_with_globals<rustc_interface[593877ef20606c3d]::interface::run_compiler<(), rustc_driver_impl[12052c784fa38642]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[caaf70a19b46f696]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7fdb93046a6c - <std[f332ca7ac2aab280]::sys::thread::unix::Thread>::new::thread_start
  34:     0x7fdb8caa598b - <unknown>
  35:     0x7fdb8cb29a0c - <unknown>
  36:                0x0 - <unknown>

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.96.0-nightly (a0e206b56 2026-03-13) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0229, E0658.
For more information about an error, try `rustc --explain E0229`.

@rustbot label +F-unboxed_closures

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-unboxed_closures`#![feature(unboxed_closures)]`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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions