7
7
#![ feature( auto_traits) ]
8
8
#![ feature( box_patterns) ]
9
9
#![ feature( const_trait_impl) ]
10
- #![ feature( decl_macro) ]
11
10
#![ feature( coroutines) ]
11
+ #![ feature( decl_macro) ]
12
12
#![ feature( explicit_tail_calls) ]
13
13
#![ feature( more_qualified_paths) ]
14
14
#![ feature( raw_ref_op) ]
@@ -97,6 +97,7 @@ fn test_expr() {
97
97
// ExprKind::MethodCall
98
98
c1 ! ( expr, [ x. f( ) ] , "x.f()" ) ;
99
99
c2 ! ( expr, [ x. f:: <u8 >( ) ] , "x.f::<u8>()" , "x.f :: < u8 > ()" ) ;
100
+ c2 ! ( expr, [ x. collect:: <Vec <_>>( ) ] , "x.collect::<Vec<_>>()" , "x.collect :: < Vec < _ >> ()" ) ;
100
101
101
102
// ExprKind::Tup
102
103
c1 ! ( expr, [ ( ) ] , "()" ) ;
@@ -107,6 +108,13 @@ fn test_expr() {
107
108
// ExprKind::Binary
108
109
c1 ! ( expr, [ true || false ] , "true || false" ) ;
109
110
c1 ! ( expr, [ true || false && false ] , "true || false && false" ) ;
111
+ c1 ! ( expr, [ a < 1 && 2 < b && c > 3 && 4 > d ] , "a < 1 && 2 < b && c > 3 && 4 > d" ) ;
112
+ c2 ! ( expr, [ a & b & !c ] , "a & b & !c" , "a & b &! c" ) ; // FIXME
113
+ c2 ! ( expr,
114
+ [ a + b * c - d + -1 * -2 - -3 ] ,
115
+ "a + b * c - d + -1 * -2 - -3" ,
116
+ "a + b * c - d + - 1 * - 2 - - 3"
117
+ ) ;
110
118
111
119
// ExprKind::Unary
112
120
c2 ! ( expr, [ * expr ] , "*expr" , "* expr" ) ;
@@ -129,18 +137,12 @@ fn test_expr() {
129
137
130
138
// ExprKind::If
131
139
c1 ! ( expr, [ if true { } ] , "if true {}" ) ;
132
- c1 ! ( expr,
133
- [ if true {
134
- } else {
135
- } ] ,
136
- "if true {} else {}"
137
- ) ;
138
- c1 ! ( expr,
139
- [ if let true = true {
140
- } else {
141
- } ] ,
142
- "if let true = true {} else {}"
140
+ c2 ! ( expr,
141
+ [ if :: std:: blah( ) { } else { } ] ,
142
+ "if ::std::blah() {} else {}" ,
143
+ "if :: std :: blah() {} else {}"
143
144
) ;
145
+ c1 ! ( expr, [ if let true = true { } else { } ] , "if let true = true {} else {}" ) ;
144
146
c1 ! ( expr,
145
147
[ if true {
146
148
} else if false {
@@ -205,30 +207,16 @@ fn test_expr() {
205
207
c1 ! ( expr, [ async move || self ] , "async move || self" ) ;
206
208
c1 ! ( expr, [ static || self ] , "static || self" ) ;
207
209
c1 ! ( expr, [ static move || self ] , "static move || self" ) ;
208
- #[ rustfmt:: skip] // https://github.com/rust-lang/rustfmt/issues/5149
209
- c1 ! ( expr,
210
- [ static async || self ] ,
211
- "static async || self"
212
- ) ;
213
- #[ rustfmt:: skip] // https://github.com/rust-lang/rustfmt/issues/5149
214
- c1 ! ( expr,
215
- [ static async move || self ] ,
216
- "static async move || self"
217
- ) ;
210
+ c1 ! ( expr, [ static async || self ] , "static async || self" ) ;
211
+ c1 ! ( expr, [ static async move || self ] , "static async move || self" ) ;
218
212
c1 ! ( expr, [ || -> u8 { self } ] , "|| -> u8 { self }" ) ;
219
213
c2 ! ( expr, [ 1 + || { } ] , "1 + (|| {})" , "1 + || {}" ) ; // AST??
220
214
221
215
// ExprKind::Block
222
216
c1 ! ( expr, [ { } ] , "{}" ) ;
223
217
c1 ! ( expr, [ unsafe { } ] , "unsafe {}" ) ;
224
218
c2 ! ( expr, [ ' a: { } ] , "'a: {}" , "'a : {}" ) ;
225
- c1 ! ( expr,
226
- [
227
- #[ attr]
228
- { }
229
- ] ,
230
- "#[attr] {}"
231
- ) ;
219
+ c1 ! ( expr, [ #[ attr] { } ] , "#[attr] {}" ) ;
232
220
c2 ! ( expr,
233
221
[
234
222
{
@@ -316,7 +304,6 @@ fn test_expr() {
316
304
317
305
// ExprKind::Struct
318
306
c1 ! ( expr, [ Struct { } ] , "Struct {}" ) ;
319
- #[ rustfmt:: skip] // https://github.com/rust-lang/rustfmt/issues/5151
320
307
c2 ! ( expr,
321
308
[ <Struct as Trait >:: Type { } ] ,
322
309
"<Struct as Trait>::Type {}" ,
@@ -379,6 +366,7 @@ fn test_item() {
379
366
"pub use crate::{a, b::c};" ,
380
367
"pub use crate :: { a, b :: c } ;"
381
368
) ;
369
+ c2 ! ( item, [ pub use A :: * ; ] , "pub use A::*;" , "pub use A :: * ;" ) ;
382
370
383
371
// ItemKind::Static
384
372
c2 ! ( item, [ pub static S : ( ) = { } ; ] , "pub static S: () = {};" , "pub static S : () = {} ;" ) ;
@@ -395,6 +383,16 @@ fn test_item() {
395
383
[ pub default const async unsafe extern "C" fn f( ) { } ] ,
396
384
"pub default const async unsafe extern \" C\" fn f() {}"
397
385
) ;
386
+ c2 ! ( item,
387
+ [ fn g<T >( t: Vec <Vec <Vec <T >>>) { } ] ,
388
+ "fn g<T>(t: Vec<Vec<Vec<T>>>) {}" ,
389
+ "fn g < T > (t : Vec < Vec < Vec < T >> >) {}"
390
+ ) ;
391
+ c2 ! ( item,
392
+ [ fn h<' a>( t: & ' a Vec <Cell <dyn D >>) { } ] ,
393
+ "fn h<'a>(t: &'a Vec<Cell<dyn D>>) {}" ,
394
+ "fn h < 'a > (t : & 'a Vec < Cell < dyn D >>) {}"
395
+ ) ;
398
396
399
397
// ItemKind::Mod
400
398
c2 ! ( item, [ pub mod m; ] , "pub mod m;" , "pub mod m ;" ) ;
@@ -404,21 +402,16 @@ fn test_item() {
404
402
405
403
// ItemKind::ForeignMod
406
404
c1 ! ( item, [ extern "C" { } ] , "extern \" C\" {}" ) ;
407
- #[ rustfmt:: skip]
408
405
c2 ! ( item,
409
406
[ pub extern "C" { } ] ,
410
407
"extern \" C\" {}" , // ??
411
408
"pub extern \" C\" {}"
412
409
) ;
413
- c1 ! ( item,
414
- [ unsafe extern "C++" { } ] ,
415
- "unsafe extern \" C++\" {}"
416
- ) ;
410
+ c1 ! ( item, [ unsafe extern "C++" { } ] , "unsafe extern \" C++\" {}" ) ;
417
411
418
412
// ItemKind::GlobalAsm: untestable because this test works pre-expansion.
419
413
420
414
// ItemKind::TyAlias
421
- #[ rustfmt:: skip]
422
415
c2 ! ( item,
423
416
[
424
417
pub default type Type <' a>: Bound
@@ -579,7 +572,6 @@ fn test_pat() {
579
572
c1 ! ( pat, [ Struct { .. } ] , "Struct { .. }" ) ;
580
573
c1 ! ( pat, [ Struct { x, .. } ] , "Struct { x, .. }" ) ;
581
574
c2 ! ( pat, [ Struct { x: _x, .. } ] , "Struct { x: _x, .. }" , "Struct { x : _x, .. }" ) ;
582
- #[ rustfmt:: skip] // https://github.com/rust-lang/rustfmt/issues/5151
583
575
c2 ! ( pat,
584
576
[ <Struct as Trait >:: Type { } ] ,
585
577
"<Struct as Trait>::Type {}" ,
@@ -669,6 +661,12 @@ fn test_stmt() {
669
661
c2 ! ( stmt, [ let _ ] , "let _;" , "let _" ) ;
670
662
c2 ! ( stmt, [ let x = true ] , "let x = true;" , "let x = true" ) ;
671
663
c2 ! ( stmt, [ let x: bool = true ] , "let x: bool = true;" , "let x : bool = true" ) ;
664
+ c2 ! ( stmt, [ let ( a, b) = ( 1 , 2 ) ] , "let (a, b) = (1, 2);" , "let(a, b) = (1, 2)" ) ; // FIXME
665
+ c2 ! ( stmt,
666
+ [ let ( a, b) : ( u32 , u32 ) = ( 1 , 2 ) ] ,
667
+ "let (a, b): (u32, u32) = (1, 2);" ,
668
+ "let(a, b) : (u32, u32) = (1, 2)"
669
+ ) ;
672
670
673
671
// StmtKind::Item
674
672
c2 ! ( stmt, [ struct S ; ] , "struct S;" , "struct S ;" ) ;
@@ -705,14 +703,14 @@ fn test_ty() {
705
703
c2 ! ( ty, [ & T ] , "&T" , "& T" ) ;
706
704
c2 ! ( ty, [ & mut T ] , "&mut T" , "& mut T" ) ;
707
705
c2 ! ( ty, [ & ' a T ] , "&'a T" , "& 'a T" ) ;
708
- c2 ! ( ty, [ & ' a mut T ] , "&'a mut T" , "& 'a mut T" ) ;
706
+ c2 ! ( ty, [ & ' a mut [ T ] ] , "&'a mut [T]" , "& 'a mut [T]" ) ;
707
+ c2 ! ( ty, [ & A <B <C <D <E >>>> ] , "&A<B<C<D<E>>>>" , "& A < B < C < D < E >> >>" ) ;
709
708
710
709
// TyKind::BareFn
711
710
c1 ! ( ty, [ fn ( ) ] , "fn()" ) ;
712
711
c1 ! ( ty, [ fn ( ) -> ( ) ] , "fn() -> ()" ) ;
713
712
c1 ! ( ty, [ fn ( u8 ) ] , "fn(u8)" ) ;
714
713
c2 ! ( ty, [ fn ( x: u8 ) ] , "fn(x: u8)" , "fn(x : u8)" ) ;
715
- #[ rustfmt:: skip]
716
714
c2 ! ( ty, [ for <> fn ( ) ] , "fn()" , "for < > fn()" ) ;
717
715
c2 ! ( ty, [ for <' a> fn ( ) ] , "for<'a> fn()" , "for < 'a > fn()" ) ;
718
716
@@ -760,7 +758,7 @@ fn test_ty() {
760
758
761
759
// TyKind::Infer
762
760
c1 ! ( ty, [ _ ] , "_" ) ;
763
-
761
+
764
762
// TyKind::ImplicitSelf: there is no syntax for this.
765
763
766
764
// TyKind::MacCall
0 commit comments