Skip to content

ICE: Unexpected const bound var #131668

Closed as not planned
Closed as not planned
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(generic_associated_types_extended)]
fn make_static<'a, 'b, T: ?Sized>(x: &'a T) -> &'b T {
    trait A<T>: B<T = T> {}

    trait B {
        type Y<const N: i16>;
    }

    struct Erase<T: ?Sized + B>(T::T);

    Erase::<dyn for<'c> A<&'c T>>(Waker::noop()).0
}

original:

fn make_static<'a, 'b, T: ?Sized>(x: &'a T) -> &'b T {
    trait A<T>: B<T = T> {}

    trait B {
        type Y<const N: i16>;
    }

    struct Erase<T: ?Sized + B>(T::T);

    Erase::<dyn for<'c> A<&'c T>>(Waker::noop()).0
}

fn main() {
    let s = {
        make_static(String::from("hello").as_str())
    };

    for example_member in EXAMPLE_MAP {
        (example_member.member2)(&port);
    }
}

Version information

rustc 1.83.0-nightly (36780360b 2024-10-13)
binary: rustc
commit-hash: 36780360b62320a61e2234b17ec600e8e4785509
commit-date: 2024-10-13
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.1

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(generic_associated_types_extended)

Program output

error[E0433]: failed to resolve: use of undeclared type `Waker`
  --> /tmp/icemaker_global_tempdir.IaSg5fALVGp5/rustc_testrunner_tmpdir_reporting.lckb7GfbLyNa/mvce.rs:10:35
   |
10 |     Erase::<dyn for<'c> A<&'c T>>(Waker::noop()).0
   |                                   ^^^^^ use of undeclared type `Waker`
   |
help: consider importing this struct
   |
1  + use std::task::Waker;
   |

warning: the feature `generic_associated_types_extended` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:9
  |
1 | feature(generic_associated_types_extended)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #95451 <https://github.com/rust-lang/rust/issues/95451> for more information
  = note: `#[warn(incomplete_features)]` on by default

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

error[E0220]: associated type `T` not found for `B`
 --> /tmp/icemaker_global_tempdir.IaSg5fALVGp5/rustc_testrunner_tmpdir_reporting.lckb7GfbLyNa/mvce.rs:2:19
  |
2 |     trait A<T>: B<T = T> {}
  |                   ^ help: there is an associated type with a similar name: `Y`

error[E0220]: associated type `T` not found for `T`
 --> /tmp/icemaker_global_tempdir.IaSg5fALVGp5/rustc_testrunner_tmpdir_reporting.lckb7GfbLyNa/mvce.rs:8:36
  |
8 |     struct Erase<T: ?Sized + B>(T::T);
  |                                    ^ there is a similarly named associated type `Y` in the trait `B`
  |
help: change the associated type name to use `Y` from `B`
  |
8 |     struct Erase<T: ?Sized + B>(T::Y);
  |                                    ~

error[E0191]: the value of the associated type `Y` in `B` must be specified
  --> /tmp/icemaker_global_tempdir.IaSg5fALVGp5/rustc_testrunner_tmpdir_reporting.lckb7GfbLyNa/mvce.rs:10:17
   |
5  |         type Y<const N: i16>;
   |         -------------------- `Y` defined here
...
10 |     Erase::<dyn for<'c> A<&'c T>>(Waker::noop()).0
   |                 ^^^^^^^^^^^^^^^^ help: specify the associated type: `for<'c> A<&'c T, Y = Type>`

error: internal compiler error: compiler/rustc_infer/src/infer/freshen.rs:178:17: unexpected const ^0

thread 'rustc' panicked at compiler/rustc_infer/src/infer/freshen.rs:178:17:
Box<dyn Any>
stack backtrace:
   0:     0x778ff8bd55ca - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hf200c11c9fce97cd
   1:     0x778ff94034a6 - core::fmt::write::h44e2a25b26982225
   2:     0x778ffa600991 - std::io::Write::write_fmt::h9aae7daacab8c281
   3:     0x778ff8bd5422 - std::sys::backtrace::BacktraceLock::print::hbde90d84d6c34a2f
   4:     0x778ff8bd78f6 - std::panicking::default_hook::{{closure}}::h5f9a7466f6d55fa4
   5:     0x778ff8bd7740 - std::panicking::default_hook::h889bcdd61427cfea
   6:     0x778ff7c2ccbf - std[dad1c9cd4209e29f]::panicking::update_hook::<alloc[b36bac19b723d86a]::boxed::Box<rustc_driver_impl[b4430c9a2ffdc2d8]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x778ff8bd8008 - std::panicking::rust_panic_with_hook::h24c51a3a03576cce
   8:     0x778ff7c66681 - std[dad1c9cd4209e29f]::panicking::begin_panic::<rustc_errors[44cef3b94fe7d510]::ExplicitBug>::{closure#0}
   9:     0x778ff7c59726 - std[dad1c9cd4209e29f]::sys::backtrace::__rust_end_short_backtrace::<std[dad1c9cd4209e29f]::panicking::begin_panic<rustc_errors[44cef3b94fe7d510]::ExplicitBug>::{closure#0}, !>
  10:     0x778ff7c596ee - std[dad1c9cd4209e29f]::panicking::begin_panic::<rustc_errors[44cef3b94fe7d510]::ExplicitBug>
  11:     0x778ff7c6fdd1 - <rustc_errors[44cef3b94fe7d510]::diagnostic::BugAbort as rustc_errors[44cef3b94fe7d510]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x778ff82cb414 - rustc_middle[f935b324f13658c5]::util::bug::opt_span_bug_fmt::<rustc_span[2f3a5b6ef5575c7c]::span_encoding::Span>::{closure#0}
  13:     0x778ff82b139a - rustc_middle[f935b324f13658c5]::ty::context::tls::with_opt::<rustc_middle[f935b324f13658c5]::util::bug::opt_span_bug_fmt<rustc_span[2f3a5b6ef5575c7c]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x778ff82b122b - rustc_middle[f935b324f13658c5]::ty::context::tls::with_context_opt::<rustc_middle[f935b324f13658c5]::ty::context::tls::with_opt<rustc_middle[f935b324f13658c5]::util::bug::opt_span_bug_fmt<rustc_span[2f3a5b6ef5575c7c]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x778ff5816d20 - rustc_middle[f935b324f13658c5]::util::bug::bug_fmt
  16:     0x778ffa173e3b - <rustc_infer[7d93aa896a2a41a3]::infer::freshen::TypeFreshener as rustc_type_ir[70a71db6b5d2d52b]::fold::TypeFolder<rustc_middle[f935b324f13658c5]::ty::context::TyCtxt>>::fold_const
  17:     0x778ff9538808 - <rustc_middle[f935b324f13658c5]::ty::Ty as rustc_type_ir[70a71db6b5d2d52b]::fold::TypeSuperFoldable<rustc_middle[f935b324f13658c5]::ty::context::TyCtxt>>::try_super_fold_with::<rustc_infer[7d93aa896a2a41a3]::infer::freshen::TypeFreshener>
  18:     0x778ffa094e1f - <rustc_trait_selection[1966c28e1c67d278]::traits::select::SelectionContext>::poly_select::{closure#0}
  19:     0x778ff592134d - <rustc_trait_selection[1966c28e1c67d278]::traits::fulfill::FulfillProcessor>::process_trait_obligation
  20:     0x778ff58e66f5 - <rustc_trait_selection[1966c28e1c67d278]::traits::fulfill::FulfillProcessor as rustc_data_structures[4ff922b557bd2789]::obligation_forest::ObligationProcessor>::process_obligation
  21:     0x778ff940f152 - <rustc_data_structures[4ff922b557bd2789]::obligation_forest::ObligationForest<rustc_trait_selection[1966c28e1c67d278]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[1966c28e1c67d278]::traits::fulfill::FulfillProcessor>
  22:     0x778ff5b74f14 - <rustc_hir_typeck[968d3c965f96f2db]::fn_ctxt::FnCtxt>::confirm_builtin_call
  23:     0x778ffa067174 - <rustc_hir_typeck[968d3c965f96f2db]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:     0x778ff94bfc8b - <rustc_hir_typeck[968d3c965f96f2db]::fn_ctxt::FnCtxt>::check_field
  25:     0x778ffa06879f - <rustc_hir_typeck[968d3c965f96f2db]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  26:     0x778ffa06090a - <rustc_hir_typeck[968d3c965f96f2db]::fn_ctxt::FnCtxt>::check_block_with_expected
  27:     0x778ffa067aa3 - <rustc_hir_typeck[968d3c965f96f2db]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x778ff9cef066 - rustc_hir_typeck[968d3c965f96f2db]::check::check_fn
  29:     0x778ff9ce3e8b - rustc_hir_typeck[968d3c965f96f2db]::typeck
  30:     0x778ff9ce3807 - rustc_query_impl[d805d7aa85f0ab3c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d805d7aa85f0ab3c]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f935b324f13658c5]::query::erase::Erased<[u8; 8usize]>>
  31:     0x778ff986507a - rustc_query_system[d9c2e7afa5df5fa1]::query::plumbing::try_execute_query::<rustc_query_impl[d805d7aa85f0ab3c]::DynamicConfig<rustc_query_system[d9c2e7afa5df5fa1]::query::caches::VecCache<rustc_span[2f3a5b6ef5575c7c]::def_id::LocalDefId, rustc_middle[f935b324f13658c5]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d805d7aa85f0ab3c]::plumbing::QueryCtxt, false>
  32:     0x778ff9863ddb - rustc_query_impl[d805d7aa85f0ab3c]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  33:     0x778ff9863a61 - <rustc_middle[f935b324f13658c5]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[9224370b9464c813]::check_crate::{closure#4}>::{closure#0}
  34:     0x778ff986199b - rustc_hir_analysis[9224370b9464c813]::check_crate
  35:     0x778ff985e3d7 - rustc_interface[2d1024fbde9086d5]::passes::run_required_analyses
  36:     0x778ffa28585e - rustc_interface[2d1024fbde9086d5]::passes::analysis
  37:     0x778ffa285831 - rustc_query_impl[d805d7aa85f0ab3c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d805d7aa85f0ab3c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f935b324f13658c5]::query::erase::Erased<[u8; 1usize]>>
  38:     0x778ffa2c76ee - rustc_query_system[d9c2e7afa5df5fa1]::query::plumbing::try_execute_query::<rustc_query_impl[d805d7aa85f0ab3c]::DynamicConfig<rustc_query_system[d9c2e7afa5df5fa1]::query::caches::SingleCache<rustc_middle[f935b324f13658c5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[d805d7aa85f0ab3c]::plumbing::QueryCtxt, false>
  39:     0x778ffa2c73cf - rustc_query_impl[d805d7aa85f0ab3c]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x778ffa169fdb - rustc_interface[2d1024fbde9086d5]::interface::run_compiler::<core[cecbbef79298d09e]::result::Result<(), rustc_span[2f3a5b6ef5575c7c]::ErrorGuaranteed>, rustc_driver_impl[b4430c9a2ffdc2d8]::run_compiler::{closure#0}>::{closure#1}
  41:     0x778ffa248814 - std[dad1c9cd4209e29f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[2d1024fbde9086d5]::util::run_in_thread_with_globals<rustc_interface[2d1024fbde9086d5]::util::run_in_thread_pool_with_globals<rustc_interface[2d1024fbde9086d5]::interface::run_compiler<core[cecbbef79298d09e]::result::Result<(), rustc_span[2f3a5b6ef5575c7c]::ErrorGuaranteed>, rustc_driver_impl[b4430c9a2ffdc2d8]::run_compiler::{closure#0}>::{closure#1}, core[cecbbef79298d09e]::result::Result<(), rustc_span[2f3a5b6ef5575c7c]::ErrorGuaranteed>>::{closure#0}, core[cecbbef79298d09e]::result::Result<(), rustc_span[2f3a5b6ef5575c7c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cecbbef79298d09e]::result::Result<(), rustc_span[2f3a5b6ef5575c7c]::ErrorGuaranteed>>
  42:     0x778ffa248c28 - <<std[dad1c9cd4209e29f]::thread::Builder>::spawn_unchecked_<rustc_interface[2d1024fbde9086d5]::util::run_in_thread_with_globals<rustc_interface[2d1024fbde9086d5]::util::run_in_thread_pool_with_globals<rustc_interface[2d1024fbde9086d5]::interface::run_compiler<core[cecbbef79298d09e]::result::Result<(), rustc_span[2f3a5b6ef5575c7c]::ErrorGuaranteed>, rustc_driver_impl[b4430c9a2ffdc2d8]::run_compiler::{closure#0}>::{closure#1}, core[cecbbef79298d09e]::result::Result<(), rustc_span[2f3a5b6ef5575c7c]::ErrorGuaranteed>>::{closure#0}, core[cecbbef79298d09e]::result::Result<(), rustc_span[2f3a5b6ef5575c7c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cecbbef79298d09e]::result::Result<(), rustc_span[2f3a5b6ef5575c7c]::ErrorGuaranteed>>::{closure#1} as core[cecbbef79298d09e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x778ffa2496eb - std::sys::pal::unix::thread::Thread::new::thread_start::he87f3e0d5f9c1b15
  44:     0x778ffb95739d - <unknown>
  45:     0x778ffb9dc49c - <unknown>
  46:                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.83.0-nightly (36780360b 2024-10-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(generic_associated_types_extended) -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck] type-checking `make_static`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted

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

@rustbot label +F-generic_associated_types_extended

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)C-bugCategory: This is a bug.F-generic_associated_types_extended`#![feature(generic_associated_types_extended)]`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