Skip to content

Commit 715b885

Browse files
committed
Deny bare trait objects in in src/librustc_codegen_utils
1 parent 11432ba commit 715b885

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/librustc_codegen_utils/codegen_backend.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,23 @@ pub trait CodegenBackend {
5656
fn print_version(&self) {}
5757
fn diagnostics(&self) -> &[(&'static str, &'static str)] { &[] }
5858

59-
fn metadata_loader(&self) -> Box<MetadataLoader + Sync>;
59+
fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync>;
6060
fn provide(&self, _providers: &mut Providers);
6161
fn provide_extern(&self, _providers: &mut Providers);
6262
fn codegen_crate<'a, 'tcx>(
6363
&self,
6464
tcx: TyCtxt<'a, 'tcx, 'tcx>,
65-
rx: mpsc::Receiver<Box<Any + Send>>
66-
) -> Box<Any>;
65+
rx: mpsc::Receiver<Box<dyn Any + Send>>
66+
) -> Box<dyn Any>;
6767

68-
/// This is called on the returned `Box<Any>` from `codegen_backend`
68+
/// This is called on the returned `Box<dyn Any>` from `codegen_backend`
6969
///
7070
/// # Panics
7171
///
72-
/// Panics when the passed `Box<Any>` was not returned by `codegen_backend`.
72+
/// Panics when the passed `Box<dyn Any>` was not returned by `codegen_backend`.
7373
fn join_codegen_and_link(
7474
&self,
75-
ongoing_codegen: Box<Any>,
75+
ongoing_codegen: Box<dyn Any>,
7676
sess: &Session,
7777
dep_graph: &DepGraph,
7878
outputs: &OutputFilenames,
@@ -105,7 +105,7 @@ pub struct OngoingCodegen {
105105
}
106106

107107
impl MetadataOnlyCodegenBackend {
108-
pub fn new() -> Box<CodegenBackend> {
108+
pub fn new() -> Box<dyn CodegenBackend> {
109109
box MetadataOnlyCodegenBackend(())
110110
}
111111
}
@@ -125,7 +125,7 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
125125
}
126126
}
127127

128-
fn metadata_loader(&self) -> Box<MetadataLoader + Sync> {
128+
fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync> {
129129
box NoLlvmMetadataLoader
130130
}
131131

@@ -145,8 +145,8 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
145145
fn codegen_crate<'a, 'tcx>(
146146
&self,
147147
tcx: TyCtxt<'a, 'tcx, 'tcx>,
148-
_rx: mpsc::Receiver<Box<Any + Send>>
149-
) -> Box<Any> {
148+
_rx: mpsc::Receiver<Box<dyn Any + Send>>
149+
) -> Box<dyn Any> {
150150
use rustc_mir::monomorphize::item::MonoItem;
151151

152152
::check_for_rustc_errors_attr(tcx);
@@ -193,13 +193,13 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
193193

194194
fn join_codegen_and_link(
195195
&self,
196-
ongoing_codegen: Box<Any>,
196+
ongoing_codegen: Box<dyn Any>,
197197
sess: &Session,
198198
_dep_graph: &DepGraph,
199199
outputs: &OutputFilenames,
200200
) -> Result<(), CompileIncomplete> {
201201
let ongoing_codegen = ongoing_codegen.downcast::<OngoingCodegen>()
202-
.expect("Expected MetadataOnlyCodegenBackend's OngoingCodegen, found Box<Any>");
202+
.expect("Expected MetadataOnlyCodegenBackend's OngoingCodegen, found Box<dyn Any>");
203203
for &crate_type in sess.opts.crate_types.iter() {
204204
if crate_type != CrateType::CrateTypeRlib && crate_type != CrateType::CrateTypeDylib {
205205
continue;

src/librustc_codegen_utils/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#![feature(box_syntax)]
2121
#![feature(custom_attribute)]
2222
#![allow(unused_attributes)]
23+
#![deny(bare_trait_objects)]
2324
#![feature(quote)]
2425
#![feature(rustc_diagnostic_macros)]
2526

0 commit comments

Comments
 (0)