Skip to content

Commit b7af250

Browse files
committed
Rolling up PRs in the queue
Closes #14797 (librustc: Fix the issue with labels shadowing variable names by making) Closes #14823 (Improve error messages for io::fs) Closes #14827 (libsyntax: Allow `+` to separate trait bounds from objects.) Closes #14834 (configure: Don't sync unused submodules) Closes #14838 (Remove typo on collections::treemap::UnionItems) Closes #14839 (Fix the unused struct field lint for struct variants) Closes #14840 (Clarify `Any` docs) Closes #14846 (rustc: [T, ..N] and [T, ..N+1] are not the same) Closes #14847 (Audit usage of NativeMutex) Closes #14850 (remove unnecessary PaX detection) Closes #14856 (librustc: Take in account mutability when casting array to raw ptr.) Closes #14859 (librustc: Forbid `transmute` from being called on types whose size is) Closes #14860 (Fix `quote_pat!` & parse outer attributes in `quote_item!`)
1 parent f907d97 commit b7af250

File tree

9 files changed

+37
-22
lines changed

9 files changed

+37
-22
lines changed

src/libnative/io/c_win32.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,20 @@ pub mod compat {
7777
fn GetProcAddress(hModule: HMODULE, lpProcName: LPCSTR) -> LPVOID;
7878
}
7979

80-
// store_func() is idempotent, so using relaxed ordering for the atomics should be enough.
81-
// This way, calling a function in this compatibility layer (after it's loaded) shouldn't
82-
// be any slower than a regular DLL call.
83-
unsafe fn store_func<T: Copy>(ptr: *mut T, module: &str, symbol: &str, fallback: T) {
80+
// store_func() is idempotent, so using relaxed ordering for the atomics
81+
// should be enough. This way, calling a function in this compatibility
82+
// layer (after it's loaded) shouldn't be any slower than a regular DLL
83+
// call.
84+
unsafe fn store_func(ptr: *mut uint, module: &str, symbol: &str, fallback: uint) {
8485
let module = module.to_utf16().append_one(0);
8586
symbol.with_c_str(|symbol| {
8687
let handle = GetModuleHandleW(module.as_ptr());
87-
let func: Option<T> = transmute(GetProcAddress(handle, symbol));
88-
atomic_store_relaxed(ptr, func.unwrap_or(fallback))
88+
let func: uint = transmute(GetProcAddress(handle, symbol));
89+
atomic_store_relaxed(ptr, if func == 0 {
90+
fallback
91+
} else {
92+
func
93+
})
8994
})
9095
}
9196

@@ -109,10 +114,10 @@ pub mod compat {
109114

110115
extern "system" fn thunk($($argname: $argtype),*) -> $rettype {
111116
unsafe {
112-
::io::c::compat::store_func(&mut ptr,
113-
stringify!($module),
114-
stringify!($symbol),
115-
fallback);
117+
::io::c::compat::store_func(&mut ptr as *mut _ as *mut uint,
118+
stringify!($module),
119+
stringify!($symbol),
120+
fallback as uint);
116121
::std::intrinsics::atomic_load_relaxed(&ptr)($($argname),*)
117122
}
118123
}

src/libstd/dynamic_lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ mod test {
158158
use super::*;
159159
use prelude::*;
160160
use libc;
161+
use mem;
161162

162163
#[test]
163164
#[ignore(cfg(windows))] // FIXME #8818
@@ -174,7 +175,7 @@ mod test {
174175
let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe {
175176
match libm.symbol("cos") {
176177
Err(error) => fail!("Could not load function cos: {}", error),
177-
Ok(cosine) => cosine
178+
Ok(cosine) => mem::transmute::<*u8, _>(cosine)
178179
}
179180
};
180181

src/libstd/io/fs.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,9 @@ mod test {
977977
let result = File::open_mode(filename, Open, Read);
978978

979979
error!(result, "couldn't open file");
980-
error!(result, "no such file or directory");
980+
if cfg!(unix) {
981+
error!(result, "no such file or directory");
982+
}
981983
error!(result, format!("path={}; mode=open; access=read", filename.display()));
982984
})
983985

@@ -988,7 +990,9 @@ mod test {
988990
let result = unlink(filename);
989991

990992
error!(result, "couldn't unlink path");
991-
error!(result, "no such file or directory");
993+
if cfg!(unix) {
994+
error!(result, "no such file or directory");
995+
}
992996
error!(result, format!("path={}", filename.display()));
993997
})
994998

src/libstd/rt/backtrace.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -873,12 +873,12 @@ mod imp {
873873
Err(..) => return Ok(()),
874874
};
875875

876-
macro_rules! sym( ($e:expr, $t:ident) => (
877-
match unsafe { lib.symbol::<$t>($e) } {
878-
Ok(f) => f,
876+
macro_rules! sym( ($e:expr, $t:ident) => (unsafe {
877+
match lib.symbol($e) {
878+
Ok(f) => mem::transmute::<*u8, $t>(f),
879879
Err(..) => return Ok(())
880880
}
881-
) )
881+
}) )
882882

883883
// Fetch the symbols necessary from dbghelp.dll
884884
let SymFromAddr = sym!("SymFromAddr", SymFromAddrFn);

src/test/compile-fail/issue-14845.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn main() {
1717
let x = X { a: [0] };
1818
let _f = &x.a as *mut u8;
1919
//~^ ERROR mismatched types: expected `*mut u8` but found `&[u8, .. 1]`
20-
20+
2121
let local = [0u8];
2222
let _v = &local as *mut u8;
2323
//~^ ERROR mismatched types: expected `*mut u8` but found `&[u8, .. 1]`

src/test/compile-fail/transmute-different-sizes.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// Tests that `transmute` cannot be called on types of different size.
1212

13+
#![allow(warnings)]
14+
1315
use std::mem::transmute;
1416

1517
unsafe fn f() {

src/test/pretty/path-type-bounds.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
trait Tr { }
1515
impl Tr for int { }
1616

17-
fn foo(x: Box<Tr: Share>) -> Box<Tr: Share> { x }
17+
fn foo(x: Box<Tr+ Share>) -> Box<Tr+ Share> { x }
1818

1919
fn main() {
20-
let x: Box<Tr: Share>;
20+
let x: Box<Tr+ Share>;
2121

22-
box() 1 as Box<Tr: Share>;
22+
box() 1 as Box<Tr+ Share>;
2323
}
2424

src/test/run-pass-fulldeps/quote-tokens.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-android
12+
// ignore-pretty: does not work well with `--test`
13+
1114
#![feature(quote)]
1215
#![feature(managed_boxes)]
1316

src/test/run-pass/issue-14837.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
#![feature(struct_variant)]
12-
#![deny(warnings)]
1312

13+
#[deny(dead_code)]
1414
pub enum Foo {
1515
Bar {
1616
pub baz: int

0 commit comments

Comments
 (0)