Skip to content

Commit 40c8165

Browse files
committed
Only enable relative span hashing on nightly.
1 parent 65f342d commit 40c8165

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
776776
/// Intercept all spans entering HIR.
777777
/// Mark a span as relative to the current owning item.
778778
fn lower_span(&self, span: Span) -> Span {
779-
if self.tcx.sess.opts.incremental.is_some() {
779+
if self.tcx.sess.opts.incremental_relative_spans() {
780780
span.with_parent(Some(self.current_hir_id_owner.def_id))
781781
} else {
782782
// Do not make spans relative when not using incremental compilation.

compiler/rustc_expand/src/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
587587
.resolver
588588
.visit_ast_fragment_with_placeholders(self.cx.current_expansion.id, &fragment);
589589

590-
if self.cx.sess.opts.incremental.is_some() {
590+
if self.cx.sess.opts.incremental_relative_spans() {
591591
for (invoc, _) in invocations.iter_mut() {
592592
let expn_id = invoc.expansion_data.id;
593593
let parent_def = self.cx.resolver.invocation_parent(expn_id);

compiler/rustc_middle/src/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
11621162
hir_body_hash.hash_stable(&mut hcx, &mut stable_hasher);
11631163
upstream_crates.hash_stable(&mut hcx, &mut stable_hasher);
11641164
source_file_names.hash_stable(&mut hcx, &mut stable_hasher);
1165-
if tcx.sess.opts.incremental.is_some() {
1165+
if tcx.sess.opts.incremental_relative_spans() {
11661166
let definitions = tcx.definitions_untracked();
11671167
let mut owner_spans: Vec<_> = krate
11681168
.owners

compiler/rustc_session/src/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,12 @@ impl Options {
787787
pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion {
788788
self.cg.symbol_mangling_version.unwrap_or(SymbolManglingVersion::Legacy)
789789
}
790+
791+
#[allow(rustc::bad_opt_access)]
792+
pub fn incremental_relative_spans(&self) -> bool {
793+
self.unstable_opts.incremental_relative_spans
794+
|| (self.unstable_features.is_nightly_build() && self.incremental.is_some())
795+
}
790796
}
791797

792798
impl UnstableOptions {

compiler/rustc_session/src/options.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,9 @@ options! {
13381338
incremental_info: bool = (false, parse_bool, [UNTRACKED],
13391339
"print high-level information about incremental reuse (or the lack thereof) \
13401340
(default: no)"),
1341+
#[rustc_lint_opt_deny_field_access("use `Session::incremental_relative_spans` instead of this field")]
1342+
incremental_relative_spans: bool = (false, parse_bool, [TRACKED],
1343+
"hash spans relative to their parent item for incr. comp. (default: no)"),
13411344
incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
13421345
"verify incr. comp. hashes of green query instances (default: no)"),
13431346
inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],

0 commit comments

Comments
 (0)