File tree 3 files changed +28
-0
lines changed
3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ pub fn expand_assert<'cx>(
24
24
tts : & [ TokenTree ] ,
25
25
) -> Box < dyn MacResult + ' cx > {
26
26
let mut parser = cx. new_parser_from_tts ( tts) ;
27
+
28
+ if parser. token == token:: Eof {
29
+ cx. struct_span_err ( sp, "macro requires a boolean expression as an argument" )
30
+ . span_label ( sp, "boolean expression required" )
31
+ . emit ( ) ;
32
+ return DummyResult :: expr ( sp) ;
33
+ }
34
+
27
35
let cond_expr = panictry ! ( parser. parse_expr( ) ) ;
28
36
let custom_msg_args = if parser. eat ( & token:: Comma ) {
29
37
let ts = parser. parse_tokens ( ) ;
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ assert ! ( ) ; //~ ERROR requires a boolean expression
3
+ debug_assert ! ( ) ; //~ ERROR requires a boolean expression
4
+ }
Original file line number Diff line number Diff line change
1
+ error: macro requires a boolean expression as an argument
2
+ --> $DIR/assert.rs:2:5
3
+ |
4
+ LL | assert!(); //~ ERROR requires a boolean expression
5
+ | ^^^^^^^^^^ boolean expression required
6
+
7
+ error: macro requires a boolean expression as an argument
8
+ --> $DIR/assert.rs:3:5
9
+ |
10
+ LL | debug_assert!(); //~ ERROR requires a boolean expression
11
+ | ^^^^^^^^^^^^^^^^ boolean expression required
12
+ |
13
+ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
14
+
15
+ error: aborting due to 2 previous errors
16
+
You can’t perform that action at this time.
0 commit comments