]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-return-variable-on-stack-via-clone.rs
Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper
[rust.git] / tests / ui / borrowck / borrowck-return-variable-on-stack-via-clone.rs
1 // Check that when we clone a `&T` pointer we properly relate the
2 // lifetime of the pointer which results to the pointer being cloned.
3 // Bugs in method resolution have sometimes broken this connection.
4 // Issue #19261.
5
6 fn leak<'a, T>(x: T) -> &'a T {
7     (&x).clone() //~ ERROR cannot return value referencing function parameter `x`
8 }
9
10 fn main() { }