summaryrefslogtreecommitdiffstats
path: root/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.rs
blob: 75e5e7fd4211a9514b7a88b7d057566c160bb89f (plain)
1
2
3
4
5
6
7
8
9
10
// Check that when we clone a `&T` pointer we properly relate the
// lifetime of the pointer which results to the pointer being cloned.
// Bugs in method resolution have sometimes broken this connection.
// Issue #19261.

fn leak<'a, T>(x: T) -> &'a T {
    (&x).clone() //~ ERROR cannot return value referencing function parameter `x`
}

fn main() { }