Skip to content

Commit 09b4525

Browse files
committed
auto merge of #7113 : alexcrichton/rust/banned-warnings, r=cmr
Reopening of #7031, Closes #6963 I imagine though that this will bounce in bors once or twice... Because attributes can't be cfg(stage0)'d off, there's temporarily a lot of new stage0/stage1+ code.
2 parents ebed4d0 + c109bed commit 09b4525

File tree

9 files changed

+35
-33
lines changed

9 files changed

+35
-33
lines changed

mk/target.mk

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
# this exists can be found on issue #2400
1414
export CFG_COMPILER_TRIPLE
1515

16+
# The standard libraries should be held up to a higher standard than any old
17+
# code, make sure that these common warnings are denied by default. These can
18+
# be overridden during development temporarily. For stage0, we allow all these
19+
# to suppress warnings which may be bugs in stage0 (should be fixed in stage1+)
20+
# NOTE: add "-A warnings" after snapshot to WFLAGS_ST0
21+
WFLAGS_ST0 = -A unrecognized-lint
22+
WFLAGS_ST1 = -D warnings
23+
WFLAGS_ST2 = -D warnings
24+
1625
# TARGET_STAGE_N template: This defines how target artifacts are built
1726
# for all stage/target architecture combinations. The arguments:
1827
# $(1) is the stage
@@ -39,15 +48,15 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)): \
3948
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
4049
| $$(TLIB$(1)_T_$(2)_H_$(3))/
4150
@$$(call E, compile_and_link: $$@)
42-
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
51+
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) -o $$@ $$< && touch $$@
4352

4453
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)): \
4554
$$(EXTRALIB_CRATE) $$(EXTRALIB_INPUTS) \
4655
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
4756
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
4857
| $$(TLIB$(1)_T_$(2)_H_$(3))/
4958
@$$(call E, compile_and_link: $$@)
50-
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
59+
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) -o $$@ $$< && touch $$@
5160

5261
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
5362
$$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \

src/libextra/term.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
use core::prelude::*;
1616

1717
use core::io;
18-
use core::os;
1918

20-
use terminfo::*;
21-
use terminfo::searcher::open;
22-
use terminfo::parser::compiled::parse;
23-
use terminfo::parm::{expand, Number, Variables};
19+
#[cfg(not(target_os = "win32"))] use core::os;
20+
#[cfg(not(target_os = "win32"))] use terminfo::*;
21+
#[cfg(not(target_os = "win32"))] use terminfo::searcher::open;
22+
#[cfg(not(target_os = "win32"))] use terminfo::parser::compiled::parse;
23+
#[cfg(not(target_os = "win32"))] use terminfo::parm::{expand, Number, Variables};
2424

2525
// FIXME (#2807): Windows support.
2626

@@ -122,10 +122,10 @@ impl Terminal {
122122
return Ok(Terminal {out: out, color_supported: false});
123123
}
124124

125-
pub fn fg(&self, color: u8) {
125+
pub fn fg(&self, _color: u8) {
126126
}
127127

128-
pub fn bg(&self, color: u8) {
128+
pub fn bg(&self, _color: u8) {
129129
}
130130

131131
pub fn reset(&self) {

src/libstd/libc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ pub mod types {
568568
pub mod os {
569569
pub mod common {
570570
pub mod posix01 {
571-
use libc::types::os::arch::c95::{c_int, c_short};
571+
use libc::types::os::arch::c95::c_short;
572572
use libc::types::os::arch::extra::{int64, time64_t};
573573
use libc::types::os::arch::posix88::{dev_t, ino_t};
574574
use libc::types::os::arch::posix88::mode_t;

src/libstd/os.rs

+8-13
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ use io;
3333
use iterator::IteratorUtil;
3434
use libc;
3535
use libc::{c_char, c_void, c_int, size_t};
36-
use libc::{mode_t, FILE};
36+
use libc::FILE;
3737
use local_data;
38-
use option;
3938
use option::{Some, None};
4039
use os;
4140
use prelude::*;
@@ -181,7 +180,6 @@ pub fn env() -> ~[(~str,~str)] {
181180
unsafe {
182181
#[cfg(windows)]
183182
unsafe fn get_env_pairs() -> ~[~str] {
184-
use libc::types::os::arch::extra::LPTCH;
185183
use libc::funcs::extra::kernel32::{
186184
GetEnvironmentStringsA,
187185
FreeEnvironmentStringsA
@@ -248,10 +246,10 @@ pub fn getenv(n: &str) -> Option<~str> {
248246
do with_env_lock {
249247
let s = str::as_c_str(n, |s| libc::getenv(s));
250248
if ptr::null::<u8>() == cast::transmute(s) {
251-
option::None::<~str>
249+
None::<~str>
252250
} else {
253251
let s = cast::transmute(s);
254-
option::Some::<~str>(str::raw::from_buf(s))
252+
Some::<~str>(str::raw::from_buf(s))
255253
}
256254
}
257255
}
@@ -540,7 +538,7 @@ pub fn homedir() -> Option<Path> {
540538

541539
#[cfg(windows)]
542540
fn secondary() -> Option<Path> {
543-
do getenv(~"USERPROFILE").chain |p| {
541+
do getenv("USERPROFILE").chain |p| {
544542
if !p.is_empty() {
545543
Some(Path(p))
546544
} else {
@@ -647,9 +645,7 @@ pub fn make_dir(p: &Path, mode: c_int) -> bool {
647645
use os::win32::as_utf16_p;
648646
// FIXME: turn mode into something useful? #2623
649647
do as_utf16_p(p.to_str()) |buf| {
650-
libc::CreateDirectoryW(buf, unsafe {
651-
cast::transmute(0)
652-
})
648+
libc::CreateDirectoryW(buf, cast::transmute(0))
653649
!= (0 as libc::BOOL)
654650
}
655651
}
@@ -659,7 +655,7 @@ pub fn make_dir(p: &Path, mode: c_int) -> bool {
659655
fn mkdir(p: &Path, mode: c_int) -> bool {
660656
unsafe {
661657
do as_c_charp(p.to_str()) |c| {
662-
libc::mkdir(c, mode as mode_t) == (0 as c_int)
658+
libc::mkdir(c, mode as libc::mode_t) == (0 as c_int)
663659
}
664660
}
665661
}
@@ -732,7 +728,6 @@ pub fn list_dir(p: &Path) -> ~[~str] {
732728
}
733729
#[cfg(windows)]
734730
unsafe fn get_list(p: &Path) -> ~[~str] {
735-
use libc::types::os::arch::extra::{LPCTSTR, HANDLE, BOOL};
736731
use libc::consts::os::extra::INVALID_HANDLE_VALUE;
737732
use libc::wcslen;
738733
use libc::funcs::extra::kernel32::{
@@ -961,7 +956,7 @@ pub fn copy_file(from: &Path, to: &Path) -> bool {
961956

962957
// Give the new file the old file's permissions
963958
if do str::as_c_str(to.to_str()) |to_buf| {
964-
libc::chmod(to_buf, from_mode as mode_t)
959+
libc::chmod(to_buf, from_mode as libc::mode_t)
965960
} != 0 {
966961
return false; // should be a condition...
967962
}
@@ -1329,7 +1324,7 @@ pub fn glob(pattern: &str) -> ~[Path] {
13291324

13301325
/// Returns a vector of Path objects that match the given glob pattern
13311326
#[cfg(target_os = "win32")]
1332-
pub fn glob(pattern: &str) -> ~[Path] {
1327+
pub fn glob(_pattern: &str) -> ~[Path] {
13331328
fail!("glob() is unimplemented on Windows")
13341329
}
13351330

src/libstd/rt/thread_local_storage.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ pub type Key = DWORD;
6060
#[cfg(windows)]
6161
pub unsafe fn create(key: &mut Key) {
6262
static TLS_OUT_OF_INDEXES: DWORD = 0xFFFFFFFF;
63-
*key = unsafe { TlsAlloc() };
63+
*key = TlsAlloc();
6464
assert!(*key != TLS_OUT_OF_INDEXES);
6565
}
6666

6767
#[cfg(windows)]
6868
pub unsafe fn set(key: Key, value: *mut c_void) {
69-
unsafe { assert!(0 != TlsSetValue(key, value)) }
69+
assert!(0 != TlsSetValue(key, value))
7070
}
7171

7272
#[cfg(windows)]

src/libstd/run.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
1313
#[allow(missing_doc)];
1414

15-
use iterator::IteratorUtil;
1615
use cast;
1716
use comm::{stream, SharedChan, GenericChan, GenericPort};
18-
use int;
1917
use io;
18+
use iterator::IteratorUtil;
2019
use libc::{pid_t, c_void, c_int};
2120
use libc;
2221
use option::{Some, None};
@@ -465,7 +464,6 @@ fn spawn_process_os(prog: &str, args: &[~str],
465464
use libc::funcs::extra::msvcrt::get_osfhandle;
466465

467466
use sys;
468-
use uint;
469467

470468
unsafe {
471469

@@ -638,6 +636,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
638636

639637
use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp};
640638
use libc::funcs::bsd44::getdtablesize;
639+
use int;
641640

642641
mod rustrt {
643642
use libc::c_void;

src/libstd/task/spawn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ use uint;
9191
use util;
9292
use unstable::sync::{Exclusive, exclusive};
9393
use rt::local::Local;
94-
use iterator::{IteratorUtil};
94+
use iterator::IteratorUtil;
9595

9696
#[cfg(test)] use task::default_task_opts;
9797
#[cfg(test)] use comm;

src/libstd/to_str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ The `ToStr` trait for converting to strings
1717
use str::OwnedStr;
1818
use hashmap::HashMap;
1919
use hashmap::HashSet;
20-
use iterator::IteratorUtil;
2120
use hash::Hash;
21+
use iterator::IteratorUtil;
2222
use cmp::Eq;
2323
use vec::ImmutableVector;
2424

@@ -177,7 +177,7 @@ impl<A:ToStr> ToStr for @[A] {
177177
mod tests {
178178
use hashmap::HashMap;
179179
use hashmap::HashSet;
180-
use container::{Set,Map};
180+
use container::{Set, Map};
181181
#[test]
182182
fn test_simple_types() {
183183
assert_eq!(1i.to_str(), ~"1");

src/libstd/unstable/dynamic_lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ mod dl {
164164
use libc;
165165
use path;
166166
use ptr;
167-
use str;
168167
use task;
169168
use result::*;
170169

@@ -175,7 +174,7 @@ mod dl {
175174
}
176175

177176
pub unsafe fn open_internal() -> *libc::c_void {
178-
let mut handle = ptr::null();
177+
let handle = ptr::null();
179178
GetModuleHandleExW(0 as libc::DWORD, ptr::null(), &handle as **libc::c_void);
180179
handle
181180
}

0 commit comments

Comments
 (0)