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: effects: assertion failed: constant == lifetime #119524

Closed
matthiaskrgr opened this issue Jan 2, 2024 · 1 comment · Fixed by #119540
Closed

ICE: effects: assertion failed: constant == lifetime #119524

matthiaskrgr opened this issue Jan 2, 2024 · 1 comment · Fixed by #119540
Assignees
Labels
C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]` F-effects `#![feature(effects)]` 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.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

#![feature(effects, const_trait_impl)]

const fn foo(xB: ~const From<_>) {}

original:

#![feature(effects, const_trait_impl)]

const fn foo<>(xB: ~const From<_>) {}

pub fn main() {}

Version information

rustc 1.77.0-nightly (e51e98dde 2023-12-31)
binary: rustc
commit-hash: e51e98dde6a60637b6a71b8105245b629ac3fe77
commit-date: 2023-12-31
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

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

Program output

error: `~const` is not allowed here
 --> /tmp/icemaker_global_tempdir.2kROOgaqeeAJ/rustc_testrunner_tmpdir_reporting.debhZaZQZZDf/mvce.rs:3:18
  |
3 | const fn foo(xB: ~const From<_>) {}
  |                  ^^^^^^
  |
  = note: trait objects cannot have `~const` trait bounds

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.2kROOgaqeeAJ/rustc_testrunner_tmpdir_reporting.debhZaZQZZDf/mvce.rs:3:36
  |
3 | const fn foo(xB: ~const From<_>) {}
  |                                    ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.2kROOgaqeeAJ/rustc_testrunner_tmpdir_reporting.debhZaZQZZDf/mvce.rs`

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.2kROOgaqeeAJ/rustc_testrunner_tmpdir_reporting.debhZaZQZZDf/mvce.rs:3:18
  |
3 | const fn foo(xB: ~const From<_>) {}
  |                  ^^^^^^^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` on by default
help: use `dyn`
  |
3 | const fn foo(xB: dyn ~const From<_>) {}
  |                  +++

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/astconv/generics.rs:377:25:
assertion `left == right` failed
  left: "constant"
 right: "lifetime"
stack backtrace:
   0:     0x7f10185f3946 - std::backtrace_rs::backtrace::libunwind::trace::h44f4ca7c442c0986
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f10185f3946 - std::backtrace_rs::backtrace::trace_unsynchronized::h8e72beef8f98799e
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f10185f3946 - std::sys_common::backtrace::_print_fmt::had1f7322c7191a83
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f10185f3946 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc02075f68ac68e83
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f1018646060 - core::fmt::rt::Argument::fmt::h4fb797bf569c9381
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/core/src/fmt/rt.rs:142:9
   5:     0x7f1018646060 - core::fmt::write::h6f1ea15fe9368d17
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f10185e736f - std::io::Write::write_fmt::haaa4143b58137630
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/io/mod.rs:1810:15
   7:     0x7f10185f3724 - std::sys_common::backtrace::_print::h16f1f390d8dff6aa
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f10185f3724 - std::sys_common::backtrace::print::h7a4cfc718891723c
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f10185f64b7 - std::panicking::default_hook::{{closure}}::h66f09592313f4ce8
  10:     0x7f10185f6219 - std::panicking::default_hook::he45e0a376ce42f7d
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/panicking.rs:292:9
  11:     0x7f101536605c - std[59bbd359e4a0812d]::panicking::update_hook::<alloc[9e8bbef5278c9f16]::boxed::Box<rustc_driver_impl[f5f02e8ab7f89dcf]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f10185f6c06 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h0ebdda5c503ff158
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/alloc/src/boxed.rs:2029:9
  13:     0x7f10185f6c06 - std::panicking::rust_panic_with_hook::h4f38919015b1c60f
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/panicking.rs:783:13
  14:     0x7f10185f6952 - std::panicking::begin_panic_handler::{{closure}}::h6e933e94ded3024f
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/panicking.rs:657:13
  15:     0x7f10185f3e46 - std::sys_common::backtrace::__rust_end_short_backtrace::h4efef00f0bd07d56
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f10185f66b0 - rust_begin_unwind
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/panicking.rs:645:5
  17:     0x7f1018642765 - core::panicking::panic_fmt::h3f2350d70561f7cb
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/core/src/panicking.rs:72:14
  18:     0x7f1018642cfb - core::panicking::assert_failed_inner::h44ef086644106b14
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/core/src/panicking.rs:342:17
  19:     0x7f101543046b - core[f50a4b4ddb6878bb]::panicking::assert_failed::<&str, &str>
  20:     0x7f1016f84212 - <dyn rustc_hir_analysis[239f966c4ce807be]::astconv::AstConv>::instantiate_poly_trait_ref
  21:     0x7f1016f237e8 - <dyn rustc_hir_analysis[239f966c4ce807be]::astconv::AstConv>::conv_object_ty_poly_trait_ref
  22:     0x7f10167f9cd4 - <dyn rustc_hir_analysis[239f966c4ce807be]::astconv::AstConv>::ast_ty_to_ty_inner
  23:     0x7f10167f6db0 - <dyn rustc_hir_analysis[239f966c4ce807be]::astconv::AstConv>::ty_of_fn
  24:     0x7f10167f5ee6 - rustc_hir_analysis[239f966c4ce807be]::collect::infer_return_ty_for_fn_sig
  25:     0x7f10167f517c - rustc_hir_analysis[239f966c4ce807be]::collect::fn_sig
  26:     0x7f10167ee5c1 - rustc_query_impl[6eb9e4a88fa21aca]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6eb9e4a88fa21aca]::query_impl::fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7d80ff9c88f366f3]::query::erase::Erased<[u8; 24usize]>>
  27:     0x7f10167ee591 - <rustc_query_impl[6eb9e4a88fa21aca]::query_impl::fn_sig::dynamic_query::{closure#2} as core[f50a4b4ddb6878bb]::ops::function::FnOnce<(rustc_middle[7d80ff9c88f366f3]::ty::context::TyCtxt, rustc_span[44814e3eac9e4a35]::def_id::DefId)>>::call_once
  28:     0x7f10167edbd3 - rustc_query_system[cdab7429fb42dda2]::query::plumbing::try_execute_query::<rustc_query_impl[6eb9e4a88fa21aca]::DynamicConfig<rustc_query_system[cdab7429fb42dda2]::query::caches::DefaultCache<rustc_span[44814e3eac9e4a35]::def_id::DefId, rustc_middle[7d80ff9c88f366f3]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[6eb9e4a88fa21aca]::plumbing::QueryCtxt, false>
  29:     0x7f10167ed5e3 - rustc_query_impl[6eb9e4a88fa21aca]::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f1016aba284 - <rustc_hir_analysis[239f966c4ce807be]::collect::CollectItemTypesVisitor as rustc_hir[556501f2b35f222e]::intravisit::Visitor>::visit_item
  31:     0x7f1016ab82bd - rustc_hir_analysis[239f966c4ce807be]::collect::collect_mod_item_types
  32:     0x7f1016ab8251 - rustc_query_impl[6eb9e4a88fa21aca]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6eb9e4a88fa21aca]::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7d80ff9c88f366f3]::query::erase::Erased<[u8; 0usize]>>
  33:     0x7f1017218dbb - rustc_query_system[cdab7429fb42dda2]::query::plumbing::try_execute_query::<rustc_query_impl[6eb9e4a88fa21aca]::DynamicConfig<rustc_query_system[cdab7429fb42dda2]::query::caches::DefaultCache<rustc_span[44814e3eac9e4a35]::def_id::LocalModDefId, rustc_middle[7d80ff9c88f366f3]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[6eb9e4a88fa21aca]::plumbing::QueryCtxt, false>
  34:     0x7f10172188d7 - rustc_query_impl[6eb9e4a88fa21aca]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f1016edf4df - rustc_hir_analysis[239f966c4ce807be]::check_crate
  36:     0x7f1016f5a319 - rustc_interface[8dea96efab884454]::passes::analysis
  37:     0x7f1016f59f5f - rustc_query_impl[6eb9e4a88fa21aca]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6eb9e4a88fa21aca]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7d80ff9c88f366f3]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7f1017597a64 - rustc_query_system[cdab7429fb42dda2]::query::plumbing::try_execute_query::<rustc_query_impl[6eb9e4a88fa21aca]::DynamicConfig<rustc_query_system[cdab7429fb42dda2]::query::caches::SingleCache<rustc_middle[7d80ff9c88f366f3]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[6eb9e4a88fa21aca]::plumbing::QueryCtxt, false>
  39:     0x7f1017597855 - rustc_query_impl[6eb9e4a88fa21aca]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f101762d094 - rustc_interface[8dea96efab884454]::interface::run_compiler::<core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>, rustc_driver_impl[f5f02e8ab7f89dcf]::run_compiler::{closure#0}>::{closure#0}
  41:     0x7f10175b7306 - std[59bbd359e4a0812d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8dea96efab884454]::util::run_in_thread_with_globals<rustc_interface[8dea96efab884454]::util::run_in_thread_pool_with_globals<rustc_interface[8dea96efab884454]::interface::run_compiler<core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>, rustc_driver_impl[f5f02e8ab7f89dcf]::run_compiler::{closure#0}>::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>
  42:     0x7f10175b7133 - <<std[59bbd359e4a0812d]::thread::Builder>::spawn_unchecked_<rustc_interface[8dea96efab884454]::util::run_in_thread_with_globals<rustc_interface[8dea96efab884454]::util::run_in_thread_pool_with_globals<rustc_interface[8dea96efab884454]::interface::run_compiler<core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>, rustc_driver_impl[f5f02e8ab7f89dcf]::run_compiler::{closure#0}>::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f50a4b4ddb6878bb]::result::Result<(), rustc_span[44814e3eac9e4a35]::ErrorGuaranteed>>::{closure#1} as core[f50a4b4ddb6878bb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f1018600b35 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfced58be344e2c05
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/alloc/src/boxed.rs:2015:9
  44:     0x7f1018600b35 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7842a7154462ae57
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/alloc/src/boxed.rs:2015:9
  45:     0x7f1018600b35 - std::sys::unix::thread::Thread::new::thread_start::ha365c5d9b9d0ac99
                               at /rustc/e51e98dde6a60637b6a71b8105245b629ac3fe77/library/std/src/sys/unix/thread.rs:108:17
  46:     0x7f10124aa9eb - <unknown>
  47:     0x7f101252e7cc - <unknown>
  48:                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: rustc 1.77.0-nightly (e51e98dde 2023-12-31) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [fn_sig] computing function signature of `foo`
#1 [collect_mod_item_types] collecting item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0601`.

@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 Jan 2, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 2, 2024
@matthiaskrgr matthiaskrgr added F-const_trait_impl `#![feature(const_trait_impl)]` F-effects `#![feature(effects)]` labels Jan 2, 2024
@matthiaskrgr
Copy link
Member Author

bisects to #117171

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 3, 2024
@fmease fmease self-assigned this Jan 3, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 3, 2024
…rait, r=compiler-errors

Don't synthesize host effect args inside trait object types

While we were indeed emitting an error for `~const` & `const` trait bounds in trait object types, we were still synthesizing host effect args for them.

Since we don't record the original trait bound modifiers for dyn-Trait in `hir::TyKind::TraitObject` (unlike we do for let's say impl-Trait, `hir::TyKind::OpaqueTy`), AstConv just assumes `ty::BoundConstness::NotConst` in `conv_object_ty_poly_trait_ref` which given `<host> dyn ~const NonConstTrait` resulted in us not realizing that `~const` was used on a non-const trait which lead to a failed assertion in the end.

Instead of updating `hir::TyKind::TraitObject` to track this kind of information, just strip the user-provided constness (similar to rust-lang#119505).

Fixes rust-lang#119524.
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jan 4, 2024
…rait, r=compiler-errors

Don't synthesize host effect args inside trait object types

While we were indeed emitting an error for `~const` & `const` trait bounds in trait object types, we were still synthesizing host effect args for them.

Since we don't record the original trait bound modifiers for dyn-Trait in `hir::TyKind::TraitObject` (unlike we do for let's say impl-Trait, `hir::TyKind::OpaqueTy`), AstConv just assumes `ty::BoundConstness::NotConst` in `conv_object_ty_poly_trait_ref` which given `<host> dyn ~const NonConstTrait` resulted in us not realizing that `~const` was used on a non-const trait which lead to a failed assertion in the end.

Instead of updating `hir::TyKind::TraitObject` to track this kind of information, just strip the user-provided constness (similar to rust-lang#119505).

Fixes rust-lang#119524.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 4, 2024
…rait, r=compiler-errors

Don't synthesize host effect args inside trait object types

While we were indeed emitting an error for `~const` & `const` trait bounds in trait object types, we were still synthesizing host effect args for them.

Since we don't record the original trait bound modifiers for dyn-Trait in `hir::TyKind::TraitObject` (unlike we do for let's say impl-Trait, `hir::TyKind::OpaqueTy`), AstConv just assumes `ty::BoundConstness::NotConst` in `conv_object_ty_poly_trait_ref` which given `<host> dyn ~const NonConstTrait` resulted in us not realizing that `~const` was used on a non-const trait which lead to a failed assertion in the end.

Instead of updating `hir::TyKind::TraitObject` to track this kind of information, just strip the user-provided constness (similar to rust-lang#119505).

Fixes rust-lang#119524.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 4, 2024
Rollup merge of rust-lang#119540 - fmease:no-effect-args-inside-dyn-trait, r=compiler-errors

Don't synthesize host effect args inside trait object types

While we were indeed emitting an error for `~const` & `const` trait bounds in trait object types, we were still synthesizing host effect args for them.

Since we don't record the original trait bound modifiers for dyn-Trait in `hir::TyKind::TraitObject` (unlike we do for let's say impl-Trait, `hir::TyKind::OpaqueTy`), AstConv just assumes `ty::BoundConstness::NotConst` in `conv_object_ty_poly_trait_ref` which given `<host> dyn ~const NonConstTrait` resulted in us not realizing that `~const` was used on a non-const trait which lead to a failed assertion in the end.

Instead of updating `hir::TyKind::TraitObject` to track this kind of information, just strip the user-provided constness (similar to rust-lang#119505).

Fixes rust-lang#119524.
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. F-const_trait_impl `#![feature(const_trait_impl)]` F-effects `#![feature(effects)]` 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants