Skip to content

Commit a0fc455

Browse files
committed
Replace absolute paths with relative ones
Modern compilers allow reaching external crates like std or core via relative paths in modules outside of lib.rs and main.rs.
1 parent f54072b commit a0fc455

File tree

32 files changed

+73
-76
lines changed

32 files changed

+73
-76
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ unsafe fn configure_llvm(sess: &Session) {
122122

123123
llvm::LLVMInitializePasses();
124124

125-
::rustc_llvm::initialize_available_targets();
125+
rustc_llvm::initialize_available_targets();
126126

127127
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr());
128128
}

compiler/rustc_codegen_ssa/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
11751175
// necessary. There's already optimizations in place to avoid sending work
11761176
// back to the coordinator if LTO isn't requested.
11771177
return thread::spawn(move || {
1178-
let max_workers = ::num_cpus::get();
1178+
let max_workers = num_cpus::get();
11791179
let mut worker_id_counter = 0;
11801180
let mut free_worker_ids = Vec::new();
11811181
let mut get_worker_id = |free_worker_ids: &mut Vec<usize>| {

compiler/rustc_codegen_ssa/src/base.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
695695
total_codegen_time.into_inner(),
696696
);
697697

698-
::rustc_incremental::assert_module_sources::assert_module_sources(tcx);
698+
rustc_incremental::assert_module_sources::assert_module_sources(tcx);
699699

700700
symbol_names_test::report_symbol_names(tcx);
701701

@@ -754,8 +754,8 @@ impl<B: ExtraBackendMethods> Drop for AbortCodegenOnDrop<B> {
754754
}
755755

756756
fn finalize_tcx(tcx: TyCtxt<'_>) {
757-
tcx.sess.time("assert_dep_graph", || ::rustc_incremental::assert_dep_graph(tcx));
758-
tcx.sess.time("serialize_dep_graph", || ::rustc_incremental::save_dep_graph(tcx));
757+
tcx.sess.time("assert_dep_graph", || rustc_incremental::assert_dep_graph(tcx));
758+
tcx.sess.time("serialize_dep_graph", || rustc_incremental::save_dep_graph(tcx));
759759

760760
// We assume that no queries are run past here. If there are new queries
761761
// after this point, they'll show up as "<unknown>" in self-profiling data.

compiler/rustc_codegen_ssa/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'tcx, T> CodegenMethods<'tcx> for T where
8585
}
8686

8787
pub trait HasCodegen<'tcx>:
88-
Backend<'tcx> + ::std::ops::Deref<Target = <Self as HasCodegen<'tcx>>::CodegenCx>
88+
Backend<'tcx> + std::ops::Deref<Target = <Self as HasCodegen<'tcx>>::CodegenCx>
8989
{
9090
type CodegenCx: CodegenMethods<'tcx>
9191
+ BackendTypes<

compiler/rustc_data_structures/src/fingerprint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ impl Fingerprint {
7171
}
7272
}
7373

74-
impl ::std::fmt::Display for Fingerprint {
75-
fn fmt(&self, formatter: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
74+
impl std::fmt::Display for Fingerprint {
75+
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7676
write!(formatter, "{:x}-{:x}", self.0, self.1)
7777
}
7878
}

compiler/rustc_data_structures/src/obligation_forest/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub enum ProcessResult<O, E> {
129129
struct ObligationTreeId(usize);
130130

131131
type ObligationTreeIdGenerator =
132-
::std::iter::Map<::std::ops::RangeFrom<usize>, fn(usize) -> ObligationTreeId>;
132+
std::iter::Map<std::ops::RangeFrom<usize>, fn(usize) -> ObligationTreeId>;
133133

134134
pub struct ObligationForest<O: ForestObligation> {
135135
/// The list of obligations. In between calls to `process_obligations`,

compiler/rustc_data_structures/src/sorted_map.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<K: Ord, V> SortedMap<K, V> {
9393

9494
/// Iterate over elements, sorted by key
9595
#[inline]
96-
pub fn iter(&self) -> ::std::slice::Iter<'_, (K, V)> {
96+
pub fn iter(&self) -> std::slice::Iter<'_, (K, V)> {
9797
self.data.iter()
9898
}
9999

@@ -134,7 +134,7 @@ impl<K: Ord, V> SortedMap<K, V> {
134134
R: RangeBounds<K>,
135135
{
136136
let (start, end) = self.range_slice_indices(range);
137-
self.data.splice(start..end, ::std::iter::empty());
137+
self.data.splice(start..end, std::iter::empty());
138138
}
139139

140140
/// Mutate all keys with the given function `f`. This mutation must not
@@ -241,7 +241,7 @@ impl<K: Ord, V> SortedMap<K, V> {
241241

242242
impl<K: Ord, V> IntoIterator for SortedMap<K, V> {
243243
type Item = (K, V);
244-
type IntoIter = ::std::vec::IntoIter<(K, V)>;
244+
type IntoIter = std::vec::IntoIter<(K, V)>;
245245

246246
fn into_iter(self) -> Self::IntoIter {
247247
self.data.into_iter()

compiler/rustc_data_structures/src/stable_hasher.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct StableHasher {
2020
}
2121

2222
impl ::std::fmt::Debug for StableHasher {
23-
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
23+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2424
write!(f, "{:?}", self.state)
2525
}
2626
}

compiler/rustc_hir/src/definitions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl DefKey {
118118

119119
let DisambiguatedDefPathData { ref data, disambiguator } = self.disambiguated_data;
120120

121-
::std::mem::discriminant(data).hash(&mut hasher);
121+
std::mem::discriminant(data).hash(&mut hasher);
122122
if let Some(name) = data.get_opt_name() {
123123
// Get a stable hash by considering the symbol chars rather than
124124
// the symbol index.

compiler/rustc_infer/src/infer/nll_relate/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ where
341341
// been fully instantiated and hence the set of scopes we have
342342
// doesn't matter -- just to be sure, put an empty vector
343343
// in there.
344-
let old_a_scopes = ::std::mem::take(pair.vid_scopes(self));
344+
let old_a_scopes = std::mem::take(pair.vid_scopes(self));
345345

346346
// Relate the generalized kind to the original one.
347347
let result = pair.relate_generalized_ty(self, generalized_ty);
@@ -680,7 +680,7 @@ where
680680
// itself occurs. Note that `'b` and `'c` must both
681681
// include P. At the point, the call works because of
682682
// subtyping (i.e., `&'b u32 <: &{P} u32`).
683-
let variance = ::std::mem::replace(&mut self.ambient_variance, ty::Variance::Covariant);
683+
let variance = std::mem::replace(&mut self.ambient_variance, ty::Variance::Covariant);
684684

685685
self.relate(a.skip_binder(), b.skip_binder())?;
686686

@@ -709,7 +709,7 @@ where
709709
// Reset ambient variance to contravariance. See the
710710
// covariant case above for an explanation.
711711
let variance =
712-
::std::mem::replace(&mut self.ambient_variance, ty::Variance::Contravariant);
712+
std::mem::replace(&mut self.ambient_variance, ty::Variance::Contravariant);
713713

714714
self.relate(a.skip_binder(), b.skip_binder())?;
715715

compiler/rustc_infer/src/infer/outlives/obligations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
110110

111111
/// Trait queries just want to pass back type obligations "as is"
112112
pub fn take_registered_region_obligations(&self) -> Vec<(hir::HirId, RegionObligation<'tcx>)> {
113-
::std::mem::take(&mut self.inner.borrow_mut().region_obligations)
113+
std::mem::take(&mut self.inner.borrow_mut().region_obligations)
114114
}
115115

116116
/// Process the region obligations that must be proven (during

compiler/rustc_middle/src/ich/impls_syntax.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::ich::StableHashingContext;
55

66
use rustc_ast as ast;
77
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
8-
use rustc_span::SourceFile;
8+
use rustc_span::{BytePos, NormalizedPos, SourceFile};
99

1010
use smallvec::SmallVec;
1111

@@ -102,34 +102,28 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
102102
}
103103
}
104104

105-
fn stable_byte_pos(pos: ::rustc_span::BytePos, source_file_start: ::rustc_span::BytePos) -> u32 {
105+
fn stable_byte_pos(pos: BytePos, source_file_start: BytePos) -> u32 {
106106
pos.0 - source_file_start.0
107107
}
108108

109-
fn stable_multibyte_char(
110-
mbc: ::rustc_span::MultiByteChar,
111-
source_file_start: ::rustc_span::BytePos,
112-
) -> (u32, u32) {
113-
let ::rustc_span::MultiByteChar { pos, bytes } = mbc;
109+
fn stable_multibyte_char(mbc: rustc_span::MultiByteChar, source_file_start: BytePos) -> (u32, u32) {
110+
let rustc_span::MultiByteChar { pos, bytes } = mbc;
114111

115112
(pos.0 - source_file_start.0, bytes as u32)
116113
}
117114

118115
fn stable_non_narrow_char(
119-
swc: ::rustc_span::NonNarrowChar,
120-
source_file_start: ::rustc_span::BytePos,
116+
swc: rustc_span::NonNarrowChar,
117+
source_file_start: BytePos,
121118
) -> (u32, u32) {
122119
let pos = swc.pos();
123120
let width = swc.width();
124121

125122
(pos.0 - source_file_start.0, width as u32)
126123
}
127124

128-
fn stable_normalized_pos(
129-
np: ::rustc_span::NormalizedPos,
130-
source_file_start: ::rustc_span::BytePos,
131-
) -> (u32, u32) {
132-
let ::rustc_span::NormalizedPos { pos, diff } = np;
125+
fn stable_normalized_pos(np: NormalizedPos, source_file_start: BytePos) -> (u32, u32) {
126+
let NormalizedPos { pos, diff } = np;
133127

134128
(pos.0 - source_file_start.0, diff)
135129
}

compiler/rustc_middle/src/mir/interpret/allocation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct Allocation<Tag = (), Extra = ()> {
4040
pub extra: Extra,
4141
}
4242

43-
pub trait AllocationExtra<Tag>: ::std::fmt::Debug + Clone {
43+
pub trait AllocationExtra<Tag>: std::fmt::Debug + Clone {
4444
// There is no constructor in here because the constructor's type depends
4545
// on `MemoryKind`, and making things sufficiently generic leads to painful
4646
// inference failure.

compiler/rustc_middle/src/mir/interpret/value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'tcx> ConstValue<'tcx> {
5858

5959
pub fn try_to_str_slice(&self) -> Option<&'tcx str> {
6060
if let ConstValue::Slice { data, start, end } = *self {
61-
::std::str::from_utf8(data.inspect_with_uninit_and_ptr_outside_interpreter(start..end))
61+
std::str::from_utf8(data.inspect_with_uninit_and_ptr_outside_interpreter(start..end))
6262
.ok()
6363
} else {
6464
None
@@ -465,7 +465,7 @@ impl<'tcx, Tag> Scalar<Tag> {
465465

466466
pub fn to_char(self) -> InterpResult<'tcx, char> {
467467
let val = self.to_u32()?;
468-
match ::std::char::from_u32(val) {
468+
match std::char::from_u32(val) {
469469
Some(c) => Ok(c),
470470
None => throw_ub!(InvalidChar(val)),
471471
}

compiler/rustc_middle/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ mod binding_form_impl {
775775
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for super::BindingForm<'tcx> {
776776
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
777777
use super::BindingForm::*;
778-
::std::mem::discriminant(self).hash_stable(hcx, hasher);
778+
std::mem::discriminant(self).hash_stable(hcx, hasher);
779779

780780
match self {
781781
Var(binding) => binding.hash_stable(hcx, hasher),

compiler/rustc_middle/src/ty/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ impl<'tcx, T: HasTyCtxt<'tcx>> HasTyCtxt<'tcx> for LayoutCx<'tcx, T> {
18941894
}
18951895
}
18961896

1897-
pub type TyAndLayout<'tcx> = ::rustc_target::abi::TyAndLayout<'tcx, Ty<'tcx>>;
1897+
pub type TyAndLayout<'tcx> = rustc_target::abi::TyAndLayout<'tcx, Ty<'tcx>>;
18981898

18991899
impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
19001900
type Ty = Ty<'tcx>;

compiler/rustc_middle/src/ty/normalize_erasing_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<'tcx> TyCtxt<'tcx> {
2323
{
2424
debug!(
2525
"normalize_erasing_regions::<{}>(value={:?}, param_env={:?})",
26-
::std::any::type_name::<T>(),
26+
std::any::type_name::<T>(),
2727
value,
2828
param_env,
2929
);

compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ pub trait PrettyPrinter<'tcx>:
11421142
// relocations (we have an active `str` reference here). We don't use this
11431143
// result to affect interpreter execution.
11441144
let slice = data.inspect_with_uninit_and_ptr_outside_interpreter(start..end);
1145-
let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri");
1145+
let s = std::str::from_utf8(slice).expect("non utf8 str from miri");
11461146
p!(write("{:?}", s));
11471147
Ok(self)
11481148
}

compiler/rustc_middle/src/ty/query/on_disk_cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ impl<'a, 'tcx> DecoderWithPosition for CacheDecoder<'a, 'tcx> {
543543
// tag matches and the correct amount of bytes was read.
544544
fn decode_tagged<D, T, V>(decoder: &mut D, expected_tag: T) -> Result<V, D::Error>
545545
where
546-
T: Decodable<D> + Eq + ::std::fmt::Debug,
546+
T: Decodable<D> + Eq + std::fmt::Debug,
547547
V: Decodable<D>,
548548
D: DecoderWithPosition,
549549
{
@@ -1023,7 +1023,7 @@ where
10231023
let _timer = tcx
10241024
.sess
10251025
.prof
1026-
.extra_verbose_generic_activity("encode_query_results_for", ::std::any::type_name::<Q>());
1026+
.extra_verbose_generic_activity("encode_query_results_for", std::any::type_name::<Q>());
10271027

10281028
let state = Q::query_state(tcx);
10291029
assert!(state.all_inactive());

compiler/rustc_middle/src/ty/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ impl<'tcx> ty::TyS<'tcx> {
646646
}
647647
ty::Char => Some(std::char::MAX as u128),
648648
ty::Float(fty) => Some(match fty {
649-
ast::FloatTy::F32 => ::rustc_apfloat::ieee::Single::INFINITY.to_bits(),
650-
ast::FloatTy::F64 => ::rustc_apfloat::ieee::Double::INFINITY.to_bits(),
649+
ast::FloatTy::F32 => rustc_apfloat::ieee::Single::INFINITY.to_bits(),
650+
ast::FloatTy::F64 => rustc_apfloat::ieee::Double::INFINITY.to_bits(),
651651
}),
652652
_ => None,
653653
};

compiler/rustc_mir/src/interpret/machine.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! interpreting common C functions leak into CTFE.
44
55
use std::borrow::{Borrow, Cow};
6+
use std::fmt::Debug;
67
use std::hash::Hash;
78

89
use rustc_middle::mir;
@@ -79,19 +80,19 @@ pub trait AllocMap<K: Hash + Eq, V> {
7980
/// and some use case dependent behaviour can instead be applied.
8081
pub trait Machine<'mir, 'tcx>: Sized {
8182
/// Additional memory kinds a machine wishes to distinguish from the builtin ones
82-
type MemoryKind: ::std::fmt::Debug + ::std::fmt::Display + MayLeak + Eq + 'static;
83+
type MemoryKind: Debug + std::fmt::Display + MayLeak + Eq + 'static;
8384

8485
/// Tag tracked alongside every pointer. This is used to implement "Stacked Borrows"
8586
/// <https://www.ralfj.de/blog/2018/08/07/stacked-borrows.html>.
8687
/// The `default()` is used for pointers to consts, statics, vtables and functions.
8788
/// The `Debug` formatting is used for displaying pointers; we cannot use `Display`
8889
/// as `()` does not implement that, but it should be "nice" output.
89-
type PointerTag: ::std::fmt::Debug + Copy + Eq + Hash + 'static;
90+
type PointerTag: Debug + Copy + Eq + Hash + 'static;
9091

9192
/// Machines can define extra (non-instance) things that represent values of function pointers.
9293
/// For example, Miri uses this to return a function pointer from `dlsym`
9394
/// that can later be called to execute the right thing.
94-
type ExtraFnVal: ::std::fmt::Debug + Copy;
95+
type ExtraFnVal: Debug + Copy;
9596

9697
/// Extra data stored in every call frame.
9798
type FrameExtra;

compiler/rustc_mir/src/interpret/operand.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<Tag: Copy> std::fmt::Display for ImmTy<'tcx, Tag> {
133133
}
134134
}
135135

136-
impl<'tcx, Tag> ::std::ops::Deref for ImmTy<'tcx, Tag> {
136+
impl<'tcx, Tag> std::ops::Deref for ImmTy<'tcx, Tag> {
137137
type Target = Immediate<Tag>;
138138
#[inline(always)]
139139
fn deref(&self) -> &Immediate<Tag> {
@@ -156,7 +156,7 @@ pub struct OpTy<'tcx, Tag = ()> {
156156
pub layout: TyAndLayout<'tcx>,
157157
}
158158

159-
impl<'tcx, Tag> ::std::ops::Deref for OpTy<'tcx, Tag> {
159+
impl<'tcx, Tag> std::ops::Deref for OpTy<'tcx, Tag> {
160160
type Target = Operand<Tag>;
161161
#[inline(always)]
162162
fn deref(&self) -> &Operand<Tag> {
@@ -340,7 +340,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
340340
pub fn read_str(&self, mplace: MPlaceTy<'tcx, M::PointerTag>) -> InterpResult<'tcx, &str> {
341341
let len = mplace.len(self)?;
342342
let bytes = self.memory.read_bytes(mplace.ptr, Size::from_bytes(len))?;
343-
let str = ::std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?;
343+
let str = std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?;
344344
Ok(str)
345345
}
346346

0 commit comments

Comments
 (0)