Skip to content

Deny bare trait objects in src/librustc_errors #52286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/librustc_errors/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl Diagnostic {
}

pub fn note_expected_found(&mut self,
label: &fmt::Display,
label: &dyn fmt::Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString)
-> &mut Self
Expand All @@ -130,11 +130,11 @@ impl Diagnostic {
}

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)];
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_errors/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@ impl<'a> DiagnosticBuilder<'a> {
}

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);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl EmitterWriter {
}
}

pub fn new(dst: Box<Write + Send>,
pub fn new(dst: Box<dyn Write + Send>,
code_map: Option<Lrc<CodeMapperDyn>>,
short_message: bool,
teach: bool)
Expand Down Expand Up @@ -1469,13 +1469,13 @@ fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
pub enum Destination {
Terminal(StandardStream),
Buffered(BufferWriter),
Raw(Box<Write + Send>),
Raw(Box<dyn Write + Send>),
}

pub enum WritableDst<'a> {
Terminal(&'a mut StandardStream),
Buffered(&'a mut BufferWriter, Buffer),
Raw(&'a mut Box<Write + Send>),
Raw(&'a mut Box<dyn Write + Send>),
}

impl Destination {
Expand Down
11 changes: 7 additions & 4 deletions src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/")]
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -270,7 +272,7 @@ pub struct Handler {
pub flags: HandlerFlags,

err_count: AtomicUsize,
emitter: Lock<Box<Emitter + sync::Send>>,
emitter: Lock<Box<dyn Emitter + sync::Send>>,
continue_after_error: LockCell<bool>,
delayed_span_bug: Lock<Option<Diagnostic>>,

Expand Down Expand Up @@ -326,7 +328,7 @@ impl Handler {

pub fn with_emitter(can_emit_warnings: bool,
treat_err_as_bug: bool,
e: Box<Emitter + sync::Send>)
e: Box<dyn Emitter + sync::Send>)
-> Handler {
Handler::with_emitter_and_flags(
e,
Expand All @@ -337,7 +339,8 @@ impl Handler {
})
}

pub fn with_emitter_and_flags(e: Box<Emitter + sync::Send>, flags: HandlerFlags) -> Handler {
pub fn with_emitter_and_flags(e: Box<dyn Emitter + sync::Send>, flags: HandlerFlags) -> Handler
{
Handler {
flags,
err_count: AtomicUsize::new(0),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_errors/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::any::Any;

#[cfg(windows)]
#[allow(bad_style)]
pub fn acquire_global_lock(name: &str) -> Box<Any> {
pub fn acquire_global_lock(name: &str) -> Box<dyn Any> {
use std::ffi::CString;
use std::io;

Expand Down Expand Up @@ -110,6 +110,6 @@ pub fn acquire_global_lock(name: &str) -> Box<Any> {
}

#[cfg(unix)]
pub fn acquire_global_lock(_name: &str) -> Box<Any> {
pub fn acquire_global_lock(_name: &str) -> Box<dyn Any> {
Box::new(())
}