From 0de81dab0fcdb670eddaefecd6bd11629d2d6200 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 19 Jun 2022 18:23:11 -0700 Subject: [PATCH] Include r# in the invalid raw identifier panic This is how quote's implementation did it prior to https://github.com/dtolnay/quote/pull/225. --- src/fallback.rs | 2 +- tests/test.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fallback.rs b/src/fallback.rs index 6b7837e8..6afa790f 100644 --- a/src/fallback.rs +++ b/src/fallback.rs @@ -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); } _ => {} } diff --git a/tests/test.rs b/tests/test.rs index 0de78c38..86031db6 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -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()); }