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_consts)]
12 #![feature(associated_type_defaults)]
72 // B is pub, not in scope
73 // C : A + B is pub, in scope
76 // Methods, method call
77 // a, b, c are resolved as trait items, their traits need to be in scope
78 S.a(); //~ ERROR no method named `a` found for type `S` in the current scope
79 S.b(); //~ ERROR no method named `b` found for type `S` in the current scope
81 // a, b, c are resolved as inherent items, their traits don't need to be in scope
83 c.a(); //~ ERROR method `a` is private
88 // a, b, c are resolved as trait items, their traits need to be in scope
89 S::a(&S); //~ ERROR no associated item named `a` found for type `S` in the current scope
90 S::b(&S); //~ ERROR no associated item named `b` found for type `S` in the current scope
92 // a, b, c are resolved as inherent items, their traits don't need to be in scope
93 C::a(&S); //~ ERROR method `a` is private
98 fn check_assoc_const() {
100 // B is pub, not in scope
101 // C : A + B is pub, in scope
104 // Associated constants
105 // A, B, C are resolved as trait items, their traits need to be in scope
106 S::A; //~ ERROR no associated item named `A` found for type `S` in the current scope
107 S::B; //~ ERROR no associated item named `B` found for type `S` in the current scope
109 // A, B, C are resolved as inherent items, their traits don't need to be in scope
110 C::A; //~ ERROR associated constant `A` is private
111 //~^ ERROR the trait `assoc_const::C` cannot be made into an object
112 //~| ERROR the trait bound `assoc_const::C: assoc_const::A` is not satisfied
113 C::B; // ERROR the trait `assoc_const::C` cannot be made into an object
114 //~^ ERROR the trait bound `assoc_const::C: assoc_const::B` is not satisfied
118 fn check_assoc_ty<T: assoc_ty::C>() {
120 // B is pub, not in scope
121 // C : A + B is pub, in scope
125 // A, B, C are resolved as trait items, their traits need to be in scope, not implemented yet
126 let _: S::A; //~ ERROR ambiguous associated type
127 let _: S::B; //~ ERROR ambiguous associated type
128 let _: S::C; //~ ERROR ambiguous associated type
129 // A, B, C are resolved as inherent items, their traits don't need to be in scope
130 let _: T::A; //~ ERROR associated type `A` is private