Skip to content

Commit 21d9ac1

Browse files
committed
Deny bare trait objects in librustc_target and libtest
1 parent c946c25 commit 21d9ac1

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/librustc_target/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
//! one that doesn't; the one that doesn't might get decent parallel
2222
//! build speedups.
2323
24+
#![deny(bare_trait_objects)]
25+
2426
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2527
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2628
html_root_url = "https://doc.rust-lang.org/nightly/")]

src/librustc_target/spec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ macro_rules! supported_targets {
229229
}
230230
}
231231

232-
pub fn get_targets() -> Box<Iterator<Item=String>> {
232+
pub fn get_targets() -> Box<dyn Iterator<Item=String>> {
233233
Box::new(TARGETS.iter().filter_map(|t| -> Option<String> {
234234
load_specific(t)
235235
.and(Ok(t.to_string()))

src/libtest/lib.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
// NB: this is also specified in this crate's Cargo.toml, but libsyntax contains logic specific to
2727
// this crate, which relies on this attribute (rather than the value of `--crate-name` passed by
2828
// cargo) to detect this crate.
29+
30+
#![deny(bare_trait_objects)]
31+
2932
#![crate_name = "test"]
3033
#![unstable(feature = "test", issue = "27812")]
3134
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -165,8 +168,8 @@ pub trait TDynBenchFn: Send {
165168
pub enum TestFn {
166169
StaticTestFn(fn()),
167170
StaticBenchFn(fn(&mut Bencher)),
168-
DynTestFn(Box<FnBox() + Send>),
169-
DynBenchFn(Box<TDynBenchFn + 'static>),
171+
DynTestFn(Box<dyn FnBox() + Send>),
172+
DynBenchFn(Box<dyn TDynBenchFn + 'static>),
170173
}
171174

172175
impl TestFn {
@@ -840,7 +843,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
840843
fn callback(
841844
event: &TestEvent,
842845
st: &mut ConsoleTestState,
843-
out: &mut OutputFormatter,
846+
out: &mut dyn OutputFormatter,
844847
) -> io::Result<()> {
845848
match (*event).clone() {
846849
TeFiltered(ref filtered_tests) => {
@@ -897,7 +900,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
897900

898901
let is_multithreaded = opts.test_threads.unwrap_or_else(get_concurrency) > 1;
899902

900-
let mut out: Box<OutputFormatter> = match opts.format {
903+
let mut out: Box<dyn OutputFormatter> = match opts.format {
901904
OutputFormat::Pretty => Box::new(PrettyFormatter::new(
902905
output,
903906
use_color(opts),
@@ -1386,7 +1389,7 @@ pub fn run_test(
13861389
desc: TestDesc,
13871390
monitor_ch: Sender<MonitorMsg>,
13881391
nocapture: bool,
1389-
testfn: Box<FnBox() + Send>,
1392+
testfn: Box<dyn FnBox() + Send>,
13901393
) {
13911394
// Buffer for capturing standard I/O
13921395
let data = Arc::new(Mutex::new(Vec::new()));
@@ -1459,7 +1462,7 @@ fn __rust_begin_short_backtrace<F: FnOnce()>(f: F) {
14591462
f()
14601463
}
14611464

1462-
fn calc_result(desc: &TestDesc, task_result: Result<(), Box<Any + Send>>) -> TestResult {
1465+
fn calc_result(desc: &TestDesc, task_result: Result<(), Box<dyn Any + Send>>) -> TestResult {
14631466
match (&desc.should_panic, task_result) {
14641467
(&ShouldPanic::No, Ok(())) | (&ShouldPanic::Yes, Err(_)) => TrOk,
14651468
(&ShouldPanic::YesWithMessage(msg), Err(ref err)) => {

0 commit comments

Comments
 (0)