1 // Copyright 2015 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.
11 // It should not be possible to use the concrete value of a defaulted
12 // associated type in the impl defining it -- otherwise, what happens
13 // if it's overridden?
15 #![feature(specialization)]
19 fn generate(self) -> Self::Output;
22 impl<T> Example for T {
23 default type Output = Box<T>;
24 default fn generate(self) -> Self::Output {
25 Box::new(self) //~ ERROR mismatched types
29 impl Example for bool {
31 fn generate(self) -> bool { self }
34 fn trouble<T>(t: T) -> Box<T> {
35 Example::generate(t) //~ ERROR mismatched types
38 fn weaponize() -> bool {
39 let b: Box<bool> = trouble(true);