From 04f020bd00cdbaacc0e206fa783f546f6dd57e44 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 5 Sep 2017 10:23:12 -0700 Subject: Use the `quote!` macro for `link_name` attributes The latest `rustfmt` has fixed the formatting bugs we were running into. --- src/codegen/helpers.rs | 9 +++------ tests/expectations/tests/mangling-win32.rs | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs index 822922cd..5136d787 100644 --- a/src/codegen/helpers.rs +++ b/src/codegen/helpers.rs @@ -45,12 +45,9 @@ pub mod attributes { } pub fn link_name(name: &str) -> quote::Tokens { - // This is ridiculous, but rustfmt doesn't seem to be formatting - // `link_name` attributes very well, so we jump through these formatting - // hoops to make it work. - let mut tokens = quote! {}; - tokens.append(format!(" #[link_name = \"{}\"]", name)); - tokens + quote! { + #[link_name = #name] + } } } diff --git a/tests/expectations/tests/mangling-win32.rs b/tests/expectations/tests/mangling-win32.rs index bea6baf1..747ccbf5 100644 --- a/tests/expectations/tests/mangling-win32.rs +++ b/tests/expectations/tests/mangling-win32.rs @@ -13,7 +13,7 @@ pub struct Foo { pub _address: u8, } extern "C" { - #[link_name = "?sBar@Foo@@2_NA"] + #[link_name = "\u{1}?sBar@Foo@@2_NA"] pub static mut Foo_sBar: bool; } #[test] -- cgit v1.2.3