How can this instance seemingly outlive its own parameter lifetime? : <p>Before I stumbled upon the code below, I was convinced that a lifetime in a type's lifetime parameter would always outlive its own instances. In other words, given a <code>foo: Foo&lt;'a&gt;</code>, then <code>'a</code> would always outlive <code>foo</code>. Then I was introduced to this counter-argument code by @Luc Danton (<a href="https://play.rust-lang.org/?gist=77356b872435d476359ec1e0602cc54c&amp;version=stable&amp;backtrace=0" rel="noreferrer">Playground</a>):</p>

<pre><code>#[derive(Debug)]
struct Foo&lt;'a&gt;(std::marker::PhantomData&lt;fn(&amp;'a ())&gt;);

fn hint&lt;'a, Arg&gt;(_: &amp;'a Arg) -&gt; Foo&lt;'a&gt; {
    Foo(std::marker::PhantomData)
}

fn check&lt;'a&gt;(_: &amp;Foo&lt;'a&gt;, _: &amp;'a ()) {}

fn main() {
    let outlived = ();
    let foo;

    {
        let shortlived = ();
        foo = hint(&amp;shortlived);
        // error: `shortlived` does not live long enough
        //check(&amp;foo, &amp;shortlived);
    }

    check(&amp;foo, &amp;outlived);
}
</code></pre>

<p>Even though the <code>foo</code> created by <code>hint</code> appears to consider a lifetime that does not live for as long as itself, and a reference to it is passed to a function in a wider scope, the code compiles exactly as it is. Uncommenting the line stated in the code triggers a compilation error. Alternatively, changing <code>Foo</code> to the struct tuple <code>(PhantomData&lt;&amp;'a ()&gt;)</code> also makes the code no longer compile with the same kind of error (<a href="https://play.rust-lang.org/?gist=9ad22db8a7d7bd0f764602098ffae9f3&amp;version=stable&amp;backtrace=0" rel="noreferrer">Playground</a>).</p>

<p>How is it valid Rust code? What is the reasoning of the compiler here?</p>
