1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 #![feature(existential_type)]
16 // two definitions with different types
17 existential type Foo: std::fmt::Debug;
23 fn bar() -> Foo { //~ ERROR defining existential type use differs from previous
27 // declared but never defined
28 existential type Bar: std::fmt::Debug; //~ ERROR could not find defining uses
31 // declared in module but not defined inside of it
32 pub existential type Boo: ::std::fmt::Debug; //~ ERROR could not find defining uses
35 fn bomp() -> boo::Boo {
36 "" //~ ERROR mismatched types
41 pub existential type Boo: ::std::fmt::Debug;
47 // don't actually know the type here
50 let _: &str = bomp(); //~ ERROR mismatched types
53 fn bomp() -> boo::Boo {
54 "" //~ ERROR mismatched types
61 existential type Underconstrained<T: Trait>: 'static; //~ ERROR the trait bound `T: Trait`
64 fn underconstrain<T>(_: T) -> Underconstrained<T> {
68 existential type MyIter<T>: Iterator<Item = T>;
70 fn my_iter<T>(t: T) -> MyIter<T> {
74 fn my_iter2<T>(t: T) -> MyIter<T> { //~ ERROR defining existential type use differs from previous
78 existential type WrongGeneric<T>: 'static;
79 //~^ ERROR the parameter type `T` may not live long enough
81 fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
85 // don't reveal the concrete type
86 existential type NoReveal: std::fmt::Debug;
88 fn define_no_reveal() -> NoReveal {
92 fn no_reveal(x: NoReveal) {
93 let _: &'static str = x; //~ mismatched types
94 let _ = x as &'static str; //~ non-primitive cast