forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunused-parens-pinned-reference-patterns.rs
More file actions
56 lines (42 loc) · 1.55 KB
/
Copy pathunused-parens-pinned-reference-patterns.rs
File metadata and controls
56 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//@ run-rustfix
//@ check-pass
//@ normalize-stderr: "warning: 9 warnings emitted\n\n" -> "warning: 9 warnings emitted\n"
#![feature(pin_ergonomics, mut_ref)]
#![allow(dead_code)]
#![warn(unused_parens)]
fn pinned_reference_patterns(
pin_const: &pin const i32,
pin_mut: &pin mut i32,
nested_pin_const: &pin const &pin const i32,
) {
let &pin const (_x) = pin_const;
//~^ WARN unnecessary parentheses around pattern
let &pin const (mut _x) = pin_const;
//~^ WARN unnecessary parentheses around pattern
let &pin const (mut _x @ _) = pin_const;
//~^ WARN unnecessary parentheses around pattern
let &pin mut (mut _x) = pin_mut;
//~^ WARN unnecessary parentheses around pattern
let &pin const (&pin const _x) = nested_pin_const;
//~^ WARN unnecessary parentheses around pattern
let &pin const (ref pin const _x) = pin_const;
//~^ WARN unnecessary parentheses around pattern
let &pin mut (ref pin mut _x) = pin_mut;
//~^ WARN unnecessary parentheses around pattern
let &pin const (mut ref pin const _x) = pin_const;
//~^ WARN unnecessary parentheses around pattern
let &pin mut (mut ref pin mut _x) = pin_mut;
//~^ WARN unnecessary parentheses around pattern
}
fn pinned_or_patterns_are_still_ambiguous(pin_const: &pin const i32) {
match pin_const {
&pin const (0 | 1) => {}
_ => {}
}
}
fn plain_shared_reference_patterns_still_need_parens(shared: &i32) {
let &(mut _x) = shared;
let &(mut ref _x) = shared;
let &(mut ref pin const _x) = shared;
}
fn main() {}