1
Fork 0

Auto merge of #111641 - michaelwoerister:debugger-visualizer-fixes, r=cjgillot

Fix dependency tracking for debugger visualizers

This PR fixes dependency tracking for debugger visualizer files by changing the `debugger_visualizers` query to an `eval_always` query that scans the AST while it is still available. This way the set of visualizer files is already available when dep-info is emitted. Since the query is turned into an `eval_always` query, dependency tracking will now reliably detect changes to the visualizer script files themselves.

TODO:
 - [x] perf.rlo
 - [x] Needs a bit more documentation in some places
 - [x] Needs regression test for the incr. comp. case

Fixes https://github.com/rust-lang/rust/issues/111226
Fixes https://github.com/rust-lang/rust/issues/111227
Fixes https://github.com/rust-lang/rust/issues/111295

r? `@wesleywiser`
cc `@gibbyfree`
This commit is contained in:
bors 2023-05-19 11:30:44 +00:00
commit 17a681000b
27 changed files with 246 additions and 145 deletions

View file

@ -19,6 +19,7 @@ use rustc_hir::definitions::{DefKey, DefPath, DefPathData, DefPathHash};
use rustc_hir::diagnostic_items::DiagnosticItems;
use rustc_index::{Idx, IndexVec};
use rustc_middle::metadata::ModChild;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
use rustc_middle::ty::codec::TyDecoder;
@ -958,7 +959,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
.decode((self, sess))
}
fn get_debugger_visualizers(self) -> Vec<rustc_span::DebuggerVisualizerFile> {
fn get_debugger_visualizers(self) -> Vec<DebuggerVisualizerFile> {
self.root.debugger_visualizers.decode(self).collect::<Vec<_>>()
}

View file

@ -19,6 +19,7 @@ use rustc_hir::definitions::DefPathData;
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::lang_items::LangItem;
use rustc_middle::hir::nested_filter;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols::{
metadata_symbol_name, ExportedSymbol, SymbolExportInfo,
@ -36,9 +37,7 @@ use rustc_session::config::{CrateType, OptLevel};
use rustc_session::cstore::{ForeignModule, LinkagePreference, NativeLib};
use rustc_span::hygiene::{ExpnIndex, HygieneEncodeContext, MacroKind};
use rustc_span::symbol::{sym, Symbol};
use rustc_span::{
self, DebuggerVisualizerFile, ExternalSource, FileName, SourceFile, Span, SyntaxContext,
};
use rustc_span::{self, ExternalSource, FileName, SourceFile, Span, SyntaxContext};
use std::borrow::Borrow;
use std::collections::hash_map::Entry;
use std::hash::Hash;
@ -1855,7 +1854,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
fn encode_debugger_visualizers(&mut self) -> LazyArray<DebuggerVisualizerFile> {
empty_proc_macro!(self);
self.lazy_array(self.tcx.debugger_visualizers(LOCAL_CRATE).iter())
self.lazy_array(
self.tcx
.debugger_visualizers(LOCAL_CRATE)
.iter()
// Erase the path since it may contain privacy sensitive data
// that we don't want to end up in crate metadata.
// The path is only needed for the local crate because of
// `--emit dep-info`.
.map(DebuggerVisualizerFile::path_erased),
)
}
fn encode_crate_deps(&mut self) -> LazyArray<CrateDep> {

View file

@ -2,6 +2,7 @@ use crate::creader::CrateMetadataRef;
use decoder::Metadata;
use def_path_hash_map::DefPathHashMapRef;
use rustc_data_structures::fx::FxHashMap;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use table::TableBuilder;
use rustc_ast as ast;
@ -245,7 +246,7 @@ pub(crate) struct CrateRoot {
proc_macro_data: Option<ProcMacroData>,
tables: LazyTables,
debugger_visualizers: LazyArray<rustc_span::DebuggerVisualizerFile>,
debugger_visualizers: LazyArray<DebuggerVisualizerFile>,
exported_symbols: LazyArray<(ExportedSymbol<'static>, SymbolExportInfo)>,