Skip to content

Commit 4f3886a

Browse files
committed
Auto merge of rust-lang#41847 - alexcrichton:less-unstable-annotations, r=eddyb
rustc: Add a new `-Z force-unstable-if-unmarked` flag This commit adds a new `-Z` flag to the compiler for use when bootstrapping the compiler itself. We want to be able to use crates.io crates, but we also want the usage of such crates to be as ergonomic as possible! To that end compiler crates are a little tricky in that the crates.io crates are not annotated as unstable, nor do they expect to pull in unstable dependencies. To cover all these situations it's intended that the compiler will forever now bootstrap with `-Z force-unstable-if-unmarked`. This flags serves a dual purpose of forcing crates.io crates to themselves be unstable while also allowing them to use other "unstable" crates.io crates. This should mean that adding a dependency to compiler no longer requires upstream modification with unstable/staged_api attributes for inclusion!
2 parents d5f1cfd + ab54f4b commit 4f3886a

File tree

43 files changed

+201
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+201
-140
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ fn main() {
194194
// do that we pass a weird flag to the compiler to get it to do
195195
// so. Note that this is definitely a hack, and we should likely
196196
// flesh out rpath support more fully in the future.
197+
//
198+
// FIXME: remove condition after next stage0
197199
if stage != "0" {
198200
cmd.arg("-Z").arg("osx-rpath-install-name");
199201
}
@@ -218,6 +220,17 @@ fn main() {
218220
cmd.arg("-Z").arg("unstable-options");
219221
cmd.arg("-C").arg("target-feature=+crt-static");
220222
}
223+
224+
// Force all crates compiled by this compiler to (a) be unstable and (b)
225+
// allow the `rustc_private` feature to link to other unstable crates
226+
// also in the sysroot.
227+
//
228+
// FIXME: remove condition after next stage0
229+
if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() {
230+
if stage != "0" {
231+
cmd.arg("-Z").arg("force-unstable-if-unmarked");
232+
}
233+
}
221234
}
222235

223236
if verbose > 1 {

src/bootstrap/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ impl Build {
479479
// compiled with debuginfo.
480480
if mode != Mode::Tool {
481481
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string())
482-
.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
482+
.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string())
483+
.env("RUSTC_FORCE_UNSTABLE", "1");
483484
}
484485

485486
// Enable usage of unstable features
@@ -524,7 +525,9 @@ impl Build {
524525
// the comipiler, libs, and tests are stable and we don't want to make
525526
// their deps unstable (since this would break the first invariant
526527
// above).
527-
if mode != Mode::Tool {
528+
//
529+
// FIXME: remove this after next stage0
530+
if mode != Mode::Tool && stage == 0 {
528531
cargo.env("RUSTBUILD_UNSTABLE", "1");
529532
}
530533

src/libarena/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! objects of a single type.
2020
2121
#![crate_name = "arena"]
22-
#![unstable(feature = "rustc_private", issue = "27812")]
22+
#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
2323
#![crate_type = "rlib"]
2424
#![crate_type = "dylib"]
2525
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -32,7 +32,7 @@
3232
#![feature(core_intrinsics)]
3333
#![feature(dropck_eyepatch)]
3434
#![feature(generic_param_attrs)]
35-
#![feature(staged_api)]
35+
#![cfg_attr(stage0, feature(staged_api))]
3636
#![cfg_attr(test, feature(test))]
3737

3838
#![allow(deprecated)]

src/libflate/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! [mz]: https://code.google.com/p/miniz/
1616
1717
#![crate_name = "flate"]
18-
#![unstable(feature = "rustc_private", issue = "27812")]
18+
#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
1919
#![crate_type = "rlib"]
2020
#![crate_type = "dylib"]
2121
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -25,7 +25,7 @@
2525
#![deny(warnings)]
2626

2727
#![feature(libc)]
28-
#![feature(staged_api)]
28+
#![cfg_attr(stage0, feature(staged_api))]
2929
#![feature(unique)]
3030
#![cfg_attr(test, feature(rand))]
3131

src/libfmt_macros/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! generated instead.
1616
1717
#![crate_name = "fmt_macros"]
18-
#![unstable(feature = "rustc_private", issue = "27812")]
18+
#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
1919
#![crate_type = "rlib"]
2020
#![crate_type = "dylib"]
2121
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -25,7 +25,7 @@
2525
test(attr(deny(warnings))))]
2626
#![deny(warnings)]
2727

28-
#![feature(staged_api)]
28+
#![cfg_attr(stage0, feature(staged_api))]
2929
#![feature(unicode)]
3030

3131
pub use self::Piece::*;

src/libgetopts/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@
7878
//! ```
7979
8080
#![crate_name = "getopts"]
81-
#![unstable(feature = "rustc_private",
81+
#![cfg_attr(stage0, unstable(feature = "rustc_private",
8282
reason = "use the crates.io `getopts` library instead",
83-
issue = "27812")]
83+
issue = "27812"))]
8484
#![crate_type = "rlib"]
8585
#![crate_type = "dylib"]
8686
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -91,7 +91,7 @@
9191

9292
#![deny(missing_docs)]
9393
#![deny(warnings)]
94-
#![feature(staged_api)]
94+
#![cfg_attr(stage0, feature(staged_api))]
9595

9696
use self::Name::*;
9797
use self::HasArg::*;

src/libgraphviz/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@
284284
//! * [DOT language](http://www.graphviz.org/doc/info/lang.html)
285285
286286
#![crate_name = "graphviz"]
287-
#![unstable(feature = "rustc_private", issue = "27812")]
288-
#![feature(staged_api)]
287+
#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
288+
#![cfg_attr(stage0, feature(staged_api))]
289289
#![crate_type = "rlib"]
290290
#![crate_type = "dylib"]
291291
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",

src/libproc_macro_plugin/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
//! }
7373
//! ```
7474
#![crate_name = "proc_macro_plugin"]
75-
#![unstable(feature = "rustc_private", issue = "27812")]
75+
#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
7676
#![feature(plugin_registrar)]
7777
#![crate_type = "dylib"]
7878
#![crate_type = "rlib"]
@@ -81,9 +81,9 @@
8181
html_root_url = "https://doc.rust-lang.org/nightly/")]
8282
#![deny(warnings)]
8383

84-
#![feature(staged_api)]
84+
#![cfg_attr(stage0, feature(staged_api))]
8585
#![feature(rustc_diagnostic_macros)]
86-
#![feature(rustc_private)]
86+
#![cfg_attr(stage0, feature(rustc_private))]
8787

8888
extern crate rustc_plugin;
8989
extern crate syntax;

src/librustc/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
//! This API is completely unstable and subject to change.
1616
1717
#![crate_name = "rustc"]
18-
#![unstable(feature = "rustc_private", issue = "27812")]
1918
#![crate_type = "dylib"]
2019
#![crate_type = "rlib"]
2120
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -36,15 +35,17 @@
3635
#![feature(nonzero)]
3736
#![feature(quote)]
3837
#![feature(rustc_diagnostic_macros)]
39-
#![feature(rustc_private)]
4038
#![feature(slice_patterns)]
4139
#![feature(specialization)]
42-
#![feature(staged_api)]
4340
#![feature(unboxed_closures)]
4441
#![feature(discriminant_value)]
4542
#![feature(sort_unstable)]
4643
#![feature(trace_macros)]
4744

45+
#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
46+
#![cfg_attr(stage0, feature(rustc_private))]
47+
#![cfg_attr(stage0, feature(staged_api))]
48+
4849
#![recursion_limit="128"]
4950

5051
extern crate arena;

src/librustc/middle/cstore.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ pub trait CrateStore {
233233
fn export_macros(&self, cnum: CrateNum);
234234
fn lang_items(&self, cnum: CrateNum) -> Vec<(DefIndex, usize)>;
235235
fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>;
236-
fn is_staged_api(&self, cnum: CrateNum) -> bool;
237236
fn is_allocator(&self, cnum: CrateNum) -> bool;
238237
fn is_panic_runtime(&self, cnum: CrateNum) -> bool;
239238
fn is_compiler_builtins(&self, cnum: CrateNum) -> bool;
@@ -356,7 +355,6 @@ impl CrateStore for DummyCrateStore {
356355
{ bug!("lang_items") }
357356
fn missing_lang_items(&self, cnum: CrateNum) -> Vec<lang_items::LangItem>
358357
{ bug!("missing_lang_items") }
359-
fn is_staged_api(&self, cnum: CrateNum) -> bool { bug!("is_staged_api") }
360358
fn dep_kind(&self, cnum: CrateNum) -> DepKind { bug!("is_explicitly_linked") }
361359
fn export_macros(&self, cnum: CrateNum) { bug!("export_macros") }
362360
fn is_allocator(&self, cnum: CrateNum) -> bool { bug!("is_allocator") }

0 commit comments

Comments
 (0)