Skip to content

Commit bb8785e

Browse files
committed
move CrateDisambiguator -> rustc_ast
1 parent fdf2d2d commit bb8785e

File tree

4 files changed

+48
-52
lines changed

4 files changed

+48
-52
lines changed

src/librustc/hir/map/definitions.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@
55
//! expressions) that are mostly just leftovers.
66
77
use rustc_ast::ast;
8+
use rustc_ast::crate_disambiguator::CrateDisambiguator;
89
use rustc_data_structures::fx::FxHashMap;
910
use rustc_data_structures::stable_hasher::StableHasher;
1011
use rustc_hir as hir;
12+
pub use rustc_hir::def_id::DefPathHash;
1113
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
1214
use rustc_index::vec::IndexVec;
13-
use rustc_session::CrateDisambiguator;
1415
use rustc_span::hygiene::ExpnId;
1516
use rustc_span::symbol::{sym, Symbol};
1617
use rustc_span::Span;
1718

1819
use std::fmt::Write;
1920
use std::hash::Hash;
2021

21-
pub use rustc_hir::def_id::DefPathHash;
22-
2322
/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
2423
/// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey`
2524
/// stores the `DefIndex` of its parent.
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// This is here because `rustc_session` wants to refer to it,
2+
// and so does `rustc_hir`, but `rustc_hir` shouldn't refer to `rustc_session`.
3+
4+
use rustc_data_structures::fingerprint::Fingerprint;
5+
use rustc_data_structures::{base_n, impl_stable_hash_via_hash};
6+
7+
use std::fmt;
8+
9+
/// Hash value constructed out of all the `-C metadata` arguments passed to the
10+
/// compiler. Together with the crate-name forms a unique global identifier for
11+
/// the crate.
12+
#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)]
13+
pub struct CrateDisambiguator(Fingerprint);
14+
15+
impl CrateDisambiguator {
16+
pub fn to_fingerprint(self) -> Fingerprint {
17+
self.0
18+
}
19+
}
20+
21+
impl fmt::Display for CrateDisambiguator {
22+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
23+
let (a, b) = self.0.as_value();
24+
let as_u128 = a as u128 | ((b as u128) << 64);
25+
f.write_str(&base_n::encode(as_u128, base_n::CASE_INSENSITIVE))
26+
}
27+
}
28+
29+
impl From<Fingerprint> for CrateDisambiguator {
30+
fn from(fingerprint: Fingerprint) -> CrateDisambiguator {
31+
CrateDisambiguator(fingerprint)
32+
}
33+
}
34+
35+
impl_stable_hash_via_hash!(CrateDisambiguator);

src/librustc_ast/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub mod util {
4040
pub mod ast;
4141
pub mod attr;
4242
pub use attr::{with_default_globals, with_globals, GLOBALS};
43+
pub mod crate_disambiguator;
4344
pub mod entry;
4445
pub mod expand;
4546
pub mod mut_visit;

src/librustc_session/session.rs

+10-49
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,30 @@
1+
use crate::cgu_reuse_tracker::CguReuseTracker;
12
use crate::code_stats::CodeStats;
23
pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
3-
4-
use crate::cgu_reuse_tracker::CguReuseTracker;
5-
use rustc_data_structures::fingerprint::Fingerprint;
6-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
7-
84
use crate::config::{self, OutputType, PrintRequest, Sanitizer, SwitchWithOptPath};
95
use crate::filesearch;
106
use crate::lint;
7+
use crate::parse::ParseSess;
118
use crate::search_paths::{PathKind, SearchPath};
12-
use rustc_data_structures::profiling::duration_to_secs_str;
13-
use rustc_errors::ErrorReported;
149

15-
use rustc_data_structures::base_n;
16-
use rustc_data_structures::impl_stable_hash_via_hash;
10+
pub use rustc_ast::crate_disambiguator::CrateDisambiguator;
11+
use rustc_data_structures::flock;
12+
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
13+
use rustc_data_structures::jobserver::{self, Client};
14+
use rustc_data_structures::profiling::{duration_to_secs_str, SelfProfiler, SelfProfilerRef};
1715
use rustc_data_structures::sync::{
1816
self, AtomicU64, AtomicUsize, Lock, Lrc, Once, OneThread, Ordering, Ordering::SeqCst,
1917
};
20-
21-
use crate::parse::ParseSess;
2218
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter;
23-
use rustc_errors::emitter::HumanReadableErrorType;
24-
use rustc_errors::emitter::{Emitter, EmitterWriter};
19+
use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType};
2520
use rustc_errors::json::JsonEmitter;
26-
use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId};
21+
use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId, ErrorReported};
2722
use rustc_span::edition::Edition;
28-
use rustc_span::source_map;
29-
use rustc_span::{MultiSpan, Span};
30-
31-
use rustc_data_structures::flock;
32-
use rustc_data_structures::jobserver::{self, Client};
33-
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
23+
use rustc_span::source_map::{self, MultiSpan, Span};
3424
use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple};
3525

3626
use std::cell::{self, RefCell};
3727
use std::env;
38-
use std::fmt;
3928
use std::io::Write;
4029
use std::num::NonZeroU32;
4130
use std::path::PathBuf;
@@ -1193,34 +1182,6 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
11931182
}
11941183
}
11951184

1196-
/// Hash value constructed out of all the `-C metadata` arguments passed to the
1197-
/// compiler. Together with the crate-name forms a unique global identifier for
1198-
/// the crate.
1199-
#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)]
1200-
pub struct CrateDisambiguator(Fingerprint);
1201-
1202-
impl CrateDisambiguator {
1203-
pub fn to_fingerprint(self) -> Fingerprint {
1204-
self.0
1205-
}
1206-
}
1207-
1208-
impl fmt::Display for CrateDisambiguator {
1209-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
1210-
let (a, b) = self.0.as_value();
1211-
let as_u128 = a as u128 | ((b as u128) << 64);
1212-
f.write_str(&base_n::encode(as_u128, base_n::CASE_INSENSITIVE))
1213-
}
1214-
}
1215-
1216-
impl From<Fingerprint> for CrateDisambiguator {
1217-
fn from(fingerprint: Fingerprint) -> CrateDisambiguator {
1218-
CrateDisambiguator(fingerprint)
1219-
}
1220-
}
1221-
1222-
impl_stable_hash_via_hash!(CrateDisambiguator);
1223-
12241185
/// Holds data on the current incremental compilation session, if there is one.
12251186
#[derive(Debug)]
12261187
pub enum IncrCompSession {

0 commit comments

Comments
 (0)