]> git.lizzy.rs Git - rust.git/blob - src/test/ui/match/match-ref-mut-let-invariance.rs
Make some diagnostics not depend on the source of what they reference being available
[rust.git] / src / test / ui / match / match-ref-mut-let-invariance.rs
1 // Check that when making a ref mut binding with type `&mut T`, the
2 // type `T` must match precisely the type `U` of the value being
3 // matched, and in particular cannot be some supertype of `U`. Issue
4 // #23116. This test focuses on a `let`.
5
6 #![allow(dead_code)]
7 struct S<'b>(&'b i32);
8 impl<'b> S<'b> {
9     fn bar<'a>(&'a mut self) -> &'a mut &'a i32 {
10         let ref mut x = self.0;
11         x
12         //~^ ERROR lifetime may not live long enough
13     }
14 }
15
16 fn main() {}