Skip to content

ICE "raw ptr comparison should already be caught in the trait system" #105047

Closed

Description

Code

#![feature(raw_ref_op)]

const RCZ: *const i32 = &raw const *&0;

const fn f() {
    if let RCZ = &raw const *&0 { }
}

fn main() {}

Error output

internal compiler error: compiler/rustc_const_eval/src/transform/check_consts/ops.rs:611: raw ptr comparison should already be caught in the trait system

Full output including backtrace

error: internal compiler error: compiler/rustc_const_eval/src/transform/check_consts/ops.rs:611:9: raw ptr comparison should already be caught in the trait system
 --> rps.rs:6:12
  |
6 |     if let RCZ = &raw const *&0 { }
  |            ^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/1eb62b1235fd77200e6bd967d70e83c0f2497233/compiler/rustc_errors/src/lib.rs:972:33
stack backtrace:
   0:        0x10f2f22a6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1901ec5c10c2d477
   1:        0x10f350e2a - core::fmt::write::h453ba3b763f16dfb
   2:        0x10f2e464c - std::io::Write::write_fmt::h35935f9cf41659e0
   3:        0x10f2f208a - std::sys_common::backtrace::print::h48cb2ddd4d16ad05
   4:        0x10f2f53d3 - std::panicking::default_hook::{{closure}}::hf85401495f021b7c
   5:        0x10f2f5128 - std::panicking::default_hook::hcc698ed67aaec0db
   6:        0x11f1035fd - rustc_driver[c6bc39476a4ff69]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x10f2f5bb7 - std::panicking::rust_panic_with_hook::h4686e220b4123e59
   8:        0x122797167 - std[e853a6d0ec043b70]::panicking::begin_panic::<rustc_errors[5974999511236221]::ExplicitBug>::{closure#0}
   9:        0x122795a39 - std[e853a6d0ec043b70]::sys_common::backtrace::__rust_end_short_backtrace::<std[e853a6d0ec043b70]::panicking::begin_panic<rustc_errors[5974999511236221]::ExplicitBug>::{closure#0}, !>
  10:        0x123eb2ff9 - std[e853a6d0ec043b70]::panicking::begin_panic::<rustc_errors[5974999511236221]::ExplicitBug>
  11:        0x12271faf9 - std[e853a6d0ec043b70]::panic::panic_any::<rustc_errors[5974999511236221]::ExplicitBug>
  12:        0x12271e938 - <rustc_errors[5974999511236221]::HandlerInner>::span_bug::<rustc_span[db835ecaf6c42563]::span_encoding::Span, &alloc[374a688e4a400e73]::string::String>
  13:        0x12271e74e - <rustc_errors[5974999511236221]::Handler>::span_bug::<rustc_span[db835ecaf6c42563]::span_encoding::Span, &alloc[374a688e4a400e73]::string::String>
  14:        0x1227eac72 - rustc_middle[d5319f07d231351a]::ty::context::tls::with_context_opt::<rustc_middle[d5319f07d231351a]::ty::context::tls::with_opt<rustc_middle[d5319f07d231351a]::util::bug::opt_span_bug_fmt<rustc_span[db835ecaf6c42563]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  15:        0x1227ea4a1 - rustc_middle[d5319f07d231351a]::util::bug::opt_span_bug_fmt::<rustc_span[db835ecaf6c42563]::span_encoding::Span>
  16:        0x123eb53df - rustc_middle[d5319f07d231351a]::util::bug::span_bug_fmt::<rustc_span[db835ecaf6c42563]::span_encoding::Span>
  17:        0x1227d0ae9 - <rustc_const_eval[c3ddd231fb47b19c]::transform::check_consts::ops::RawPtrComparison as rustc_const_eval[c3ddd231fb47b19c]::transform::check_consts::ops::NonConstOp>::build_error
  18:        0x12279f6b0 - <rustc_const_eval[c3ddd231fb47b19c]::transform::check_consts::check::Checker as rustc_middle[d5319f07d231351a]::mir::visit::Visitor>::visit_rvalue
  19:        0x12279aeb2 - <rustc_const_eval[c3ddd231fb47b19c]::transform::check_consts::check::Checker>::check_body
  20:        0x121dc2b0a - rustc_mir_transform[827416b191d7b3aa]::mir_const_qualif
  21:        0x121db4316 - <rustc_mir_transform[827416b191d7b3aa]::provide::{closure#0} as core[e7c8723dd1d9fd02]::ops::function::FnOnce<(rustc_middle[d5319f07d231351a]::ty::context::TyCtxt, rustc_span[db835ecaf6c42563]::def_id::DefId)>>::call_once
  22:        0x12291437b - rustc_query_system[91c4ad596cfd42fe]::query::plumbing::try_execute_query::<rustc_query_impl[5858643fdf1b29eb]::plumbing::QueryCtxt, rustc_query_system[91c4ad596cfd42fe]::query::caches::DefaultCache<rustc_span[db835ecaf6c42563]::def_id::DefId, rustc_middle[d5319f07d231351a]::mir::query::ConstQualifs>>
  23:        0x122a031ad - rustc_query_system[91c4ad596cfd42fe]::query::plumbing::get_query::<rustc_query_impl[5858643fdf1b29eb]::queries::mir_const_qualif, rustc_query_impl[5858643fdf1b29eb]::plumbing::QueryCtxt>
  24:        0x121dc3f62 - rustc_mir_transform[827416b191d7b3aa]::mir_promoted
  25:        0x1228d7451 - rustc_query_system[91c4ad596cfd42fe]::query::plumbing::try_execute_query::<rustc_query_impl[5858643fdf1b29eb]::plumbing::QueryCtxt, rustc_query_system[91c4ad596cfd42fe]::query::caches::DefaultCache<rustc_middle[d5319f07d231351a]::ty::WithOptConstParam<rustc_span[db835ecaf6c42563]::def_id::LocalDefId>, (&rustc_data_structures[8f5aaa015017f2be]::steal::Steal<rustc_middle[d5319f07d231351a]::mir::Body>, &rustc_data_structures[8f5aaa015017f2be]::steal::Steal<rustc_index[4370e6fc8b417ef]::vec::IndexVec<rustc_middle[d5319f07d231351a]::mir::Promoted, rustc_middle[d5319f07d231351a]::mir::Body>>)>>
  26:        0x1229fe350 - rustc_query_system[91c4ad596cfd42fe]::query::plumbing::get_query::<rustc_query_impl[5858643fdf1b29eb]::queries::mir_promoted, rustc_query_impl[5858643fdf1b29eb]::plumbing::QueryCtxt>
  27:        0x122aa8947 - <rustc_query_impl[5858643fdf1b29eb]::Queries as rustc_middle[d5319f07d231351a]::ty::query::QueryEngine>::mir_promoted
  28:        0x12249d47f - rustc_borrowck[85dfbb963c3a91f9]::mir_borrowck
  29:        0x122478355 - <rustc_borrowck[85dfbb963c3a91f9]::provide::{closure#0} as core[e7c8723dd1d9fd02]::ops::function::FnOnce<(rustc_middle[d5319f07d231351a]::ty::context::TyCtxt, rustc_span[db835ecaf6c42563]::def_id::LocalDefId)>>::call_once
  30:        0x1229895bf - rustc_query_system[91c4ad596cfd42fe]::query::plumbing::try_execute_query::<rustc_query_impl[5858643fdf1b29eb]::plumbing::QueryCtxt, rustc_query_system[91c4ad596cfd42fe]::query::caches::VecCache<rustc_span[db835ecaf6c42563]::def_id::LocalDefId, &rustc_middle[d5319f07d231351a]::mir::query::BorrowCheckResult>>
  31:        0x1229fe0b7 - rustc_query_system[91c4ad596cfd42fe]::query::plumbing::get_query::<rustc_query_impl[5858643fdf1b29eb]::queries::mir_borrowck, rustc_query_impl[5858643fdf1b29eb]::plumbing::QueryCtxt>
  32:        0x11f21804b - rustc_data_structures[8f5aaa015017f2be]::sync::par_for_each_in::<&[rustc_span[db835ecaf6c42563]::def_id::LocalDefId], <rustc_middle[d5319f07d231351a]::hir::map::Map>::par_body_owners<rustc_interface[6b0baa6f0acee236]::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>
  33:        0x11f189100 - <rustc_session[bf9d936332845243]::session::Session>::time::<(), rustc_interface[6b0baa6f0acee236]::passes::analysis::{closure#2}>
  34:        0x11f1cc1c3 - rustc_interface[6b0baa6f0acee236]::passes::analysis
  35:        0x12295878b - rustc_query_system[91c4ad596cfd42fe]::query::plumbing::try_execute_query::<rustc_query_impl[5858643fdf1b29eb]::plumbing::QueryCtxt, rustc_query_system[91c4ad596cfd42fe]::query::caches::DefaultCache<(), core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>>
  36:        0x122a12e8d - rustc_query_system[91c4ad596cfd42fe]::query::plumbing::get_query::<rustc_query_impl[5858643fdf1b29eb]::queries::analysis, rustc_query_impl[5858643fdf1b29eb]::plumbing::QueryCtxt>
  37:        0x11f0956d7 - <rustc_interface[6b0baa6f0acee236]::passes::QueryContext>::enter::<rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>
  38:        0x11f0dbb75 - <rustc_interface[6b0baa6f0acee236]::interface::Compiler>::enter::<rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}::{closure#2}, core[e7c8723dd1d9fd02]::result::Result<core[e7c8723dd1d9fd02]::option::Option<rustc_interface[6b0baa6f0acee236]::queries::Linker>, rustc_errors[5974999511236221]::ErrorGuaranteed>>
  39:        0x11f077d5d - rustc_span[db835ecaf6c42563]::with_source_map::<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  40:        0x11f0cea9d - <scoped_tls[9dceb67bf45baec5]::ScopedKey<rustc_span[db835ecaf6c42563]::SessionGlobals>>::set::<rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>
  41:        0x11f09dffa - std[e853a6d0ec043b70]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[6b0baa6f0acee236]::util::run_in_thread_pool_with_globals<rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>
  42:        0x11f07e2a5 - <<std[e853a6d0ec043b70]::thread::Builder>::spawn_unchecked_<rustc_interface[6b0baa6f0acee236]::util::run_in_thread_pool_with_globals<rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>::{closure#1} as core[e7c8723dd1d9fd02]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:        0x10f2fee87 - std::sys::unix::thread::Thread::new::thread_start::hb253bfeab5e611e1
  44:     0x7ff807a764e1 - __pthread_start

note: 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: rustc 1.67.0-nightly (1eb62b123 2022-11-27) running on x86_64-apple-darwin

query stack during panic:
#0 [mir_const_qualif] const checking `f`
#1 [mir_promoted] processing MIR for `f`
#2 [mir_borrowck] borrow-checking `f`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

Regression

Regression in nightly-2022-07-28, somewhere in rollup 2a22093

Very likely due to #99704, which added this assertion (@fee1-dead, @oli-obk)

Version

rustc 1.67.0-nightly (1eb62b123 2022-11-27)
binary: rustc
commit-hash: 1eb62b1235fd77200e6bd967d70e83c0f2497233
commit-date: 2022-11-27
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-const-fnArea: const fn foo(..) {..}. Pure functions which can be applied at compile time.C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions