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: Unexpected node Synthetic #122908

Closed
matthiaskrgr opened this issue Mar 22, 2024 · 2 comments · Fixed by #125958
Closed

ICE: Unexpected node Synthetic #122908

matthiaskrgr opened this issue Mar 22, 2024 · 2 comments · Fixed by #125958
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

trait Trait<const module_path: Trait = bar> {
    async fn handle<F>(slf: &F) {}
}

original:

trait Trait<const module_path: Trait = bar> {
    async fn handle<F>(slf: &F)
where
    F: Fn(&()) -> &mut (dyn Future<Output = ()> + Unpin),
{
    (slf)(&()).await;
}
}

fn main() {}

Version information

rustc 1.79.0-nightly (b3df0d7e5 2024-03-22)
binary: rustc
commit-hash: b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87
commit-date: 2024-03-22
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zunstable-options --edition=2024

Program output

error[E0425]: cannot find value `bar` in this scope
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:1:40
  |
1 | trait Trait<const module_path: Trait = bar> {
  |                                        ^^^ not found in this scope

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

error[E0391]: cycle detected when computing type of `Trait::module_path`
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:1:32
  |
1 | trait Trait<const module_path: Trait = bar> {
  |                                ^^^^^
  |
  = note: ...which immediately requires computing type of `Trait::module_path` again
note: cycle used when computing explicit predicates of trait `Trait`
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:1:1
  |
1 | trait Trait<const module_path: Trait = bar> {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error[E0391]: cycle detected when computing type of `Trait::module_path`
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:1:13
  |
1 | trait Trait<const module_path: Trait = bar> {
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: ...which immediately requires computing type of `Trait::module_path` again
note: cycle used when computing explicit predicates of trait `Trait`
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:1:1
  |
1 | trait Trait<const module_path: Trait = bar> {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error[E0038]: the trait `Trait` cannot be made into an object
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:1:32
  |
1 | trait Trait<const module_path: Trait = bar> {
  |                                ^^^^^ `Trait` cannot be made into an object
  |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:2:14
  |
1 | trait Trait<const module_path: Trait = bar> {
  |       ----- this trait cannot be made into an object...
2 |     async fn handle<F>(slf: &F) {}
  |              ^^^^^^ ...because associated function `handle` has no `self` parameter
help: consider turning `handle` into a method by giving it a `&self` argument
  |
2 |     async fn handle<F>(&self, slf: &F) {}
  |                        ++++++
help: alternatively, consider constraining `handle` so it does not apply to trait objects
  |
2 |     async fn handle<F>(slf: &F) where Self: Sized {}
  |                                 +++++++++++++++++

error[E0038]: the trait `Trait` cannot be made into an object
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:1:13
  |
1 | trait Trait<const module_path: Trait = bar> {
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
  |
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:2:14
  |
1 | trait Trait<const module_path: Trait = bar> {
  |       ----- this trait cannot be made into an object...
2 |     async fn handle<F>(slf: &F) {}
  |              ^^^^^^ ...because associated function `handle` has no `self` parameter
help: consider turning `handle` into a method by giving it a `&self` argument
  |
2 |     async fn handle<F>(&self, slf: &F) {}
  |                        ++++++
help: alternatively, consider constraining `handle` so it does not apply to trait objects
  |
2 |     async fn handle<F>(slf: &F) where Self: Sized {}
  |                                 +++++++++++++++++

error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:1:32
  |
1 | trait Trait<const module_path: Trait = bar> {
  |                                ^^^^^
  |
  = note: the only supported types are integers, `bool` and `char`

error: internal compiler error: compiler/rustc_hir_analysis/src/hir_wf_check.rs:176:25: Unexpected node Synthetic

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_wf_check.rs:176:25:
Box<dyn Any>
stack backtrace:
   0:     0x7364225c2fa5 - std::backtrace_rs::backtrace::libunwind::trace::h4515e3e00f57996f
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7364225c2fa5 - std::backtrace_rs::backtrace::trace_unsynchronized::h1e64ac1112175e4e
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7364225c2fa5 - std::sys_common::backtrace::_print_fmt::h182160b5ad873150
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7364225c2fa5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h432843f19f8b2b6d
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x736422613feb - core::fmt::rt::Argument::fmt::hb59bbd21accf1885
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/core/src/fmt/rt.rs:142:9
   5:     0x736422613feb - core::fmt::write::haf243cf4605e411d
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/core/src/fmt/mod.rs:1153:17
   6:     0x7364225b7d3f - std::io::Write::write_fmt::hd8c8c68b4f5b8f11
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/std/src/io/mod.rs:1843:15
   7:     0x7364225c2d7e - std::sys_common::backtrace::_print::h0ec933d6103e5515
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7364225c2d7e - std::sys_common::backtrace::print::h55136fa64edb86e6
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7364225c59f9 - std::panicking::default_hook::{{closure}}::h28cbeefc01b40f52
  10:     0x7364225c5763 - std::panicking::default_hook::h15e904210c67a3ca
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/std/src/panicking.rs:292:9
  11:     0x73641edcb6bf - std[48784e9e46568672]::panicking::update_hook::<alloc[590c7545ac68a568]::boxed::Box<rustc_driver_impl[9e9e6466696ec967]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7364225c6150 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::had664932fcaf7f86
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/alloc/src/boxed.rs:2029:9
  13:     0x7364225c6150 - std::panicking::rust_panic_with_hook::h9f23cc8a1f418825
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/std/src/panicking.rs:783:13
  14:     0x73641edfbaa4 - std[48784e9e46568672]::panicking::begin_panic::<rustc_errors[85c3c7ac8d959a53]::ExplicitBug>::{closure#0}
  15:     0x73641edf86f6 - std[48784e9e46568672]::sys_common::backtrace::__rust_end_short_backtrace::<std[48784e9e46568672]::panicking::begin_panic<rustc_errors[85c3c7ac8d959a53]::ExplicitBug>::{closure#0}, !>
  16:     0x73641edf3c06 - std[48784e9e46568672]::panicking::begin_panic::<rustc_errors[85c3c7ac8d959a53]::ExplicitBug>
  17:     0x73641ee04f31 - <rustc_errors[85c3c7ac8d959a53]::diagnostic::BugAbort as rustc_errors[85c3c7ac8d959a53]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x73641f29754c - rustc_middle[cfd7f582085b2efd]::util::bug::opt_span_bug_fmt::<rustc_span[9e6cb2d6f72e9bb4]::span_encoding::Span>::{closure#0}
  19:     0x73641f27abca - rustc_middle[cfd7f582085b2efd]::ty::context::tls::with_opt::<rustc_middle[cfd7f582085b2efd]::util::bug::opt_span_bug_fmt<rustc_span[9e6cb2d6f72e9bb4]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x73641f27aa4b - rustc_middle[cfd7f582085b2efd]::ty::context::tls::with_context_opt::<rustc_middle[cfd7f582085b2efd]::ty::context::tls::with_opt<rustc_middle[cfd7f582085b2efd]::util::bug::opt_span_bug_fmt<rustc_span[9e6cb2d6f72e9bb4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x73641ce50b50 - rustc_middle[cfd7f582085b2efd]::util::bug::bug_fmt
  22:     0x73641ef048aa - rustc_hir_analysis[595b5ec1edcfd0c3]::hir_wf_check::diagnostic_hir_wf_check
  23:     0x73641f60bd64 - rustc_query_impl[82a63e1d7cdec9a7]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[82a63e1d7cdec9a7]::query_impl::diagnostic_hir_wf_check::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cfd7f582085b2efd]::query::erase::Erased<[u8; 8usize]>>
  24:     0x73641f5f02cb - <rustc_query_impl[82a63e1d7cdec9a7]::query_impl::diagnostic_hir_wf_check::dynamic_query::{closure#2} as core[b4a1350c838fc0f9]::ops::function::FnOnce<(rustc_middle[cfd7f582085b2efd]::ty::context::TyCtxt, (rustc_middle[cfd7f582085b2efd]::ty::predicate::Predicate, rustc_middle[cfd7f582085b2efd]::traits::WellFormedLoc))>>::call_once
  25:     0x73641f571f4b - rustc_query_system[ee3912bf2a9f33a7]::query::plumbing::try_execute_query::<rustc_query_impl[82a63e1d7cdec9a7]::DynamicConfig<rustc_query_system[ee3912bf2a9f33a7]::query::caches::DefaultCache<(rustc_middle[cfd7f582085b2efd]::ty::predicate::Predicate, rustc_middle[cfd7f582085b2efd]::traits::WellFormedLoc), rustc_middle[cfd7f582085b2efd]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[82a63e1d7cdec9a7]::plumbing::QueryCtxt, false>
  26:     0x73641f636410 - rustc_query_impl[82a63e1d7cdec9a7]::query_impl::diagnostic_hir_wf_check::get_query_non_incr::__rust_end_short_backtrace
  27:     0x73641f8fe7ae - <rustc_infer[be9aceac34789818]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[dc9d16cead07ba55]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
  28:     0x73641f912571 - <rustc_infer[be9aceac34789818]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[dc9d16cead07ba55]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
  29:     0x73641f8fbd6d - <rustc_infer[be9aceac34789818]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[dc9d16cead07ba55]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  30:     0x736420849cab - rustc_hir_analysis[595b5ec1edcfd0c3]::check::wfcheck::check_associated_item
  31:     0x73642085b1d4 - rustc_hir_analysis[595b5ec1edcfd0c3]::check::wfcheck::check_well_formed
  32:     0x736420857b07 - rustc_query_impl[82a63e1d7cdec9a7]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[82a63e1d7cdec9a7]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cfd7f582085b2efd]::query::erase::Erased<[u8; 1usize]>>
  33:     0x736420857280 - rustc_query_system[ee3912bf2a9f33a7]::query::plumbing::try_execute_query::<rustc_query_impl[82a63e1d7cdec9a7]::DynamicConfig<rustc_query_system[ee3912bf2a9f33a7]::query::caches::VecCache<rustc_hir[a67f1a97fc26ff83]::hir_id::OwnerId, rustc_middle[cfd7f582085b2efd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[82a63e1d7cdec9a7]::plumbing::QueryCtxt, false>
  34:     0x736420856fff - rustc_query_impl[82a63e1d7cdec9a7]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  35:     0x736420856f50 - <rustc_middle[cfd7f582085b2efd]::hir::ModuleItems>::par_trait_items::<rustc_hir_analysis[595b5ec1edcfd0c3]::check::wfcheck::check_mod_type_wf::{closure#2}>::{closure#0}
  36:     0x73642085521e - rustc_hir_analysis[595b5ec1edcfd0c3]::check::wfcheck::check_mod_type_wf
  37:     0x736420854d61 - rustc_query_impl[82a63e1d7cdec9a7]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[82a63e1d7cdec9a7]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cfd7f582085b2efd]::query::erase::Erased<[u8; 1usize]>>
  38:     0x736420cc2930 - rustc_query_system[ee3912bf2a9f33a7]::query::plumbing::try_execute_query::<rustc_query_impl[82a63e1d7cdec9a7]::DynamicConfig<rustc_query_system[ee3912bf2a9f33a7]::query::caches::DefaultCache<rustc_span[9e6cb2d6f72e9bb4]::def_id::LocalModDefId, rustc_middle[cfd7f582085b2efd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[82a63e1d7cdec9a7]::plumbing::QueryCtxt, false>
  39:     0x736420cc26db - rustc_query_impl[82a63e1d7cdec9a7]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7364203f907b - rustc_hir_analysis[595b5ec1edcfd0c3]::check_crate
  41:     0x7364206a02ea - rustc_interface[7ddcde71cf02e108]::passes::analysis
  42:     0x73642069fe51 - rustc_query_impl[82a63e1d7cdec9a7]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[82a63e1d7cdec9a7]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cfd7f582085b2efd]::query::erase::Erased<[u8; 1usize]>>
  43:     0x736420feb4a5 - rustc_query_system[ee3912bf2a9f33a7]::query::plumbing::try_execute_query::<rustc_query_impl[82a63e1d7cdec9a7]::DynamicConfig<rustc_query_system[ee3912bf2a9f33a7]::query::caches::SingleCache<rustc_middle[cfd7f582085b2efd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[82a63e1d7cdec9a7]::plumbing::QueryCtxt, false>
  44:     0x736420feb209 - rustc_query_impl[82a63e1d7cdec9a7]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  45:     0x736420e870d9 - rustc_interface[7ddcde71cf02e108]::interface::run_compiler::<core[b4a1350c838fc0f9]::result::Result<(), rustc_span[9e6cb2d6f72e9bb4]::ErrorGuaranteed>, rustc_driver_impl[9e9e6466696ec967]::run_compiler::{closure#0}>::{closure#0}
  46:     0x736420f52399 - std[48784e9e46568672]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7ddcde71cf02e108]::util::run_in_thread_with_globals<rustc_interface[7ddcde71cf02e108]::util::run_in_thread_pool_with_globals<rustc_interface[7ddcde71cf02e108]::interface::run_compiler<core[b4a1350c838fc0f9]::result::Result<(), rustc_span[9e6cb2d6f72e9bb4]::ErrorGuaranteed>, rustc_driver_impl[9e9e6466696ec967]::run_compiler::{closure#0}>::{closure#0}, core[b4a1350c838fc0f9]::result::Result<(), rustc_span[9e6cb2d6f72e9bb4]::ErrorGuaranteed>>::{closure#0}, core[b4a1350c838fc0f9]::result::Result<(), rustc_span[9e6cb2d6f72e9bb4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b4a1350c838fc0f9]::result::Result<(), rustc_span[9e6cb2d6f72e9bb4]::ErrorGuaranteed>>
  47:     0x736420f521c6 - <<std[48784e9e46568672]::thread::Builder>::spawn_unchecked_<rustc_interface[7ddcde71cf02e108]::util::run_in_thread_with_globals<rustc_interface[7ddcde71cf02e108]::util::run_in_thread_pool_with_globals<rustc_interface[7ddcde71cf02e108]::interface::run_compiler<core[b4a1350c838fc0f9]::result::Result<(), rustc_span[9e6cb2d6f72e9bb4]::ErrorGuaranteed>, rustc_driver_impl[9e9e6466696ec967]::run_compiler::{closure#0}>::{closure#0}, core[b4a1350c838fc0f9]::result::Result<(), rustc_span[9e6cb2d6f72e9bb4]::ErrorGuaranteed>>::{closure#0}, core[b4a1350c838fc0f9]::result::Result<(), rustc_span[9e6cb2d6f72e9bb4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b4a1350c838fc0f9]::result::Result<(), rustc_span[9e6cb2d6f72e9bb4]::ErrorGuaranteed>>::{closure#1} as core[b4a1350c838fc0f9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7364225cf919 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3e016c41180ed802
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/alloc/src/boxed.rs:2015:9
  49:     0x7364225cf919 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcf0716ba35a33b0c
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/alloc/src/boxed.rs:2015:9
  50:     0x7364225cf919 - std::sys::pal::unix::thread::Thread::new::thread_start::hd585680968d21553
                               at /rustc/b3df0d7e5ef5f7dbeeca3fb289c65680ad013f87/library/std/src/sys/pal/unix/thread.rs:108:17
  51:     0x73642236f55a - <unknown>
  52:     0x7364223eca3c - <unknown>
  53:                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: rustc 1.79.0-nightly (b3df0d7e5 2024-03-22) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unstable-options -Z dump-mir-dir=dir

query stack during panic:
#0 [diagnostic_hir_wf_check] performing HIR wf-checking for predicate `Binder { value: ObjectSafe(DefId(0:3 ~ mvce[230a]::Trait)), bound_vars: [] }` at item `Ty(DefId(0:12 ~ mvce[230a]::Trait::{synthetic#0}))`
#1 [check_well_formed] checking that `Trait::handle` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error[E0782]: trait objects must include the `dyn` keyword
 --> /tmp/icemaker_global_tempdir.pLv5S1PJhcgC/rustc_testrunner_tmpdir_reporting.vqm2wcW7QHJ8/mvce.rs:1:32
  |
1 | trait Trait<const module_path: Trait = bar> {
  |                                ^^^^^
  |
help: add `dyn` keyword before this trait
  |
1 | trait Trait<const module_path: dyn Trait = bar> {
  |                                +++

error: aborting due to 9 previous errors

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Mar 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 22, 2024
@matthiaskrgr
Copy link
Member Author

#122027 cc @compiler-errors

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 23, 2024
@cushionbadak
Copy link

slightly more reduced:

trait Trait<const N: Trait = bar> {
    async fn a() {}
}

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 5, 2024
Remove the `ty` field from type system `Const`s

Fixes rust-lang#125556
Fixes rust-lang#122908

Part of the work on `adt_const_params`/`generic_const_param_types`/`min_generic_const_exprs`/generally making the compiler nicer. cc rust-lang/project-const-generics#44

Please review commit-by-commit otherwise I wasted a lot of time not just squashing this into a giant mess (and also it'll be SO much nicer because theres a lot of fluff changes mixed in with other more careful changes if looking via File Changes

---

Why do this?
- The `ty` field keeps causing ICEs and weird behaviour due to it either being treated as "part of the const" or it being forgotten about leading to ICEs.
- As we move forward with `adt_const_params` and a potential `min_generic_const_exprs` it's going to become more complex to actually lower the correct `Ty<'tcx>`
- It muddles the idea behind how we check `Const` arguments have the correct type. By having the `ty` field it may seem like we ought to be relating it when we relate two types, or that its generally important information about the `Const`.
- Brings the compiler more in line with `a-mir-formality` as that also tracks the type of type system `Const`s via `ConstArgHasType` bounds in the env instead of on the `Const` itself.
- A lot of stuff is a lot nicer when you dont have to pass around the type of a const lol. Everywhere we construct `Const` is now significantly nicer 😅

See rust-lang#125671's description for some more information about the `ty` field

---

General summary of changes in this PR:

- Add `Ty` to `ConstKind::Value` as otherwise there is no way to implement `ConstArgHasType` to ensure that const arguments are correctly typed for the parameter when we stop creating anon consts for all const args. It's also just incredibly difficult/annoying to thread the correct `Ty` around to a bunch of ctfe functions otherwise.
-  Fully implement `ConstArgHasType` in both the old and new solver. Since it now has no reliance on the `ty` field it serves its originally intended purpose of being able to act as a double check that trait vs impls have correctly typed const parameters. It also will now be able to be responsible for checking types of const arguments to parameters under `min_generic_const_exprs`.
- Add `Ty` to `mir::Const::Ty`. I dont have a great understanding of why mir constants are setup like this to be honest. Regardless they need to be able to determine the type of the const and the easiest way to make this happen was to simply store the `Ty` along side the `ty::Const`. Maybe we can do better here in the future but I'd have to spend way more time looking at everywhere we use `mir::Const`.
- rustdoc has its own `Const` which also has a `ty` field. It was relatively easy to remove this.

---

r? `@lcnr` `@compiler-errors`
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 6, 2024
Remove the `ty` field from type system `Const`s

Fixes rust-lang#125556
Fixes rust-lang#122908

Part of the work on `adt_const_params`/`generic_const_param_types`/`min_generic_const_exprs`/generally making the compiler nicer. cc rust-lang/project-const-generics#44

Please review commit-by-commit otherwise I wasted a lot of time not just squashing this into a giant mess (and also it'll be SO much nicer because theres a lot of fluff changes mixed in with other more careful changes if looking via File Changes

---

Why do this?
- The `ty` field keeps causing ICEs and weird behaviour due to it either being treated as "part of the const" or it being forgotten about leading to ICEs.
- As we move forward with `adt_const_params` and a potential `min_generic_const_exprs` it's going to become more complex to actually lower the correct `Ty<'tcx>`
- It muddles the idea behind how we check `Const` arguments have the correct type. By having the `ty` field it may seem like we ought to be relating it when we relate two types, or that its generally important information about the `Const`.
- Brings the compiler more in line with `a-mir-formality` as that also tracks the type of type system `Const`s via `ConstArgHasType` bounds in the env instead of on the `Const` itself.
- A lot of stuff is a lot nicer when you dont have to pass around the type of a const lol. Everywhere we construct `Const` is now significantly nicer 😅

See rust-lang#125671's description for some more information about the `ty` field

---

General summary of changes in this PR:

- Add `Ty` to `ConstKind::Value` as otherwise there is no way to implement `ConstArgHasType` to ensure that const arguments are correctly typed for the parameter when we stop creating anon consts for all const args. It's also just incredibly difficult/annoying to thread the correct `Ty` around to a bunch of ctfe functions otherwise.
-  Fully implement `ConstArgHasType` in both the old and new solver. Since it now has no reliance on the `ty` field it serves its originally intended purpose of being able to act as a double check that trait vs impls have correctly typed const parameters. It also will now be able to be responsible for checking types of const arguments to parameters under `min_generic_const_exprs`.
- Add `Ty` to `mir::Const::Ty`. I dont have a great understanding of why mir constants are setup like this to be honest. Regardless they need to be able to determine the type of the const and the easiest way to make this happen was to simply store the `Ty` along side the `ty::Const`. Maybe we can do better here in the future but I'd have to spend way more time looking at everywhere we use `mir::Const`.
- rustdoc has its own `Const` which also has a `ty` field. It was relatively easy to remove this.

---

r? `@lcnr` `@compiler-errors`
@bors bors closed this as completed in 003a902 Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler 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