From 2273b5202354b3091f493cfcfa5bf48165e92b1e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 21 Jan 2016 15:26:19 -0800 Subject: [PATCH 1/3] mk: Move from `-D warnings` to `#![deny(warnings)]` This commit removes the `-D warnings` flag being passed through the makefiles to all crates to instead be a crate attribute. We want these attributes always applied for all our standard builds, and this is more amenable to Cargo-based builds as well. Note that all `deny(warnings)` attributes are gated with a `cfg(stage0)` attribute currently to match the same semantics we have today --- mk/target.mk | 8 -------- src/liballoc/lib.rs | 1 + src/liballoc_jemalloc/lib.rs | 1 + src/liballoc_system/lib.rs | 1 + src/libarena/lib.rs | 1 + src/libcollections/lib.rs | 1 + src/libcore/lib.rs | 1 + src/libflate/lib.rs | 1 + src/libfmt_macros/lib.rs | 1 + src/libgraphviz/lib.rs | 1 + src/liblog/lib.rs | 1 + src/librand/lib.rs | 1 + src/librbml/lib.rs | 1 + src/librustc/lib.rs | 5 +++-- src/librustc_back/lib.rs | 1 + src/librustc_bitflags/lib.rs | 1 + src/librustc_borrowck/lib.rs | 1 + src/librustc_data_structures/lib.rs | 1 + src/librustc_driver/lib.rs | 1 + src/librustc_front/lib.rs | 5 +++-- src/librustc_lint/lib.rs | 1 + src/librustc_llvm/lib.rs | 1 + src/librustc_metadata/lib.rs | 5 +++-- src/librustc_mir/lib.rs | 1 + src/librustc_passes/lib.rs | 5 +++-- src/librustc_platform_intrinsics/lib.rs | 1 + src/librustc_plugin/lib.rs | 5 +++-- src/librustc_privacy/lib.rs | 1 + src/librustc_resolve/lib.rs | 1 + src/librustc_trans/lib.rs | 1 + src/librustc_typeck/lib.rs | 1 + src/librustc_unicode/lib.rs | 1 + src/librustdoc/lib.rs | 1 + src/libserialize/lib.rs | 1 + src/libstd/lib.rs | 1 + src/libsyntax/lib.rs | 1 + src/libsyntax_ext/lib.rs | 4 ++-- src/libterm/lib.rs | 1 + src/libtest/lib.rs | 1 + 39 files changed, 49 insertions(+), 20 deletions(-) diff --git a/mk/target.mk b/mk/target.mk index f90b09479c985..32a3eb5c20d28 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -17,14 +17,6 @@ export CFG_COMPILER_HOST_TRIPLE export CFG_DEFAULT_LINKER export CFG_DEFAULT_AR -# The standard libraries should be held up to a higher standard than any old -# code, make sure that these common warnings are denied by default. These can -# be overridden during development temporarily. For stage0, we allow warnings -# which may be bugs in stage0 (should be fixed in stage1+) -RUST_LIB_FLAGS_ST0 += -W warnings -RUST_LIB_FLAGS_ST1 += -D warnings -RUST_LIB_FLAGS_ST2 += -D warnings - # Macro that generates the full list of dependencies for a crate at a particular # stage/target/host tuple. # diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 0a232ed0620d4..403baa4a7b260 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -70,6 +70,7 @@ test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] #![no_std] #![needs_allocator] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(allocator)] #![feature(box_syntax)] diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index 91d229b819df1..b009dfd8c751c 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -16,6 +16,7 @@ reason = "this library is unlikely to be stabilized in its current \ form or name", issue = "27783")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(allocator)] #![feature(libc)] #![feature(staged_api)] diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index ffb6999d6e3fe..8a9e32daa728a 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -12,6 +12,7 @@ #![crate_type = "rlib"] #![no_std] #![allocator] +#![cfg_attr(not(stage0), deny(warnings))] #![unstable(feature = "alloc_system", reason = "this library is unlikely to be stabilized in its current \ form or name", diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index cd2093984e618..46a63390c8352 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -27,6 +27,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", test(no_crate_inject, attr(deny(warnings))))] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(alloc)] #![feature(core_intrinsics)] diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 6077a4c01045b..a3c05c5a68137 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -28,6 +28,7 @@ #![allow(trivial_casts)] #![cfg_attr(test, allow(deprecated))] // rand +#![cfg_attr(not(stage0), deny(warnings))] #![feature(alloc)] #![feature(box_patterns)] diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index e8803976937d2..f76b8655ad1ed 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -56,6 +56,7 @@ #![no_core] #![deny(missing_docs)] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(allow_internal_unstable)] #![feature(associated_type_defaults)] diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index a60a1c67e175d..f316250d96d71 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -22,6 +22,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(libc)] #![feature(staged_api)] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 7a229ad522227..07d26cddfdb87 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -23,6 +23,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(staged_api)] #![feature(unicode)] diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 38b45ec0feaed..2e26cc1b2660a 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -280,6 +280,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(allow(unused_variables), deny(warnings))))] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(str_escape)] diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index dbd553acd68fc..011f5a744dc84 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -168,6 +168,7 @@ html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] #![deny(missing_docs)] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(box_syntax)] #![feature(const_fn)] diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 06f4c8dfd20a8..9640322a2dd6f 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -23,6 +23,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] +#![cfg_attr(not(stage0), deny(warnings))] #![no_std] #![unstable(feature = "rand", reason = "use `rand` from crates.io", diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index 913314c4899a2..8404026df143e 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -120,6 +120,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(rustc_private)] #![feature(staged_api)] diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 4d772de783594..3167deb5cbdf2 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -19,8 +19,9 @@ #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] + html_favicon_url = "https://doc.rust-lang.org/favicon.ico", + html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(associated_consts)] #![feature(box_patterns)] diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs index 746d3ba07d601..4d8cfc2380420 100644 --- a/src/librustc_back/lib.rs +++ b/src/librustc_back/lib.rs @@ -28,6 +28,7 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(box_syntax)] #![feature(libc)] diff --git a/src/librustc_bitflags/lib.rs b/src/librustc_bitflags/lib.rs index e2a929f58e14d..e2025eaa8ee06 100644 --- a/src/librustc_bitflags/lib.rs +++ b/src/librustc_bitflags/lib.rs @@ -15,6 +15,7 @@ #![crate_type = "rlib"] #![no_std] #![unstable(feature = "rustc_private", issue = "27812")] +#![cfg_attr(not(stage0), deny(warnings))] //! A typesafe bitmask flag generator. diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index d730b383a8049..e7f5fddc7bbf2 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -15,6 +15,7 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![allow(non_camel_case_types)] diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 1fbbdf17455b2..2983590af3240 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -23,6 +23,7 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(hashmap_hasher)] #![feature(nonzero)] diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 31151e10a5a55..9a63751d8890c 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -21,6 +21,7 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(box_syntax)] #![feature(libc)] diff --git a/src/librustc_front/lib.rs b/src/librustc_front/lib.rs index b12c41d060a07..02ad69e8a7c3a 100644 --- a/src/librustc_front/lib.rs +++ b/src/librustc_front/lib.rs @@ -19,8 +19,9 @@ #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/nightly/")] + html_favicon_url = "https://doc.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(associated_consts)] #![feature(box_patterns)] diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 78252c491ecfe..6868b4f2ab768 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -26,6 +26,7 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![cfg_attr(test, feature(test))] #![feature(box_patterns)] diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index fc7fa299fb8fa..f831232303bf4 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -21,6 +21,7 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(associated_consts)] #![feature(box_syntax)] diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 42332c4696979..f416ec75010f3 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -13,8 +13,9 @@ #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] + html_favicon_url = "https://doc.rust-lang.org/favicon.ico", + html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(box_patterns)] #![feature(enumset)] diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 9cc40bbc3838a..4337f62db12c9 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -17,6 +17,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![crate_name = "rustc_mir"] #![crate_type = "rlib"] #![crate_type = "dylib"] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(rustc_private)] diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index fcdbd6384d543..91bfb19aa9d60 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -19,8 +19,9 @@ #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] + html_favicon_url = "https://doc.rust-lang.org/favicon.ico", + html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(rustc_diagnostic_macros)] #![feature(staged_api)] diff --git a/src/librustc_platform_intrinsics/lib.rs b/src/librustc_platform_intrinsics/lib.rs index e857434682d15..6a43ef65d6a06 100644 --- a/src/librustc_platform_intrinsics/lib.rs +++ b/src/librustc_platform_intrinsics/lib.rs @@ -13,6 +13,7 @@ #![crate_type = "dylib"] #![crate_type = "rlib"] #![feature(staged_api, rustc_private)] +#![cfg_attr(not(stage0), deny(warnings))] extern crate rustc_llvm as llvm; extern crate rustc; diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 333c226c2a373..c55e97412bb1b 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -55,8 +55,9 @@ #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] + html_favicon_url = "https://doc.rust-lang.org/favicon.ico", + html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(dynamic_lib)] #![feature(staged_api)] diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index cfd0540cc60e7..929ec523f639f 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -15,6 +15,7 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 444c43163e3c3..b648af7fe2b08 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -15,6 +15,7 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(associated_consts)] #![feature(borrow_state)] diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index c1ab0284ade52..9ab056a187b65 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -21,6 +21,7 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 17d71fa7be9a6..49de0efa61d4d 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -70,6 +70,7 @@ This API is completely unstable and subject to change. #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] #![allow(non_camel_case_types)] diff --git a/src/librustc_unicode/lib.rs b/src/librustc_unicode/lib.rs index 161da07911061..4cbcfd5a0b2a5 100644 --- a/src/librustc_unicode/lib.rs +++ b/src/librustc_unicode/lib.rs @@ -29,6 +29,7 @@ html_playground_url = "https://play.rust-lang.org/", issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/", test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] +#![cfg_attr(not(stage0), deny(warnings))] #![no_std] #![feature(core_char_ext)] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index ac5b64f37aafe..c52459f6c1059 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -16,6 +16,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 910600d91e456..ee5e40adc9c90 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -25,6 +25,7 @@ Core encoding and decoding interfaces. html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", test(attr(allow(unused_variables), deny(warnings))))] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(box_syntax)] #![feature(collections)] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 9adea351e3d0e..bc8fafd7fb101 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -273,6 +273,7 @@ #![deny(missing_docs)] #![allow(unused_features)] // std may use features in a platform-specific way +#![cfg_attr(not(stage0), deny(warnings))] #[cfg(test)] extern crate test; #[cfg(test)] #[macro_use] extern crate log; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 795f4044f6eb1..d7d3e576a613d 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -22,6 +22,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(associated_consts)] #![feature(filling_drop)] diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 0f049fa979255..97531d4279d4b 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -11,13 +11,13 @@ //! Syntax extensions in the Rust compiler. #![crate_name = "syntax_ext"] +#![unstable(feature = "rustc_private", issue = "27812")] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] - -#![unstable(feature = "rustc_private", issue = "27812")] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(rustc_private)] #![feature(staged_api)] diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index df1fedf3d4e66..771e24704558d 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -52,6 +52,7 @@ html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] #![deny(missing_docs)] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(box_syntax)] #![feature(staged_api)] diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index ac5b235854a04..130ce3a9637f3 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -31,6 +31,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] +#![cfg_attr(not(stage0), deny(warnings))] #![feature(asm)] #![feature(box_syntax)] From 4b3c35509b7bd75c0b4712bb45440955d997ae75 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 22 Jan 2016 10:17:07 -0800 Subject: [PATCH 2/3] rustc_mir: Mark the crate as unstable Wouldn't want to be able to link to this on stable Rust! --- src/librustc_mir/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 4337f62db12c9..6f4128fc24de4 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -18,8 +18,10 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![crate_type = "rlib"] #![crate_type = "dylib"] #![cfg_attr(not(stage0), deny(warnings))] +#![unstable(feature = "rustc_private", issue = "27812")] #![feature(rustc_private)] +#![feature(staged_api)] #[macro_use] extern crate log; extern crate graphviz as dot; From cb343c33acf0f9833d8d6eb637234acf4321976b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 22 Jan 2016 23:49:57 -0800 Subject: [PATCH 3/3] Fix warnings during tests The deny(warnings) attribute is now enabled for tests so we need to weed out these warnings as well. --- src/liballoc/boxed_test.rs | 1 - src/liballoc/lib.rs | 13 ++--- src/libcollections/lib.rs | 2 +- src/libcollections/slice.rs | 15 +----- src/libcollections/str.rs | 4 -- src/libcollectionstest/slice.rs | 1 - src/librand/lib.rs | 2 +- src/libserialize/json.rs | 1 - src/libstd/dynamic_lib.rs | 14 +++++- src/libstd/io/buffered.rs | 4 +- src/libstd/os/raw.rs | 1 + src/libstd/path.rs | 8 +-- src/libstd/process.rs | 62 ++++++++++-------------- src/libstd/sync/mpsc/select.rs | 2 +- src/libstd/sync/semaphore.rs | 24 +++++++-- src/libstd/sys/unix/mod.rs | 53 ++++++++++---------- src/libstd/sys/unix/stack_overflow.rs | 1 + src/libstd/sys/unix/thread.rs | 19 +++----- src/libstd/sys/windows/fs.rs | 4 +- src/libstd/sys/windows/mod.rs | 42 ++++++++-------- src/libstd/sys/windows/process.rs | 1 - src/libstd/sys/windows/stack_overflow.rs | 2 + src/libstd/sys/windows/thread.rs | 1 + src/libsyntax/print/pprust.rs | 1 - 24 files changed, 137 insertions(+), 141 deletions(-) diff --git a/src/liballoc/boxed_test.rs b/src/liballoc/boxed_test.rs index e7da6d04d3f8f..120301afa449f 100644 --- a/src/liballoc/boxed_test.rs +++ b/src/liballoc/boxed_test.rs @@ -15,7 +15,6 @@ use core::ops::Deref; use core::result::Result::{Ok, Err}; use core::clone::Clone; -use std::boxed; use std::boxed::Box; #[test] diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 403baa4a7b260..1438103d7f6d4 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -75,31 +75,28 @@ #![feature(allocator)] #![feature(box_syntax)] #![feature(coerce_unsized)] +#![feature(const_fn)] #![feature(core_intrinsics)] #![feature(custom_attribute)] +#![feature(drop_in_place)] +#![feature(dropck_parametricity)] #![feature(fundamental)] #![feature(lang_items)] +#![feature(needs_allocator)] #![feature(optin_builtin_traits)] #![feature(placement_in_syntax)] -#![feature(placement_new_protocol)] -#![feature(raw)] #![feature(shared)] #![feature(staged_api)] #![feature(unboxed_closures)] #![feature(unique)] #![feature(unsafe_no_drop_flag, filling_drop)] -#![feature(dropck_parametricity)] #![feature(unsize)] -#![feature(drop_in_place)] -#![feature(fn_traits)] -#![feature(const_fn)] - -#![feature(needs_allocator)] // Issue# 30592: Systematically use alloc_system during stage0 since jemalloc // might be unavailable or disabled #![cfg_attr(stage0, feature(alloc_system))] +#![cfg_attr(not(test), feature(raw, fn_traits, placement_new_protocol))] #![cfg_attr(test, feature(test, rustc_private, box_heap))] #[cfg(stage0)] diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index a3c05c5a68137..4958f75016651 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -56,7 +56,7 @@ #![feature(unicode)] #![feature(unique)] #![feature(unsafe_no_drop_flag)] -#![cfg_attr(test, feature(clone_from_slice, rand, test))] +#![cfg_attr(test, feature(rand, test))] #![no_std] diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 8b4497e6f037e..6252e4888eb3c 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -83,20 +83,14 @@ // Many of the usings in this module are only used in the test configuration. // It's cleaner to just turn off the unused_imports warning than to fix them. -#![allow(unused_imports)] +#![cfg_attr(test, allow(unused_imports, dead_code))] use alloc::boxed::Box; -use core::clone::Clone; use core::cmp::Ordering::{self, Greater, Less}; -use core::cmp::{self, Ord, PartialEq}; -use core::iter::Iterator; -use core::marker::Sized; +use core::cmp; use core::mem::size_of; use core::mem; -use core::ops::FnMut; -use core::option::Option::{self, Some, None}; use core::ptr; -use core::result::Result; use core::slice as core_slice; use borrow::{Borrow, BorrowMut, ToOwned}; @@ -136,12 +130,7 @@ pub use self::hack::to_vec; // `test_permutations` test mod hack { use alloc::boxed::Box; - use core::clone::Clone; - #[cfg(test)] - use core::iter::Iterator; use core::mem; - #[cfg(test)] - use core::option::Option::{Some, None}; #[cfg(test)] use string::ToString; diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 9ce1a111cf83a..094b7f1d03453 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -19,10 +19,6 @@ // It's cleaner to just turn off the unused_imports warning than to fix them. #![allow(unused_imports)] -use core::clone::Clone; -use core::iter::{Iterator, Extend}; -use core::option::Option::{self, Some, None}; -use core::result::Result; use core::str as core_str; use core::str::pattern::Pattern; use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher}; diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs index 80dcd48fbfaa9..e5e15025625b5 100644 --- a/src/libcollectionstest/slice.rs +++ b/src/libcollectionstest/slice.rs @@ -9,7 +9,6 @@ // except according to those terms. use std::cmp::Ordering::{Equal, Greater, Less}; -use std::default::Default; use std::mem; use std::__rand::{Rng, thread_rng}; use std::rc::Rc; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 9640322a2dd6f..531be63b7bb73 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -36,7 +36,7 @@ #![feature(custom_attribute)] #![allow(unused_attributes)] -#![cfg_attr(test, feature(test, rand, rustc_private, iter_order_deprecated))] +#![cfg_attr(test, feature(test, rand, rustc_private))] #![allow(deprecated)] diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 9e1e3c6a55805..2310a8237f426 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -2606,7 +2606,6 @@ impl FromStr for Json { mod tests { extern crate test; use self::Animal::*; - use self::DecodeEnum::*; use self::test::Bencher; use {Encodable, Decodable}; use super::Json::*; diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 41001153c3cc4..585051a98e5f7 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -16,7 +16,6 @@ reason = "API has not been scrutinized and is highly likely to \ either disappear or change", issue = "27810")] -#![rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")] #![allow(missing_docs)] #![allow(deprecated)] @@ -26,6 +25,11 @@ use env; use ffi::{CString, OsString}; use path::{Path, PathBuf}; +#[unstable(feature = "dynamic_lib", + reason = "API has not been scrutinized and is highly likely to \ + either disappear or change", + issue = "27810")] +#[rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")] pub struct DynamicLibrary { handle: *mut u8 } @@ -43,6 +47,11 @@ impl Drop for DynamicLibrary { } } +#[unstable(feature = "dynamic_lib", + reason = "API has not been scrutinized and is highly likely to \ + either disappear or change", + issue = "27810")] +#[rustc_deprecated(since = "1.5.0", reason = "replaced with 'dylib' on crates.io")] impl DynamicLibrary { /// Lazily open a dynamic library. When passed None it gives a /// handle to the calling process @@ -126,7 +135,6 @@ mod tests { use prelude::v1::*; use libc; use mem; - use path::Path; #[test] #[cfg_attr(any(windows, @@ -167,6 +175,8 @@ mod tests { target_os = "openbsd"))] #[allow(deprecated)] fn test_errors_do_not_crash() { + use path::Path; + // Open /dev/null as a library to get an error, and make sure // that only causes an error, and not a crash. let path = Path::new("/dev/null"); diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 5ec51eaa56733..ccebf3682c217 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -1095,8 +1095,8 @@ mod tests { thread::spawn(|| { let mut writer = BufWriter::new(PanicWriter); - writer.write(b"hello world"); - writer.flush(); + let _ = writer.write(b"hello world"); + let _ = writer.flush(); }).join().err().unwrap(); assert_eq!(WRITES.load(Ordering::SeqCst), 1); diff --git a/src/libstd/os/raw.rs b/src/libstd/os/raw.rs index 62080fee48ec1..31d889fd422b7 100644 --- a/src/libstd/os/raw.rs +++ b/src/libstd/os/raw.rs @@ -68,6 +68,7 @@ pub enum c_void { } #[cfg(test)] +#[allow(unused_imports)] mod tests { use any::TypeId; use libc; diff --git a/src/libstd/path.rs b/src/libstd/path.rs index e398a5a28c904..207c4d02e4817 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -3326,11 +3326,13 @@ mod tests { "{:?}.ends_with({:?}), expected {:?}, got {:?}", $path1, $path2, $ends_with, ends_with); - let relative_from = path1.relative_from(path2).map(|p| p.to_str().unwrap()); + let relative_from = path1.strip_prefix(path2) + .map(|p| p.to_str().unwrap()) + .ok(); let exp: Option<&str> = $relative_from; assert!(relative_from == exp, - "{:?}.relative_from({:?}), expected {:?}, got {:?}", $path1, $path2, - exp, relative_from); + "{:?}.strip_prefix({:?}), expected {:?}, got {:?}", + $path1, $path2, exp, relative_from); }); ); diff --git a/src/libstd/process.rs b/src/libstd/process.rs index be1fe9b2a9bd7..7197dfa8b2d47 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -618,8 +618,8 @@ mod tests { // FIXME(#10380) these tests should not all be ignored on android. - #[cfg(not(target_os="android"))] #[test] + #[cfg_attr(target_os = "android", ignore)] fn smoke() { let p = Command::new("true").spawn(); assert!(p.is_ok()); @@ -627,8 +627,8 @@ mod tests { assert!(p.wait().unwrap().success()); } - #[cfg(not(target_os="android"))] #[test] + #[cfg_attr(target_os = "android", ignore)] fn smoke_failure() { match Command::new("if-this-is-a-binary-then-the-world-has-ended").spawn() { Ok(..) => panic!(), @@ -636,8 +636,8 @@ mod tests { } } - #[cfg(not(target_os="android"))] #[test] + #[cfg_attr(target_os = "android", ignore)] fn exit_reported_right() { let p = Command::new("false").spawn(); assert!(p.is_ok()); @@ -646,8 +646,9 @@ mod tests { drop(p.wait()); } - #[cfg(all(unix, not(target_os="android")))] #[test] + #[cfg(unix)] + #[cfg_attr(target_os = "android", ignore)] fn signal_reported_right() { use os::unix::process::ExitStatusExt; @@ -674,16 +675,16 @@ mod tests { return ret; } - #[cfg(not(target_os="android"))] #[test] + #[cfg_attr(target_os = "android", ignore)] fn stdout_works() { let mut cmd = Command::new("echo"); cmd.arg("foobar").stdout(Stdio::piped()); assert_eq!(run_output(cmd), "foobar\n"); } - #[cfg(all(unix, not(target_os="android")))] #[test] + #[cfg_attr(any(windows, target_os = "android"), ignore)] fn set_current_dir_works() { let mut cmd = Command::new("/bin/sh"); cmd.arg("-c").arg("pwd") @@ -692,8 +693,8 @@ mod tests { assert_eq!(run_output(cmd), "/\n"); } - #[cfg(all(unix, not(target_os="android")))] #[test] + #[cfg_attr(any(windows, target_os = "android"), ignore)] fn stdin_works() { let mut p = Command::new("/bin/sh") .arg("-c").arg("read line; echo $line") @@ -709,8 +710,9 @@ mod tests { } - #[cfg(all(unix, not(target_os="android")))] #[test] + #[cfg_attr(target_os = "android", ignore)] + #[cfg(unix)] fn uid_works() { use os::unix::prelude::*; use libc; @@ -722,8 +724,9 @@ mod tests { assert!(p.wait().unwrap().success()); } - #[cfg(all(unix, not(target_os="android")))] #[test] + #[cfg_attr(target_os = "android", ignore)] + #[cfg(unix)] fn uid_to_root_fails() { use os::unix::prelude::*; use libc; @@ -734,8 +737,8 @@ mod tests { assert!(Command::new("/bin/ls").uid(0).gid(0).spawn().is_err()); } - #[cfg(not(target_os="android"))] #[test] + #[cfg_attr(target_os = "android", ignore)] fn test_process_status() { let mut status = Command::new("false").status().unwrap(); assert!(status.code() == Some(1)); @@ -752,8 +755,8 @@ mod tests { } } - #[cfg(not(target_os="android"))] #[test] + #[cfg_attr(target_os = "android", ignore)] fn test_process_output_output() { let Output {status, stdout, stderr} = Command::new("echo").arg("hello").output().unwrap(); @@ -764,8 +767,8 @@ mod tests { assert_eq!(stderr, Vec::new()); } - #[cfg(not(target_os="android"))] #[test] + #[cfg_attr(target_os = "android", ignore)] fn test_process_output_error() { let Output {status, stdout, stderr} = Command::new("mkdir").arg(".").output().unwrap(); @@ -775,23 +778,23 @@ mod tests { assert!(!stderr.is_empty()); } - #[cfg(not(target_os="android"))] #[test] + #[cfg_attr(target_os = "android", ignore)] fn test_finish_once() { let mut prog = Command::new("false").spawn().unwrap(); assert!(prog.wait().unwrap().code() == Some(1)); } - #[cfg(not(target_os="android"))] #[test] + #[cfg_attr(target_os = "android", ignore)] fn test_finish_twice() { let mut prog = Command::new("false").spawn().unwrap(); assert!(prog.wait().unwrap().code() == Some(1)); assert!(prog.wait().unwrap().code() == Some(1)); } - #[cfg(not(target_os="android"))] #[test] + #[cfg_attr(target_os = "android", ignore)] fn test_wait_with_output_once() { let prog = Command::new("echo").arg("hello").stdout(Stdio::piped()) .spawn().unwrap(); @@ -821,7 +824,6 @@ mod tests { cmd } - #[cfg(not(target_os="android"))] #[test] fn test_inherit_env() { use env; @@ -830,36 +832,22 @@ mod tests { let output = String::from_utf8(result.stdout).unwrap(); for (ref k, ref v) in env::vars() { + // don't check android RANDOM variables + if cfg!(target_os = "android") && *k == "RANDOM" { + continue + } + // Windows has hidden environment variables whose names start with // equals signs (`=`). Those do not show up in the output of the // `set` command. assert!((cfg!(windows) && k.starts_with("=")) || k.starts_with("DYLD") || - output.contains(&format!("{}={}", *k, *v)), + output.contains(&format!("{}={}", *k, *v)) || + output.contains(&format!("{}='{}'", *k, *v)), "output doesn't contain `{}={}`\n{}", k, v, output); } } - #[cfg(target_os="android")] - #[test] - fn test_inherit_env() { - use env; - - let mut result = env_cmd().output().unwrap(); - let output = String::from_utf8(result.stdout).unwrap(); - - for (ref k, ref v) in env::vars() { - // don't check android RANDOM variables - if *k != "RANDOM".to_string() { - assert!(output.contains(&format!("{}={}", - *k, - *v)) || - output.contains(&format!("{}=\'{}\'", - *k, - *v))); - } - } - } #[test] fn test_override_env() { diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index d743cbb18909f..5aa4ce81b8ae4 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -789,7 +789,7 @@ mod tests { fn fmt_debug_handle() { let (_, rx) = channel::(); let sel = Select::new(); - let mut handle = sel.handle(&rx); + let handle = sel.handle(&rx); assert_eq!(format!("{:?}", handle), "Handle { .. }"); } } diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs index ac5ce298c5c6f..dd76444d3ae02 100644 --- a/src/libstd/sync/semaphore.rs +++ b/src/libstd/sync/semaphore.rs @@ -12,9 +12,6 @@ reason = "the interaction between semaphores and the acquisition/release \ of resources is currently unclear", issue = "27798")] -#![rustc_deprecated(since = "1.7.0", - reason = "easily confused with system semaphores and not \ - used enough to pull its weight")] #![allow(deprecated)] use ops::Drop; @@ -49,6 +46,13 @@ use sync::{Mutex, Condvar}; /// // Release our initially acquired resource /// sem.release(); /// ``` +#[rustc_deprecated(since = "1.7.0", + reason = "easily confused with system semaphores and not \ + used enough to pull its weight")] +#[unstable(feature = "semaphore", + reason = "the interaction between semaphores and the acquisition/release \ + of resources is currently unclear", + issue = "27798")] pub struct Semaphore { lock: Mutex, cvar: Condvar, @@ -56,10 +60,24 @@ pub struct Semaphore { /// An RAII guard which will release a resource acquired from a semaphore when /// dropped. +#[rustc_deprecated(since = "1.7.0", + reason = "easily confused with system semaphores and not \ + used enough to pull its weight")] +#[unstable(feature = "semaphore", + reason = "the interaction between semaphores and the acquisition/release \ + of resources is currently unclear", + issue = "27798")] pub struct SemaphoreGuard<'a> { sem: &'a Semaphore, } +#[rustc_deprecated(since = "1.7.0", + reason = "easily confused with system semaphores and not \ + used enough to pull its weight")] +#[unstable(feature = "semaphore", + reason = "the interaction between semaphores and the acquisition/release \ + of resources is currently unclear", + issue = "27798")] impl Semaphore { /// Creates a new semaphore with the initial count specified. /// diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 9771b057d8d21..2e89becfa67e6 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -8,14 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(missing_docs)] -#![allow(non_camel_case_types)] +#![allow(missing_docs, bad_style)] use io::{self, ErrorKind}; use libc; use num::One; use ops::Neg; -use alloc::oom; #[cfg(target_os = "android")] pub use os::android as platform; #[cfg(target_os = "bitrig")] pub use os::bitrig as platform; @@ -46,25 +44,10 @@ pub mod thread_local; pub mod time; pub mod stdio; -// A nicer handler for out-of-memory situations than the default one. This one -// prints a message to stderr before aborting. It is critical that this code -// does not allocate any memory since we are in an OOM situation. Any errors are -// ignored while printing since there's nothing we can do about them and we are -// about to exit anyways. -fn oom_handler() -> ! { - use intrinsics; - let msg = "fatal runtime error: out of memory\n"; - unsafe { - libc::write(libc::STDERR_FILENO, - msg.as_ptr() as *const libc::c_void, - msg.len() as libc::size_t); - intrinsics::abort(); - } -} - -#[cfg(not(any(target_os = "nacl", test)))] +#[cfg(not(test))] pub fn init() { - use libc::signal; + use alloc::oom; + // By default, some platforms will send a *signal* when an EPIPE error // would otherwise be delivered. This runtime doesn't install a SIGPIPE // handler, causing it to kill the program, which isn't exactly what we @@ -73,15 +56,33 @@ pub fn init() { // Hence, we set SIGPIPE to ignore when the program starts up in order // to prevent this problem. unsafe { - assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != !0); + reset_sigpipe(); } oom::set_oom_handler(oom_handler); -} -#[cfg(all(target_os = "nacl", not(test)))] -pub fn init() { - oom::set_oom_handler(oom_handler); + // A nicer handler for out-of-memory situations than the default one. This + // one prints a message to stderr before aborting. It is critical that this + // code does not allocate any memory since we are in an OOM situation. Any + // errors are ignored while printing since there's nothing we can do about + // them and we are about to exit anyways. + fn oom_handler() -> ! { + use intrinsics; + let msg = "fatal runtime error: out of memory\n"; + unsafe { + libc::write(libc::STDERR_FILENO, + msg.as_ptr() as *const libc::c_void, + msg.len() as libc::size_t); + intrinsics::abort(); + } + } + + #[cfg(not(target_os = "nacl"))] + unsafe fn reset_sigpipe() { + assert!(libc::signal(libc::SIGPIPE, libc::SIG_IGN) != !0); + } + #[cfg(target_os = "nacl")] + unsafe fn reset_sigpipe() {} } pub fn decode_error_kind(errno: i32) -> ErrorKind { diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index fc49f4257be2a..c7614db329959 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -7,6 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. + #![cfg_attr(test, allow(dead_code))] use libc; diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 4d715b579c6c5..9e28cf06d619a 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(dead_code)] - use prelude::v1::*; use alloc::boxed::FnBox; @@ -174,6 +172,7 @@ impl Drop for Thread { not(target_os = "bitrig"), not(all(target_os = "netbsd", not(target_vendor = "rumprun"))), not(target_os = "openbsd")))] +#[cfg_attr(test, allow(dead_code))] pub mod guard { pub unsafe fn current() -> Option { None } pub unsafe fn init() -> Option { None } @@ -185,15 +184,13 @@ pub mod guard { target_os = "bitrig", all(target_os = "netbsd", not(target_vendor = "rumprun")), target_os = "openbsd"))] -#[allow(unused_imports)] +#[cfg_attr(test, allow(dead_code))] pub mod guard { use prelude::v1::*; - use libc::{self, pthread_t}; + use libc; use libc::mmap; use libc::{PROT_NONE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED}; - use mem; - use ptr; use sys::os; #[cfg(any(target_os = "macos", @@ -206,10 +203,10 @@ pub mod guard { #[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))] unsafe fn get_stack_start() -> Option<*mut libc::c_void> { let mut ret = None; - let mut attr: libc::pthread_attr_t = mem::zeroed(); + let mut attr: libc::pthread_attr_t = ::mem::zeroed(); assert_eq!(libc::pthread_attr_init(&mut attr), 0); if libc::pthread_getattr_np(libc::pthread_self(), &mut attr) == 0 { - let mut stackaddr = ptr::null_mut(); + let mut stackaddr = ::ptr::null_mut(); let mut stacksize = 0; assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut stacksize), 0); @@ -265,7 +262,7 @@ pub mod guard { #[cfg(any(target_os = "openbsd", target_os = "bitrig"))] pub unsafe fn current() -> Option { - let mut current_stack: libc::stack_t = mem::zeroed(); + let mut current_stack: libc::stack_t = ::mem::zeroed(); assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(), &mut current_stack), 0); @@ -282,7 +279,7 @@ pub mod guard { #[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))] pub unsafe fn current() -> Option { let mut ret = None; - let mut attr: libc::pthread_attr_t = mem::zeroed(); + let mut attr: libc::pthread_attr_t = ::mem::zeroed(); assert_eq!(libc::pthread_attr_init(&mut attr), 0); if libc::pthread_getattr_np(libc::pthread_self(), &mut attr) == 0 { let mut guardsize = 0; @@ -290,7 +287,7 @@ pub mod guard { if guardsize == 0 { panic!("there is no guard page"); } - let mut stackaddr = ptr::null_mut(); + let mut stackaddr = ::ptr::null_mut(); let mut size = 0; assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut size), 0); diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index 60e3f7c22bd58..a8b82ef5f297c 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -639,7 +639,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { fn directory_junctions_are_directories() { use ffi::OsStr; use env; - use rand::{self, StdRng, Rng}; + use rand::{self, Rng}; use vec::Vec; macro_rules! t { @@ -683,7 +683,7 @@ fn directory_junctions_are_directories() { let mut data = [0u8; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; let mut db = data.as_mut_ptr() as *mut c::REPARSE_MOUNTPOINT_DATA_BUFFER; - let mut buf = &mut (*db).ReparseTarget as *mut _; + let buf = &mut (*db).ReparseTarget as *mut _; let mut i = 0; let v = br"\??\"; let v = v.iter().map(|x| *x as u16); diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index 16c4ae8257c13..9ecef5ee92c71 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] +#![allow(missing_docs, bad_style)] use prelude::v1::*; @@ -20,7 +18,6 @@ use num::Zero; use os::windows::ffi::{OsStrExt, OsStringExt}; use path::PathBuf; use time::Duration; -use alloc::oom; #[macro_use] pub mod compat; @@ -43,25 +40,26 @@ pub mod thread_local; pub mod time; pub mod stdio; -// See comment in sys/unix/mod.rs -fn oom_handler() -> ! { - use intrinsics; - use ptr; - let msg = "fatal runtime error: out of memory\n"; - unsafe { - // WriteFile silently fails if it is passed an invalid handle, so there - // is no need to check the result of GetStdHandle. - c::WriteFile(c::GetStdHandle(c::STD_ERROR_HANDLE), - msg.as_ptr() as c::LPVOID, - msg.len() as c::DWORD, - ptr::null_mut(), - ptr::null_mut()); - intrinsics::abort(); - } -} - +#[cfg(not(test))] pub fn init() { - oom::set_oom_handler(oom_handler); + ::alloc::oom::set_oom_handler(oom_handler); + + // See comment in sys/unix/mod.rs + fn oom_handler() -> ! { + use intrinsics; + use ptr; + let msg = "fatal runtime error: out of memory\n"; + unsafe { + // WriteFile silently fails if it is passed an invalid handle, so + // there is no need to check the result of GetStdHandle. + c::WriteFile(c::GetStdHandle(c::STD_ERROR_HANDLE), + msg.as_ptr() as c::LPVOID, + msg.len() as c::DWORD, + ptr::null_mut(), + ptr::null_mut()); + intrinsics::abort(); + } + } } pub fn decode_error_kind(errno: i32) -> ErrorKind { diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index e0f8d6f9df963..4ab9f678d065d 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -386,7 +386,6 @@ impl Stdio { #[cfg(test)] mod tests { use prelude::v1::*; - use str; use ffi::{OsStr, OsString}; use super::make_command_line; diff --git a/src/libstd/sys/windows/stack_overflow.rs b/src/libstd/sys/windows/stack_overflow.rs index 01317bec0de88..4a406d70e63ab 100644 --- a/src/libstd/sys/windows/stack_overflow.rs +++ b/src/libstd/sys/windows/stack_overflow.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![cfg_attr(test, allow(dead_code))] + use sys_common::util::report_overflow; use sys::c; diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index 1ba8586756311..b18772c0c2438 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -83,6 +83,7 @@ impl Thread { pub fn into_handle(self) -> Handle { self.handle } } +#[cfg_attr(test, allow(dead_code))] pub mod guard { pub unsafe fn current() -> Option { None } pub unsafe fn init() -> Option { None } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 67817ee0740e6..c31cd5a06ce53 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -3149,7 +3149,6 @@ mod tests { use super::*; use ast; - use ast_util; use codemap; use parse::token;