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
90 //~^ ERROR no function or associated item named `a` found for type `S`
92 //~^ ERROR no function or associated item named `b` found for type `S`
94 // a, b, c are resolved as inherent items, their traits don't need to be in scope
95 C::a(&S); //~ ERROR method `a` is private
100 fn check_assoc_const() {
102 // B is pub, not in scope
103 // C : A + B is pub, in scope
106 // Associated constants
107 // A, B, C are resolved as trait items, their traits need to be in scope
108 S::A; //~ ERROR no associated item named `A` found for type `S` in the current scope
109 S::B; //~ ERROR no associated item named `B` found for type `S` in the current scope
111 // A, B, C are resolved as inherent items, their traits don't need to be in scope
112 C::A; //~ ERROR associated constant `A` is private
113 //~^ ERROR the trait `assoc_const::C` cannot be made into an object
114 //~| ERROR the trait bound `assoc_const::C: assoc_const::A` is not satisfied
115 C::B; // ERROR the trait `assoc_const::C` cannot be made into an object
116 //~^ ERROR the trait bound `assoc_const::C: assoc_const::B` is not satisfied
120 fn check_assoc_ty<T: assoc_ty::C>() {
122 // B is pub, not in scope
123 // C : A + B is pub, in scope
127 // A, B, C are resolved as trait items, their traits need to be in scope, not implemented yet
128 let _: S::A; //~ ERROR ambiguous associated type
129 let _: S::B; //~ ERROR ambiguous associated type
130 let _: S::C; //~ ERROR ambiguous associated type
131 // A, B, C are resolved as inherent items, their traits don't need to be in scope
132 let _: T::A; //~ ERROR associated type `A` is private