diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-08 11:51:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-08 11:51:09 +0100 |
| commit | 24757a82f183363c00c51de726a39126a45091ca (patch) | |
| tree | d4fc598e734358d5f076e45208138177da2a9929 /src | |
| parent | f459d2ed99f446a95dff044b980582895bd8782a (diff) | |
| parent | 33ebc20513c692691216ee1924d5cd29aca6f6aa (diff) | |
| download | rust-24757a82f183363c00c51de726a39126a45091ca.tar.gz rust-24757a82f183363c00c51de726a39126a45091ca.zip | |
Rollup merge of #69548 - LeSeulArtichaut:assert-errors, r=petrochenkov
Turn trailing tokens in `assert!()` into hard errors I didn't have time to build the compiler and thus edited the tests manually, I hope it will still pass. Closes #69531 r? @Centril do you want to queue the Crater experiment?
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_builtin_macros/assert.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/macros/assert-trailing-junk.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/macros/assert-trailing-junk.stderr | 14 |
3 files changed, 11 insertions, 21 deletions
diff --git a/src/librustc_builtin_macros/assert.rs b/src/librustc_builtin_macros/assert.rs index 5da4a540940..09ff770e87b 100644 --- a/src/librustc_builtin_macros/assert.rs +++ b/src/librustc_builtin_macros/assert.rs @@ -80,17 +80,15 @@ fn parse_assert<'a>( // my_function(); // ); // - // Warn about semicolon and suggest removing it. Eventually, this should be turned into an - // error. + // Emit an error about semicolon and suggest removing it. if parser.token == token::Semi { - let mut err = cx.struct_span_warn(sp, "macro requires an expression as an argument"); + let mut err = cx.struct_span_err(sp, "macro requires an expression as an argument"); err.span_suggestion( parser.token.span, "try removing semicolon", String::new(), Applicability::MaybeIncorrect, ); - err.note("this is going to be an error in the future"); err.emit(); parser.bump(); @@ -101,11 +99,10 @@ fn parse_assert<'a>( // // assert!(true "error message"); // - // Parse this as an actual message, and suggest inserting a comma. Eventually, this should be - // turned into an error. + // Emit an error and suggest inserting a comma. let custom_message = if let token::Literal(token::Lit { kind: token::Str, .. }) = parser.token.kind { - let mut err = cx.struct_span_warn(parser.token.span, "unexpected string literal"); + let mut err = cx.struct_span_err(parser.token.span, "unexpected string literal"); let comma_span = parser.prev_token.span.shrink_to_hi(); err.span_suggestion_short( comma_span, @@ -113,7 +110,6 @@ fn parse_assert<'a>( ", ".to_string(), Applicability::MaybeIncorrect, ); - err.note("this is going to be an error in the future"); err.emit(); parse_custom_message(&mut parser) diff --git a/src/test/ui/macros/assert-trailing-junk.rs b/src/test/ui/macros/assert-trailing-junk.rs index 676ae05bf0f..cd7faf9bf8b 100644 --- a/src/test/ui/macros/assert-trailing-junk.rs +++ b/src/test/ui/macros/assert-trailing-junk.rs @@ -13,12 +13,12 @@ fn main() { //~^ ERROR no rules expected assert!(true "whatever" blah); - //~^ WARN unexpected string literal + //~^ ERROR unexpected string literal //~^^ ERROR no rules expected assert!(true;); - //~^ WARN macro requires an expression + //~^ ERROR macro requires an expression assert!(false || true "error message"); - //~^ WARN unexpected string literal + //~^ ERROR unexpected string literal } diff --git a/src/test/ui/macros/assert-trailing-junk.stderr b/src/test/ui/macros/assert-trailing-junk.stderr index 4d18a531a80..84a6768b3f4 100644 --- a/src/test/ui/macros/assert-trailing-junk.stderr +++ b/src/test/ui/macros/assert-trailing-junk.stderr @@ -18,15 +18,13 @@ LL | assert!(true, "whatever" blah); | | | help: missing comma here -warning: unexpected string literal +error: unexpected string literal --> $DIR/assert-trailing-junk.rs:15:18 | LL | assert!(true "whatever" blah); | -^^^^^^^^^^ | | | help: try adding a comma - | - = note: this is going to be an error in the future error: no rules expected the token `blah` --> $DIR/assert-trailing-junk.rs:15:29 @@ -36,25 +34,21 @@ LL | assert!(true "whatever" blah); | | | help: missing comma here -warning: macro requires an expression as an argument +error: macro requires an expression as an argument --> $DIR/assert-trailing-junk.rs:19:5 | LL | assert!(true;); | ^^^^^^^^^^^^-^^ | | | help: try removing semicolon - | - = note: this is going to be an error in the future -warning: unexpected string literal +error: unexpected string literal --> $DIR/assert-trailing-junk.rs:22:27 | LL | assert!(false || true "error message"); | -^^^^^^^^^^^^^^^ | | | help: try adding a comma - | - = note: this is going to be an error in the future -error: aborting due to 4 previous errors +error: aborting due to 7 previous errors |
