forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#132363 - compiler-errors:raw-lt-id-valid, r…
…=wesleywiser Enforce that raw lifetimes must be valid raw identifiers Make sure that the identifier part of a raw lifetime is a valid raw identifier. This precludes `'r#_` and all module segment paths for now. I don't believe this is compelling to support. This was raised by `@ehuss` in rust-lang/reference#1603 (comment) (well, specifically the `'r#_` case), but I don't see why we shouldn't just make it consistent with raw identifiers.
- Loading branch information
Showing
5 changed files
with
72 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,20 @@ | ||
//@ edition: 2021 | ||
|
||
// Reject raw lifetimes with identifier parts that wouldn't be valid raw identifiers. | ||
|
||
macro_rules! w { | ||
($tt:tt) => {}; | ||
} | ||
|
||
w!('r#_); | ||
//~^ ERROR `_` cannot be a raw lifetime | ||
w!('r#self); | ||
//~^ ERROR `self` cannot be a raw lifetime | ||
w!('r#super); | ||
//~^ ERROR `super` cannot be a raw lifetime | ||
w!('r#Self); | ||
//~^ ERROR `Self` cannot be a raw lifetime | ||
w!('r#crate); | ||
//~^ ERROR `crate` cannot be a raw lifetime | ||
|
||
fn main() {} |
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,32 @@ | ||
error: `_` cannot be a raw lifetime | ||
--> $DIR/raw-lt-invalid-raw-id.rs:9:4 | ||
| | ||
LL | w!('r#_); | ||
| ^^^^ | ||
|
||
error: `self` cannot be a raw lifetime | ||
--> $DIR/raw-lt-invalid-raw-id.rs:11:4 | ||
| | ||
LL | w!('r#self); | ||
| ^^^^^^^ | ||
|
||
error: `super` cannot be a raw lifetime | ||
--> $DIR/raw-lt-invalid-raw-id.rs:13:4 | ||
| | ||
LL | w!('r#super); | ||
| ^^^^^^^^ | ||
|
||
error: `Self` cannot be a raw lifetime | ||
--> $DIR/raw-lt-invalid-raw-id.rs:15:4 | ||
| | ||
LL | w!('r#Self); | ||
| ^^^^^^^ | ||
|
||
error: `crate` cannot be a raw lifetime | ||
--> $DIR/raw-lt-invalid-raw-id.rs:17:4 | ||
| | ||
LL | w!('r#crate); | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|