Skip to content

Commit 388f969

Browse files
committed
continue CovariantCopyTaggedPtr
1 parent 21877e8 commit 388f969

File tree

12 files changed

+160
-805
lines changed

12 files changed

+160
-805
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
4747
use rustc_data_structures::sorted_map::SortedMap;
4848
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
4949
use rustc_data_structures::sync::Lrc;
50-
use rustc_data_structures::tagged_ptr::CovariantCopyTaggedPtr;
50+
use rustc_data_structures::tagged_ptr::TaggedPtr;
5151
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey};
5252
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5353
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
@@ -1162,7 +1162,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11621162
});
11631163
let kind = hir::TyKind::TraitObject(
11641164
bounds,
1165-
CovariantCopyTaggedPtr::new(lifetime_bound, TraitObjectSyntax::None),
1165+
TaggedPtr::new(lifetime_bound, TraitObjectSyntax::None),
11661166
);
11671167
return hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.next_id() };
11681168
}
@@ -1314,7 +1314,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13141314
lifetime_bound.unwrap_or_else(|| this.elided_dyn_bound(t.span));
13151315
(bounds, lifetime_bound)
13161316
});
1317-
hir::TyKind::TraitObject(bounds, CovariantCopyTaggedPtr::new(lifetime_bound, *kind))
1317+
hir::TyKind::TraitObject(bounds, TaggedPtr::new(lifetime_bound, *kind))
13181318
}
13191319
TyKind::ImplTrait(def_node_id, bounds) => {
13201320
let span = t.span;
@@ -2370,7 +2370,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23702370
hir_id = self.next_id();
23712371
hir::TyKind::TraitObject(
23722372
arena_vec![self; principal],
2373-
CovariantCopyTaggedPtr::new(
2373+
TaggedPtr::new(
23742374
self.elided_dyn_bound(span),
23752375
TraitObjectSyntax::None,
23762376
),

compiler/rustc_data_structures/src/marker.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ impl_dyn_send!(
7272
[Vec<T, A> where T: DynSend, A: std::alloc::Allocator + DynSend]
7373
[Box<T, A> where T: ?Sized + DynSend, A: std::alloc::Allocator + DynSend]
7474
[crate::sync::RwLock<T> where T: DynSend]
75-
[crate::tagged_ptr::CopyTaggedPtr<P, T, CP> where P: Send + crate::tagged_ptr::Pointer, T: Send + crate::tagged_ptr::Tag, const CP: bool]
76-
[crate::tagged_ptr::CovariantCopyTaggedPtr<P, T, CP> where P: Send + crate::tagged_ptr::Pointer<Target: Sized>, T: Send + crate::tagged_ptr::Tag, const CP: bool]
75+
[crate::tagged_ptr::TaggedPtr<P, P::Target, T, CP> where P: Send + crate::tagged_ptr::Pointer<Target: Sized>, T: Send + crate::tagged_ptr::Tag, const CP: bool]
7776
[rustc_arena::TypedArena<T> where T: DynSend]
7877
[indexmap::IndexSet<V, S> where V: DynSend, S: DynSend]
7978
[indexmap::IndexMap<K, V, S> where K: DynSend, V: DynSend, S: DynSend]
@@ -149,8 +148,7 @@ impl_dyn_sync!(
149148
[crate::sync::RwLock<T> where T: DynSend + DynSync]
150149
[crate::sync::WorkerLocal<T> where T: DynSend]
151150
[crate::intern::Interned<'a, T> where 'a, T: DynSync]
152-
[crate::tagged_ptr::CopyTaggedPtr<P, T, CP> where P: Sync + crate::tagged_ptr::Pointer, T: Sync + crate::tagged_ptr::Tag, const CP: bool]
153-
[crate::tagged_ptr::CovariantCopyTaggedPtr<P, T, CP> where P: Sync + crate::tagged_ptr::Pointer<Target: Sized>, T: Sync + crate::tagged_ptr::Tag, const CP: bool]
151+
[crate::tagged_ptr::TaggedPtr<P, P::Target, T, CP> where P: Sync + crate::tagged_ptr::Pointer<Target: Sized>, T: Sync + crate::tagged_ptr::Tag, const CP: bool]
154152
[parking_lot::lock_api::Mutex<R, T> where R: DynSync, T: ?Sized + DynSend]
155153
[parking_lot::lock_api::RwLock<R, T> where R: DynSync, T: ?Sized + DynSend + DynSync]
156154
[indexmap::IndexSet<V, S> where V: DynSync, S: DynSync]

compiler/rustc_data_structures/src/tagged_ptr.rs

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,10 @@ use std::sync::Arc;
2222

2323
use crate::aligned::Aligned;
2424

25-
mod copy;
2625
mod covariant;
27-
mod drop;
2826
mod impl_tag;
2927

30-
pub use copy::CopyTaggedPtr;
31-
pub use covariant::CovariantCopyTaggedPtr;
32-
pub use drop::TaggedPtr;
28+
pub use covariant::TaggedPtr;
3329

3430
/// This describes the pointer type encapsulated by [`TaggedPtr`] and
3531
/// [`CopyTaggedPtr`].
@@ -248,38 +244,40 @@ unsafe impl<'a, T: 'a + ?Sized + Aligned> Pointer for &'a mut T {
248244
}
249245
}
250246

251-
/// A tag type used in [`CopyTaggedPtr`] and [`TaggedPtr`] tests.
252-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
253247
#[cfg(test)]
254-
enum Tag2 {
255-
B00 = 0b00,
256-
B01 = 0b01,
257-
B10 = 0b10,
258-
B11 = 0b11,
259-
}
248+
mod tests {
249+
use super::*;
250+
251+
/// A tag type used in [`CopyTaggedPtr`] and [`TaggedPtr`] tests.
252+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
253+
pub enum Tag2 {
254+
B00 = 0b00,
255+
B01 = 0b01,
256+
B10 = 0b10,
257+
B11 = 0b11,
258+
}
260259

261-
#[cfg(test)]
262-
unsafe impl Tag for Tag2 {
263-
const BITS: u32 = 2;
260+
unsafe impl Tag for Tag2 {
261+
const BITS: u32 = 2;
264262

265-
fn into_usize(self) -> usize {
266-
self as _
267-
}
263+
fn into_usize(self) -> usize {
264+
self as _
265+
}
268266

269-
unsafe fn from_usize(tag: usize) -> Self {
270-
match tag {
271-
0b00 => Tag2::B00,
272-
0b01 => Tag2::B01,
273-
0b10 => Tag2::B10,
274-
0b11 => Tag2::B11,
275-
_ => unreachable!(),
267+
unsafe fn from_usize(tag: usize) -> Self {
268+
match tag {
269+
0b00 => Tag2::B00,
270+
0b01 => Tag2::B01,
271+
0b10 => Tag2::B10,
272+
0b11 => Tag2::B11,
273+
_ => unreachable!(),
274+
}
276275
}
277276
}
278-
}
279277

280-
#[cfg(test)]
281-
impl<HCX> crate::stable_hasher::HashStable<HCX> for Tag2 {
282-
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut crate::stable_hasher::StableHasher) {
283-
(*self as u8).hash_stable(hcx, hasher);
278+
impl<HCX> crate::stable_hasher::HashStable<HCX> for Tag2 {
279+
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut crate::stable_hasher::StableHasher) {
280+
(*self as u8).hash_stable(hcx, hasher);
281+
}
284282
}
285283
}

0 commit comments

Comments
 (0)