<p dir="auto">This complies ok:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct A(int);

impl A {
    unsafe fn a(&amp;self) -&gt; int { **self }
}

trait B {
    unsafe fn b(&amp;self) -&gt; int;
}

impl B for A {
    unsafe fn b(&amp;self) -&gt; int { **self }
}

fn main() {
    let _ = A(1).a();
    let _ = A(1).b();

    unsafe {
        let _ = A(1).a();
        let _ = A(1).b();
    }
}"><pre class="notranslate"><span class="pl-k">struct</span> <span class="pl-smi">A</span><span class="pl-kos">(</span><span class="pl-smi">int</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">impl</span> <span class="pl-smi">A</span> <span class="pl-kos">{</span>
    <span class="pl-k">unsafe</span> <span class="pl-k">fn</span> <span class="pl-en">a</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">int</span> <span class="pl-kos">{</span> <span class="pl-c1">*</span><span class="pl-c1">*</span><span class="pl-smi">self</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">trait</span> <span class="pl-smi">B</span> <span class="pl-kos">{</span>
    <span class="pl-k">unsafe</span> <span class="pl-k">fn</span> <span class="pl-en">b</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">int</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">impl</span> <span class="pl-smi">B</span> <span class="pl-k">for</span> <span class="pl-smi">A</span> <span class="pl-kos">{</span>
    <span class="pl-k">unsafe</span> <span class="pl-k">fn</span> <span class="pl-en">b</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">int</span> <span class="pl-kos">{</span> <span class="pl-c1">*</span><span class="pl-c1">*</span><span class="pl-smi">self</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> _ = <span class="pl-v">A</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">a</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> _ = <span class="pl-v">A</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">b</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-k">let</span> _ = <span class="pl-v">A</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">a</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-k">let</span> _ = <span class="pl-v">A</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">b</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">With this warning:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="unsafe-methods.rs:19:4: 22:5 warning: unnecessary `unsafe` block [-W unused-unsafe (default)]
unsafe-methods.rs:19     unsafe {
unsafe-methods.rs:20         let _ = A(1).a();
unsafe-methods.rs:21         let _ = A(1).b();
unsafe-methods.rs:22     }"><pre class="notranslate"><code class="notranslate">unsafe-methods.rs:19:4: 22:5 warning: unnecessary `unsafe` block [-W unused-unsafe (default)]
unsafe-methods.rs:19     unsafe {
unsafe-methods.rs:20         let _ = A(1).a();
unsafe-methods.rs:21         let _ = A(1).b();
unsafe-methods.rs:22     }
</code></pre></div>
<p dir="auto">Yikes.</p>
<p dir="auto">This compiles, and shouldn't:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="enum x = ();
impl x {
    unsafe fn with() { }
}

fn main() {
    x(()).with();
}"><pre class="notranslate"><code class="notranslate">enum x = ();
impl x {
    unsafe fn with() { }
}

fn main() {
    x(()).with();
}
</code></pre></div>