File tree Expand file tree Collapse file tree 2 files changed +98
-2
lines changed Expand file tree Collapse file tree 2 files changed +98
-2
lines changed Original file line number Diff line number Diff line change 1
- /* Tests proper formatting of pre and post cast ("as") comments */
1
+ /*****
2
+ * Tests for proper formatting of pre and post cast ("as") comments
3
+ ******/
2
4
3
5
// Test 1
4
6
fn main ( ) {
@@ -48,3 +50,49 @@ let x = 1 /* as foo yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy */
48
50
as /* as bar xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
49
51
i32 ;
50
52
}
53
+
54
+
55
+ /*****
56
+ * Tests for not leaving trailing spaces related to cast comments (related to #2896?)
57
+ ******/
58
+ // Test 10 - note the extra blank at the end of the 2nd line
59
+ fn main ( ) {
60
+ if 0 == 1
61
+ /* x */ as i32 { } }
62
+
63
+ // Test 11 - note the extra blank at the end of the 2nd line
64
+ fn main ( ) {
65
+ if 0 == ' '
66
+ as i32 { } }
67
+
68
+ // Test 10 - note the extra blank at the end of the 2nd line
69
+ fn main ( ) {
70
+ if 0 == ' ' /* x */
71
+ as i32 { } }
72
+
73
+
74
+ /*****
75
+ * Tests for not moving "as" to new line unnecessarily - from #3528
76
+ ******/
77
+ fn get_old_backends ( old_toml_config : & toml:: Value ) -> Option < Vec < Box < dyn Backend > > > {
78
+ old_toml_config. as_table ( ) . and_then ( |table| {
79
+ table
80
+ . get ( "backends" )
81
+ . and_then ( |backends| backends. as_table ( ) )
82
+ . map ( |backends| {
83
+ backends
84
+ . into_iter ( )
85
+ . filter_map ( |( key, value) | match AvailableBackend :: from ( key. as_str ( ) ) {
86
+ AvailableBackend :: Git => Some ( Box :: new ( Git {
87
+ config : value. clone ( ) . try_into :: < GitConfig > ( ) . unwrap ( ) ,
88
+ } )
89
+ as Box < dyn Backend > ) ,
90
+ AvailableBackend :: Github => Some ( Box :: new ( Github {
91
+ config : value. clone ( ) . try_into :: < GithubConfig > ( ) . unwrap ( ) ,
92
+ } )
93
+ as Box < dyn Backend > ) ,
94
+ } )
95
+ . collect ( )
96
+ } )
97
+ } )
98
+ }
Original file line number Diff line number Diff line change 1
- /* Tests proper formatting of pre and post cast ("as") comments */
1
+ /*****
2
+ * Tests for proper formatting of pre and post cast ("as") comments
3
+ ******/
2
4
3
5
// Test 1
4
6
fn main ( ) {
@@ -49,3 +51,49 @@ fn main() {
49
51
as /* as bar xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
50
52
i32 ;
51
53
}
54
+
55
+ /*****
56
+ * Tests for not leaving trailing spaces related to cast comments (related to #2896?)
57
+ ******/
58
+ // Test 10 - note the extra blank at the end of the 2nd line
59
+ fn main ( ) {
60
+ if 0 == 1 /* x */ as i32 { }
61
+ }
62
+
63
+ // Test 11 - note the extra blank at the end of the 2nd line
64
+ fn main ( ) {
65
+ if 0 == ' ' as i32 { }
66
+ }
67
+
68
+ // Test 10 - note the extra blank at the end of the 2nd line
69
+ fn main ( ) {
70
+ if 0 == ' ' /* x */ as i32 { }
71
+ }
72
+
73
+ /*****
74
+ * Tests for not moving "as" to new line unnecessarily - from #3528
75
+ ******/
76
+ fn get_old_backends ( old_toml_config : & toml:: Value ) -> Option < Vec < Box < dyn Backend > > > {
77
+ old_toml_config. as_table ( ) . and_then ( |table| {
78
+ table
79
+ . get ( "backends" )
80
+ . and_then ( |backends| backends. as_table ( ) )
81
+ . map ( |backends| {
82
+ backends
83
+ . into_iter ( )
84
+ . filter_map ( |( key, value) | match AvailableBackend :: from ( key. as_str ( ) ) {
85
+ AvailableBackend :: Git => {
86
+ Some ( Box :: new ( Git {
87
+ config : value. clone ( ) . try_into :: < GitConfig > ( ) . unwrap ( ) ,
88
+ } ) as Box < dyn Backend > )
89
+ }
90
+ AvailableBackend :: Github => {
91
+ Some ( Box :: new ( Github {
92
+ config : value. clone ( ) . try_into :: < GithubConfig > ( ) . unwrap ( ) ,
93
+ } ) as Box < dyn Backend > )
94
+ }
95
+ } )
96
+ . collect ( )
97
+ } )
98
+ } )
99
+ }
You can’t perform that action at this time.
0 commit comments