Skip to content

Commit d8b5745

Browse files
committed
Treat nightlies for a version as complete
This commit makes cfg(version) treat the nightlies for version 1.n.0 as 1.n.0, even though that nightly version might not have all stabilizations and features of the released 1.n.0. This is done for greater convenience for people who want to test a newly stabilized feature on nightly. For users who wish to pin nightlies, this commit adds a -Z assume-incomplete-release option that they can enable if there are any issues due to this change.
1 parent 14aa12f commit d8b5745

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

Diff for: compiler/rustc_attr/src/builtin.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,14 @@ pub fn eval_condition(
586586
return false;
587587
}
588588
};
589-
let channel = env!("CFG_RELEASE_CHANNEL");
590-
let nightly = channel == "nightly" || channel == "dev";
591589
let rustc_version = parse_version(env!("CFG_RELEASE"), true).unwrap();
592590

593-
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-625474439 for details
594-
if nightly { rustc_version > min_version } else { rustc_version >= min_version }
591+
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
592+
if sess.assume_incomplete_release {
593+
rustc_version > min_version
594+
} else {
595+
rustc_version >= min_version
596+
}
595597
}
596598
ast::MetaItemKind::List(ref mis) => {
597599
for mi in mis.iter() {

Diff for: compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ fn test_debugging_options_tracking_hash() {
538538
// This list is in alphabetical order.
539539
tracked!(allow_features, Some(vec![String::from("lang_items")]));
540540
tracked!(always_encode_mir, true);
541+
tracked!(assume_incomplete_release, true);
541542
tracked!(asm_comments, true);
542543
tracked!(binary_dep_depinfo, true);
543544
tracked!(chalk, true);

Diff for: compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
856856
"only allow the listed language features to be enabled in code (space separated)"),
857857
always_encode_mir: bool = (false, parse_bool, [TRACKED],
858858
"encode MIR of all functions into the crate metadata (default: no)"),
859+
assume_incomplete_release: bool = (false, parse_bool, [TRACKED],
860+
"make cfg(version) treat the current version as incomplete (default: no)"),
859861
asm_comments: bool = (false, parse_bool, [TRACKED],
860862
"generate comments into the assembly (may change behavior) (default: no)"),
861863
ast_json: bool = (false, parse_bool, [UNTRACKED],

Diff for: compiler/rustc_session/src/parse.rs

+3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ pub struct ParseSess {
138138
pub env_depinfo: Lock<FxHashSet<(Symbol, Option<Symbol>)>>,
139139
/// All the type ascriptions expressions that have had a suggestion for likely path typo.
140140
pub type_ascription_path_suggestions: Lock<FxHashSet<Span>>,
141+
/// Whether cfg(version) should treat the current release as incomplete
142+
pub assume_incomplete_release: bool,
141143
}
142144

143145
impl ParseSess {
@@ -164,6 +166,7 @@ impl ParseSess {
164166
reached_eof: Lock::new(false),
165167
env_depinfo: Default::default(),
166168
type_ascription_path_suggestions: Default::default(),
169+
assume_incomplete_release: false,
167170
}
168171
}
169172

Diff for: compiler/rustc_session/src/session.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,8 @@ pub fn build_session(
13361336
None
13371337
};
13381338

1339-
let parse_sess = ParseSess::with_span_handler(span_diagnostic, source_map);
1339+
let mut parse_sess = ParseSess::with_span_handler(span_diagnostic, source_map);
1340+
parse_sess.assume_incomplete_release = sopts.debugging_opts.assume_incomplete_release;
13401341
let sysroot = match &sopts.maybe_sysroot {
13411342
Some(sysroot) => sysroot.clone(),
13421343
None => filesearch::get_or_default_sysroot(),

0 commit comments

Comments
 (0)