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: invalid Res for const path #136379

Open
matthiaskrgr opened this issue Feb 1, 2025 · 1 comment
Open

ICE: invalid Res for const path #136379

matthiaskrgr opened this issue Feb 1, 2025 · 1 comment
Labels
C-bug Category: This is a bug. F-min_generic_const_args `#![feature(min_generic_const_args)]` 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):

//@compile-flags: --crate-type=lib
#![feature(min_generic_const_args)]
mod m {
    pub struct Uuid(());

    impl Uuid {
        pub fn encode_buffer() -> [u8; Uuid] {
            []
        }
    }
}

original:

mod m {
    pub struct Uuid(());

    impl Uuid {
        pub fn encode_buffer() -> [u8; Uuid] {
            []
        }
    }
    const LENGTH: usize = 0;
}

pub use m::Uuid;

Version information

rustc 1.86.0-nightly (9e48dfe5e 2025-02-01)
binary: rustc
commit-hash: 9e48dfe5e0d5ec1b064b5d25504948ede0ec9b53
commit-date: 2025-02-01
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(min_generic_const_args) --crate-type=lib

Program output

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:9
  |
1 | feature(min_generic_const_args)
  |         ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: struct `Uuid` is never constructed
 --> /tmp/icemaker_global_tempdir.pnE6EpSQ5yN3/rustc_testrunner_tmpdir_reporting.8KFeOkEvN674/mvce.rs:2:16
  |
2 |     pub struct Uuid(());
  |                ^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: associated function `encode_buffer` is never used
 --> /tmp/icemaker_global_tempdir.pnE6EpSQ5yN3/rustc_testrunner_tmpdir_reporting.8KFeOkEvN674/mvce.rs:5:16
  |
4 |     impl Uuid {
  |     --------- associated function in this implementation
5 |         pub fn encode_buffer() -> [u8; Uuid] {
  |                ^^^^^^^^^^^^^

warning: 3 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: invalid Res for const path
 --> /tmp/icemaker_global_tempdir.pnE6EpSQ5yN3/rustc_testrunner_tmpdir_reporting.8KFeOkEvN674/mvce.rs:5:40
  |
5 |         pub fn encode_buffer() -> [u8; Uuid] {
  |                                        ^^^^
  |
note: delayed at compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2202:27
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_const_arg.cold
         5: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
         6: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
         7: rustc_hir_analysis::collect::lower_fn_sig_recovering_infer_ret_ty
         8: rustc_hir_analysis::collect::fn_sig
         9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        10: <rustc_query_impl::query_impl::fn_sig::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
        11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        12: rustc_query_impl::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
        13: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_impl_item
        14: rustc_hir_analysis::check::wfcheck::check_well_formed
        15: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        16: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        17: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
        18: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
        19: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        20: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        21: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
        22: rustc_hir_analysis::check_crate
        23: rustc_interface::passes::run_required_analyses
        24: rustc_interface::passes::analysis
        25: 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; 0]>>
        26: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        27: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        28: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        29: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        30: std::sys::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<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        31: <<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<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        32: std::sys::pal::unix::thread::Thread::new::thread_start
        33: <unknown>
        34: <unknown>
 --> /tmp/icemaker_global_tempdir.pnE6EpSQ5yN3/rustc_testrunner_tmpdir_reporting.8KFeOkEvN674/mvce.rs:5:40
  |
5 |         pub fn encode_buffer() -> [u8; Uuid] {
  |                                        ^^^^

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: please make sure that you have updated to the latest nightly

note: rustc 1.86.0-nightly (9e48dfe5e 2025-02-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(min_generic_const_args) --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
end of query stack

@rustbot label +F-min_generic_const_args

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. 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. labels Feb 1, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 1, 2025
@matthiaskrgr matthiaskrgr added F-min_generic_const_args `#![feature(min_generic_const_args)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 1, 2025
@matthiaskrgr
Copy link
Member Author

#![feature(min_generic_const_args)]
pub struct S();

impl S {
    pub fn f() -> [u8; S] {
        []
    }
}

pub fn main() {}

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-min_generic_const_args `#![feature(min_generic_const_args)]` 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

2 participants