1- // Here we test that `ast_validation ` behaves correctly wrt. `let $pats = $expr` expressions.
1+ // Here we test that `lowering ` behaves correctly wrt. `let $pats = $expr` expressions.
22//
33// We want to make sure that `let` is banned in situations other than:
44//
@@ -30,17 +30,22 @@ fn main() {}
3030
3131fn nested_within_if_expr ( ) {
3232 if & let 0 = 0 { } //~ ERROR `let` expressions are not supported here
33- //~^ ERROR `let` expressions only supported in `if`
33+ //~^ ERROR mismatched types
3434
3535 if !let 0 = 0 { } //~ ERROR `let` expressions are not supported here
3636 if * let 0 = 0 { } //~ ERROR `let` expressions are not supported here
37+ //~^ ERROR type `bool` cannot be dereferenced
3738 if -let 0 = 0 { } //~ ERROR `let` expressions are not supported here
39+ //~^ ERROR cannot apply unary operator `-` to type `bool`
3840
3941 fn _check_try_binds_tighter ( ) -> Result < ( ) , ( ) > {
4042 if let 0 = 0 ? { }
43+ //~^ ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
4144 Ok ( ( ) )
4245 }
4346 if ( let 0 = 0 ) ? { } //~ ERROR `let` expressions are not supported here
47+ //~^ ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
48+ //~| ERROR the `?` operator can only be used in a function that returns `Result`
4449
4550 if true || let 0 = 0 { } //~ ERROR `let` expressions are not supported here
4651 if ( true || let 0 = 0 ) { } //~ ERROR `let` expressions are not supported here
@@ -49,42 +54,62 @@ fn nested_within_if_expr() {
4954
5055 let mut x = true ;
5156 if x = let 0 = 0 { } //~ ERROR `let` expressions are not supported here
57+ //~^ ERROR mismatched types
5258
5359 if true ..( let 0 = 0 ) { } //~ ERROR `let` expressions are not supported here
60+ //~^ ERROR mismatched types
5461 if ..( let 0 = 0 ) { } //~ ERROR `let` expressions are not supported here
62+ //~^ ERROR mismatched types
5563 if ( let 0 = 0 ) .. { } //~ ERROR `let` expressions are not supported here
64+ //~^ ERROR mismatched types
5665
5766 // Binds as `(let ... = true)..true &&/|| false`.
5867 if let Range { start : _, end : _ } = true ..true && false { }
5968 //~^ ERROR `let` expressions are not supported here
69+ //~| ERROR mismatched types
70+ //~| ERROR mismatched types
6071 if let Range { start : _, end : _ } = true ..true || false { }
6172 //~^ ERROR `let` expressions are not supported here
73+ //~| ERROR mismatched types
74+ //~| ERROR mismatched types
6275
6376 // Binds as `(let Range { start: F, end } = F)..(|| true)`.
6477 const F : fn ( ) -> bool = || true ;
6578 if let Range { start : F , end } = F ..|| true { }
6679 //~^ ERROR `let` expressions are not supported here
80+ //~| ERROR mismatched types
81+ //~| ERROR mismatched types
82+ //~| ERROR mismatched types
6783
6884 // Binds as `(let Range { start: true, end } = t)..(&&false)`.
6985 let t = & & true ;
7086 if let Range { start : true , end } = t..&&false { }
7187 //~^ ERROR `let` expressions are not supported here
88+ //~| ERROR mismatched types
89+ //~| ERROR mismatched types
90+ //~| ERROR mismatched types
7291
7392 if let true = let true = true { } //~ ERROR `let` expressions are not supported here
7493}
7594
7695fn nested_within_while_expr ( ) {
7796 while & let 0 = 0 { } //~ ERROR `let` expressions are not supported here
97+ //~^ ERROR mismatched types
7898
7999 while !let 0 = 0 { } //~ ERROR `let` expressions are not supported here
80100 while * let 0 = 0 { } //~ ERROR `let` expressions are not supported here
101+ //~^ ERROR type `bool` cannot be dereferenced
81102 while -let 0 = 0 { } //~ ERROR `let` expressions are not supported here
103+ //~^ ERROR cannot apply unary operator `-` to type `bool`
82104
83105 fn _check_try_binds_tighter ( ) -> Result < ( ) , ( ) > {
84106 while let 0 = 0 ? { }
107+ //~^ ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
85108 Ok ( ( ) )
86109 }
87110 while ( let 0 = 0 ) ? { } //~ ERROR `let` expressions are not supported here
111+ //~^ ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
112+ //~| ERROR the `?` operator can only be used in a function that returns `Result`
88113
89114 while true || let 0 = 0 { } //~ ERROR `let` expressions are not supported here
90115 while ( true || let 0 = 0 ) { } //~ ERROR `let` expressions are not supported here
@@ -93,26 +118,40 @@ fn nested_within_while_expr() {
93118
94119 let mut x = true ;
95120 while x = let 0 = 0 { } //~ ERROR `let` expressions are not supported here
121+ //~^ ERROR mismatched types
96122
97123 while true ..( let 0 = 0 ) { } //~ ERROR `let` expressions are not supported here
124+ //~^ ERROR mismatched types
98125 while ..( let 0 = 0 ) { } //~ ERROR `let` expressions are not supported here
126+ //~^ ERROR mismatched types
99127 while ( let 0 = 0 ) .. { } //~ ERROR `let` expressions are not supported here
128+ //~^ ERROR mismatched types
100129
101130 // Binds as `(let ... = true)..true &&/|| false`.
102131 while let Range { start : _, end : _ } = true ..true && false { }
103132 //~^ ERROR `let` expressions are not supported here
133+ //~| ERROR mismatched types
134+ //~| ERROR mismatched types
104135 while let Range { start : _, end : _ } = true ..true || false { }
105136 //~^ ERROR `let` expressions are not supported here
137+ //~| ERROR mismatched types
138+ //~| ERROR mismatched types
106139
107140 // Binds as `(let Range { start: F, end } = F)..(|| true)`.
108141 const F : fn ( ) -> bool = || true ;
109142 while let Range { start : F , end } = F ..|| true { }
110143 //~^ ERROR `let` expressions are not supported here
144+ //~| ERROR mismatched types
145+ //~| ERROR mismatched types
146+ //~| ERROR mismatched types
111147
112148 // Binds as `(let Range { start: true, end } = t)..(&&false)`.
113149 let t = & & true ;
114150 while let Range { start : true , end } = t..&&false { }
115151 //~^ ERROR `let` expressions are not supported here
152+ //~| ERROR mismatched types
153+ //~| ERROR mismatched types
154+ //~| ERROR mismatched types
116155
117156 while let true = let true = true { } //~ ERROR `let` expressions are not supported here
118157}
@@ -132,13 +171,18 @@ fn outside_if_and_while_expr() {
132171
133172 !let 0 = 0 ; //~ ERROR `let` expressions are not supported here
134173 * let 0 = 0 ; //~ ERROR `let` expressions are not supported here
174+ //~^ ERROR type `bool` cannot be dereferenced
135175 -let 0 = 0 ; //~ ERROR `let` expressions are not supported here
176+ //~^ ERROR cannot apply unary operator `-` to type `bool`
136177
137178 fn _check_try_binds_tighter ( ) -> Result < ( ) , ( ) > {
138179 let 0 = 0 ?;
180+ //~^ ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
139181 Ok ( ( ) )
140182 }
141183 ( let 0 = 0 ) ?; //~ ERROR `let` expressions are not supported here
184+ //~^ ERROR the `?` operator can only be used in a function that returns `Result`
185+ //~| ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
142186
143187 true || let 0 = 0 ; //~ ERROR `let` expressions are not supported here
144188 ( true || let 0 = 0 ) ; //~ ERROR `let` expressions are not supported here
@@ -153,6 +197,7 @@ fn outside_if_and_while_expr() {
153197
154198 ( let Range { start : _, end : _ } = true ..true || false ) ;
155199 //~^ ERROR `let` expressions are not supported here
200+ //~| ERROR mismatched types
156201
157202 ( let true = let true = true ) ;
158203 //~^ ERROR `let` expressions are not supported here
@@ -161,6 +206,7 @@ fn outside_if_and_while_expr() {
161206 // Check function tail position.
162207 & let 0 = 0
163208 //~^ ERROR `let` expressions are not supported here
209+ //~| ERROR mismatched types
164210}
165211
166212// Let's make sure that `let` inside const generic arguments are considered.
@@ -170,14 +216,20 @@ fn inside_const_generic_arguments() {
170216
171217 if let A :: < {
172218 true && let 1 = 1 //~ ERROR `let` expressions are not supported here
219+ //~^ ERROR constant contains unimplemented expression type
220+ //~| ERROR constant contains unimplemented expression type
173221 } > :: O = 5 { }
174222
175223 while let A :: < {
176224 true && let 1 = 1 //~ ERROR `let` expressions are not supported here
225+ //~^ ERROR constant contains unimplemented expression type
226+ //~| ERROR constant contains unimplemented expression type
177227 } > :: O = 5 { }
178228
179229 if A :: < {
180230 true && let 1 = 1 //~ ERROR `let` expressions are not supported here
231+ //~^ ERROR constant contains unimplemented expression type
232+ //~| ERROR constant contains unimplemented expression type
181233 } > :: O == 5 { }
182234
183235 // In the cases above we have `ExprKind::Block` to help us out.
0 commit comments