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 (delayed): broken MIR in DefId(...) (...): bad assignment (...): NoSolution #134587

Open
niacdoial opened this issue Dec 20, 2024 · 4 comments
Labels
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. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@niacdoial
Copy link
Contributor

Code

(one file: "ice-mwe.rs")

use std::ops::Add;

pub trait TimesTwo
   where *const Self: Add<*const Self>,
{
   extern "C" fn t2_ptr(slf: *const Self)
   -> <*const Self as Add<*const Self>>::Output {
       slf + slf
   }
}

fn main(){}

Meta

rustc --version --verbose:

rustc 1.85.0-nightly (9e136a30a 2024-12-19)
binary: rustc
commit-hash: 9e136a30a965bf4e63f03095c57df7257bf96fd6
commit-date: 2024-12-19
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6

Error output

(exact command used: rustc path/to/ice-mwe.rs)

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: broken MIR in DefId(0:5 ~ ice_mwe[fdb9]::TimesTwo::t2_ptr) (_0 = Add(move _2, move _3)): bad assignment (Alias(Projection, AliasTy { args: [*const Self/#0, *const Self/#0], def_id: DefId(2:3495 ~ core[57d6]::ops::arith::Add::Output), .. }) = *const Self/#0): NoSolution
 --> src/ice-mwe.rs:8:8
  |
8 |        slf + slf
  |        ^^^^^^^^^
  |
note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:1157:21 - disabled backtrace
 --> src/ice-mwe.rs:8:8
  |
8 |        slf + slf
  |        ^^^^^^^^^

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 `/home/niac/tmp/mwe/rustc-ice-2024-12-20T22_57_23-3180020.txt` to your bug report

query stack during panic:
end of query stack
Backtrace

(exact command used: RUST_BACKTRACE=1 rustc path/to/ice-mwe.rs)
(also downloadable as rustc-ice-2024-12-20T22_54_18-3179078.txt)

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: broken MIR in DefId(0:5 ~ ice_mwe[fdb9]::TimesTwo::t2_ptr) (_0 = Add(move _2, move _3)): bad assignment (Alias(Projection, AliasTy { args: [*const Self/#0, *const Self/#0], def_id: DefId(2:3495 ~ core[57d6]::ops::arith::Add::Output), .. }) = *const Self/#0): NoSolution
 --> src/ice-mwe.rs:8:8
  |
8 |        slf + slf
  |        ^^^^^^^^^
  |
note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:1157:21
         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, alloc::string::String>
         4: <rustc_borrowck::type_check::TypeChecker>::typeck_mir
         5: rustc_borrowck::type_check::type_check
         6: rustc_borrowck::nll::compute_regions
         7: rustc_borrowck::do_mir_borrowck
         8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         9: 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; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        10: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
        11: rustc_interface::passes::run_required_analyses
        12: rustc_interface::passes::analysis
        13: 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]>>
        14: 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>
        15: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        16: 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}
        17: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        18: 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}, ()>
        19: <<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}
        20: std::sys::pal::unix::thread::Thread::new::thread_start
        21: start_thread
        22: clone3
 --> src/ice-mwe.rs:8:8
  |
8 |        slf + slf
  |        ^^^^^^^^^

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 `/home/niac/tmp/mwe/rustc-ice-2024-12-20T22_54_18-3179078.txt` to your bug report

query stack during panic:
end of query stack

@niacdoial niacdoial 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 Dec 20, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 20, 2024
@cyrgani
Copy link
Contributor

cyrgani commented Dec 20, 2024

Reduced:

use std::ops::Add;

pub fn foo<T>(slf: *const T)
where
    *const T: Add,
{
    slf + slf;
}

@niacdoial
Copy link
Contributor Author

It also gives a different stack trace when using this variation of the reduced input. (and the ICE is no longer "delayed").
I think they likely have the same cause, but I can easily move this to a separate issue if need be.

use std::ops::Add;

pub fn foo<T>(slf: *const T)
where
    *const T: Add<u8>,
{
    slf + 1_u8;
}

(attached: the log file produced by running RUST_BACKTRACE=1 rustc on that new example (give or take a fn main(){} line))

@niacdoial
Copy link
Contributor Author

cargo bisect-rust can't get nightlies that far but...
this seems like a regression that took place somewhere between rust 1.1 and rust 1.2 :wheeze:
I'll continue the bisection from source (if that's possible) some other time

@saethlin
Copy link
Member

Bisecting back that far is unlikely to be useful because the compiler codebase has changed so much since then.

@saethlin saethlin added T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 22, 2024
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. 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. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants