From d97e7078028ca70489d988b2675a0baa99651c49 Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Tue, 2 Mar 2021 21:27:54 +0100 Subject: [PATCH] Pass through cfg attrs Otherwise things like cfg(target_os = "android") cannot be used within a cxx bridge. Resolves error: error: unsupported attribute --> system/bt/gd/rust/common/src/sys_prop.rs:4:1 | 4 | #[cfg(target_os = "android")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When updating to cxx version 1.0.x in AOSP. https://cs.android.com/android/platform/superproject/+/master:system/bt/gd/rust/common/src/sys_prop.rs;l=3 --- syntax/attrs.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/syntax/attrs.rs b/syntax/attrs.rs index 4808f2e1e..b1811e091 100644 --- a/syntax/attrs.rs +++ b/syntax/attrs.rs @@ -131,6 +131,10 @@ pub fn parse(cx: &mut Errors, attrs: Vec, mut parser: Parser) -> Othe // https://doc.rust-lang.org/reference/attributes/diagnostics.html passthrough_attrs.push(attr); continue; + } else if attr.path.is_ident("cfg") + { + passthrough_attrs.push(attr); + continue; } else if attr.path.segments.len() > 1 { let tool = &attr.path.segments.first().unwrap().ident; if tool == "rustfmt" {