Allow raw identifiers to be used as fluent arguments
This commit is contained in:
parent
8489a67f0b
commit
4d02892acf
4 changed files with 19 additions and 0 deletions
|
@ -281,6 +281,8 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
|
||||||
if should_generate_set_arg(&field) {
|
if should_generate_set_arg(&field) {
|
||||||
let diag = &self.parent.diag;
|
let diag = &self.parent.diag;
|
||||||
let ident = field.ident.as_ref().unwrap();
|
let ident = field.ident.as_ref().unwrap();
|
||||||
|
// strip `r#` prefix, if present
|
||||||
|
let ident = format_ident!("{}", ident);
|
||||||
return quote! {
|
return quote! {
|
||||||
#diag.set_arg(
|
#diag.set_arg(
|
||||||
stringify!(#ident),
|
stringify!(#ident),
|
||||||
|
|
|
@ -189,6 +189,9 @@ impl<'a> SubdiagnosticDeriveBuilder<'a> {
|
||||||
|
|
||||||
let diag = &self.diag;
|
let diag = &self.diag;
|
||||||
let ident = ast.ident.as_ref().unwrap();
|
let ident = ast.ident.as_ref().unwrap();
|
||||||
|
// strip `r#` prefix, if present
|
||||||
|
let ident = format_ident!("{}", ident);
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
#diag.set_arg(
|
#diag.set_arg(
|
||||||
stringify!(#ident),
|
stringify!(#ident),
|
||||||
|
|
|
@ -671,3 +671,9 @@ enum ExampleEnum {
|
||||||
#[diag(typeck::ambiguous_lifetime_bound)]
|
#[diag(typeck::ambiguous_lifetime_bound)]
|
||||||
Baz,
|
Baz,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
||||||
|
struct RawIdentDiagnosticArg {
|
||||||
|
pub r#type: String,
|
||||||
|
}
|
||||||
|
|
|
@ -633,3 +633,11 @@ struct BI {
|
||||||
#[suggestion_part(code = "")]
|
#[suggestion_part(code = "")]
|
||||||
spans: Vec<Span>,
|
spans: Vec<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Subdiagnostic)]
|
||||||
|
#[label(parser::add_paren)]
|
||||||
|
struct BJ {
|
||||||
|
#[primary_span]
|
||||||
|
span: Span,
|
||||||
|
r#type: String,
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue