Skip to content

Commit 66c4dc9

Browse files
committed
Add missing dyn
1 parent 8646a17 commit 66c4dc9

File tree

23 files changed

+69
-65
lines changed

23 files changed

+69
-65
lines changed

src/liballoc/tests/arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn uninhabited() {
1818
a = a.clone();
1919
assert!(a.upgrade().is_none());
2020

21-
let mut a: Weak<Any> = a; // Unsizing
21+
let mut a: Weak<dyn Any> = a; // Unsizing
2222
a = a.clone();
2323
assert!(a.upgrade().is_none());
2424
}
@@ -39,7 +39,7 @@ fn slice() {
3939
#[test]
4040
fn trait_object() {
4141
let a: Arc<u32> = Arc::new(4);
42-
let a: Arc<Any> = a; // Unsizing
42+
let a: Arc<dyn Any> = a; // Unsizing
4343

4444
// Exercise is_dangling() with a DST
4545
let mut a = Arc::downgrade(&a);
@@ -49,7 +49,7 @@ fn trait_object() {
4949
let mut b = Weak::<u32>::new();
5050
b = b.clone();
5151
assert!(b.upgrade().is_none());
52-
let mut b: Weak<Any> = b; // Unsizing
52+
let mut b: Weak<dyn Any> = b; // Unsizing
5353
b = b.clone();
5454
assert!(b.upgrade().is_none());
5555
}

src/liballoc/tests/btree/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn test_hash() {
4040
}
4141

4242
fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
43-
where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool
43+
where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut dyn FnMut(&i32) -> bool) -> bool
4444
{
4545
let mut set_a = BTreeSet::new();
4646
let mut set_b = BTreeSet::new();

src/liballoc/tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn test_boxed_hasher() {
6363
5u32.hash(&mut hasher_1);
6464
assert_eq!(ordinary_hash, hasher_1.finish());
6565

66-
let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<Hasher>;
66+
let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<dyn Hasher>;
6767
5u32.hash(&mut hasher_2);
6868
assert_eq!(ordinary_hash, hasher_2.finish());
6969
}

src/liballoc/tests/rc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn uninhabited() {
1818
a = a.clone();
1919
assert!(a.upgrade().is_none());
2020

21-
let mut a: Weak<Any> = a; // Unsizing
21+
let mut a: Weak<dyn Any> = a; // Unsizing
2222
a = a.clone();
2323
assert!(a.upgrade().is_none());
2424
}
@@ -39,7 +39,7 @@ fn slice() {
3939
#[test]
4040
fn trait_object() {
4141
let a: Rc<u32> = Rc::new(4);
42-
let a: Rc<Any> = a; // Unsizing
42+
let a: Rc<dyn Any> = a; // Unsizing
4343

4444
// Exercise is_dangling() with a DST
4545
let mut a = Rc::downgrade(&a);
@@ -49,7 +49,7 @@ fn trait_object() {
4949
let mut b = Weak::<u32>::new();
5050
b = b.clone();
5151
assert!(b.upgrade().is_none());
52-
let mut b: Weak<Any> = b; // Unsizing
52+
let mut b: Weak<dyn Any> = b; // Unsizing
5353
b = b.clone();
5454
assert!(b.upgrade().is_none());
5555
}

src/libcore/tests/any.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static TEST: &'static str = "Test";
1717

1818
#[test]
1919
fn any_referenced() {
20-
let (a, b, c) = (&5 as &Any, &TEST as &Any, &Test as &Any);
20+
let (a, b, c) = (&5 as &dyn Any, &TEST as &dyn Any, &Test as &dyn Any);
2121

2222
assert!(a.is::<i32>());
2323
assert!(!b.is::<i32>());
@@ -34,7 +34,11 @@ fn any_referenced() {
3434

3535
#[test]
3636
fn any_owning() {
37-
let (a, b, c) = (box 5_usize as Box<Any>, box TEST as Box<Any>, box Test as Box<Any>);
37+
let (a, b, c) = (
38+
box 5_usize as Box<dyn Any>,
39+
box TEST as Box<dyn Any>,
40+
box Test as Box<dyn Any>,
41+
);
3842

3943
assert!(a.is::<usize>());
4044
assert!(!b.is::<usize>());
@@ -51,7 +55,7 @@ fn any_owning() {
5155

5256
#[test]
5357
fn any_downcast_ref() {
54-
let a = &5_usize as &Any;
58+
let a = &5_usize as &dyn Any;
5559

5660
match a.downcast_ref::<usize>() {
5761
Some(&5) => {}
@@ -69,9 +73,9 @@ fn any_downcast_mut() {
6973
let mut a = 5_usize;
7074
let mut b: Box<_> = box 7_usize;
7175

72-
let a_r = &mut a as &mut Any;
76+
let a_r = &mut a as &mut dyn Any;
7377
let tmp: &mut usize = &mut *b;
74-
let b_r = tmp as &mut Any;
78+
let b_r = tmp as &mut dyn Any;
7579

7680
match a_r.downcast_mut::<usize>() {
7781
Some(x) => {
@@ -113,7 +117,7 @@ fn any_downcast_mut() {
113117
#[test]
114118
fn any_fixed_vec() {
115119
let test = [0_usize; 8];
116-
let test = &test as &Any;
120+
let test = &test as &dyn Any;
117121
assert!(test.is::<[usize; 8]>());
118122
assert!(!test.is::<[usize; 10]>());
119123
}

src/libcore/tests/hash/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn test_custom_state() {
128128
fn test_indirect_hasher() {
129129
let mut hasher = MyHasher { hash: 0 };
130130
{
131-
let mut indirect_hasher: &mut Hasher = &mut hasher;
131+
let mut indirect_hasher: &mut dyn Hasher = &mut hasher;
132132
5u32.hash(&mut indirect_hasher);
133133
}
134134
assert_eq!(hasher.hash, 5);

src/libcore/tests/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn test_typeid_sized_types() {
2222
#[test]
2323
fn test_typeid_unsized_types() {
2424
trait Z {}
25-
struct X(str); struct Y(Z + 'static);
25+
struct X(str); struct Y(dyn Z + 'static);
2626

2727
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
2828
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());

src/libcore/tests/mem.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ fn test_transmute() {
109109
trait Foo { fn dummy(&self) { } }
110110
impl Foo for isize {}
111111

112-
let a = box 100isize as Box<Foo>;
112+
let a = box 100isize as Box<dyn Foo>;
113113
unsafe {
114114
let x: ::core::raw::TraitObject = transmute(a);
115115
assert!(*(x.data as *const isize) == 100);
116-
let _x: Box<Foo> = transmute(x);
116+
let _x: Box<dyn Foo> = transmute(x);
117117
}
118118

119119
unsafe {

src/libcore/tests/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ fn test_collect() {
240240
assert!(v == None);
241241

242242
// test that it does not take more elements than it needs
243-
let mut functions: [Box<Fn() -> Option<()>>; 3] =
243+
let mut functions: [Box<dyn Fn() -> Option<()>>; 3] =
244244
[box || Some(()), box || None, box || panic!()];
245245

246246
let v: Option<Vec<()>> = functions.iter_mut().map(|f| (*f)()).collect();

src/libcore/tests/ptr.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ fn test_is_null() {
8484
assert!(nms.is_null());
8585

8686
// Pointers to unsized types -- trait objects
87-
let ci: *const ToString = &3;
87+
let ci: *const dyn ToString = &3;
8888
assert!(!ci.is_null());
8989

90-
let mi: *mut ToString = &mut 3;
90+
let mi: *mut dyn ToString = &mut 3;
9191
assert!(!mi.is_null());
9292

93-
let nci: *const ToString = null::<isize>();
93+
let nci: *const dyn ToString = null::<isize>();
9494
assert!(nci.is_null());
9595

96-
let nmi: *mut ToString = null_mut::<isize>();
96+
let nmi: *mut dyn ToString = null_mut::<isize>();
9797
assert!(nmi.is_null());
9898
}
9999

@@ -140,16 +140,16 @@ fn test_as_ref() {
140140
assert_eq!(nms.as_ref(), None);
141141

142142
// Pointers to unsized types -- trait objects
143-
let ci: *const ToString = &3;
143+
let ci: *const dyn ToString = &3;
144144
assert!(ci.as_ref().is_some());
145145

146-
let mi: *mut ToString = &mut 3;
146+
let mi: *mut dyn ToString = &mut 3;
147147
assert!(mi.as_ref().is_some());
148148

149-
let nci: *const ToString = null::<isize>();
149+
let nci: *const dyn ToString = null::<isize>();
150150
assert!(nci.as_ref().is_none());
151151

152-
let nmi: *mut ToString = null_mut::<isize>();
152+
let nmi: *mut dyn ToString = null_mut::<isize>();
153153
assert!(nmi.as_ref().is_none());
154154
}
155155
}
@@ -182,10 +182,10 @@ fn test_as_mut() {
182182
assert_eq!(nms.as_mut(), None);
183183

184184
// Pointers to unsized types -- trait objects
185-
let mi: *mut ToString = &mut 3;
185+
let mi: *mut dyn ToString = &mut 3;
186186
assert!(mi.as_mut().is_some());
187187

188-
let nmi: *mut ToString = null_mut::<isize>();
188+
let nmi: *mut dyn ToString = null_mut::<isize>();
189189
assert!(nmi.as_mut().is_none());
190190
}
191191
}

src/libcore/tests/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn test_collect() {
8181
assert!(v == Err(2));
8282

8383
// test that it does not take more elements than it needs
84-
let mut functions: [Box<Fn() -> Result<(), isize>>; 3] =
84+
let mut functions: [Box<dyn Fn() -> Result<(), isize>>; 3] =
8585
[box || Ok(()), box || Err(1), box || panic!()];
8686

8787
let v: Result<Vec<()>, isize> = functions.iter_mut().map(|f| (*f)()).collect();

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ impl fmt::Debug for Item {
375375

376376
let fake = MAX_DEF_ID.with(|m| m.borrow().get(&self.def_id.krate)
377377
.map(|id| self.def_id >= *id).unwrap_or(false));
378-
let def_id: &fmt::Debug = if fake { &"**FAKE**" } else { &self.def_id };
378+
let def_id: &dyn fmt::Debug = if fake { &"**FAKE**" } else { &self.def_id };
379379

380380
fmt.debug_struct("Item")
381381
.field("source", &self.source)

src/librustdoc/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a> {
5555
/// The stack of module NodeIds up till this point
5656
pub mod_ids: RefCell<Vec<NodeId>>,
5757
pub crate_name: Option<String>,
58-
pub cstore: Rc<CrateStore>,
58+
pub cstore: Rc<dyn CrateStore>,
5959
pub populated_all_crate_impls: Cell<bool>,
6060
// Note that external items for which `doc(hidden)` applies to are shown as
6161
// non-reachable while local items aren't. This is because we're reusing

src/librustdoc/html/highlight.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl Class {
395395

396396
fn write_header(class: Option<&str>,
397397
id: Option<&str>,
398-
out: &mut Write)
398+
out: &mut dyn Write)
399399
-> io::Result<()> {
400400
write!(out, "<pre ")?;
401401
if let Some(id) = id {
@@ -404,6 +404,6 @@ fn write_header(class: Option<&str>,
404404
write!(out, "class=\"rust {}\">\n", class.unwrap_or(""))
405405
}
406406

407-
fn write_footer(out: &mut Write) -> io::Result<()> {
407+
fn write_footer(out: &mut dyn Write) -> io::Result<()> {
408408
write!(out, "</pre>\n")
409409
}

src/librustdoc/html/layout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct Page<'a> {
3232
}
3333

3434
pub fn render<T: fmt::Display, S: fmt::Display>(
35-
dst: &mut io::Write, layout: &Layout, page: &Page, sidebar: &S, t: &T,
35+
dst: &mut dyn io::Write, layout: &Layout, page: &Page, sidebar: &S, t: &T,
3636
css_file_extension: bool, themes: &[PathBuf])
3737
-> io::Result<()>
3838
{
@@ -194,7 +194,7 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
194194
)
195195
}
196196

197-
pub fn redirect(dst: &mut io::Write, url: &str) -> io::Result<()> {
197+
pub fn redirect(dst: &mut dyn io::Write, url: &str) -> io::Result<()> {
198198
// <script> triggers a redirect before refresh, so this is fine.
199199
write!(dst,
200200
r##"<!DOCTYPE html>

src/librustdoc/html/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ impl Context {
18221822
}
18231823

18241824
fn render_item(&self,
1825-
writer: &mut io::Write,
1825+
writer: &mut dyn io::Write,
18261826
it: &clean::Item,
18271827
pushname: bool)
18281828
-> io::Result<()> {

src/librustdoc/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
249249
}
250250
fn flush(&mut self) -> io::Result<()> { Ok(()) }
251251
}
252-
struct Bomb(Arc<Mutex<Vec<u8>>>, Box<Write+Send>);
252+
struct Bomb(Arc<Mutex<Vec<u8>>>, Box<dyn Write+Send>);
253253
impl Drop for Bomb {
254254
fn drop(&mut self) {
255255
let _ = self.1.write_all(&self.0.lock().unwrap());

src/libstd/sys/redox/process.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct Command {
5151
uid: Option<u32>,
5252
gid: Option<u32>,
5353
saw_nul: bool,
54-
closures: Vec<Box<FnMut() -> io::Result<()> + Send + Sync>>,
54+
closures: Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>>,
5555
stdin: Option<Stdio>,
5656
stdout: Option<Stdio>,
5757
stderr: Option<Stdio>,
@@ -122,7 +122,7 @@ impl Command {
122122
}
123123

124124
pub fn before_exec(&mut self,
125-
f: Box<FnMut() -> io::Result<()> + Send + Sync>) {
125+
f: Box<dyn FnMut() -> io::Result<()> + Send + Sync>) {
126126
self.closures.push(f);
127127
}
128128

src/tools/compiletest/src/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl TestProps {
416416
}
417417
}
418418

419-
fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut FnMut(&str)) {
419+
fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) {
420420
if testfile.is_dir() {
421421
return;
422422
}

src/tools/compiletest/src/read2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod imp {
2121
pub fn read2(
2222
out_pipe: ChildStdout,
2323
err_pipe: ChildStderr,
24-
data: &mut FnMut(bool, &mut Vec<u8>, bool),
24+
data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
2525
) -> io::Result<()> {
2626
let mut buffer = Vec::new();
2727
out_pipe.read_to_end(&mut buffer)?;
@@ -45,7 +45,7 @@ mod imp {
4545
pub fn read2(
4646
mut out_pipe: ChildStdout,
4747
mut err_pipe: ChildStderr,
48-
data: &mut FnMut(bool, &mut Vec<u8>, bool),
48+
data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
4949
) -> io::Result<()> {
5050
unsafe {
5151
libc::fcntl(out_pipe.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK);
@@ -133,7 +133,7 @@ mod imp {
133133
pub fn read2(
134134
out_pipe: ChildStdout,
135135
err_pipe: ChildStderr,
136-
data: &mut FnMut(bool, &mut Vec<u8>, bool),
136+
data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
137137
) -> io::Result<()> {
138138
let mut out = Vec::new();
139139
let mut err = Vec::new();

0 commit comments

Comments
 (0)