Closed dwrensha closed 7 years ago
Consider the following program:
// test.rs #![feature(core_intrinsics)] pub trait Foo {} pub struct Bar; impl Foo for Bar {} pub fn main() { let b = Box::new(Bar) as Box<Foo>; let mut x: *const Foo = &*b; let y: *const Foo = &*b; unsafe { ::std::intrinsics::atomic_xchg(&mut x, y); } }
When I try to compile test.rs with rustc, I get a monomorphization error:
test.rs
$ rustc test.rs error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `*const Foo` --> test.rs:16:9 | 16 | ::std::intrinsics::atomic_xchg(&mut x, y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error(s)
When I run test.rs with miri, I expect to see a similar error. Instead, I get an "internal compiler error":
$ cargo run --bin miri -- test.rs Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs Running `target/debug/miri test.rs` error: internal compiler error: src/eval_context.rs:1143: value_to_primval can't work with fat pointers thread 'main' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:480
Similar to #181. If the rustc typechecker caught these errors then there would be no problem.
I'd consider this a dupe. Let's keep it all in the other issue.
Consider the following program:
When I try to compile
test.rs
with rustc, I get a monomorphization error:When I run
test.rs
with miri, I expect to see a similar error. Instead, I get an "internal compiler error":