Skip to content

Commit 2273b52

Browse files
committed
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
1 parent 6866f13 commit 2273b52

File tree

39 files changed

+49
-20
lines changed

39 files changed

+49
-20
lines changed

mk/target.mk

-8
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ export CFG_COMPILER_HOST_TRIPLE
1717
export CFG_DEFAULT_LINKER
1818
export CFG_DEFAULT_AR
1919

20-
# The standard libraries should be held up to a higher standard than any old
21-
# code, make sure that these common warnings are denied by default. These can
22-
# be overridden during development temporarily. For stage0, we allow warnings
23-
# which may be bugs in stage0 (should be fixed in stage1+)
24-
RUST_LIB_FLAGS_ST0 += -W warnings
25-
RUST_LIB_FLAGS_ST1 += -D warnings
26-
RUST_LIB_FLAGS_ST2 += -D warnings
27-
2820
# Macro that generates the full list of dependencies for a crate at a particular
2921
# stage/target/host tuple.
3022
#

src/liballoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
7171
#![no_std]
7272
#![needs_allocator]
73+
#![cfg_attr(not(stage0), deny(warnings))]
7374

7475
#![feature(allocator)]
7576
#![feature(box_syntax)]

src/liballoc_jemalloc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
reason = "this library is unlikely to be stabilized in its current \
1717
form or name",
1818
issue = "27783")]
19+
#![cfg_attr(not(stage0), deny(warnings))]
1920
#![feature(allocator)]
2021
#![feature(libc)]
2122
#![feature(staged_api)]

src/liballoc_system/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![crate_type = "rlib"]
1313
#![no_std]
1414
#![allocator]
15+
#![cfg_attr(not(stage0), deny(warnings))]
1516
#![unstable(feature = "alloc_system",
1617
reason = "this library is unlikely to be stabilized in its current \
1718
form or name",

src/libarena/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2828
html_root_url = "https://doc.rust-lang.org/nightly/",
2929
test(no_crate_inject, attr(deny(warnings))))]
30+
#![cfg_attr(not(stage0), deny(warnings))]
3031

3132
#![feature(alloc)]
3233
#![feature(core_intrinsics)]

src/libcollections/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#![allow(trivial_casts)]
3030
#![cfg_attr(test, allow(deprecated))] // rand
31+
#![cfg_attr(not(stage0), deny(warnings))]
3132

3233
#![feature(alloc)]
3334
#![feature(box_patterns)]

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656

5757
#![no_core]
5858
#![deny(missing_docs)]
59+
#![cfg_attr(not(stage0), deny(warnings))]
5960

6061
#![feature(allow_internal_unstable)]
6162
#![feature(associated_type_defaults)]

src/libflate/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2323
html_root_url = "https://doc.rust-lang.org/nightly/",
2424
test(attr(deny(warnings))))]
25+
#![cfg_attr(not(stage0), deny(warnings))]
2526

2627
#![feature(libc)]
2728
#![feature(staged_api)]

src/libfmt_macros/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
html_root_url = "https://doc.rust-lang.org/nightly/",
2424
html_playground_url = "https://play.rust-lang.org/",
2525
test(attr(deny(warnings))))]
26+
#![cfg_attr(not(stage0), deny(warnings))]
2627

2728
#![feature(staged_api)]
2829
#![feature(unicode)]

src/libgraphviz/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
281281
html_root_url = "https://doc.rust-lang.org/nightly/",
282282
test(attr(allow(unused_variables), deny(warnings))))]
283+
#![cfg_attr(not(stage0), deny(warnings))]
283284

284285
#![feature(str_escape)]
285286

src/liblog/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
html_playground_url = "https://play.rust-lang.org/",
169169
test(attr(deny(warnings))))]
170170
#![deny(missing_docs)]
171+
#![cfg_attr(not(stage0), deny(warnings))]
171172

172173
#![feature(box_syntax)]
173174
#![feature(const_fn)]

src/librand/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
html_root_url = "https://doc.rust-lang.org/nightly/",
2424
html_playground_url = "https://play.rust-lang.org/",
2525
test(attr(deny(warnings))))]
26+
#![cfg_attr(not(stage0), deny(warnings))]
2627
#![no_std]
2728
#![unstable(feature = "rand",
2829
reason = "use `rand` from crates.io",

src/librbml/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
html_root_url = "https://doc.rust-lang.org/nightly/",
121121
html_playground_url = "https://play.rust-lang.org/",
122122
test(attr(deny(warnings))))]
123+
#![cfg_attr(not(stage0), deny(warnings))]
123124

124125
#![feature(rustc_private)]
125126
#![feature(staged_api)]

src/librustc/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#![crate_type = "dylib"]
2020
#![crate_type = "rlib"]
2121
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22-
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
23-
html_root_url = "https://doc.rust-lang.org/nightly/")]
22+
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
23+
html_root_url = "https://doc.rust-lang.org/nightly/")]
24+
#![cfg_attr(not(stage0), deny(warnings))]
2425

2526
#![feature(associated_consts)]
2627
#![feature(box_patterns)]

src/librustc_back/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2929
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
3030
html_root_url = "https://doc.rust-lang.org/nightly/")]
31+
#![cfg_attr(not(stage0), deny(warnings))]
3132

3233
#![feature(box_syntax)]
3334
#![feature(libc)]

src/librustc_bitflags/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![crate_type = "rlib"]
1616
#![no_std]
1717
#![unstable(feature = "rustc_private", issue = "27812")]
18+
#![cfg_attr(not(stage0), deny(warnings))]
1819

1920
//! A typesafe bitmask flag generator.
2021

src/librustc_borrowck/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1616
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1717
html_root_url = "https://doc.rust-lang.org/nightly/")]
18+
#![cfg_attr(not(stage0), deny(warnings))]
1819

1920
#![allow(non_camel_case_types)]
2021

src/librustc_data_structures/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2424
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
2525
html_root_url = "https://doc.rust-lang.org/nightly/")]
26+
#![cfg_attr(not(stage0), deny(warnings))]
2627

2728
#![feature(hashmap_hasher)]
2829
#![feature(nonzero)]

src/librustc_driver/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2222
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2323
html_root_url = "https://doc.rust-lang.org/nightly/")]
24+
#![cfg_attr(not(stage0), deny(warnings))]
2425

2526
#![feature(box_syntax)]
2627
#![feature(libc)]

src/librustc_front/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#![crate_type = "dylib"]
2020
#![crate_type = "rlib"]
2121
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22-
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
23-
html_root_url = "http://doc.rust-lang.org/nightly/")]
22+
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
23+
html_root_url = "http://doc.rust-lang.org/nightly/")]
24+
#![cfg_attr(not(stage0), deny(warnings))]
2425

2526
#![feature(associated_consts)]
2627
#![feature(box_patterns)]

src/librustc_lint/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2727
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2828
html_root_url = "https://doc.rust-lang.org/nightly/")]
29+
#![cfg_attr(not(stage0), deny(warnings))]
2930

3031
#![cfg_attr(test, feature(test))]
3132
#![feature(box_patterns)]

src/librustc_llvm/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2222
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2323
html_root_url = "https://doc.rust-lang.org/nightly/")]
24+
#![cfg_attr(not(stage0), deny(warnings))]
2425

2526
#![feature(associated_consts)]
2627
#![feature(box_syntax)]

src/librustc_metadata/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
#![crate_type = "dylib"]
1414
#![crate_type = "rlib"]
1515
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
16-
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
17-
html_root_url = "https://doc.rust-lang.org/nightly/")]
16+
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
17+
html_root_url = "https://doc.rust-lang.org/nightly/")]
18+
#![cfg_attr(not(stage0), deny(warnings))]
1819

1920
#![feature(box_patterns)]
2021
#![feature(enumset)]

src/librustc_mir/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
1717
#![crate_name = "rustc_mir"]
1818
#![crate_type = "rlib"]
1919
#![crate_type = "dylib"]
20+
#![cfg_attr(not(stage0), deny(warnings))]
2021

2122
#![feature(rustc_private)]
2223

src/librustc_passes/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#![crate_type = "dylib"]
2020
#![crate_type = "rlib"]
2121
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22-
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
23-
html_root_url = "https://doc.rust-lang.org/nightly/")]
22+
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
23+
html_root_url = "https://doc.rust-lang.org/nightly/")]
24+
#![cfg_attr(not(stage0), deny(warnings))]
2425

2526
#![feature(rustc_diagnostic_macros)]
2627
#![feature(staged_api)]

src/librustc_platform_intrinsics/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#![crate_type = "dylib"]
1414
#![crate_type = "rlib"]
1515
#![feature(staged_api, rustc_private)]
16+
#![cfg_attr(not(stage0), deny(warnings))]
1617

1718
extern crate rustc_llvm as llvm;
1819
extern crate rustc;

src/librustc_plugin/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
#![crate_type = "dylib"]
5656
#![crate_type = "rlib"]
5757
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
58-
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
59-
html_root_url = "https://doc.rust-lang.org/nightly/")]
58+
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
59+
html_root_url = "https://doc.rust-lang.org/nightly/")]
60+
#![cfg_attr(not(stage0), deny(warnings))]
6061

6162
#![feature(dynamic_lib)]
6263
#![feature(staged_api)]

src/librustc_privacy/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1616
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1717
html_root_url = "https://doc.rust-lang.org/nightly/")]
18+
#![cfg_attr(not(stage0), deny(warnings))]
1819

1920
#![feature(rustc_diagnostic_macros)]
2021
#![feature(rustc_private)]

src/librustc_resolve/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1616
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1717
html_root_url = "https://doc.rust-lang.org/nightly/")]
18+
#![cfg_attr(not(stage0), deny(warnings))]
1819

1920
#![feature(associated_consts)]
2021
#![feature(borrow_state)]

src/librustc_trans/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2222
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2323
html_root_url = "https://doc.rust-lang.org/nightly/")]
24+
#![cfg_attr(not(stage0), deny(warnings))]
2425

2526
#![feature(box_patterns)]
2627
#![feature(box_syntax)]

src/librustc_typeck/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ This API is completely unstable and subject to change.
7070
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
7171
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
7272
html_root_url = "https://doc.rust-lang.org/nightly/")]
73+
#![cfg_attr(not(stage0), deny(warnings))]
7374

7475
#![allow(non_camel_case_types)]
7576

src/librustc_unicode/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
html_playground_url = "https://play.rust-lang.org/",
3030
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
3131
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
32+
#![cfg_attr(not(stage0), deny(warnings))]
3233
#![no_std]
3334

3435
#![feature(core_char_ext)]

src/librustdoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1717
html_root_url = "https://doc.rust-lang.org/nightly/",
1818
html_playground_url = "https://play.rust-lang.org/")]
19+
#![cfg_attr(not(stage0), deny(warnings))]
1920

2021
#![feature(box_patterns)]
2122
#![feature(box_syntax)]

src/libserialize/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Core encoding and decoding interfaces.
2525
html_root_url = "https://doc.rust-lang.org/nightly/",
2626
html_playground_url = "https://play.rust-lang.org/",
2727
test(attr(allow(unused_variables), deny(warnings))))]
28+
#![cfg_attr(not(stage0), deny(warnings))]
2829

2930
#![feature(box_syntax)]
3031
#![feature(collections)]

src/libstd/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273

274274
#![deny(missing_docs)]
275275
#![allow(unused_features)] // std may use features in a platform-specific way
276+
#![cfg_attr(not(stage0), deny(warnings))]
276277

277278
#[cfg(test)] extern crate test;
278279
#[cfg(test)] #[macro_use] extern crate log;

src/libsyntax/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2323
html_root_url = "https://doc.rust-lang.org/nightly/",
2424
test(attr(deny(warnings))))]
25+
#![cfg_attr(not(stage0), deny(warnings))]
2526

2627
#![feature(associated_consts)]
2728
#![feature(filling_drop)]

src/libsyntax_ext/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
//! Syntax extensions in the Rust compiler.
1212
1313
#![crate_name = "syntax_ext"]
14+
#![unstable(feature = "rustc_private", issue = "27812")]
1415
#![crate_type = "dylib"]
1516
#![crate_type = "rlib"]
1617
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1718
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1819
html_root_url = "https://doc.rust-lang.org/nightly/")]
19-
20-
#![unstable(feature = "rustc_private", issue = "27812")]
20+
#![cfg_attr(not(stage0), deny(warnings))]
2121

2222
#![feature(rustc_private)]
2323
#![feature(staged_api)]

src/libterm/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
html_playground_url = "https://play.rust-lang.org/",
5353
test(attr(deny(warnings))))]
5454
#![deny(missing_docs)]
55+
#![cfg_attr(not(stage0), deny(warnings))]
5556

5657
#![feature(box_syntax)]
5758
#![feature(staged_api)]

src/libtest/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
3232
html_root_url = "https://doc.rust-lang.org/nightly/",
3333
test(attr(deny(warnings))))]
34+
#![cfg_attr(not(stage0), deny(warnings))]
3435

3536
#![feature(asm)]
3637
#![feature(box_syntax)]

0 commit comments

Comments
 (0)