Skip to content

Commit 227d5dd

Browse files
committed
---
yaml --- r: 48620 b: refs/heads/snap-stage3 c: 7353568 h: refs/heads/master v: v3
1 parent 712efb5 commit 227d5dd

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 1274d4a0063fbb0ae5feaa277caf08c3230b46a9
4+
refs/heads/snap-stage3: 7353568cd8d079fd4d9f928bc49a228276e86d19
55
refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/typeck/check/method.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,24 @@ use syntax::ast::{m_const, m_mutbl, m_imm};
105105
use syntax::ast;
106106
use syntax::ast_map;
107107

108+
#[deriving_eq]
109+
pub enum CheckTraitsFlag {
110+
CheckTraitsOnly,
111+
CheckTraitsAndInherentMethods,
112+
}
113+
108114
pub fn lookup(
109115
fcx: @mut FnCtxt,
110116

111117
// 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.
119126
-> Option<method_map_entry>
120127
{
121128
let lcx = LookupContext {
@@ -129,6 +136,7 @@ pub fn lookup(
129136
inherent_candidates: @mut ~[],
130137
extension_candidates: @mut ~[],
131138
deref_args: deref_args,
139+
check_traits: check_traits,
132140
};
133141
let mme = lcx.do_lookup(self_ty);
134142
debug!("method lookup for %s yielded %?",
@@ -147,6 +155,7 @@ pub struct LookupContext {
147155
inherent_candidates: @mut ~[Candidate],
148156
extension_candidates: @mut ~[Candidate],
149157
deref_args: check::DerefArgs,
158+
check_traits: CheckTraitsFlag,
150159
}
151160

152161
/**
@@ -299,7 +308,9 @@ pub impl LookupContext/&self {
299308
self_ty, self_did, &substs);
300309
}
301310
ty_enum(did, _) | ty_struct(did, _) => {
302-
self.push_inherent_impl_candidates_for_type(did);
311+
if self.check_traits == CheckTraitsAndInherentMethods {
312+
self.push_inherent_impl_candidates_for_type(did);
313+
}
303314
}
304315
_ => { /* No inherent methods in these types */ }
305316
}

branches/snap-stage3/src/librustc/middle/typeck/check/mod.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ use middle::typeck::astconv::{AstConv, ast_path_to_ty};
8989
use middle::typeck::astconv::{ast_region_to_region, ast_ty_to_ty};
9090
use middle::typeck::astconv;
9191
use middle::typeck::check::_match::pat_ctxt;
92-
use middle::typeck::check::method::TransformTypeNormally;
92+
use middle::typeck::check::method::{CheckTraitsAndInherentMethods};
93+
use middle::typeck::check::method::{CheckTraitsOnly, TransformTypeNormally};
9394
use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_sig;
9495
use middle::typeck::check::vtable::{LocationInfo, VtableContext};
9596
use middle::typeck::CrateCtxt;
@@ -1371,7 +1372,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
13711372
method_name,
13721373
expr_t,
13731374
tps,
1374-
DontDerefArgs) {
1375+
DontDerefArgs,
1376+
CheckTraitsAndInherentMethods) {
13751377
Some(ref entry) => {
13761378
let method_map = fcx.ccx.method_map;
13771379
method_map.insert(expr.id, (*entry));
@@ -1453,9 +1455,15 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
14531455
+args: ~[@ast::expr],
14541456
+deref_args: DerefArgs)
14551457
-> Option<(ty::t, bool)> {
1456-
match method::lookup(fcx, op_ex, self_ex,
1457-
op_ex.callee_id, opname, self_t, ~[],
1458-
deref_args) {
1458+
match method::lookup(fcx,
1459+
op_ex,
1460+
self_ex,
1461+
op_ex.callee_id,
1462+
opname,
1463+
self_t,
1464+
~[],
1465+
deref_args,
1466+
CheckTraitsOnly) {
14591467
Some(ref origin) => {
14601468
let method_ty = fcx.node_ty(op_ex.callee_id);
14611469
let method_map = fcx.ccx.method_map;
@@ -1732,7 +1740,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
17321740
field,
17331741
expr_t,
17341742
tps,
1735-
DontDerefArgs) {
1743+
DontDerefArgs,
1744+
CheckTraitsAndInherentMethods) {
17361745
Some(ref entry) => {
17371746
let method_map = fcx.ccx.method_map;
17381747
method_map.insert(expr.id, (*entry));

0 commit comments

Comments
 (0)