<p dir="auto">It seems that <code class="notranslate">rustc</code> does not check if the type paramater satisfy the declared type bounds in trait and impl function definitions, but only for bare functions. <code class="notranslate">Rustc</code> fails on the following code with the following, rather confusing, error message: <code class="notranslate">type &amp;mut std::collections::hash::set::HashSet&lt;[u8]&gt; does not implement any method in scope named insert</code></p>
<p dir="auto">But I think that <code class="notranslate">rustc</code> should fail at an earlier stage, because <code class="notranslate">[u8]</code> does not implement <code class="notranslate">core::marker::Sized</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="use std::collections::HashSet;

struct Bar;

impl Bar {
    fn test(bar: &amp;mut HashSet&lt;[u8]&gt;) {
        let x: [u8; 3] = [1, 2, 3];
        bar.insert(x);
    }
}

trait Foo {
    fn test(&amp;self, _: &amp;mut HashSet&lt;[u8]&gt;);
}"><pre class="notranslate"><code class="notranslate">use std::collections::HashSet;

struct Bar;

impl Bar {
    fn test(bar: &amp;mut HashSet&lt;[u8]&gt;) {
        let x: [u8; 3] = [1, 2, 3];
        bar.insert(x);
    }
}

trait Foo {
    fn test(&amp;self, _: &amp;mut HashSet&lt;[u8]&gt;);
}
</code></pre></div>
<p dir="auto">The following code is a more general example and does not depend on any library.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="trait Cons {
    fn myFn(&amp;self);
}

struct Foo&lt;T: Cons&gt; {
    field: T
}

trait Kaboom {
    fn foo(&amp;self, x: Foo&lt;u8&gt;) {}
   // this does NOT fail, but Foo&lt;u8&gt; is no valid type
}

struct KaboomStruct;

impl KaboomStruct {
    fn bar(&amp;self, x: Foo&lt;u8&gt;) {}
   // this does NOT fail, but Foo&lt;u8&gt; is no valid type
}

fn foo(x: Foo&lt;u8&gt;) {}
// this fails, beacuse u8 does not implement Cons"><pre class="notranslate"><code class="notranslate">trait Cons {
    fn myFn(&amp;self);
}

struct Foo&lt;T: Cons&gt; {
    field: T
}

trait Kaboom {
    fn foo(&amp;self, x: Foo&lt;u8&gt;) {}
   // this does NOT fail, but Foo&lt;u8&gt; is no valid type
}

struct KaboomStruct;

impl KaboomStruct {
    fn bar(&amp;self, x: Foo&lt;u8&gt;) {}
   // this does NOT fail, but Foo&lt;u8&gt; is no valid type
}

fn foo(x: Foo&lt;u8&gt;) {}
// this fails, beacuse u8 does not implement Cons
</code></pre></div>
<p dir="auto">Now that <a href="https://github.com/rust-lang/rfcs/blob/master/text/0517-io-os-reform.md">IO reform</a> is complete, we have a large number of "primitive" IO APIs -- functions in Rust that roughly correspond to a single system API, like opening a file or extracting its metadata.</p>
<p dir="auto">We need to go through all of these APIs and add a section like <code class="notranslate"># Platform notes</code> which details which system API(s) are being used for each platform (usually, a Unix/Windows division suffices).</p>
<p dir="auto">This documentation is very important for understanding the interaction of the <code class="notranslate">std</code> IO APIs with the underlying system, which is relevant when using lowering APIs, when sandboxing and application, and likely for other scenarios as well.</p>