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 #![feature(specialization)]
13 // Check a number of scenarios in which one impl tries to override another,
14 // without correctly using `default`.
16 ////////////////////////////////////////////////////////////////////////////////
17 // Test 1: one layer of specialization, multiple methods, missing `default`
18 ////////////////////////////////////////////////////////////////////////////////
32 fn foo(&self) {} //~ ERROR E0520
35 fn bar(&self) {} //~ ERROR E0520
38 ////////////////////////////////////////////////////////////////////////////////
39 // Test 2: one layer of specialization, missing `default` on associated type
40 ////////////////////////////////////////////////////////////////////////////////
51 type T = (); //~ ERROR E0520
54 ////////////////////////////////////////////////////////////////////////////////
55 // Test 3a: multiple layers of specialization, missing interior `default`
56 ////////////////////////////////////////////////////////////////////////////////
62 default impl<T> Baz for T {
66 impl<T: Clone> Baz for T {
71 fn baz(&self) {} //~ ERROR E0520
74 ////////////////////////////////////////////////////////////////////////////////
75 // Test 3b: multiple layers of specialization, missing interior `default`,
76 // redundant `default` in bottom layer.
77 ////////////////////////////////////////////////////////////////////////////////
83 default impl<T> Redundant for T {
84 fn redundant(&self) {}
87 impl<T: Clone> Redundant for T {
88 fn redundant(&self) {}
91 default impl Redundant for i32 {
92 fn redundant(&self) {} //~ ERROR E0520