Update test/ui/parser for bare_trait_object warnings
This commit is contained in:
parent
54e10558b4
commit
a1d1d7a2c6
10 changed files with 43 additions and 12 deletions
|
@ -1,5 +1,7 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
|
|
||||||
|
#![allow(bare_trait_objects)]
|
||||||
|
|
||||||
type A = Box<(Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318)
|
type A = Box<(Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318)
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// compile-flags: -Z continue-parse-after-error
|
// compile-flags: -Z continue-parse-after-error
|
||||||
|
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
#![allow(bare_trait_objects)]
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// compile-flags: -Z continue-parse-after-error
|
// compile-flags: -Z continue-parse-after-error
|
||||||
|
|
||||||
#![feature(optin_builtin_traits)]
|
#![feature(optin_builtin_traits)]
|
||||||
|
#![allow(bare_trait_objects)]
|
||||||
|
|
||||||
auto trait Auto {}
|
auto trait Auto {}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
error[E0178]: expected a path on the left-hand side of `+`, not `((Auto))`
|
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>;
|
LL | let _: Box<((Auto)) + Auto>;
|
||||||
| ^^^^^^^^^^^^^^^ expected a path
|
| ^^^^^^^^^^^^^^^ expected a path
|
||||||
|
|
||||||
error[E0178]: expected a path on the left-hand side of `+`, not `(Auto + Auto)`
|
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>;
|
LL | let _: Box<(Auto + Auto) + Auto>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ expected a path
|
| ^^^^^^^^^^^^^^^^^^^^ expected a path
|
||||||
|
|
||||||
error[E0178]: expected a path on the left-hand side of `+`, not `(Auto)`
|
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>;
|
LL | let _: Box<(Auto +) + Auto>;
|
||||||
| ^^^^^^^^^^^^^^^ expected a path
|
| ^^^^^^^^^^^^^^^ expected a path
|
||||||
|
|
||||||
error[E0178]: expected a path on the left-hand side of `+`, not `(dyn Auto)`
|
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>;
|
LL | let _: Box<(dyn Auto) + Auto>;
|
||||||
| ^^^^^^^^^^^^^^^^^ expected a path
|
| ^^^^^^^^^^^^^^^^^ expected a path
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// compile-flags: -Z continue-parse-after-error
|
// compile-flags: -Z continue-parse-after-error
|
||||||
|
|
||||||
|
#![allow(bare_trait_objects)]
|
||||||
|
|
||||||
trait Trait {}
|
trait Trait {}
|
||||||
|
|
||||||
fn f<'a, T: Trait + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported
|
fn f<'a, T: Trait + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
error: parenthesized lifetime bounds are not supported
|
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)>() {}
|
LL | fn f<'a, T: Trait + ('a)>() {}
|
||||||
| ^^^^ help: remove the parentheses
|
| ^^^^ help: remove the parentheses
|
||||||
|
|
||||||
error: parenthesized lifetime bounds are not supported
|
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)>;
|
LL | let _: Box<Trait + ('a)>;
|
||||||
| ^^^^ help: remove the parentheses
|
| ^^^^ help: remove the parentheses
|
||||||
|
|
||||||
error: expected `:`, found `)`
|
error: expected `:`, found `)`
|
||||||
--> $DIR/trait-object-lifetime-parens.rs:9:19
|
--> $DIR/trait-object-lifetime-parens.rs:11:19
|
||||||
|
|
|
|
||||||
LL | let _: Box<('a) + Trait>;
|
LL | let _: Box<('a) + Trait>;
|
||||||
| ^ expected `:`
|
| ^ expected `:`
|
||||||
|
|
||||||
error: chained comparison operators require parentheses
|
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>;
|
LL | let _: Box<('a) + Trait>;
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
@ -26,7 +26,7 @@ LL | let _: Box<('a) + Trait>;
|
||||||
= help: or use `(...)` if you meant to specify fn arguments
|
= help: or use `(...)` if you meant to specify fn arguments
|
||||||
|
|
||||||
error: expected type, found `'a`
|
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>;
|
LL | let _: Box<('a) + Trait>;
|
||||||
| - ^^
|
| - ^^
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(bare_trait_objects)]
|
||||||
|
|
||||||
trait Trait<'a> {}
|
trait Trait<'a> {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0178]: expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>`
|
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;
|
LL | let _: &for<'a> Trait<'a> + 'static;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try adding parentheses: `&(for<'a> Trait<'a> + 'static)`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try adding parentheses: `&(for<'a> Trait<'a> + 'static)`
|
||||||
|
|
|
@ -5,8 +5,11 @@ fn f<T: (Copy) + (?Sized) + (for<'a> Trait<'a>)>() {}
|
||||||
fn main() {
|
fn main() {
|
||||||
let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
|
let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
|
||||||
//~^ ERROR `?Trait` is not permitted in trait object types
|
//~^ 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)>;
|
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)>;
|
let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
|
||||||
//~^ ERROR use of undeclared lifetime name `'a`
|
//~^ ERROR use of undeclared lifetime name `'a`
|
||||||
//~| ERROR `?Trait` is not permitted in trait object types
|
//~| ERROR `?Trait` is not permitted in trait object types
|
||||||
|
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,33 @@ LL | let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: `?Trait` is not permitted in trait object types
|
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)>;
|
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`
|
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)>;
|
LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
|
||||||
| ^^ undeclared lifetime
|
| ^^ undeclared lifetime
|
||||||
|
|
Loading…
Reference in a new issue