Skip to content

Commit

Permalink
Update test/ui/parser for bare_trait_object warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
memoryruins committed May 28, 2019
1 parent 54e1055 commit a1d1d7a
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/test/ui/parser/bounds-obj-parens.rs
@@ -1,5 +1,7 @@
// compile-pass

#![allow(bare_trait_objects)]

type A = Box<(Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318)

fn main() {}
1 change: 1 addition & 0 deletions src/test/ui/parser/trailing-plus-in-bounds.rs
Expand Up @@ -2,6 +2,7 @@
// compile-flags: -Z continue-parse-after-error

#![feature(box_syntax)]
#![allow(bare_trait_objects)]

use std::fmt::Debug;

Expand Down
1 change: 1 addition & 0 deletions src/test/ui/parser/trait-object-bad-parens.rs
@@ -1,6 +1,7 @@
// compile-flags: -Z continue-parse-after-error

#![feature(optin_builtin_traits)]
#![allow(bare_trait_objects)]

auto trait Auto {}

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/parser/trait-object-bad-parens.stderr
@@ -1,23 +1,23 @@
error[E0178]: expected a path on the left-hand side of `+`, not `((Auto))`
--> $DIR/trait-object-bad-parens.rs:8:16
--> $DIR/trait-object-bad-parens.rs:9:16
|
LL | let _: Box<((Auto)) + Auto>;
| ^^^^^^^^^^^^^^^ expected a path

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

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

error[E0178]: expected a path on the left-hand side of `+`, not `(dyn Auto)`
--> $DIR/trait-object-bad-parens.rs:14:16
--> $DIR/trait-object-bad-parens.rs:15:16
|
LL | let _: Box<(dyn Auto) + Auto>;
| ^^^^^^^^^^^^^^^^^ expected a path
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/parser/trait-object-lifetime-parens.rs
@@ -1,5 +1,7 @@
// compile-flags: -Z continue-parse-after-error

#![allow(bare_trait_objects)]

trait Trait {}

fn f<'a, T: Trait + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/parser/trait-object-lifetime-parens.stderr
@@ -1,23 +1,23 @@
error: parenthesized lifetime bounds are not supported
--> $DIR/trait-object-lifetime-parens.rs:5:21
--> $DIR/trait-object-lifetime-parens.rs:7:21
|
LL | fn f<'a, T: Trait + ('a)>() {}
| ^^^^ help: remove the parentheses

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

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

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

error: expected type, found `'a`
--> $DIR/trait-object-lifetime-parens.rs:9:17
--> $DIR/trait-object-lifetime-parens.rs:11:17
|
LL | let _: Box<('a) + Trait>;
| - ^^
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/parser/trait-object-polytrait-priority.rs
@@ -1,3 +1,5 @@
#![allow(bare_trait_objects)]

trait Trait<'a> {}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/trait-object-polytrait-priority.stderr
@@ -1,5 +1,5 @@
error[E0178]: expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>`
--> $DIR/trait-object-polytrait-priority.rs:4:12
--> $DIR/trait-object-polytrait-priority.rs:6:12
|
LL | let _: &for<'a> Trait<'a> + 'static;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try adding parentheses: `&(for<'a> Trait<'a> + 'static)`
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/parser/trait-object-trait-parens.rs
Expand Up @@ -5,8 +5,11 @@ fn f<T: (Copy) + (?Sized) + (for<'a> Trait<'a>)>() {}
fn main() {
let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
//~^ ERROR `?Trait` is not permitted in trait object types
//~| WARN trait objects without an explicit `dyn` are deprecated
let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>;
//~^ WARN trait objects without an explicit `dyn` are deprecated
let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
//~^ ERROR use of undeclared lifetime name `'a`
//~| ERROR `?Trait` is not permitted in trait object types
//~| WARN trait objects without an explicit `dyn` are deprecated
}
24 changes: 22 additions & 2 deletions src/test/ui/parser/trait-object-trait-parens.stderr
Expand Up @@ -5,13 +5,33 @@ LL | let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
| ^^^^^^^^

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

warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/trait-object-trait-parens.rs:6:16
|
LL | let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (Copy) + (?Sized) + (for<'a> Trait<'a>)`
|
= note: #[warn(bare_trait_objects)] on by default

warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/trait-object-trait-parens.rs:9:16
|
LL | let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (?Sized) + (for<'a> Trait<'a>) + (Copy)`

warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/trait-object-trait-parens.rs:11:16
|
LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (for<'a> Trait<'a>) + (Copy) + (?Sized)`

error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/trait-object-trait-parens.rs:9:31
--> $DIR/trait-object-trait-parens.rs:11:31
|
LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
| ^^ undeclared lifetime
Expand Down

0 comments on commit a1d1d7a

Please sign in to comment.