<p dir="auto">I was playing around with unsafe blocks with the code listed below and it failed with the following.<br>
System Info:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc 1.0.0-nightly (d3732a12e 2015-02-06 23:30:17 +0000)
host: 3.18.5-1-ARCH
architecture: x86_64"><pre class="notranslate"><code class="notranslate">rustc 1.0.0-nightly (d3732a12e 2015-02-06 23:30:17 +0000)
host: 3.18.5-1-ARCH
architecture: x86_64
</code></pre></div>
<p dir="auto">Example:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="extern crate libc;
pub struct TestBuffer&lt;T&gt; {
    start: *mut T,
    size: usize,
    curr: isize,
}

impl&lt;T: Send&gt; TestBuffer&lt;T&gt; {
    pub fn new(value: T, size: usize) -&gt; TestBuffer&lt;T&gt; {
        unsafe {
            let start = libc::malloc(
                (std::mem::size_of::&lt;T&gt;() * size)
                as libc::size_t) as *mut T;
            std::ptr::write(&amp;mut *start, value);
            TestBuffer{start: start, size: size, curr: 0}
        }
    }
}

impl&lt;T&gt; Iterator for TestBuffer&lt;T&gt; {
    type Item = T;
    fn next(&amp;mut self) -&gt; Option&lt;T&gt; {
        if self.curr &lt; (self.size as isize) {
            self.curr += 1;
        } else {
            ()
        }
        unsafe { Some(*self.start.offset(self.curr - 1)) }
    }
}
```rust

Running with `RUST_BACKTRACE=1`:
"><pre class="notranslate"><span class="pl-k">extern</span> <span class="pl-k">crate</span> libc<span class="pl-kos">;</span>
<span class="pl-k">pub</span> <span class="pl-k">struct</span> <span class="pl-smi">TestBuffer</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c1">start</span><span class="pl-kos">:</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-c1">size</span><span class="pl-kos">:</span> <span class="pl-smi">usize</span><span class="pl-kos">,</span>
    <span class="pl-c1">curr</span><span class="pl-kos">:</span> <span class="pl-smi">isize</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span>

<span class="pl-k">impl</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">:</span> <span class="pl-smi">Send</span><span class="pl-kos">&gt;</span> <span class="pl-smi">TestBuffer</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">pub</span> <span class="pl-k">fn</span> <span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-s1">value</span><span class="pl-kos">:</span> <span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-s1">size</span><span class="pl-kos">:</span> <span class="pl-smi">usize</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">TestBuffer</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-k">unsafe</span> <span class="pl-kos">{</span>
            <span class="pl-k">let</span> start = libc<span class="pl-kos">::</span><span class="pl-en">malloc</span><span class="pl-kos">(</span>
                <span class="pl-kos">(</span>std<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">T</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">*</span> size<span class="pl-kos">)</span>
                <span class="pl-k">as</span> libc<span class="pl-kos">::</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">T</span><span class="pl-kos">;</span>
            std<span class="pl-kos">::</span>ptr<span class="pl-kos">::</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> <span class="pl-c1">*</span>start<span class="pl-kos">,</span> value<span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-smi">TestBuffer</span><span class="pl-kos">{</span><span class="pl-c1">start</span><span class="pl-kos">:</span> start<span class="pl-kos">,</span> <span class="pl-c1">size</span><span class="pl-kos">:</span> size<span class="pl-kos">,</span> <span class="pl-c1">curr</span><span class="pl-kos">:</span> <span class="pl-c1">0</span><span class="pl-kos">}</span>
        <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">impl</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-smi">Iterator</span> <span class="pl-k">for</span> <span class="pl-smi">TestBuffer</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">type</span> <span class="pl-smi">Item</span> = <span class="pl-smi">T</span><span class="pl-kos">;</span>
    <span class="pl-k">fn</span> <span class="pl-en">next</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> <span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Option</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-k">if</span> <span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-c1">curr</span> &lt; <span class="pl-kos">(</span><span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-c1">size</span> <span class="pl-k">as</span> <span class="pl-smi">isize</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-c1">curr</span> += <span class="pl-c1">1</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
            <span class="pl-kos">(</span><span class="pl-kos">)</span>
        <span class="pl-kos">}</span>
        <span class="pl-k">unsafe</span> <span class="pl-kos">{</span> <span class="pl-v">Some</span><span class="pl-kos">(</span><span class="pl-c1">*</span><span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-c1">start</span><span class="pl-kos">.</span><span class="pl-en">offset</span><span class="pl-kos">(</span><span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-c1">curr</span> - <span class="pl-c1">1</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>
```rust

<span class="pl-v">Running</span> with `<span class="pl-v">RUST_BACKTRACE</span>=<span class="pl-c1">1</span>`<span class="pl-kos">:</span></pre></div>
<p dir="auto">Buff.rs:29:23: 29:56 error: internal compiler error: this path should not cause illegal move<br>
Buff.rs:29         unsafe { Some(*self.start.offset(self.curr - 1)) }<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', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:129</p>
<p dir="auto">stack backtrace:<br>
1:     0x7f93ce6cd250 - sys::backtrace::write::h361f9c7ed16d6f6eUsy<br>
2:     0x7f93ce6f0950 - failure::on_fail::h69f5f434699d11ccOWF<br>
3:     0x7f93ce6507d0 - rt::unwind::begin_unwind_inner::hc4455d84b00b874blBF<br>
4:     0x7f93cba20040 - rt::unwind::begin_unwind::h13236156776379767181<br>
5:     0x7f93cba1ffd0 - diagnostic::SpanHandler::span_bug::h5ec31613fa5cf53fBUE<br>
6:     0x7f93cc547270 - session::Session::span_bug::h5f8ab95419f97cb6xdq<br>
7:     0x7f93cd8375e0 - borrowck::build_borrowck_dataflow_data::h3de5b29d7c85ab98gVe<br>
8:     0x7f93cd833ed0 - borrowck::borrowck_fn::hac2da55ab2d59b33DSe<br>
9:     0x7f93cd837440 - visit::walk_method_helper::h7515637727083481066<br>
10:     0x7f93cd834ee0 - borrowck::borrowck_item::h918c0642f54f00c7BRe<br>
11:     0x7f93cd8356f0 - borrowck::check_crate::h5c36e499d0e6ca76tMe<br>
12:     0x7f93cecbfb20 - driver::phase_3_run_analysis_passes::h8f5a5e5500230bd1oGa<br>
13:     0x7f93ceca5a40 - driver::compile_input::hcb43bced2a0b021bCba<br>
14:     0x7f93ced77be0 - run_compiler::hb81cf958c2f963666ac<br>
15:     0x7f93ced76270 - thunk::F.Invoke&lt;A, R&gt;::invoke::h6159218808669033746<br>
16:     0x7f93ced751a0 - rt::unwind::try::try_fn::h8268217050585033268<br>
17:     0x7f93ce75ca90 - rust_try_inner<br>
18:     0x7f93ce75ca80 - rust_try<br>
19:     0x7f93ced75450 - thunk::F.Invoke&lt;A, R&gt;::invoke::h8703575304585054118<br>
20:     0x7f93ce6dce40 - sys:<g-emoji class="g-emoji" alias="thread" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f9f5.png">🧵</g-emoji>:thread_start::h35f66aa7ce5d7277LCB<br>
21:     0x7f93c870f250 - start_thread<br>
22:     0x7f93ce2d8219 - clone<br>
23:                0x0 - </p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="I'm still definitely a noobie just playing around, so this could definitely be my fault. Thanks in advance for the help. Any input or advice would also be appreciated."><pre class="notranslate"><code class="notranslate">I'm still definitely a noobie just playing around, so this could definitely be my fault. Thanks in advance for the help. Any input or advice would also be appreciated.
</code></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>