Skip to content

ICE: broken mir  #110683

Closed
Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

#![crate_type = "lib"]

use std::ops::Sub;
trait Vector2 {
    type ScalarType;

    fn from_values(x: Self::ScalarType, y: Self::ScalarType) -> Vec2
    where
        Self: Sized;

    fn x(&self) -> Self::ScalarType;
    fn y(&self) -> Self::ScalarType;
}

impl<T> Sub for dyn Vector2<ScalarType = T>
where
    T: Sub<Output = T>,
    (dyn Vector2<ScalarType = T>): Sized,
{
    type Output = dyn Vector2<ScalarType = T>;

    fn sub(self, rhs: Self) -> Self::Output {
        Self::from_values(self.x() - rhs.x(), self.y() - rhs.y())
    }
}

struct Vec2 {
    x: i32,
    y: i32,
}

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (fec9adcdb 2023-04-21)
binary: rustc
commit-hash: fec9adcdbc21469ef105162cc8cabf81c72d06be
commit-date: 2023-04-21
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

-
Backtrace

warning: fields `x` and `y` are never read
  --> treereduce.out:28:5
   |
27 | struct Vec2 {
   |        ---- fields in this struct
28 |     x: i32,
   |     ^
29 |     y: i32,
   |     ^
   |
   = note: `#[warn(dead_code)]` on by default

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DefId(0:12 ~ treereduce[24c2]::{impl#0}::sub) (Terminator { source_info: SourceInfo { span: treereduce.out:23:9: 23:66 (#0), scope: scope[0] }, kind: _0 = <dyn Vector2<ScalarType = T> as Vector2>::from_values(move _3, move _8) -> [return: bb7, unwind: bb10] }): call dest mismatch (dyn Vector2<ScalarType = T> <- Vec2): NoSolution
  --> treereduce.out:23:64
   |
23 |         Self::from_values(self.x() - rhs.x(), self.y() - rhs.y())
   |                                                                ^
   |
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
              1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
              2: <rustc_borrowck::type_check::TypeChecker>::typeck_mir
              3: rustc_borrowck::type_check::type_check
              4: rustc_borrowck::nll::compute_regions
              5: rustc_borrowck::do_mir_borrowck
              6: rustc_borrowck::mir_borrowck
              7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
              8: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>
              9: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#2}>
             10: rustc_interface::passes::analysis
             11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
             12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
             13: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             14: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
             15: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
             16: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             17: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             18: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
             19: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/fec9adcdbc21469ef105162cc8cabf81c72d06be/library/alloc/src/boxed.rs:1962:9
             20: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/fec9adcdbc21469ef105162cc8cabf81c72d06be/library/alloc/src/boxed.rs:1962:9
             21: std::sys::unix::thread::Thread::new::thread_start
                        at /rustc/fec9adcdbc21469ef105162cc8cabf81c72d06be/library/std/src/sys/unix/thread.rs:108:17
             22: <unknown>
             23: <unknown>


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.71.0-nightly (fec9adcdb 2023-04-21) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions