Skip to content

ICE when writing a no_core binary #89578

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
0xAda opened this issue Oct 5, 2021 · 1 comment
Closed

ICE when writing a no_core binary #89578

0xAda opened this issue Oct 5, 2021 · 1 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.

Comments

@0xAda
Copy link

0xAda commented Oct 5, 2021

Code

#![feature(no_core)]
#![feature(lang_items)]
#![no_core]

#[cfg(target_os = "linux")]
#[link(name = "c")]
extern "C" {}

#[lang = "sized"]
pub trait Sized {}

#[lang = "copy"]
pub trait Copy {}

#[lang = "add"]
trait Add<RHS> {
    type Output;
    fn add(self, other: RHS) -> Self::Output;
}

impl Add<isize> for isize {
    type Output = isize;

    fn add(self, other: isize) -> Self::Output {
        self + other
    }
}

#[lang = "start"]
fn lang_start<T>(main: fn() -> T, argc: isize, argv: *const *const u8) -> isize {
    1 + 1
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.57.0-nightly (003d8d3f5 2021-10-04)
binary: rustc
commit-hash: 003d8d3f56848b6f3833340e859b089a09aea36a
commit-date: 2021-10-04
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0

Error output

error: internal compiler error: broken MIR in DefId(0:10 ~ nocoretest[4aa5]::{impl#0}::add) (NoSolution): could not prove Binder(TraitPredicate(<isize as Copy>), [])
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:330:27

Backtrace

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1165:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/003d8d3f56848b6f3833340e859b089a09aea36a/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/003d8d3f56848b6f3833340e859b089a09aea36a/library/core/src/panicking.rs:100:14
   2: core::panicking::panic_display
   3: rustc_errors::HandlerInner::flush_delayed
   4: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   6: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   7: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   8: rustc_span::with_source_map
   9: scoped_tls::ScopedKey<T>::set

@0xAda 0xAda 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 Oct 5, 2021
@jonas-schievink
Copy link
Contributor

Duplicate of #9307 – the compiler assumes that Copy is implemented by built-in types

# for free to join this conversation on GitHub. Already have an account? # 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.
Projects
None yet
Development

No branches or pull requests

2 participants