-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #103914 - nnethercote:close-42326, r=petrochenkov
Make underscore_literal_suffix a hard error. It's been a warning for 5.5 years. Time to make it a hard error. Closes #42326. r? ``@pnkfelix``
- Loading branch information
Showing
4 changed files
with
28 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
// check-pass | ||
macro_rules! sink { | ||
($tt:tt) => {()} | ||
} | ||
|
||
fn main() { | ||
let _ = "Foo"_; | ||
//~^ WARNING underscore literal suffix is not allowed | ||
//~| WARNING this was previously accepted | ||
//~| NOTE issue #42326 | ||
//~^ ERROR underscore literal suffix is not allowed | ||
|
||
// This is ok, because `__` is a valid identifier and the macro consumes it | ||
// before proper parsing happens. | ||
let _ = sink!("Foo"__); | ||
|
||
// This is not ok, even as an input to a macro, because the `_` suffix is | ||
// never allowed. | ||
sink!("Foo"_); | ||
//~^ ERROR underscore literal suffix is not allowed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
warning: underscore literal suffix is not allowed | ||
--> $DIR/underscore-suffix-for-string.rs:4:18 | ||
error: underscore literal suffix is not allowed | ||
--> $DIR/underscore-suffix-for-string.rs:6:18 | ||
| | ||
LL | let _ = "Foo"_; | ||
| ^ | ||
|
||
error: underscore literal suffix is not allowed | ||
--> $DIR/underscore-suffix-for-string.rs:15:16 | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: see issue #42326 <https://github.com/rust-lang/rust/issues/42326> for more information | ||
LL | sink!("Foo"_); | ||
| ^ | ||
|
||
warning: 1 warning emitted | ||
error: aborting due to 2 previous errors | ||
|