mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-25 13:24:22 +00:00
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!`)
This commit is contained in:
parent
f907d9772c
commit
b7af25060a
@ -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<T: Copy>(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<T> = 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 mod compat {
|
||||
|
||||
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),*)
|
||||
}
|
||||
}
|
||||
|
@ -158,6 +158,7 @@ mod test {
|
||||
use super::*;
|
||||
use prelude::*;
|
||||
use libc;
|
||||
use mem;
|
||||
|
||||
#[test]
|
||||
#[ignore(cfg(windows))] // FIXME #8818
|
||||
@ -174,7 +175,7 @@ mod test {
|
||||
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)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -977,7 +977,9 @@ mod test {
|
||||
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 @@ mod test {
|
||||
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()));
|
||||
})
|
||||
|
||||
|
@ -873,12 +873,12 @@ mod imp {
|
||||
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);
|
||||
|
@ -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]`
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// Tests that `transmute` cannot be called on types of different size.
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
use std::mem::transmute;
|
||||
|
||||
unsafe fn f() {
|
||||
|
@ -14,11 +14,11 @@
|
||||
trait Tr { }
|
||||
impl Tr for int { }
|
||||
|
||||
fn foo(x: Box<Tr: Share>) -> Box<Tr: Share> { x }
|
||||
fn foo(x: Box<Tr+ Share>) -> Box<Tr+ Share> { x }
|
||||
|
||||
fn main() {
|
||||
let x: Box<Tr: Share>;
|
||||
let x: Box<Tr+ Share>;
|
||||
|
||||
box() 1 as Box<Tr: Share>;
|
||||
box() 1 as Box<Tr+ Share>;
|
||||
}
|
||||
|
||||
|
@ -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)]
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(struct_variant)]
|
||||
#![deny(warnings)]
|
||||
|
||||
#[deny(dead_code)]
|
||||
pub enum Foo {
|
||||
Bar {
|
||||
pub baz: int
|
||||
|
Loading…
Reference in New Issue
Block a user