<p dir="auto">% RUST_BACKTRACE=1 rustc z.rs<br>
z.rs:32:23: 32:27 error: internal compiler error: this path should not cause illegal move<br>
z.rs:32     let xs = unsafe { *x.s };<br>
^~~~<br>
note: the compiler unexpectedly panicked. this is a bug.<br>
note: we would appreciate a bug report: <a href="http://doc.rust-lang.org/complement-bugreport.html" rel="nofollow">http://doc.rust-lang.org/complement-bugreport.html</a><br>
note: run with <code class="notranslate">RUST_BACKTRACE=1</code> for a backtrace<br>
thread 'rustc' panicked at 'Box', /Users/swizard/distr/rust/src/libsyntax/diagnostic.rs:129</p>
<p dir="auto">stack backtrace:<br>
1:        0x109ab2287 - sys::backtrace::write::h2b97e0c0d0aa5194lOu<br>
2:        0x109ad85f2 - failure::on_fail::h32ddd7e1e3390facx5B<br>
3:        0x109a33b88 - rt::unwind::begin_unwind_inner::hb37dbcf6d204588dZMB<br>
4:        0x1091a094f - rt::unwind::begin_unwind::h8510903163256875893<br>
5:        0x1091a08fc - diagnostic::SpanHandler::span_bug::hfcb4ef83c0f1c5bdUNE<br>
6:        0x10691b76d - session::Session::span_bug::hb8a1a20581917af1F2p<br>
7:        0x106895a2d - borrowck::build_borrowck_dataflow_data::h06a69dcffbac8f96gVe<br>
8:        0x106890f48 - borrowck::borrowck_fn::h7e0284b073f72b9eDSe<br>
9:        0x106891ef5 - borrowck::borrowck_item::hdde643940f987691BRe<br>
10:        0x1068925df - borrowck::check_crate::hbd8fcf67d63856aetMe<br>
11:        0x105fe9718 - driver::phase_3_run_analysis_passes::h96113b6369fd2034pGa<br>
12:        0x105fcd5a7 - driver::compile_input::hd95a9a5f39416926Cba<br>
13:        0x1060a0e3e - run_compiler::hae062a80d6febfab2ac<br>
14:        0x10609de2f - thunk::F.Invoke&lt;A, R&gt;::invoke::h7970639354112803481<br>
15:        0x10609cac0 - rt::unwind::try::try_fn::h3125464406127530110<br>
16:        0x109b51ce9 - rust_try_inner<br>
17:        0x109b51cd6 - rust_try<br>
18:        0x10609d180 - thunk::F.Invoke&lt;A, R&gt;::invoke::h13905946553486041138<br>
19:        0x109ac2bf3 - sys:<g-emoji class="g-emoji" alias="thread" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f9f5.png">🧵</g-emoji>:thread_start::h8b9ffeb7ea0667f4xVx<br>
20:     0x7fff87bec268 - _pthread_body<br>
21:     0x7fff87bec1e5 - _pthread_body</p>
<p dir="auto">% rustc --version --verbose<br>
rustc 1.0.0-dev (<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/rust-lang/rust/commit/7858cb432d3f2efc0374424cb2b51518f697c172/hovercard" href="https://github.com/rust-lang/rust/commit/7858cb432d3f2efc0374424cb2b51518f697c172"><tt>7858cb4</tt></a> 2015-02-03 03:44:05 +0000)<br>
binary: rustc<br>
commit-hash: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/rust-lang/rust/commit/7858cb432d3f2efc0374424cb2b51518f697c172/hovercard" href="https://github.com/rust-lang/rust/commit/7858cb432d3f2efc0374424cb2b51518f697c172"><tt>7858cb4</tt></a><br>
commit-date: 2015-02-03 03:44:05 +0000<br>
host: x86_64-apple-darwin<br>
release: 1.0.0-dev</p>
<p dir="auto">% uname -a<br>
Darwin pair 14.1.0 Darwin Kernel Version 14.1.0: Mon Dec 22 23:10:38 PST 2014; root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64</p>
<p dir="auto">% cat z.rs</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#![feature(libc,core,std_misc)]
extern crate libc;
use libc::{size_t, c_void};
use std::{mem};

extern {
    fn malloc(size: size_t) -&gt; *mut c_void;
}

#[repr(C)]
#[derive(Debug)]
#[allow(raw_pointer_derive)]
struct S_ {
    ext_value: *mut c_void,
}

#[derive(Debug)]
#[allow(raw_pointer_derive)]
pub struct S {
    s: *mut S_,
}

impl S {
    fn new() -&gt; S {
        let obj = unsafe { malloc(mem::size_of::&lt;S_&gt;() as size_t) as *mut S_ };
        S { s: obj }
    }
}

fn main() {
    let x = S::new();
    let xs = unsafe { *x.s };
    println!(&quot;x = {:?}, x.s = {:?}&quot;, x, xs);
}"><pre class="notranslate"><span class="pl-c1">#!<span class="pl-kos">[</span>feature<span class="pl-kos">(</span>libc<span class="pl-kos">,</span>core<span class="pl-kos">,</span>std_misc<span class="pl-kos">)</span><span class="pl-kos">]</span></span>
<span class="pl-k">extern</span> <span class="pl-k">crate</span> libc<span class="pl-kos">;</span>
<span class="pl-k">use</span> libc<span class="pl-kos">::</span><span class="pl-kos">{</span>size_t<span class="pl-kos">,</span> c_void<span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-k">use</span> std<span class="pl-kos">::</span><span class="pl-kos">{</span>mem<span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-k">extern</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">malloc</span><span class="pl-kos">(</span><span class="pl-s1">size</span><span class="pl-kos">:</span> <span class="pl-smi">size_t</span><span class="pl-kos">)</span> -&gt; <span class="pl-c1">*</span><span class="pl-k">mut</span> <span class="pl-smi">c_void</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-c1">#<span class="pl-kos">[</span>repr<span class="pl-kos">(</span><span class="pl-v">C</span><span class="pl-kos">)</span><span class="pl-kos">]</span></span>
<span class="pl-c1">#<span class="pl-kos">[</span>derive<span class="pl-kos">(</span><span class="pl-v">Debug</span><span class="pl-kos">)</span><span class="pl-kos">]</span></span>
<span class="pl-c1">#<span class="pl-kos">[</span>allow<span class="pl-kos">(</span>raw_pointer_derive<span class="pl-kos">)</span><span class="pl-kos">]</span></span>
<span class="pl-k">struct</span> <span class="pl-smi">S_</span> <span class="pl-kos">{</span>
    <span class="pl-c1">ext_value</span><span class="pl-kos">:</span> <span class="pl-c1">*</span><span class="pl-k">mut</span> <span class="pl-smi">c_void</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span>

<span class="pl-c1">#<span class="pl-kos">[</span>derive<span class="pl-kos">(</span><span class="pl-v">Debug</span><span class="pl-kos">)</span><span class="pl-kos">]</span></span>
<span class="pl-c1">#<span class="pl-kos">[</span>allow<span class="pl-kos">(</span>raw_pointer_derive<span class="pl-kos">)</span><span class="pl-kos">]</span></span>
<span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">S</span> <span class="pl-kos">{</span>
    <span class="pl-c1">s</span><span class="pl-kos">:</span> <span class="pl-c1">*</span><span class="pl-k">mut</span> <span class="pl-smi">S_</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span>

<span class="pl-k">impl</span> <span class="pl-smi">S</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">S</span> <span class="pl-kos">{</span>
        <span class="pl-k">let</span> obj = <span class="pl-k">unsafe</span> <span class="pl-kos">{</span> <span class="pl-en">malloc</span><span class="pl-kos">(</span>mem<span class="pl-kos">::</span><span class="pl-en">size_of</span><span class="pl-kos">::</span><span class="pl-kos">&lt;</span><span class="pl-smi">S_</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-k">as</span> <span class="pl-smi">size_t</span><span class="pl-kos">)</span> <span class="pl-k">as</span> <span class="pl-c1">*</span><span class="pl-k">mut</span> <span class="pl-smi">S_</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
        <span class="pl-smi">S</span> <span class="pl-kos">{</span> <span class="pl-c1">s</span><span class="pl-kos">:</span> obj <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> x = <span class="pl-smi">S</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> xs = <span class="pl-k">unsafe</span> <span class="pl-kos">{</span> <span class="pl-c1">*</span>x<span class="pl-kos">.</span><span class="pl-c1">s</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
    <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"x = {:?}, x.s = {:?}"</span>, x, xs<span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Input:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct T(u8);

fn t() -&gt; *mut T {
    unsafe { 0u8 as *mut T }
}

fn main() {
    let a = unsafe { *t() };
}"><pre class="notranslate"><span class="pl-k">struct</span> <span class="pl-smi">T</span><span class="pl-kos">(</span><span class="pl-smi">u8</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">fn</span> <span class="pl-en">t</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-c1">*</span><span class="pl-k">mut</span> <span class="pl-smi">T</span> <span class="pl-kos">{</span>
    <span class="pl-k">unsafe</span> <span class="pl-kos">{</span> <span class="pl-c1">0u8</span> <span class="pl-k">as</span> <span class="pl-c1">*</span><span class="pl-k">mut</span> <span class="pl-smi">T</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> a = <span class="pl-k">unsafe</span> <span class="pl-kos">{</span> <span class="pl-c1">*</span><span class="pl-en">t</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ rustc ../test.rs 
../test.rs:9:19: 9:23 error: internal compiler error: this path should not cause illegal move
../test.rs:9    let a = unsafe { *t() };
                                 ^~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box&lt;Any&gt;', /Users/John/Documents/dev/rust/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:        0x10f825b75 - sys::backtrace::write::h757d4037fec4513elCt
   2:        0x10f84800f - failure::on_fail::he99e1d2cd81a67a80Hz
   3:        0x10f7b3c8a - rt::unwind::begin_unwind_inner::hede15ebc165353e0Qpz
   4:        0x10d508707 - rt::unwind::begin_unwind::h5150449308391082809
   5:        0x10d50869c - diagnostic::SpanHandler::span_bug::h1cc7aa850b4525b9nQF
   6:        0x10c93bc1d - session::Session::span_bug::h9dff6f0c981e0b95mRq
   7:        0x10c547999 - borrowck::build_borrowck_dataflow_data::hbfab9f3785e58ec8QRe
   8:        0x10c5432fb - borrowck::borrowck_fn::h9d4d5a57ec1e26a2cPe
   9:        0x10c5440f2 - borrowck::borrowck_item::hd3de64f0b51b624a9Ne
  10:        0x10c54461f - borrowck::check_crate::hab49ad1d67fb67e9ZIe
  11:        0x10c09e8aa - driver::phase_3_run_analysis_passes::h3bf5eb3f470c8788gwa
  12:        0x10c082d90 - driver::compile_input::h63293298907e332cxba
  13:        0x10c14e7ba - monitor::unboxed_closure.22558
  14:        0x10c14cf15 - thunk::F.Invoke&lt;A, R&gt;::invoke::h15985566512806182469
  15:        0x10c14bcf0 - rt::unwind::try::try_fn::h5957420952141477940
  16:        0x10f8b1189 - rust_try_inner
  17:        0x10f8b1176 - rust_try
  18:        0x10c14c3ec - thunk::F.Invoke&lt;A, R&gt;::invoke::h12578415658120090831
  19:        0x10f835814 - sys::thread::thread_start::he6c5dcba45c95bf2drw
  20:     0x7fff933e22fc - _pthread_body
  21:     0x7fff933e2279 - _pthread_body"><pre class="notranslate"><code class="notranslate">$ rustc ../test.rs 
../test.rs:9:19: 9:23 error: internal compiler error: this path should not cause illegal move
../test.rs:9    let a = unsafe { *t() };
                                 ^~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box&lt;Any&gt;', /Users/John/Documents/dev/rust/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:        0x10f825b75 - sys::backtrace::write::h757d4037fec4513elCt
   2:        0x10f84800f - failure::on_fail::he99e1d2cd81a67a80Hz
   3:        0x10f7b3c8a - rt::unwind::begin_unwind_inner::hede15ebc165353e0Qpz
   4:        0x10d508707 - rt::unwind::begin_unwind::h5150449308391082809
   5:        0x10d50869c - diagnostic::SpanHandler::span_bug::h1cc7aa850b4525b9nQF
   6:        0x10c93bc1d - session::Session::span_bug::h9dff6f0c981e0b95mRq
   7:        0x10c547999 - borrowck::build_borrowck_dataflow_data::hbfab9f3785e58ec8QRe
   8:        0x10c5432fb - borrowck::borrowck_fn::h9d4d5a57ec1e26a2cPe
   9:        0x10c5440f2 - borrowck::borrowck_item::hd3de64f0b51b624a9Ne
  10:        0x10c54461f - borrowck::check_crate::hab49ad1d67fb67e9ZIe
  11:        0x10c09e8aa - driver::phase_3_run_analysis_passes::h3bf5eb3f470c8788gwa
  12:        0x10c082d90 - driver::compile_input::h63293298907e332cxba
  13:        0x10c14e7ba - monitor::unboxed_closure.22558
  14:        0x10c14cf15 - thunk::F.Invoke&lt;A, R&gt;::invoke::h15985566512806182469
  15:        0x10c14bcf0 - rt::unwind::try::try_fn::h5957420952141477940
  16:        0x10f8b1189 - rust_try_inner
  17:        0x10f8b1176 - rust_try
  18:        0x10c14c3ec - thunk::F.Invoke&lt;A, R&gt;::invoke::h12578415658120090831
  19:        0x10f835814 - sys::thread::thread_start::he6c5dcba45c95bf2drw
  20:     0x7fff933e22fc - _pthread_body
  21:     0x7fff933e2279 - _pthread_body
</code></pre></div>