]> git.lizzy.rs Git - rust.git/blob - src/test/ui/match/match-ref-mut-let-invariance.rs
Auto merge of #93466 - cjgillot:query-dead, r=nagisa
[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 //~ ERROR mismatched types
12     }
13 }
14
15 fn main() {}