-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #106844 - Ezrashaw:concat-negative-int-lit, r=dtolnay
allow negative numeric literals in `concat!` Fixes #106837 While *technically* negative numeric literals are implemented as unary operations, users can reasonably expect that negative literals are treated the same as positive literals.
- Loading branch information
Showing
5 changed files
with
45 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
fn main() { | ||
concat!(-42); | ||
concat!(-3.14); | ||
|
||
concat!(-"hello"); | ||
//~^ ERROR expected a literal | ||
|
||
concat!(--1); | ||
//~^ ERROR expected a literal | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error: expected a literal | ||
--> $DIR/issue-106837.rs:5:13 | ||
| | ||
LL | concat!(-"hello"); | ||
| ^^^^^^^^ | ||
| | ||
= note: only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()` | ||
|
||
error: expected a literal | ||
--> $DIR/issue-106837.rs:8:13 | ||
| | ||
LL | concat!(--1); | ||
| ^^^ | ||
| | ||
= note: only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()` | ||
|
||
error: aborting due to 2 previous errors | ||
|