<story><title>Cve-rs: Fast memory vulnerabilities, written in safe Rust</title><url>https://github.com/Speykious/cve-rs</url></story><parent_chain><item><author>dgfitz</author><text>Looking at the syntax in that bug report makes me think I could never learn rust.</text></item><item><author>dralley</author><text>Seems to rely on at least one known compiler bug (admittedly one open since 2015) &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;rust-lang&amp;#x2F;rust&amp;#x2F;issues&amp;#x2F;25860&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;rust-lang&amp;#x2F;rust&amp;#x2F;issues&amp;#x2F;25860&lt;/a&gt;</text></item></parent_chain><comment><author>oneshtein</author><text>`&amp;amp;` is a reference.&lt;p&gt;`&amp;#x27;a` is a label for a memory area, like goto labels in C but for data. You can read it as (memory) pool A. Roughly, when function entered, memory pool is created, then destroyed at exit.&lt;p&gt;`&amp;#x27;static` is special label for static data (embedded constants).&lt;p&gt;`()` is nothing, like void in C.&lt;p&gt;`&amp;amp;()` is an reference to nothing (an address) like `void const *` in C.&lt;p&gt;`&amp;amp;&amp;amp;()` is an reference to reference to nothing, like `void const * const *` in C.&lt;p&gt;`&amp;amp; &amp;#x27;static &amp;amp; &amp;#x27;static ()` is like void `const * const *` to a built-in data in C.&lt;p&gt;`&amp;amp; &amp;#x27;a &amp;amp; &amp;#x27;b ()` tells compiler that second reference is stored in pool &amp;#x27;a, while data is stored in pool &amp;#x27;b. (First reference is in scope of current function.)&lt;p&gt;`_` is a special prefix for variables to instruct compiler to ignore warning about unused variable. Just `_` is a valid variable name too.&lt;p&gt;&lt;pre&gt;&lt;code&gt;  static UNIT: &amp;amp;&amp;#x27;static &amp;amp;&amp;#x27;static () = &amp;amp;&amp;amp;();

  fn foo&amp;lt;&amp;#x27;a, &amp;#x27;b, T&amp;gt;(_: &amp;amp;&amp;#x27;a &amp;amp;&amp;#x27;b (), v: &amp;amp;&amp;#x27;b T) -&amp;gt; &amp;amp;&amp;#x27;a T { v }
&lt;/code&gt;&lt;/pre&gt;
Let&amp;#x27;s say that `&amp;amp;&amp;#x27;a` is from a function `a()`, while `&amp;amp;&amp;#x27;b` is from a function `b()`, which called from the function `a()`.&lt;p&gt;The trick here is that we relabel reference from pool `&amp;#x27;b`, from an inner function, to pool `&amp;#x27;a` from outer function, so when program will exit from function `b()`, compiler will destroy memory pool `&amp;#x27;b`, but will keep reference to data inside until end of the function `a()`.&lt;p&gt;This should not be allowed.</text></comment>
<story><title>Cve-rs: Fast memory vulnerabilities, written in safe Rust</title><url>https://github.com/Speykious/cve-rs</url></story><parent_chain><item><author>dgfitz</author><text>Looking at the syntax in that bug report makes me think I could never learn rust.</text></item><item><author>dralley</author><text>Seems to rely on at least one known compiler bug (admittedly one open since 2015) &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;rust-lang&amp;#x2F;rust&amp;#x2F;issues&amp;#x2F;25860&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;rust-lang&amp;#x2F;rust&amp;#x2F;issues&amp;#x2F;25860&lt;/a&gt;</text></item></parent_chain><comment><author>faitswulff</author><text>You could also think of it as &amp;quot;look at all the weird syntax olympics you need to do in order to trigger a compiler edge case!&amp;quot;</text></comment>