Skip to content

ice: assertion failed: constant / lifetime with effects and try_trait  #119717

Closed
@matthiaskrgr

Description

@matthiaskrgr

snippet:

#![feature(const_trait_impl, effects)]

use std::ops::{FromResidual, Try};

impl const FromResidual for T {
    fn from_residual(t: T) -> _ {
        t
    }
}

Version information

rustc 1.77.0-nightly (75c68cfd2 2024-01-07)
binary: rustc
commit-hash: 75c68cfd2b9870f2953b62d250bd7d0564a7b56d
commit-date: 2024-01-07
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[E0412]: cannot find type `T` in this scope
 --> /tmp/icemaker_global_tempdir.lbZhrjbfGw3A/rustc_testrunner_tmpdir_reporting.YccQD9hrVX62/mvce.rs:5:29
  |
5 | impl const FromResidual for T {
  |                             ^ not found in this scope

error[E0412]: cannot find type `T` in this scope
 --> /tmp/icemaker_global_tempdir.lbZhrjbfGw3A/rustc_testrunner_tmpdir_reporting.YccQD9hrVX62/mvce.rs:6:25
  |
6 |     fn from_residual(t: T) -> _ {
  |                         ^ not found in this scope

warning: unused import: `Try`
 --> /tmp/icemaker_global_tempdir.lbZhrjbfGw3A/rustc_testrunner_tmpdir_reporting.YccQD9hrVX62/mvce.rs:3:30
  |
3 | use std::ops::{FromResidual, Try};
  |                              ^^^
  |
  = note: `#[warn(unused_imports)]` on by default

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

error[E0658]: use of unstable library feature 'try_trait_v2'
 --> /tmp/icemaker_global_tempdir.lbZhrjbfGw3A/rustc_testrunner_tmpdir_reporting.YccQD9hrVX62/mvce.rs:3:16
  |
3 | use std::ops::{FromResidual, Try};
  |                ^^^^^^^^^^^^
  |
  = note: see issue #84277 <https://github.com/rust-lang/rust/issues/84277> for more information
  = help: add `#![feature(try_trait_v2)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'try_trait_v2'
 --> /tmp/icemaker_global_tempdir.lbZhrjbfGw3A/rustc_testrunner_tmpdir_reporting.YccQD9hrVX62/mvce.rs:3:30
  |
3 | use std::ops::{FromResidual, Try};
  |                              ^^^
  |
  = note: see issue #84277 <https://github.com/rust-lang/rust/issues/84277> for more information
  = help: add `#![feature(try_trait_v2)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'try_trait_v2'
 --> /tmp/icemaker_global_tempdir.lbZhrjbfGw3A/rustc_testrunner_tmpdir_reporting.YccQD9hrVX62/mvce.rs:6:5
  |
6 | /     fn from_residual(t: T) -> _ {
7 | |         t
8 | |     }
  | |_____^
  |
  = note: see issue #84277 <https://github.com/rust-lang/rust/issues/84277> for more information
  = help: add `#![feature(try_trait_v2)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'try_trait_v2'
 --> /tmp/icemaker_global_tempdir.lbZhrjbfGw3A/rustc_testrunner_tmpdir_reporting.YccQD9hrVX62/mvce.rs:5:12
  |
5 | impl const FromResidual for T {
  |            ^^^^^^^^^^^^
  |
  = note: see issue #84277 <https://github.com/rust-lang/rust/issues/84277> for more information
  = help: add `#![feature(try_trait_v2)]` to the crate attributes to enable

error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
 --> /tmp/icemaker_global_tempdir.lbZhrjbfGw3A/rustc_testrunner_tmpdir_reporting.YccQD9hrVX62/mvce.rs:5:12
  |
5 | impl const FromResidual for T {
  |            ^^^^^^^^^^^^
  |
  = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
  = note: adding a non-const method body in the future would be a breaking change

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:     0x7faa8b98c7e6 - std::backtrace_rs::backtrace::libunwind::trace::h77800003d5e1d475
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7faa8b98c7e6 - std::backtrace_rs::backtrace::trace_unsynchronized::h053be484c7eba922
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7faa8b98c7e6 - std::sys_common::backtrace::_print_fmt::h658f0ed17c0b78d9
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7faa8b98c7e6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h92f7276dc2d1ad88
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7faa8b9deed0 - core::fmt::rt::Argument::fmt::heed5d96f67f8a94e
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/core/src/fmt/rt.rs:142:9
   5:     0x7faa8b9deed0 - core::fmt::write::hb0a14a1b109d343e
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/core/src/fmt/mod.rs:1120:17
   6:     0x7faa8b98014f - std::io::Write::write_fmt::hb68419aa79b5d241
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/io/mod.rs:1810:15
   7:     0x7faa8b98c5c4 - std::sys_common::backtrace::_print::h2515a5f3f70c3f2a
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7faa8b98c5c4 - std::sys_common::backtrace::print::haa99668665f11fc1
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7faa8b98f357 - std::panicking::default_hook::{{closure}}::h98d80deda6602b54
  10:     0x7faa8b98f0b9 - std::panicking::default_hook::h01558a8bbd5d1c0b
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/panicking.rs:292:9
  11:     0x7faa8e75093c - std[ca913780aff877b3]::panicking::update_hook::<alloc[6aabbde17010a607]::boxed::Box<rustc_driver_impl[c8d6e38be153bd2e]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7faa8b98faa6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1171429379e58ebd
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/alloc/src/boxed.rs:2030:9
  13:     0x7faa8b98faa6 - std::panicking::rust_panic_with_hook::he8cd11bc79b74e48
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/panicking.rs:783:13
  14:     0x7faa8b98f7f2 - std::panicking::begin_panic_handler::{{closure}}::he1868b3475576648
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/panicking.rs:657:13
  15:     0x7faa8b98cce6 - std::sys_common::backtrace::__rust_end_short_backtrace::h9210389720f5c16a
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7faa8b98f550 - rust_begin_unwind
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/panicking.rs:645:5
  17:     0x7faa8b9db5d5 - core::panicking::panic_fmt::hfbd09a125111b8b4
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/core/src/panicking.rs:72:14
  18:     0x7faa8b9dbb6b - core::panicking::assert_failed_inner::ha427bb62c1496cc3
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/core/src/panicking.rs:342:17
  19:     0x7faa8e8125eb - core[db2dbba8ad13fc6d]::panicking::assert_failed::<&str, &str>
  20:     0x7faa9036f69d - <dyn rustc_hir_analysis[e387dd78e074a169]::astconv::AstConv>::create_args_for_ast_path
  21:     0x7faa9036d26a - <dyn rustc_hir_analysis[e387dd78e074a169]::astconv::AstConv>::instantiate_mono_trait_ref
  22:     0x7faa8e87aa36 - <dyn rustc_hir_analysis[e387dd78e074a169]::astconv::AstConv>::suggest_trait_fn_ty_for_impl_fn_infer
  23:     0x7faa8fbef222 - <dyn rustc_hir_analysis[e387dd78e074a169]::astconv::AstConv>::ty_of_fn
  24:     0x7faa8fbecce0 - rustc_hir_analysis[e387dd78e074a169]::collect::fn_sig
  25:     0x7faa8fbe6045 - rustc_query_impl[d71d27d8d4fd2043]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d71d27d8d4fd2043]::query_impl::fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fc3d6de4885c956b]::query::erase::Erased<[u8; 24usize]>>
  26:     0x7faa8fbe6015 - <rustc_query_impl[d71d27d8d4fd2043]::query_impl::fn_sig::dynamic_query::{closure#2} as core[db2dbba8ad13fc6d]::ops::function::FnOnce<(rustc_middle[fc3d6de4885c956b]::ty::context::TyCtxt, rustc_span[5c4821f8b4a403f8]::def_id::DefId)>>::call_once
  27:     0x7faa8fbe5653 - rustc_query_system[af0d53eaca50a21]::query::plumbing::try_execute_query::<rustc_query_impl[d71d27d8d4fd2043]::DynamicConfig<rustc_query_system[af0d53eaca50a21]::query::caches::DefaultCache<rustc_span[5c4821f8b4a403f8]::def_id::DefId, rustc_middle[fc3d6de4885c956b]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[d71d27d8d4fd2043]::plumbing::QueryCtxt, false>
  28:     0x7faa8fbe5075 - rustc_query_impl[d71d27d8d4fd2043]::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7faa8fd581bb - <rustc_hir_analysis[e387dd78e074a169]::collect::CollectItemTypesVisitor as rustc_hir[149574241a95a1a8]::intravisit::Visitor>::visit_impl_item
  30:     0x7faa8febc04d - rustc_hir_analysis[e387dd78e074a169]::collect::collect_mod_item_types
  31:     0x7faa8febbf91 - rustc_query_impl[d71d27d8d4fd2043]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d71d27d8d4fd2043]::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fc3d6de4885c956b]::query::erase::Erased<[u8; 0usize]>>
  32:     0x7faa90614ecf - rustc_query_system[af0d53eaca50a21]::query::plumbing::try_execute_query::<rustc_query_impl[d71d27d8d4fd2043]::DynamicConfig<rustc_query_system[af0d53eaca50a21]::query::caches::DefaultCache<rustc_span[5c4821f8b4a403f8]::def_id::LocalModDefId, rustc_middle[fc3d6de4885c956b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[d71d27d8d4fd2043]::plumbing::QueryCtxt, false>
  33:     0x7faa90614a03 - rustc_query_impl[d71d27d8d4fd2043]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7faa8fbf323d - rustc_hir_analysis[e387dd78e074a169]::check_crate
  35:     0x7faa9060bbd9 - rustc_interface[1bd61175f6644bbf]::passes::analysis
  36:     0x7faa9060b81f - rustc_query_impl[d71d27d8d4fd2043]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d71d27d8d4fd2043]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fc3d6de4885c956b]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7faa909a79a4 - rustc_query_system[af0d53eaca50a21]::query::plumbing::try_execute_query::<rustc_query_impl[d71d27d8d4fd2043]::DynamicConfig<rustc_query_system[af0d53eaca50a21]::query::caches::SingleCache<rustc_middle[fc3d6de4885c956b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[d71d27d8d4fd2043]::plumbing::QueryCtxt, false>
  38:     0x7faa909a7795 - rustc_query_impl[d71d27d8d4fd2043]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7faa906fb575 - rustc_interface[1bd61175f6644bbf]::interface::run_compiler::<core[db2dbba8ad13fc6d]::result::Result<(), rustc_span[5c4821f8b4a403f8]::ErrorGuaranteed>, rustc_driver_impl[c8d6e38be153bd2e]::run_compiler::{closure#0}>::{closure#0}
  40:     0x7faa909cc486 - std[ca913780aff877b3]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1bd61175f6644bbf]::util::run_in_thread_with_globals<rustc_interface[1bd61175f6644bbf]::util::run_in_thread_pool_with_globals<rustc_interface[1bd61175f6644bbf]::interface::run_compiler<core[db2dbba8ad13fc6d]::result::Result<(), rustc_span[5c4821f8b4a403f8]::ErrorGuaranteed>, rustc_driver_impl[c8d6e38be153bd2e]::run_compiler::{closure#0}>::{closure#0}, core[db2dbba8ad13fc6d]::result::Result<(), rustc_span[5c4821f8b4a403f8]::ErrorGuaranteed>>::{closure#0}, core[db2dbba8ad13fc6d]::result::Result<(), rustc_span[5c4821f8b4a403f8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db2dbba8ad13fc6d]::result::Result<(), rustc_span[5c4821f8b4a403f8]::ErrorGuaranteed>>
  41:     0x7faa909cc2b3 - <<std[ca913780aff877b3]::thread::Builder>::spawn_unchecked_<rustc_interface[1bd61175f6644bbf]::util::run_in_thread_with_globals<rustc_interface[1bd61175f6644bbf]::util::run_in_thread_pool_with_globals<rustc_interface[1bd61175f6644bbf]::interface::run_compiler<core[db2dbba8ad13fc6d]::result::Result<(), rustc_span[5c4821f8b4a403f8]::ErrorGuaranteed>, rustc_driver_impl[c8d6e38be153bd2e]::run_compiler::{closure#0}>::{closure#0}, core[db2dbba8ad13fc6d]::result::Result<(), rustc_span[5c4821f8b4a403f8]::ErrorGuaranteed>>::{closure#0}, core[db2dbba8ad13fc6d]::result::Result<(), rustc_span[5c4821f8b4a403f8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db2dbba8ad13fc6d]::result::Result<(), rustc_span[5c4821f8b4a403f8]::ErrorGuaranteed>>::{closure#1} as core[db2dbba8ad13fc6d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7faa8b9999d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h531f62f3337edeaa
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/alloc/src/boxed.rs:2016:9
  43:     0x7faa8b9999d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8927a97a093d165e
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/alloc/src/boxed.rs:2016:9
  44:     0x7faa8b9999d5 - std::sys::unix::thread::Thread::new::thread_start::h95607854405756e7
                               at /rustc/75c68cfd2b9870f2953b62d250bd7d0564a7b56d/library/std/src/sys/unix/thread.rs:108:17
  45:     0x7faa8b7859eb - <unknown>
  46:     0x7faa8b8097cc - <unknown>
  47:                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 (75c68cfd2 2024-01-07) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [fn_sig] computing function signature of `<impl at /tmp/icemaker_global_tempdir.lbZhrjbfGw3A/rustc_testrunner_tmpdir_reporting.YccQD9hrVX62/mvce.rs:5:1: 5:30>::from_residual`
#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 8 previous errors; 1 warning emitted

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]`F-effects`#![feature(effects)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.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