Skip to content

Commit a1d1d7a

Browse files
committed
Update test/ui/parser for bare_trait_object warnings
1 parent 54e1055 commit a1d1d7a

10 files changed

+43
-12
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// compile-pass
22

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

57
fn main() {}

src/test/ui/parser/trailing-plus-in-bounds.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// compile-flags: -Z continue-parse-after-error
33

44
#![feature(box_syntax)]
5+
#![allow(bare_trait_objects)]
56

67
use std::fmt::Debug;
78

src/test/ui/parser/trait-object-bad-parens.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// compile-flags: -Z continue-parse-after-error
22

33
#![feature(optin_builtin_traits)]
4+
#![allow(bare_trait_objects)]
45

56
auto trait Auto {}
67

src/test/ui/parser/trait-object-bad-parens.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error[E0178]: expected a path on the left-hand side of `+`, not `((Auto))`
2-
--> $DIR/trait-object-bad-parens.rs:8:16
2+
--> $DIR/trait-object-bad-parens.rs:9:16
33
|
44
LL | let _: Box<((Auto)) + Auto>;
55
| ^^^^^^^^^^^^^^^ expected a path
66

77
error[E0178]: expected a path on the left-hand side of `+`, not `(Auto + Auto)`
8-
--> $DIR/trait-object-bad-parens.rs:10:16
8+
--> $DIR/trait-object-bad-parens.rs:11:16
99
|
1010
LL | let _: Box<(Auto + Auto) + Auto>;
1111
| ^^^^^^^^^^^^^^^^^^^^ expected a path
1212

1313
error[E0178]: expected a path on the left-hand side of `+`, not `(Auto)`
14-
--> $DIR/trait-object-bad-parens.rs:12:16
14+
--> $DIR/trait-object-bad-parens.rs:13:16
1515
|
1616
LL | let _: Box<(Auto +) + Auto>;
1717
| ^^^^^^^^^^^^^^^ expected a path
1818

1919
error[E0178]: expected a path on the left-hand side of `+`, not `(dyn Auto)`
20-
--> $DIR/trait-object-bad-parens.rs:14:16
20+
--> $DIR/trait-object-bad-parens.rs:15:16
2121
|
2222
LL | let _: Box<(dyn Auto) + Auto>;
2323
| ^^^^^^^^^^^^^^^^^ expected a path

src/test/ui/parser/trait-object-lifetime-parens.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// compile-flags: -Z continue-parse-after-error
22

3+
#![allow(bare_trait_objects)]
4+
35
trait Trait {}
46

57
fn f<'a, T: Trait + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported

src/test/ui/parser/trait-object-lifetime-parens.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error: parenthesized lifetime bounds are not supported
2-
--> $DIR/trait-object-lifetime-parens.rs:5:21
2+
--> $DIR/trait-object-lifetime-parens.rs:7:21
33
|
44
LL | fn f<'a, T: Trait + ('a)>() {}
55
| ^^^^ help: remove the parentheses
66

77
error: parenthesized lifetime bounds are not supported
8-
--> $DIR/trait-object-lifetime-parens.rs:8:24
8+
--> $DIR/trait-object-lifetime-parens.rs:10:24
99
|
1010
LL | let _: Box<Trait + ('a)>;
1111
| ^^^^ help: remove the parentheses
1212

1313
error: expected `:`, found `)`
14-
--> $DIR/trait-object-lifetime-parens.rs:9:19
14+
--> $DIR/trait-object-lifetime-parens.rs:11:19
1515
|
1616
LL | let _: Box<('a) + Trait>;
1717
| ^ expected `:`
1818

1919
error: chained comparison operators require parentheses
20-
--> $DIR/trait-object-lifetime-parens.rs:9:15
20+
--> $DIR/trait-object-lifetime-parens.rs:11:15
2121
|
2222
LL | let _: Box<('a) + Trait>;
2323
| ^^^^^^^^^^^^^^^
@@ -26,7 +26,7 @@ LL | let _: Box<('a) + Trait>;
2626
= help: or use `(...)` if you meant to specify fn arguments
2727

2828
error: expected type, found `'a`
29-
--> $DIR/trait-object-lifetime-parens.rs:9:17
29+
--> $DIR/trait-object-lifetime-parens.rs:11:17
3030
|
3131
LL | let _: Box<('a) + Trait>;
3232
| - ^^

src/test/ui/parser/trait-object-polytrait-priority.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(bare_trait_objects)]
2+
13
trait Trait<'a> {}
24

35
fn main() {

src/test/ui/parser/trait-object-polytrait-priority.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0178]: expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>`
2-
--> $DIR/trait-object-polytrait-priority.rs:4:12
2+
--> $DIR/trait-object-polytrait-priority.rs:6:12
33
|
44
LL | let _: &for<'a> Trait<'a> + 'static;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try adding parentheses: `&(for<'a> Trait<'a> + 'static)`

src/test/ui/parser/trait-object-trait-parens.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ fn f<T: (Copy) + (?Sized) + (for<'a> Trait<'a>)>() {}
55
fn main() {
66
let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
77
//~^ ERROR `?Trait` is not permitted in trait object types
8+
//~| WARN trait objects without an explicit `dyn` are deprecated
89
let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>;
10+
//~^ WARN trait objects without an explicit `dyn` are deprecated
911
let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
1012
//~^ ERROR use of undeclared lifetime name `'a`
1113
//~| ERROR `?Trait` is not permitted in trait object types
14+
//~| WARN trait objects without an explicit `dyn` are deprecated
1215
}

src/test/ui/parser/trait-object-trait-parens.stderr

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,33 @@ LL | let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
55
| ^^^^^^^^
66

77
error: `?Trait` is not permitted in trait object types
8-
--> $DIR/trait-object-trait-parens.rs:9:47
8+
--> $DIR/trait-object-trait-parens.rs:11:47
99
|
1010
LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
1111
| ^^^^^^^^
1212

13+
warning: trait objects without an explicit `dyn` are deprecated
14+
--> $DIR/trait-object-trait-parens.rs:6:16
15+
|
16+
LL | let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (Copy) + (?Sized) + (for<'a> Trait<'a>)`
18+
|
19+
= note: #[warn(bare_trait_objects)] on by default
20+
21+
warning: trait objects without an explicit `dyn` are deprecated
22+
--> $DIR/trait-object-trait-parens.rs:9:16
23+
|
24+
LL | let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>;
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (?Sized) + (for<'a> Trait<'a>) + (Copy)`
26+
27+
warning: trait objects without an explicit `dyn` are deprecated
28+
--> $DIR/trait-object-trait-parens.rs:11:16
29+
|
30+
LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (for<'a> Trait<'a>) + (Copy) + (?Sized)`
32+
1333
error[E0261]: use of undeclared lifetime name `'a`
14-
--> $DIR/trait-object-trait-parens.rs:9:31
34+
--> $DIR/trait-object-trait-parens.rs:11:31
1535
|
1636
LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
1737
| ^^ undeclared lifetime

0 commit comments

Comments
 (0)