about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-21 04:30:30 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-03-21 22:18:57 +0100
commitbb8785ea0089602e07ad955b2ba49b2ddcf57cec (patch)
treefd2e6a58ba9db2e9cf7f4becf353512b26b27229 /src
parentfdf2d2d9dc4740eb9d3d18c8a1d52c520c912565 (diff)
downloadrust-bb8785ea0089602e07ad955b2ba49b2ddcf57cec.tar.gz
rust-bb8785ea0089602e07ad955b2ba49b2ddcf57cec.zip
move CrateDisambiguator -> rustc_ast
Diffstat (limited to 'src')
-rw-r--r--src/librustc/hir/map/definitions.rs5
-rw-r--r--src/librustc_ast/crate_disambiguator.rs35
-rw-r--r--src/librustc_ast/lib.rs1
-rw-r--r--src/librustc_session/session.rs59
4 files changed, 48 insertions, 52 deletions
diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs
index aa4742ea891..796c94ac03f 100644
--- a/src/librustc/hir/map/definitions.rs
+++ b/src/librustc/hir/map/definitions.rs
@@ -5,12 +5,13 @@
 //! expressions) that are mostly just leftovers.
 
 use rustc_ast::ast;
+use rustc_ast::crate_disambiguator::CrateDisambiguator;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::stable_hasher::StableHasher;
 use rustc_hir as hir;
+pub use rustc_hir::def_id::DefPathHash;
 use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
 use rustc_index::vec::IndexVec;
-use rustc_session::CrateDisambiguator;
 use rustc_span::hygiene::ExpnId;
 use rustc_span::symbol::{sym, Symbol};
 use rustc_span::Span;
@@ -18,8 +19,6 @@ use rustc_span::Span;
 use std::fmt::Write;
 use std::hash::Hash;
 
-pub use rustc_hir::def_id::DefPathHash;
-
 /// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
 /// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey`
 /// stores the `DefIndex` of its parent.
diff --git a/src/librustc_ast/crate_disambiguator.rs b/src/librustc_ast/crate_disambiguator.rs
new file mode 100644
index 00000000000..95d4c09dac3
--- /dev/null
+++ b/src/librustc_ast/crate_disambiguator.rs
@@ -0,0 +1,35 @@
+// This is here because `rustc_session` wants to refer to it,
+// and so does `rustc_hir`, but `rustc_hir` shouldn't refer to `rustc_session`.
+
+use rustc_data_structures::fingerprint::Fingerprint;
+use rustc_data_structures::{base_n, impl_stable_hash_via_hash};
+
+use std::fmt;
+
+/// Hash value constructed out of all the `-C metadata` arguments passed to the
+/// compiler. Together with the crate-name forms a unique global identifier for
+/// the crate.
+#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)]
+pub struct CrateDisambiguator(Fingerprint);
+
+impl CrateDisambiguator {
+    pub fn to_fingerprint(self) -> Fingerprint {
+        self.0
+    }
+}
+
+impl fmt::Display for CrateDisambiguator {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
+        let (a, b) = self.0.as_value();
+        let as_u128 = a as u128 | ((b as u128) << 64);
+        f.write_str(&base_n::encode(as_u128, base_n::CASE_INSENSITIVE))
+    }
+}
+
+impl From<Fingerprint> for CrateDisambiguator {
+    fn from(fingerprint: Fingerprint) -> CrateDisambiguator {
+        CrateDisambiguator(fingerprint)
+    }
+}
+
+impl_stable_hash_via_hash!(CrateDisambiguator);
diff --git a/src/librustc_ast/lib.rs b/src/librustc_ast/lib.rs
index 2594cc536ac..a93e0fcbd71 100644
--- a/src/librustc_ast/lib.rs
+++ b/src/librustc_ast/lib.rs
@@ -40,6 +40,7 @@ pub mod util {
 pub mod ast;
 pub mod attr;
 pub use attr::{with_default_globals, with_globals, GLOBALS};
+pub mod crate_disambiguator;
 pub mod entry;
 pub mod expand;
 pub mod mut_visit;
diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs
index 81281857dbc..80f59aff691 100644
--- a/src/librustc_session/session.rs
+++ b/src/librustc_session/session.rs
@@ -1,41 +1,30 @@
+use crate::cgu_reuse_tracker::CguReuseTracker;
 use crate::code_stats::CodeStats;
 pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
-
-use crate::cgu_reuse_tracker::CguReuseTracker;
-use rustc_data_structures::fingerprint::Fingerprint;
-use rustc_data_structures::fx::{FxHashMap, FxHashSet};
-
 use crate::config::{self, OutputType, PrintRequest, Sanitizer, SwitchWithOptPath};
 use crate::filesearch;
 use crate::lint;
+use crate::parse::ParseSess;
 use crate::search_paths::{PathKind, SearchPath};
-use rustc_data_structures::profiling::duration_to_secs_str;
-use rustc_errors::ErrorReported;
 
-use rustc_data_structures::base_n;
-use rustc_data_structures::impl_stable_hash_via_hash;
+pub use rustc_ast::crate_disambiguator::CrateDisambiguator;
+use rustc_data_structures::flock;
+use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_data_structures::jobserver::{self, Client};
+use rustc_data_structures::profiling::{duration_to_secs_str, SelfProfiler, SelfProfilerRef};
 use rustc_data_structures::sync::{
     self, AtomicU64, AtomicUsize, Lock, Lrc, Once, OneThread, Ordering, Ordering::SeqCst,
 };
-
-use crate::parse::ParseSess;
 use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter;
-use rustc_errors::emitter::HumanReadableErrorType;
-use rustc_errors::emitter::{Emitter, EmitterWriter};
+use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType};
 use rustc_errors::json::JsonEmitter;
-use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId};
+use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId, ErrorReported};
 use rustc_span::edition::Edition;
-use rustc_span::source_map;
-use rustc_span::{MultiSpan, Span};
-
-use rustc_data_structures::flock;
-use rustc_data_structures::jobserver::{self, Client};
-use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
+use rustc_span::source_map::{self, MultiSpan, Span};
 use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple};
 
 use std::cell::{self, RefCell};
 use std::env;
-use std::fmt;
 use std::io::Write;
 use std::num::NonZeroU32;
 use std::path::PathBuf;
@@ -1193,34 +1182,6 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
     }
 }
 
-/// Hash value constructed out of all the `-C metadata` arguments passed to the
-/// compiler. Together with the crate-name forms a unique global identifier for
-/// the crate.
-#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)]
-pub struct CrateDisambiguator(Fingerprint);
-
-impl CrateDisambiguator {
-    pub fn to_fingerprint(self) -> Fingerprint {
-        self.0
-    }
-}
-
-impl fmt::Display for CrateDisambiguator {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
-        let (a, b) = self.0.as_value();
-        let as_u128 = a as u128 | ((b as u128) << 64);
-        f.write_str(&base_n::encode(as_u128, base_n::CASE_INSENSITIVE))
-    }
-}
-
-impl From<Fingerprint> for CrateDisambiguator {
-    fn from(fingerprint: Fingerprint) -> CrateDisambiguator {
-        CrateDisambiguator(fingerprint)
-    }
-}
-
-impl_stable_hash_via_hash!(CrateDisambiguator);
-
 /// Holds data on the current incremental compilation session, if there is one.
 #[derive(Debug)]
 pub enum IncrCompSession {