Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: not using infcx #139082

Open
matthiaskrgr opened this issue Mar 28, 2025 · 4 comments · May be fixed by #139124
Open

ICE: not using infcx #139082

matthiaskrgr opened this issue Mar 28, 2025 · 4 comments · May be fixed by #139124
Assignees
Labels
A-trait-objects Area: trait objects, vtable layout C-bug Category: This is a bug. F-trait_alias `#![feature(trait_alias)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 28, 2025

auto-reduced (treereduce-rust):

trait ReturnsVoidFn<T: Fn() -> ()> = Fn() -> r#Self;

type A<'a, > = Vec<&'a dyn ReturnsVoidFn<impl Sized + use<Self>>>;

original:

#![feature(trait_alias)]
trait ReturnsVoidFn<T: Fn() -> ()> = Fn() -> r#Self;

type A<'a, T: Fn() -> ()> = Vec<&'a dyn ReturnsVoidFn<impl Sized + use<Self>>>;

Version information

rustc 1.87.0-nightly (2a0602295 2025-03-28)
binary: rustc
commit-hash: 2a06022951893fe5b5384f8dbd75b4e6e3b5cee0
commit-date: 2025-03-28
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.1

Possibly related line of code:

// ```
//
// Since `'b` is not in scope on `Foo`, can't
// do anything here, ignore it.
}
Component::UnresolvedInferenceVariable(_) => bug!("not using infcx"),
}
}
}
GenericArgKind::Lifetime(r) => {
if !is_free_region(r) {

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

Program output

error: `Self` cannot be a raw identifier
 --> /tmp/icemaker_global_tempdir.gEOZ3yXcDzPR/rustc_testrunner_tmpdir_reporting.8WXvu1YxUMnu/mvce.rs:2:46
  |
2 | trait ReturnsVoidFn<T: Fn() -> ()> = Fn() -> r#Self;
  |                                              ^^^^^^

error[E0411]: cannot find type or const parameter `Self` in this scope
 --> /tmp/icemaker_global_tempdir.gEOZ3yXcDzPR/rustc_testrunner_tmpdir_reporting.8WXvu1YxUMnu/mvce.rs:4:59
  |
4 | type A<'a, > = Vec<&'a dyn ReturnsVoidFn<impl Sized + use<Self>>>;
  |      - `Self` not allowed in a type alias                 ^^^^ `Self` is only available in impls, traits, and type definitions

error[E0658]: trait aliases are experimental
 --> /tmp/icemaker_global_tempdir.gEOZ3yXcDzPR/rustc_testrunner_tmpdir_reporting.8WXvu1YxUMnu/mvce.rs:2:1
  |
2 | trait ReturnsVoidFn<T: Fn() -> ()> = Fn() -> r#Self;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information
  = help: add `#![feature(trait_alias)]` to the crate attributes to enable
  = note: this compiler was built on 2025-03-28; consider upgrading it if it is out of date

error[E0658]: `impl Trait` in type aliases is unstable
 --> /tmp/icemaker_global_tempdir.gEOZ3yXcDzPR/rustc_testrunner_tmpdir_reporting.8WXvu1YxUMnu/mvce.rs:4:42
  |
4 | type A<'a, > = Vec<&'a dyn ReturnsVoidFn<impl Sized + use<Self>>>;
  |                                          ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
  = note: this compiler was built on 2025-03-28; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.gEOZ3yXcDzPR/rustc_testrunner_tmpdir_reporting.8WXvu1YxUMnu/mvce.rs:4:67
  |
4 | type A<'a, > = Vec<&'a dyn ReturnsVoidFn<impl Sized + use<Self>>>;
  |                                                                   ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.gEOZ3yXcDzPR/rustc_testrunner_tmpdir_reporting.8WXvu1YxUMnu/mvce.rs`

error: internal compiler error: compiler/rustc_hir_analysis/src/outlives/utils.rs:129:66: not using infcx


thread 'rustc' panicked at compiler/rustc_hir_analysis/src/outlives/utils.rs:129:66:
Box<dyn Any>
stack backtrace:
   0:     0x7b3177277313 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hec1be6b515a4b985
   1:     0x7b3177a05d91 - core::fmt::write::h1a721e23ea933c95
   2:     0x7b3178e8da51 - std::io::Write::write_fmt::h8aaeee0f3c8d3f0a
   3:     0x7b3177277172 - std::sys::backtrace::BacktraceLock::print::h5669ce1c06d4f78b
   4:     0x7b3177279a2a - std::panicking::default_hook::{{closure}}::h266748ebbae7c4be
   5:     0x7b31772795af - std::panicking::default_hook::hc3bb6e6c093f4ea4
   6:     0x7b31762e39b0 - std[4597d80d7047b022]::panicking::update_hook::<alloc[772d3812010e97a3]::boxed::Box<rustc_driver_impl[1d133c6972a1a6b9]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7b317727a2a3 - std::panicking::rust_panic_with_hook::h51ac92c4d270e86c
   8:     0x7b3176322cc1 - std[4597d80d7047b022]::panicking::begin_panic::<rustc_errors[7964d5e4d9f7f11a]::ExplicitBug>::{closure#0}
   9:     0x7b3176316986 - std[4597d80d7047b022]::sys::backtrace::__rust_end_short_backtrace::<std[4597d80d7047b022]::panicking::begin_panic<rustc_errors[7964d5e4d9f7f11a]::ExplicitBug>::{closure#0}, !>
  10:     0x7b31763132c9 - std[4597d80d7047b022]::panicking::begin_panic::<rustc_errors[7964d5e4d9f7f11a]::ExplicitBug>
  11:     0x7b317632c681 - <rustc_errors[7964d5e4d9f7f11a]::diagnostic::BugAbort as rustc_errors[7964d5e4d9f7f11a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7b317696530a - rustc_middle[8492cbf8fcfbb736]::util::bug::opt_span_bug_fmt::<rustc_span[c4947a62e1591df3]::span_encoding::Span>::{closure#0}
  13:     0x7b3176940d5a - rustc_middle[8492cbf8fcfbb736]::ty::context::tls::with_opt::<rustc_middle[8492cbf8fcfbb736]::util::bug::opt_span_bug_fmt<rustc_span[c4947a62e1591df3]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7b3176940bcb - rustc_middle[8492cbf8fcfbb736]::ty::context::tls::with_context_opt::<rustc_middle[8492cbf8fcfbb736]::ty::context::tls::with_opt<rustc_middle[8492cbf8fcfbb736]::util::bug::opt_span_bug_fmt<rustc_span[c4947a62e1591df3]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7b3174465af0 - rustc_middle[8492cbf8fcfbb736]::util::bug::bug_fmt
  16:     0x7b317859831d - rustc_hir_analysis[ccce52f49be93bd3]::outlives::utils::insert_outlives_predicate
  17:     0x7b3177ebc75a - rustc_hir_analysis[ccce52f49be93bd3]::outlives::implicit_infer::insert_required_predicates_to_be_wf
  18:     0x7b3177ebe299 - rustc_hir_analysis[ccce52f49be93bd3]::outlives::inferred_outlives_crate
  19:     0x7b317880cce0 - rustc_query_impl[3289d2c66c00b6f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3289d2c66c00b6f8]::query_impl::inferred_outlives_crate::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 8usize]>>
  20:     0x7b31789bec84 - rustc_query_system[87ba3fee088a6fc4]::query::plumbing::try_execute_query::<rustc_query_impl[3289d2c66c00b6f8]::DynamicConfig<rustc_query_system[87ba3fee088a6fc4]::query::caches::SingleCache<rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[3289d2c66c00b6f8]::plumbing::QueryCtxt, false>
  21:     0x7b31789bd511 - rustc_query_impl[3289d2c66c00b6f8]::query_impl::inferred_outlives_crate::get_query_non_incr::__rust_end_short_backtrace
  22:     0x7b3177c7ce09 - rustc_query_impl[3289d2c66c00b6f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3289d2c66c00b6f8]::query_impl::inferred_outlives_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 16usize]>>
  23:     0x7b3177c7baf5 - rustc_query_system[87ba3fee088a6fc4]::query::plumbing::try_execute_query::<rustc_query_impl[3289d2c66c00b6f8]::DynamicConfig<rustc_query_system[87ba3fee088a6fc4]::query::caches::DefIdCache<rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[3289d2c66c00b6f8]::plumbing::QueryCtxt, false>
  24:     0x7b3177c7b522 - rustc_query_impl[3289d2c66c00b6f8]::query_impl::inferred_outlives_of::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7b3177c825dd - rustc_query_impl[3289d2c66c00b6f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3289d2c66c00b6f8]::query_impl::predicates_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 24usize]>>
  26:     0x7b3177c835e3 - rustc_query_system[87ba3fee088a6fc4]::query::plumbing::try_execute_query::<rustc_query_impl[3289d2c66c00b6f8]::DynamicConfig<rustc_query_system[87ba3fee088a6fc4]::query::caches::DefIdCache<rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[3289d2c66c00b6f8]::plumbing::QueryCtxt, false>
  27:     0x7b3177c82e42 - rustc_query_impl[3289d2c66c00b6f8]::query_impl::predicates_of::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7b3177ef4ff7 - <rustc_hir_analysis[ccce52f49be93bd3]::collect::CollectItemTypesVisitor as rustc_hir[ef5124c98fbfaebc]::intravisit::Visitor>::visit_item
  29:     0x7b3177eeaf23 - rustc_hir_analysis[ccce52f49be93bd3]::check::wfcheck::check_well_formed
  30:     0x7b3177eead2b - rustc_query_impl[3289d2c66c00b6f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3289d2c66c00b6f8]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 1usize]>>
  31:     0x7b3177eea5d4 - rustc_query_system[87ba3fee088a6fc4]::query::plumbing::try_execute_query::<rustc_query_impl[3289d2c66c00b6f8]::DynamicConfig<rustc_data_structures[44af7552550bcb5]::vec_cache::VecCache<rustc_span[c4947a62e1591df3]::def_id::LocalDefId, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[87ba3fee088a6fc4]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[3289d2c66c00b6f8]::plumbing::QueryCtxt, false>
  32:     0x7b3177eea0c3 - rustc_query_impl[3289d2c66c00b6f8]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7b3177ee7555 - rustc_hir_analysis[ccce52f49be93bd3]::check::wfcheck::check_mod_type_wf
  34:     0x7b3177ee7375 - rustc_query_impl[3289d2c66c00b6f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3289d2c66c00b6f8]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 1usize]>>
  35:     0x7b3178894a19 - rustc_query_system[87ba3fee088a6fc4]::query::plumbing::try_execute_query::<rustc_query_impl[3289d2c66c00b6f8]::DynamicConfig<rustc_query_system[87ba3fee088a6fc4]::query::caches::DefaultCache<rustc_span[c4947a62e1591df3]::def_id::LocalModDefId, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3289d2c66c00b6f8]::plumbing::QueryCtxt, false>
  36:     0x7b317889478a - rustc_query_impl[3289d2c66c00b6f8]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7b3177d3a697 - rustc_hir_analysis[ccce52f49be93bd3]::check_crate
  38:     0x7b3178341a23 - rustc_interface[838c222bb47cac2d]::passes::run_required_analyses
  39:     0x7b317841fc9e - rustc_interface[838c222bb47cac2d]::passes::analysis
  40:     0x7b317841fc6d - rustc_query_impl[3289d2c66c00b6f8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3289d2c66c00b6f8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 0usize]>>
  41:     0x7b31789bc3fd - rustc_query_system[87ba3fee088a6fc4]::query::plumbing::try_execute_query::<rustc_query_impl[3289d2c66c00b6f8]::DynamicConfig<rustc_query_system[87ba3fee088a6fc4]::query::caches::SingleCache<rustc_middle[8492cbf8fcfbb736]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[3289d2c66c00b6f8]::plumbing::QueryCtxt, false>
  42:     0x7b31789bc0f8 - rustc_query_impl[3289d2c66c00b6f8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:     0x7b3178cc874d - rustc_interface[838c222bb47cac2d]::passes::create_and_enter_global_ctxt::<core[d013d7c9d10039cf]::option::Option<rustc_interface[838c222bb47cac2d]::queries::Linker>, rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  44:     0x7b3178b651aa - rustc_interface[838c222bb47cac2d]::interface::run_compiler::<(), rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}>::{closure#1}
  45:     0x7b3178978148 - std[4597d80d7047b022]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[838c222bb47cac2d]::util::run_in_thread_with_globals<rustc_interface[838c222bb47cac2d]::util::run_in_thread_pool_with_globals<rustc_interface[838c222bb47cac2d]::interface::run_compiler<(), rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  46:     0x7b3178978a34 - <<std[4597d80d7047b022]::thread::Builder>::spawn_unchecked_<rustc_interface[838c222bb47cac2d]::util::run_in_thread_with_globals<rustc_interface[838c222bb47cac2d]::util::run_in_thread_pool_with_globals<rustc_interface[838c222bb47cac2d]::interface::run_compiler<(), rustc_driver_impl[1d133c6972a1a6b9]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d013d7c9d10039cf]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  47:     0x7b3178979e37 - std::sys::pal::unix::thread::Thread::new::thread_start::h287c1faba384eaa8
  48:     0x7b31728a370a - <unknown>
  49:     0x7b3172927aac - <unknown>
  50:                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.87.0-nightly (2a0602295 2025-03-28) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [inferred_outlives_crate] computing the inferred outlives-predicates for items in this crate
#1 [inferred_outlives_of] computing inferred outlives-predicates of `A`
#2 [predicates_of] computing predicates of `A`
#3 [check_well_formed] checking that `A` is well-formed
#4 [check_mod_type_wf] checking that types are well-formed in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors

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

@rustbot label +F-trait_alias

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 28, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-trait_alias `#![feature(trait_alias)]` labels Mar 28, 2025
@matthiaskrgr
Copy link
Member Author

smaller

trait B<C> = Fn() -> Self;
type D<'a> = Vec<&'a dyn B<impl>>;

@matthiaskrgr
Copy link
Member Author

seems to bisect to #133830

@moxian
Copy link
Contributor

moxian commented Mar 28, 2025

@rustbot label: +T-types -T-compiler +S-has-mcve +S-has-bisection +F-type_alias_impl_trait +A-trait-objects -needs-triage

@rustbot rustbot added A-trait-objects Area: trait objects, vtable layout F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-types Relevant to the types team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 28, 2025
@xtexx
Copy link
Contributor

xtexx commented Mar 29, 2025

@rustbot claim

xtexx added a commit to xtexx/rust that referenced this issue Mar 30, 2025
xtexx added a commit to xtexx/rust that referenced this issue Mar 30, 2025
Fixes rust-lang#139082.

Emits an error when `Self` is found in the projection bounds of a trait
object. In type aliases, `Self` has no meaning, so `type A = &'static
dyn B` where `trait B = Fn() -> Self` will expands to `type A = &'static
Fn() -> Self` which is illegal, causing the region solver to bail out
when hitting the uninferred Self.

Bug: rust-lang#139082
Signed-off-by: xtex <xtexchooser@duck.com>
xtexx added a commit to xtexx/rust that referenced this issue Mar 30, 2025
Fixes rust-lang#139082.

Emits an error when `Self` is found in the projection bounds of a trait
object. In type aliases, `Self` has no meaning, so `type A = &'static
dyn B` where `trait B = Fn() -> Self` will expands to `type A = &'static
Fn() -> Self` which is illegal, causing the region solver to bail out
when hitting the uninferred Self.

Bug: rust-lang#139082
Signed-off-by: xtex <xtexchooser@duck.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-objects Area: trait objects, vtable layout C-bug Category: This is a bug. F-trait_alias `#![feature(trait_alias)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants