From 44972b2ce7bff10ca9277212eedf23b15bbe0eb2 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 31 Oct 2022 16:39:45 +0000 Subject: Mark incremental-ignore-spans as TRACKED. Using that options basically changes all stable hashes we may compute. Adding/removing as UNTRACKED it makes everything ICE (unstable fingerprint everywhere). As TRACKED, it can still do its job without ICEing. --- compiler/rustc_session/src/options.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler/rustc_session/src') diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 40bc669707a..19dde0a9775 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1333,7 +1333,7 @@ options! { "generate human-readable, predictable names for codegen units (default: no)"), identify_regions: bool = (false, parse_bool, [UNTRACKED], "display unnamed regions as `'`, using a non-ident unique id (default: no)"), - incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED], + incremental_ignore_spans: bool = (false, parse_bool, [TRACKED], "ignore spans during ICH computation -- used for testing (default: no)"), incremental_info: bool = (false, parse_bool, [UNTRACKED], "print high-level information about incremental reuse (or the lack thereof) \ -- cgit 1.4.1-3-g733a5 From 65f342daeaaab5b546e2e76d04140d1c788780b9 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 10 Jun 2021 20:34:42 +0200 Subject: Enable relative span hashing. --- compiler/rustc_ast_lowering/src/lib.rs | 2 +- compiler/rustc_expand/src/expand.rs | 2 +- compiler/rustc_middle/src/hir/map/mod.rs | 2 +- compiler/rustc_session/src/options.rs | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_session/src') diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index db2527a200c..bff48a6d0a1 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -776,7 +776,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { /// Intercept all spans entering HIR. /// Mark a span as relative to the current owning item. fn lower_span(&self, span: Span) -> Span { - if self.tcx.sess.opts.unstable_opts.incremental_relative_spans { + if self.tcx.sess.opts.incremental.is_some() { span.with_parent(Some(self.current_hir_id_owner.def_id)) } else { // Do not make spans relative when not using incremental compilation. diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index e26c16dcd7e..32dbe579fb4 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -587,7 +587,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { .resolver .visit_ast_fragment_with_placeholders(self.cx.current_expansion.id, &fragment); - if self.cx.sess.opts.unstable_opts.incremental_relative_spans { + if self.cx.sess.opts.incremental.is_some() { for (invoc, _) in invocations.iter_mut() { let expn_id = invoc.expansion_data.id; let parent_def = self.cx.resolver.invocation_parent(expn_id); diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index fe640f185b6..ec5f7f7917b 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -1162,7 +1162,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { hir_body_hash.hash_stable(&mut hcx, &mut stable_hasher); upstream_crates.hash_stable(&mut hcx, &mut stable_hasher); source_file_names.hash_stable(&mut hcx, &mut stable_hasher); - if tcx.sess.opts.unstable_opts.incremental_relative_spans { + if tcx.sess.opts.incremental.is_some() { let definitions = tcx.definitions_untracked(); let mut owner_spans: Vec<_> = krate .owners diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 19dde0a9775..cd2c9f4d0ea 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1338,8 +1338,6 @@ options! { incremental_info: bool = (false, parse_bool, [UNTRACKED], "print high-level information about incremental reuse (or the lack thereof) \ (default: no)"), - incremental_relative_spans: bool = (false, parse_bool, [TRACKED], - "hash spans relative to their parent item for incr. comp. (default: no)"), incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED], "verify incr. comp. hashes of green query instances (default: no)"), inline_in_all_cgus: Option = (None, parse_opt_bool, [TRACKED], -- cgit 1.4.1-3-g733a5 From 40c8165395cef78f5f8bfadd8802cbda41a4cb00 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Fri, 9 Dec 2022 16:36:28 +0000 Subject: Only enable relative span hashing on nightly. --- compiler/rustc_ast_lowering/src/lib.rs | 2 +- compiler/rustc_expand/src/expand.rs | 2 +- compiler/rustc_middle/src/hir/map/mod.rs | 2 +- compiler/rustc_session/src/config.rs | 6 ++++++ compiler/rustc_session/src/options.rs | 3 +++ 5 files changed, 12 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_session/src') diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index bff48a6d0a1..bb087326cb1 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -776,7 +776,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { /// Intercept all spans entering HIR. /// Mark a span as relative to the current owning item. fn lower_span(&self, span: Span) -> Span { - if self.tcx.sess.opts.incremental.is_some() { + if self.tcx.sess.opts.incremental_relative_spans() { span.with_parent(Some(self.current_hir_id_owner.def_id)) } else { // Do not make spans relative when not using incremental compilation. diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 32dbe579fb4..5d47c1ed363 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -587,7 +587,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { .resolver .visit_ast_fragment_with_placeholders(self.cx.current_expansion.id, &fragment); - if self.cx.sess.opts.incremental.is_some() { + if self.cx.sess.opts.incremental_relative_spans() { for (invoc, _) in invocations.iter_mut() { let expn_id = invoc.expansion_data.id; let parent_def = self.cx.resolver.invocation_parent(expn_id); diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index ec5f7f7917b..c35681b4b35 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -1162,7 +1162,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { hir_body_hash.hash_stable(&mut hcx, &mut stable_hasher); upstream_crates.hash_stable(&mut hcx, &mut stable_hasher); source_file_names.hash_stable(&mut hcx, &mut stable_hasher); - if tcx.sess.opts.incremental.is_some() { + if tcx.sess.opts.incremental_relative_spans() { let definitions = tcx.definitions_untracked(); let mut owner_spans: Vec<_> = krate .owners diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 3bafd3730bd..02e3992a6a9 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -787,6 +787,12 @@ impl Options { pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion { self.cg.symbol_mangling_version.unwrap_or(SymbolManglingVersion::Legacy) } + + #[allow(rustc::bad_opt_access)] + pub fn incremental_relative_spans(&self) -> bool { + self.unstable_opts.incremental_relative_spans + || (self.unstable_features.is_nightly_build() && self.incremental.is_some()) + } } impl UnstableOptions { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index cd2c9f4d0ea..83a3fd75265 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1338,6 +1338,9 @@ options! { incremental_info: bool = (false, parse_bool, [UNTRACKED], "print high-level information about incremental reuse (or the lack thereof) \ (default: no)"), + #[rustc_lint_opt_deny_field_access("use `Session::incremental_relative_spans` instead of this field")] + incremental_relative_spans: bool = (false, parse_bool, [TRACKED], + "hash spans relative to their parent item for incr. comp. (default: no)"), incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED], "verify incr. comp. hashes of green query instances (default: no)"), inline_in_all_cgus: Option = (None, parse_opt_bool, [TRACKED], -- cgit 1.4.1-3-g733a5