Skip to content

Commit a2b6f14

Browse files
authored
Rollup merge of #141957 - ferrocene:lw/missing-dyn-kw2, r=compiler-errors
Add missing `dyn` keywords to tests that do not test for them Part 2 Some more tests that were found
2 parents 9653141 + 4fc62e0 commit a2b6f14

15 files changed

+26
-31
lines changed

tests/ui/issues/auxiliary/issue-11224.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ mod inner {
1111
}
1212

1313
pub fn foo() {
14-
let a = &1isize as &inner::Trait;
14+
let a = &1isize as &dyn inner::Trait;
1515
a.f();
1616
}

tests/ui/issues/auxiliary/issue-13507.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub mod testtypes {
1616
TypeId::of::<FooFnPtr>(),
1717
TypeId::of::<FooNil>(),
1818
TypeId::of::<FooTuple>(),
19-
TypeId::of::<FooTrait>(),
19+
TypeId::of::<dyn FooTrait>(),
2020
TypeId::of::<FooStruct>(),
2121
TypeId::of::<FooEnum>()
2222
]

tests/ui/issues/auxiliary/issue-17662.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ pub trait Foo<'a, T> {
44
fn foo(&'a self) -> T;
55
}
66

7-
pub fn foo<'a, T>(x: &'a Foo<'a, T>) -> T {
8-
let x: &'a Foo<T> = x;
9-
// ^ the lifetime parameter of Foo is left to be inferred.
7+
pub fn foo<'a, T>(x: &'a dyn Foo<'a, T>) -> T {
8+
let x: &'a dyn Foo<T> = x;
9+
// ^ the lifetime parameter of Foo is left to be inferred.
1010
x.foo()
1111
// ^ encoding this method call in metadata triggers an ICE.
1212
}

tests/ui/issues/auxiliary/issue-2380.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ pub trait i<T>
66
fn dummy(&self, t: T) -> T { panic!() }
77
}
88

9-
pub fn f<T>() -> Box<i<T>+'static> {
9+
pub fn f<T>() -> Box<dyn i<T>+'static> {
1010
impl<T> i<T> for () { }
1111

12-
Box::new(()) as Box<i<T>+'static>
12+
Box::new(()) as Box<dyn i<T>+'static>
1313
}

tests/ui/issues/auxiliary/issue-25467.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ pub trait Trait {
77
type Issue25467BarT;
88
}
99

10-
pub type Object = Option<Box<Trait<Issue25467FooT=(),Issue25467BarT=()>>>;
10+
pub type Object = Option<Box<dyn Trait<Issue25467FooT=(),Issue25467BarT=()>>>;

tests/ui/issues/auxiliary/issue-34796-aux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl Future for u32 {
99
type Error = Box<()>;
1010
}
1111

12-
fn foo() -> Box<Future<Item=(), Error=Box<()>>> {
12+
fn foo() -> Box<dyn Future<Item=(), Error=Box<()>>> {
1313
Box::new(0u32)
1414
}
1515

tests/ui/issues/auxiliary/issue-38226-aux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#[inline(never)]
44
pub fn foo<T>() {
5-
let _: Box<SomeTrait> = Box::new(SomeTraitImpl);
5+
let _: Box<dyn SomeTrait> = Box::new(SomeTraitImpl);
66
}
77

88
pub fn bar() {

tests/ui/issues/auxiliary/issue-8401.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ trait A {
88
struct B;
99
impl A for B {}
1010

11-
fn bar<T>(_: &mut A, _: &T) {}
11+
fn bar<T>(_: &mut dyn A, _: &T) {}
1212

1313
fn foo<T>(t: &T) {
1414
let mut b = B;
15-
bar(&mut b as &mut A, t)
15+
bar(&mut b as &mut dyn A, t)
1616
}

tests/ui/issues/issue-34373.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ trait Trait<T> {
44
fn foo(_: T) {}
55
}
66

7-
pub struct Foo<T = Box<Trait<DefaultFoo>>>; //~ ERROR cycle detected
7+
pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>; //~ ERROR cycle detected
88
//~^ ERROR `T` is never used
99
type DefaultFoo = Foo;
1010

tests/ui/issues/issue-34373.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0391]: cycle detected when computing type of `Foo::T`
2-
--> $DIR/issue-34373.rs:7:30
2+
--> $DIR/issue-34373.rs:7:34
33
|
4-
LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
5-
| ^^^^^^^^^^
4+
LL | pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>;
5+
| ^^^^^^^^^^
66
|
77
note: ...which requires expanding type alias `DefaultFoo`...
88
--> $DIR/issue-34373.rs:9:19
@@ -13,15 +13,15 @@ LL | type DefaultFoo = Foo;
1313
note: cycle used when checking that `Foo` is well-formed
1414
--> $DIR/issue-34373.rs:7:1
1515
|
16-
LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
LL | pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>;
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
1919

2020
error[E0392]: type parameter `T` is never used
2121
--> $DIR/issue-34373.rs:7:16
2222
|
23-
LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
24-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ unused type parameter
23+
LL | pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>;
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused type parameter
2525
|
2626
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
2727
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
// Helper for testing that we get suitable warnings when lifetime
44
// bound change will cause breakage.
55

6-
pub fn just_ref(x: &Fn()) {
7-
}
6+
pub fn just_ref(x: &dyn Fn()) {}
87

9-
pub fn ref_obj(x: &Box<Fn()>) {
8+
pub fn ref_obj(x: &Box<dyn Fn()>) {
109
// this will change to &Box<Fn()+'static>...
1110
}

tests/ui/parser/bounds-obj-parens.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ check-pass
22

3-
#![allow(bare_trait_objects)]
4-
5-
type A = Box<(Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318)
3+
type A = Box<dyn (Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318)
64

75
fn main() {}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//@ check-pass
22

3-
#![allow(bare_trait_objects)]
4-
53
use std::fmt::Debug;
64

75
fn main() {
8-
let x: Box<Debug+> = Box::new(3) as Box<Debug+>; // Trailing `+` is OK
6+
let x: Box<dyn Debug+> = Box::new(3) as Box<dyn Debug+>; // Trailing `+` is OK
97
}

tests/ui/regions/region-object-lifetime-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait Foo {
1010

1111
// Here the receiver and return value all have the same lifetime,
1212
// so no error results.
13-
fn borrowed_receiver_same_lifetime<'a>(x: &'a Foo) -> &'a () {
13+
fn borrowed_receiver_same_lifetime<'a>(x: &'a dyn Foo) -> &'a () {
1414
x.borrowed()
1515
}
1616

tests/ui/regions/region-object-lifetime-3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait Foo {
1010

1111
// Borrowed receiver with two distinct lifetimes, but we know that
1212
// 'b:'a, hence &'a () is permitted.
13-
fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (Foo+'b)) -> &'a () {
13+
fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (dyn Foo+'b)) -> &'a () {
1414
x.borrowed()
1515
}
1616

0 commit comments

Comments
 (0)