Skip to content

Commit 0339244

Browse files
committed
Deny bare trait objects in src/librustc_errors
Enforce `#![deny(bare_trait_objects)]` in `src/librustc_errors`.
1 parent c946c25 commit 0339244

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

src/librustc_errors/diagnostic.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl Diagnostic {
121121
}
122122

123123
pub fn note_expected_found(&mut self,
124-
label: &fmt::Display,
124+
label: &dyn fmt::Display,
125125
expected: DiagnosticStyledString,
126126
found: DiagnosticStyledString)
127127
-> &mut Self
@@ -130,11 +130,11 @@ impl Diagnostic {
130130
}
131131

132132
pub fn note_expected_found_extra(&mut self,
133-
label: &fmt::Display,
133+
label: &dyn fmt::Display,
134134
expected: DiagnosticStyledString,
135135
found: DiagnosticStyledString,
136-
expected_extra: &fmt::Display,
137-
found_extra: &fmt::Display)
136+
expected_extra: &dyn fmt::Display,
137+
found_extra: &dyn fmt::Display)
138138
-> &mut Self
139139
{
140140
let mut msg: Vec<_> = vec![(format!("expected {} `", label), Style::NoStyle)];

src/librustc_errors/diagnostic_builder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ impl<'a> DiagnosticBuilder<'a> {
148148
}
149149

150150
forward!(pub fn note_expected_found(&mut self,
151-
label: &fmt::Display,
151+
label: &dyn fmt::Display,
152152
expected: DiagnosticStyledString,
153153
found: DiagnosticStyledString)
154154
-> &mut Self);
155155

156156
forward!(pub fn note_expected_found_extra(&mut self,
157-
label: &fmt::Display,
157+
label: &dyn fmt::Display,
158158
expected: DiagnosticStyledString,
159159
found: DiagnosticStyledString,
160-
expected_extra: &fmt::Display,
161-
found_extra: &fmt::Display)
160+
expected_extra: &dyn fmt::Display,
161+
found_extra: &dyn fmt::Display)
162162
-> &mut Self);
163163

164164
forward!(pub fn note(&mut self, msg: &str) -> &mut Self);

src/librustc_errors/emitter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl EmitterWriter {
148148
}
149149
}
150150

151-
pub fn new(dst: Box<Write + Send>,
151+
pub fn new(dst: Box<dyn Write + Send>,
152152
code_map: Option<Lrc<CodeMapperDyn>>,
153153
short_message: bool,
154154
teach: bool)
@@ -1469,13 +1469,13 @@ fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
14691469
pub enum Destination {
14701470
Terminal(StandardStream),
14711471
Buffered(BufferWriter),
1472-
Raw(Box<Write + Send>),
1472+
Raw(Box<dyn Write + Send>),
14731473
}
14741474

14751475
pub enum WritableDst<'a> {
14761476
Terminal(&'a mut StandardStream),
14771477
Buffered(&'a mut BufferWriter, Buffer),
1478-
Raw(&'a mut Box<Write + Send>),
1478+
Raw(&'a mut Box<dyn Write + Send>),
14791479
}
14801480

14811481
impl Destination {

src/librustc_errors/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![deny(bare_trait_objects)]
12+
1113
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1214
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1315
html_root_url = "https://doc.rust-lang.org/nightly/")]
@@ -110,7 +112,7 @@ pub struct SubstitutionPart {
110112
pub snippet: String,
111113
}
112114

113-
pub type CodeMapperDyn = CodeMapper + sync::Send + sync::Sync;
115+
pub type CodeMapperDyn = dyn CodeMapper + sync::Send + sync::Sync;
114116

115117
pub trait CodeMapper {
116118
fn lookup_char_pos(&self, pos: BytePos) -> Loc;
@@ -270,7 +272,7 @@ pub struct Handler {
270272
pub flags: HandlerFlags,
271273

272274
err_count: AtomicUsize,
273-
emitter: Lock<Box<Emitter + sync::Send>>,
275+
emitter: Lock<Box<dyn Emitter + sync::Send>>,
274276
continue_after_error: LockCell<bool>,
275277
delayed_span_bug: Lock<Option<Diagnostic>>,
276278

@@ -326,7 +328,7 @@ impl Handler {
326328

327329
pub fn with_emitter(can_emit_warnings: bool,
328330
treat_err_as_bug: bool,
329-
e: Box<Emitter + sync::Send>)
331+
e: Box<dyn Emitter + sync::Send>)
330332
-> Handler {
331333
Handler::with_emitter_and_flags(
332334
e,
@@ -337,7 +339,8 @@ impl Handler {
337339
})
338340
}
339341

340-
pub fn with_emitter_and_flags(e: Box<Emitter + sync::Send>, flags: HandlerFlags) -> Handler {
342+
pub fn with_emitter_and_flags(e: Box<dyn Emitter + sync::Send>, flags: HandlerFlags) -> Handler
343+
{
341344
Handler {
342345
flags,
343346
err_count: AtomicUsize::new(0),

src/librustc_errors/lock.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::any::Any;
2323

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

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

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

0 commit comments

Comments
 (0)