rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.18k stars 12.8k forks source link

ICE: `DefId::expect_local DefId isn't local` #133808

Open matthiaskrgr opened 15 hours ago

matthiaskrgr commented 15 hours ago

code:

#![feature(generic_const_exprs, transmutability)]

mod assert {
    use std::mem::TransmuteFrom;

    pub fn is_transmutable<Src, Dst>()
    where
        Dst: TransmuteFrom<Src>,
    {
    }
}

pub fn main() {}

Version information

rustc 1.85.0-nightly (8575f8f91 2024-12-03)
binary: rustc
commit-hash: 8575f8f91bbd7dca529d362afc8117db74661c3b
commit-date: 2024-12-03
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4

Possibly related line of code: https://github.com/rust-lang/rust/blob/8575f8f91bbd7dca529d362afc8117db74661c3b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs#L395-L407

Command: /home/matthias/.rustup/toolchains/master/bin/rustc

Program output

``` warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes --> /tmp/crash.rs:1:12 | 1 | #![feature(generic_const_exprs, transmutability)] | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #76560 for more information = note: `#[warn(incomplete_features)]` on by default thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect/predicates_of.rs:401:60: DefId::expect_local: `DefId(2:2144 ~ core[958b]::mem::transmutability::TransmuteFrom::{constant#0})` isn't local stack backtrace: 0: 0x744f82b429ba - ::fmt::h297eb035a685a8b3 1: 0x744f83213ca6 - core::fmt::write::h8e5bb32e06fa555f 2: 0x744f841d9f11 - std::io::Write::write_fmt::h5d3c55e1a008be63 3: 0x744f82b42812 - std::sys::backtrace::BacktraceLock::print::h2e284e09a2de7ba2 4: 0x744f82b44d1a - std::panicking::default_hook::{{closure}}::h69c9a1055a2222c1 5: 0x744f82b44b63 - std::panicking::default_hook::h1b78022d7d188ab6 6: 0x744f81cc19e8 - std[a8291144892739ee]::panicking::update_hook::>::{closure#0} 7: 0x744f82b45518 - std::panicking::rust_panic_with_hook::h032cdc7be3cb56c8 8: 0x744f82b4520a - std::panicking::begin_panic_handler::{{closure}}::ha7afe2e3fcd9c50e 9: 0x744f82b42e79 - std::sys::backtrace::__rust_end_short_backtrace::hda5e7bea82be6b3c 10: 0x744f82b44ecd - rust_begin_unwind 11: 0x744f7f7ae750 - core::panicking::panic_fmt::hf510dcbfda4b6faf 12: 0x744f81ea6240 - >::visit_const 13: 0x744f83fcc8ef - rustc_hir_analysis[4f3591f81681eb24]::collect::predicates_of::gather_explicit_predicates_of 14: 0x744f83fc41f4 - rustc_query_impl[1566d5036aaf6ee4]::plumbing::__rust_begin_short_backtrace::> 15: 0x744f8338f670 - rustc_query_system[3e62bfa58e5579fb]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[1566d5036aaf6ee4]::plumbing::QueryCtxt, false> 16: 0x744f8338eeb2 - rustc_query_impl[1566d5036aaf6ee4]::query_impl::explicit_predicates_of::get_query_non_incr::__rust_end_short_backtrace 17: 0x744f8338d5c6 - rustc_hir_analysis[4f3591f81681eb24]::collect::predicates_of::predicates_of 18: 0x744f8338d4e1 - rustc_query_impl[1566d5036aaf6ee4]::plumbing::__rust_begin_short_backtrace::> 19: 0x744f8338f659 - rustc_query_system[3e62bfa58e5579fb]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[1566d5036aaf6ee4]::plumbing::QueryCtxt, false> 20: 0x744f8338edc6 - rustc_query_impl[1566d5036aaf6ee4]::query_impl::predicates_of::get_query_non_incr::__rust_end_short_backtrace 21: 0x744f8337d99b - ::visit_item 22: 0x744f80e1da34 - rustc_hir_analysis[4f3591f81681eb24]::check::wfcheck::check_well_formed 23: 0x744f83c86687 - rustc_query_impl[1566d5036aaf6ee4]::plumbing::__rust_begin_short_backtrace::> 24: 0x744f83c86948 - rustc_query_system[3e62bfa58e5579fb]::query::plumbing::try_execute_query::, rustc_query_system[3e62bfa58e5579fb]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[1566d5036aaf6ee4]::plumbing::QueryCtxt, false> 25: 0x744f83c86662 - rustc_query_impl[1566d5036aaf6ee4]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace 26: 0x744f83c873ec - rustc_hir_analysis[4f3591f81681eb24]::check::wfcheck::check_mod_type_wf 27: 0x744f83c8720b - rustc_query_impl[1566d5036aaf6ee4]::plumbing::__rust_begin_short_backtrace::> 28: 0x744f84012308 - rustc_query_system[3e62bfa58e5579fb]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[1566d5036aaf6ee4]::plumbing::QueryCtxt, false> 29: 0x744f840120b0 - rustc_query_impl[1566d5036aaf6ee4]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace 30: 0x744f834c53dc - rustc_hir_analysis[4f3591f81681eb24]::check_crate 31: 0x744f83b0eebc - rustc_interface[14f05bc75be5cd61]::passes::run_required_analyses 32: 0x744f83b09f1e - rustc_interface[14f05bc75be5cd61]::passes::analysis 33: 0x744f83b09eef - rustc_query_impl[1566d5036aaf6ee4]::plumbing::__rust_begin_short_backtrace::> 34: 0x744f841467fa - rustc_query_system[3e62bfa58e5579fb]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[1566d5036aaf6ee4]::plumbing::QueryCtxt, false> 35: 0x744f841464ce - rustc_query_impl[1566d5036aaf6ee4]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 36: 0x744f8426ed79 - rustc_interface[14f05bc75be5cd61]::interface::run_compiler::, rustc_driver_impl[eeb16750bb3b6251]::run_compiler::{closure#0}>::{closure#1} 37: 0x744f840e1bc7 - std[a8291144892739ee]::sys::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[eeb16750bb3b6251]::run_compiler::{closure#0}>::{closure#1}, core[958b0aa3988e400a]::result::Result<(), rustc_span[634f3266c1e253b7]::ErrorGuaranteed>>::{closure#0}, core[958b0aa3988e400a]::result::Result<(), rustc_span[634f3266c1e253b7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[958b0aa3988e400a]::result::Result<(), rustc_span[634f3266c1e253b7]::ErrorGuaranteed>> 38: 0x744f840e1862 - <::spawn_unchecked_, rustc_driver_impl[eeb16750bb3b6251]::run_compiler::{closure#0}>::{closure#1}, core[958b0aa3988e400a]::result::Result<(), rustc_span[634f3266c1e253b7]::ErrorGuaranteed>>::{closure#0}, core[958b0aa3988e400a]::result::Result<(), rustc_span[634f3266c1e253b7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[958b0aa3988e400a]::result::Result<(), rustc_span[634f3266c1e253b7]::ErrorGuaranteed>>::{closure#1} as core[958b0aa3988e400a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 39: 0x744f840e0fab - std::sys::pal::unix::thread::Thread::new::thread_start::hcf422f7542348f85 40: 0x744f7e4a339d - 41: 0x744f7e52849c - 42: 0x0 - 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: please make sure that you have updated to the latest nightly note: please attach the file at `/tmp/im/rustc-ice-2024-12-03T17_09_07-4164483.txt` to your bug report query stack during panic: #0 [explicit_predicates_of] computing explicit predicates of `assert::is_transmutable` #1 [predicates_of] computing predicates of `assert::is_transmutable` end of query stack warning: 1 warning emitted ```

@rustbot label +F-generic_const_exprs +F-transmutability

matthiaskrgr commented 15 hours ago

cc @camelid this went from "compiles" to ice with https://github.com/rust-lang/rust/pull/133610