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: no type-dependent def for method call #136855

Closed
matthiaskrgr opened this issue Feb 11, 2025 · 0 comments · Fixed by #136884
Closed

ICE: no type-dependent def for method call #136855

matthiaskrgr opened this issue Feb 11, 2025 · 0 comments · Fixed by #136884
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

snippet:

//@compile-flags: --crate-type=lib
#![feature(min_generic_const_args)]
trait A<B> {
    fn c();
}
impl A<[usize; d]> for () {}
fn d() {
    let e = <()>::c;
    e.f()
}

Version information

rustc 1.86.0-nightly (ffa9afef1 2025-02-11)
binary: rustc
commit-hash: ffa9afef183a3496a277c8da2e61403582a99508
commit-date: 2025-02-11
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --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
 --> /tmp/icemaker_global_tempdir.IbyiDuC5Lmc8/rustc_testrunner_tmpdir_reporting.XYo951OOreeE/mvce.rs:1:12
  |
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: trait `A` is never used
 --> /tmp/icemaker_global_tempdir.IbyiDuC5Lmc8/rustc_testrunner_tmpdir_reporting.XYo951OOreeE/mvce.rs:2:7
  |
2 | trait A<B> {
  |       ^
  |
  = note: `#[warn(dead_code)]` on by default

warning: function `d` is never used
 --> /tmp/icemaker_global_tempdir.IbyiDuC5Lmc8/rustc_testrunner_tmpdir_reporting.XYo951OOreeE/mvce.rs:6:4
  |
6 | fn d() {
  |    ^

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: fn items cannot be used as const args
 --> /tmp/icemaker_global_tempdir.IbyiDuC5Lmc8/rustc_testrunner_tmpdir_reporting.XYo951OOreeE/mvce.rs:5:16
  |
5 | impl A<[usize; d]> for () {}
  |                ^
  |
note: delayed at compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2157:60
         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: <rustc_middle::ty::consts::Const>::new_error_with_message::<rustc_span::span_encoding::Span, &str>
         5: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_const_arg.cold
         6: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
         7: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_generic_args_of_path::{closure#0}
         8: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_impl_trait_ref
         9: rustc_hir_analysis::collect::impl_trait_header
        10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::impl_trait_header::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        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::impl_trait_header::get_query_non_incr::__rust_end_short_backtrace
        13: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_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.IbyiDuC5Lmc8/rustc_testrunner_tmpdir_reporting.XYo951OOreeE/mvce.rs:5:16
  |
5 | impl A<[usize; d]> for () {}
  |                ^

error: internal compiler error: no type-dependent def for method call
 --> /tmp/icemaker_global_tempdir.IbyiDuC5Lmc8/rustc_testrunner_tmpdir_reporting.XYo951OOreeE/mvce.rs:8:5
  |
8 |     e.f()
  |     ^^^^^
  |
note: delayed at compiler/rustc_privacy/src/lib.rs:1232:26
         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_privacy::TypePrivacyVisitor as rustc_hir::intravisit::Visitor>::visit_expr
         4: <rustc_privacy::TypePrivacyVisitor as rustc_hir::intravisit::Visitor>::visit_expr
         5: rustc_privacy::check_mod_privacy
         6: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_privacy::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
         7: 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; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
         8: rustc_query_impl::query_impl::check_mod_privacy::get_query_non_incr::__rust_end_short_backtrace
         9: rustc_interface::passes::analysis
        10: 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]>>
        11: 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>
        12: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        13: 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}
        14: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        15: 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}, ()>
        16: <<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}
        17: std::sys::pal::unix::thread::Thread::new::thread_start
        18: <unknown>
        19: <unknown>
 --> /tmp/icemaker_global_tempdir.IbyiDuC5Lmc8/rustc_testrunner_tmpdir_reporting.XYo951OOreeE/mvce.rs:8:5
  |
8 |     e.f()
  |     ^^^^^

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 (ffa9afef1 2025-02-11) running on x86_64-unknown-linux-gnu

note: compiler flags: --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 11, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-min_generic_const_args `#![feature(min_generic_const_args)]` labels Feb 11, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 11, 2025
Lower fn items as ZST valtrees and delay a bug

Lower it as a ZST instead of a const error, which we can handle mostly fine. Delay a bug so we don't accidentally support it tho.

r? BoxyUwU

Fixes rust-lang#136855
Fixes rust-lang#136853
Fixes rust-lang#136854

Only added one test bc that's really the crux of the issue (fn item in array length position).
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 12, 2025
@bors bors closed this as completed in febb367 Feb 12, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 12, 2025
Rollup merge of rust-lang#136884 - compiler-errors:fn-zst, r=BoxyUwU

Lower fn items as ZST valtrees and delay a bug

Lower it as a ZST instead of a const error, which we can handle mostly fine. Delay a bug so we don't accidentally support it tho.

r? BoxyUwU

Fixes rust-lang#136855
Fixes rust-lang#136853
Fixes rust-lang#136854
Fixes rust-lang#136337

Only added one test bc that's really the crux of the issue (fn item in array length position).
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

Successfully merging a pull request may close this issue.

3 participants