]> git.lizzy.rs Git - rust.git/blob - tests/ui/temporary_assignment.rs
Adapt the *.stderr files of the ui-tests to the tool_lints
[rust.git] / tests / ui / temporary_assignment.rs
1 #![feature(tool_lints)]
2
3
4 #![warn(clippy::temporary_assignment)]
5
6 use std::ops::{Deref, DerefMut};
7
8 struct Struct {
9     field: i32
10 }
11
12 struct Wrapper<'a> {
13     inner: &'a mut Struct
14 }
15
16 impl<'a> Deref for Wrapper<'a> {
17     type Target = Struct;
18     fn deref(&self) -> &Struct { self.inner }
19 }
20
21 impl<'a> DerefMut for Wrapper<'a> {
22     fn deref_mut(&mut self) -> &mut Struct { self.inner }
23 }
24
25 fn main() {
26     let mut s = Struct { field: 0 };
27     let mut t = (0, 0);
28
29     Struct { field: 0 }.field = 1;
30     (0, 0).0 = 1;
31
32     // no error
33     s.field = 1;
34     t.0 = 1;
35     Wrapper { inner: &mut s }.field = 1;
36 }