From b7af25060a1b0451cb06085ba5893980bc4e5333 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 12 Jun 2014 21:34:32 -0700 Subject: [PATCH] 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!`) --- src/libnative/io/c_win32.rs | 25 +++++++++++-------- src/libstd/dynamic_lib.rs | 3 ++- src/libstd/io/fs.rs | 8 ++++-- src/libstd/rt/backtrace.rs | 8 +++--- src/test/compile-fail/issue-14845.rs | 2 +- .../compile-fail/transmute-different-sizes.rs | 2 ++ src/test/pretty/path-type-bounds.rs | 6 ++--- src/test/run-pass-fulldeps/quote-tokens.rs | 3 +++ src/test/run-pass/issue-14837.rs | 2 +- 9 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/libnative/io/c_win32.rs b/src/libnative/io/c_win32.rs index e855b8bd4f2..1b6525c6e38 100644 --- a/src/libnative/io/c_win32.rs +++ b/src/libnative/io/c_win32.rs @@ -77,15 +77,20 @@ pub mod compat { fn GetProcAddress(hModule: HMODULE, lpProcName: LPCSTR) -> LPVOID; } - // store_func() is idempotent, so using relaxed ordering for the atomics should be enough. - // This way, calling a function in this compatibility layer (after it's loaded) shouldn't - // be any slower than a regular DLL call. - unsafe fn store_func(ptr: *mut T, module: &str, symbol: &str, fallback: T) { + // store_func() is idempotent, so using relaxed ordering for the atomics + // should be enough. This way, calling a function in this compatibility + // layer (after it's loaded) shouldn't be any slower than a regular DLL + // call. + unsafe fn store_func(ptr: *mut uint, module: &str, symbol: &str, fallback: uint) { let module = module.to_utf16().append_one(0); symbol.with_c_str(|symbol| { let handle = GetModuleHandleW(module.as_ptr()); - let func: Option = transmute(GetProcAddress(handle, symbol)); - atomic_store_relaxed(ptr, func.unwrap_or(fallback)) + let func: uint = transmute(GetProcAddress(handle, symbol)); + atomic_store_relaxed(ptr, if func == 0 { + fallback + } else { + func + }) }) } @@ -109,10 +114,10 @@ pub unsafe fn $symbol($($argname: $argtype),*) -> $rettype { extern "system" fn thunk($($argname: $argtype),*) -> $rettype { unsafe { - ::io::c::compat::store_func(&mut ptr, - stringify!($module), - stringify!($symbol), - fallback); + ::io::c::compat::store_func(&mut ptr as *mut _ as *mut uint, + stringify!($module), + stringify!($symbol), + fallback as uint); ::std::intrinsics::atomic_load_relaxed(&ptr)($($argname),*) } } diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 61f7997071e..76dbfa8c29e 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -158,6 +158,7 @@ mod test { use super::*; use prelude::*; use libc; + use mem; #[test] #[ignore(cfg(windows))] // FIXME #8818 @@ -174,7 +175,7 @@ fn test_loading_cosine() { let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe { match libm.symbol("cos") { Err(error) => fail!("Could not load function cos: {}", error), - Ok(cosine) => cosine + Ok(cosine) => mem::transmute::<*u8, _>(cosine) } }; diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 008be8ffaae..10dfec0f566 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -977,7 +977,9 @@ pub fn tmpdir() -> TempDir { let result = File::open_mode(filename, Open, Read); error!(result, "couldn't open file"); - error!(result, "no such file or directory"); + if cfg!(unix) { + error!(result, "no such file or directory"); + } error!(result, format!("path={}; mode=open; access=read", filename.display())); }) @@ -988,7 +990,9 @@ pub fn tmpdir() -> TempDir { let result = unlink(filename); error!(result, "couldn't unlink path"); - error!(result, "no such file or directory"); + if cfg!(unix) { + error!(result, "no such file or directory"); + } error!(result, format!("path={}", filename.display())); }) diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index a1372b51d47..e2a963c5a87 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -873,12 +873,12 @@ pub fn write(w: &mut Writer) -> IoResult<()> { Err(..) => return Ok(()), }; - macro_rules! sym( ($e:expr, $t:ident) => ( - match unsafe { lib.symbol::<$t>($e) } { - Ok(f) => f, + macro_rules! sym( ($e:expr, $t:ident) => (unsafe { + match lib.symbol($e) { + Ok(f) => mem::transmute::<*u8, $t>(f), Err(..) => return Ok(()) } - ) ) + }) ) // Fetch the symbols necessary from dbghelp.dll let SymFromAddr = sym!("SymFromAddr", SymFromAddrFn); diff --git a/src/test/compile-fail/issue-14845.rs b/src/test/compile-fail/issue-14845.rs index d87eab7b6de..90366d09e2d 100644 --- a/src/test/compile-fail/issue-14845.rs +++ b/src/test/compile-fail/issue-14845.rs @@ -17,7 +17,7 @@ fn main() { let x = X { a: [0] }; let _f = &x.a as *mut u8; //~^ ERROR mismatched types: expected `*mut u8` but found `&[u8, .. 1]` - + let local = [0u8]; let _v = &local as *mut u8; //~^ ERROR mismatched types: expected `*mut u8` but found `&[u8, .. 1]` diff --git a/src/test/compile-fail/transmute-different-sizes.rs b/src/test/compile-fail/transmute-different-sizes.rs index 5ea1c496c76..abdfe983e3a 100644 --- a/src/test/compile-fail/transmute-different-sizes.rs +++ b/src/test/compile-fail/transmute-different-sizes.rs @@ -10,6 +10,8 @@ // Tests that `transmute` cannot be called on types of different size. +#![allow(warnings)] + use std::mem::transmute; unsafe fn f() { diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs index 0fdbad67f16..f90937c34a6 100644 --- a/src/test/pretty/path-type-bounds.rs +++ b/src/test/pretty/path-type-bounds.rs @@ -14,11 +14,11 @@ trait Tr { } impl Tr for int { } -fn foo(x: Box) -> Box { x } +fn foo(x: Box) -> Box { x } fn main() { - let x: Box; + let x: Box; - box() 1 as Box; + box() 1 as Box; } diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs index 96f5fca5a2d..4b2e29135ad 100644 --- a/src/test/run-pass-fulldeps/quote-tokens.rs +++ b/src/test/run-pass-fulldeps/quote-tokens.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-android +// ignore-pretty: does not work well with `--test` + #![feature(quote)] #![feature(managed_boxes)] diff --git a/src/test/run-pass/issue-14837.rs b/src/test/run-pass/issue-14837.rs index c207980cd6e..7876fe86d47 100644 --- a/src/test/run-pass/issue-14837.rs +++ b/src/test/run-pass/issue-14837.rs @@ -9,8 +9,8 @@ // except according to those terms. #![feature(struct_variant)] -#![deny(warnings)] +#[deny(dead_code)] pub enum Foo { Bar { pub baz: int -- 2.44.0