Skip to content

Commit ff65bbe

Browse files
committed
Deny bare trait objects in in src/librustc_data_structures
1 parent ae5b629 commit ff65bbe

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/librustc_data_structures/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
//!
1717
//! This API is completely unstable and subject to change.
1818
19+
#![deny(bare_trait_objects)]
20+
1921
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2022
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
2123
html_root_url = "https://doc.rust-lang.org/nightly/")]

src/librustc_data_structures/owning_ref/mod.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ unsafe impl<O, T: ?Sized> Send for OwningRefMut<O, T>
10461046
unsafe impl<O, T: ?Sized> Sync for OwningRefMut<O, T>
10471047
where O: Sync, for<'a> (&'a mut T): Sync {}
10481048

1049-
impl Debug for Erased {
1049+
impl Debug for dyn Erased {
10501050
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10511051
write!(f, "<Erased>",)
10521052
}
@@ -1166,35 +1166,35 @@ pub type MutexGuardRefMut<'a, T, U = T> = OwningRefMut<MutexGuard<'a, T>, U>;
11661166
pub type RwLockWriteGuardRefMut<'a, T, U = T> = OwningRef<RwLockWriteGuard<'a, T>, U>;
11671167

11681168
unsafe impl<'a, T: 'a> IntoErased<'a> for Box<T> {
1169-
type Erased = Box<Erased + 'a>;
1169+
type Erased = Box<dyn Erased + 'a>;
11701170
fn into_erased(self) -> Self::Erased {
11711171
self
11721172
}
11731173
}
11741174
unsafe impl<'a, T: 'a> IntoErased<'a> for Rc<T> {
1175-
type Erased = Rc<Erased + 'a>;
1175+
type Erased = Rc<dyn Erased + 'a>;
11761176
fn into_erased(self) -> Self::Erased {
11771177
self
11781178
}
11791179
}
11801180
unsafe impl<'a, T: 'a> IntoErased<'a> for Arc<T> {
1181-
type Erased = Arc<Erased + 'a>;
1181+
type Erased = Arc<dyn Erased + 'a>;
11821182
fn into_erased(self) -> Self::Erased {
11831183
self
11841184
}
11851185
}
11861186

11871187
unsafe impl<'a, T: Send + 'a> IntoErasedSend<'a> for Box<T> {
1188-
type Erased = Box<Erased + Send + 'a>;
1188+
type Erased = Box<dyn Erased + Send + 'a>;
11891189
fn into_erased_send(self) -> Self::Erased {
11901190
self
11911191
}
11921192
}
11931193

11941194
unsafe impl<'a, T: Send + 'a> IntoErasedSendSync<'a> for Box<T> {
1195-
type Erased = Box<Erased + Sync + Send + 'a>;
1195+
type Erased = Box<dyn Erased + Sync + Send + 'a>;
11961196
fn into_erased_send_sync(self) -> Self::Erased {
1197-
let result: Box<Erased + Send + 'a> = self;
1197+
let result: Box<dyn Erased + Send + 'a> = self;
11981198
// This is safe since Erased can always implement Sync
11991199
// Only the destructor is available and it takes &mut self
12001200
unsafe {
@@ -1204,21 +1204,21 @@ unsafe impl<'a, T: Send + 'a> IntoErasedSendSync<'a> for Box<T> {
12041204
}
12051205

12061206
unsafe impl<'a, T: Send + Sync + 'a> IntoErasedSendSync<'a> for Arc<T> {
1207-
type Erased = Arc<Erased + Send + Sync + 'a>;
1207+
type Erased = Arc<dyn Erased + Send + Sync + 'a>;
12081208
fn into_erased_send_sync(self) -> Self::Erased {
12091209
self
12101210
}
12111211
}
12121212

12131213
/// Typedef of a owning reference that uses an erased `Box` as the owner.
1214-
pub type ErasedBoxRef<U> = OwningRef<Box<Erased>, U>;
1214+
pub type ErasedBoxRef<U> = OwningRef<Box<dyn Erased>, U>;
12151215
/// Typedef of a owning reference that uses an erased `Rc` as the owner.
1216-
pub type ErasedRcRef<U> = OwningRef<Rc<Erased>, U>;
1216+
pub type ErasedRcRef<U> = OwningRef<Rc<dyn Erased>, U>;
12171217
/// Typedef of a owning reference that uses an erased `Arc` as the owner.
1218-
pub type ErasedArcRef<U> = OwningRef<Arc<Erased>, U>;
1218+
pub type ErasedArcRef<U> = OwningRef<Arc<dyn Erased>, U>;
12191219

12201220
/// Typedef of a mutable owning reference that uses an erased `Box` as the owner.
1221-
pub type ErasedBoxRefMut<U> = OwningRefMut<Box<Erased>, U>;
1221+
pub type ErasedBoxRefMut<U> = OwningRefMut<Box<dyn Erased>, U>;
12221222

12231223
#[cfg(test)]
12241224
mod tests {

src/librustc_data_structures/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ cfg_if! {
8888
t.into_iter()
8989
}
9090

91-
pub type MetadataRef = OwningRef<Box<Erased>, [u8]>;
91+
pub type MetadataRef = OwningRef<Box<dyn Erased>, [u8]>;
9292

9393
pub use std::rc::Rc as Lrc;
9494
pub use std::rc::Weak as Weak;

0 commit comments

Comments
 (0)