|
0 |
From 81fb2d97d3050b74dbdb83a9b4005a51b12cfaf1 Mon Sep 17 00:00:00 2001
|
|
1 |
From: Ximin Luo <infinity0@debian.org>
|
|
2 |
Date: Mon, 20 May 2019 20:18:24 -0700
|
|
3 |
Subject: [PATCH] Work around rust-lang/rust#58516
|
|
4 |
|
|
5 |
---
|
|
6 |
crates/macro-support/src/parser.rs | 21 +++++++++++++++++++--
|
|
7 |
1 file changed, 19 insertions(+), 2 deletions(-)
|
|
8 |
|
|
9 |
diff --git a/crates/macro-support/src/parser.rs b/crates/macro-support/src/parser.rs
|
|
10 |
index d00802ce80..ed04b13e0b 100644
|
|
11 |
--- a/src/parser.rs
|
|
12 |
+++ b/src/parser.rs
|
|
13 |
@@ -60,6 +60,7 @@ macro_rules! methods {
|
|
14 |
($(($name:ident $(($other:tt))*, $variant:ident($($contents:tt)*)),)*) => {
|
|
15 |
$(methods!(@method $name, $variant($($contents)*));)*
|
|
16 |
|
|
17 |
+ #[cfg(feature = "strict-macro")]
|
|
18 |
fn check_used(self) -> Result<(), Diagnostic> {
|
|
19 |
// Account for the fact this method was called
|
|
20 |
ATTRS.with(|state| state.checks.set(state.checks.get() + 1));
|
|
21 |
@@ -69,9 +70,12 @@ macro_rules! methods {
|
|
22 |
if used.get() {
|
|
23 |
continue
|
|
24 |
}
|
|
25 |
- if !cfg!(feature = "strict-macro") {
|
|
26 |
+ // The check below causes rustc to crash on powerpc64 platforms
|
|
27 |
+ // with an LLVM error. To avoid this, we instead use #[cfg()]
|
|
28 |
+ // and duplicate the function below. See #58516 for details.
|
|
29 |
+ /*if !cfg!(feature = "strict-macro") {
|
|
30 |
continue
|
|
31 |
- }
|
|
32 |
+ }*/
|
|
33 |
let span = match attr {
|
|
34 |
$(BindgenAttr::$variant(span, ..) => span,)*
|
|
35 |
};
|
|
36 |
@@ -79,6 +83,19 @@ macro_rules! methods {
|
|
37 |
}
|
|
38 |
Diagnostic::from_vec(errors)
|
|
39 |
}
|
|
40 |
+
|
|
41 |
+ #[cfg(not(feature = "strict-macro"))]
|
|
42 |
+ fn check_used(self) -> Result<(), Diagnostic> {
|
|
43 |
+ // Account for the fact this method was called
|
|
44 |
+ ATTRS.with(|state| state.checks.set(state.checks.get() + 1));
|
|
45 |
+ let mut errors = Vec::new();
|
|
46 |
+ for (used, attr) in self.attrs.iter() {
|
|
47 |
+ if used.get() {
|
|
48 |
+ continue
|
|
49 |
+ }
|
|
50 |
+ }
|
|
51 |
+ Diagnostic::from_vec(errors)
|
|
52 |
+ }
|
|
53 |
};
|
|
54 |
|
|
55 |
(@method $name:ident, $variant:ident(Span, String, Span)) => {
|