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: parent also has host effect param? #121418

Closed
matthiaskrgr opened this issue Feb 21, 2024 · 7 comments
Closed

ICE: parent also has host effect param? #121418

matthiaskrgr opened this issue Feb 21, 2024 · 7 comments
Assignees
Labels
C-bug Category: This is a bug. 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)]

struct S;
trait T {}

impl const T {
    pub const fn new() -> LazyLock<T> {}
}

original:

#![allow(unused_variables)]
#![feature(
    associated_type_bounds,
    const_trait_impl,
    const_cmp,
    return_position_impl_trait_in_trait,
)]

struct S;
trait T {}

impl const S {
    fn ffi(
        #[allow(unused_mut)] a: i32,
        #[cfg(something)] b: i32,
        #[cfg_attr(something, cfg(nothing))] c: i32,
        #[forbid(unused_mut)] d: i32,
        #[deny(unused_mut)] #[warn(unused_mut)] ...
    );
}
// issue #88015

impl const T {
    pub const fn new(f: fn() -> T) -> LazyLock<T> {
        LazyLock { data: (None, f) }
    }
}
//~^ ERROR inherent impls cannot be `const`

fn main() {}

Version information

rustc 1.78.0-nightly (f8131a48a 2024-02-21)
binary: rustc
commit-hash: f8131a48a46ac3bc8a3d0fe0477055b132cffdc3
commit-date: 2024-02-21
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

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

Program output

error: inherent impls cannot be `const`
 --> /tmp/icemaker_global_tempdir.hviw91Tg4hl3/rustc_testrunner_tmpdir_reporting.NAMwIoI8bW6T/mvce.rs:4:12
  |
4 | impl const T {
  |      ----- ^ inherent impl for this type
  |      |
  |      `const` because of this
  |
  = note: only trait implementations may be annotated with `const`

error[E0412]: cannot find type `LazyLock` in this scope
 --> /tmp/icemaker_global_tempdir.hviw91Tg4hl3/rustc_testrunner_tmpdir_reporting.NAMwIoI8bW6T/mvce.rs:5:27
  |
5 |     pub const fn new() -> LazyLock<T> {}
  |                           ^^^^^^^^ not found in this scope
  |
help: consider importing this struct
  |
1 + use std::sync::LazyLock;
  |

error[E0658]: const trait impls are experimental
 --> /tmp/icemaker_global_tempdir.hviw91Tg4hl3/rustc_testrunner_tmpdir_reporting.NAMwIoI8bW6T/mvce.rs:4:6
  |
4 | impl const T {
  |      ^^^^^
  |
  = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
  = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
  = note: this compiler was built on 2024-02-21; consider upgrading it if it is out of date

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

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.hviw91Tg4hl3/rustc_testrunner_tmpdir_reporting.NAMwIoI8bW6T/mvce.rs:4:12
  |
4 | impl const T {
  |            ^
  |
  = 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: if this is an object-safe trait, use `dyn`
  |
4 | impl const dyn T {
  |            +++

error: internal compiler error: parent also has host effect param? index: 0, def: DefId(0:7 ~ mvce[8c01]::{impl#0}::new)
 --> /tmp/icemaker_global_tempdir.hviw91Tg4hl3/rustc_testrunner_tmpdir_reporting.NAMwIoI8bW6T/mvce.rs:5:9
  |
5 |     pub const fn new() -> LazyLock<T> {}
  |         ^^^^^

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect/generics_of.rs:318:31:
Box<dyn Any>
stack backtrace:
   0:     0x7fa7e2b8caf6 - std::backtrace_rs::backtrace::libunwind::trace::hbec2edc838b433e2
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fa7e2b8caf6 - std::backtrace_rs::backtrace::trace_unsynchronized::h88c30257ee0dd166
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fa7e2b8caf6 - std::sys_common::backtrace::_print_fmt::h9176654d509e3088
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fa7e2b8caf6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h671feaee1776bf19
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fa7e2bdda7c - core::fmt::rt::Argument::fmt::h59605c83ae32d935
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/core/src/fmt/rt.rs:142:9
   5:     0x7fa7e2bdda7c - core::fmt::write::hf7af8dfcfd20db5b
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fa7e2b814bf - std::io::Write::write_fmt::h92a5dbf489025e71
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/io/mod.rs:1846:15
   7:     0x7fa7e2b8c8a4 - std::sys_common::backtrace::_print::h00080302d23998ae
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fa7e2b8c8a4 - std::sys_common::backtrace::print::h6b23124445400245
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fa7e2b8f5eb - std::panicking::default_hook::{{closure}}::hd67b2f9d36675a28
  10:     0x7fa7e2b8f339 - std::panicking::default_hook::h10a39ef11c714e42
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/panicking.rs:292:9
  11:     0x7fa7e5a7a94c - std[5a8e7f94216a9138]::panicking::update_hook::<alloc[e14ab1f516d287ab]::boxed::Box<rustc_driver_impl[e279e4f1fedd9109]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fa7e2b8fd50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h37ba37dc48823c1d
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/alloc/src/boxed.rs:2030:9
  13:     0x7fa7e2b8fd50 - std::panicking::rust_panic_with_hook::he3e3bc7c345bf54b
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/panicking.rs:786:13
  14:     0x7fa7e5aa7524 - std[5a8e7f94216a9138]::panicking::begin_panic::<rustc_errors[34364e5c712fab73]::ExplicitBug>::{closure#0}
  15:     0x7fa7e5aa4176 - std[5a8e7f94216a9138]::sys_common::backtrace::__rust_end_short_backtrace::<std[5a8e7f94216a9138]::panicking::begin_panic<rustc_errors[34364e5c712fab73]::ExplicitBug>::{closure#0}, !>
  16:     0x7fa7e5a9f936 - std[5a8e7f94216a9138]::panicking::begin_panic::<rustc_errors[34364e5c712fab73]::ExplicitBug>
  17:     0x7fa7e4417631 - <rustc_errors[34364e5c712fab73]::diagnostic::BugAbort as rustc_errors[34364e5c712fab73]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7fa7e727f3f0 - rustc_hir_analysis[71d4294717f7f2b7]::collect::generics_of::generics_of
  19:     0x7fa7e727cfb9 - rustc_query_impl[9d4c51777e2bb749]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d4c51777e2bb749]::query_impl::generics_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 8usize]>>
  20:     0x7fa7e6e74da1 - rustc_query_system[9b2ccfe41ae3bb1b]::query::plumbing::try_execute_query::<rustc_query_impl[9d4c51777e2bb749]::DynamicConfig<rustc_query_system[9b2ccfe41ae3bb1b]::query::caches::DefIdCache<rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[9d4c51777e2bb749]::plumbing::QueryCtxt, false>
  21:     0x7fa7e6e74a1b - rustc_query_impl[9d4c51777e2bb749]::query_impl::generics_of::get_query_non_incr::__rust_end_short_backtrace
  22:     0x7fa7e72981b8 - <rustc_hir_analysis[71d4294717f7f2b7]::collect::CollectItemTypesVisitor as rustc_hir[170b9793d794ea06]::intravisit::Visitor>::visit_impl_item
  23:     0x7fa7e71f31ca - rustc_hir_analysis[71d4294717f7f2b7]::collect::collect_mod_item_types
  24:     0x7fa7e71f3109 - rustc_query_impl[9d4c51777e2bb749]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d4c51777e2bb749]::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 0usize]>>
  25:     0x7fa7e7a2b2ed - rustc_query_system[9b2ccfe41ae3bb1b]::query::plumbing::try_execute_query::<rustc_query_impl[9d4c51777e2bb749]::DynamicConfig<rustc_query_system[9b2ccfe41ae3bb1b]::query::caches::DefaultCache<rustc_span[adb133ac03280fc1]::def_id::LocalModDefId, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[9d4c51777e2bb749]::plumbing::QueryCtxt, false>
  26:     0x7fa7e7a2ae17 - rustc_query_impl[9d4c51777e2bb749]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7fa7e77ad4e8 - rustc_hir_analysis[71d4294717f7f2b7]::check_crate
  28:     0x7fa7e78a2dd3 - rustc_interface[7ca501d7f8f3a34f]::passes::analysis
  29:     0x7fa7e78a2a29 - rustc_query_impl[9d4c51777e2bb749]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d4c51777e2bb749]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 1usize]>>
  30:     0x7fa7e7b3d4a5 - rustc_query_system[9b2ccfe41ae3bb1b]::query::plumbing::try_execute_query::<rustc_query_impl[9d4c51777e2bb749]::DynamicConfig<rustc_query_system[9b2ccfe41ae3bb1b]::query::caches::SingleCache<rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[9d4c51777e2bb749]::plumbing::QueryCtxt, false>
  31:     0x7fa7e7b3d209 - rustc_query_impl[9d4c51777e2bb749]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7fa7e7b4c719 - rustc_interface[7ca501d7f8f3a34f]::interface::run_compiler::<core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>, rustc_driver_impl[e279e4f1fedd9109]::run_compiler::{closure#0}>::{closure#0}
  33:     0x7fa7e7dbe705 - std[5a8e7f94216a9138]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_with_globals<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_pool_with_globals<rustc_interface[7ca501d7f8f3a34f]::interface::run_compiler<core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>, rustc_driver_impl[e279e4f1fedd9109]::run_compiler::{closure#0}>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>
  34:     0x7fa7e7dbe532 - <<std[5a8e7f94216a9138]::thread::Builder>::spawn_unchecked_<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_with_globals<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_pool_with_globals<rustc_interface[7ca501d7f8f3a34f]::interface::run_compiler<core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>, rustc_driver_impl[e279e4f1fedd9109]::run_compiler::{closure#0}>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#1} as core[85b4fd477ce5bb21]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7fa7e2b99725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1bff3efb61c3fa6b
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/alloc/src/boxed.rs:2016:9
  36:     0x7fa7e2b99725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h83141cf549dced8a
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/alloc/src/boxed.rs:2016:9
  37:     0x7fa7e2b99725 - std::sys::pal::unix::thread::Thread::new::thread_start::hbe9287fdd7c325bc
                               at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys/pal/unix/thread.rs:108:17
  38:     0x7fa7e29819eb - <unknown>
  39:     0x7fa7e2a057cc - <unknown>
  40:                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.78.0-nightly (f8131a48a 2024-02-21) running on x86_64-unknown-linux-gnu

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

query stack during panic:
#0 [generics_of] computing generics of `<impl at /tmp/icemaker_global_tempdir.hviw91Tg4hl3/rustc_testrunner_tmpdir_reporting.NAMwIoI8bW6T/mvce.rs:4:1: 4:13>::new`
#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 5 previous errors; 1 warning emitted

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

@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 Feb 21, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 21, 2024
@matthiaskrgr
Copy link
Member Author

#121208 cc @nnethercote I'm pretty sure this was previously fixed explicitly, @fmease may know more

@nnethercote
Copy link
Contributor

@lcnr and @fee1-dead were confident that this path should be unreachable...

@matthiaskrgr
Copy link
Member Author

🙃

@fee1-dead
Copy link
Member

Welp. I forgot about invalid programs like this. This will be fixed by the new desugaring though, so don't think we need to revert back to delay span bug yet

@nnethercote
Copy link
Contributor

How soon will the new desugaring merge? If it's not "really soon" then I think it probably is worth reverting.

@fee1-dead
Copy link
Member

That won't happen for a while. Feel free to revert and add this file as a test

@fmease fmease added F-effects `#![feature(effects)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 22, 2024
@nnethercote
Copy link
Contributor

nnethercote commented Feb 22, 2024

#121208 cc @nnethercote I'm pretty sure this was previously fixed explicitly, @fmease may know more

It was converted from a bug to a span_delayed_bug in #119505, but there was no associated test case.

@nnethercote nnethercote self-assigned this Feb 22, 2024
nnethercote added a commit to nnethercote/rust that referenced this issue Feb 22, 2024
@bors bors closed this as completed in 4f83e50 Feb 23, 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. 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

No branches or pull requests

5 participants