]> git.lizzy.rs Git - rust.git/blob - tests/ui/typeck/assign-non-lval-derefmut.fixed
Auto merge of #106092 - asquared31415:start_lang_item_checks, r=davidtwco
[rust.git] / tests / ui / typeck / assign-non-lval-derefmut.fixed
1 // run-rustfix
2
3 fn main() {
4     let x = std::sync::Mutex::new(1usize);
5     *x.lock().unwrap() = 2;
6     //~^ ERROR invalid left-hand side of assignment
7     *x.lock().unwrap() += 1;
8     //~^ ERROR binary assignment operation `+=` cannot be applied to type `MutexGuard<'_, usize>`
9
10     let mut y = x.lock().unwrap();
11     *y = 2;
12     //~^ ERROR mismatched types
13     *y += 1;
14     //~^ ERROR binary assignment operation `+=` cannot be applied to type `MutexGuard<'_, usize>`
15 }