fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// Test the suggestion to remove a leading, or trailing `|`. 2 3// run-rustfix 4 5#![allow(warnings)] 6 7fn main() {} 8 9#[cfg(FALSE)] 10fn leading() { 11 fn fun1( A: E) {} //~ ERROR top-level or-patterns are not allowed 12 fn fun2( A: E) {} //~ ERROR unexpected `||` before function parameter 13 let ( | A): E; 14 let ( | A): (E); //~ ERROR unexpected token `||` in pattern 15 let ( | A,): (E,); 16 let [ | A ]: [E; 1]; 17 let [ | A ]: [E; 1]; //~ ERROR unexpected token `||` in pattern 18 let TS( | A ): TS; 19 let TS( | A ): TS; //~ ERROR unexpected token `||` in pattern 20 let NS { f: | A }: NS; 21 let NS { f: | A }: NS; //~ ERROR unexpected token `||` in pattern 22} 23 24#[cfg(FALSE)] 25fn trailing() { 26 let ( A ): E; //~ ERROR a trailing `|` is not allowed in an or-pattern 27 let (a ,): (E,); //~ ERROR a trailing `|` is not allowed in an or-pattern 28 let ( A | B ): E; //~ ERROR a trailing `|` is not allowed in an or-pattern 29 let [ A | B ]: [E; 1]; //~ ERROR a trailing `|` is not allowed in an or-pattern 30 let S { f: B }; //~ ERROR a trailing `|` is not allowed in an or-pattern 31 let ( A | B ): E; //~ ERROR unexpected token `||` in pattern 32 //~^ ERROR a trailing `|` is not allowed in an or-pattern 33 match A { 34 A => {} //~ ERROR a trailing `|` is not allowed in an or-pattern 35 A => {} //~ ERROR a trailing `|` is not allowed in an or-pattern 36 A | B => {} //~ ERROR unexpected token `||` in pattern 37 //~^ ERROR a trailing `|` is not allowed in an or-pattern 38 | A | B => {} 39 //~^ ERROR a trailing `|` is not allowed in an or-pattern 40 } 41 42 // These test trailing-vert in `let` bindings, but they also test that we don't emit a 43 // duplicate suggestion that would confuse rustfix. 44 45 let a : u8 = 0; //~ ERROR a trailing `|` is not allowed in an or-pattern 46 let a = 0; //~ ERROR a trailing `|` is not allowed in an or-pattern 47 let a ; //~ ERROR a trailing `|` is not allowed in an or-pattern 48}