Skip to content

[ICE]: did not expect duplicate ConstParamHasTy for N/#1 in param-env: ParamEnv { #158675

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Trait<'a, T, const F: bool> {
    fn r#static() -> Self;
}
impl<'T, const N: usize> W<N> {
    reuse Trait::<'T, W<N>, N>::r#static;
}

original:

#![feature(fn_delegation)]
struct W<const N: usize>;
trait Trait<'a, T, const F: bool> {
    fn r#static() -> Self;
}
impl<'T, const N: usize> W<N> {
    reuse Trait::<'T, W<N>, N>::r#static;
}

fn main() {}

Version information

rustc 1.98.0-nightly (4c9d2bfe4 2026-07-01)
binary: rustc
commit-hash: 4c9d2bfe4ad7a65669098754964aaebe0ec1ced2
commit-date: 2026-07-01
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.8

Possibly related line of code:

// underlying issues with how we construct generics and predicates of
// items. It's advised to fix the underlying issue rather than trying
// to modify this function.
let ty = candidates.next().unwrap_or_else(|| {
bug!("cannot find `{self:?}` in param-env: {env:#?}");
});
assert!(
candidates.next().is_none(),
"did not expect duplicate `ConstParamHasTy` for `{self:?}` in param-env: {env:#?}"
);
ty
}
}

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

Program output

error[E0425]: cannot find type `W` in this scope
 --> /tmp/icemaker_global_tempdir.zm1FldSVy35z/rustc_testrunner_tmpdir_reporting.BimMTowxrpho/mvce.rs:4:26
  |
4 | impl<'T, const N: usize> W<N> {
  |                          ^ not found in this scope

error[E0425]: cannot find type `W` in this scope
 --> /tmp/icemaker_global_tempdir.zm1FldSVy35z/rustc_testrunner_tmpdir_reporting.BimMTowxrpho/mvce.rs:5:23
  |
5 |     reuse Trait::<'T, W<N>, N>::r#static;
  |                       ^ not found in this scope

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.zm1FldSVy35z/rustc_testrunner_tmpdir_reporting.BimMTowxrpho/mvce.rs:5:5
  |
5 |     reuse Trait::<'T, W<N>, N>::r#static;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
  = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
  = note: this compiler was built on 2026-07-01; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.zm1FldSVy35z/rustc_testrunner_tmpdir_reporting.BimMTowxrpho/mvce.rs:6:2
  |
6 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.zm1FldSVy35z/rustc_testrunner_tmpdir_reporting.BimMTowxrpho/mvce.rs`


thread 'rustc' (1011618) panicked at /rustc-dev/4c9d2bfe4ad7a65669098754964aaebe0ec1ced2/compiler/rustc_middle/src/ty/sty.rs:367:9:
did not expect duplicate `ConstParamHasTy` for `N/#1` in param-env: ParamEnv {
    caller_bounds: [
        Binder { value: ConstArgHasType(N/#1, bool), bound_vars: [] },
        Binder { value: TraitPredicate(<{type error} as std::marker::Sized>, polarity:Positive), bound_vars: [] },
        Binder { value: TraitPredicate(<{type error} as std::marker::MetaSized>, polarity:Positive), bound_vars: [] },
        Binder { value: ConstArgHasType(N/#1, usize), bound_vars: [] },
    ],
}
stack backtrace:
   0:     0x7f9e1f0e6ac6 - <<std[16495cdcf3c2a980]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[e500fd9f2ab8424]::fmt::Display>::fmt
   1:     0x7f9e1f80f288 - core[e500fd9f2ab8424]::fmt::write
   2:     0x7f9e1f0fbeac - <std[16495cdcf3c2a980]::sys::stdio::unix::Stderr as std[16495cdcf3c2a980]::io::Write>::write_fmt
   3:     0x7f9e1f0baf2a - std[16495cdcf3c2a980]::panicking::default_hook::{closure#0}
   4:     0x7f9e1f0d9213 - std[16495cdcf3c2a980]::panicking::default_hook
   5:     0x7f9e1e0c6108 - std[16495cdcf3c2a980]::panicking::update_hook::<alloc[99712308a9e7a3db]::boxed::Box<rustc_driver_impl[6fdcfad033932331]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f9e1f0d96b2 - std[16495cdcf3c2a980]::panicking::panic_with_hook
   7:     0x7f9e1f0bafe2 - std[16495cdcf3c2a980]::panicking::panic_handler::{closure#0}
   8:     0x7f9e1f0af4c9 - std[16495cdcf3c2a980]::sys::backtrace::__rust_end_short_backtrace::<std[16495cdcf3c2a980]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f9e1f0bc94d - __rustc[32109bd59933d253]::rust_begin_unwind
  10:     0x7f9e1c07f7bc - core[e500fd9f2ab8424]::panicking::panic_fmt
  11:     0x7f9e211a0ad2 - <rustc_middle[320e6cb0af7a3edc]::ty::sty::ParamConst>::find_const_ty_from_env.cold
  12:     0x7f9e1fec465d - <rustc_trait_selection[82eb004aec24fc7d]::traits::fulfill::FulfillProcessor as rustc_data_structures[850f084c2feb1379]::obligation_forest::ObligationProcessor>::process_obligation
  13:     0x7f9e1f805ad1 - <rustc_data_structures[850f084c2feb1379]::obligation_forest::ObligationForest<rustc_trait_selection[82eb004aec24fc7d]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[82eb004aec24fc7d]::traits::fulfill::FulfillProcessor>
  14:     0x7f9e1fae6ea6 - <rustc_hir_typeck[e15413bd17dde5e5]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  15:     0x7f9e1fb044eb - <rustc_hir_typeck[e15413bd17dde5e5]::fn_ctxt::FnCtxt>::check_expr_call
  16:     0x7f9e1fae6913 - <rustc_hir_typeck[e15413bd17dde5e5]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  17:     0x7f9e1fabc7e3 - <rustc_hir_typeck[e15413bd17dde5e5]::fn_ctxt::FnCtxt>::check_expr_block
  18:     0x7f9e1fae68ed - <rustc_hir_typeck[e15413bd17dde5e5]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:     0x7f9e1faa420f - rustc_hir_typeck[e15413bd17dde5e5]::check::check_fn
  20:     0x7f9e2067d277 - rustc_hir_typeck[e15413bd17dde5e5]::typeck_with_inspect::{closure#0}
  21:     0x7f9e2067bc70 - rustc_query_impl[e8ce24fe214a5db4]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7f9e1ff86129 - rustc_query_impl[e8ce24fe214a5db4]::execution::try_execute_query::<rustc_data_structures[850f084c2feb1379]::vec_cache::VecCache<rustc_span[d4ad0aa40b44abc2]::def_id::LocalDefId, rustc_middle[320e6cb0af7a3edc]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[320e6cb0af7a3edc]::dep_graph::graph::DepNodeIndex>, false>
  23:     0x7f9e1ff85b83 - rustc_query_impl[e8ce24fe214a5db4]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7f9e1fe35e6d - <rustc_middle[320e6cb0af7a3edc]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[81978af84cf663ed]::check_crate::{closure#1}>::{closure#0}
  25:     0x7f9e1fe357ab - rustc_hir_analysis[81978af84cf663ed]::check_crate
  26:     0x7f9e1ff86e3a - rustc_interface[8b4b822bfe1350c5]::passes::analysis
  27:     0x7f9e209828c7 - rustc_query_impl[e8ce24fe214a5db4]::execution::try_execute_query::<rustc_middle[320e6cb0af7a3edc]::query::caches::SingleCache<rustc_middle[320e6cb0af7a3edc]::query::erase::ErasedData<[u8; 0usize]>>, false>
  28:     0x7f9e20982529 - rustc_query_impl[e8ce24fe214a5db4]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7f9e209b8bc0 - rustc_interface[8b4b822bfe1350c5]::interface::run_compiler::<(), rustc_driver_impl[6fdcfad033932331]::run_compiler::{closure#0}>::{closure#1}
  30:     0x7f9e209915ba - std[16495cdcf3c2a980]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[8b4b822bfe1350c5]::util::run_in_thread_with_globals<rustc_interface[8b4b822bfe1350c5]::util::run_in_thread_pool_with_globals<rustc_interface[8b4b822bfe1350c5]::interface::run_compiler<(), rustc_driver_impl[6fdcfad033932331]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  31:     0x7f9e2099136d - <std[16495cdcf3c2a980]::thread::lifecycle::spawn_unchecked<rustc_interface[8b4b822bfe1350c5]::util::run_in_thread_with_globals<rustc_interface[8b4b822bfe1350c5]::util::run_in_thread_pool_with_globals<rustc_interface[8b4b822bfe1350c5]::interface::run_compiler<(), rustc_driver_impl[6fdcfad033932331]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e500fd9f2ab8424]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f9e20995790 - <std[16495cdcf3c2a980]::sys::thread::unix::Thread>::new::thread_start
  33:     0x7f9e1a2981b9 - <unknown>
  34:     0x7f9e1a31d21c - <unknown>
  35:                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.98.0-nightly (4c9d2bfe4 2026-07-01) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck_root] type-checking `<impl at /tmp/icemaker_global_tempdir.zm1FldSVy35z/rustc_testrunner_tmpdir_reporting.BimMTowxrpho/mvce.rs:4:1: 4:30>::r#static`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors

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

@rustbot label +F-fn_delegation

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-fn_delegation`#![feature(fn_delegation)]`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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions