From: ljedrz Date: Thu, 12 Jul 2018 07:33:33 +0000 (+0200) Subject: Deny bare trait objects in src/librustc_errors X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=033924464fedf2c68abd4605930a81569a02cbf9;p=rust.git Deny bare trait objects in src/librustc_errors Enforce `#![deny(bare_trait_objects)]` in `src/librustc_errors`. --- diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index de73295b499..d079102a4ba 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -121,7 +121,7 @@ pub fn span_label>(&mut self, span: Span, label: T) -> &mut Self } pub fn note_expected_found(&mut self, - label: &fmt::Display, + label: &dyn fmt::Display, expected: DiagnosticStyledString, found: DiagnosticStyledString) -> &mut Self @@ -130,11 +130,11 @@ pub fn note_expected_found(&mut self, } pub fn note_expected_found_extra(&mut self, - label: &fmt::Display, + label: &dyn fmt::Display, expected: DiagnosticStyledString, found: DiagnosticStyledString, - expected_extra: &fmt::Display, - found_extra: &fmt::Display) + expected_extra: &dyn fmt::Display, + found_extra: &dyn fmt::Display) -> &mut Self { let mut msg: Vec<_> = vec![(format!("expected {} `", label), Style::NoStyle)]; diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 562c28f0840..9c7b7ea3395 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -148,17 +148,17 @@ pub fn span_label>(&mut self, span: Span, label: T) -> &mut Self } forward!(pub fn note_expected_found(&mut self, - label: &fmt::Display, + label: &dyn fmt::Display, expected: DiagnosticStyledString, found: DiagnosticStyledString) -> &mut Self); forward!(pub fn note_expected_found_extra(&mut self, - label: &fmt::Display, + label: &dyn fmt::Display, expected: DiagnosticStyledString, found: DiagnosticStyledString, - expected_extra: &fmt::Display, - found_extra: &fmt::Display) + expected_extra: &dyn fmt::Display, + found_extra: &dyn fmt::Display) -> &mut Self); forward!(pub fn note(&mut self, msg: &str) -> &mut Self); diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index e79a3a87738..2f71c3a7232 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -148,7 +148,7 @@ pub fn stderr(color_config: ColorConfig, } } - pub fn new(dst: Box, + pub fn new(dst: Box, code_map: Option>, short_message: bool, teach: bool) @@ -1469,13 +1469,13 @@ fn emit_to_destination(rendered_buffer: &Vec>, pub enum Destination { Terminal(StandardStream), Buffered(BufferWriter), - Raw(Box), + Raw(Box), } pub enum WritableDst<'a> { Terminal(&'a mut StandardStream), Buffered(&'a mut BufferWriter, Buffer), - Raw(&'a mut Box), + Raw(&'a mut Box), } impl Destination { diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index fd90e1cbe08..f18a7bd9136 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![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/")] @@ -110,7 +112,7 @@ pub struct SubstitutionPart { pub snippet: String, } -pub type CodeMapperDyn = CodeMapper + sync::Send + sync::Sync; +pub type CodeMapperDyn = dyn CodeMapper + sync::Send + sync::Sync; pub trait CodeMapper { fn lookup_char_pos(&self, pos: BytePos) -> Loc; @@ -270,7 +272,7 @@ pub struct Handler { pub flags: HandlerFlags, err_count: AtomicUsize, - emitter: Lock>, + emitter: Lock>, continue_after_error: LockCell, delayed_span_bug: Lock>, @@ -326,7 +328,7 @@ pub fn with_tty_emitter_and_flags(color_config: ColorConfig, pub fn with_emitter(can_emit_warnings: bool, treat_err_as_bug: bool, - e: Box) + e: Box) -> Handler { Handler::with_emitter_and_flags( e, @@ -337,7 +339,8 @@ pub fn with_emitter(can_emit_warnings: bool, }) } - pub fn with_emitter_and_flags(e: Box, flags: HandlerFlags) -> Handler { + pub fn with_emitter_and_flags(e: Box, flags: HandlerFlags) -> Handler + { Handler { flags, err_count: AtomicUsize::new(0), diff --git a/src/librustc_errors/lock.rs b/src/librustc_errors/lock.rs index 4c298228c37..dff8d53986d 100644 --- a/src/librustc_errors/lock.rs +++ b/src/librustc_errors/lock.rs @@ -23,7 +23,7 @@ #[cfg(windows)] #[allow(bad_style)] -pub fn acquire_global_lock(name: &str) -> Box { +pub fn acquire_global_lock(name: &str) -> Box { use std::ffi::CString; use std::io; @@ -110,6 +110,6 @@ fn drop(&mut self) { } #[cfg(unix)] -pub fn acquire_global_lock(_name: &str) -> Box { +pub fn acquire_global_lock(_name: &str) -> Box { Box::new(()) }