Skip to content

Commit 55bd904

Browse files
committed
---
yaml --- r: 174359 b: refs/heads/master c: 0859e5e h: refs/heads/master i: 174357: e63d3de 174355: b4f6348 174351: bf963dd v: v3
1 parent 32a7551 commit 55bd904

File tree

19 files changed

+137
-191
lines changed

19 files changed

+137
-191
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 7b87900d72cf53037119e3bac1506a9786ca508a
2+
refs/heads/master: 0859e5ebb319ceddcce01ddb63470d8f59860aba
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9006c3c0f14be45da8ffeba43d354d088e366c83
55
refs/heads/try: 08f6380a9f0b866796080094f44fe25ea5636547

trunk/src/liblibc/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,10 +2207,10 @@ pub mod consts {
22072207
pub const IPPROTO_TCP: c_int = 6;
22082208
pub const IPPROTO_IP: c_int = 0;
22092209
pub const IPPROTO_IPV6: c_int = 41;
2210-
pub const IP_MULTICAST_TTL: c_int = 10;
2211-
pub const IP_MULTICAST_LOOP: c_int = 11;
2212-
pub const IP_ADD_MEMBERSHIP: c_int = 12;
2213-
pub const IP_DROP_MEMBERSHIP: c_int = 13;
2210+
pub const IP_MULTICAST_TTL: c_int = 3;
2211+
pub const IP_MULTICAST_LOOP: c_int = 4;
2212+
pub const IP_ADD_MEMBERSHIP: c_int = 5;
2213+
pub const IP_DROP_MEMBERSHIP: c_int = 6;
22142214
pub const IPV6_ADD_MEMBERSHIP: c_int = 5;
22152215
pub const IPV6_DROP_MEMBERSHIP: c_int = 6;
22162216
pub const IP_TTL: c_int = 4;

trunk/src/librustc/middle/infer/error_reporting.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
11771177
ast::Return(ref ret_ty) => ast::Return(
11781178
self.rebuild_arg_ty_or_output(&**ret_ty, lifetime, anon_nums, region_names)
11791179
),
1180-
ast::DefaultReturn(span) => ast::DefaultReturn(span),
11811180
ast::NoReturn(span) => ast::NoReturn(span)
11821181
}
11831182
}

trunk/src/librustc_trans/trans/debuginfo.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,15 +1450,18 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
14501450
let mut signature = Vec::with_capacity(fn_decl.inputs.len() + 1);
14511451

14521452
// Return type -- llvm::DIBuilder wants this at index 0
1453-
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
1454-
let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
1455-
let return_type = monomorphize::apply_param_substs(cx.tcx(),
1456-
param_substs,
1457-
&return_type);
1458-
if ty::type_is_nil(return_type) {
1459-
signature.push(ptr::null_mut())
1460-
} else {
1461-
signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
1453+
match fn_decl.output {
1454+
ast::Return(ref ret_ty) if ret_ty.node == ast::TyTup(vec![]) =>
1455+
signature.push(ptr::null_mut()),
1456+
_ => {
1457+
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
1458+
1459+
let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
1460+
let return_type = monomorphize::apply_param_substs(cx.tcx(),
1461+
param_substs,
1462+
&return_type);
1463+
signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
1464+
}
14621465
}
14631466

14641467
// Arguments types

trunk/src/librustc_trans/trans/foreign.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,9 @@ fn gate_simd_ffi(tcx: &ty::ctxt, decl: &ast::FnDecl, ty: &ty::BareFnTy) {
445445
for (input, ty) in decl.inputs.iter().zip(sig.inputs.iter()) {
446446
check(&*input.ty, *ty)
447447
}
448-
if let ast::Return(ref ty) = decl.output {
449-
check(&**ty, sig.output.unwrap())
448+
match decl.output {
449+
ast::NoReturn(_) => {}
450+
ast::Return(ref ty) => check(&**ty, sig.output.unwrap())
450451
}
451452
}
452453
}

trunk/src/librustc_trans/trans/intrinsic.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,11 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
361361
}
362362
(_, "init") => {
363363
let tp_ty = *substs.types.get(FnSpace, 0);
364-
let lltp_ty = type_of::arg_type_of(ccx, tp_ty);
365-
if return_type_is_void(ccx, tp_ty) {
366-
C_nil(ccx)
367-
} else {
368-
C_null(lltp_ty)
364+
if !return_type_is_void(ccx, tp_ty) {
365+
// Just zero out the stack slot
366+
zero_mem(bcx, llresult, tp_ty);
369367
}
368+
C_nil(ccx)
370369
}
371370
// Effectively no-ops
372371
(_, "uninit") | (_, "forget") => {

trunk/src/librustc_typeck/astconv.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,8 +1359,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
13591359
implied_output_region,
13601360
lifetimes_for_params,
13611361
&**output)),
1362-
ast::DefaultReturn(..) => ty::FnConverging(ty::mk_nil(this.tcx())),
1363-
ast::NoReturn(..) => ty::FnDiverging
1362+
ast::NoReturn(_) => ty::FnDiverging
13641363
};
13651364

13661365
(ty::BareFnTy {
@@ -1487,21 +1486,14 @@ pub fn ty_of_closure<'tcx>(
14871486

14881487
let expected_ret_ty = expected_sig.map(|e| e.output);
14891488

1490-
let is_infer = match decl.output {
1491-
ast::Return(ref output) if output.node == ast::TyInfer => true,
1492-
ast::DefaultReturn(..) => true,
1493-
_ => false
1494-
};
1495-
14961489
let output_ty = match decl.output {
1497-
_ if is_infer && expected_ret_ty.is_some() =>
1490+
ast::Return(ref output) if output.node == ast::TyInfer && expected_ret_ty.is_some() =>
14981491
expected_ret_ty.unwrap(),
1499-
_ if is_infer =>
1500-
ty::FnConverging(this.ty_infer(decl.output.span())),
1492+
ast::Return(ref output) if output.node == ast::TyInfer =>
1493+
ty::FnConverging(this.ty_infer(output.span)),
15011494
ast::Return(ref output) =>
15021495
ty::FnConverging(ast_ty_to_ty(this, &rb, &**output)),
1503-
ast::DefaultReturn(..) => unreachable!(),
1504-
ast::NoReturn(..) => ty::FnDiverging
1496+
ast::NoReturn(_) => ty::FnDiverging
15051497
};
15061498

15071499
debug!("ty_of_closure: input_tys={}", input_tys.repr(this.tcx()));

trunk/src/librustc_typeck/collect.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,9 +1488,7 @@ fn ty_of_foreign_fn_decl<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
14881488
let output = match decl.output {
14891489
ast::Return(ref ty) =>
14901490
ty::FnConverging(ast_ty_to_ty(ccx, &rb, &**ty)),
1491-
ast::DefaultReturn(..) =>
1492-
ty::FnConverging(ty::mk_nil(ccx.tcx)),
1493-
ast::NoReturn(..) =>
1491+
ast::NoReturn(_) =>
14941492
ty::FnDiverging
14951493
};
14961494

trunk/src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,16 +1141,14 @@ impl Clean<Argument> for ast::Arg {
11411141
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
11421142
pub enum FunctionRetTy {
11431143
Return(Type),
1144-
DefaultReturn,
11451144
NoReturn
11461145
}
11471146

11481147
impl Clean<FunctionRetTy> for ast::FunctionRetTy {
11491148
fn clean(&self, cx: &DocContext) -> FunctionRetTy {
11501149
match *self {
11511150
ast::Return(ref typ) => Return(typ.clean(cx)),
1152-
ast::DefaultReturn(..) => DefaultReturn,
1153-
ast::NoReturn(..) => NoReturn
1151+
ast::NoReturn(_) => NoReturn
11541152
}
11551153
}
11561154
}

trunk/src/librustdoc/html/format.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ impl fmt::String for clean::FunctionRetTy {
557557
match *self {
558558
clean::Return(clean::Tuple(ref tys)) if tys.is_empty() => Ok(()),
559559
clean::Return(ref ty) => write!(f, " -&gt; {}", ty),
560-
clean::DefaultReturn => Ok(()),
561560
clean::NoReturn => write!(f, " -&gt; !")
562561
}
563562
}

trunk/src/libstd/dynamic_lib.rs

Lines changed: 43 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,21 @@ impl DynamicLibrary {
5252
/// Lazily open a dynamic library. When passed None it gives a
5353
/// handle to the calling process
5454
pub fn open(filename: Option<&Path>) -> Result<DynamicLibrary, String> {
55-
let maybe_library = dl::open(filename.map(|path| path.as_vec()));
56-
57-
// The dynamic library must not be constructed if there is
58-
// an error opening the library so the destructor does not
59-
// run.
60-
match maybe_library {
61-
Err(err) => Err(err),
62-
Ok(handle) => Ok(DynamicLibrary { handle: handle })
55+
unsafe {
56+
let maybe_library = dl::check_for_errors_in(|| {
57+
match filename {
58+
Some(name) => dl::open_external(name.as_vec()),
59+
None => dl::open_internal()
60+
}
61+
});
62+
63+
// The dynamic library must not be constructed if there is
64+
// an error opening the library so the destructor does not
65+
// run.
66+
match maybe_library {
67+
Err(err) => Err(err),
68+
Ok(handle) => Ok(DynamicLibrary { handle: handle })
69+
}
6370
}
6471
}
6572

@@ -191,34 +198,22 @@ mod test {
191198
target_os = "ios",
192199
target_os = "freebsd",
193200
target_os = "dragonfly"))]
194-
mod dl {
201+
pub mod dl {
202+
pub use self::Rtld::*;
195203
use prelude::v1::*;
196204

197205
use ffi::{self, CString};
198206
use str;
199207
use libc;
200208
use ptr;
201209

202-
pub fn open(filename: Option<&[u8]>) -> Result<*mut u8, String> {
203-
check_for_errors_in(|| {
204-
unsafe {
205-
match filename {
206-
Some(filename) => open_external(filename),
207-
None => open_internal(),
208-
}
209-
}
210-
})
211-
}
212-
213-
const LAZY: libc::c_int = 1;
214-
215-
unsafe fn open_external(filename: &[u8]) -> *mut u8 {
210+
pub unsafe fn open_external(filename: &[u8]) -> *mut u8 {
216211
let s = CString::from_slice(filename);
217-
dlopen(s.as_ptr(), LAZY) as *mut u8
212+
dlopen(s.as_ptr(), Lazy as libc::c_int) as *mut u8
218213
}
219214

220-
unsafe fn open_internal() -> *mut u8 {
221-
dlopen(ptr::null(), LAZY) as *mut u8
215+
pub unsafe fn open_internal() -> *mut u8 {
216+
dlopen(ptr::null(), Lazy as libc::c_int) as *mut u8
222217
}
223218

224219
pub fn check_for_errors_in<T, F>(f: F) -> Result<T, String> where
@@ -254,6 +249,14 @@ mod dl {
254249
dlclose(handle as *mut libc::c_void); ()
255250
}
256251

252+
#[derive(Copy)]
253+
pub enum Rtld {
254+
Lazy = 1,
255+
Now = 2,
256+
Global = 256,
257+
Local = 0,
258+
}
259+
257260
#[link_name = "dl"]
258261
extern {
259262
fn dlopen(filename: *const libc::c_char,
@@ -266,13 +269,11 @@ mod dl {
266269
}
267270

268271
#[cfg(target_os = "windows")]
269-
mod dl {
272+
pub mod dl {
270273
use iter::IteratorExt;
271274
use libc;
272-
use libc::consts::os::extra::ERROR_CALL_NOT_IMPLEMENTED;
273275
use ops::FnOnce;
274276
use os;
275-
use option::Option::{self, Some, None};
276277
use ptr;
277278
use result::Result;
278279
use result::Result::{Ok, Err};
@@ -281,75 +282,19 @@ mod dl {
281282
use str;
282283
use string::String;
283284
use vec::Vec;
284-
use sys::c::compat::kernel32::SetThreadErrorMode;
285-
286-
pub fn open(filename: Option<&[u8]>) -> Result<*mut u8, String> {
287-
// disable "dll load failed" error dialog.
288-
let mut use_thread_mode = true;
289-
let prev_error_mode = unsafe {
290-
// SEM_FAILCRITICALERRORS 0x01
291-
let new_error_mode = 1;
292-
let mut prev_error_mode = 0;
293-
// Windows >= 7 supports thread error mode.
294-
let result = SetThreadErrorMode(new_error_mode, &mut prev_error_mode);
295-
if result == 0 {
296-
let err = os::errno();
297-
if err as libc::c_int == ERROR_CALL_NOT_IMPLEMENTED {
298-
use_thread_mode = false;
299-
// SetThreadErrorMode not found. use fallback solution: SetErrorMode()
300-
// Note that SetErrorMode is process-wide so this can cause race condition!
301-
// However, since even Windows APIs do not care of such problem (#20650),
302-
// we just assume SetErrorMode race is not a great deal.
303-
prev_error_mode = SetErrorMode(new_error_mode);
304-
}
305-
}
306-
prev_error_mode
307-
};
308-
309-
unsafe {
310-
SetLastError(0);
311-
}
312-
313-
let result = match filename {
314-
Some(filename) => {
315-
let filename_str = str::from_utf8(filename).unwrap();
316-
let mut filename_str: Vec<u16> = filename_str.utf16_units().collect();
317-
filename_str.push(0);
318-
let result = unsafe {
319-
LoadLibraryW(filename_str.as_ptr() as *const libc::c_void)
320-
};
321-
// beware: Vec/String may change errno during drop!
322-
// so we get error here.
323-
if result == ptr::null_mut() {
324-
let errno = os::errno();
325-
Err(os::error_string(errno))
326-
} else {
327-
Ok(result as *mut u8)
328-
}
329-
}
330-
None => {
331-
let mut handle = ptr::null_mut();
332-
let succeeded = unsafe {
333-
GetModuleHandleExW(0 as libc::DWORD, ptr::null(), &mut handle)
334-
};
335-
if succeeded == libc::FALSE {
336-
let errno = os::errno();
337-
Err(os::error_string(errno))
338-
} else {
339-
Ok(handle as *mut u8)
340-
}
341-
}
342-
};
343285

344-
unsafe {
345-
if use_thread_mode {
346-
SetThreadErrorMode(prev_error_mode, ptr::null_mut());
347-
} else {
348-
SetErrorMode(prev_error_mode);
349-
}
350-
}
286+
pub unsafe fn open_external(filename: &[u8]) -> *mut u8 {
287+
// Windows expects Unicode data
288+
let filename_str = str::from_utf8(filename).unwrap();
289+
let mut filename_str: Vec<u16> = filename_str.utf16_units().collect();
290+
filename_str.push(0);
291+
LoadLibraryW(filename_str.as_ptr() as *const libc::c_void) as *mut u8
292+
}
351293

352-
result
294+
pub unsafe fn open_internal() -> *mut u8 {
295+
let mut handle = ptr::null_mut();
296+
GetModuleHandleExW(0 as libc::DWORD, ptr::null(), &mut handle);
297+
handle as *mut u8
353298
}
354299

355300
pub fn check_for_errors_in<T, F>(f: F) -> Result<T, String> where
@@ -381,10 +326,10 @@ mod dl {
381326
fn SetLastError(error: libc::size_t);
382327
fn LoadLibraryW(name: *const libc::c_void) -> *mut libc::c_void;
383328
fn GetModuleHandleExW(dwFlags: libc::DWORD, name: *const u16,
384-
handle: *mut *mut libc::c_void) -> libc::BOOL;
329+
handle: *mut *mut libc::c_void)
330+
-> *mut libc::c_void;
385331
fn GetProcAddress(handle: *mut libc::c_void,
386332
name: *const libc::c_char) -> *mut libc::c_void;
387333
fn FreeLibrary(handle: *mut libc::c_void);
388-
fn SetErrorMode(uMode: libc::c_uint) -> libc::c_uint;
389334
}
390335
}

trunk/src/libstd/sys/windows/c.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ pub mod compat {
226226
/// * `CreateSymbolicLinkW`: Windows XP, Windows Server 2003
227227
/// * `GetFinalPathNameByHandleW`: Windows XP, Windows Server 2003
228228
pub mod kernel32 {
229-
use libc::c_uint;
230229
use libc::types::os::arch::extra::{DWORD, LPCWSTR, BOOLEAN, HANDLE};
231230
use libc::consts::os::extra::ERROR_CALL_NOT_IMPLEMENTED;
232231

@@ -250,12 +249,6 @@ pub mod compat {
250249
unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0 }
251250
}
252251
}
253-
254-
compat_fn! {
255-
kernel32::SetThreadErrorMode(_dwNewMode: DWORD, _lpOldMode: *mut DWORD) -> c_uint {
256-
unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0 }
257-
}
258-
}
259252
}
260253
}
261254

0 commit comments

Comments
 (0)