Add more tests.
This commit is contained in:
parent
1cda3c3b49
commit
a8fcfcef30
7 changed files with 147 additions and 54 deletions
|
|
@ -1,38 +0,0 @@
|
|||
error: type parameters on the left side of a trait alias cannot be bounded
|
||||
--> $DIR/trait-alias-fail.rs:14:14
|
||||
|
|
||||
LL | trait Alias2<T: Clone = ()> = Default;
|
||||
| ^
|
||||
|
||||
error: type parameters on the left side of a trait alias cannot have defaults
|
||||
--> $DIR/trait-alias-fail.rs:14:14
|
||||
|
|
||||
LL | trait Alias2<T: Clone = ()> = Default;
|
||||
| ^
|
||||
|
||||
error[E0404]: expected trait, found trait alias `Alias1`
|
||||
--> $DIR/trait-alias-fail.rs:18:6
|
||||
|
|
||||
LL | impl Alias1 for () {}
|
||||
| ^^^^^^ not a trait
|
||||
|
||||
error[E0658]: trait aliases are experimental (see issue #41517)
|
||||
--> $DIR/trait-alias-fail.rs:13:1
|
||||
|
|
||||
LL | trait Alias1<T> = Default where T: Clone;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(trait_alias)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: trait aliases are experimental (see issue #41517)
|
||||
--> $DIR/trait-alias-fail.rs:14:1
|
||||
|
|
||||
LL | trait Alias2<T: Clone = ()> = Default;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(trait_alias)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors occurred: E0404, E0658.
|
||||
For more information about an error, try `rustc --explain E0404`.
|
||||
|
|
@ -10,11 +10,12 @@
|
|||
|
||||
// gate-test-trait_alias
|
||||
|
||||
trait Alias1<T> = Default where T: Clone;
|
||||
trait Alias2<T: Clone = ()> = Default;
|
||||
trait CloneDefault<T> = Default where T: Clone;
|
||||
trait BoundedAlias<T: Clone = ()> = Default;
|
||||
|
||||
impl Alias1 {}
|
||||
trait A<T: Send> {}
|
||||
trait B<T> = A<T>; // FIXME: parameter T should need a bound here, or semantics should be changed
|
||||
|
||||
impl Alias1 for () {}
|
||||
impl CloneDefault for () {}
|
||||
|
||||
fn main() {}
|
||||
46
src/test/ui/traits/trait-alias-fail1.stderr
Normal file
46
src/test/ui/traits/trait-alias-fail1.stderr
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
error: type parameters on the left side of a trait alias cannot be bounded
|
||||
--> $DIR/trait-alias-fail1.rs:14:20
|
||||
|
|
||||
LL | trait BoundedAlias<T: Clone = ()> = Default;
|
||||
| ^
|
||||
|
||||
error: type parameters on the left side of a trait alias cannot have defaults
|
||||
--> $DIR/trait-alias-fail1.rs:14:20
|
||||
|
|
||||
LL | trait BoundedAlias<T: Clone = ()> = Default;
|
||||
| ^
|
||||
|
||||
error[E0404]: expected trait, found trait alias `CloneDefault`
|
||||
--> $DIR/trait-alias-fail1.rs:19:6
|
||||
|
|
||||
LL | impl CloneDefault for () {}
|
||||
| ^^^^^^^^^^^^ not a trait
|
||||
|
||||
error[E0658]: trait aliases are experimental (see issue #41517)
|
||||
--> $DIR/trait-alias-fail1.rs:13:1
|
||||
|
|
||||
LL | trait CloneDefault<T> = Default where T: Clone;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(trait_alias)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: trait aliases are experimental (see issue #41517)
|
||||
--> $DIR/trait-alias-fail1.rs:14:1
|
||||
|
|
||||
LL | trait BoundedAlias<T: Clone = ()> = Default;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(trait_alias)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: trait aliases are experimental (see issue #41517)
|
||||
--> $DIR/trait-alias-fail1.rs:17:1
|
||||
|
|
||||
LL | trait B<T> = A<T>; // FIXME: this should not work... or should it?
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(trait_alias)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Some errors occurred: E0404, E0658.
|
||||
For more information about an error, try `rustc --explain E0404`.
|
||||
19
src/test/ui/traits/trait-alias-fail2.rs
Normal file
19
src/test/ui/traits/trait-alias-fail2.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// gate-test-trait_alias
|
||||
|
||||
trait EqAlias = Eq;
|
||||
trait IteratorAlias = Iterator;
|
||||
|
||||
fn main() {
|
||||
let _: &dyn EqAlias = &123;
|
||||
let _: &dyn IteratorAlias = &vec![123].into_iter();
|
||||
}
|
||||
19
src/test/ui/traits/trait-alias-fail2.stderr
Normal file
19
src/test/ui/traits/trait-alias-fail2.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
error[E0658]: trait aliases are experimental (see issue #41517)
|
||||
--> $DIR/trait-alias-fail2.rs:13:1
|
||||
|
|
||||
LL | trait EqAlias = Eq;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(trait_alias)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: trait aliases are experimental (see issue #41517)
|
||||
--> $DIR/trait-alias-fail2.rs:14:1
|
||||
|
|
||||
LL | trait IteratorAlias = Iterator;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(trait_alias)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue