Skip to content

Commit

Permalink
Include r# in the invalid raw identifier panic
Browse files Browse the repository at this point in the history
This is how quote's implementation did it prior to dtolnay/quote#225.
  • Loading branch information
dtolnay committed Jun 20, 2022
1 parent 9a4f130 commit 0de81da
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/fallback.rs
Expand Up @@ -702,7 +702,7 @@ fn validate_ident(string: &str, raw: bool) {
if raw {
match string {
"_" | "super" | "self" | "Self" | "crate" => {
panic!("`{}` cannot be a raw identifier", string);
panic!("`r#{}` cannot be a raw identifier", string);
}
_ => {}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test.rs
Expand Up @@ -24,13 +24,13 @@ fn raw_idents() {
}

#[test]
#[should_panic(expected = "`_` cannot be a raw identifier")]
#[should_panic(expected = "`r#_` cannot be a raw identifier")]
fn ident_raw_underscore() {
Ident::new_raw("_", Span::call_site());
}

#[test]
#[should_panic(expected = "`super` cannot be a raw identifier")]
#[should_panic(expected = "`r#super` cannot be a raw identifier")]
fn ident_raw_reserved() {
Ident::new_raw("super", Span::call_site());
}
Expand Down

0 comments on commit 0de81da

Please sign in to comment.