Skip to content

Commit edbc7bb

Browse files
committed
Add missing dyn keywords to tests that do not test for them
1 parent 1d7c1b1 commit edbc7bb

15 files changed

+85
-128
lines changed

tests/ui/auxiliary/typeid-intrinsic-aux1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ pub struct E(Result<&'static str, isize>);
99
pub type F = Option<isize>;
1010
pub type G = usize;
1111
pub type H = &'static str;
12-
pub type I = Box<Fn()>;
13-
pub type I32Iterator = Iterator<Item=i32>;
14-
pub type U32Iterator = Iterator<Item=u32>;
12+
pub type I = Box<dyn Fn()>;
13+
pub type I32Iterator = dyn Iterator<Item=i32>;
14+
pub type U32Iterator = dyn Iterator<Item=u32>;
1515

1616
pub fn id_A() -> TypeId { TypeId::of::<A>() }
1717
pub fn id_B() -> TypeId { TypeId::of::<B>() }

tests/ui/auxiliary/typeid-intrinsic-aux2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ pub struct E(Result<&'static str, isize>);
99
pub type F = Option<isize>;
1010
pub type G = usize;
1111
pub type H = &'static str;
12-
pub type I = Box<Fn()>;
13-
pub type I32Iterator = Iterator<Item=i32>;
14-
pub type U32Iterator = Iterator<Item=u32>;
12+
pub type I = Box<dyn Fn()>;
13+
pub type I32Iterator = dyn Iterator<Item=i32>;
14+
pub type U32Iterator = dyn Iterator<Item=u32>;
1515

1616
pub fn id_A() -> TypeId { TypeId::of::<A>() }
1717
pub fn id_B() -> TypeId { TypeId::of::<B>() }
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
#![allow(bare_trait_objects)]
21
trait A: Sized {
3-
fn f(a: A) -> A;
2+
fn f(a: dyn A) -> dyn A;
43
//~^ ERROR associated item referring to unboxed trait object for its own trait
54
//~| ERROR the trait `A` is not dyn compatible
65
}
76
trait B {
8-
fn f(a: B) -> B;
7+
fn f(a: dyn B) -> dyn B;
98
//~^ ERROR associated item referring to unboxed trait object for its own trait
109
//~| ERROR the trait `B` is not dyn compatible
1110
}
1211
trait C {
13-
fn f(&self, a: C) -> C;
12+
fn f(&self, a: dyn C) -> dyn C;
1413
}
1514

1615
fn main() {}

tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: associated item referring to unboxed trait object for its own trait
2-
--> $DIR/dyn-incompatible-trait-should-use-self.rs:3:13
2+
--> $DIR/dyn-incompatible-trait-should-use-self.rs:2:13
33
|
44
LL | trait A: Sized {
55
| - in this trait
@@ -13,22 +13,22 @@ LL + fn f(a: Self) -> Self;
1313
|
1414

1515
error[E0038]: the trait `A` is not dyn compatible
16-
--> $DIR/dyn-incompatible-trait-should-use-self.rs:3:13
16+
--> $DIR/dyn-incompatible-trait-should-use-self.rs:2:13
1717
|
1818
LL | fn f(a: dyn A) -> dyn A;
1919
| ^^^^^ `A` is not dyn compatible
2020
|
2121
note: for a trait to be dyn compatible it needs to allow building a vtable
2222
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
23-
--> $DIR/dyn-incompatible-trait-should-use-self.rs:2:10
23+
--> $DIR/dyn-incompatible-trait-should-use-self.rs:1:10
2424
|
2525
LL | trait A: Sized {
2626
| - ^^^^^ ...because it requires `Self: Sized`
2727
| |
2828
| this trait is not dyn compatible...
2929

3030
error: associated item referring to unboxed trait object for its own trait
31-
--> $DIR/dyn-incompatible-trait-should-use-self.rs:8:13
31+
--> $DIR/dyn-incompatible-trait-should-use-self.rs:7:13
3232
|
3333
LL | trait B {
3434
| - in this trait
@@ -42,14 +42,14 @@ LL + fn f(a: Self) -> Self;
4242
|
4343

4444
error[E0038]: the trait `B` is not dyn compatible
45-
--> $DIR/dyn-incompatible-trait-should-use-self.rs:8:13
45+
--> $DIR/dyn-incompatible-trait-should-use-self.rs:7:13
4646
|
4747
LL | fn f(a: dyn B) -> dyn B;
4848
| ^^^^^ `B` is not dyn compatible
4949
|
5050
note: for a trait to be dyn compatible it needs to allow building a vtable
5151
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
52-
--> $DIR/dyn-incompatible-trait-should-use-self.rs:8:8
52+
--> $DIR/dyn-incompatible-trait-should-use-self.rs:7:8
5353
|
5454
LL | trait B {
5555
| - this trait is not dyn compatible...

tests/ui/suggestions/missing-lifetime-specifier.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// Different number of duplicated diagnostics on different targets
88
//@ compile-flags: -Zdeduplicate-diagnostics=yes
99

10-
#![allow(bare_trait_objects)]
1110
use std::cell::RefCell;
1211
use std::collections::HashMap;
1312

@@ -28,15 +27,15 @@ thread_local! {
2827
//~^ ERROR missing lifetime specifiers
2928
}
3029
thread_local! {
31-
static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
30+
static b: RefCell<HashMap<i32, Vec<Vec<&dyn Bar>>>> = RefCell::new(HashMap::new());
3231
//~^ ERROR missing lifetime specifiers
3332
}
3433
thread_local! {
3534
static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
3635
//~^ ERROR missing lifetime specifiers
3736
}
3837
thread_local! {
39-
static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
38+
static d: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<i32>>>>> = RefCell::new(HashMap::new());
4039
//~^ ERROR missing lifetime specifiers
4140
}
4241

@@ -45,7 +44,7 @@ thread_local! {
4544
//~^ ERROR union takes 2 lifetime arguments but 1 lifetime argument
4645
}
4746
thread_local! {
48-
static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
47+
static f: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
4948
//~^ ERROR trait takes 2 lifetime arguments but 1 lifetime argument was supplied
5049
//~| ERROR missing lifetime specifier
5150
}

tests/ui/suggestions/missing-lifetime-specifier.stderr

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0106]: missing lifetime specifiers
2-
--> $DIR/missing-lifetime-specifier.rs:27:44
2+
--> $DIR/missing-lifetime-specifier.rs:26:44
33
|
44
LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
55
| ^^^ expected 2 lifetime parameters
@@ -11,21 +11,21 @@ LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo<'static, 'static>>>>> = RefC
1111
| ++++++++++++++++++
1212

1313
error[E0106]: missing lifetime specifiers
14-
--> $DIR/missing-lifetime-specifier.rs:31:44
14+
--> $DIR/missing-lifetime-specifier.rs:30:44
1515
|
16-
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
17-
| ^^^^ expected 2 lifetime parameters
16+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&dyn Bar>>>> = RefCell::new(HashMap::new());
17+
| ^ ^^^ expected 2 lifetime parameters
1818
| |
1919
| expected named lifetime parameter
2020
|
2121
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
2222
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
2323
|
24-
LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static Bar<'static, 'static>>>>> = RefCell::new(HashMap::new());
25-
| +++++++ ++++++++++++++++++
24+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static dyn Bar<'static, 'static>>>>> = RefCell::new(HashMap::new());
25+
| +++++++ ++++++++++++++++++
2626

2727
error[E0106]: missing lifetime specifiers
28-
--> $DIR/missing-lifetime-specifier.rs:35:47
28+
--> $DIR/missing-lifetime-specifier.rs:34:47
2929
|
3030
LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
3131
| ^ expected 2 lifetime parameters
@@ -37,41 +37,46 @@ LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> =
3737
| +++++++++++++++++
3838

3939
error[E0106]: missing lifetime specifiers
40-
--> $DIR/missing-lifetime-specifier.rs:39:44
40+
--> $DIR/missing-lifetime-specifier.rs:38:44
4141
|
42-
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
43-
| ^ ^ expected 2 lifetime parameters
42+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<i32>>>>> = RefCell::new(HashMap::new());
43+
| ^ ^ expected 2 lifetime parameters
4444
| |
4545
| expected named lifetime parameter
4646
|
4747
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
4848
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
4949
|
50-
LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
51-
| +++++++ +++++++++++++++++
50+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static dyn Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
51+
| +++++++ +++++++++++++++++
5252

5353
error[E0106]: missing lifetime specifier
54-
--> $DIR/missing-lifetime-specifier.rs:48:44
54+
--> $DIR/missing-lifetime-specifier.rs:47:44
5555
|
56-
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
56+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
5757
| ^ expected named lifetime parameter
5858
|
5959
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
6060
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
6161
|
62-
LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
62+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static dyn Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
6363
| +++++++
64+
help: instead, you are more likely to want to return an owned value
65+
|
66+
LL - static f: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
67+
LL + static f: RefCell<HashMap<i32, Vec<Vec<dyn Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
68+
|
6469

6570
error[E0107]: union takes 2 lifetime arguments but 1 lifetime argument was supplied
66-
--> $DIR/missing-lifetime-specifier.rs:44:44
71+
--> $DIR/missing-lifetime-specifier.rs:43:44
6772
|
6873
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
6974
| ^^^ ------- supplied 1 lifetime argument
7075
| |
7176
| expected 2 lifetime arguments
7277
|
7378
note: union defined here, with 2 lifetime parameters: `'t`, `'k`
74-
--> $DIR/missing-lifetime-specifier.rs:20:11
79+
--> $DIR/missing-lifetime-specifier.rs:19:11
7580
|
7681
LL | pub union Qux<'t, 'k, I> {
7782
| ^^^ -- --
@@ -81,22 +86,22 @@ LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> =
8186
| +++++++++
8287

8388
error[E0107]: trait takes 2 lifetime arguments but 1 lifetime argument was supplied
84-
--> $DIR/missing-lifetime-specifier.rs:48:45
89+
--> $DIR/missing-lifetime-specifier.rs:47:49
8590
|
86-
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
87-
| ^^^ ------- supplied 1 lifetime argument
88-
| |
89-
| expected 2 lifetime arguments
91+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
92+
| ^^^ ------- supplied 1 lifetime argument
93+
| |
94+
| expected 2 lifetime arguments
9095
|
9196
note: trait defined here, with 2 lifetime parameters: `'t`, `'k`
92-
--> $DIR/missing-lifetime-specifier.rs:24:7
97+
--> $DIR/missing-lifetime-specifier.rs:23:7
9398
|
9499
LL | trait Tar<'t, 'k, I> {}
95100
| ^^^ -- --
96101
help: add missing lifetime argument
97102
|
98-
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
99-
| +++++++++
103+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
104+
| +++++++++
100105

101106
error: aborting due to 7 previous errors
102107

tests/ui/traits/auxiliary/traitimpl.rs

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

33
pub trait Bar<'a> : 'a {}
44

5-
impl<'a> Bar<'a> {
5+
impl<'a> dyn Bar<'a> {
66
pub fn bar(&self) {}
77
}

tests/ui/traits/const-traits/inherent-impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ trait T {}
77
impl const S {}
88
//~^ ERROR inherent impls cannot be `const`
99

10-
impl const T {}
10+
impl const dyn T {}
1111
//~^ ERROR inherent impls cannot be `const`
1212

1313
fn main() {}

tests/ui/traits/const-traits/inherent-impl.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | impl const S {}
1111
error: inherent impls cannot be `const`
1212
--> $DIR/inherent-impl.rs:10:12
1313
|
14-
LL | impl const T {}
15-
| ----- ^ inherent impl for this type
14+
LL | impl const dyn T {}
15+
| ----- ^^^^^ inherent impl for this type
1616
| |
1717
| `const` because of this
1818
|

tests/ui/type/auxiliary/crate_a1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ pub struct Foo;
22

33
pub trait Bar {}
44

5-
pub fn bar() -> Box<Bar> {
5+
pub fn bar() -> Box<dyn Bar> {
66
unimplemented!()
77
}
88

99

1010
pub fn try_foo(x: Foo){}
11-
pub fn try_bar(x: Box<Bar>){}
11+
pub fn try_bar(x: Box<dyn Bar>){}

tests/ui/type/auxiliary/crate_a2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ pub struct Foo;
22

33
pub trait Bar {}
44

5-
pub fn bar() -> Box<Bar> {
5+
pub fn bar() -> Box<dyn Bar> {
66
unimplemented!()
77
}

tests/ui/type/type-mismatch-same-crate-name.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ LL | extern crate crate_a1 as a;
5959
note: function defined here
6060
--> $DIR/auxiliary/crate_a1.rs:11:8
6161
|
62-
LL | pub fn try_bar(x: Box<Bar>){}
62+
LL | pub fn try_bar(x: Box<dyn Bar>){}
6363
| ^^^^^^^
6464

6565
error: aborting due to 2 previous errors

tests/ui/unsized/unsized3-rpass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl Tr for St {
3737
}
3838

3939
struct Qux<'a> {
40-
f: Tr + 'a,
40+
f: dyn Tr + 'a,
4141
}
4242

4343
pub fn main() {
@@ -85,7 +85,7 @@ pub fn main() {
8585
}
8686

8787
let obj: Box<St> = Box::new(St { f: 42 });
88-
let obj: &Tr = &*obj;
88+
let obj: &dyn Tr = &*obj;
8989
let data: Box<_> = Box::new(Qux_ { f: St { f: 234 } });
9090
let x: &Qux = &*ptr::from_raw_parts::<Qux>(&*data as *const _, ptr::metadata(obj));
9191
assert_eq!(x.f.foo(), 234);

tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
trait Trait<const N: Trait = bar> {
1+
trait Trait<const N: dyn Trait = bar> {
22
//~^ ERROR cannot find value `bar` in this scope
33
//~| ERROR cycle detected when computing type of `Trait::N`
4-
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
5-
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
6-
fn fnc<const N: Trait = u32>(&self) -> Trait {
4+
fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait {
75
//~^ ERROR the name `N` is already used for a generic parameter in this item's generic parameters
86
//~| ERROR expected value, found builtin type `u32`
97
//~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
108
//~| ERROR associated item referring to unboxed trait object for its own trait
11-
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
12-
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
13-
//~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
14-
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
159
bar
1610
//~^ ERROR cannot find value `bar` in this scope
1711
}

0 commit comments

Comments
 (0)