1 // Copyright 2016 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(associated_type_defaults)]
71 // B is pub, not in scope
72 // C : A + B is pub, in scope
75 // Methods, method call
76 // a, b, c are resolved as trait items, their traits need to be in scope
77 S.a(); //~ ERROR no method named `a` found for type `S` in the current scope
78 S.b(); //~ ERROR no method named `b` found for type `S` in the current scope
80 // a, b, c are resolved as inherent items, their traits don't need to be in scope
82 c.a(); //~ ERROR method `a` is private
87 // a, b, c are resolved as trait items, their traits need to be in scope
89 //~^ ERROR no function or associated item named `a` found for type `S`
91 //~^ ERROR no function or associated item named `b` found for type `S`
93 // a, b, c are resolved as inherent items, their traits don't need to be in scope
94 C::a(&S); //~ ERROR method `a` is private
99 fn check_assoc_const() {
101 // B is pub, not in scope
102 // C : A + B is pub, in scope
105 // Associated constants
106 // A, B, C are resolved as trait items, their traits need to be in scope
107 S::A; //~ ERROR no associated item named `A` found for type `S` in the current scope
108 S::B; //~ ERROR no associated item named `B` found for type `S` in the current scope
110 // A, B, C are resolved as inherent items, their traits don't need to be in scope
111 C::A; //~ ERROR associated constant `A` is private
112 //~^ ERROR the trait `assoc_const::C` cannot be made into an object
113 //~| ERROR the trait bound `assoc_const::C: assoc_const::A` is not satisfied
114 C::B; // ERROR the trait `assoc_const::C` cannot be made into an object
115 //~^ ERROR the trait bound `assoc_const::C: assoc_const::B` is not satisfied
119 fn check_assoc_ty<T: assoc_ty::C>() {
121 // B is pub, not in scope
122 // C : A + B is pub, in scope
126 // A, B, C are resolved as trait items, their traits need to be in scope, not implemented yet
127 let _: S::A; //~ ERROR ambiguous associated type
128 let _: S::B; //~ ERROR ambiguous associated type
129 let _: S::C; //~ ERROR ambiguous associated type
130 // A, B, C are resolved as inherent items, their traits don't need to be in scope
131 let _: T::A; //~ ERROR associated type `A` is private
135 // Associated types, bindings
140 A = u8, //~ ERROR associated type `A` is private