Skip to content

Commit f19f454

Browse files
committed
Update run-pass test suite to use dyn
1 parent eb4580a commit f19f454

File tree

208 files changed

+502
-502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+502
-502
lines changed

src/test/run-pass/alignment-gep-tup-like-1.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> {
2222
}
2323
}
2424

25-
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+'static> {
25+
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> {
2626
box Invoker {
2727
a: a,
2828
b: b,
29-
} as (Box<Invokable<A>+'static>)
29+
} as (Box<dyn Invokable<A>+'static>)
3030
}
3131

3232
pub fn main() {

src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-pass
22
#![feature(box_syntax)]
33

4-
fn pairwise_sub(mut t: Box<DoubleEndedIterator<Item=isize>>) -> isize {
4+
fn pairwise_sub(mut t: Box<dyn DoubleEndedIterator<Item=isize>>) -> isize {
55
let mut result = 0;
66
loop {
77
let front = t.next();

src/test/run-pass/associated-types/associated-types-eq-obj.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl Foo for char {
1515
fn boo(&self) -> Bar { Bar }
1616
}
1717

18-
fn baz(x: &Foo<A=Bar>) -> Bar {
18+
fn baz(x: &dyn Foo<A=Bar>) -> Bar {
1919
x.boo()
2020
}
2121

src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ pub trait Subscriber {
1919

2020
pub trait Publisher<'a> {
2121
type Output;
22-
fn subscribe(&mut self, _: Box<Subscriber<Input=Self::Output> + 'a>);
22+
fn subscribe(&mut self, _: Box<dyn Subscriber<Input=Self::Output> + 'a>);
2323
}
2424

2525
pub trait Processor<'a> : Subscriber + Publisher<'a> { }
2626

2727
impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { }
2828

2929
struct MyStruct<'a> {
30-
sub: Box<Subscriber<Input=u64> + 'a>
30+
sub: Box<dyn Subscriber<Input=u64> + 'a>
3131
}
3232

3333
impl<'a> Publisher<'a> for MyStruct<'a> {
3434
type Output = u64;
35-
fn subscribe(&mut self, t : Box<Subscriber<Input=u64> + 'a>) {
35+
fn subscribe(&mut self, t : Box<dyn Subscriber<Input=u64> + 'a>) {
3636
self.sub = t;
3737
}
3838
}

src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ impl double for usize {
1111
}
1212

1313
pub fn main() {
14-
let x: Box<_> = box (box 3usize as Box<double>);
14+
let x: Box<_> = box (box 3usize as Box<dyn double>);
1515
assert_eq!(x.double(), 6);
1616
}

src/test/run-pass/borrowck/borrowck-trait-lifetime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::marker;
1212
fn main() {
1313
trait T { fn foo(&self) {} }
1414

15-
fn f<'a, V: T>(v: &'a V) -> &'a T {
16-
v as &'a T
15+
fn f<'a, V: T>(v: &'a V) -> &'a dyn T {
16+
v as &'a dyn T
1717
}
1818
}

src/test/run-pass/cast-rfc0401-vtable-kinds.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ impl<T> Foo<T> for () {}
1515
impl Foo<u32> for u32 { fn foo(&self, _: u32) -> u32 { self+43 } }
1616
impl Bar for () {}
1717

18-
unsafe fn round_trip_and_call<'a>(t: *const (Foo<u32>+'a)) -> u32 {
19-
let foo_e : *const Foo<u16> = t as *const _;
20-
let r_1 = foo_e as *mut Foo<u32>;
18+
unsafe fn round_trip_and_call<'a>(t: *const (dyn Foo<u32>+'a)) -> u32 {
19+
let foo_e : *const dyn Foo<u16> = t as *const _;
20+
let r_1 = foo_e as *mut dyn Foo<u32>;
2121

2222
(&*r_1).foo(0)
2323
}
@@ -38,8 +38,8 @@ fn tuple_i32_to_u32<T:?Sized>(u: *const (i32, T)) -> *const (u32, T) {
3838

3939
fn main() {
4040
let x = 4u32;
41-
let y : &Foo<u32> = &x;
42-
let fl = unsafe { round_trip_and_call(y as *const Foo<u32>) };
41+
let y : &dyn Foo<u32> = &x;
42+
let fl = unsafe { round_trip_and_call(y as *const dyn Foo<u32>) };
4343
assert_eq!(fl, (43+4));
4444

4545
let s = FooS([0,1,2]);

src/test/run-pass/cast-rfc0401.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ fn main()
2525
// coercion-cast
2626
let mut it = vec![137].into_iter();
2727
let itr: &mut vec::IntoIter<u32> = &mut it;
28-
assert_eq!((itr as &mut Iterator<Item=u32>).next(), Some(137));
29-
assert_eq!((itr as &mut Iterator<Item=u32>).next(), None);
28+
assert_eq!((itr as &mut dyn Iterator<Item=u32>).next(), Some(137));
29+
assert_eq!((itr as &mut dyn Iterator<Item=u32>).next(), None);
3030

3131
assert_eq!(Some(4u32) as Option<u32>, Some(4u32));
3232
assert_eq!((1u32,2u32) as (u32,u32), (1,2));

src/test/run-pass/close-over-big-then-small-data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> {
2424
}
2525
}
2626

27-
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+'static> {
27+
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> {
2828
box Invoker {
2929
a: a,
3030
b: b,
31-
} as (Box<Invokable<A>+'static>)
31+
} as (Box<dyn Invokable<A>+'static>)
3232
}
3333

3434
pub fn main() {
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
fn main() {
2-
assert_eq!((ToString::to_string as fn(&(ToString+'static)) -> String)(&"foo"),
2+
assert_eq!((ToString::to_string as fn(&(dyn ToString+'static)) -> String)(&"foo"),
33
String::from("foo"));
44
}

src/test/run-pass/coerce/coerce-expect-unsized.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ pub fn main() {
1212
let _: Box<[isize]> = Box::new({ [1, 2, 3] });
1313
let _: Box<[isize]> = Box::new(if true { [1, 2, 3] } else { [1, 3, 4] });
1414
let _: Box<[isize]> = Box::new(match true { true => [1, 2, 3], false => [1, 3, 4] });
15-
let _: Box<Fn(isize) -> _> = Box::new({ |x| (x as u8) });
16-
let _: Box<Debug> = Box::new(if true { false } else { true });
17-
let _: Box<Debug> = Box::new(match true { true => 'a', false => 'b' });
15+
let _: Box<dyn Fn(isize) -> _> = Box::new({ |x| (x as u8) });
16+
let _: Box<dyn Debug> = Box::new(if true { false } else { true });
17+
let _: Box<dyn Debug> = Box::new(match true { true => 'a', false => 'b' });
1818

1919
let _: &[isize] = &{ [1, 2, 3] };
2020
let _: &[isize] = &if true { [1, 2, 3] } else { [1, 3, 4] };
2121
let _: &[isize] = &match true { true => [1, 2, 3], false => [1, 3, 4] };
22-
let _: &Fn(isize) -> _ = &{ |x| (x as u8) };
23-
let _: &Debug = &if true { false } else { true };
24-
let _: &Debug = &match true { true => 'a', false => 'b' };
22+
let _: &dyn Fn(isize) -> _ = &{ |x| (x as u8) };
23+
let _: &dyn Debug = &if true { false } else { true };
24+
let _: &dyn Debug = &match true { true => 'a', false => 'b' };
2525

2626
let _: &str = &{ String::new() };
2727
let _: &str = &if true { String::from("...") } else { 5.to_string() };
@@ -31,12 +31,12 @@ pub fn main() {
3131
};
3232

3333
let _: Box<[isize]> = Box::new([1, 2, 3]);
34-
let _: Box<Fn(isize) -> _> = Box::new(|x| (x as u8));
34+
let _: Box<dyn Fn(isize) -> _> = Box::new(|x| (x as u8));
3535

3636
let _: Rc<RefCell<[isize]>> = Rc::new(RefCell::new([1, 2, 3]));
37-
let _: Rc<RefCell<FnMut(isize) -> _>> = Rc::new(RefCell::new(|x| (x as u8)));
37+
let _: Rc<RefCell<dyn FnMut(isize) -> _>> = Rc::new(RefCell::new(|x| (x as u8)));
3838

39-
let _: Vec<Box<Fn(isize) -> _>> = vec![
39+
let _: Vec<Box<dyn Fn(isize) -> _>> = vec![
4040
Box::new(|x| (x as u8)),
4141
Box::new(|x| (x as i16 as u8)),
4242
];

src/test/run-pass/consts/const-trait-to-trait.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ struct Bar;
88
impl Trait for Bar {}
99

1010
fn main() {
11-
let x: &[&Trait] = &[{ &Bar }];
11+
let x: &[&dyn Trait] = &[{ &Bar }];
1212
}
1313

1414
// Issue #25748 - the cast causes an &Encoding -> &Encoding coercion:
1515
pub struct UTF8Encoding;
1616
pub const UTF_8: &'static UTF8Encoding = &UTF8Encoding;
1717
pub trait Encoding {}
1818
impl Encoding for UTF8Encoding {}
19-
pub fn f() -> &'static Encoding { UTF_8 as &'static Encoding }
19+
pub fn f() -> &'static dyn Encoding { UTF_8 as &'static dyn Encoding }
2020

2121
// Root of the problem: &Trait -> &Trait coercions:
22-
const FOO: &'static Trait = &Bar;
23-
const BAR: &'static Trait = FOO;
22+
const FOO: &'static dyn Trait = &Bar;
23+
const BAR: &'static dyn Trait = FOO;
2424
fn foo() { let _x = BAR; }

src/test/run-pass/deriving/deriving-show.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ enum Enum {
1717
}
1818

1919
#[derive(Debug)]
20-
struct Pointers(*const Send, *mut Sync);
20+
struct Pointers(*const dyn Send, *mut dyn Sync);
2121

2222
macro_rules! t {
2323
($x:expr, $expected:expr) => {

src/test/run-pass/drop/drop-struct-as-object.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Drop for Cat {
3030
pub fn main() {
3131
{
3232
let x = box Cat {name: 22};
33-
let nyan: Box<Dummy> = x as Box<Dummy>;
33+
let nyan: Box<dyn Dummy> = x as Box<dyn Dummy>;
3434
}
3535
unsafe {
3636
assert_eq!(value, 22);

src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636

3737
// Trait objects.
3838
let a: Bar<i32> = Bar { x: &42 };
39-
let b: Bar<Baz> = a;
39+
let b: Bar<dyn Baz> = a;
4040
unsafe {
4141
assert_eq!((*b.x).get(), 42);
4242
}

src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ fn main() {
2626
assert_eq!(b[2], 3);
2727

2828
let a: Rc<i32> = Rc::new(42);
29-
let b: Rc<Baz> = a.clone();
29+
let b: Rc<dyn Baz> = a.clone();
3030
assert_eq!(b.get(), 42);
3131

3232
let c: Weak<i32> = Rc::downgrade(&a);
33-
let d: Weak<Baz> = c.clone();
33+
let d: Weak<dyn Baz> = c.clone();
3434

3535
let _c = b.clone();
3636

3737
let a: Rc<RefCell<i32>> = Rc::new(RefCell::new(42));
38-
let b: Rc<RefCell<Baz>> = a.clone();
38+
let b: Rc<RefCell<dyn Baz>> = a.clone();
3939
assert_eq!(b.borrow().get(), 42);
4040
// FIXME
41-
let c: Weak<RefCell<Baz>> = Rc::downgrade(&a) as Weak<_>;
41+
let c: Weak<RefCell<dyn Baz>> = Rc::downgrade(&a) as Weak<_>;
4242
}

src/test/run-pass/dynamically-sized-types/dst-coercions.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ trait T { fn dummy(&self) { } }
99
impl T for S {}
1010

1111
pub fn main() {
12-
let x: &T = &S;
12+
let x: &dyn T = &S;
1313
// Test we can convert from &-ptr to *-ptr of trait objects
14-
let x: *const T = &S;
14+
let x: *const dyn T = &S;
1515

1616
// Test we can convert from &-ptr to *-ptr of struct pointer (not DST)
1717
let x: *const S = &S;
1818

1919
// As above, but mut
20-
let x: &mut T = &mut S;
21-
let x: *mut T = &mut S;
20+
let x: &mut dyn T = &mut S;
21+
let x: *mut dyn T = &mut S;
2222

2323
let x: *mut S = &mut S;
2424

2525
// Test we can change the mutability from mut to const.
26-
let x: &T = &mut S;
27-
let x: *const T = &mut S;
26+
let x: &dyn T = &mut S;
27+
let x: *const dyn T = &mut S;
2828
}

src/test/run-pass/dynamically-sized-types/dst-field-align.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ fn main() {
2626
// Test that zero-offset works properly
2727
let b : Baz<usize> = Baz { a: 7 };
2828
assert_eq!(b.a.get(), 7);
29-
let b : &Baz<Bar> = &b;
29+
let b : &Baz<dyn Bar> = &b;
3030
assert_eq!(b.a.get(), 7);
3131

3232
// Test that the field is aligned properly
3333
let f : Foo<usize> = Foo { a: 0, b: 11 };
3434
assert_eq!(f.b.get(), 11);
3535
let ptr1 : *const u8 = &f.b as *const _ as *const u8;
3636

37-
let f : &Foo<Bar> = &f;
37+
let f : &Foo<dyn Bar> = &f;
3838
let ptr2 : *const u8 = &f.b as *const _ as *const u8;
3939
assert_eq!(f.b.get(), 11);
4040

@@ -44,13 +44,13 @@ fn main() {
4444
// Test that nested DSTs work properly
4545
let f : Foo<Foo<usize>> = Foo { a: 0, b: Foo { a: 1, b: 17 }};
4646
assert_eq!(f.b.b.get(), 17);
47-
let f : &Foo<Foo<Bar>> = &f;
47+
let f : &Foo<Foo<dyn Bar>> = &f;
4848
assert_eq!(f.b.b.get(), 17);
4949

5050
// Test that get the pointer via destructuring works
5151

5252
let f : Foo<usize> = Foo { a: 0, b: 11 };
53-
let f : &Foo<Bar> = &f;
53+
let f : &Foo<dyn Bar> = &f;
5454
let &Foo { a: _, b: ref bar } = f;
5555
assert_eq!(bar.get(), 11);
5656

src/test/run-pass/dynamically-sized-types/dst-index.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ impl Index<usize> for S {
1919
struct T;
2020

2121
impl Index<usize> for T {
22-
type Output = Debug + 'static;
22+
type Output = dyn Debug + 'static;
2323

24-
fn index<'a>(&'a self, idx: usize) -> &'a (Debug + 'static) {
24+
fn index<'a>(&'a self, idx: usize) -> &'a (dyn Debug + 'static) {
2525
static X: usize = 42;
26-
&X as &(Debug + 'static)
26+
&X as &(dyn Debug + 'static)
2727
}
2828
}
2929

src/test/run-pass/dynamically-sized-types/dst-raw.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ struct Foo<T: ?Sized> {
2424
pub fn main() {
2525
// raw trait object
2626
let x = A { f: 42 };
27-
let z: *const Trait = &x;
27+
let z: *const dyn Trait = &x;
2828
let r = unsafe {
2929
(&*z).foo()
3030
};
3131
assert_eq!(r, 42);
3232

3333
// raw DST struct
3434
let p = Foo {f: A { f: 42 }};
35-
let o: *const Foo<Trait> = &p;
35+
let o: *const Foo<dyn Trait> = &p;
3636
let r = unsafe {
3737
(&*o).f.foo()
3838
};
3939
assert_eq!(r, 42);
4040

4141
// raw DST tuple
4242
let p = (A { f: 42 },);
43-
let o: *const (Trait,) = &p;
43+
let o: *const (dyn Trait,) = &p;
4444
let r = unsafe {
4545
(&*o).0.foo()
4646
};
@@ -84,21 +84,21 @@ pub fn main() {
8484

8585
// all of the above with *mut
8686
let mut x = A { f: 42 };
87-
let z: *mut Trait = &mut x;
87+
let z: *mut dyn Trait = &mut x;
8888
let r = unsafe {
8989
(&*z).foo()
9090
};
9191
assert_eq!(r, 42);
9292

9393
let mut p = Foo {f: A { f: 42 }};
94-
let o: *mut Foo<Trait> = &mut p;
94+
let o: *mut Foo<dyn Trait> = &mut p;
9595
let r = unsafe {
9696
(&*o).f.foo()
9797
};
9898
assert_eq!(r, 42);
9999

100100
let mut p = (A { f: 42 },);
101-
let o: *mut (Trait,) = &mut p;
101+
let o: *mut (dyn Trait,) = &mut p;
102102
let r = unsafe {
103103
(&*o).0.foo()
104104
};

0 commit comments

Comments
 (0)