From 21d9ac1d04cd59044fa96a3064dd0b56c648655a Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 12 Jul 2018 13:26:29 +0200 Subject: [PATCH] Deny bare trait objects in librustc_target and libtest --- src/librustc_target/lib.rs | 2 ++ src/librustc_target/spec/mod.rs | 2 +- src/libtest/lib.rs | 15 +++++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index 8f491157439..e611d26da56 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -21,6 +21,8 @@ //! one that doesn't; the one that doesn't might get decent parallel //! build speedups. +#![deny(bare_trait_objects)] + #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 19e353c6a94..484563aa302 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -229,7 +229,7 @@ macro_rules! supported_targets { } } - pub fn get_targets() -> Box> { + pub fn get_targets() -> Box> { Box::new(TARGETS.iter().filter_map(|t| -> Option { load_specific(t) .and(Ok(t.to_string())) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index a4d1797c3ec..6b547dff912 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -26,6 +26,9 @@ // NB: this is also specified in this crate's Cargo.toml, but libsyntax contains logic specific to // this crate, which relies on this attribute (rather than the value of `--crate-name` passed by // cargo) to detect this crate. + +#![deny(bare_trait_objects)] + #![crate_name = "test"] #![unstable(feature = "test", issue = "27812")] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -165,8 +168,8 @@ pub trait TDynBenchFn: Send { pub enum TestFn { StaticTestFn(fn()), StaticBenchFn(fn(&mut Bencher)), - DynTestFn(Box), - DynBenchFn(Box), + DynTestFn(Box), + DynBenchFn(Box), } impl TestFn { @@ -840,7 +843,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec) -> io::Resu fn callback( event: &TestEvent, st: &mut ConsoleTestState, - out: &mut OutputFormatter, + out: &mut dyn OutputFormatter, ) -> io::Result<()> { match (*event).clone() { TeFiltered(ref filtered_tests) => { @@ -897,7 +900,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec) -> io::Resu let is_multithreaded = opts.test_threads.unwrap_or_else(get_concurrency) > 1; - let mut out: Box = match opts.format { + let mut out: Box = match opts.format { OutputFormat::Pretty => Box::new(PrettyFormatter::new( output, use_color(opts), @@ -1386,7 +1389,7 @@ pub fn run_test( desc: TestDesc, monitor_ch: Sender, nocapture: bool, - testfn: Box, + testfn: Box, ) { // Buffer for capturing standard I/O let data = Arc::new(Mutex::new(Vec::new())); @@ -1459,7 +1462,7 @@ fn __rust_begin_short_backtrace(f: F) { f() } -fn calc_result(desc: &TestDesc, task_result: Result<(), Box>) -> TestResult { +fn calc_result(desc: &TestDesc, task_result: Result<(), Box>) -> TestResult { match (&desc.should_panic, task_result) { (&ShouldPanic::No, Ok(())) | (&ShouldPanic::Yes, Err(_)) => TrOk, (&ShouldPanic::YesWithMessage(msg), Err(ref err)) => {