@@ -105,17 +105,24 @@ use syntax::ast::{m_const, m_mutbl, m_imm};
105
105
use syntax:: ast;
106
106
use syntax:: ast_map;
107
107
108
+ #[ deriving_eq]
109
+ pub enum CheckTraitsFlag {
110
+ CheckTraitsOnly ,
111
+ CheckTraitsAndInherentMethods ,
112
+ }
113
+
108
114
pub fn lookup (
109
115
fcx : @mut FnCtxt ,
110
116
111
117
// In a call `a.b::<X, Y, ...>(...)`:
112
- expr : @ast:: expr , // The expression `a.b`.
113
- self_expr : @ast:: expr , // The expression `a`.
114
- callee_id : node_id , // Where to store the type of `a.b`
115
- m_name : ast:: ident , // The ident `b`.
116
- self_ty : ty:: t , // The type of `a`.
117
- supplied_tps : & [ ty:: t ] , // The list of types X, Y, ... .
118
- deref_args : check:: DerefArgs ) // Whether we autopointer first.
118
+ expr : @ast:: expr , // The expression `a.b`.
119
+ self_expr : @ast:: expr , // The expression `a`.
120
+ callee_id : node_id , // Where to store the type of `a.b`
121
+ m_name : ast:: ident , // The ident `b`.
122
+ self_ty : ty:: t , // The type of `a`.
123
+ supplied_tps : & [ ty:: t ] , // The list of types X, Y, ... .
124
+ deref_args : check:: DerefArgs , // Whether we autopointer first.
125
+ check_traits : CheckTraitsFlag ) // Whether we check traits only.
119
126
-> Option < method_map_entry >
120
127
{
121
128
let lcx = LookupContext {
@@ -129,6 +136,7 @@ pub fn lookup(
129
136
inherent_candidates : @mut ~[ ] ,
130
137
extension_candidates : @mut ~[ ] ,
131
138
deref_args : deref_args,
139
+ check_traits : check_traits,
132
140
} ;
133
141
let mme = lcx. do_lookup ( self_ty) ;
134
142
debug ! ( "method lookup for %s yielded %?" ,
@@ -147,6 +155,7 @@ pub struct LookupContext {
147
155
inherent_candidates : @mut ~[ Candidate ] ,
148
156
extension_candidates : @mut ~[ Candidate ] ,
149
157
deref_args : check:: DerefArgs ,
158
+ check_traits : CheckTraitsFlag ,
150
159
}
151
160
152
161
/**
@@ -298,7 +307,9 @@ pub impl LookupContext/&self {
298
307
self_ty, self_did, & substs) ;
299
308
}
300
309
ty_enum( did, _) | ty_struct( did, _) => {
301
- self . push_inherent_impl_candidates_for_type ( did) ;
310
+ if self . check_traits == CheckTraitsAndInherentMethods {
311
+ self . push_inherent_impl_candidates_for_type ( did) ;
312
+ }
302
313
}
303
314
_ => { /* No inherent methods in these types */ }
304
315
}
0 commit comments