From f121b1a3a96d34909d148a31e7082c78da51111b Mon Sep 17 00:00:00 2001 From: Andrew Audibert Date: Sat, 28 Jul 2018 19:38:14 -0700 Subject: [PATCH] Support raw identifiers in struct expressions --- src/expr.rs | 2 +- tests/target/raw_identifiers.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index 6814b91e0532..8118e3bccfd6 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1651,7 +1651,7 @@ pub fn rewrite_field( if !attrs_str.is_empty() { attrs_str.push_str(&shape.indent.to_string_with_newline(context.config)); }; - let name = &field.ident.name.to_string(); + let name = context.snippet(field.ident.span); if field.is_shorthand { Some(attrs_str + &name) } else { diff --git a/tests/target/raw_identifiers.rs b/tests/target/raw_identifiers.rs index 4abb22b88b7a..dd76117fa8ee 100644 --- a/tests/target/raw_identifiers.rs +++ b/tests/target/raw_identifiers.rs @@ -10,7 +10,7 @@ fn main() { #[r#attr] r#foo::r#bar(); - let r#local = 3; + let r#local = r#Struct { r#field: () }; let r#async = r#foo(r#local); r#macro!();