Skip to content

Commit 58fb492

Browse files
committed
auto merge of #12893 : alexcrichton/rust/cfg-not, r=luqmana
The two commits have the details of the two fixes
2 parents 76e0e26 + 8e5ca4b commit 58fb492

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/libstd/rt/libunwind.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,26 @@ extern "C" {
101101
pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
102102
trace_argument: *libc::c_void)
103103
-> _Unwind_Reason_Code;
104-
#[cfg(not(target_os = "android"))]
104+
#[cfg(stage0, not(target_os = "android"))]
105105
pub fn _Unwind_GetIP(ctx: *_Unwind_Context) -> libc::uintptr_t;
106-
#[cfg(not(target_os = "android"))]
106+
#[cfg(stage0, not(target_os = "android"))]
107+
pub fn _Unwind_FindEnclosingFunction(pc: *libc::c_void) -> *libc::c_void;
108+
109+
#[cfg(not(stage0),
110+
not(target_os = "android"),
111+
not(target_os = "linux", target_arch = "arm"))]
112+
pub fn _Unwind_GetIP(ctx: *_Unwind_Context) -> libc::uintptr_t;
113+
#[cfg(not(stage0),
114+
not(target_os = "android"),
115+
not(target_os = "linux", target_arch = "arm"))]
107116
pub fn _Unwind_FindEnclosingFunction(pc: *libc::c_void) -> *libc::c_void;
108117
}
109118

110119
// On android, the function _Unwind_GetIP is a macro, and this is the expansion
111120
// of the macro. This is all copy/pasted directly from the header file with the
112121
// definition of _Unwind_GetIP.
113122
#[cfg(target_os = "android")]
123+
#[cfg(target_os = "linux", target_os = "arm")]
114124
pub unsafe fn _Unwind_GetIP(ctx: *_Unwind_Context) -> libc::uintptr_t {
115125
#[repr(C)]
116126
enum _Unwind_VRS_Result {
@@ -154,6 +164,7 @@ pub unsafe fn _Unwind_GetIP(ctx: *_Unwind_Context) -> libc::uintptr_t {
154164

155165
// This function also doesn't exist on android, so make it a no-op
156166
#[cfg(target_os = "android")]
167+
#[cfg(target_os = "linux", target_os = "arm")]
157168
pub unsafe fn _Unwind_FindEnclosingFunction(pc: *libc::c_void) -> *libc::c_void{
158169
pc
159170
}

src/libsyntax/attr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ pub fn test_cfg<AM: AttrMetaMethods, It: Iterator<AM>>
317317
debug!("not!");
318318
// inside #[cfg(not(...))], so these need to all
319319
// not match.
320-
not_cfgs.iter().all(|mi| {
320+
!not_cfgs.iter().all(|mi| {
321321
debug!("cfg(not({}[...]))", mi.name());
322-
!contains(cfg, *mi)
322+
contains(cfg, *mi)
323323
})
324324
}
325325
_ => contains(cfg, *cfg_mi)

src/test/run-pass/cfgs-on-items.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,24 @@
1616
fn foo1() -> int { 1 }
1717

1818
// !fooA AND !bar
19-
#[cfg(not(fooA, bar))]
19+
#[cfg(not(fooA), not(bar))]
2020
fn foo2() -> int { 2 }
2121

2222
// fooC OR (fooB AND !bar)
2323
#[cfg(fooC)]
2424
#[cfg(fooB, not(bar))]
2525
fn foo2() -> int { 3 }
2626

27+
// fooA AND bar
28+
#[cfg(fooA, bar)]
29+
fn foo3() -> int { 2 }
30+
31+
// !(fooA AND bar)
32+
#[cfg(not(fooA, bar))]
33+
fn foo3() -> int { 3 }
2734

2835
pub fn main() {
2936
assert_eq!(1, foo1());
3037
assert_eq!(3, foo2());
38+
assert_eq!(3, foo3());
3139
}

0 commit comments

Comments
 (0)