]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/patterns.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / patterns.rs
CommitLineData
781aab86 1//@aux-build:proc_macros.rs
f20569fa 2#![warn(clippy::all)]
2b03887a
FG
3#![allow(unused)]
4#![allow(clippy::uninlined_format_args)]
f20569fa 5
fe692bf9
FG
6#[macro_use]
7extern crate proc_macros;
8
f20569fa
XL
9fn main() {
10 let v = Some(true);
11 let s = [0, 1, 2, 3, 4];
12 match v {
13 Some(x) => (),
14 y @ _ => (),
15 }
16 match v {
17 Some(x) => (),
18 y @ None => (), // no error
19 }
20 match s {
21 [x, inside @ .., y] => (), // no error
22 [..] => (),
23 }
24
25 let mut mutv = vec![1, 2, 3];
26
27 // required "ref" left out in suggestion: #5271
28 match mutv {
29 ref mut x @ _ => {
30 x.push(4);
31 println!("vec: {:?}", x);
32 },
33 ref y if y == &vec![0] => (),
34 }
35
36 match mutv {
37 ref x @ _ => println!("vec: {:?}", x),
38 ref y if y == &vec![0] => (),
39 }
fe692bf9
FG
40 external! {
41 let v = Some(true);
42 match v {
43 Some(x) => (),
44 y @ _ => (),
45 }
46 }
f20569fa 47}