1
Fork 0

Update run-pass test suite to use dyn

This commit is contained in:
memoryruins 2019-05-28 14:47:21 -04:00
parent eb4580a570
commit f19f4545b1
208 changed files with 502 additions and 502 deletions

View file

@ -22,11 +22,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> {
}
}
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+'static> {
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> {
box Invoker {
a: a,
b: b,
} as (Box<Invokable<A>+'static>)
} as (Box<dyn Invokable<A>+'static>)
}
pub fn main() {

View file

@ -1,7 +1,7 @@
// run-pass
#![feature(box_syntax)]
fn pairwise_sub(mut t: Box<DoubleEndedIterator<Item=isize>>) -> isize {
fn pairwise_sub(mut t: Box<dyn DoubleEndedIterator<Item=isize>>) -> isize {
let mut result = 0;
loop {
let front = t.next();

View file

@ -15,7 +15,7 @@ impl Foo for char {
fn boo(&self) -> Bar { Bar }
}
fn baz(x: &Foo<A=Bar>) -> Bar {
fn baz(x: &dyn Foo<A=Bar>) -> Bar {
x.boo()
}

View file

@ -19,7 +19,7 @@ pub trait Subscriber {
pub trait Publisher<'a> {
type Output;
fn subscribe(&mut self, _: Box<Subscriber<Input=Self::Output> + 'a>);
fn subscribe(&mut self, _: Box<dyn Subscriber<Input=Self::Output> + 'a>);
}
pub trait Processor<'a> : Subscriber + Publisher<'a> { }
@ -27,12 +27,12 @@ pub trait Processor<'a> : Subscriber + Publisher<'a> { }
impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { }
struct MyStruct<'a> {
sub: Box<Subscriber<Input=u64> + 'a>
sub: Box<dyn Subscriber<Input=u64> + 'a>
}
impl<'a> Publisher<'a> for MyStruct<'a> {
type Output = u64;
fn subscribe(&mut self, t : Box<Subscriber<Input=u64> + 'a>) {
fn subscribe(&mut self, t : Box<dyn Subscriber<Input=u64> + 'a>) {
self.sub = t;
}
}

View file

@ -11,6 +11,6 @@ impl double for usize {
}
pub fn main() {
let x: Box<_> = box (box 3usize as Box<double>);
let x: Box<_> = box (box 3usize as Box<dyn double>);
assert_eq!(x.double(), 6);
}

View file

@ -12,7 +12,7 @@ use std::marker;
fn main() {
trait T { fn foo(&self) {} }
fn f<'a, V: T>(v: &'a V) -> &'a T {
v as &'a T
fn f<'a, V: T>(v: &'a V) -> &'a dyn T {
v as &'a dyn T
}
}

View file

@ -15,9 +15,9 @@ impl<T> Foo<T> for () {}
impl Foo<u32> for u32 { fn foo(&self, _: u32) -> u32 { self+43 } }
impl Bar for () {}
unsafe fn round_trip_and_call<'a>(t: *const (Foo<u32>+'a)) -> u32 {
let foo_e : *const Foo<u16> = t as *const _;
let r_1 = foo_e as *mut Foo<u32>;
unsafe fn round_trip_and_call<'a>(t: *const (dyn Foo<u32>+'a)) -> u32 {
let foo_e : *const dyn Foo<u16> = t as *const _;
let r_1 = foo_e as *mut dyn Foo<u32>;
(&*r_1).foo(0)
}
@ -38,8 +38,8 @@ fn tuple_i32_to_u32<T:?Sized>(u: *const (i32, T)) -> *const (u32, T) {
fn main() {
let x = 4u32;
let y : &Foo<u32> = &x;
let fl = unsafe { round_trip_and_call(y as *const Foo<u32>) };
let y : &dyn Foo<u32> = &x;
let fl = unsafe { round_trip_and_call(y as *const dyn Foo<u32>) };
assert_eq!(fl, (43+4));
let s = FooS([0,1,2]);

View file

@ -25,8 +25,8 @@ fn main()
// coercion-cast
let mut it = vec![137].into_iter();
let itr: &mut vec::IntoIter<u32> = &mut it;
assert_eq!((itr as &mut Iterator<Item=u32>).next(), Some(137));
assert_eq!((itr as &mut Iterator<Item=u32>).next(), None);
assert_eq!((itr as &mut dyn Iterator<Item=u32>).next(), Some(137));
assert_eq!((itr as &mut dyn Iterator<Item=u32>).next(), None);
assert_eq!(Some(4u32) as Option<u32>, Some(4u32));
assert_eq!((1u32,2u32) as (u32,u32), (1,2));

View file

@ -24,11 +24,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> {
}
}
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+'static> {
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> {
box Invoker {
a: a,
b: b,
} as (Box<Invokable<A>+'static>)
} as (Box<dyn Invokable<A>+'static>)
}
pub fn main() {

View file

@ -1,4 +1,4 @@
fn main() {
assert_eq!((ToString::to_string as fn(&(ToString+'static)) -> String)(&"foo"),
assert_eq!((ToString::to_string as fn(&(dyn ToString+'static)) -> String)(&"foo"),
String::from("foo"));
}

View file

@ -12,16 +12,16 @@ pub fn main() {
let _: Box<[isize]> = Box::new({ [1, 2, 3] });
let _: Box<[isize]> = Box::new(if true { [1, 2, 3] } else { [1, 3, 4] });
let _: Box<[isize]> = Box::new(match true { true => [1, 2, 3], false => [1, 3, 4] });
let _: Box<Fn(isize) -> _> = Box::new({ |x| (x as u8) });
let _: Box<Debug> = Box::new(if true { false } else { true });
let _: Box<Debug> = Box::new(match true { true => 'a', false => 'b' });
let _: Box<dyn Fn(isize) -> _> = Box::new({ |x| (x as u8) });
let _: Box<dyn Debug> = Box::new(if true { false } else { true });
let _: Box<dyn Debug> = Box::new(match true { true => 'a', false => 'b' });
let _: &[isize] = &{ [1, 2, 3] };
let _: &[isize] = &if true { [1, 2, 3] } else { [1, 3, 4] };
let _: &[isize] = &match true { true => [1, 2, 3], false => [1, 3, 4] };
let _: &Fn(isize) -> _ = &{ |x| (x as u8) };
let _: &Debug = &if true { false } else { true };
let _: &Debug = &match true { true => 'a', false => 'b' };
let _: &dyn Fn(isize) -> _ = &{ |x| (x as u8) };
let _: &dyn Debug = &if true { false } else { true };
let _: &dyn Debug = &match true { true => 'a', false => 'b' };
let _: &str = &{ String::new() };
let _: &str = &if true { String::from("...") } else { 5.to_string() };
@ -31,12 +31,12 @@ pub fn main() {
};
let _: Box<[isize]> = Box::new([1, 2, 3]);
let _: Box<Fn(isize) -> _> = Box::new(|x| (x as u8));
let _: Box<dyn Fn(isize) -> _> = Box::new(|x| (x as u8));
let _: Rc<RefCell<[isize]>> = Rc::new(RefCell::new([1, 2, 3]));
let _: Rc<RefCell<FnMut(isize) -> _>> = Rc::new(RefCell::new(|x| (x as u8)));
let _: Rc<RefCell<dyn FnMut(isize) -> _>> = Rc::new(RefCell::new(|x| (x as u8)));
let _: Vec<Box<Fn(isize) -> _>> = vec![
let _: Vec<Box<dyn Fn(isize) -> _>> = vec![
Box::new(|x| (x as u8)),
Box::new(|x| (x as i16 as u8)),
];

View file

@ -8,7 +8,7 @@ struct Bar;
impl Trait for Bar {}
fn main() {
let x: &[&Trait] = &[{ &Bar }];
let x: &[&dyn Trait] = &[{ &Bar }];
}
// Issue #25748 - the cast causes an &Encoding -> &Encoding coercion:
@ -16,9 +16,9 @@ pub struct UTF8Encoding;
pub const UTF_8: &'static UTF8Encoding = &UTF8Encoding;
pub trait Encoding {}
impl Encoding for UTF8Encoding {}
pub fn f() -> &'static Encoding { UTF_8 as &'static Encoding }
pub fn f() -> &'static dyn Encoding { UTF_8 as &'static dyn Encoding }
// Root of the problem: &Trait -> &Trait coercions:
const FOO: &'static Trait = &Bar;
const BAR: &'static Trait = FOO;
const FOO: &'static dyn Trait = &Bar;
const BAR: &'static dyn Trait = FOO;
fn foo() { let _x = BAR; }

View file

@ -17,7 +17,7 @@ enum Enum {
}
#[derive(Debug)]
struct Pointers(*const Send, *mut Sync);
struct Pointers(*const dyn Send, *mut dyn Sync);
macro_rules! t {
($x:expr, $expected:expr) => {

View file

@ -30,7 +30,7 @@ impl Drop for Cat {
pub fn main() {
{
let x = box Cat {name: 22};
let nyan: Box<Dummy> = x as Box<Dummy>;
let nyan: Box<dyn Dummy> = x as Box<dyn Dummy>;
}
unsafe {
assert_eq!(value, 22);

View file

@ -36,7 +36,7 @@ fn main() {
// Trait objects.
let a: Bar<i32> = Bar { x: &42 };
let b: Bar<Baz> = a;
let b: Bar<dyn Baz> = a;
unsafe {
assert_eq!((*b.x).get(), 42);
}

View file

@ -26,17 +26,17 @@ fn main() {
assert_eq!(b[2], 3);
let a: Rc<i32> = Rc::new(42);
let b: Rc<Baz> = a.clone();
let b: Rc<dyn Baz> = a.clone();
assert_eq!(b.get(), 42);
let c: Weak<i32> = Rc::downgrade(&a);
let d: Weak<Baz> = c.clone();
let d: Weak<dyn Baz> = c.clone();
let _c = b.clone();
let a: Rc<RefCell<i32>> = Rc::new(RefCell::new(42));
let b: Rc<RefCell<Baz>> = a.clone();
let b: Rc<RefCell<dyn Baz>> = a.clone();
assert_eq!(b.borrow().get(), 42);
// FIXME
let c: Weak<RefCell<Baz>> = Rc::downgrade(&a) as Weak<_>;
let c: Weak<RefCell<dyn Baz>> = Rc::downgrade(&a) as Weak<_>;
}

View file

@ -9,20 +9,20 @@ trait T { fn dummy(&self) { } }
impl T for S {}
pub fn main() {
let x: &T = &S;
let x: &dyn T = &S;
// Test we can convert from &-ptr to *-ptr of trait objects
let x: *const T = &S;
let x: *const dyn T = &S;
// Test we can convert from &-ptr to *-ptr of struct pointer (not DST)
let x: *const S = &S;
// As above, but mut
let x: &mut T = &mut S;
let x: *mut T = &mut S;
let x: &mut dyn T = &mut S;
let x: *mut dyn T = &mut S;
let x: *mut S = &mut S;
// Test we can change the mutability from mut to const.
let x: &T = &mut S;
let x: *const T = &mut S;
let x: &dyn T = &mut S;
let x: *const dyn T = &mut S;
}

View file

@ -26,7 +26,7 @@ fn main() {
// Test that zero-offset works properly
let b : Baz<usize> = Baz { a: 7 };
assert_eq!(b.a.get(), 7);
let b : &Baz<Bar> = &b;
let b : &Baz<dyn Bar> = &b;
assert_eq!(b.a.get(), 7);
// Test that the field is aligned properly
@ -34,7 +34,7 @@ fn main() {
assert_eq!(f.b.get(), 11);
let ptr1 : *const u8 = &f.b as *const _ as *const u8;
let f : &Foo<Bar> = &f;
let f : &Foo<dyn Bar> = &f;
let ptr2 : *const u8 = &f.b as *const _ as *const u8;
assert_eq!(f.b.get(), 11);
@ -44,13 +44,13 @@ fn main() {
// Test that nested DSTs work properly
let f : Foo<Foo<usize>> = Foo { a: 0, b: Foo { a: 1, b: 17 }};
assert_eq!(f.b.b.get(), 17);
let f : &Foo<Foo<Bar>> = &f;
let f : &Foo<Foo<dyn Bar>> = &f;
assert_eq!(f.b.b.get(), 17);
// Test that get the pointer via destructuring works
let f : Foo<usize> = Foo { a: 0, b: 11 };
let f : &Foo<Bar> = &f;
let f : &Foo<dyn Bar> = &f;
let &Foo { a: _, b: ref bar } = f;
assert_eq!(bar.get(), 11);

View file

@ -19,11 +19,11 @@ impl Index<usize> for S {
struct T;
impl Index<usize> for T {
type Output = Debug + 'static;
type Output = dyn Debug + 'static;
fn index<'a>(&'a self, idx: usize) -> &'a (Debug + 'static) {
fn index<'a>(&'a self, idx: usize) -> &'a (dyn Debug + 'static) {
static X: usize = 42;
&X as &(Debug + 'static)
&X as &(dyn Debug + 'static)
}
}

View file

@ -24,7 +24,7 @@ struct Foo<T: ?Sized> {
pub fn main() {
// raw trait object
let x = A { f: 42 };
let z: *const Trait = &x;
let z: *const dyn Trait = &x;
let r = unsafe {
(&*z).foo()
};
@ -32,7 +32,7 @@ pub fn main() {
// raw DST struct
let p = Foo {f: A { f: 42 }};
let o: *const Foo<Trait> = &p;
let o: *const Foo<dyn Trait> = &p;
let r = unsafe {
(&*o).f.foo()
};
@ -40,7 +40,7 @@ pub fn main() {
// raw DST tuple
let p = (A { f: 42 },);
let o: *const (Trait,) = &p;
let o: *const (dyn Trait,) = &p;
let r = unsafe {
(&*o).0.foo()
};
@ -84,21 +84,21 @@ pub fn main() {
// all of the above with *mut
let mut x = A { f: 42 };
let z: *mut Trait = &mut x;
let z: *mut dyn Trait = &mut x;
let r = unsafe {
(&*z).foo()
};
assert_eq!(r, 42);
let mut p = Foo {f: A { f: 42 }};
let o: *mut Foo<Trait> = &mut p;
let o: *mut Foo<dyn Trait> = &mut p;
let r = unsafe {
(&*o).f.foo()
};
assert_eq!(r, 42);
let mut p = (A { f: 42 },);
let o: *mut (Trait,) = &mut p;
let o: *mut (dyn Trait,) = &mut p;
let r = unsafe {
(&*o).0.foo()
};

View file

@ -38,7 +38,7 @@ impl ToBar for Bar1 {
}
// x is a fat pointer
fn foo(x: &Fat<ToBar>) {
fn foo(x: &Fat<dyn ToBar>) {
assert_eq!(x.0, 5);
assert_eq!(x.1, "some str");
assert_eq!(x.2.to_bar(), Bar);
@ -49,12 +49,12 @@ fn foo(x: &Fat<ToBar>) {
assert_eq!(y.to_val(), 42);
}
fn bar(x: &ToBar) {
fn bar(x: &dyn ToBar) {
assert_eq!(x.to_bar(), Bar);
assert_eq!(x.to_val(), 42);
}
fn baz(x: &Fat<Fat<ToBar>>) {
fn baz(x: &Fat<Fat<dyn ToBar>>) {
assert_eq!(x.0, 5);
assert_eq!(x.1, "some str");
assert_eq!((x.2).0, 8);
@ -73,20 +73,20 @@ pub fn main() {
foo(&f1);
let f2 = &f1;
foo(f2);
let f3: &Fat<ToBar> = f2;
let f3: &Fat<dyn ToBar> = f2;
foo(f3);
let f4: &Fat<ToBar> = &f1;
let f4: &Fat<dyn ToBar> = &f1;
foo(f4);
let f5: &Fat<ToBar> = &(5, "some str", Bar1 {f :42});
let f5: &Fat<dyn ToBar> = &(5, "some str", Bar1 {f :42});
foo(f5);
// Zero size object.
let f6: &Fat<ToBar> = &(5, "some str", Bar);
let f6: &Fat<dyn ToBar> = &(5, "some str", Bar);
assert_eq!(f6.2.to_bar(), Bar);
// &*
//
let f7: Box<ToBar> = Box::new(Bar1 {f :42});
let f7: Box<dyn ToBar> = Box::new(Bar1 {f :42});
bar(&*f7);
// Deep nesting
@ -94,10 +94,10 @@ pub fn main() {
baz(&f1);
let f2 = &f1;
baz(f2);
let f3: &Fat<Fat<ToBar>> = f2;
let f3: &Fat<Fat<dyn ToBar>> = f2;
baz(f3);
let f4: &Fat<Fat<ToBar>> = &f1;
let f4: &Fat<Fat<dyn ToBar>> = &f1;
baz(f4);
let f5: &Fat<Fat<ToBar>> = &(5, "some str", (8, "deep str", Bar1 {f :42}));
let f5: &Fat<Fat<dyn ToBar>> = &(5, "some str", (8, "deep str", Bar1 {f :42}));
baz(f5);
}

View file

@ -38,7 +38,7 @@ impl ToBar for Bar1 {
}
// x is a fat pointer
fn foo(x: &Fat<ToBar>) {
fn foo(x: &Fat<dyn ToBar>) {
assert_eq!(x.f1, 5);
assert_eq!(x.f2, "some str");
assert_eq!(x.ptr.to_bar(), Bar);
@ -49,12 +49,12 @@ fn foo(x: &Fat<ToBar>) {
assert_eq!(y.to_val(), 42);
}
fn bar(x: &ToBar) {
fn bar(x: &dyn ToBar) {
assert_eq!(x.to_bar(), Bar);
assert_eq!(x.to_val(), 42);
}
fn baz(x: &Fat<Fat<ToBar>>) {
fn baz(x: &Fat<Fat<dyn ToBar>>) {
assert_eq!(x.f1, 5);
assert_eq!(x.f2, "some str");
assert_eq!(x.ptr.f1, 8);
@ -73,20 +73,20 @@ pub fn main() {
foo(&f1);
let f2 = &f1;
foo(f2);
let f3: &Fat<ToBar> = f2;
let f3: &Fat<dyn ToBar> = f2;
foo(f3);
let f4: &Fat<ToBar> = &f1;
let f4: &Fat<dyn ToBar> = &f1;
foo(f4);
let f5: &Fat<ToBar> = &Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
let f5: &Fat<dyn ToBar> = &Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
foo(f5);
// Zero size object.
let f6: &Fat<ToBar> = &Fat { f1: 5, f2: "some str", ptr: Bar };
let f6: &Fat<dyn ToBar> = &Fat { f1: 5, f2: "some str", ptr: Bar };
assert_eq!(f6.ptr.to_bar(), Bar);
// &*
//
let f7: Box<ToBar> = Box::new(Bar1 {f :42});
let f7: Box<dyn ToBar> = Box::new(Bar1 {f :42});
bar(&*f7);
// Deep nesting
@ -95,11 +95,11 @@ pub fn main() {
baz(&f1);
let f2 = &f1;
baz(f2);
let f3: &Fat<Fat<ToBar>> = f2;
let f3: &Fat<Fat<dyn ToBar>> = f2;
baz(f3);
let f4: &Fat<Fat<ToBar>> = &f1;
let f4: &Fat<Fat<dyn ToBar>> = &f1;
baz(f4);
let f5: &Fat<Fat<ToBar>> =
let f5: &Fat<Fat<dyn ToBar>> =
&Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: Bar1 {f :42}} };
baz(f5);
}

View file

@ -18,7 +18,7 @@ impl Foo for A {
fn assert_foo<T: ?Sized + Foo>() { }
fn use_foo<T: ?Sized + Foo>(x: &Foo) {
fn use_foo<T: ?Sized + Foo>(x: &dyn Foo) {
x.foo();
}

View file

@ -25,7 +25,7 @@ fn main() {
assert_eq!(a as usize, b as *const () as usize);
// And conversion to a void pointer/address for trait objects too.
let a: *mut Foo = &mut Bar;
let a: *mut dyn Foo = &mut Bar;
let b = a as *mut ();
let c = a as *const () as usize;
let d = unsafe {

View file

@ -5,7 +5,7 @@ struct UsizeRef<'a> {
a: &'a usize
}
type RefTo = Box<for<'r> Fn(&'r Vec<usize>) -> UsizeRef<'r>>;
type RefTo = Box<dyn for<'r> Fn(&'r Vec<usize>) -> UsizeRef<'r>>;
fn ref_to<'a>(vec: &'a Vec<usize>) -> UsizeRef<'a> {
UsizeRef{ a: &vec[0]}

View file

@ -17,6 +17,6 @@ impl Foo<isize> for S {
pub fn main() {
let x = box S { x: 1 };
let y = x as Box<Foo<isize>>;
let y = x as Box<dyn Foo<isize>>;
assert_eq!(y.get(), 1);
}

View file

@ -19,7 +19,7 @@ mod map_reduce {
use std::str;
use std::thread;
pub type putter<'a> = Box<FnMut(String, String) + 'a>;
pub type putter<'a> = Box<dyn FnMut(String, String) + 'a>;
pub type mapper = extern fn(String, putter);

View file

@ -19,7 +19,7 @@ struct Tcx<'tcx> {
impl<'tcx> Typer<'tcx> for Tcx<'tcx> {
}
fn g<'tcx>(typer: &Typer<'tcx>) {
fn g<'tcx>(typer: &dyn Typer<'tcx>) {
}
fn check_static_type<'x>(tcx: &Tcx<'x>) {

View file

@ -7,7 +7,7 @@ trait Typer<'tcx> {
fn dummy(&self) { }
}
fn g<F>(_: F) where F: FnOnce(&Typer) {}
fn g<F>(_: F) where F: FnOnce(&dyn Typer) {}
fn h() {
g(|typer| typer.dummy())

View file

@ -6,7 +6,7 @@ trait FnLike<A,R> {
fn call(&self, arg: A) -> R;
}
type FnObject<'b> = for<'a> FnLike<&'a isize, &'a isize> + 'b;
type FnObject<'b> = dyn for<'a> FnLike<&'a isize, &'a isize> + 'b;
struct Identity;

View file

@ -24,8 +24,8 @@ fn foo01<T: for<'a> Get<&'a i32, &'a i32>>(t: T)
// Parse HRTB with explicit `for` in various sorts of types:
fn foo10(t: Box<for<'a> Get<i32, i32>>) { }
fn foo11(t: Box<for<'a> Fn(i32) -> i32>) { }
fn foo10(t: Box<dyn for<'a> Get<i32, i32>>) { }
fn foo11(t: Box<dyn for<'a> Fn(i32) -> i32>) { }
fn foo20(t: for<'a> fn(i32) -> i32) { }
fn foo21(t: for<'a> unsafe fn(i32) -> i32) { }

View file

@ -6,7 +6,7 @@
// 'static` and not `Fn(isize) -> (isize + 'static)`. The latter would
// cause a compilation error. Issue #18772.
fn adder(y: isize) -> Box<Fn(isize) -> isize + 'static> {
fn adder(y: isize) -> Box<dyn Fn(isize) -> isize + 'static> {
Box::new(move |x| y + x)
}

View file

@ -8,7 +8,7 @@ trait FnLike<A,R> {
fn call(&self, arg: A) -> R;
}
type FnObject<'b> = for<'a> FnLike<&'a isize, &'a isize> + 'b;
type FnObject<'b> = dyn for<'a> FnLike<&'a isize, &'a isize> + 'b;
fn main() {
}

View file

@ -5,7 +5,7 @@ trait FnLike<A,R> {
fn call(&self, arg: A) -> R;
}
type FnObject<'b> = for<'a> FnLike<(&'a i32,), &'a i32> + 'b;
type FnObject<'b> = dyn for<'a> FnLike<(&'a i32,), &'a i32> + 'b;
struct Identity;

View file

@ -17,7 +17,7 @@ struct NoAnn<'ast> {
impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> {
}
fn foo<'ast, G>(f: Option<&'ast usize>, g: G) where G: FnOnce(&PrinterSupport) {
fn foo<'ast, G>(f: Option<&'ast usize>, g: G) where G: FnOnce(&dyn PrinterSupport) {
let annotation = NoAnn { f: f };
g(&annotation)
}

View file

@ -93,7 +93,7 @@ pub fn main() {
t!(format!("{:#4}", C), "☃123");
t!(format!("{:b}", D), "aa☃bb");
let a: &fmt::Debug = &1;
let a: &dyn fmt::Debug = &1;
t!(format!("{:?}", a), "1");

View file

@ -24,9 +24,9 @@ trait MyTrait { fn dummy(&self) { } }
impl MyTrait for Box<DroppableStruct> {}
impl MyTrait for Box<DroppableEnum> {}
struct Whatever { w: Box<MyTrait+'static> }
struct Whatever { w: Box<dyn MyTrait+'static> }
impl Whatever {
fn new(w: Box<MyTrait+'static>) -> Whatever {
fn new(w: Box<dyn MyTrait+'static>) -> Whatever {
Whatever { w: w }
}
}
@ -34,13 +34,13 @@ impl Whatever {
fn main() {
{
let f: Box<_> = box DroppableStruct;
let _a = Whatever::new(box f as Box<MyTrait>);
let _a = Whatever::new(box f as Box<dyn MyTrait>);
}
assert!(unsafe { DROPPED });
unsafe { DROPPED = false; }
{
let f: Box<_> = box DroppableEnum::DroppableVariant1;
let _a = Whatever::new(box f as Box<MyTrait>);
let _a = Whatever::new(box f as Box<dyn MyTrait>);
}
assert!(unsafe { DROPPED });
}

View file

@ -5,44 +5,44 @@
trait Foo { fn dummy(&self) { } }
impl Foo for isize {}
fn foo(_: [&Foo; 2]) {}
fn foos(_: &[&Foo]) {}
fn foo(_: [&dyn Foo; 2]) {}
fn foos(_: &[&dyn Foo]) {}
fn foog<T>(_: &[T], _: &[T]) {}
fn bar(_: [Box<Foo>; 2]) {}
fn bars(_: &[Box<Foo+'static>]) {}
fn bar(_: [Box<dyn Foo>; 2]) {}
fn bars(_: &[Box<dyn Foo+'static>]) {}
fn main() {
let x: [&Foo; 2] = [&1, &2];
let x: [&dyn Foo; 2] = [&1, &2];
foo(x);
foo([&1, &2]);
let r = &1;
let x: [&Foo; 2] = [r; 2];
let x: [&dyn Foo; 2] = [r; 2];
foo(x);
foo([&1; 2]);
let x: &[&Foo] = &[&1, &2];
let x: &[&dyn Foo] = &[&1, &2];
foos(x);
foos(&[&1, &2]);
let x: &[&Foo] = &[&1, &2];
let x: &[&dyn Foo] = &[&1, &2];
let r = &1;
foog(x, &[r]);
let x: [Box<Foo>; 2] = [Box::new(1), Box::new(2)];
let x: [Box<dyn Foo>; 2] = [Box::new(1), Box::new(2)];
bar(x);
bar([Box::new(1), Box::new(2)]);
let x: &[Box<Foo+'static>] = &[Box::new(1), Box::new(2)];
let x: &[Box<dyn Foo+'static>] = &[Box::new(1), Box::new(2)];
bars(x);
bars(&[Box::new(1), Box::new(2)]);
let x: &[Box<Foo+'static>] = &[Box::new(1), Box::new(2)];
let x: &[Box<dyn Foo+'static>] = &[Box::new(1), Box::new(2)];
foog(x, &[Box::new(1)]);
struct T<'a> {
t: [&'a (Foo+'a); 2]
t: [&'a (dyn Foo+'a); 2]
}
let _n = T {
t: [&1, &2]
@ -51,34 +51,34 @@ fn main() {
let _n = T {
t: [r; 2]
};
let x: [&Foo; 2] = [&1, &2];
let x: [&dyn Foo; 2] = [&1, &2];
let _n = T {
t: x
};
struct F<'b> {
t: &'b [&'b (Foo+'b)]
t: &'b [&'b (dyn Foo+'b)]
}
let _n = F {
t: &[&1, &2]
};
let r = &1;
let r: [&Foo; 2] = [r; 2];
let r: [&dyn Foo; 2] = [r; 2];
let _n = F {
t: &r
};
let x: [&Foo; 2] = [&1, &2];
let x: [&dyn Foo; 2] = [&1, &2];
let _n = F {
t: &x
};
struct M<'a> {
t: &'a [Box<Foo+'static>]
t: &'a [Box<dyn Foo+'static>]
}
let _n = M {
t: &[Box::new(1), Box::new(2)]
};
let x: [Box<Foo>; 2] = [Box::new(1), Box::new(2)];
let x: [Box<dyn Foo>; 2] = [Box::new(1), Box::new(2)];
let _n = M {
t: &x
};

View file

@ -10,7 +10,7 @@ impl T<isize> for Empty {
fn next(&mut self) -> Option<isize> { None }
}
fn do_something_with(a : &mut T<isize>) {
fn do_something_with(a : &mut dyn T<isize>) {
println!("{:?}", a.next())
}

View file

@ -11,8 +11,8 @@ trait X<T> {
fn dummy(&self) -> T { panic!() }
}
struct S<T> {f: Box<X<T>+'static>,
g: Box<X<T>+'static>}
struct S<T> {f: Box<dyn X<T>+'static>,
g: Box<dyn X<T>+'static>}
struct F;
impl X<isize> for F {

View file

@ -9,7 +9,7 @@
struct S {x:()}
fn test(slot: &mut Option<Box<FnMut() -> Box<FnMut()>>>) -> () {
fn test(slot: &mut Option<Box<dyn FnMut() -> Box<dyn FnMut()>>>) -> () {
let a = slot.take();
let _a = match a {
// `{let .. a(); }` would break

View file

@ -1,5 +1,5 @@
// run-pass
fn main() {
fn test() -> Box<std::any::Any + 'static> { Box::new(1) }
fn test() -> Box<dyn std::any::Any + 'static> { Box::new(1) }
println!("{:?}", test())
}

View file

@ -23,7 +23,7 @@ pub fn type_ids() -> Vec<TypeId> {
TypeId::of::<FooFnPtr>(),
TypeId::of::<FooNil>(),
TypeId::of::<FooTuple>(),
TypeId::of::<FooTrait>(),
TypeId::of::<dyn FooTrait>(),
TypeId::of::<FooStruct>(),
TypeId::of::<FooEnum>()
]

View file

@ -4,7 +4,7 @@
// pretty-expanded FIXME #23616
struct Foo<'a> {
listener: Box<FnMut() + 'a>,
listener: Box<dyn FnMut() + 'a>,
}
impl<'a> Foo<'a> {

View file

@ -16,5 +16,5 @@ impl A for B1 {}
fn main() {
let v: Box<_> = box B1;
let _c: Box<A> = v.clone();
let _c: Box<dyn A> = v.clone();
}

View file

@ -5,9 +5,9 @@
// pretty-expanded FIXME #23616
fn main() {
send::<Box<Foo>>(Box::new(Output(0)));
Test::<Box<Foo>>::foo(Box::new(Output(0)));
Test::<Box<Foo>>::new().send(Box::new(Output(0)));
send::<Box<dyn Foo>>(Box::new(Output(0)));
Test::<Box<dyn Foo>>::foo(Box::new(Output(0)));
Test::<Box<dyn Foo>>::new().send(Box::new(Output(0)));
}
fn send<T>(_: T) {}

View file

@ -6,16 +6,16 @@ struct Meow;
impl SomeTrait for Meow {}
struct Foo<'a> {
x: &'a SomeTrait,
y: &'a SomeTrait,
x: &'a dyn SomeTrait,
y: &'a dyn SomeTrait,
}
impl<'a> Foo<'a> {
pub fn new<'b>(x: &'b SomeTrait, y: &'b SomeTrait) -> Foo<'b> { Foo { x: x, y: y } }
pub fn new<'b>(x: &'b dyn SomeTrait, y: &'b dyn SomeTrait) -> Foo<'b> { Foo { x: x, y: y } }
}
fn main() {
let r = Meow;
let s = Meow;
let q = Foo::new(&r as &SomeTrait, &s as &SomeTrait);
let q = Foo::new(&r as &dyn SomeTrait, &s as &dyn SomeTrait);
}

View file

@ -9,7 +9,7 @@ trait Matcher {
struct CharPredMatcher<'a, 'b> {
str: &'a str,
pred: Box<FnMut(char) -> bool + 'b>,
pred: Box<dyn FnMut(char) -> bool + 'b>,
}
impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> {

View file

@ -7,17 +7,17 @@ trait Foo { fn dummy(&self) { }}
struct Bar;
impl<'a> std::ops::Fn<(&'a (Foo+'a),)> for Bar {
extern "rust-call" fn call(&self, _: (&'a Foo,)) {}
impl<'a> std::ops::Fn<(&'a (dyn Foo+'a),)> for Bar {
extern "rust-call" fn call(&self, _: (&'a dyn Foo,)) {}
}
impl<'a> std::ops::FnMut<(&'a (Foo+'a),)> for Bar {
extern "rust-call" fn call_mut(&mut self, a: (&'a Foo,)) { self.call(a) }
impl<'a> std::ops::FnMut<(&'a (dyn Foo+'a),)> for Bar {
extern "rust-call" fn call_mut(&mut self, a: (&'a dyn Foo,)) { self.call(a) }
}
impl<'a> std::ops::FnOnce<(&'a (Foo+'a),)> for Bar {
impl<'a> std::ops::FnOnce<(&'a (dyn Foo+'a),)> for Bar {
type Output = ();
extern "rust-call" fn call_once(self, a: (&'a Foo,)) { self.call(a) }
extern "rust-call" fn call_once(self, a: (&'a dyn Foo,)) { self.call(a) }
}
struct Baz;

View file

@ -4,18 +4,18 @@ trait IndirectTraitWithSend: TraitWithSend {}
// Check struct instantiation (Box<TraitWithSend> will only have Send if TraitWithSend has Send)
#[allow(dead_code)]
struct Blah { x: Box<TraitWithSend> }
struct Blah { x: Box<dyn TraitWithSend> }
impl TraitWithSend for Blah {}
// Struct instantiation 2-levels deep
#[allow(dead_code)]
struct IndirectBlah { x: Box<IndirectTraitWithSend> }
struct IndirectBlah { x: Box<dyn IndirectTraitWithSend> }
impl TraitWithSend for IndirectBlah {}
impl IndirectTraitWithSend for IndirectBlah {}
fn test_trait<T: Send + ?Sized>() { println!("got here!") }
fn main() {
test_trait::<TraitWithSend>();
test_trait::<IndirectTraitWithSend>();
test_trait::<dyn TraitWithSend>();
test_trait::<dyn IndirectTraitWithSend>();
}

View file

@ -78,12 +78,12 @@ fn main() {
assert_eq!(cc().unwrap(), 3);
assert_eq!(dd().unwrap(), 3);
let i = box 32isize as Box<A>;
let i = box 32isize as Box<dyn A>;
assert_eq!(i.aaa(), 3);
let i = box 32isize as Box<A>;
let i = box 32isize as Box<dyn A>;
assert_eq!(i.bbb(), 3);
let i = box 32isize as Box<A>;
let i = box 32isize as Box<dyn A>;
assert_eq!(i.ccc().unwrap(), 3);
let i = box 32isize as Box<A>;
let i = box 32isize as Box<dyn A>;
assert_eq!(i.ddd().unwrap(), 3);
}

View file

@ -39,12 +39,12 @@ impl FnOnce<(u32,u32)> for Foo {
}
fn main() {
let mut f = box Foo { foo: 42 } as Box<FnMut() -> u32>;
let mut f = box Foo { foo: 42 } as Box<dyn FnMut() -> u32>;
assert_eq!(f.call_mut(()), 42);
let mut f = box Foo { foo: 40 } as Box<FnMut(u32) -> u32>;
let mut f = box Foo { foo: 40 } as Box<dyn FnMut(u32) -> u32>;
assert_eq!(f.call_mut((2,)), 42);
let mut f = box Foo { foo: 40 } as Box<FnMut(u32, u32) -> u32>;
let mut f = box Foo { foo: 40 } as Box<dyn FnMut(u32, u32) -> u32>;
assert_eq!(f.call_mut((1, 1)), 42);
}

View file

@ -7,5 +7,5 @@ fn foo(_: &u8) {
}
fn main() {
let _ = &foo as &Any;
let _ = &foo as &dyn Any;
}

View file

@ -5,11 +5,11 @@
use std::io::{self, Write};
fn f(wr: &mut Write) {
fn f(wr: &mut dyn Write) {
wr.write_all(b"hello").ok().expect("failed");
}
fn main() {
let mut wr = box io::stdout() as Box<Write>;
let mut wr = box io::stdout() as Box<dyn Write>;
f(&mut wr);
}

View file

@ -6,5 +6,5 @@ impl Str for str {}
impl<'a, S: ?Sized> Str for &'a S where S: Str {}
fn main() {
let _: &Str = &"x";
let _: &dyn Str = &"x";
}

View file

@ -4,13 +4,13 @@
trait Aaa { fn dummy(&self) { } }
impl<'a> Aaa for &'a mut (Aaa + 'a) {}
impl<'a> Aaa for &'a mut (dyn Aaa + 'a) {}
struct Bar<'a> {
writer: &'a mut (Aaa + 'a),
writer: &'a mut (dyn Aaa + 'a),
}
fn baz(_: &mut Aaa) {
fn baz(_: &mut dyn Aaa) {
}
fn foo<'a>(mut bar: Bar<'a>) {

View file

@ -1,5 +1,5 @@
// run-pass
fn action(mut cb: Box<FnMut(usize) -> usize>) -> usize {
fn action(mut cb: Box<dyn FnMut(usize) -> usize>) -> usize {
cb(1)
}

View file

@ -22,7 +22,7 @@ pub fn foo(box_1: fn () -> Box<[i8; 1]>,
box_4: fn () -> Box<[i8; 4]>,
) {
println!("Hello World 1");
let _: Box<Boo> = match 3 {
let _: Box<dyn Boo> = match 3 {
1 => box_1(),
2 => box_2(),
3 => box_3(),

View file

@ -4,7 +4,7 @@
// pretty-expanded FIXME #23616
fn main() {
let functions: [Box<Fn() -> Option<()>>; 1] = [Box::new(|| None)];
let functions: [Box<dyn Fn() -> Option<()>>; 1] = [Box::new(|| None)];
let _: Option<Vec<()>> = functions.iter().map(|f| (*f)()).collect();
}

View file

@ -7,6 +7,6 @@
use std::fmt;
fn main() {
let a: &fmt::Debug = &1;
let a: &dyn fmt::Debug = &1;
format!("{:?}", a);
}

View file

@ -2,11 +2,11 @@
#![allow(unused_mut)]
#![allow(unused_variables)]
fn main() {
let mut shrinker: Box<Iterator<Item=i32>> = Box::new(vec![1].into_iter());
let mut shrinker: Box<dyn Iterator<Item=i32>> = Box::new(vec![1].into_iter());
println!("{:?}", shrinker.next());
for v in shrinker { assert!(false); }
let mut shrinker: &mut Iterator<Item=i32> = &mut vec![1].into_iter();
let mut shrinker: &mut dyn Iterator<Item=i32> = &mut vec![1].into_iter();
println!("{:?}", shrinker.next());
for v in shrinker { assert!(false); }
}

View file

@ -13,7 +13,7 @@ fn main() {
// str
std::intrinsics::type_name::<str>(),
// Trait
std::intrinsics::type_name::<Send>(),
std::intrinsics::type_name::<dyn Send>(),
// Newtype
std::intrinsics::type_name::<NT>(),
// DST

View file

@ -2,10 +2,10 @@
fn main() {
let v = vec![1, 2, 3];
let boxed: Box<Iterator<Item=i32>> = Box::new(v.into_iter());
let boxed: Box<dyn Iterator<Item=i32>> = Box::new(v.into_iter());
assert_eq!(boxed.max(), Some(3));
let v = vec![1, 2, 3];
let boxed: &mut Iterator<Item=i32> = &mut v.into_iter();
let boxed: &mut dyn Iterator<Item=i32> = &mut v.into_iter();
assert_eq!(boxed.max(), Some(3));
}

View file

@ -1,6 +1,6 @@
// run-pass
fn test(it: &mut Iterator<Item=i32>) {
fn test(it: &mut dyn Iterator<Item=i32>) {
for x in it {
assert_eq!(x, 1)
}

View file

@ -9,11 +9,11 @@ use std::thread::Builder;
static generations: usize = 1024+256+128+49;
fn spawn(mut f: Box<FnMut() + 'static + Send>) {
fn spawn(mut f: Box<dyn FnMut() + 'static + Send>) {
Builder::new().stack_size(32 * 1024).spawn(move|| f());
}
fn child_no(x: usize) -> Box<FnMut() + 'static + Send> {
fn child_no(x: usize) -> Box<dyn FnMut() + 'static + Send> {
Box::new(move|| {
if x < generations {
spawn(child_no(x+1));

View file

@ -3,7 +3,7 @@
// pretty-expanded FIXME #23616
// This used to cause an ICE because the retslot for the "return" had the wrong type
fn testcase<'a>() -> Box<Iterator<Item=usize> + 'a> {
fn testcase<'a>() -> Box<dyn Iterator<Item=usize> + 'a> {
return Box::new((0..3).map(|i| { return i; }));
}

View file

@ -23,13 +23,13 @@ fn foo<A>(b: A) -> foo<A> {
}
}
fn f<A>(x: Box<clam<A>>, a: A) {
fn f<A>(x: Box<dyn clam<A>>, a: A) {
x.chowder(a);
}
pub fn main() {
let c = foo(42);
let d: Box<clam<isize>> = box c as Box<clam<isize>>;
let d: Box<dyn clam<isize>> = box c as Box<dyn clam<isize>>;
f(d, c.x);
}

View file

@ -41,7 +41,7 @@ fn check_both(val: &Foo<[u8]>) {
}
}
fn check_trait_obj(val: &Foo<Get>) {
fn check_trait_obj(val: &Foo<dyn Get>) {
match *val {
Foo { a, ref inner } => {
assert_eq!(a, 32);
@ -56,6 +56,6 @@ fn main() {
check_dst_val(foo);
check_both(foo);
let foo: &Foo<Get> = &Foo { a: 32, inner: 32 };
let foo: &Foo<dyn Get> = &Foo { a: 32, inner: 32 };
check_trait_obj(foo);
}

View file

@ -45,6 +45,6 @@ impl Iterator for Counter {
}
fn main() {
let mut x: Box<Iterator<Item=Token>> = Box::new(Counter { value: 22 });
let mut x: Box<dyn Iterator<Item=Token>> = Box::new(Counter { value: 22 });
assert_eq!(x.next().unwrap().value, 22);
}

View file

@ -2,7 +2,7 @@ trait Foo: Fn(i32) -> i32 + Send {}
impl<T: ?Sized + Fn(i32) -> i32 + Send> Foo for T {}
fn wants_foo(f: Box<Foo>) -> i32 {
fn wants_foo(f: Box<dyn Foo>) -> i32 {
f(42)
}

View file

@ -7,8 +7,8 @@ pub struct Registry<'a> {
}
pub struct Listener<'a> {
pub announce: Option<Box<FnMut(&mut Registry) + 'a>>,
pub remove: Option<Box<FnMut(&mut Registry) + 'a>>,
pub announce: Option<Box<dyn FnMut(&mut Registry) + 'a>>,
pub remove: Option<Box<dyn FnMut(&mut Registry) + 'a>>,
}
impl<'a> Drop for Registry<'a> {

View file

@ -12,7 +12,7 @@ pub trait Routing<I> {
pub trait ToRouting {
type Input;
type Routing : ?Sized = Routing<Self::Input, Output=()>;
type Routing : ?Sized = dyn Routing<Self::Input, Output=()>;
fn to_routing(self) -> Self::Routing;
}

View file

@ -13,7 +13,7 @@ fn main() {
let mut drops = 0;
{
let _: Rc<Send> = Rc::new(Foo(&mut drops));
let _: Rc<dyn Send> = Rc::new(Foo(&mut drops));
}
assert_eq!(1, drops);

View file

@ -25,7 +25,7 @@ fn main() {
drops = 0;
{
let y = &Holder(Foo(&mut drops)) as &Holder<Trait>;
let y = &Holder(Foo(&mut drops)) as &Holder<dyn Trait>;
// this used to cause an extra drop of the Foo instance
let x = &y.0;
}

View file

@ -9,7 +9,7 @@ impl Foo {
}
}
const FUNC: &'static Fn(&mut Foo) -> () = &Foo::x;
const FUNC: &'static dyn Fn(&mut Foo) -> () = &Foo::x;
fn main() {
let mut foo = Foo { a: 137 };

View file

@ -1,5 +1,5 @@
// run-pass
struct Parser<'a>(Box<FnMut(Parser) + 'a>);
struct Parser<'a>(Box<dyn FnMut(Parser) + 'a>);
fn main() {
let _x = Parser(Box::new(|_|{}));

View file

@ -11,7 +11,7 @@ fn main() {
let mut x = 0;
{
let wrapper = Box::new(Wrapper(&mut x, 123));
let _: Box<Wrapper<Send>> = wrapper;
let _: Box<Wrapper<dyn Send>> = wrapper;
}
assert_eq!(432, x)
}

View file

@ -5,7 +5,7 @@ trait Foo<'a> {
pub struct FooBar;
impl Foo<'static> for FooBar {}
fn test(foobar: FooBar) -> Box<Foo<'static>> {
fn test(foobar: FooBar) -> Box<dyn Foo<'static>> {
Box::new(foobar)
}

View file

@ -2,5 +2,5 @@
struct NonOrd;
fn main() {
let _: Box<Iterator<Item = _>> = Box::new(vec![NonOrd].into_iter());
let _: Box<dyn Iterator<Item = _>> = Box::new(vec![NonOrd].into_iter());
}

View file

@ -17,5 +17,5 @@ fn main() {
let data = [1, 2, 3];
let iter = data.iter();
let x = MyRc { _ptr: &iter, _boo: PhantomData };
let _y: MyRc<Iterator<Item=&u32>> = x;
let _y: MyRc<dyn Iterator<Item=&u32>> = x;
}

View file

@ -1,4 +1,4 @@
// run-pass
fn main() {
const _C: &'static Fn() = &||{};
const _C: &'static dyn Fn() = &||{};
}

View file

@ -11,8 +11,8 @@ trait hax {
}
impl<A> hax for A { }
fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax+'static> {
box x as Box<hax+'static>
fn perform_hax<T: 'static>(x: Box<T>) -> Box<dyn hax+'static> {
box x as Box<dyn hax+'static>
}
fn deadcode() {

View file

@ -11,8 +11,8 @@ trait hax {
}
impl<A> hax for A { }
fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax+'static> {
box x as Box<hax+'static>
fn perform_hax<T: 'static>(x: Box<T>) -> Box<dyn hax+'static> {
box x as Box<dyn hax+'static>
}
fn deadcode() {

View file

@ -1,6 +1,6 @@
// run-pass
static PLUS_ONE: &'static (Fn(i32) -> i32 + Sync) = (&|x: i32| { x + 1 })
as &'static (Fn(i32) -> i32 + Sync);
static PLUS_ONE: &'static (dyn Fn(i32) -> i32 + Sync) = (&|x: i32| { x + 1 })
as &'static (dyn Fn(i32) -> i32 + Sync);
fn main() {
assert_eq!(PLUS_ONE(2), 3);

View file

@ -20,7 +20,7 @@ pub fn main() {
// let y = box ({a: 4});
// let z = box ({a: 4} as it);
// let z = box ({a: true} as it);
let z: Box<_> = box (box true as Box<it>);
let z: Box<_> = box (box true as Box<dyn it>);
// x.f();
// y.f();
// (*z).f();

View file

@ -2,7 +2,7 @@
#![allow(dead_code)]
// pretty-expanded FIXME #23616
type Connection = Box<FnMut(Vec<u8>) + 'static>;
type Connection = Box<dyn FnMut(Vec<u8>) + 'static>;
fn f() -> Option<Connection> {
let mock_connection: Connection = Box::new(|_| {});

View file

@ -8,7 +8,7 @@
pub enum Handler {
Default,
#[allow(dead_code)]
Custom(*mut Box<Fn()>),
Custom(*mut Box<dyn Fn()>),
}
fn main() {
@ -16,7 +16,7 @@ fn main() {
}
#[inline(never)]
pub fn take(h: Handler, f: Box<Fn()>) -> Box<Fn()> {
pub fn take(h: Handler, f: Box<dyn Fn()>) -> Box<dyn Fn()> {
unsafe {
match h {
Handler::Custom(ptr) => *Box::from_raw(ptr),

View file

@ -1,5 +1,5 @@
// run-pass
fn main() {
&0u8 as *const u8 as *const PartialEq<u8>;
&0u8 as *const u8 as *const dyn PartialEq<u8>;
&[0u8] as *const [u8; 1] as *const [u8];
}

View file

@ -2,7 +2,7 @@
fn foo<T>() -> T { loop {} }
fn test() {
let ref mut a: &mut FnMut((i8,), i16) = foo();
let ref mut a: &mut dyn FnMut((i8,), i16) = foo();
a((0,), 0);
}

View file

@ -15,18 +15,18 @@ impl Foo for [u8; 2] {
struct Bar<T: ?Sized>(T);
fn unsize_fat_ptr<'a>(x: &'a Bar<Foo + Send + 'a>) -> &'a Bar<Foo + 'a> {
fn unsize_fat_ptr<'a>(x: &'a Bar<dyn Foo + Send + 'a>) -> &'a Bar<dyn Foo + 'a> {
x
}
fn unsize_nested_fat_ptr(x: Arc<Foo + Send>) -> Arc<Foo> {
fn unsize_nested_fat_ptr(x: Arc<dyn Foo + Send>) -> Arc<dyn Foo> {
x
}
fn main() {
let x: Box<Bar<Foo + Send>> = Box::new(Bar([1,2]));
let x: Box<Bar<dyn Foo + Send>> = Box::new(Bar([1,2]));
assert_eq!(unsize_fat_ptr(&*x).0.get(), [1, 2]);
let x: Arc<Foo + Send> = Arc::new([3, 4]);
let x: Arc<dyn Foo + Send> = Arc::new([3, 4]);
assert_eq!(unsize_nested_fat_ptr(x).get(), [3, 4]);
}

View file

@ -24,5 +24,5 @@ impl<P: TheTrait> Shape<P> for TheType<P::TheAssociatedType> {
fn main() {
let ball = TheType { t: PhantomData };
let handle: &Shape<()> = &ball;
let handle: &dyn Shape<()> = &ball;
}

View file

@ -7,5 +7,5 @@ fn main() {
where Option<T>: Ord { *x < *x }
}
impl Foo<X> for () {}
let _ = &() as &Foo<X>;
let _ = &() as &dyn Foo<X>;
}

View file

@ -10,6 +10,6 @@ struct Foo<T: ?Sized> {
fn main() {
let foo: &Foo<i32> = &Foo { a: 1, b: false, c: 2i32 };
let foo_unsized: &Foo<Send> = foo;
let foo_unsized: &Foo<dyn Send> = foo;
assert_eq!(mem::size_of_val(foo), mem::size_of_val(foo_unsized));
}

View file

@ -2,7 +2,7 @@
// Make sure this compiles without getting a linker error because of missing
// drop-glue because the collector missed adding drop-glue for the closure:
fn create_fn() -> Box<Fn()> {
fn create_fn() -> Box<dyn Fn()> {
let text = String::new();
Box::new(move || { let _ = &text; })

View file

@ -3,6 +3,6 @@
// correctly
fn main() {
let x : Vec<Box<Fn()>> = vec![Box::new(|| ())];
let x : Vec<Box<dyn Fn()>> = vec![Box::new(|| ())];
x[0]()
}

View file

@ -6,7 +6,7 @@ pub fn main() {
fn to_string(&self) -> String;
}
fn to_string(t: Box<Text>) {
fn to_string(t: Box<dyn Text>) {
println!("{}", (*t).to_string());
}

View file

@ -16,7 +16,7 @@ impl T for S {
}
}
fn print_t(t: &T) {
fn print_t(t: &dyn T) {
t.print();
}
@ -27,6 +27,6 @@ fn print_s(s: &S) {
pub fn main() {
let s: Box<S> = box S { s: 5 };
print_s(&*s);
let t: Box<T> = s as Box<T>;
let t: Box<dyn T> = s as Box<dyn T>;
print_t(&*t);
}

View file

@ -13,5 +13,5 @@ trait Bar: for<'a> Foo<&'a ()> { }
impl Bar for () {}
fn main() {
(&() as &Bar).print(); // Segfault
(&() as &dyn Bar).print(); // Segfault
}

View file

@ -11,15 +11,15 @@ struct LocalC(u32);
struct LocalG<T>(T);
fn main() {
let virtual_localc : &Fn(_) -> LocalC = &LocalC;
let virtual_localc : &dyn Fn(_) -> LocalC = &LocalC;
assert_eq!(virtual_localc(1), LocalC(1));
let virtual_localg : &Fn(_) -> LocalG<u32> = &LocalG;
let virtual_localg : &dyn Fn(_) -> LocalG<u32> = &LocalG;
assert_eq!(virtual_localg(1), LocalG(1));
let virtual_remotec : &Fn(_) -> RemoteC = &RemoteC;
let virtual_remotec : &dyn Fn(_) -> RemoteC = &RemoteC;
assert_eq!(virtual_remotec(1), RemoteC(1));
let virtual_remoteg : &Fn(_) -> RemoteG<u32> = &RemoteG;
let virtual_remoteg : &dyn Fn(_) -> RemoteG<u32> = &RemoteG;
assert_eq!(virtual_remoteg(1), RemoteG(1));
}

View file

@ -6,8 +6,8 @@ pub trait Trait { fn foo(&self) {} }
pub struct Foo;
impl Iterator for Foo {
type Item = Box<Trait>;
fn next(&mut self) -> Option<Box<Trait>> {
type Item = Box<dyn Trait>;
fn next(&mut self) -> Option<Box<dyn Trait>> {
extern crate issue_41053;
impl ::Trait for issue_41053::Test {
fn foo(&self) {}

Some files were not shown because too many files have changed in this diff Show more