mirror of
https://github.com/topjohnwu/cxx.git
synced 2025-03-01 13:05:45 +00:00
Provide a suggestion to replace quoted raw identifier
This commit is contained in:
parent
dc5a920deb
commit
33432a868d
@ -36,15 +36,15 @@ fn parse_unquoted(input: ParseStream, allow_raw: bool) -> Result<QualifiedName>
|
||||
let leading_colons: Option<Token![::]> = input.parse()?;
|
||||
while trailing_punct && input.peek(Ident::peek_any) {
|
||||
let mut ident = Ident::parse_any(input)?;
|
||||
if ident.to_string().starts_with("r#") {
|
||||
if let Some(unraw) = ident.to_string().strip_prefix("r#") {
|
||||
if !allow_raw {
|
||||
let msg = format!(
|
||||
"raw identifier `{}` is not allowed in a quoted namespace",
|
||||
ident,
|
||||
"raw identifier `{}` is not allowed in a quoted namespace; use `{}`, or remove quotes",
|
||||
ident, unraw,
|
||||
);
|
||||
return Err(Error::new(ident.span(), msg));
|
||||
}
|
||||
ident = ident.unraw();
|
||||
ident = Ident::new(unraw, ident.span());
|
||||
}
|
||||
segments.push(ident);
|
||||
let colons: Option<Token![::]> = input.parse()?;
|
||||
|
@ -1,10 +1,10 @@
|
||||
error: raw identifier `r#box` is not allowed in a quoted namespace
|
||||
error: raw identifier `r#box` is not allowed in a quoted namespace; use `box`, or remove quotes
|
||||
--> tests/ui/raw_ident_namespace.rs:7:24
|
||||
|
|
||||
7 | type Id = type_id!("org::r#box::implementation::QuotedRaw");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: raw identifier `r#box` is not allowed in a quoted namespace
|
||||
error: raw identifier `r#box` is not allowed in a quoted namespace; use `box`, or remove quotes
|
||||
--> tests/ui/raw_ident_namespace.rs:38:23
|
||||
|
|
||||
38 | #[namespace = "org::r#box::implementation"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user