Skip to content

ICE: effects: no host param id for call in const yet no errors reported? #119700

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(const_trait_impl, effects)]

#[const_trait]
trait Bar {
    fn bar() -> u8;
}

#[const_trait]
trait Foo {
    fn foo() -> u8
    where
        Self: ~const Bar,
    {
        <Self as Bar>::bar() * 6
    }
}

struct Const;

impl const Bar for Const {
    fn bar() -> u8 {
        4
    }
}

impl const Foo for Const {
    fn foo() -> u8
    where
        Self: ~const Bar,
    {
        <Self as Bar>::bar() * 6
    }
}

fn main() {}

original:

// run-pass

#![feature(const_trait_impl, effects)]

#[const_trait]
trait Bar {
    fn bar() -> u8;
}

#[const_trait]
trait Foo {
    fn foo() -> u8 where Self: ~const Bar {
        <Self as Bar>::bar() * 6
    }
}

struct NonConst;
struct Const;

impl Bar for NonConst {
    fn bar() -> u8 {
        3
    }
}

impl Foo for NonConst {}

impl const Bar for Const {
    fn bar() -> u8 {
        4
    }
}

impl const Foo for Const {
    fn foo() -> u8 where Self: ~const Bar {
        <Self as Bar>::bar() * 6
    }
}

fn main() {
    const ANS1: u8 = Const::foo();
    let ans2 = NonConst::foo();

    assert_eq!(ANS1 + ans2, 42);
}

Version information

rustc 1.77.0-nightly (87e143089 2024-01-07)
binary: rustc
commit-hash: 87e1430893d55001034bd76c5dbe832d80bc50c3
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: internal compiler error: no errors encountered even though `span_delayed_bug` issued

error: internal compiler error: no host param id for call in const yet no errors reported
  --> /tmp/icemaker_global_tempdir.MkEVVxxd8A0u/rustc_testrunner_tmpdir_reporting.Vb3DcJiRrH2h/mvce.rs:29:15
   |
29 |         Self: ~const Bar,
   |               ^^^^^^
   |
note: delayed at compiler/rustc_ast_lowering/src/lib.rs:2617:31
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic_without_consuming
         1: <rustc_errors::DiagCtxt>::emit_diagnostic_without_consuming
         2: <rustc_errors::DiagCtxt>::emit_diagnostic
         3: <rustc_errors::DiagCtxt>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: <rustc_ast_lowering::LoweringContext>::lower_qpath
         5: <rustc_ast_lowering::LoweringContext>::lower_param_bounds
         6: <rustc_ast_lowering::LoweringContext>::lower_where_predicate
         7: <rustc_ast_lowering::LoweringContext>::lower_method_sig
         8: <rustc_ast_lowering::LoweringContext>::lower_assoc_item
         9: <rustc_ast_lowering::item::ItemLowerer>::lower_node
        10: rustc_ast_lowering::lower_to_hir
        11: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::hir_crate::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        13: rustc_query_impl::query_impl::hir_crate::get_query_non_incr::__rust_end_short_backtrace
        14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::hir_attrs::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        16: rustc_query_impl::query_impl::hir_attrs::get_query_non_incr::__rust_end_short_backtrace
        17: <rustc_middle::hir::map::Map>::attrs
        18: rustc_passes::entry::entry_fn
        19: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::entry_fn::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 12]>>
        20: <rustc_query_impl::query_impl::entry_fn::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 12]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        22: rustc_query_impl::query_impl::entry_fn::get_query_non_incr::__rust_end_short_backtrace
        23: rustc_interface::passes::analysis
        24: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        25: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        26: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        27: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
        28: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        29: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        30: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/87e1430893d55001034bd76c5dbe832d80bc50c3/library/alloc/src/boxed.rs:2016:9
        31: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/87e1430893d55001034bd76c5dbe832d80bc50c3/library/alloc/src/boxed.rs:2016:9
        32: std::sys::unix::thread::Thread::new::thread_start
                   at /rustc/87e1430893d55001034bd76c5dbe832d80bc50c3/library/std/src/sys/unix/thread.rs:108:17
        33: <unknown>
        34: <unknown>
  --> /tmp/icemaker_global_tempdir.MkEVVxxd8A0u/rustc_testrunner_tmpdir_reporting.Vb3DcJiRrH2h/mvce.rs:29:15
   |
29 |         Self: ~const Bar,
   |               ^^^^^^

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 (87e143089 2024-01-07) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 2 previous errors


Metadata

Metadata

Assignees

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) ❄️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