rustc_middle/middle/
debugger_visualizer.rs

1use std::path::PathBuf;
2use std::sync::Arc;
3
4use rustc_hir::attrs::DebuggerVisualizerType;
5use rustc_macros::{Decodable, Encodable, HashStable};
6
7/// A single debugger visualizer file.
8#[derive(HashStable)]
9#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable)]
10pub struct DebuggerVisualizerFile {
11    /// The complete debugger visualizer source.
12    pub src: Arc<[u8]>,
13    /// Indicates which visualizer type this targets.
14    pub visualizer_type: DebuggerVisualizerType,
15    /// The file path to the visualizer file. This is used for reporting
16    /// visualizer files in dep-info. Before it is written to crate metadata,
17    /// the path is erased to `None`, so as not to emit potentially privacy
18    /// sensitive data.
19    pub path: Option<PathBuf>,
20}
21
22impl DebuggerVisualizerFile {
23    pub fn new(src: Arc<[u8]>, visualizer_type: DebuggerVisualizerType, path: PathBuf) -> Self {
24        DebuggerVisualizerFile { src, visualizer_type, path: Some(path) }
25    }
26
27    pub fn path_erased(&self) -> Self {
28        DebuggerVisualizerFile {
29            src: Arc::clone(&self.src),
30            visualizer_type: self.visualizer_type,
31            path: None,
32        }
33    }
34}