]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/promote-ref-mut-in-let-issue-46557.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / promote-ref-mut-in-let-issue-46557.rs
1 // Test that we fail to promote the constant here which has a `ref
2 // mut` borrow.
3
4 fn gimme_static_mut_let() -> &'static mut u32 {
5     let ref mut x = 1234543;
6     x //~ ERROR
7 }
8
9 fn gimme_static_mut_let_nested() -> &'static mut u32 {
10     let (ref mut x, ) = (1234543, );
11     x //~ ERROR
12 }
13
14 fn gimme_static_mut_match() -> &'static mut u32 {
15     match 1234543 { //~ ERROR
16         ref mut x => x
17     }
18 }
19
20 fn gimme_static_mut_match_nested() -> &'static mut u32 {
21     match (123443,) { //~ ERROR
22         (ref mut x,) => x,
23     }
24 }
25
26 fn gimme_static_mut_ampersand() -> &'static mut u32 {
27     &mut 1234543 //~ ERROR
28 }
29
30 fn main() {
31 }