From f19f4545b1674e6d16b9ec81a2358d615bb6a786 Mon Sep 17 00:00:00 2001 From: memoryruins Date: Tue, 28 May 2019 14:47:21 -0400 Subject: [PATCH] Update run-pass test suite to use dyn --- src/test/run-pass/alignment-gep-tup-like-1.rs | 4 +-- ...ciated-types-doubleendediterator-object.rs | 2 +- .../associated-types-eq-obj.rs | 2 +- ...ociated-types-projection-in-object-type.rs | 6 ++-- .../autoderef-method-on-trait.rs | 2 +- .../borrowck/borrowck-trait-lifetime.rs | 4 +-- .../run-pass/cast-rfc0401-vtable-kinds.rs | 10 +++--- src/test/run-pass/cast-rfc0401.rs | 4 +-- .../close-over-big-then-small-data.rs | 4 +-- src/test/run-pass/codegen-object-shim.rs | 2 +- .../run-pass/coerce/coerce-expect-unsized.rs | 18 +++++----- .../run-pass/consts/const-trait-to-trait.rs | 8 ++--- src/test/run-pass/deriving/deriving-show.rs | 2 +- .../run-pass/drop/drop-struct-as-object.rs | 2 +- .../dst-coerce-custom.rs | 2 +- .../dynamically-sized-types/dst-coerce-rc.rs | 8 ++--- .../dynamically-sized-types/dst-coercions.rs | 12 +++---- .../dst-field-align.rs | 8 ++--- .../dynamically-sized-types/dst-index.rs | 6 ++-- .../dynamically-sized-types/dst-raw.rs | 12 +++---- .../dst-trait-tuple.rs | 22 ++++++------ .../dynamically-sized-types/dst-trait.rs | 22 ++++++------ .../extern/extern-types-trait-impl.rs | 2 +- src/test/run-pass/fat-ptr-cast.rs | 2 +- .../closure-expected-type/issue-38714.rs | 2 +- src/test/run-pass/generics/generic-object.rs | 2 +- src/test/run-pass/hashmap-memory.rs | 2 +- .../hrtb-binder-levels-in-object-types.rs | 2 +- .../hrtb-debruijn-object-types-in-closures.rs | 2 +- .../hrtb-fn-like-trait-object.rs | 2 +- .../higher-rank-trait-bounds/hrtb-parse.rs | 4 +-- .../hrtb-precedence-of-plus.rs | 2 +- .../hrtb-resolve-lifetime.rs | 2 +- .../hrtb-trait-object-paren-notation.rs | 2 +- .../hrtb-trait-object-passed-to-closure.rs | 2 +- src/test/run-pass/ifmt.rs | 2 +- src/test/run-pass/issues/issue-10802.rs | 8 ++--- src/test/run-pass/issues/issue-11205.rs | 36 +++++++++---------- src/test/run-pass/issues/issue-11267.rs | 2 +- src/test/run-pass/issues/issue-11677.rs | 4 +-- src/test/run-pass/issues/issue-11709.rs | 2 +- src/test/run-pass/issues/issue-12744.rs | 2 +- src/test/run-pass/issues/issue-13507-2.rs | 2 +- src/test/run-pass/issues/issue-13808.rs | 2 +- src/test/run-pass/issues/issue-14399.rs | 2 +- src/test/run-pass/issues/issue-14589.rs | 6 ++-- src/test/run-pass/issues/issue-14821.rs | 8 ++--- src/test/run-pass/issues/issue-14919.rs | 2 +- src/test/run-pass/issues/issue-14958.rs | 12 +++---- src/test/run-pass/issues/issue-15155.rs | 8 ++--- src/test/run-pass/issues/issue-15763.rs | 8 ++--- src/test/run-pass/issues/issue-16739.rs | 6 ++-- src/test/run-pass/issues/issue-16922.rs | 2 +- src/test/run-pass/issues/issue-17322.rs | 4 +-- src/test/run-pass/issues/issue-17351.rs | 2 +- src/test/run-pass/issues/issue-17771.rs | 6 ++-- src/test/run-pass/issues/issue-17897.rs | 2 +- .../run-pass/issues/issue-20055-box-trait.rs | 2 +- src/test/run-pass/issues/issue-20575.rs | 2 +- src/test/run-pass/issues/issue-20676.rs | 2 +- src/test/run-pass/issues/issue-20953.rs | 4 +-- src/test/run-pass/issues/issue-21058.rs | 2 +- src/test/run-pass/issues/issue-21361.rs | 4 +-- src/test/run-pass/issues/issue-21655.rs | 2 +- src/test/run-pass/issues/issue-2190-1.rs | 4 +-- src/test/run-pass/issues/issue-22346.rs | 2 +- src/test/run-pass/issues/issue-2288.rs | 4 +-- src/test/run-pass/issues/issue-23261.rs | 4 +-- src/test/run-pass/issues/issue-23485.rs | 2 +- src/test/run-pass/issues/issue-24010.rs | 2 +- src/test/run-pass/issues/issue-24086.rs | 4 +-- src/test/run-pass/issues/issue-25339.rs | 2 +- src/test/run-pass/issues/issue-25515.rs | 2 +- .../issues/issue-25549-multiple-drop.rs | 2 +- src/test/run-pass/issues/issue-25757.rs | 2 +- src/test/run-pass/issues/issue-26641.rs | 2 +- src/test/run-pass/issues/issue-26709.rs | 2 +- src/test/run-pass/issues/issue-26802.rs | 2 +- src/test/run-pass/issues/issue-26805.rs | 2 +- src/test/run-pass/issues/issue-26905.rs | 2 +- src/test/run-pass/issues/issue-27268.rs | 2 +- src/test/run-pass/issues/issue-2734.rs | 4 +-- src/test/run-pass/issues/issue-2735.rs | 4 +-- src/test/run-pass/issues/issue-27890.rs | 4 +-- src/test/run-pass/issues/issue-2935.rs | 2 +- src/test/run-pass/issues/issue-3052.rs | 2 +- src/test/run-pass/issues/issue-30530.rs | 4 +-- src/test/run-pass/issues/issue-30615.rs | 2 +- src/test/run-pass/issues/issue-32389.rs | 2 +- src/test/run-pass/issues/issue-33387.rs | 8 ++--- src/test/run-pass/issues/issue-33461.rs | 2 +- src/test/run-pass/issues/issue-34503.rs | 2 +- src/test/run-pass/issues/issue-35815.rs | 2 +- src/test/run-pass/issues/issue-36260.rs | 2 +- .../issues/issue-36786-resolve-call.rs | 2 +- src/test/run-pass/issues/issue-3702.rs | 2 +- src/test/run-pass/issues/issue-3794.rs | 4 +-- src/test/run-pass/issues/issue-39292.rs | 2 +- src/test/run-pass/issues/issue-39823.rs | 8 ++--- src/test/run-pass/issues/issue-41053.rs | 4 +-- src/test/run-pass/issues/issue-41744.rs | 2 +- src/test/run-pass/issues/issue-42210.rs | 4 +-- src/test/run-pass/issues/issue-43132.rs | 2 +- src/test/run-pass/issues/issue-4333.rs | 2 +- src/test/run-pass/issues/issue-47638.rs | 4 +-- ...e-5008-borrowed-traitobject-method-call.rs | 4 +-- src/test/run-pass/issues/issue-5192.rs | 6 ++-- src/test/run-pass/issues/issue-5666.rs | 2 +- src/test/run-pass/issues/issue-5708.rs | 10 +++--- src/test/run-pass/issues/issue-5988.rs | 2 +- src/test/run-pass/issues/issue-6128.rs | 2 +- src/test/run-pass/issues/issue-6157.rs | 4 +-- src/test/run-pass/issues/issue-6318.rs | 4 +-- src/test/run-pass/issues/issue-7563.rs | 2 +- src/test/run-pass/issues/issue-7911.rs | 12 +++---- src/test/run-pass/issues/issue-8248.rs | 4 +-- src/test/run-pass/issues/issue-8249.rs | 4 +-- src/test/run-pass/issues/issue-9129.rs | 4 +-- .../issue-9394-inherited-trait-calls.rs | 2 +- src/test/run-pass/issues/issue-9951.rs | 10 +++--- src/test/run-pass/last-use-in-cap-clause.rs | 2 +- .../run-pass/macros/colorful-write-macros.rs | 4 +-- .../run-pass/macros/type-macros-simple.rs | 2 +- ...thod-argument-inference-associated-type.rs | 4 +-- src/test/run-pass/mir/mir_codegen_calls.rs | 8 ++--- .../run-pass/mir/mir_codegen_critical_edge.rs | 2 +- src/test/run-pass/mir/mir_coercions.rs | 10 +++--- src/test/run-pass/mir/mir_raw_fat_ptr.rs | 6 ++-- src/test/run-pass/new-box.rs | 6 ++-- src/test/run-pass/newlambdas-ret-infer.rs | 2 +- src/test/run-pass/newlambdas-ret-infer2.rs | 2 +- ...ject-lifetime-default-default-to-static.rs | 12 +++---- .../object-lifetime-default-from-rptr-box.rs | 10 +++--- .../object-lifetime-default-from-rptr-mut.rs | 12 +++---- .../object-lifetime-default-from-rptr.rs | 16 ++++----- src/test/run-pass/object-method-numbering.rs | 2 +- .../objects-coerce-freeze-borrored.rs | 6 ++-- ...owned-object-borrowed-method-headerless.rs | 8 ++--- .../objects-owned-object-owned-method.rs | 2 +- .../overloaded-calls-object-one-arg.rs | 2 +- .../overloaded-calls-object-two-args.rs | 2 +- .../overloaded-calls-object-zero-args.rs | 2 +- src/test/run-pass/panics/panic-safe.rs | 2 +- src/test/run-pass/privacy/privacy-ns.rs | 12 +++---- src/test/run-pass/raw-fat-ptr.rs | 4 +-- .../regions-bound-lists-feature-gate.rs | 2 +- ...-close-over-type-parameter-successfully.rs | 4 +-- .../run-pass/regions/regions-copy-closure.rs | 4 +-- .../regions/regions-debruijn-of-object.rs | 4 +-- .../regions-early-bound-trait-param.rs | 18 +++++----- .../regions/regions-fn-subtyping-2.rs | 4 +-- .../run-pass/regions/regions-fn-subtyping.rs | 8 ++--- ...regions-infer-region-in-fn-but-not-type.rs | 2 +- .../regions-lifetime-nonfree-late-bound.rs | 8 ++--- ...ions-on-closures-to-inference-variables.rs | 2 +- .../regions/regions-static-closure.rs | 4 +-- .../regions/regions-trait-object-1.rs | 4 +-- src/test/run-pass/string-box-error.rs | 8 ++--- .../class-cast-to-trait-cross-crate-2.rs | 4 +-- .../class-cast-to-trait-multiple-types.rs | 2 +- .../structs-enums/class-cast-to-trait.rs | 2 +- .../structs-enums/class-separate-impl.rs | 4 +-- .../structs-enums/enum-null-pointer-opt.rs | 6 ++-- ...object-lifetime-default-from-ref-struct.rs | 22 ++++++------ ...bject-lifetime-default-from-rptr-struct.rs | 10 +++--- src/test/run-pass/traits/auto-traits.rs | 2 +- .../traits/impl-inherent-prefer-over-trait.rs | 4 +-- .../infer-from-object-trait-issue-26952.rs | 2 +- .../traits/kindck-owned-trait-contains-1.rs | 4 +-- .../traits/object-one-type-two-traits.rs | 10 +++--- .../traits/parameterized-trait-with-bounds.rs | 10 +++--- .../run-pass/traits/trait-bounds-basic.rs | 8 ++--- .../run-pass/traits/trait-bounds-in-arc.rs | 22 ++++++------ .../trait-bounds-on-structs-and-enums.rs | 4 +-- .../run-pass/traits/trait-coercion-generic.rs | 4 +-- src/test/run-pass/traits/trait-coercion.rs | 6 ++-- src/test/run-pass/traits/trait-impl-2.rs | 2 +- src/test/run-pass/traits/trait-impl.rs | 6 ++-- ...ritance-cast-without-call-to-supertrait.rs | 4 +-- .../run-pass/traits/trait-inheritance-cast.rs | 4 +-- .../run-pass/traits/trait-object-exclusion.rs | 2 +- .../run-pass/traits/trait-object-generics.rs | 4 +-- .../traits/trait-object-lifetime-first.rs | 4 +-- .../trait-object-with-lifetime-bound.rs | 4 +-- .../traits/trait-region-pointer-simple.rs | 2 +- .../traits-impl-object-overlap-issue-23853.rs | 2 +- .../run-pass/traits/traits-issue-26339.rs | 2 +- .../traits/traits-repeated-supertrait.rs | 2 +- src/test/run-pass/traits/ufcs-trait-object.rs | 2 +- src/test/run-pass/trivial_casts.rs | 14 ++++---- src/test/run-pass/type-id-higher-rank-2.rs | 6 ++-- src/test/run-pass/type-id-higher-rank.rs | 18 +++++----- .../run-pass/type-infer-generalize-ty-var.rs | 8 ++--- .../unboxed-closures-blanket-fn-mut.rs | 2 +- .../unboxed-closures-blanket-fn.rs | 2 +- .../unboxed-closures-boxed.rs | 4 +-- ...ed-closures-call-sugar-object-autoderef.rs | 2 +- .../unboxed-closures-call-sugar-object.rs | 2 +- .../unboxed-closures-extern-fn-hr.rs | 2 +- ...fer-arg-types-from-expected-object-type.rs | 2 +- .../unboxed-closures-infer-recursive-fn.rs | 8 ++--- .../unboxed-closures-manual-impl.rs | 2 +- .../unboxed-closures-monomorphization.rs | 2 +- .../unboxed-closures-prelude.rs | 4 +-- .../unboxed-closures-sugar-object.rs | 2 +- .../run-pass/unique/unique-object-move.rs | 2 +- src/test/run-pass/unsized2.rs | 16 ++++----- .../wf-bound-region-in-object-type.rs | 2 +- 208 files changed, 502 insertions(+), 502 deletions(-) diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index badd095d0ae..7e6ee60e519 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -22,11 +22,11 @@ impl Invokable for Invoker { } } -fn f(a: A, b: u16) -> Box+'static> { +fn f(a: A, b: u16) -> Box+'static> { box Invoker { a: a, b: b, - } as (Box+'static>) + } as (Box+'static>) } pub fn main() { diff --git a/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs b/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs index 5f86888aef0..96ba2ee3b62 100644 --- a/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs +++ b/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs @@ -1,7 +1,7 @@ // run-pass #![feature(box_syntax)] -fn pairwise_sub(mut t: Box>) -> isize { +fn pairwise_sub(mut t: Box>) -> isize { let mut result = 0; loop { let front = t.next(); diff --git a/src/test/run-pass/associated-types/associated-types-eq-obj.rs b/src/test/run-pass/associated-types/associated-types-eq-obj.rs index 0f3dfe338a3..c202c376c5f 100644 --- a/src/test/run-pass/associated-types/associated-types-eq-obj.rs +++ b/src/test/run-pass/associated-types/associated-types-eq-obj.rs @@ -15,7 +15,7 @@ impl Foo for char { fn boo(&self) -> Bar { Bar } } -fn baz(x: &Foo) -> Bar { +fn baz(x: &dyn Foo) -> Bar { x.boo() } diff --git a/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs b/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs index 0dc32f2fd94..eec95a141f5 100644 --- a/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs +++ b/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs @@ -19,7 +19,7 @@ pub trait Subscriber { pub trait Publisher<'a> { type Output; - fn subscribe(&mut self, _: Box + 'a>); + fn subscribe(&mut self, _: Box + '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 + 'a> + sub: Box + 'a> } impl<'a> Publisher<'a> for MyStruct<'a> { type Output = u64; - fn subscribe(&mut self, t : Box + 'a>) { + fn subscribe(&mut self, t : Box + 'a>) { self.sub = t; } } diff --git a/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs b/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs index 0a54db7f5cd..fadb0784e75 100644 --- a/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs @@ -11,6 +11,6 @@ impl double for usize { } pub fn main() { - let x: Box<_> = box (box 3usize as Box); + let x: Box<_> = box (box 3usize as Box); assert_eq!(x.double(), 6); } diff --git a/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs b/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs index 9721b08233e..8a6dfe76d60 100644 --- a/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs +++ b/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs @@ -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 } } diff --git a/src/test/run-pass/cast-rfc0401-vtable-kinds.rs b/src/test/run-pass/cast-rfc0401-vtable-kinds.rs index e53ab791922..a27dd9eef52 100644 --- a/src/test/run-pass/cast-rfc0401-vtable-kinds.rs +++ b/src/test/run-pass/cast-rfc0401-vtable-kinds.rs @@ -15,9 +15,9 @@ impl Foo for () {} impl Foo for u32 { fn foo(&self, _: u32) -> u32 { self+43 } } impl Bar for () {} -unsafe fn round_trip_and_call<'a>(t: *const (Foo+'a)) -> u32 { - let foo_e : *const Foo = t as *const _; - let r_1 = foo_e as *mut Foo; +unsafe fn round_trip_and_call<'a>(t: *const (dyn Foo+'a)) -> u32 { + let foo_e : *const dyn Foo = t as *const _; + let r_1 = foo_e as *mut dyn Foo; (&*r_1).foo(0) } @@ -38,8 +38,8 @@ fn tuple_i32_to_u32(u: *const (i32, T)) -> *const (u32, T) { fn main() { let x = 4u32; - let y : &Foo = &x; - let fl = unsafe { round_trip_and_call(y as *const Foo) }; + let y : &dyn Foo = &x; + let fl = unsafe { round_trip_and_call(y as *const dyn Foo) }; assert_eq!(fl, (43+4)); let s = FooS([0,1,2]); diff --git a/src/test/run-pass/cast-rfc0401.rs b/src/test/run-pass/cast-rfc0401.rs index 324860e53e1..017b63c7374 100644 --- a/src/test/run-pass/cast-rfc0401.rs +++ b/src/test/run-pass/cast-rfc0401.rs @@ -25,8 +25,8 @@ fn main() // coercion-cast let mut it = vec![137].into_iter(); let itr: &mut vec::IntoIter = &mut it; - assert_eq!((itr as &mut Iterator).next(), Some(137)); - assert_eq!((itr as &mut Iterator).next(), None); + assert_eq!((itr as &mut dyn Iterator).next(), Some(137)); + assert_eq!((itr as &mut dyn Iterator).next(), None); assert_eq!(Some(4u32) as Option, Some(4u32)); assert_eq!((1u32,2u32) as (u32,u32), (1,2)); diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index 2ae0b6c7d3d..0eead0194ef 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -24,11 +24,11 @@ impl Invokable for Invoker { } } -fn f(a: A, b: u16) -> Box+'static> { +fn f(a: A, b: u16) -> Box+'static> { box Invoker { a: a, b: b, - } as (Box+'static>) + } as (Box+'static>) } pub fn main() { diff --git a/src/test/run-pass/codegen-object-shim.rs b/src/test/run-pass/codegen-object-shim.rs index 4e2d7ac6086..26f53a9c182 100644 --- a/src/test/run-pass/codegen-object-shim.rs +++ b/src/test/run-pass/codegen-object-shim.rs @@ -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")); } diff --git a/src/test/run-pass/coerce/coerce-expect-unsized.rs b/src/test/run-pass/coerce/coerce-expect-unsized.rs index a7e80afbf76..b44aa6ab377 100644 --- a/src/test/run-pass/coerce/coerce-expect-unsized.rs +++ b/src/test/run-pass/coerce/coerce-expect-unsized.rs @@ -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 _> = Box::new({ |x| (x as u8) }); - let _: Box = Box::new(if true { false } else { true }); - let _: Box = Box::new(match true { true => 'a', false => 'b' }); + let _: Box _> = Box::new({ |x| (x as u8) }); + let _: Box = Box::new(if true { false } else { true }); + let _: Box = 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 _> = Box::new(|x| (x as u8)); + let _: Box _> = Box::new(|x| (x as u8)); let _: Rc> = Rc::new(RefCell::new([1, 2, 3])); - let _: Rc _>> = Rc::new(RefCell::new(|x| (x as u8))); + let _: Rc _>> = Rc::new(RefCell::new(|x| (x as u8))); - let _: Vec _>> = vec![ + let _: Vec _>> = vec![ Box::new(|x| (x as u8)), Box::new(|x| (x as i16 as u8)), ]; diff --git a/src/test/run-pass/consts/const-trait-to-trait.rs b/src/test/run-pass/consts/const-trait-to-trait.rs index a324d73a3a9..12a2999d79d 100644 --- a/src/test/run-pass/consts/const-trait-to-trait.rs +++ b/src/test/run-pass/consts/const-trait-to-trait.rs @@ -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; } diff --git a/src/test/run-pass/deriving/deriving-show.rs b/src/test/run-pass/deriving/deriving-show.rs index 98c1f3ac027..eb3a8948fc8 100644 --- a/src/test/run-pass/deriving/deriving-show.rs +++ b/src/test/run-pass/deriving/deriving-show.rs @@ -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) => { diff --git a/src/test/run-pass/drop/drop-struct-as-object.rs b/src/test/run-pass/drop/drop-struct-as-object.rs index 307b3f1d6dc..1bc3b4c157c 100644 --- a/src/test/run-pass/drop/drop-struct-as-object.rs +++ b/src/test/run-pass/drop/drop-struct-as-object.rs @@ -30,7 +30,7 @@ impl Drop for Cat { pub fn main() { { let x = box Cat {name: 22}; - let nyan: Box = x as Box; + let nyan: Box = x as Box; } unsafe { assert_eq!(value, 22); diff --git a/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs b/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs index 35927bde027..24d83eb5343 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs @@ -36,7 +36,7 @@ fn main() { // Trait objects. let a: Bar = Bar { x: &42 }; - let b: Bar = a; + let b: Bar = a; unsafe { assert_eq!((*b.x).get(), 42); } diff --git a/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs b/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs index bbd0b1f8be1..683fa6850fd 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs @@ -26,17 +26,17 @@ fn main() { assert_eq!(b[2], 3); let a: Rc = Rc::new(42); - let b: Rc = a.clone(); + let b: Rc = a.clone(); assert_eq!(b.get(), 42); let c: Weak = Rc::downgrade(&a); - let d: Weak = c.clone(); + let d: Weak = c.clone(); let _c = b.clone(); let a: Rc> = Rc::new(RefCell::new(42)); - let b: Rc> = a.clone(); + let b: Rc> = a.clone(); assert_eq!(b.borrow().get(), 42); // FIXME - let c: Weak> = Rc::downgrade(&a) as Weak<_>; + let c: Weak> = Rc::downgrade(&a) as Weak<_>; } diff --git a/src/test/run-pass/dynamically-sized-types/dst-coercions.rs b/src/test/run-pass/dynamically-sized-types/dst-coercions.rs index 06c2892b69e..66688e93fb8 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-coercions.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-coercions.rs @@ -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; } diff --git a/src/test/run-pass/dynamically-sized-types/dst-field-align.rs b/src/test/run-pass/dynamically-sized-types/dst-field-align.rs index 9c81f5652d1..6c338e99912 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-field-align.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-field-align.rs @@ -26,7 +26,7 @@ fn main() { // Test that zero-offset works properly let b : Baz = Baz { a: 7 }; assert_eq!(b.a.get(), 7); - let b : &Baz = &b; + let b : &Baz = &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 = &f; + let f : &Foo = &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 { a: 0, b: Foo { a: 1, b: 17 }}; assert_eq!(f.b.b.get(), 17); - let f : &Foo> = &f; + let f : &Foo> = &f; assert_eq!(f.b.b.get(), 17); // Test that get the pointer via destructuring works let f : Foo = Foo { a: 0, b: 11 }; - let f : &Foo = &f; + let f : &Foo = &f; let &Foo { a: _, b: ref bar } = f; assert_eq!(bar.get(), 11); diff --git a/src/test/run-pass/dynamically-sized-types/dst-index.rs b/src/test/run-pass/dynamically-sized-types/dst-index.rs index 0728599f323..980d99a6d6c 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-index.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-index.rs @@ -19,11 +19,11 @@ impl Index for S { struct T; impl Index 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) } } diff --git a/src/test/run-pass/dynamically-sized-types/dst-raw.rs b/src/test/run-pass/dynamically-sized-types/dst-raw.rs index 949adbbefce..0893b02e74e 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-raw.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-raw.rs @@ -24,7 +24,7 @@ struct Foo { 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 = &p; + let o: *const Foo = &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 = &mut p; + let o: *mut Foo = &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() }; diff --git a/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs b/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs index ca88605ee3a..70bcc3de07d 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs @@ -38,7 +38,7 @@ impl ToBar for Bar1 { } // x is a fat pointer -fn foo(x: &Fat) { +fn foo(x: &Fat) { 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) { 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>) { +fn baz(x: &Fat>) { 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 = f2; + let f3: &Fat = f2; foo(f3); - let f4: &Fat = &f1; + let f4: &Fat = &f1; foo(f4); - let f5: &Fat = &(5, "some str", Bar1 {f :42}); + let f5: &Fat = &(5, "some str", Bar1 {f :42}); foo(f5); // Zero size object. - let f6: &Fat = &(5, "some str", Bar); + let f6: &Fat = &(5, "some str", Bar); assert_eq!(f6.2.to_bar(), Bar); // &* // - let f7: Box = Box::new(Bar1 {f :42}); + let f7: Box = 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> = f2; + let f3: &Fat> = f2; baz(f3); - let f4: &Fat> = &f1; + let f4: &Fat> = &f1; baz(f4); - let f5: &Fat> = &(5, "some str", (8, "deep str", Bar1 {f :42})); + let f5: &Fat> = &(5, "some str", (8, "deep str", Bar1 {f :42})); baz(f5); } diff --git a/src/test/run-pass/dynamically-sized-types/dst-trait.rs b/src/test/run-pass/dynamically-sized-types/dst-trait.rs index 9a9bd12d50f..ec6bc72192d 100644 --- a/src/test/run-pass/dynamically-sized-types/dst-trait.rs +++ b/src/test/run-pass/dynamically-sized-types/dst-trait.rs @@ -38,7 +38,7 @@ impl ToBar for Bar1 { } // x is a fat pointer -fn foo(x: &Fat) { +fn foo(x: &Fat) { 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) { 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>) { +fn baz(x: &Fat>) { 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 = f2; + let f3: &Fat = f2; foo(f3); - let f4: &Fat = &f1; + let f4: &Fat = &f1; foo(f4); - let f5: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; + let f5: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; foo(f5); // Zero size object. - let f6: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar }; + let f6: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar }; assert_eq!(f6.ptr.to_bar(), Bar); // &* // - let f7: Box = Box::new(Bar1 {f :42}); + let f7: Box = 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> = f2; + let f3: &Fat> = f2; baz(f3); - let f4: &Fat> = &f1; + let f4: &Fat> = &f1; baz(f4); - let f5: &Fat> = + let f5: &Fat> = &Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: Bar1 {f :42}} }; baz(f5); } diff --git a/src/test/run-pass/extern/extern-types-trait-impl.rs b/src/test/run-pass/extern/extern-types-trait-impl.rs index ac4c70a71ce..6cce6c723c5 100644 --- a/src/test/run-pass/extern/extern-types-trait-impl.rs +++ b/src/test/run-pass/extern/extern-types-trait-impl.rs @@ -18,7 +18,7 @@ impl Foo for A { fn assert_foo() { } -fn use_foo(x: &Foo) { +fn use_foo(x: &dyn Foo) { x.foo(); } diff --git a/src/test/run-pass/fat-ptr-cast.rs b/src/test/run-pass/fat-ptr-cast.rs index 367b57d5ea0..1943abe9e14 100644 --- a/src/test/run-pass/fat-ptr-cast.rs +++ b/src/test/run-pass/fat-ptr-cast.rs @@ -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 { diff --git a/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs b/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs index 96b7a66d075..e97785b5cac 100644 --- a/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs +++ b/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs @@ -5,7 +5,7 @@ struct UsizeRef<'a> { a: &'a usize } -type RefTo = Box Fn(&'r Vec) -> UsizeRef<'r>>; +type RefTo = Box Fn(&'r Vec) -> UsizeRef<'r>>; fn ref_to<'a>(vec: &'a Vec) -> UsizeRef<'a> { UsizeRef{ a: &vec[0]} diff --git a/src/test/run-pass/generics/generic-object.rs b/src/test/run-pass/generics/generic-object.rs index 054425989c3..870ff980ec6 100644 --- a/src/test/run-pass/generics/generic-object.rs +++ b/src/test/run-pass/generics/generic-object.rs @@ -17,6 +17,6 @@ impl Foo for S { pub fn main() { let x = box S { x: 1 }; - let y = x as Box>; + let y = x as Box>; assert_eq!(y.get(), 1); } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 364661e565e..987a3e414f5 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -19,7 +19,7 @@ mod map_reduce { use std::str; use std::thread; - pub type putter<'a> = Box; + pub type putter<'a> = Box; pub type mapper = extern fn(String, putter); diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs index 1591d616cac..cc766c0605c 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs @@ -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>) { diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs index 09152970fdc..8431226a3ec 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs @@ -7,7 +7,7 @@ trait Typer<'tcx> { fn dummy(&self) { } } -fn g(_: F) where F: FnOnce(&Typer) {} +fn g(_: F) where F: FnOnce(&dyn Typer) {} fn h() { g(|typer| typer.dummy()) diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs index 7ef8ea046b8..ff84ad9d298 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs @@ -6,7 +6,7 @@ trait FnLike { 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; diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs index 3fb0b3290eb..1fab9758c5c 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs @@ -24,8 +24,8 @@ fn foo01 Get<&'a i32, &'a i32>>(t: T) // Parse HRTB with explicit `for` in various sorts of types: -fn foo10(t: Box Get>) { } -fn foo11(t: Box Fn(i32) -> i32>) { } +fn foo10(t: Box Get>) { } +fn foo11(t: Box Fn(i32) -> i32>) { } fn foo20(t: for<'a> fn(i32) -> i32) { } fn foo21(t: for<'a> unsafe fn(i32) -> i32) { } diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs index 5fda4b826e0..6834c392d4e 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs @@ -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 isize + 'static> { +fn adder(y: isize) -> Box isize + 'static> { Box::new(move |x| y + x) } diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs index 917f6f96118..b97fdf4df50 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs @@ -8,7 +8,7 @@ trait FnLike { 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() { } diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs index 0ed8f7ee52a..d8c726cdd71 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs @@ -5,7 +5,7 @@ trait FnLike { 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; diff --git a/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs b/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs index 4cb9242f0ed..41ebb3f5a14 100644 --- a/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs +++ b/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs @@ -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) } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 8c17b01e2bd..6660f393f7d 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -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"); diff --git a/src/test/run-pass/issues/issue-10802.rs b/src/test/run-pass/issues/issue-10802.rs index 8872eae6f8b..f1d6b37a684 100644 --- a/src/test/run-pass/issues/issue-10802.rs +++ b/src/test/run-pass/issues/issue-10802.rs @@ -24,9 +24,9 @@ trait MyTrait { fn dummy(&self) { } } impl MyTrait for Box {} impl MyTrait for Box {} -struct Whatever { w: Box } +struct Whatever { w: Box } impl Whatever { - fn new(w: Box) -> Whatever { + fn new(w: Box) -> 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); + let _a = Whatever::new(box f as Box); } assert!(unsafe { DROPPED }); unsafe { DROPPED = false; } { let f: Box<_> = box DroppableEnum::DroppableVariant1; - let _a = Whatever::new(box f as Box); + let _a = Whatever::new(box f as Box); } assert!(unsafe { DROPPED }); } diff --git a/src/test/run-pass/issues/issue-11205.rs b/src/test/run-pass/issues/issue-11205.rs index b628bf60196..ce0951eafdd 100644 --- a/src/test/run-pass/issues/issue-11205.rs +++ b/src/test/run-pass/issues/issue-11205.rs @@ -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]) {} -fn bar(_: [Box; 2]) {} -fn bars(_: &[Box]) {} +fn bar(_: [Box; 2]) {} +fn bars(_: &[Box]) {} 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; 2] = [Box::new(1), Box::new(2)]; + let x: [Box; 2] = [Box::new(1), Box::new(2)]; bar(x); bar([Box::new(1), Box::new(2)]); - let x: &[Box] = &[Box::new(1), Box::new(2)]; + let x: &[Box] = &[Box::new(1), Box::new(2)]; bars(x); bars(&[Box::new(1), Box::new(2)]); - let x: &[Box] = &[Box::new(1), Box::new(2)]; + let x: &[Box] = &[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] + t: &'a [Box] } let _n = M { t: &[Box::new(1), Box::new(2)] }; - let x: [Box; 2] = [Box::new(1), Box::new(2)]; + let x: [Box; 2] = [Box::new(1), Box::new(2)]; let _n = M { t: &x }; diff --git a/src/test/run-pass/issues/issue-11267.rs b/src/test/run-pass/issues/issue-11267.rs index 1aaeaa62ad0..848ed6ac7a8 100644 --- a/src/test/run-pass/issues/issue-11267.rs +++ b/src/test/run-pass/issues/issue-11267.rs @@ -10,7 +10,7 @@ impl T for Empty { fn next(&mut self) -> Option { None } } -fn do_something_with(a : &mut T) { +fn do_something_with(a : &mut dyn T) { println!("{:?}", a.next()) } diff --git a/src/test/run-pass/issues/issue-11677.rs b/src/test/run-pass/issues/issue-11677.rs index 5dabecc48f9..be18c736f14 100644 --- a/src/test/run-pass/issues/issue-11677.rs +++ b/src/test/run-pass/issues/issue-11677.rs @@ -11,8 +11,8 @@ trait X { fn dummy(&self) -> T { panic!() } } -struct S {f: Box+'static>, - g: Box+'static>} +struct S {f: Box+'static>, + g: Box+'static>} struct F; impl X for F { diff --git a/src/test/run-pass/issues/issue-11709.rs b/src/test/run-pass/issues/issue-11709.rs index f191a203f03..cb5e3dff3b3 100644 --- a/src/test/run-pass/issues/issue-11709.rs +++ b/src/test/run-pass/issues/issue-11709.rs @@ -9,7 +9,7 @@ struct S {x:()} -fn test(slot: &mut Option Box>>) -> () { +fn test(slot: &mut Option Box>>) -> () { let a = slot.take(); let _a = match a { // `{let .. a(); }` would break diff --git a/src/test/run-pass/issues/issue-12744.rs b/src/test/run-pass/issues/issue-12744.rs index d02620ee1a4..e2756ec970c 100644 --- a/src/test/run-pass/issues/issue-12744.rs +++ b/src/test/run-pass/issues/issue-12744.rs @@ -1,5 +1,5 @@ // run-pass fn main() { - fn test() -> Box { Box::new(1) } + fn test() -> Box { Box::new(1) } println!("{:?}", test()) } diff --git a/src/test/run-pass/issues/issue-13507-2.rs b/src/test/run-pass/issues/issue-13507-2.rs index ce920a3ccab..63f3589c6cc 100644 --- a/src/test/run-pass/issues/issue-13507-2.rs +++ b/src/test/run-pass/issues/issue-13507-2.rs @@ -23,7 +23,7 @@ pub fn type_ids() -> Vec { TypeId::of::(), TypeId::of::(), TypeId::of::(), - TypeId::of::(), + TypeId::of::(), TypeId::of::(), TypeId::of::() ] diff --git a/src/test/run-pass/issues/issue-13808.rs b/src/test/run-pass/issues/issue-13808.rs index d1b94c71864..9f9db067bf4 100644 --- a/src/test/run-pass/issues/issue-13808.rs +++ b/src/test/run-pass/issues/issue-13808.rs @@ -4,7 +4,7 @@ // pretty-expanded FIXME #23616 struct Foo<'a> { - listener: Box, + listener: Box, } impl<'a> Foo<'a> { diff --git a/src/test/run-pass/issues/issue-14399.rs b/src/test/run-pass/issues/issue-14399.rs index 1b57856e955..6bf8a589959 100644 --- a/src/test/run-pass/issues/issue-14399.rs +++ b/src/test/run-pass/issues/issue-14399.rs @@ -16,5 +16,5 @@ impl A for B1 {} fn main() { let v: Box<_> = box B1; - let _c: Box = v.clone(); + let _c: Box = v.clone(); } diff --git a/src/test/run-pass/issues/issue-14589.rs b/src/test/run-pass/issues/issue-14589.rs index d495602dff7..5d8aab2ce74 100644 --- a/src/test/run-pass/issues/issue-14589.rs +++ b/src/test/run-pass/issues/issue-14589.rs @@ -5,9 +5,9 @@ // pretty-expanded FIXME #23616 fn main() { - send::>(Box::new(Output(0))); - Test::>::foo(Box::new(Output(0))); - Test::>::new().send(Box::new(Output(0))); + send::>(Box::new(Output(0))); + Test::>::foo(Box::new(Output(0))); + Test::>::new().send(Box::new(Output(0))); } fn send(_: T) {} diff --git a/src/test/run-pass/issues/issue-14821.rs b/src/test/run-pass/issues/issue-14821.rs index 5ac0d0df0d7..00b2e3607fc 100644 --- a/src/test/run-pass/issues/issue-14821.rs +++ b/src/test/run-pass/issues/issue-14821.rs @@ -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); } diff --git a/src/test/run-pass/issues/issue-14919.rs b/src/test/run-pass/issues/issue-14919.rs index c6ccb7575bb..94361543354 100644 --- a/src/test/run-pass/issues/issue-14919.rs +++ b/src/test/run-pass/issues/issue-14919.rs @@ -9,7 +9,7 @@ trait Matcher { struct CharPredMatcher<'a, 'b> { str: &'a str, - pred: Box bool + 'b>, + pred: Box bool + 'b>, } impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> { diff --git a/src/test/run-pass/issues/issue-14958.rs b/src/test/run-pass/issues/issue-14958.rs index 17f7f159fd2..a12564ca9c0 100644 --- a/src/test/run-pass/issues/issue-14958.rs +++ b/src/test/run-pass/issues/issue-14958.rs @@ -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; diff --git a/src/test/run-pass/issues/issue-15155.rs b/src/test/run-pass/issues/issue-15155.rs index 3e513a3d5ec..7b137b4af56 100644 --- a/src/test/run-pass/issues/issue-15155.rs +++ b/src/test/run-pass/issues/issue-15155.rs @@ -4,18 +4,18 @@ trait IndirectTraitWithSend: TraitWithSend {} // Check struct instantiation (Box will only have Send if TraitWithSend has Send) #[allow(dead_code)] -struct Blah { x: Box } +struct Blah { x: Box } impl TraitWithSend for Blah {} // Struct instantiation 2-levels deep #[allow(dead_code)] -struct IndirectBlah { x: Box } +struct IndirectBlah { x: Box } impl TraitWithSend for IndirectBlah {} impl IndirectTraitWithSend for IndirectBlah {} fn test_trait() { println!("got here!") } fn main() { - test_trait::(); - test_trait::(); + test_trait::(); + test_trait::(); } diff --git a/src/test/run-pass/issues/issue-15763.rs b/src/test/run-pass/issues/issue-15763.rs index 4438d1f2cec..9ceffff2e38 100644 --- a/src/test/run-pass/issues/issue-15763.rs +++ b/src/test/run-pass/issues/issue-15763.rs @@ -78,12 +78,12 @@ fn main() { assert_eq!(cc().unwrap(), 3); assert_eq!(dd().unwrap(), 3); - let i = box 32isize as Box; + let i = box 32isize as Box; assert_eq!(i.aaa(), 3); - let i = box 32isize as Box; + let i = box 32isize as Box; assert_eq!(i.bbb(), 3); - let i = box 32isize as Box; + let i = box 32isize as Box; assert_eq!(i.ccc().unwrap(), 3); - let i = box 32isize as Box; + let i = box 32isize as Box; assert_eq!(i.ddd().unwrap(), 3); } diff --git a/src/test/run-pass/issues/issue-16739.rs b/src/test/run-pass/issues/issue-16739.rs index 6868eae6ea4..54ad8fd076e 100644 --- a/src/test/run-pass/issues/issue-16739.rs +++ b/src/test/run-pass/issues/issue-16739.rs @@ -39,12 +39,12 @@ impl FnOnce<(u32,u32)> for Foo { } fn main() { - let mut f = box Foo { foo: 42 } as Box u32>; + let mut f = box Foo { foo: 42 } as Box u32>; assert_eq!(f.call_mut(()), 42); - let mut f = box Foo { foo: 40 } as Box u32>; + let mut f = box Foo { foo: 40 } as Box u32>; assert_eq!(f.call_mut((2,)), 42); - let mut f = box Foo { foo: 40 } as Box u32>; + let mut f = box Foo { foo: 40 } as Box u32>; assert_eq!(f.call_mut((1, 1)), 42); } diff --git a/src/test/run-pass/issues/issue-16922.rs b/src/test/run-pass/issues/issue-16922.rs index 82a3943e9ef..c3c6ff30488 100644 --- a/src/test/run-pass/issues/issue-16922.rs +++ b/src/test/run-pass/issues/issue-16922.rs @@ -7,5 +7,5 @@ fn foo(_: &u8) { } fn main() { - let _ = &foo as &Any; + let _ = &foo as &dyn Any; } diff --git a/src/test/run-pass/issues/issue-17322.rs b/src/test/run-pass/issues/issue-17322.rs index 79b6a5ae533..20a8d136124 100644 --- a/src/test/run-pass/issues/issue-17322.rs +++ b/src/test/run-pass/issues/issue-17322.rs @@ -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; + let mut wr = box io::stdout() as Box; f(&mut wr); } diff --git a/src/test/run-pass/issues/issue-17351.rs b/src/test/run-pass/issues/issue-17351.rs index f51f0b3ca01..62f6bcf15e3 100644 --- a/src/test/run-pass/issues/issue-17351.rs +++ b/src/test/run-pass/issues/issue-17351.rs @@ -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"; } diff --git a/src/test/run-pass/issues/issue-17771.rs b/src/test/run-pass/issues/issue-17771.rs index 7eea5ce6589..2f6464668c2 100644 --- a/src/test/run-pass/issues/issue-17771.rs +++ b/src/test/run-pass/issues/issue-17771.rs @@ -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>) { diff --git a/src/test/run-pass/issues/issue-17897.rs b/src/test/run-pass/issues/issue-17897.rs index 291bd3f1718..6873c7ccb7f 100644 --- a/src/test/run-pass/issues/issue-17897.rs +++ b/src/test/run-pass/issues/issue-17897.rs @@ -1,5 +1,5 @@ // run-pass -fn action(mut cb: Box usize>) -> usize { +fn action(mut cb: Box usize>) -> usize { cb(1) } diff --git a/src/test/run-pass/issues/issue-20055-box-trait.rs b/src/test/run-pass/issues/issue-20055-box-trait.rs index cb7b5a638fc..772cd9d7eda 100644 --- a/src/test/run-pass/issues/issue-20055-box-trait.rs +++ b/src/test/run-pass/issues/issue-20055-box-trait.rs @@ -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 = match 3 { + let _: Box = match 3 { 1 => box_1(), 2 => box_2(), 3 => box_3(), diff --git a/src/test/run-pass/issues/issue-20575.rs b/src/test/run-pass/issues/issue-20575.rs index 95273edcf7e..0ca67d9dc71 100644 --- a/src/test/run-pass/issues/issue-20575.rs +++ b/src/test/run-pass/issues/issue-20575.rs @@ -4,7 +4,7 @@ // pretty-expanded FIXME #23616 fn main() { - let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; + let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; let _: Option> = functions.iter().map(|f| (*f)()).collect(); } diff --git a/src/test/run-pass/issues/issue-20676.rs b/src/test/run-pass/issues/issue-20676.rs index 27bbff09a00..2bc5034960a 100644 --- a/src/test/run-pass/issues/issue-20676.rs +++ b/src/test/run-pass/issues/issue-20676.rs @@ -7,6 +7,6 @@ use std::fmt; fn main() { - let a: &fmt::Debug = &1; + let a: &dyn fmt::Debug = &1; format!("{:?}", a); } diff --git a/src/test/run-pass/issues/issue-20953.rs b/src/test/run-pass/issues/issue-20953.rs index f5c743d0d82..4ec7e3195eb 100644 --- a/src/test/run-pass/issues/issue-20953.rs +++ b/src/test/run-pass/issues/issue-20953.rs @@ -2,11 +2,11 @@ #![allow(unused_mut)] #![allow(unused_variables)] fn main() { - let mut shrinker: Box> = Box::new(vec![1].into_iter()); + let mut shrinker: Box> = Box::new(vec![1].into_iter()); println!("{:?}", shrinker.next()); for v in shrinker { assert!(false); } - let mut shrinker: &mut Iterator = &mut vec![1].into_iter(); + let mut shrinker: &mut dyn Iterator = &mut vec![1].into_iter(); println!("{:?}", shrinker.next()); for v in shrinker { assert!(false); } } diff --git a/src/test/run-pass/issues/issue-21058.rs b/src/test/run-pass/issues/issue-21058.rs index e0cf26f7034..0483e62fd21 100644 --- a/src/test/run-pass/issues/issue-21058.rs +++ b/src/test/run-pass/issues/issue-21058.rs @@ -13,7 +13,7 @@ fn main() { // str std::intrinsics::type_name::(), // Trait - std::intrinsics::type_name::(), + std::intrinsics::type_name::(), // Newtype std::intrinsics::type_name::(), // DST diff --git a/src/test/run-pass/issues/issue-21361.rs b/src/test/run-pass/issues/issue-21361.rs index 5297a4a7b29..c970e77abb7 100644 --- a/src/test/run-pass/issues/issue-21361.rs +++ b/src/test/run-pass/issues/issue-21361.rs @@ -2,10 +2,10 @@ fn main() { let v = vec![1, 2, 3]; - let boxed: Box> = Box::new(v.into_iter()); + let boxed: Box> = Box::new(v.into_iter()); assert_eq!(boxed.max(), Some(3)); let v = vec![1, 2, 3]; - let boxed: &mut Iterator = &mut v.into_iter(); + let boxed: &mut dyn Iterator = &mut v.into_iter(); assert_eq!(boxed.max(), Some(3)); } diff --git a/src/test/run-pass/issues/issue-21655.rs b/src/test/run-pass/issues/issue-21655.rs index cddd48349f9..d1cd4ec7b8a 100644 --- a/src/test/run-pass/issues/issue-21655.rs +++ b/src/test/run-pass/issues/issue-21655.rs @@ -1,6 +1,6 @@ // run-pass -fn test(it: &mut Iterator) { +fn test(it: &mut dyn Iterator) { for x in it { assert_eq!(x, 1) } diff --git a/src/test/run-pass/issues/issue-2190-1.rs b/src/test/run-pass/issues/issue-2190-1.rs index 34a80ab0051..e67a924b9ee 100644 --- a/src/test/run-pass/issues/issue-2190-1.rs +++ b/src/test/run-pass/issues/issue-2190-1.rs @@ -9,11 +9,11 @@ use std::thread::Builder; static generations: usize = 1024+256+128+49; -fn spawn(mut f: Box) { +fn spawn(mut f: Box) { Builder::new().stack_size(32 * 1024).spawn(move|| f()); } -fn child_no(x: usize) -> Box { +fn child_no(x: usize) -> Box { Box::new(move|| { if x < generations { spawn(child_no(x+1)); diff --git a/src/test/run-pass/issues/issue-22346.rs b/src/test/run-pass/issues/issue-22346.rs index b728911e541..5f6d9dcc9ae 100644 --- a/src/test/run-pass/issues/issue-22346.rs +++ b/src/test/run-pass/issues/issue-22346.rs @@ -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 + 'a> { +fn testcase<'a>() -> Box + 'a> { return Box::new((0..3).map(|i| { return i; })); } diff --git a/src/test/run-pass/issues/issue-2288.rs b/src/test/run-pass/issues/issue-2288.rs index 963e7e62c7f..c74e53fca60 100644 --- a/src/test/run-pass/issues/issue-2288.rs +++ b/src/test/run-pass/issues/issue-2288.rs @@ -23,13 +23,13 @@ fn foo(b: A) -> foo { } } -fn f(x: Box>, a: A) { +fn f(x: Box>, a: A) { x.chowder(a); } pub fn main() { let c = foo(42); - let d: Box> = box c as Box>; + let d: Box> = box c as Box>; f(d, c.x); } diff --git a/src/test/run-pass/issues/issue-23261.rs b/src/test/run-pass/issues/issue-23261.rs index 0b34653a345..e21f86351ee 100644 --- a/src/test/run-pass/issues/issue-23261.rs +++ b/src/test/run-pass/issues/issue-23261.rs @@ -41,7 +41,7 @@ fn check_both(val: &Foo<[u8]>) { } } -fn check_trait_obj(val: &Foo) { +fn check_trait_obj(val: &Foo) { 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 = &Foo { a: 32, inner: 32 }; + let foo: &Foo = &Foo { a: 32, inner: 32 }; check_trait_obj(foo); } diff --git a/src/test/run-pass/issues/issue-23485.rs b/src/test/run-pass/issues/issue-23485.rs index a55846f40df..1dd3d9293bc 100644 --- a/src/test/run-pass/issues/issue-23485.rs +++ b/src/test/run-pass/issues/issue-23485.rs @@ -45,6 +45,6 @@ impl Iterator for Counter { } fn main() { - let mut x: Box> = Box::new(Counter { value: 22 }); + let mut x: Box> = Box::new(Counter { value: 22 }); assert_eq!(x.next().unwrap().value, 22); } diff --git a/src/test/run-pass/issues/issue-24010.rs b/src/test/run-pass/issues/issue-24010.rs index 1f68d47d97b..264e1ee22cd 100644 --- a/src/test/run-pass/issues/issue-24010.rs +++ b/src/test/run-pass/issues/issue-24010.rs @@ -2,7 +2,7 @@ trait Foo: Fn(i32) -> i32 + Send {} impl i32 + Send> Foo for T {} -fn wants_foo(f: Box) -> i32 { +fn wants_foo(f: Box) -> i32 { f(42) } diff --git a/src/test/run-pass/issues/issue-24086.rs b/src/test/run-pass/issues/issue-24086.rs index 86fa5a6f368..54622afbcfc 100644 --- a/src/test/run-pass/issues/issue-24086.rs +++ b/src/test/run-pass/issues/issue-24086.rs @@ -7,8 +7,8 @@ pub struct Registry<'a> { } pub struct Listener<'a> { - pub announce: Option>, - pub remove: Option>, + pub announce: Option>, + pub remove: Option>, } impl<'a> Drop for Registry<'a> { diff --git a/src/test/run-pass/issues/issue-25339.rs b/src/test/run-pass/issues/issue-25339.rs index 602f458e4cf..6f8ec700951 100644 --- a/src/test/run-pass/issues/issue-25339.rs +++ b/src/test/run-pass/issues/issue-25339.rs @@ -12,7 +12,7 @@ pub trait Routing { pub trait ToRouting { type Input; - type Routing : ?Sized = Routing; + type Routing : ?Sized = dyn Routing; fn to_routing(self) -> Self::Routing; } diff --git a/src/test/run-pass/issues/issue-25515.rs b/src/test/run-pass/issues/issue-25515.rs index 75af16d8dda..e7b9ea3acfc 100644 --- a/src/test/run-pass/issues/issue-25515.rs +++ b/src/test/run-pass/issues/issue-25515.rs @@ -13,7 +13,7 @@ fn main() { let mut drops = 0; { - let _: Rc = Rc::new(Foo(&mut drops)); + let _: Rc = Rc::new(Foo(&mut drops)); } assert_eq!(1, drops); diff --git a/src/test/run-pass/issues/issue-25549-multiple-drop.rs b/src/test/run-pass/issues/issue-25549-multiple-drop.rs index db9261f6ef4..25a2da707dc 100644 --- a/src/test/run-pass/issues/issue-25549-multiple-drop.rs +++ b/src/test/run-pass/issues/issue-25549-multiple-drop.rs @@ -25,7 +25,7 @@ fn main() { drops = 0; { - let y = &Holder(Foo(&mut drops)) as &Holder; + let y = &Holder(Foo(&mut drops)) as &Holder; // this used to cause an extra drop of the Foo instance let x = &y.0; } diff --git a/src/test/run-pass/issues/issue-25757.rs b/src/test/run-pass/issues/issue-25757.rs index caade6defdd..ec1864d7deb 100644 --- a/src/test/run-pass/issues/issue-25757.rs +++ b/src/test/run-pass/issues/issue-25757.rs @@ -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 }; diff --git a/src/test/run-pass/issues/issue-26641.rs b/src/test/run-pass/issues/issue-26641.rs index 297b1d689a6..4b6f2c2b3bc 100644 --- a/src/test/run-pass/issues/issue-26641.rs +++ b/src/test/run-pass/issues/issue-26641.rs @@ -1,5 +1,5 @@ // run-pass -struct Parser<'a>(Box); +struct Parser<'a>(Box); fn main() { let _x = Parser(Box::new(|_|{})); diff --git a/src/test/run-pass/issues/issue-26709.rs b/src/test/run-pass/issues/issue-26709.rs index 84cd2137367..281ae13399d 100644 --- a/src/test/run-pass/issues/issue-26709.rs +++ b/src/test/run-pass/issues/issue-26709.rs @@ -11,7 +11,7 @@ fn main() { let mut x = 0; { let wrapper = Box::new(Wrapper(&mut x, 123)); - let _: Box> = wrapper; + let _: Box> = wrapper; } assert_eq!(432, x) } diff --git a/src/test/run-pass/issues/issue-26802.rs b/src/test/run-pass/issues/issue-26802.rs index c4aa70d5022..307a6716098 100644 --- a/src/test/run-pass/issues/issue-26802.rs +++ b/src/test/run-pass/issues/issue-26802.rs @@ -5,7 +5,7 @@ trait Foo<'a> { pub struct FooBar; impl Foo<'static> for FooBar {} -fn test(foobar: FooBar) -> Box> { +fn test(foobar: FooBar) -> Box> { Box::new(foobar) } diff --git a/src/test/run-pass/issues/issue-26805.rs b/src/test/run-pass/issues/issue-26805.rs index 950d98315d0..bcf8a673191 100644 --- a/src/test/run-pass/issues/issue-26805.rs +++ b/src/test/run-pass/issues/issue-26805.rs @@ -2,5 +2,5 @@ struct NonOrd; fn main() { - let _: Box> = Box::new(vec![NonOrd].into_iter()); + let _: Box> = Box::new(vec![NonOrd].into_iter()); } diff --git a/src/test/run-pass/issues/issue-26905.rs b/src/test/run-pass/issues/issue-26905.rs index 2f500d1c0d1..2d5827f476b 100644 --- a/src/test/run-pass/issues/issue-26905.rs +++ b/src/test/run-pass/issues/issue-26905.rs @@ -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> = x; + let _y: MyRc> = x; } diff --git a/src/test/run-pass/issues/issue-27268.rs b/src/test/run-pass/issues/issue-27268.rs index fccea452fbc..161e2d4d204 100644 --- a/src/test/run-pass/issues/issue-27268.rs +++ b/src/test/run-pass/issues/issue-27268.rs @@ -1,4 +1,4 @@ // run-pass fn main() { - const _C: &'static Fn() = &||{}; + const _C: &'static dyn Fn() = &||{}; } diff --git a/src/test/run-pass/issues/issue-2734.rs b/src/test/run-pass/issues/issue-2734.rs index fcb224e2d04..d449f6449aa 100644 --- a/src/test/run-pass/issues/issue-2734.rs +++ b/src/test/run-pass/issues/issue-2734.rs @@ -11,8 +11,8 @@ trait hax { } impl hax for A { } -fn perform_hax(x: Box) -> Box { - box x as Box +fn perform_hax(x: Box) -> Box { + box x as Box } fn deadcode() { diff --git a/src/test/run-pass/issues/issue-2735.rs b/src/test/run-pass/issues/issue-2735.rs index c48bedf14f7..794c7d4edaa 100644 --- a/src/test/run-pass/issues/issue-2735.rs +++ b/src/test/run-pass/issues/issue-2735.rs @@ -11,8 +11,8 @@ trait hax { } impl hax for A { } -fn perform_hax(x: Box) -> Box { - box x as Box +fn perform_hax(x: Box) -> Box { + box x as Box } fn deadcode() { diff --git a/src/test/run-pass/issues/issue-27890.rs b/src/test/run-pass/issues/issue-27890.rs index 0f6a932e4b8..9f85473380f 100644 --- a/src/test/run-pass/issues/issue-27890.rs +++ b/src/test/run-pass/issues/issue-27890.rs @@ -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); diff --git a/src/test/run-pass/issues/issue-2935.rs b/src/test/run-pass/issues/issue-2935.rs index 58ade32b250..11641ca7380 100644 --- a/src/test/run-pass/issues/issue-2935.rs +++ b/src/test/run-pass/issues/issue-2935.rs @@ -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); + let z: Box<_> = box (box true as Box); // x.f(); // y.f(); // (*z).f(); diff --git a/src/test/run-pass/issues/issue-3052.rs b/src/test/run-pass/issues/issue-3052.rs index 927102981e7..ee2456da3e2 100644 --- a/src/test/run-pass/issues/issue-3052.rs +++ b/src/test/run-pass/issues/issue-3052.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // pretty-expanded FIXME #23616 -type Connection = Box) + 'static>; +type Connection = Box) + 'static>; fn f() -> Option { let mock_connection: Connection = Box::new(|_| {}); diff --git a/src/test/run-pass/issues/issue-30530.rs b/src/test/run-pass/issues/issue-30530.rs index 0ae270200a6..e837fc81721 100644 --- a/src/test/run-pass/issues/issue-30530.rs +++ b/src/test/run-pass/issues/issue-30530.rs @@ -8,7 +8,7 @@ pub enum Handler { Default, #[allow(dead_code)] - Custom(*mut Box), + Custom(*mut Box), } fn main() { @@ -16,7 +16,7 @@ fn main() { } #[inline(never)] -pub fn take(h: Handler, f: Box) -> Box { +pub fn take(h: Handler, f: Box) -> Box { unsafe { match h { Handler::Custom(ptr) => *Box::from_raw(ptr), diff --git a/src/test/run-pass/issues/issue-30615.rs b/src/test/run-pass/issues/issue-30615.rs index 236a181fc1d..c718449d84e 100644 --- a/src/test/run-pass/issues/issue-30615.rs +++ b/src/test/run-pass/issues/issue-30615.rs @@ -1,5 +1,5 @@ // run-pass fn main() { - &0u8 as *const u8 as *const PartialEq; + &0u8 as *const u8 as *const dyn PartialEq; &[0u8] as *const [u8; 1] as *const [u8]; } diff --git a/src/test/run-pass/issues/issue-32389.rs b/src/test/run-pass/issues/issue-32389.rs index 6824c66cb37..cc94cc819d6 100644 --- a/src/test/run-pass/issues/issue-32389.rs +++ b/src/test/run-pass/issues/issue-32389.rs @@ -2,7 +2,7 @@ fn foo() -> 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); } diff --git a/src/test/run-pass/issues/issue-33387.rs b/src/test/run-pass/issues/issue-33387.rs index 792ff95200a..499fa7c1f27 100644 --- a/src/test/run-pass/issues/issue-33387.rs +++ b/src/test/run-pass/issues/issue-33387.rs @@ -15,18 +15,18 @@ impl Foo for [u8; 2] { struct Bar(T); -fn unsize_fat_ptr<'a>(x: &'a Bar) -> &'a Bar { +fn unsize_fat_ptr<'a>(x: &'a Bar) -> &'a Bar { x } -fn unsize_nested_fat_ptr(x: Arc) -> Arc { +fn unsize_nested_fat_ptr(x: Arc) -> Arc { x } fn main() { - let x: Box> = Box::new(Bar([1,2])); + let x: Box> = Box::new(Bar([1,2])); assert_eq!(unsize_fat_ptr(&*x).0.get(), [1, 2]); - let x: Arc = Arc::new([3, 4]); + let x: Arc = Arc::new([3, 4]); assert_eq!(unsize_nested_fat_ptr(x).get(), [3, 4]); } diff --git a/src/test/run-pass/issues/issue-33461.rs b/src/test/run-pass/issues/issue-33461.rs index 9c6c5bfe78c..4e01d4d3061 100644 --- a/src/test/run-pass/issues/issue-33461.rs +++ b/src/test/run-pass/issues/issue-33461.rs @@ -24,5 +24,5 @@ impl Shape

for TheType { fn main() { let ball = TheType { t: PhantomData }; - let handle: &Shape<()> = &ball; + let handle: &dyn Shape<()> = &ball; } diff --git a/src/test/run-pass/issues/issue-34503.rs b/src/test/run-pass/issues/issue-34503.rs index 1fb4b8759bd..26e7358408f 100644 --- a/src/test/run-pass/issues/issue-34503.rs +++ b/src/test/run-pass/issues/issue-34503.rs @@ -7,5 +7,5 @@ fn main() { where Option: Ord { *x < *x } } impl Foo for () {} - let _ = &() as &Foo; + let _ = &() as &dyn Foo; } diff --git a/src/test/run-pass/issues/issue-35815.rs b/src/test/run-pass/issues/issue-35815.rs index 70e0ed9f7ce..05fd1b15d43 100644 --- a/src/test/run-pass/issues/issue-35815.rs +++ b/src/test/run-pass/issues/issue-35815.rs @@ -10,6 +10,6 @@ struct Foo { fn main() { let foo: &Foo = &Foo { a: 1, b: false, c: 2i32 }; - let foo_unsized: &Foo = foo; + let foo_unsized: &Foo = foo; assert_eq!(mem::size_of_val(foo), mem::size_of_val(foo_unsized)); } diff --git a/src/test/run-pass/issues/issue-36260.rs b/src/test/run-pass/issues/issue-36260.rs index 728dd5ec8d0..d96dc80ea71 100644 --- a/src/test/run-pass/issues/issue-36260.rs +++ b/src/test/run-pass/issues/issue-36260.rs @@ -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 create_fn() -> Box { let text = String::new(); Box::new(move || { let _ = &text; }) diff --git a/src/test/run-pass/issues/issue-36786-resolve-call.rs b/src/test/run-pass/issues/issue-36786-resolve-call.rs index 38461db544f..e5341ba7dbe 100644 --- a/src/test/run-pass/issues/issue-36786-resolve-call.rs +++ b/src/test/run-pass/issues/issue-36786-resolve-call.rs @@ -3,6 +3,6 @@ // correctly fn main() { - let x : Vec> = vec![Box::new(|| ())]; + let x : Vec> = vec![Box::new(|| ())]; x[0]() } diff --git a/src/test/run-pass/issues/issue-3702.rs b/src/test/run-pass/issues/issue-3702.rs index 1420dff063c..f48d549b3eb 100644 --- a/src/test/run-pass/issues/issue-3702.rs +++ b/src/test/run-pass/issues/issue-3702.rs @@ -6,7 +6,7 @@ pub fn main() { fn to_string(&self) -> String; } - fn to_string(t: Box) { + fn to_string(t: Box) { println!("{}", (*t).to_string()); } diff --git a/src/test/run-pass/issues/issue-3794.rs b/src/test/run-pass/issues/issue-3794.rs index d6af65f787d..408d8d866d8 100644 --- a/src/test/run-pass/issues/issue-3794.rs +++ b/src/test/run-pass/issues/issue-3794.rs @@ -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 = box S { s: 5 }; print_s(&*s); - let t: Box = s as Box; + let t: Box = s as Box; print_t(&*t); } diff --git a/src/test/run-pass/issues/issue-39292.rs b/src/test/run-pass/issues/issue-39292.rs index 0b8139dd795..968cf08916f 100644 --- a/src/test/run-pass/issues/issue-39292.rs +++ b/src/test/run-pass/issues/issue-39292.rs @@ -13,5 +13,5 @@ trait Bar: for<'a> Foo<&'a ()> { } impl Bar for () {} fn main() { - (&() as &Bar).print(); // Segfault + (&() as &dyn Bar).print(); // Segfault } diff --git a/src/test/run-pass/issues/issue-39823.rs b/src/test/run-pass/issues/issue-39823.rs index 0dfa8a75c4f..148cf527e7c 100644 --- a/src/test/run-pass/issues/issue-39823.rs +++ b/src/test/run-pass/issues/issue-39823.rs @@ -11,15 +11,15 @@ struct LocalC(u32); struct LocalG(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 = &LocalG; + let virtual_localg : &dyn Fn(_) -> LocalG = &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 = &RemoteG; + let virtual_remoteg : &dyn Fn(_) -> RemoteG = &RemoteG; assert_eq!(virtual_remoteg(1), RemoteG(1)); } diff --git a/src/test/run-pass/issues/issue-41053.rs b/src/test/run-pass/issues/issue-41053.rs index cd7a0a22623..967edfd4415 100644 --- a/src/test/run-pass/issues/issue-41053.rs +++ b/src/test/run-pass/issues/issue-41053.rs @@ -6,8 +6,8 @@ pub trait Trait { fn foo(&self) {} } pub struct Foo; impl Iterator for Foo { - type Item = Box; - fn next(&mut self) -> Option> { + type Item = Box; + fn next(&mut self) -> Option> { extern crate issue_41053; impl ::Trait for issue_41053::Test { fn foo(&self) {} diff --git a/src/test/run-pass/issues/issue-41744.rs b/src/test/run-pass/issues/issue-41744.rs index edc4354b253..dcdd1c21ee5 100644 --- a/src/test/run-pass/issues/issue-41744.rs +++ b/src/test/run-pass/issues/issue-41744.rs @@ -3,5 +3,5 @@ trait Tc {} impl Tc for bool {} fn main() { - let _: &[&Tc] = &[&true]; + let _: &[&dyn Tc] = &[&true]; } diff --git a/src/test/run-pass/issues/issue-42210.rs b/src/test/run-pass/issues/issue-42210.rs index cf4a698f516..318e3099f98 100644 --- a/src/test/run-pass/issues/issue-42210.rs +++ b/src/test/run-pass/issues/issue-42210.rs @@ -12,9 +12,9 @@ struct Bar; trait Baz { } -impl Foo for (Bar, Baz) { } +impl Foo for (Bar, dyn Baz) { } fn main() { - <(Bar, Baz) as Foo>::foo() + <(Bar, dyn Baz) as Foo>::foo() } diff --git a/src/test/run-pass/issues/issue-43132.rs b/src/test/run-pass/issues/issue-43132.rs index 726a86142f6..c886f4b0a2d 100644 --- a/src/test/run-pass/issues/issue-43132.rs +++ b/src/test/run-pass/issues/issue-43132.rs @@ -6,7 +6,7 @@ fn main() { fn foo() { let b = mk::< - Forward<(Box>,)>, + Forward<(Box>,)>, >(); b.map_err(|_| ()).join(); } diff --git a/src/test/run-pass/issues/issue-4333.rs b/src/test/run-pass/issues/issue-4333.rs index ae9f4c8bdb5..3df319b683f 100644 --- a/src/test/run-pass/issues/issue-4333.rs +++ b/src/test/run-pass/issues/issue-4333.rs @@ -5,6 +5,6 @@ use std::io; pub fn main() { - let stdout = &mut io::stdout() as &mut io::Write; + let stdout = &mut io::stdout() as &mut dyn io::Write; stdout.write(b"Hello!"); } diff --git a/src/test/run-pass/issues/issue-47638.rs b/src/test/run-pass/issues/issue-47638.rs index 357364ee612..a1ed3c36544 100644 --- a/src/test/run-pass/issues/issue-47638.rs +++ b/src/test/run-pass/issues/issue-47638.rs @@ -1,10 +1,10 @@ // run-pass #![allow(unused_variables)] -fn id<'c, 'b>(f: &'c &'b Fn(&i32)) -> &'c &'b Fn(&'static i32) { +fn id<'c, 'b>(f: &'c &'b dyn Fn(&i32)) -> &'c &'b dyn Fn(&'static i32) { f } fn main() { - let f: &Fn(&i32) = &|x| {}; + let f: &dyn Fn(&i32) = &|x| {}; id(&f); } diff --git a/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs b/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs index 457fca3fedf..fc869ae4fec 100644 --- a/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs +++ b/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs @@ -23,12 +23,12 @@ impl Debuggable for Thing { fn debug_name(&self) -> String { self.name.clone() } } -fn print_name(x: &Debuggable) +fn print_name(x: &dyn Debuggable) { println!("debug_name = {}", x.debug_name()); } pub fn main() { let thing = Thing::new(); - print_name(&thing as &Debuggable); + print_name(&thing as &dyn Debuggable); } diff --git a/src/test/run-pass/issues/issue-5192.rs b/src/test/run-pass/issues/issue-5192.rs index 74d8d861a7d..5a83d1c2ff9 100644 --- a/src/test/run-pass/issues/issue-5192.rs +++ b/src/test/run-pass/issues/issue-5192.rs @@ -24,12 +24,12 @@ impl EventLoop for UvEventLoop { } pub struct Scheduler { - event_loop: Box, + event_loop: Box, } impl Scheduler { - pub fn new(event_loop: Box) -> Scheduler { + pub fn new(event_loop: Box) -> Scheduler { Scheduler { event_loop: event_loop, } @@ -37,5 +37,5 @@ impl Scheduler { } pub fn main() { - let _sched = Scheduler::new(box UvEventLoop::new() as Box); + let _sched = Scheduler::new(box UvEventLoop::new() as Box); } diff --git a/src/test/run-pass/issues/issue-5666.rs b/src/test/run-pass/issues/issue-5666.rs index bf919ed5b10..aa513277830 100644 --- a/src/test/run-pass/issues/issue-5666.rs +++ b/src/test/run-pass/issues/issue-5666.rs @@ -19,7 +19,7 @@ impl Barks for Dog { pub fn main() { let snoopy = box Dog{name: "snoopy".to_string()}; let bubbles = box Dog{name: "bubbles".to_string()}; - let barker = [snoopy as Box, bubbles as Box]; + let barker = [snoopy as Box, bubbles as Box]; for pup in &barker { println!("{}", pup.bark()); diff --git a/src/test/run-pass/issues/issue-5708.rs b/src/test/run-pass/issues/issue-5708.rs index d3a2858873c..6fe9943d368 100644 --- a/src/test/run-pass/issues/issue-5708.rs +++ b/src/test/run-pass/issues/issue-5708.rs @@ -21,11 +21,11 @@ impl Inner for isize { } struct Outer<'a> { - inner: &'a (Inner+'a) + inner: &'a (dyn Inner+'a) } impl<'a> Outer<'a> { - fn new(inner: &Inner) -> Outer { + fn new(inner: &dyn Inner) -> Outer { Outer { inner: inner } @@ -34,7 +34,7 @@ impl<'a> Outer<'a> { pub fn main() { let inner: isize = 5; - let outer = Outer::new(&inner as &Inner); + let outer = Outer::new(&inner as &dyn Inner); outer.inner.print(); } @@ -45,11 +45,11 @@ pub trait MyTrait { } pub struct MyContainer<'a, T:'a> { - foos: Vec<&'a (MyTrait+'a)> , + foos: Vec<&'a (dyn MyTrait+'a)> , } impl<'a, T> MyContainer<'a, T> { - pub fn add (&mut self, foo: &'a MyTrait) { + pub fn add (&mut self, foo: &'a dyn MyTrait) { self.foos.push(foo); } } diff --git a/src/test/run-pass/issues/issue-5988.rs b/src/test/run-pass/issues/issue-5988.rs index db77ca4375f..303fb4fbc94 100644 --- a/src/test/run-pass/issues/issue-5988.rs +++ b/src/test/run-pass/issues/issue-5988.rs @@ -19,6 +19,6 @@ impl T for A { fn main() { let a = A; - let br = &a as &B; + let br = &a as &dyn B; br.f(); } diff --git a/src/test/run-pass/issues/issue-6128.rs b/src/test/run-pass/issues/issue-6128.rs index f23a317c6ba..8859fbe6afb 100644 --- a/src/test/run-pass/issues/issue-6128.rs +++ b/src/test/run-pass/issues/issue-6128.rs @@ -20,5 +20,5 @@ impl Graph for HashMap { pub fn main() { let g : Box> = box HashMap::new(); - let _g2 : Box> = g as Box>; + let _g2 : Box> = g as Box>; } diff --git a/src/test/run-pass/issues/issue-6157.rs b/src/test/run-pass/issues/issue-6157.rs index 354797cb2a7..b7a44ed8623 100644 --- a/src/test/run-pass/issues/issue-6157.rs +++ b/src/test/run-pass/issues/issue-6157.rs @@ -9,7 +9,7 @@ impl OpInt for F where F: FnMut(isize, isize) -> isize { } } -fn squarei<'a>(x: isize, op: &'a mut OpInt) -> isize { op.call(x, x) } +fn squarei<'a>(x: isize, op: &'a mut dyn OpInt) -> isize { op.call(x, x) } fn muli(x:isize, y:isize) -> isize { x * y } @@ -17,7 +17,7 @@ pub fn main() { let mut f = |x, y| muli(x, y); { let g = &mut f; - let h = g as &mut OpInt; + let h = g as &mut dyn OpInt; squarei(3, h); } } diff --git a/src/test/run-pass/issues/issue-6318.rs b/src/test/run-pass/issues/issue-6318.rs index d416048265f..d8bd83f0dc6 100644 --- a/src/test/run-pass/issues/issue-6318.rs +++ b/src/test/run-pass/issues/issue-6318.rs @@ -4,7 +4,7 @@ #![feature(box_syntax)] pub enum Thing { - A(Box) + A(Box) } pub trait Foo { @@ -16,7 +16,7 @@ pub struct Struct; impl Foo for Struct {} pub fn main() { - match Thing::A(box Struct as Box) { + match Thing::A(box Struct as Box) { Thing::A(_a) => 0, }; } diff --git a/src/test/run-pass/issues/issue-7563.rs b/src/test/run-pass/issues/issue-7563.rs index 820fffd1056..c62405554b4 100644 --- a/src/test/run-pass/issues/issue-7563.rs +++ b/src/test/run-pass/issues/issue-7563.rs @@ -16,7 +16,7 @@ struct B<'a> { b: isize, pa: &'a A } } impl<'a> B<'a> { - fn get_pa(&self) -> &'a IDummy { self.pa as &'a IDummy } + fn get_pa(&self) -> &'a dyn IDummy { self.pa as &'a dyn IDummy } } pub fn main() { diff --git a/src/test/run-pass/issues/issue-7911.rs b/src/test/run-pass/issues/issue-7911.rs index cb7e009d074..de833324bd2 100644 --- a/src/test/run-pass/issues/issue-7911.rs +++ b/src/test/run-pass/issues/issue-7911.rs @@ -12,18 +12,18 @@ struct Foo { bar: Bar } impl FooBar for Bar {} trait Test { - fn get_immut(&self) -> &FooBar; - fn get_mut(&mut self) -> &mut FooBar; + fn get_immut(&self) -> &dyn FooBar; + fn get_mut(&mut self) -> &mut dyn FooBar; } macro_rules! generate_test { ($type_:path, $slf:ident, $field:expr) => ( impl Test for $type_ { - fn get_immut(&$slf) -> &FooBar { - &$field as &FooBar + fn get_immut(&$slf) -> &dyn FooBar { + &$field as &dyn FooBar } - fn get_mut(&mut $slf) -> &mut FooBar { - &mut $field as &mut FooBar + fn get_mut(&mut $slf) -> &mut dyn FooBar { + &mut $field as &mut dyn FooBar } } )} diff --git a/src/test/run-pass/issues/issue-8248.rs b/src/test/run-pass/issues/issue-8248.rs index 239c432e457..31a305c31be 100644 --- a/src/test/run-pass/issues/issue-8248.rs +++ b/src/test/run-pass/issues/issue-8248.rs @@ -7,9 +7,9 @@ trait A { struct B; impl A for B {} -fn foo(_: &mut A) {} +fn foo(_: &mut dyn A) {} pub fn main() { let mut b = B; - foo(&mut b as &mut A); + foo(&mut b as &mut dyn A); } diff --git a/src/test/run-pass/issues/issue-8249.rs b/src/test/run-pass/issues/issue-8249.rs index db49f354a39..d09dff3a697 100644 --- a/src/test/run-pass/issues/issue-8249.rs +++ b/src/test/run-pass/issues/issue-8249.rs @@ -9,10 +9,10 @@ struct B; impl A for B {} struct C<'a> { - foo: &'a mut (A+'a), + foo: &'a mut (dyn A+'a), } -fn foo(a: &mut A) { +fn foo(a: &mut dyn A) { C{ foo: a }; } diff --git a/src/test/run-pass/issues/issue-9129.rs b/src/test/run-pass/issues/issue-9129.rs index c81b9b1a10d..3d87e1c2037 100644 --- a/src/test/run-pass/issues/issue-9129.rs +++ b/src/test/run-pass/issues/issue-9129.rs @@ -20,7 +20,7 @@ fn Ident_new() -> Ident { Ident {name: 0x6789ABCD } } -pub fn light_fuse(fld: Box) { +pub fn light_fuse(fld: Box) { int3!(); let f = || { int3!(); @@ -30,6 +30,6 @@ pub fn light_fuse(fld: Box) { } pub fn main() { - let b = box S as Box; + let b = box S as Box; light_fuse(b); } diff --git a/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs b/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs index c4c95aa1aae..cc0dd4fc14a 100644 --- a/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs +++ b/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs @@ -52,7 +52,7 @@ impl Super for X { pub fn main() { let n = X; - let s = &n as &Super; + let s = &n as &dyn Super; assert_eq!(s.bar(),"super bar".to_string()); assert_eq!(s.foo(),"base foo".to_string()); assert_eq!(s.foo1(),"base foo1".to_string()); diff --git a/src/test/run-pass/issues/issue-9951.rs b/src/test/run-pass/issues/issue-9951.rs index 4e14bdbd734..2698a3b17c6 100644 --- a/src/test/run-pass/issues/issue-9951.rs +++ b/src/test/run-pass/issues/issue-9951.rs @@ -11,11 +11,11 @@ impl Bar for u8 { } fn main() { - let (a, b) = (&5u8 as &Bar, &9u8 as &Bar); - let (c, d): (&Bar, &Bar) = (a, b); + let (a, b) = (&5u8 as &dyn Bar, &9u8 as &dyn Bar); + let (c, d): (&dyn Bar, &dyn Bar) = (a, b); - let (a, b) = (Box::new(5u8) as Box, Box::new(9u8) as Box); - let (c, d): (&Bar, &Bar) = (&*a, &*b); + let (a, b) = (Box::new(5u8) as Box, Box::new(9u8) as Box); + let (c, d): (&dyn Bar, &dyn Bar) = (&*a, &*b); - let (c, d): (&Bar, &Bar) = (&5, &9); + let (c, d): (&dyn Bar, &dyn Bar) = (&5, &9); } diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index b77f7b5d782..42dc6a4b06e 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -3,7 +3,7 @@ struct A { a: Box } -fn foo() -> Box isize + 'static> { +fn foo() -> Box isize + 'static> { let k: Box<_> = Box::new(22); let _u = A {a: k.clone()}; let result = || 22; diff --git a/src/test/run-pass/macros/colorful-write-macros.rs b/src/test/run-pass/macros/colorful-write-macros.rs index aba4383c734..eb1872cc7f0 100644 --- a/src/test/run-pass/macros/colorful-write-macros.rs +++ b/src/test/run-pass/macros/colorful-write-macros.rs @@ -4,7 +4,7 @@ use std::io::Write; use std::fmt; struct Foo<'a> { - writer: &'a mut (Write+'a), + writer: &'a mut (dyn Write+'a), other: &'a str, } @@ -22,7 +22,7 @@ fn borrowing_writer_from_struct_and_formatting_struct_field(foo: Foo) { fn main() { let mut w = Vec::new(); - write!(&mut w as &mut Write, "").unwrap(); + write!(&mut w as &mut dyn Write, "").unwrap(); write!(&mut w, "").unwrap(); // should coerce println!("ok"); diff --git a/src/test/run-pass/macros/type-macros-simple.rs b/src/test/run-pass/macros/type-macros-simple.rs index 579b485a2a5..dd3ad2ef0ac 100644 --- a/src/test/run-pass/macros/type-macros-simple.rs +++ b/src/test/run-pass/macros/type-macros-simple.rs @@ -16,7 +16,7 @@ fn issue_36540() { let x: m!() = m!(); std::cell::Cell::::new(m!()); - impl std::ops::Index for Trait<(m!(), T)> + impl std::ops::Index for dyn Trait<(m!(), T)> where T: Trait { type Output = m!(); diff --git a/src/test/run-pass/methods/method-argument-inference-associated-type.rs b/src/test/run-pass/methods/method-argument-inference-associated-type.rs index b5ba1f94556..acd4a8465b0 100644 --- a/src/test/run-pass/methods/method-argument-inference-associated-type.rs +++ b/src/test/run-pass/methods/method-argument-inference-associated-type.rs @@ -10,13 +10,13 @@ pub trait Service { pub struct S(T); impl Service for ClientMap { - type Request = S>; + type Request = S>; fn call(&self, _req: Self::Request) {} } impl Service for ClientMap2 { - type Request = (Box,); + type Request = (Box,); fn call(&self, _req: Self::Request) {} } diff --git a/src/test/run-pass/mir/mir_codegen_calls.rs b/src/test/run-pass/mir/mir_codegen_calls.rs index 075d266d34d..fc0db03e3a9 100644 --- a/src/test/run-pass/mir/mir_codegen_calls.rs +++ b/src/test/run-pass/mir/mir_codegen_calls.rs @@ -42,7 +42,7 @@ fn test4(x: &Foo, a: isize) -> isize { x.extension_method(a) } -fn test5(x: &Bar, a: isize) -> isize { +fn test5(x: &dyn Bar, a: isize) -> isize { // Test calling method on trait object x.extension_method(a) } @@ -88,11 +88,11 @@ fn test_closure(f: &F, x: i32, y: i32) -> i32 f(x, y) } -fn test_fn_object(f: &Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { +fn test_fn_object(f: &dyn Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { f(x, y) } -fn test_fn_impl(f: &&Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { +fn test_fn_impl(f: &&dyn Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { // This call goes through the Fn implementation for &Fn provided in // core::ops::impls. It expands to a static Fn::call() that calls the // Fn::call() implementation of the object shim underneath. @@ -174,7 +174,7 @@ fn main() { let closure = |x: i32, y: i32| { r*(x + (y*2)) }; assert_eq!(test_fn_const_call(&closure), 294); assert_eq!(test_closure(&closure, 100, 1), 306); - let function_object = &closure as &Fn(i32, i32) -> i32; + let function_object = &closure as &dyn Fn(i32, i32) -> i32; assert_eq!(test_fn_object(function_object, 100, 2), 312); assert_eq!(test_fn_impl(&function_object, 100, 3), 318); assert_eq!(test_fn_direct_call(&closure, 100, 4), 324); diff --git a/src/test/run-pass/mir/mir_codegen_critical_edge.rs b/src/test/run-pass/mir/mir_codegen_critical_edge.rs index 03b111e93dd..5c1f1c3b701 100644 --- a/src/test/run-pass/mir/mir_codegen_critical_edge.rs +++ b/src/test/run-pass/mir/mir_codegen_critical_edge.rs @@ -37,7 +37,7 @@ where A: Iterator, B: Iterator } // Make sure we actually codegen a version of the function -pub fn do_stuff(mut f: Foo>, Box>>) { +pub fn do_stuff(mut f: Foo>, Box>>) { let _x = f.next(); } diff --git a/src/test/run-pass/mir/mir_coercions.rs b/src/test/run-pass/mir/mir_coercions.rs index b673345db70..f3dcc6b85fd 100644 --- a/src/test/run-pass/mir/mir_coercions.rs +++ b/src/test/run-pass/mir/mir_coercions.rs @@ -4,12 +4,12 @@ use std::ops::CoerceUnsized; use std::marker::Unsize; -fn identity_coercion(x: &(Fn(u32)->u32 + Send)) -> &Fn(u32)->u32 { +fn identity_coercion(x: &(dyn Fn(u32)->u32 + Send)) -> &dyn Fn(u32)->u32 { x } fn fn_coercions(f: &fn(u32) -> u32) -> (unsafe fn(u32) -> u32, - &(Fn(u32) -> u32+Send)) + &(dyn Fn(u32) -> u32+Send)) { (*f, f) } @@ -35,8 +35,8 @@ fn coerce_triv_ptr_wrapper(p: TrivPtrWrapper<[u8; 3]>) -> TrivPtrWrapper<[u8]> { p } -fn coerce_fat_ptr_wrapper(p: PtrWrapper u32+Send>) - -> PtrWrapper u32> { +fn coerce_fat_ptr_wrapper(p: PtrWrapper u32+Send>) + -> PtrWrapper u32> { p } @@ -65,7 +65,7 @@ fn main() { let z = coerce_fat_ptr_wrapper(PtrWrapper(2,3,(),&square_local)); assert_eq!((z.3)(6), 36); - let z: PtrWrapper u32> = + let z: PtrWrapper u32> = coerce_ptr_wrapper_poly(PtrWrapper(2,3,(),&square_local)); assert_eq!((z.3)(6), 36); } diff --git a/src/test/run-pass/mir/mir_raw_fat_ptr.rs b/src/test/run-pass/mir/mir_raw_fat_ptr.rs index 328c8c502cb..6583852aa9b 100644 --- a/src/test/run-pass/mir/mir_raw_fat_ptr.rs +++ b/src/test/run-pass/mir/mir_raw_fat_ptr.rs @@ -63,7 +63,7 @@ fn compare_au8(a: *const [u8], b: *const [u8]) -> ComparisonResults { } } -fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults { +fn compare_foo<'a>(a: *const (dyn Foo+'a), b: *const (dyn Foo+'a)) -> ComparisonResults { ComparisonResults { lt: a < b, le: a <= b, @@ -74,7 +74,7 @@ fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults } } -fn simple_eq<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> bool { +fn simple_eq<'a>(a: *const (dyn Foo+'a), b: *const (dyn Foo+'a)) -> bool { let result = a == b; result } @@ -128,7 +128,7 @@ fn main() { let u32_ = (4u32, 5u32); // check ordering for ptrs - let buf: &mut [*const Foo] = &mut [ + let buf: &mut [*const dyn Foo] = &mut [ &u8_, &u8_.0, &u32_, &u32_.0, ]; diff --git a/src/test/run-pass/new-box.rs b/src/test/run-pass/new-box.rs index b35c5445a44..5539518c370 100644 --- a/src/test/run-pass/new-box.rs +++ b/src/test/run-pass/new-box.rs @@ -18,13 +18,13 @@ impl Trait for Struct { } } -fn g(x: Box) { +fn g(x: Box) { x.printme(); - let y: &Trait = &*x; + let y: &dyn Trait = &*x; y.printme(); } fn main() { f(box 1234); - g(box Struct as Box); + g(box Struct as Box); } diff --git a/src/test/run-pass/newlambdas-ret-infer.rs b/src/test/run-pass/newlambdas-ret-infer.rs index 969868486e6..79c9f7dc011 100644 --- a/src/test/run-pass/newlambdas-ret-infer.rs +++ b/src/test/run-pass/newlambdas-ret-infer.rs @@ -4,7 +4,7 @@ // pretty-expanded FIXME #23616 -fn unique() -> Box { return Box::new(|| ()); } +fn unique() -> Box { return Box::new(|| ()); } pub fn main() { } diff --git a/src/test/run-pass/newlambdas-ret-infer2.rs b/src/test/run-pass/newlambdas-ret-infer2.rs index 676b3507c57..104f5be7767 100644 --- a/src/test/run-pass/newlambdas-ret-infer2.rs +++ b/src/test/run-pass/newlambdas-ret-infer2.rs @@ -4,7 +4,7 @@ // pretty-expanded FIXME #23616 -fn unique() -> Box { Box::new(|| ()) } +fn unique() -> Box { Box::new(|| ()) } pub fn main() { } diff --git a/src/test/run-pass/object-lifetime-default-default-to-static.rs b/src/test/run-pass/object-lifetime-default-default-to-static.rs index cf836c1a7de..cd61dea0378 100644 --- a/src/test/run-pass/object-lifetime-default-default-to-static.rs +++ b/src/test/run-pass/object-lifetime-default-default-to-static.rs @@ -10,23 +10,23 @@ trait Test { } struct SomeStruct { - t: Box, - u: Box, + t: Box, + u: Box, } -fn a(t: Box, mut ss: SomeStruct) { +fn a(t: Box, mut ss: SomeStruct) { ss.t = t; } -fn b(t: Box, mut ss: SomeStruct) { +fn b(t: Box, mut ss: SomeStruct) { ss.t = t; } -fn c(t: Box, mut ss: SomeStruct) { +fn c(t: Box, mut ss: SomeStruct) { ss.u = t; } -fn d(t: Box, mut ss: SomeStruct) { +fn d(t: Box, mut ss: SomeStruct) { ss.u = t; } diff --git a/src/test/run-pass/object-lifetime-default-from-rptr-box.rs b/src/test/run-pass/object-lifetime-default-from-rptr-box.rs index 3f69c927488..9212f2802c0 100644 --- a/src/test/run-pass/object-lifetime-default-from-rptr-box.rs +++ b/src/test/run-pass/object-lifetime-default-from-rptr-box.rs @@ -10,21 +10,21 @@ trait Test { } struct SomeStruct<'a> { - t: &'a Box, - u: &'a Box, + t: &'a Box, + u: &'a Box, } -fn a<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { +fn a<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { ss.t = t; } -fn b<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { +fn b<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { ss.u = t; } // see also compile-fail/object-lifetime-default-from-rptr-box-error.rs -fn d<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { +fn d<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { ss.u = t; } diff --git a/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs b/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs index dc9e292f0de..061f3a116fc 100644 --- a/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs +++ b/src/test/run-pass/object-lifetime-default-from-rptr-mut.rs @@ -10,23 +10,23 @@ trait Test { } struct SomeStruct<'a> { - t: &'a mut Test, - u: &'a mut (Test+'a), + t: &'a mut dyn Test, + u: &'a mut (dyn Test+'a), } -fn a<'a>(t: &'a mut Test, mut ss: SomeStruct<'a>) { +fn a<'a>(t: &'a mut dyn Test, mut ss: SomeStruct<'a>) { ss.t = t; } -fn b<'a>(t: &'a mut Test, mut ss: SomeStruct<'a>) { +fn b<'a>(t: &'a mut dyn Test, mut ss: SomeStruct<'a>) { ss.u = t; } -fn c<'a>(t: &'a mut (Test+'a), mut ss: SomeStruct<'a>) { +fn c<'a>(t: &'a mut (dyn Test+'a), mut ss: SomeStruct<'a>) { ss.t = t; } -fn d<'a>(t: &'a mut (Test+'a), mut ss: SomeStruct<'a>) { +fn d<'a>(t: &'a mut (dyn Test+'a), mut ss: SomeStruct<'a>) { ss.u = t; } diff --git a/src/test/run-pass/object-lifetime-default-from-rptr.rs b/src/test/run-pass/object-lifetime-default-from-rptr.rs index 061f71b9ae6..cfa4af0d7a5 100644 --- a/src/test/run-pass/object-lifetime-default-from-rptr.rs +++ b/src/test/run-pass/object-lifetime-default-from-rptr.rs @@ -12,30 +12,30 @@ trait Test { } struct SomeStruct<'a> { - t: &'a Test, - u: &'a (Test+'a), + t: &'a dyn Test, + u: &'a (dyn Test+'a), } -fn a<'a>(t: &'a Test, mut ss: SomeStruct<'a>) { +fn a<'a>(t: &'a dyn Test, mut ss: SomeStruct<'a>) { ss.t = t; } -fn b<'a>(t: &'a Test, mut ss: SomeStruct<'a>) { +fn b<'a>(t: &'a dyn Test, mut ss: SomeStruct<'a>) { ss.u = t; } -fn c<'a>(t: &'a (Test+'a), mut ss: SomeStruct<'a>) { +fn c<'a>(t: &'a (dyn Test+'a), mut ss: SomeStruct<'a>) { ss.t = t; } -fn d<'a>(t: &'a (Test+'a), mut ss: SomeStruct<'a>) { +fn d<'a>(t: &'a (dyn Test+'a), mut ss: SomeStruct<'a>) { ss.u = t; } -fn e<'a>(_: &'a (Display+'static)) {} +fn e<'a>(_: &'a (dyn Display+'static)) {} fn main() { // Inside a function body, we can just infer both // lifetimes, to allow &'tmp (Display+'static). - e(&0 as &Display); + e(&0 as &dyn Display); } diff --git a/src/test/run-pass/object-method-numbering.rs b/src/test/run-pass/object-method-numbering.rs index 455af78c7a0..7f24ab2cbb5 100644 --- a/src/test/run-pass/object-method-numbering.rs +++ b/src/test/run-pass/object-method-numbering.rs @@ -21,7 +21,7 @@ impl SomeTrait for i32 { fn main() { let x = 22; - let x1: &SomeTrait = &x; + let x1: &dyn SomeTrait = &x; let y = get_int(x1); assert_eq!(x, y); } diff --git a/src/test/run-pass/objects-coerce-freeze-borrored.rs b/src/test/run-pass/objects-coerce-freeze-borrored.rs index 872b9d3e916..47196f108c0 100644 --- a/src/test/run-pass/objects-coerce-freeze-borrored.rs +++ b/src/test/run-pass/objects-coerce-freeze-borrored.rs @@ -17,7 +17,7 @@ impl Foo for usize { } } -fn do_it_mut(obj: &mut Foo) { +fn do_it_mut(obj: &mut dyn Foo) { let x = obj.bar(); let y = obj.foo(); assert_eq!(x, y); @@ -25,14 +25,14 @@ fn do_it_mut(obj: &mut Foo) { do_it_imm(obj, y); } -fn do_it_imm(obj: &Foo, v: usize) { +fn do_it_imm(obj: &dyn Foo, v: usize) { let y = obj.foo(); assert_eq!(v, y); } pub fn main() { let mut x: usize = 22; - let obj = &mut x as &mut Foo; + let obj = &mut x as &mut dyn Foo; do_it_mut(obj); do_it_imm(obj, 23); do_it_mut(obj); diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs index a96772bfb63..58327237494 100644 --- a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs +++ b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs @@ -20,10 +20,10 @@ impl FooTrait for BarStruct { } pub fn main() { - let foos: Vec> = vec![ - box BarStruct{ x: 0 } as Box, - box BarStruct{ x: 1 } as Box, - box BarStruct{ x: 2 } as Box + let foos: Vec> = vec![ + box BarStruct{ x: 0 } as Box, + box BarStruct{ x: 1 } as Box, + box BarStruct{ x: 2 } as Box ]; for i in 0..foos.len() { diff --git a/src/test/run-pass/objects-owned-object-owned-method.rs b/src/test/run-pass/objects-owned-object-owned-method.rs index 6ca5233b198..69984fbb62f 100644 --- a/src/test/run-pass/objects-owned-object-owned-method.rs +++ b/src/test/run-pass/objects-owned-object-owned-method.rs @@ -19,6 +19,6 @@ impl FooTrait for BarStruct { } pub fn main() { - let foo = box BarStruct{ x: 22 } as Box; + let foo = box BarStruct{ x: 22 } as Box; assert_eq!(22, foo.foo()); } diff --git a/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs b/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs index ff484418c1d..1afab9a1ffb 100644 --- a/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs +++ b/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs @@ -3,7 +3,7 @@ // This is a bit tricky due to rust-call ABI. -fn foo(f: &mut FnMut(isize) -> isize) -> isize { +fn foo(f: &mut dyn FnMut(isize) -> isize) -> isize { f(22) } diff --git a/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs b/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs index 0d0136bc29a..38087bc8710 100644 --- a/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs +++ b/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs @@ -3,7 +3,7 @@ // This is a bit tricky due to rust-call ABI. -fn foo(f: &mut FnMut(isize, isize) -> isize) -> isize { +fn foo(f: &mut dyn FnMut(isize, isize) -> isize) -> isize { f(1, 2) } diff --git a/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs b/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs index bbea6a909c8..9a7bfaa9bf4 100644 --- a/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs +++ b/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs @@ -3,7 +3,7 @@ // This is a bit tricky due to rust-call ABI. -fn foo(f: &mut FnMut() -> isize) -> isize { +fn foo(f: &mut dyn FnMut() -> isize) -> isize { f() } diff --git a/src/test/run-pass/panics/panic-safe.rs b/src/test/run-pass/panics/panic-safe.rs index 3798a4fc5cb..9867cc56406 100644 --- a/src/test/run-pass/panics/panic-safe.rs +++ b/src/test/run-pass/panics/panic-safe.rs @@ -33,7 +33,7 @@ fn main() { assert::>(); trait Trait: UnwindSafe {} - assert::>(); + assert::>(); fn bar() { assert::>(); diff --git a/src/test/run-pass/privacy/privacy-ns.rs b/src/test/run-pass/privacy/privacy-ns.rs index b1b03eae5db..c32e3f17880 100644 --- a/src/test/run-pass/privacy/privacy-ns.rs +++ b/src/test/run-pass/privacy/privacy-ns.rs @@ -28,19 +28,19 @@ fn test_unused1() { fn test_single1() { use foo1::Bar; - let _x: Box; + let _x: Box; } fn test_list1() { use foo1::{Bar,Baz}; - let _x: Box; + let _x: Box; } fn test_glob1() { use foo1::*; - let _x: Box; + let _x: Box; } // private type, public value @@ -93,21 +93,21 @@ fn test_single3() { use foo3::Bar; Bar(); - let _x: Box; + let _x: Box; } fn test_list3() { use foo3::{Bar,Baz}; Bar(); - let _x: Box; + let _x: Box; } fn test_glob3() { use foo3::*; Bar(); - let _x: Box; + let _x: Box; } fn main() { diff --git a/src/test/run-pass/raw-fat-ptr.rs b/src/test/run-pass/raw-fat-ptr.rs index df69db1cc9a..511a35b25a3 100644 --- a/src/test/run-pass/raw-fat-ptr.rs +++ b/src/test/run-pass/raw-fat-ptr.rs @@ -78,7 +78,7 @@ fn main() { let mut u32_ = (4u32, 5u32); // check ordering for ptrs - let buf: &mut [*const Foo] = &mut [ + let buf: &mut [*const dyn Foo] = &mut [ &u8_, &u8_.0, &u32_, &u32_.0, ]; @@ -90,7 +90,7 @@ fn main() { assert_inorder(buf); // check ordering for mut ptrs - let buf: &mut [*mut Foo] = &mut [ + let buf: &mut [*mut dyn Foo] = &mut [ &mut u8_, &mut u8_.0, &mut u32_, &mut u32_.0, ]; diff --git a/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs b/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs index 204f4f8130d..3815498f86f 100644 --- a/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs +++ b/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs @@ -9,7 +9,7 @@ trait Foo { fn dummy(&self) { } } -fn foo<'a>(x: Box) { +fn foo<'a>(x: Box) { } fn bar<'a, T: 'a>() { diff --git a/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs b/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs index 85c9c64c643..4b47ed8c6ae 100644 --- a/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs +++ b/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs @@ -12,8 +12,8 @@ impl<'a> SomeTrait for &'a isize { } } -fn make_object<'a,A:SomeTrait+'a>(v: A) -> Box { - box v as Box +fn make_object<'a,A:SomeTrait+'a>(v: A) -> Box { + box v as Box } fn main() { diff --git a/src/test/run-pass/regions/regions-copy-closure.rs b/src/test/run-pass/regions/regions-copy-closure.rs index 6545ddf72c7..43640079777 100644 --- a/src/test/run-pass/regions/regions-copy-closure.rs +++ b/src/test/run-pass/regions/regions-copy-closure.rs @@ -2,10 +2,10 @@ #![allow(non_camel_case_types)] struct closure_box<'a> { - cl: Box, + cl: Box, } -fn box_it<'a>(x: Box) -> closure_box<'a> { +fn box_it<'a>(x: Box) -> closure_box<'a> { closure_box {cl: x} } diff --git a/src/test/run-pass/regions/regions-debruijn-of-object.rs b/src/test/run-pass/regions/regions-debruijn-of-object.rs index 24c0cf53317..0b5510489fb 100644 --- a/src/test/run-pass/regions/regions-debruijn-of-object.rs +++ b/src/test/run-pass/regions/regions-debruijn-of-object.rs @@ -13,9 +13,9 @@ trait AstConv<'tcx> { fn tcx<'a>(&'a self) -> &'a ctxt<'tcx>; } -fn foo(conv: &AstConv) { } +fn foo(conv: &dyn AstConv) { } -fn bar<'tcx>(conv: &AstConv<'tcx>) { +fn bar<'tcx>(conv: &dyn AstConv<'tcx>) { foo(conv) } diff --git a/src/test/run-pass/regions/regions-early-bound-trait-param.rs b/src/test/run-pass/regions/regions-early-bound-trait-param.rs index c71e47db22d..cc2bde78d85 100644 --- a/src/test/run-pass/regions/regions-early-bound-trait-param.rs +++ b/src/test/run-pass/regions/regions-early-bound-trait-param.rs @@ -15,14 +15,14 @@ fn poly_invoke<'c, T: Trait<'c>>(x: &'c T) -> (isize, isize) { (l,s) } -fn object_invoke1<'d>(x: &'d Trait<'d>) -> (isize, isize) { +fn object_invoke1<'d>(x: &'d dyn Trait<'d>) -> (isize, isize) { let l = x.long(); let s = x.short(); (l,s) } struct Struct1<'e> { - f: &'e (Trait<'e>+'e) + f: &'e (dyn Trait<'e>+'e) } fn field_invoke1<'f, 'g>(x: &'g Struct1<'f>) -> (isize,isize) { @@ -32,10 +32,10 @@ fn field_invoke1<'f, 'g>(x: &'g Struct1<'f>) -> (isize,isize) { } struct Struct2<'h, 'i:'h> { - f: &'h (Trait<'i>+'h) + f: &'h (dyn Trait<'i>+'h) } -fn object_invoke2<'j, 'k>(x: &'k Trait<'j>) -> isize { +fn object_invoke2<'j, 'k>(x: &'k dyn Trait<'j>) -> isize { x.short() } @@ -70,10 +70,10 @@ impl<'s> Trait<'s> for (isize,isize) { } } -impl<'t> MakerTrait for Box+'static> { - fn mk() -> Box+'static> { +impl<'t> MakerTrait for Box+'static> { + fn mk() -> Box+'static> { let tup: Box<(isize, isize)> = box (4,5); - tup as Box + tup as Box } } @@ -105,7 +105,7 @@ impl<'t> RefMakerTrait<'t> for List<'t> { pub fn main() { let t = (2,3); - let o = &t as &Trait; + let o = &t as &dyn Trait; let s1 = Struct1 { f: o }; let s2 = Struct2 { f: o }; assert_eq!(poly_invoke(&t), (2,3)); @@ -114,7 +114,7 @@ pub fn main() { assert_eq!(object_invoke2(&t), 3); assert_eq!(field_invoke2(&s2), 3); - let m : Box = make_val(); + let m : Box = make_val(); // assert_eq!(object_invoke1(&*m), (4,5)); // ~~~~~~~~~~~~~~~~~~~ // this call yields a compilation error; see compile-fail/dropck-object-cycle.rs diff --git a/src/test/run-pass/regions/regions-fn-subtyping-2.rs b/src/test/run-pass/regions/regions-fn-subtyping-2.rs index cbd88ebde0d..83949ddba3d 100644 --- a/src/test/run-pass/regions/regions-fn-subtyping-2.rs +++ b/src/test/run-pass/regions/regions-fn-subtyping-2.rs @@ -7,13 +7,13 @@ // that `x` is in. // pretty-expanded FIXME #23616 -fn has_same_region(f: Box FnMut(&'a isize, Box)>) { +fn has_same_region(f: Box FnMut(&'a isize, Box)>) { // `f` should be the type that `wants_same_region` wants, but // right now the compiler complains that it isn't. wants_same_region(f); } -fn wants_same_region(_f: Box FnMut(&'b isize, Box)>) { +fn wants_same_region(_f: Box FnMut(&'b isize, Box)>) { } pub fn main() { diff --git a/src/test/run-pass/regions/regions-fn-subtyping.rs b/src/test/run-pass/regions/regions-fn-subtyping.rs index a1da966659a..9570359c69e 100644 --- a/src/test/run-pass/regions/regions-fn-subtyping.rs +++ b/src/test/run-pass/regions/regions-fn-subtyping.rs @@ -8,21 +8,21 @@ #![allow(unused_variables)] // Should pass region checking. -fn ok(f: Box) { +fn ok(f: Box) { // Here, g is a function that can accept a usize pointer with // lifetime r, and f is a function that can accept a usize pointer // with any lifetime. The assignment g = f should be OK (i.e., // f's type should be a subtype of g's type), because f can be // used in any context that expects g's type. But this currently // fails. - let mut g: Box FnMut(&'r usize)> = Box::new(|x| { }); + let mut g: Box FnMut(&'r usize)> = Box::new(|x| { }); g = f; } // This version is the same as above, except that here, g's type is // inferred. -fn ok_inferred(f: Box) { - let mut g: Box FnMut(&'r usize)> = Box::new(|_| {}); +fn ok_inferred(f: Box) { + let mut g: Box FnMut(&'r usize)> = Box::new(|_| {}); g = f; } diff --git a/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs b/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs index dff36e6d183..6aa5d8217a4 100644 --- a/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs +++ b/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs @@ -8,7 +8,7 @@ // contains region pointers // pretty-expanded FIXME #23616 -struct foo(Box); +struct foo(Box); fn take_foo(x: T) {} diff --git a/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs b/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs index 189f6172029..c8106f32c65 100644 --- a/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs +++ b/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs @@ -19,15 +19,15 @@ pub fn main() { fn explicit() { - fn test(_x: Option>) where F: FnMut(Box FnMut(&'a isize)>) {} - test(Some(box |_f: Box FnMut(&'a isize)>| {})); + fn test(_x: Option>) where F: FnMut(Box FnMut(&'a isize)>) {} + test(Some(box |_f: Box FnMut(&'a isize)>| {})); } // The code below is shorthand for the code above (and more likely // to represent what one encounters in practice). fn implicit() { - fn test(_x: Option>) where F: FnMut(Box< FnMut(& isize)>) {} - test(Some(box |_f: Box< FnMut(& isize)>| {})); + fn test(_x: Option>) where F: FnMut(Box) {} + test(Some(box |_f: Box| {})); } explicit(); diff --git a/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs b/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs index f26ef85ef72..aec05161c1a 100644 --- a/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs +++ b/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs @@ -44,7 +44,7 @@ impl<'a,'tcx> Foo<'a,'tcx> { fn elaborate_bounds( &mut self, - mut mk_cand: Box FnMut(&mut Foo<'b, 'tcx>) -> isize>) + mut mk_cand: Box FnMut(&mut Foo<'b, 'tcx>) -> isize>) -> isize { mk_cand(self) diff --git a/src/test/run-pass/regions/regions-static-closure.rs b/src/test/run-pass/regions/regions-static-closure.rs index 6d00f7501ca..09cd5622032 100644 --- a/src/test/run-pass/regions/regions-static-closure.rs +++ b/src/test/run-pass/regions/regions-static-closure.rs @@ -2,10 +2,10 @@ #![allow(non_camel_case_types)] struct closure_box<'a> { - cl: Box, + cl: Box, } -fn box_it<'a>(x: Box) -> closure_box<'a> { +fn box_it<'a>(x: Box) -> closure_box<'a> { closure_box {cl: x} } diff --git a/src/test/run-pass/regions/regions-trait-object-1.rs b/src/test/run-pass/regions/regions-trait-object-1.rs index 242142588ea..679bf4dd811 100644 --- a/src/test/run-pass/regions/regions-trait-object-1.rs +++ b/src/test/run-pass/regions/regions-trait-object-1.rs @@ -21,10 +21,10 @@ impl<'d> M for P<'d> { fn n(&self) -> u8 { *self.g } } -fn extension<'e>(x: &'e E<'e>) -> Box { +fn extension<'e>(x: &'e E<'e>) -> Box { loop { let p = P { g: x.m() }; - return Box::new(p) as Box; + return Box::new(p) as Box; } } diff --git a/src/test/run-pass/string-box-error.rs b/src/test/run-pass/string-box-error.rs index debbe665a89..944157d0b20 100644 --- a/src/test/run-pass/string-box-error.rs +++ b/src/test/run-pass/string-box-error.rs @@ -4,8 +4,8 @@ use std::error::Error; fn main() { - let _err1: Box = From::from("test".to_string()); - let _err2: Box = From::from("test".to_string()); - let _err3: Box = From::from("test"); - let _err4: Box = From::from("test"); + let _err1: Box = From::from("test".to_string()); + let _err2: Box = From::from("test".to_string()); + let _err3: Box = From::from("test"); + let _err4: Box = From::from("test"); } diff --git a/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs index cb4a67f609d..bf1ba8a643f 100644 --- a/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs @@ -8,13 +8,13 @@ extern crate cci_class_cast; use std::string::ToString; use cci_class_cast::kitty::cat; -fn print_out(thing: Box, expected: String) { +fn print_out(thing: Box, expected: String) { let actual = (*thing).to_string(); println!("{}", actual); assert_eq!(actual.to_string(), expected); } pub fn main() { - let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; + let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; print_out(nyan, "nyan".to_string()); } diff --git a/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs index 5ce6538fcb3..55975cbdb53 100644 --- a/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs +++ b/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs @@ -79,7 +79,7 @@ fn cat(in_x: usize, in_y: isize, in_name: String) -> cat { } -fn annoy_neighbors(critter: &mut noisy) { +fn annoy_neighbors(critter: &mut dyn noisy) { for _i in 0_usize..10 { critter.speak(); } } diff --git a/src/test/run-pass/structs-enums/class-cast-to-trait.rs b/src/test/run-pass/structs-enums/class-cast-to-trait.rs index 7fa60da6e57..1019bb30015 100644 --- a/src/test/run-pass/structs-enums/class-cast-to-trait.rs +++ b/src/test/run-pass/structs-enums/class-cast-to-trait.rs @@ -55,6 +55,6 @@ fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { pub fn main() { let mut nyan = cat(0, 2, "nyan".to_string()); - let mut nyan: &mut noisy = &mut nyan; + let mut nyan: &mut dyn noisy = &mut nyan; nyan.speak(); } diff --git a/src/test/run-pass/structs-enums/class-separate-impl.rs b/src/test/run-pass/structs-enums/class-separate-impl.rs index 2b10a46e8e2..947690b51f4 100644 --- a/src/test/run-pass/structs-enums/class-separate-impl.rs +++ b/src/test/run-pass/structs-enums/class-separate-impl.rs @@ -53,13 +53,13 @@ impl fmt::Display for cat { } } -fn print_out(thing: Box, expected: String) { +fn print_out(thing: Box, expected: String) { let actual = (*thing).to_string(); println!("{}", actual); assert_eq!(actual.to_string(), expected); } pub fn main() { - let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; + let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; print_out(nyan, "nyan".to_string()); } diff --git a/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs b/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs index 5e3b5942a82..87629665bc2 100644 --- a/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs +++ b/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs @@ -22,9 +22,9 @@ fn main() { assert_eq!(size_of::<&mut [isize]>(), size_of::>()); // Traits - Box / &Trait / &mut Trait - assert_eq!(size_of::>(), size_of::>>()); - assert_eq!(size_of::<&Trait>(), size_of::>()); - assert_eq!(size_of::<&mut Trait>(), size_of::>()); + assert_eq!(size_of::>(), size_of::>>()); + assert_eq!(size_of::<&dyn Trait>(), size_of::>()); + assert_eq!(size_of::<&mut dyn Trait>(), size_of::>()); // Pointers - Box assert_eq!(size_of::>(), size_of::>>()); diff --git a/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs b/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs index 0a48725cbe4..e1a865fa503 100644 --- a/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs +++ b/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs @@ -22,37 +22,37 @@ struct Ref2<'a,'b,T:'a+'b+?Sized> { } struct SomeStruct<'a> { - t: Ref<'a,Test>, - u: Ref<'a,Test+'a>, + t: Ref<'a, dyn Test>, + u: Ref<'a, dyn Test+'a>, } -fn a<'a>(t: Ref<'a,Test>, mut ss: SomeStruct<'a>) { +fn a<'a>(t: Ref<'a, dyn Test>, mut ss: SomeStruct<'a>) { ss.t = t; } -fn b<'a>(t: Ref<'a,Test>, mut ss: SomeStruct<'a>) { +fn b<'a>(t: Ref<'a, dyn Test>, mut ss: SomeStruct<'a>) { ss.u = t; } -fn c<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) { +fn c<'a>(t: Ref<'a, dyn Test+'a>, mut ss: SomeStruct<'a>) { ss.t = t; } -fn d<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) { +fn d<'a>(t: Ref<'a, dyn Test+'a>, mut ss: SomeStruct<'a>) { ss.u = t; } -fn e<'a>(_: Ref<'a, Display+'static>) {} -fn g<'a, 'b>(_: Ref2<'a, 'b, Display+'static>) {} +fn e<'a>(_: Ref<'a, dyn Display+'static>) {} +fn g<'a, 'b>(_: Ref2<'a, 'b, dyn Display+'static>) {} fn main() { // Inside a function body, we can just infer all // lifetimes, to allow Ref<'tmp, Display+'static> // and Ref2<'tmp, 'tmp, Display+'static>. - let x = &0 as &(Display+'static); - let r: Ref = Ref { r: x }; - let r2: Ref2 = Ref2 { a: x, b: x }; + let x = &0 as &(dyn Display+'static); + let r: Ref = Ref { r: x }; + let r2: Ref2 = Ref2 { a: x, b: x }; e(r); g(r2); } diff --git a/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs b/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs index 48ee5a2ed54..1fc52ead48e 100644 --- a/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs +++ b/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs @@ -11,25 +11,25 @@ trait Test { } struct SomeStruct<'a> { - t: &'a MyBox, - u: &'a MyBox, + t: &'a MyBox, + u: &'a MyBox, } struct MyBox { b: Box } -fn a<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { +fn a<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { ss.t = t; } -fn b<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { +fn b<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { ss.u = t; } // see also compile-fail/object-lifetime-default-from-rptr-box-error.rs -fn d<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { +fn d<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { ss.u = t; } diff --git a/src/test/run-pass/traits/auto-traits.rs b/src/test/run-pass/traits/auto-traits.rs index 7702725e640..c495b97b25b 100644 --- a/src/test/run-pass/traits/auto-traits.rs +++ b/src/test/run-pass/traits/auto-traits.rs @@ -27,5 +27,5 @@ fn main() { take_auto_unsafe(AutoBool(true)); /// Auto traits are allowed in trait object bounds. - let _: &(Send + Auto) = &0; + let _: &(dyn Send + Auto) = &0; } diff --git a/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs b/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs index 140dcaf6a27..82760788897 100644 --- a/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs +++ b/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs @@ -11,7 +11,7 @@ impl Foo { fn bar(&self) {} } -impl Trait { +impl dyn Trait { fn baz(_: &Foo) {} } @@ -26,5 +26,5 @@ fn main() { // Should work even if Trait::baz doesn't exist. // N.B: `::bar` would be ambiguous. - ::baz(&Foo); + ::baz(&Foo); } diff --git a/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs b/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs index 1deb17e00da..ed258dbb24c 100644 --- a/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs +++ b/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs @@ -14,7 +14,7 @@ trait Trait { fn foo(&self); } struct Type { a: PhantomData } -fn as_trait(t: &Type) -> &Trait { loop { } } +fn as_trait(t: &Type) -> &dyn Trait { loop { } } fn want+?Sized>(t: &T) { } diff --git a/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs b/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs index f7a58c6f926..23b91f924b5 100644 --- a/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs @@ -12,8 +12,8 @@ impl repeat for Box { } } -fn repeater(v: Box) -> Box+'static> { - box v as Box+'static> // No +fn repeater(v: Box) -> Box+'static> { + box v as Box+'static> // No } pub fn main() { diff --git a/src/test/run-pass/traits/object-one-type-two-traits.rs b/src/test/run-pass/traits/object-one-type-two-traits.rs index 12e4a34a233..b92a2ab7b4b 100644 --- a/src/test/run-pass/traits/object-one-type-two-traits.rs +++ b/src/test/run-pass/traits/object-one-type-two-traits.rs @@ -10,24 +10,24 @@ use std::any::Any; trait Wrap { fn get(&self) -> isize; - fn wrap(self: Box) -> Box; + fn wrap(self: Box) -> Box; } impl Wrap for isize { fn get(&self) -> isize { *self } - fn wrap(self: Box) -> Box { - self as Box + fn wrap(self: Box) -> Box { + self as Box } } -fn is(x: &Any) -> bool { +fn is(x: &dyn Any) -> bool { x.is::() } fn main() { - let x = box 22isize as Box; + let x = box 22isize as Box; println!("x={}", x.get()); let y = x.wrap(); } diff --git a/src/test/run-pass/traits/parameterized-trait-with-bounds.rs b/src/test/run-pass/traits/parameterized-trait-with-bounds.rs index b1339b207eb..832d4f6c89f 100644 --- a/src/test/run-pass/traits/parameterized-trait-with-bounds.rs +++ b/src/test/run-pass/traits/parameterized-trait-with-bounds.rs @@ -12,10 +12,10 @@ mod foo { pub trait D<'a, T> { fn get(self) -> &'a T; } } -fn foo1(_: &(A + Send)) {} -fn foo2(_: Box + Send + Sync>) {} -fn foo3(_: Box + 'static>) {} -fn foo4<'a, T>(_: Box + 'static + Send>) {} -fn foo5<'a, T>(_: Box + 'static + Send>) {} +fn foo1(_: &(dyn A + Send)) {} +fn foo2(_: Box + Send + Sync>) {} +fn foo3(_: Box + 'static>) {} +fn foo4<'a, T>(_: Box + 'static + Send>) {} +fn foo5<'a, T>(_: Box + 'static + Send>) {} pub fn main() {} diff --git a/src/test/run-pass/traits/trait-bounds-basic.rs b/src/test/run-pass/traits/trait-bounds-basic.rs index af6392e5658..8c8a7eb7d9d 100644 --- a/src/test/run-pass/traits/trait-bounds-basic.rs +++ b/src/test/run-pass/traits/trait-bounds-basic.rs @@ -7,18 +7,18 @@ trait Foo { } -fn b(_x: Box) { +fn b(_x: Box) { } -fn c(x: Box) { +fn c(x: Box) { e(x); } -fn d(x: Box) { +fn d(x: Box) { e(x); } -fn e(x: Box) { +fn e(x: Box) { e(x); } diff --git a/src/test/run-pass/traits/trait-bounds-in-arc.rs b/src/test/run-pass/traits/trait-bounds-in-arc.rs index 82bdcdcf7c5..a45d834297e 100644 --- a/src/test/run-pass/traits/trait-bounds-in-arc.rs +++ b/src/test/run-pass/traits/trait-bounds-in-arc.rs @@ -12,7 +12,7 @@ use std::sync::mpsc::channel; use std::thread; trait Pet { - fn name(&self, blk: Box); + fn name(&self, blk: Box); fn num_legs(&self) -> usize; fn of_good_pedigree(&self) -> bool; } @@ -34,19 +34,19 @@ struct Goldfyshe { } impl Pet for Catte { - fn name(&self, mut blk: Box) { blk(&self.name) } + fn name(&self, mut blk: Box) { blk(&self.name) } fn num_legs(&self) -> usize { 4 } fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 } } impl Pet for Dogge { - fn name(&self, mut blk: Box) { blk(&self.name) } + fn name(&self, mut blk: Box) { blk(&self.name) } fn num_legs(&self) -> usize { 4 } fn of_good_pedigree(&self) -> bool { self.bark_decibels < 70 || self.tricks_known > 20 } } impl Pet for Goldfyshe { - fn name(&self, mut blk: Box) { blk(&self.name) } + fn name(&self, mut blk: Box) { blk(&self.name) } fn num_legs(&self) -> usize { 0 } fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 } } @@ -67,10 +67,10 @@ pub fn main() { swim_speed: 998, name: "alec_guinness".to_string(), }; - let arc = Arc::new(vec![box catte as Box, - box dogge1 as Box, - box fishe as Box, - box dogge2 as Box]); + let arc = Arc::new(vec![box catte as Box, + box dogge1 as Box, + box fishe as Box, + box dogge2 as Box]); let (tx1, rx1) = channel(); let arc1 = arc.clone(); let t1 = thread::spawn(move|| { check_legs(arc1); tx1.send(()); }); @@ -88,21 +88,21 @@ pub fn main() { t3.join(); } -fn check_legs(arc: Arc>>) { +fn check_legs(arc: Arc>>) { let mut legs = 0; for pet in arc.iter() { legs += pet.num_legs(); } assert!(legs == 12); } -fn check_names(arc: Arc>>) { +fn check_names(arc: Arc>>) { for pet in arc.iter() { pet.name(Box::new(|name| { assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8); })) } } -fn check_pedigree(arc: Arc>>) { +fn check_pedigree(arc: Arc>>) { for pet in arc.iter() { assert!(pet.of_good_pedigree()); } diff --git a/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs b/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs index 18b25b852d1..4dc4fecc91f 100644 --- a/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs +++ b/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs @@ -7,11 +7,11 @@ trait U {} trait T { fn get(self) -> X; } trait S2 { - fn m(x: Box+'static>) {} + fn m(x: Box+'static>) {} } struct St { - f: Box+'static>, + f: Box+'static>, } impl St { diff --git a/src/test/run-pass/traits/trait-coercion-generic.rs b/src/test/run-pass/traits/trait-coercion-generic.rs index 5d1b442afcc..bf4dda49519 100644 --- a/src/test/run-pass/traits/trait-coercion-generic.rs +++ b/src/test/run-pass/traits/trait-coercion-generic.rs @@ -18,8 +18,8 @@ impl Trait<&'static str> for Struct { pub fn main() { let a = Struct { x: 1, y: 2 }; - let b: Box> = Box::new(a); + let b: Box> = Box::new(a); b.f("Mary"); - let c: &Trait<&'static str> = &a; + let c: &dyn Trait<&'static str> = &a; c.f("Joe"); } diff --git a/src/test/run-pass/traits/trait-coercion.rs b/src/test/run-pass/traits/trait-coercion.rs index 1a40b81c89f..cba33af1f1a 100644 --- a/src/test/run-pass/traits/trait-coercion.rs +++ b/src/test/run-pass/traits/trait-coercion.rs @@ -22,13 +22,13 @@ impl Trait for Struct { } } -fn foo(mut a: Box) {} +fn foo(mut a: Box) {} pub fn main() { let a = Struct { x: 1, y: 2 }; - let b: Box = Box::new(a); + let b: Box = Box::new(a); b.f(); - let c: &Trait = &a; + let c: &dyn Trait = &a; c.f(); let out = io::stdout(); diff --git a/src/test/run-pass/traits/trait-impl-2.rs b/src/test/run-pass/traits/trait-impl-2.rs index b28d74a7b35..804ffec12c2 100644 --- a/src/test/run-pass/traits/trait-impl-2.rs +++ b/src/test/run-pass/traits/trait-impl-2.rs @@ -11,7 +11,7 @@ pub mod Foo { } mod Bar { - impl<'a> ::Foo::Trait+'a { + impl<'a> dyn (::Foo::Trait) + 'a { fn bar(&self) { self.foo() } } } diff --git a/src/test/run-pass/traits/trait-impl.rs b/src/test/run-pass/traits/trait-impl.rs index 6b22ac08bb8..14796ce19c8 100644 --- a/src/test/run-pass/traits/trait-impl.rs +++ b/src/test/run-pass/traits/trait-impl.rs @@ -12,7 +12,7 @@ trait T { fn t(&self) {} } -impl<'a> T+'a { +impl<'a> dyn T+'a { fn foo(&self) { unsafe { COUNT *= 2; } } @@ -27,7 +27,7 @@ struct Foo; impl<'a> Bar<'a> for Foo {} fn main() { - let x: &T = &42; + let x: &dyn T = &42; x.foo(); T::foo(x); @@ -36,6 +36,6 @@ fn main() { unsafe { assert_eq!(COUNT, 12); } // Cross-crait case - let x: &Bar = &Foo; + let x: &dyn Bar = &Foo; x.bar(); } diff --git a/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs b/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs index c0b5db63bd4..25159c1adb6 100644 --- a/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs +++ b/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs @@ -26,8 +26,8 @@ impl Bar for A { pub fn main() { let a = &A { x: 3 }; - let afoo = a as &Foo; - let abar = a as &Bar; + let afoo = a as &dyn Foo; + let abar = a as &dyn Bar; assert_eq!(afoo.f(), 10); assert_eq!(abar.g(), 20); } diff --git a/src/test/run-pass/traits/trait-inheritance-cast.rs b/src/test/run-pass/traits/trait-inheritance-cast.rs index 38e5c79e9e0..9070b9d1f56 100644 --- a/src/test/run-pass/traits/trait-inheritance-cast.rs +++ b/src/test/run-pass/traits/trait-inheritance-cast.rs @@ -25,8 +25,8 @@ impl Bar for A { pub fn main() { let a = &A { x: 3 }; - let afoo = a as &Foo; - let abar = a as &Bar; + let afoo = a as &dyn Foo; + let abar = a as &dyn Bar; assert_eq!(afoo.f(), 10); assert_eq!(abar.g(), 20); assert_eq!(abar.f(), 10); diff --git a/src/test/run-pass/traits/trait-object-exclusion.rs b/src/test/run-pass/traits/trait-object-exclusion.rs index 248804d144a..0b8b0e2f5ef 100644 --- a/src/test/run-pass/traits/trait-object-exclusion.rs +++ b/src/test/run-pass/traits/trait-object-exclusion.rs @@ -4,7 +4,7 @@ trait Future: 'static { // Future::forget in vtables, otherwise there's an infinite type // recursion through as Future>::forget. fn forget(self) where Self: Sized { - Box::new(Map(self)) as Box; + Box::new(Map(self)) as Box; } } diff --git a/src/test/run-pass/traits/trait-object-generics.rs b/src/test/run-pass/traits/trait-object-generics.rs index 168bffa0e48..c18754302b7 100644 --- a/src/test/run-pass/traits/trait-object-generics.rs +++ b/src/test/run-pass/traits/trait-object-generics.rs @@ -16,7 +16,7 @@ pub struct Impl { * task failed at 'index out of bounds: the len is 1 but the index is 1', * src/librustc/middle/subst.rs:58 */ - t: Box+'static> + t: Box+'static> } impl Impl { @@ -38,6 +38,6 @@ impl Trait for () { } pub fn main() { - let a = box () as Box>; + let a = box () as Box>; assert_eq!(a.method(Type::Constant((1, 2))), 0); } diff --git a/src/test/run-pass/traits/trait-object-lifetime-first.rs b/src/test/run-pass/traits/trait-object-lifetime-first.rs index e95a652057d..33757cb7c0a 100644 --- a/src/test/run-pass/traits/trait-object-lifetime-first.rs +++ b/src/test/run-pass/traits/trait-object-lifetime-first.rs @@ -4,8 +4,8 @@ use std::fmt::Display; static BYTE: u8 = 33; fn main() { - let x: &('static + Display) = &BYTE; - let y: Box<'static + Display> = Box::new(BYTE); + let x: &(dyn 'static + Display) = &BYTE; + let y: Box = Box::new(BYTE); let xstr = format!("{}", x); let ystr = format!("{}", y); assert_eq!(xstr, "33"); diff --git a/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs b/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs index 9060380db17..05aab5e3b08 100644 --- a/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs +++ b/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs @@ -20,10 +20,10 @@ impl<'d> M for P<'d> { fn n(&self) -> u8 { *self.g } } -fn extension<'e>(x: &'e E<'e>) -> Box { +fn extension<'e>(x: &'e E<'e>) -> Box { loop { let p = P { g: x.m() }; - return Box::new(p) as Box; + return Box::new(p) as Box; } } diff --git a/src/test/run-pass/traits/trait-region-pointer-simple.rs b/src/test/run-pass/traits/trait-region-pointer-simple.rs index 6584182d38a..0456ca93115 100644 --- a/src/test/run-pass/traits/trait-region-pointer-simple.rs +++ b/src/test/run-pass/traits/trait-region-pointer-simple.rs @@ -16,6 +16,6 @@ impl Foo for A { pub fn main() { let a = A { x: 3 }; - let b = (&a) as &Foo; + let b = (&a) as &dyn Foo; assert_eq!(b.f(), 3); } diff --git a/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs b/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs index c9745e06d8f..e490967b690 100644 --- a/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs +++ b/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs @@ -14,5 +14,5 @@ impl Foo for T { } fn want_foo() { } fn main() { - want_foo::(); + want_foo::(); } diff --git a/src/test/run-pass/traits/traits-issue-26339.rs b/src/test/run-pass/traits/traits-issue-26339.rs index 0f831be2485..bedd87cc4cc 100644 --- a/src/test/run-pass/traits/traits-issue-26339.rs +++ b/src/test/run-pass/traits/traits-issue-26339.rs @@ -25,7 +25,7 @@ impl PartialEq for Aimpl { impl A for Aimpl { } fn main() { - let a = &Aimpl as &A; + let a = &Aimpl as &dyn A; assert!(*a == Foo); } diff --git a/src/test/run-pass/traits/traits-repeated-supertrait.rs b/src/test/run-pass/traits/traits-repeated-supertrait.rs index c8318bdf154..391d19c4385 100644 --- a/src/test/run-pass/traits/traits-repeated-supertrait.rs +++ b/src/test/run-pass/traits/traits-repeated-supertrait.rs @@ -22,7 +22,7 @@ impl CompareTo for i64 { impl CompareToInts for i64 { } -fn with_obj(c: &CompareToInts) -> bool { +fn with_obj(c: &dyn CompareToInts) -> bool { c.same_as(22_i64) && c.same_as(22_u64) } diff --git a/src/test/run-pass/traits/ufcs-trait-object.rs b/src/test/run-pass/traits/ufcs-trait-object.rs index abe164a5720..700488c22d6 100644 --- a/src/test/run-pass/traits/ufcs-trait-object.rs +++ b/src/test/run-pass/traits/ufcs-trait-object.rs @@ -12,6 +12,6 @@ impl Foo for i32 { } fn main() { - let a: &Foo = &22; + let a: &dyn Foo = &22; assert_eq!(Foo::test(a), 22); } diff --git a/src/test/run-pass/trivial_casts.rs b/src/test/run-pass/trivial_casts.rs index bc56d0158d4..f06b0708290 100644 --- a/src/test/run-pass/trivial_casts.rs +++ b/src/test/run-pass/trivial_casts.rs @@ -36,21 +36,21 @@ pub fn main() { // unsize trait let x: &Bar = &Bar; - let _ = x as &Foo; - let _ = x as *const Foo; + let _ = x as &dyn Foo; + let _ = x as *const dyn Foo; let x: &mut Bar = &mut Bar; - let _ = x as &mut Foo; - let _ = x as *mut Foo; + let _ = x as &mut dyn Foo; + let _ = x as *mut dyn Foo; let x: Box = Box::new(Bar); - let _ = x as Box; + let _ = x as Box; // functions fn baz(_x: i32) {} - let _ = &baz as &Fn(i32); + let _ = &baz as &dyn Fn(i32); let x = |_x: i32| {}; - let _ = &x as &Fn(i32); + let _ = &x as &dyn Fn(i32); } // subtyping diff --git a/src/test/run-pass/type-id-higher-rank-2.rs b/src/test/run-pass/type-id-higher-rank-2.rs index d9280cf97f9..469bc8ed7e1 100644 --- a/src/test/run-pass/type-id-higher-rank-2.rs +++ b/src/test/run-pass/type-id-higher-rank-2.rs @@ -7,7 +7,7 @@ struct Foo<'a>(&'a str); fn good(s: &String) -> Foo { Foo(s) } fn bad1(s: String) -> Option<&'static str> { - let a: Box = Box::new(good as fn(&String) -> Foo); + let a: Box = Box::new(good as fn(&String) -> Foo); a.downcast_ref:: Foo<'static>>().map(|f| f(&s).0) } @@ -20,8 +20,8 @@ impl<'a> AsStr<'a, 'a> for String { } fn bad2(s: String) -> Option<&'static str> { - let a: Box = Box::new(Box::new(s) as Box AsStr<'a, 'a>>); - a.downcast_ref:: AsStr<'a, 'static>>>().map(|x| x.get()) + let a: Box = Box::new(Box::new(s) as Box AsStr<'a, 'a>>); + a.downcast_ref:: AsStr<'a, 'static>>>().map(|x| x.get()) } fn main() { diff --git a/src/test/run-pass/type-id-higher-rank.rs b/src/test/run-pass/type-id-higher-rank.rs index 55d70e31b16..b98dff0d72b 100644 --- a/src/test/run-pass/type-id-higher-rank.rs +++ b/src/test/run-pass/type-id-higher-rank.rs @@ -26,9 +26,9 @@ fn main() { assert!(e != f); // Make sure lifetime parameters of items are not ignored. - let g = TypeId::of:: fn(&'a Trait<'a>) -> Struct<'a>>(); - let h = TypeId::of:: fn(&'a Trait<'a>) -> Struct<'static>>(); - let i = TypeId::of:: fn(&'a Trait<'b>) -> Struct<'b>>(); + let g = TypeId::of:: fn(&'a dyn Trait<'a>) -> Struct<'a>>(); + let h = TypeId::of:: fn(&'a dyn Trait<'a>) -> Struct<'static>>(); + let i = TypeId::of:: fn(&'a dyn Trait<'b>) -> Struct<'b>>(); assert!(g != h); assert!(g != i); assert!(h != i); @@ -40,10 +40,10 @@ fn main() { } // Boxed unboxed closures { - let a = TypeId::of::>(); - let b = TypeId::of:: Fn(&'static isize, &'a isize)>>(); - let c = TypeId::of:: Fn(&'a isize, &'b isize)>>(); - let d = TypeId::of:: Fn(&'b isize, &'a isize)>>(); + let a = TypeId::of::>(); + let b = TypeId::of:: Fn(&'static isize, &'a isize)>>(); + let c = TypeId::of:: Fn(&'a isize, &'b isize)>>(); + let d = TypeId::of:: Fn(&'b isize, &'a isize)>>(); assert!(a != b); assert!(a != c); assert!(a != d); @@ -52,8 +52,8 @@ fn main() { assert_eq!(c, d); // Make sure De Bruijn indices are handled correctly - let e = TypeId::of:: Fn(Box &'a isize>)>>(); - let f = TypeId::of:: Fn(&'a isize) -> &'a isize>)>>(); + let e = TypeId::of:: Fn(Box &'a isize>)>>(); + let f = TypeId::of:: Fn(&'a isize) -> &'a isize>)>>(); assert!(e != f); } // Raw unboxed closures diff --git a/src/test/run-pass/type-infer-generalize-ty-var.rs b/src/test/run-pass/type-infer-generalize-ty-var.rs index 244a72c80fa..6298156452e 100644 --- a/src/test/run-pass/type-infer-generalize-ty-var.rs +++ b/src/test/run-pass/type-infer-generalize-ty-var.rs @@ -23,8 +23,8 @@ trait Get { fn get(&self) -> &T; } -impl Get for Wrap { - fn get(&self) -> &(MyShow + 'static) { +impl Get for Wrap { + fn get(&self) -> &(dyn MyShow + 'static) { static x: usize = 42; &x } @@ -38,9 +38,9 @@ impl Get for Wrap { } trait MyShow { fn dummy(&self) { } } -impl<'a> MyShow for &'a (MyShow + 'a) { } +impl<'a> MyShow for &'a (dyn MyShow + 'a) { } impl MyShow for usize { } -fn constrain<'a>(rc: RefCell<&'a (MyShow + 'a)>) { } +fn constrain<'a>(rc: RefCell<&'a (dyn MyShow + 'a)>) { } fn main() { let mut collection: Wrap<_> = WrapNone; diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs index 08a9796ea29..a1001673506 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs @@ -8,7 +8,7 @@ fn a i32>(mut f: F) -> i32 { f() } -fn b(f: &mut FnMut() -> i32) -> i32 { +fn b(f: &mut dyn FnMut() -> i32) -> i32 { a(f) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs index 76ad40b8f3d..ca1d31ca544 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs @@ -8,7 +8,7 @@ fn a i32>(f: F) -> i32 { f() } -fn b(f: &Fn() -> i32) -> i32 { +fn b(f: &dyn Fn() -> i32) -> i32 { a(f) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs index 6d55fe997b0..b2596e49aa7 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs @@ -3,9 +3,9 @@ use std::ops::FnMut; - fn make_adder(x: i32) -> Boxi32+'static> { + fn make_adder(x: i32) -> Boxi32+'static> { (box move |y: i32| -> i32 { x + y }) as - Boxi32+'static> + Boxi32+'static> } pub fn main() { diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs index 22fc148c352..d47ceea0f4f 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs @@ -3,7 +3,7 @@ use std::ops::FnMut; -fn make_adder(x: isize) -> Boxisize + 'static> { +fn make_adder(x: isize) -> Boxisize + 'static> { Box::new(move |y| { x + y }) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs index 91311fba2e8..f77733d106d 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs @@ -1,7 +1,7 @@ // run-pass use std::ops::FnMut; -fn make_adder(x: isize) -> Boxisize + 'static> { +fn make_adder(x: isize) -> Boxisize + 'static> { Box::new(move |y| { x + y }) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs index 0fd23a2d796..3ee1aeb109b 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs @@ -7,7 +7,7 @@ fn call_itisize>(f: &F, x: isize) -> isize { (*f)(&x) } -fn call_it_boxed(f: &Fn(&isize) -> isize, x: isize) -> isize { +fn call_it_boxed(f: &dyn Fn(&isize) -> isize, x: isize) -> isize { f(&x) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs index 4f23f85b649..d2eaee30410 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs @@ -12,7 +12,7 @@ impl ToPrimitive for isize {} impl ToPrimitive for i32 {} impl ToPrimitive for usize {} -fn doit(val: T, f: &Fn(T)) { f(val) } +fn doit(val: T, f: &dyn Fn(T)) { f(val) } pub fn main() { doit(0, &|x /*: isize*/ | { x.to_int(); }); diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs index 72d658f393b..86834f49407 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs @@ -20,23 +20,23 @@ impl YCombinator { } } -impl R, A) -> R> Fn<(A,)> for YCombinator { +impl R, A) -> R> Fn<(A,)> for YCombinator { extern "rust-call" fn call(&self, (arg,): (A,)) -> R { (self.func)(self, arg) } } -impl R, A) -> R> FnMut<(A,)> for YCombinator { +impl R, A) -> R> FnMut<(A,)> for YCombinator { extern "rust-call" fn call_mut(&mut self, args: (A,)) -> R { self.call(args) } } -impl R, A) -> R> FnOnce<(A,)> for YCombinator { +impl R, A) -> R> FnOnce<(A,)> for YCombinator { type Output = R; extern "rust-call" fn call_once(self, args: (A,)) -> R { self.call(args) } } fn main() { - let factorial = |recur: &Fn(u32) -> u32, arg: u32| -> u32 { + let factorial = |recur: &dyn Fn(u32) -> u32, arg: u32| -> u32 { if arg == 0 {1} else {arg * recur(arg-1)} }; let factorial: YCombinator<_,u32,u32> = YCombinator::new(factorial); diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs index 5c7aafdc573..df60b42ab12 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs @@ -19,7 +19,7 @@ fn call_iti32>(mut f: F, x: i32) -> i32 { f(x) + 3 } -fn call_box(f: &mut FnMut(i32) -> i32, x: i32) -> i32 { +fn call_box(f: &mut dyn FnMut(i32) -> i32, x: i32) -> i32 { f(x) + 3 } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs index 092224b7934..2df360d4a30 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs @@ -3,7 +3,7 @@ // monomorphize correctly (issue #16791) fn main(){ - fn bar<'a, T:Clone+'a> (t: T) -> BoxT + 'a> { + fn bar<'a, T:Clone+'a> (t: T) -> BoxT + 'a> { Box::new(move || t.clone()) } diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs index 7e53c4d9eb6..89a273b7a43 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs @@ -4,10 +4,10 @@ // pretty-expanded FIXME #23616 fn main() { - let task: Box isize> = Box::new(|x| x); + let task: Box isize> = Box::new(|x| x); task(0); - let mut task: Box isize> = Box::new(|x| x); + let mut task: Box isize> = Box::new(|x| x); task(0); call(|x| x, 22); diff --git a/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs b/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs index 45ab5df94b2..1ca25517c3c 100644 --- a/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs +++ b/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs @@ -19,7 +19,7 @@ impl Getter for Identity { } fn main() { - let x: &Getter<(i32,), (i32,)> = &Identity; + let x: &dyn Getter<(i32,), (i32,)> = &Identity; let (y,) = x.get((22,)); assert_eq!(y, 22); } diff --git a/src/test/run-pass/unique/unique-object-move.rs b/src/test/run-pass/unique/unique-object-move.rs index 4bd3764fa15..84e8cdb32b8 100644 --- a/src/test/run-pass/unique/unique-object-move.rs +++ b/src/test/run-pass/unique/unique-object-move.rs @@ -15,6 +15,6 @@ pub struct UvEventLoop { impl EventLoop for UvEventLoop { } pub fn main() { - let loop_: Box = box UvEventLoop { uvio: 0 } as Box; + let loop_: Box = box UvEventLoop { uvio: 0 } as Box; let _loop2_ = loop_; } diff --git a/src/test/run-pass/unsized2.rs b/src/test/run-pass/unsized2.rs index c3eae299b86..c9a8b2e7c66 100644 --- a/src/test/run-pass/unsized2.rs +++ b/src/test/run-pass/unsized2.rs @@ -60,26 +60,26 @@ fn f7(x: &X) { trait T4 { fn dummy(&self) { } - fn m1(&self, x: &T4, y: X); - fn m2(&self, x: &T5, y: X); + fn m1(&self, x: &dyn T4, y: X); + fn m2(&self, x: &dyn T5, y: X); } trait T5 { fn dummy(&self) { } // not an error (for now) - fn m1(&self, x: &T4); - fn m2(&self, x: &T5); + fn m1(&self, x: &dyn T4); + fn m2(&self, x: &dyn T5); } trait T6 { fn dummy(&self) { } - fn m1(&self, x: &T4); - fn m2(&self, x: &T5); + fn m1(&self, x: &dyn T4); + fn m2(&self, x: &dyn T5); } trait T7 { fn dummy(&self) { } // not an error (for now) - fn m1(&self, x: &T4); - fn m2(&self, x: &T5); + fn m1(&self, x: &dyn T4); + fn m2(&self, x: &dyn T5); } // The last field in a struct may be unsized diff --git a/src/test/run-pass/wf-bound-region-in-object-type.rs b/src/test/run-pass/wf-bound-region-in-object-type.rs index d81059ca6a8..6814e2baab5 100644 --- a/src/test/run-pass/wf-bound-region-in-object-type.rs +++ b/src/test/run-pass/wf-bound-region-in-object-type.rs @@ -12,7 +12,7 @@ pub struct Context<'tcx> { pub type Cmd<'a> = &'a isize; pub type DecodeInlinedItem<'a> = - Box FnMut(Cmd, &Context<'tcx>) -> Result<&'tcx isize, ()> + 'a>; + Box FnMut(Cmd, &Context<'tcx>) -> Result<&'tcx isize, ()> + 'a>; fn foo(d: DecodeInlinedItem) { }