Skip to content

Commit 83ec70e

Browse files
committed
---
yaml --- r: 138159 b: refs/heads/try c: eb598e5 h: refs/heads/master i: 138157: fb5f24b 138155: defd49f 138151: 99137e1 138143: e985ba1 v: v3
1 parent 469322e commit 83ec70e

File tree

11 files changed

+52
-97
lines changed

11 files changed

+52
-97
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: b6e0d3a5bf4c88650a22f605f822e02c6b163580
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
5-
refs/heads/try: db640d53b82f70540092b70aa8decade97e55d63
5+
refs/heads/try: eb598e5344bde56b0ba12681e7d46c25b2dd1c88
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/metadata/encoder.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,10 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
407407
method_did.def_id());
408408
match impl_item {
409409
ty::MethodTraitItem(ref m) => {
410-
if m.explicit_self ==
411-
ty::StaticExplicitSelfCategory {
412-
encode_reexported_static_method(rbml_w,
413-
exp,
414-
m.def_id,
415-
m.ident);
416-
}
410+
encode_reexported_static_method(rbml_w,
411+
exp,
412+
m.def_id,
413+
m.ident);
417414
}
418415
ty::TypeTraitItem(_) => {}
419416
}
@@ -434,8 +431,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
434431
Some(trait_items) => {
435432
for trait_item in trait_items.iter() {
436433
match *trait_item {
437-
ty::MethodTraitItem(ref m) if m.explicit_self ==
438-
ty::StaticExplicitSelfCategory => {
434+
ty::MethodTraitItem(ref m) => {
439435
encode_reexported_static_method(rbml_w,
440436
exp,
441437
m.def_id,
@@ -1408,18 +1404,16 @@ fn encode_info_for_item(ecx: &EncodeContext,
14081404
encode_family(rbml_w,
14091405
fn_style_static_method_family(
14101406
method_ty.fty.fn_style));
1411-
1412-
let pty = ty::lookup_item_type(tcx,
1413-
method_def_id);
1414-
encode_bounds_and_type(rbml_w, ecx, &pty);
14151407
}
1416-
14171408
_ => {
14181409
encode_family(rbml_w,
14191410
style_fn_family(
14201411
method_ty.fty.fn_style));
14211412
}
14221413
}
1414+
let pty = ty::lookup_item_type(tcx,
1415+
method_def_id);
1416+
encode_bounds_and_type(rbml_w, ecx, &pty);
14231417

14241418
is_nonstatic_method = method_ty.explicit_self !=
14251419
ty::StaticExplicitSelfCategory;

branches/try/src/librustc/middle/astencode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ impl tr for def::Def {
453453
},
454454
p)
455455
}
456-
def::DefMethod(did0, did1) => {
457-
def::DefMethod(did0.tr(dcx), did1.map(|did1| did1.tr(dcx)))
456+
def::DefMethod(did0, did1, p) => {
457+
def::DefMethod(did0.tr(dcx), did1.map(|did1| did1.tr(dcx)), p)
458458
}
459459
def::DefSelfTy(nid) => { def::DefSelfTy(dcx.tr_id(nid)) }
460460
def::DefMod(did) => { def::DefMod(did.tr(dcx)) }

branches/try/src/librustc/middle/def.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub enum Def {
4646
DefTyParamBinder(ast::NodeId), /* struct, impl or trait with ty params */
4747
DefRegion(ast::NodeId),
4848
DefLabel(ast::NodeId),
49-
DefMethod(ast::DefId /* method */, Option<ast::DefId> /* trait */),
49+
DefMethod(ast::DefId /* method */, Option<ast::DefId> /* trait */, MethodProvenance),
5050
}
5151

5252
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
@@ -62,7 +62,7 @@ impl Def {
6262
DefForeignMod(id) | DefStatic(id, _) |
6363
DefVariant(_, id, _) | DefTy(id, _) | DefAssociatedTy(id) |
6464
DefTyParam(_, id, _) | DefUse(id) | DefStruct(id) | DefTrait(id) |
65-
DefMethod(id, _) | DefConst(id) => {
65+
DefMethod(id, _, _) | DefConst(id) => {
6666
id
6767
}
6868
DefLocal(id) |

branches/try/src/librustc/middle/privacy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
811811
def::DefTy(_, true) => ck("enum"),
812812
def::DefTrait(..) => ck("trait"),
813813
def::DefStruct(..) => ck("struct"),
814-
def::DefMethod(_, Some(..)) => ck("trait method"),
814+
def::DefMethod(_, Some(..), _) => ck("trait method"),
815815
def::DefMethod(..) => ck("method"),
816816
def::DefMod(..) => ck("module"),
817817
_ => {}

branches/try/src/librustc/middle/resolve.rs

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ enum FallbackSuggestion {
250250
Method,
251251
TraitItem,
252252
StaticMethod(String),
253-
StaticTraitMethod(String),
253+
TraitMethod(String),
254254
}
255255

256256
enum TypeParameters<'a> {
@@ -1386,17 +1386,17 @@ impl<'a> Resolver<'a> {
13861386
.node {
13871387
SelfStatic => {
13881388
// Static methods become
1389-
// `def_static_method`s.
1390-
DefStaticMethod(
1391-
local_def(method.id),
1392-
FromImpl(local_def(item.id)),
1393-
method.pe_fn_style())
1389+
// `DefStaticMethod`s.
1390+
DefStaticMethod(local_def(method.id),
1391+
FromImpl(local_def(item.id)),
1392+
method.pe_fn_style())
13941393
}
13951394
_ => {
13961395
// Non-static methods become
1397-
// `def_method`s.
1396+
// `DefMethod`s.
13981397
DefMethod(local_def(method.id),
1399-
None)
1398+
None,
1399+
FromImpl(local_def(item.id)))
14001400
}
14011401
};
14021402

@@ -1476,19 +1476,18 @@ impl<'a> Resolver<'a> {
14761476
let (def, static_flag) = match ty_m.explicit_self
14771477
.node {
14781478
SelfStatic => {
1479-
// Static methods become
1480-
// `def_static_method`s.
1479+
// Static methods become `DefStaticMethod`s.
14811480
(DefStaticMethod(
14821481
local_def(ty_m.id),
14831482
FromTrait(local_def(item.id)),
14841483
ty_m.fn_style),
14851484
StaticMethodTraitItemKind)
14861485
}
14871486
_ => {
1488-
// Non-static methods become
1489-
// `def_method`s.
1487+
// Non-static methods become `DefMethod`s.
14901488
(DefMethod(local_def(ty_m.id),
1491-
Some(local_def(item.id))),
1489+
Some(local_def(item.id)),
1490+
FromTrait(local_def(item.id))),
14921491
NonstaticMethodTraitItemKind)
14931492
}
14941493
};
@@ -4607,8 +4606,7 @@ impl<'a> Resolver<'a> {
46074606
// We also need a new scope for the method-
46084607
// specific type parameters.
46094608
this.resolve_method(
4610-
MethodRibKind(id,
4611-
ProvidedMethod(method.id)),
4609+
MethodRibKind(id, ProvidedMethod(method.id)),
46124610
&**method);
46134611
}
46144612
TypeImplItem(ref typedef) => {
@@ -5393,8 +5391,8 @@ impl<'a> Resolver<'a> {
53935391

53945392
let ident = path.segments.last().unwrap().identifier;
53955393
let def = match self.resolve_definition_of_name_in_module(containing_module.clone(),
5396-
ident.name,
5397-
namespace) {
5394+
ident.name,
5395+
namespace) {
53985396
NoNameDefinition => {
53995397
// We failed to resolve the name. Report an error.
54005398
return None;
@@ -5403,26 +5401,6 @@ impl<'a> Resolver<'a> {
54035401
(def, last_private.or(lp))
54045402
}
54055403
};
5406-
match containing_module.kind.get() {
5407-
TraitModuleKind | ImplModuleKind => {
5408-
match containing_module.def_id.get() {
5409-
Some(def_id) => {
5410-
match self.trait_item_map.find(&(ident.name, def_id)) {
5411-
Some(&StaticMethodTraitItemKind) => (),
5412-
Some(&TypeTraitItemKind) => (),
5413-
None => (),
5414-
Some(&NonstaticMethodTraitItemKind) => {
5415-
debug!("containing module was a trait or impl \
5416-
and name was a method -> not resolved");
5417-
return None;
5418-
}
5419-
}
5420-
},
5421-
_ => (),
5422-
}
5423-
},
5424-
_ => (),
5425-
}
54265404
match containing_module.def_id.get() {
54275405
Some(DefId{krate: kid, ..}) => { self.used_crates.insert(kid); },
54285406
_ => {}
@@ -5668,8 +5646,8 @@ impl<'a> Resolver<'a> {
56685646
FromTrait(_) => unreachable!()
56695647
}
56705648
}
5671-
Some(DefMethod(_, None)) if allowed == Everything => return Method,
5672-
Some(DefMethod(_, Some(_))) => return TraitItem,
5649+
Some(DefMethod(_, None, _)) if allowed == Everything => return Method,
5650+
Some(DefMethod(_, Some(_), _)) => return TraitItem,
56735651
_ => ()
56745652
}
56755653
}
@@ -5684,7 +5662,9 @@ impl<'a> Resolver<'a> {
56845662
let path_str = self.path_idents_to_string(&trait_ref.path);
56855663

56865664
match self.trait_item_map.find(&(name, did)) {
5687-
Some(&StaticMethodTraitItemKind) => return StaticTraitMethod(path_str),
5665+
Some(&StaticMethodTraitItemKind) => {
5666+
return TraitMethod(path_str)
5667+
}
56885668
Some(_) => return TraitItem,
56895669
None => {}
56905670
}
@@ -5810,7 +5790,7 @@ impl<'a> Resolver<'a> {
58105790
Method
58115791
| TraitItem =>
58125792
format!("to call `self.{}`", wrong_name),
5813-
StaticTraitMethod(path_str)
5793+
TraitMethod(path_str)
58145794
| StaticMethod(path_str) =>
58155795
format!("to call `{}::{}`", path_str, wrong_name)
58165796
};

branches/try/src/librustc/middle/save/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
244244
def::DefStaticMethod(_, _, _) |
245245
def::DefTyParam(..) |
246246
def::DefUse(_) |
247-
def::DefMethod(_, _) |
247+
def::DefMethod(..) |
248248
def::DefPrimTy(_) => {
249249
self.sess.span_bug(span, format!("lookup_def_kind for unexpected item: {:?}",
250250
def).as_slice());

branches/try/src/librustc/middle/trans/callee.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
137137
};
138138
}
139139

140-
fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, def: def::Def, ref_expr: &ast::Expr)
140+
fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
141+
def: def::Def,
142+
ref_expr: &ast::Expr)
141143
-> Callee<'blk, 'tcx> {
142144
debug!("trans_def(def={}, ref_expr={})", def.repr(bcx.tcx()), ref_expr.repr(bcx.tcx()));
143145
let expr_ty = node_id_type(bcx, ref_expr.id);
@@ -165,14 +167,13 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
165167
let def_id = inline::maybe_instantiate_inline(bcx.ccx(), did);
166168
Callee { bcx: bcx, data: Intrinsic(def_id.node, substs) }
167169
}
168-
def::DefFn(did, _, _) | def::DefMethod(did, _) |
170+
def::DefFn(did, _, _) | def::DefMethod(did, _, def::FromImpl(_)) |
169171
def::DefStaticMethod(did, def::FromImpl(_), _) => {
170172
fn_callee(bcx, trans_fn_ref(bcx, did, ExprId(ref_expr.id)))
171173
}
172-
def::DefStaticMethod(impl_did,
173-
def::FromTrait(trait_did),
174-
_) => {
175-
fn_callee(bcx, meth::trans_static_method_callee(bcx, impl_did,
174+
def::DefStaticMethod(meth_did, def::FromTrait(trait_did), _) |
175+
def::DefMethod(meth_did, _, def::FromTrait(trait_did)) => {
176+
fn_callee(bcx, meth::trans_static_method_callee(bcx, meth_did,
176177
trait_did,
177178
ref_expr.id))
178179
}

branches/try/src/librustc/middle/typeck/check/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5027,10 +5027,9 @@ pub fn polytype_for_def(fcx: &FnCtxt,
50275027
let typ = fcx.local_ty(sp, nid);
50285028
return no_params(typ);
50295029
}
5030-
def::DefFn(id, _, _) | def::DefStaticMethod(id, _, _) |
5030+
def::DefFn(id, _, _) | def::DefStaticMethod(id, _, _) | def::DefMethod(id, _, _) |
50315031
def::DefStatic(id, _) | def::DefVariant(_, id, _) |
5032-
def::DefStruct(id) | def::DefConst(id) |
5033-
def::DefMethod(id, _) => {
5032+
def::DefStruct(id) | def::DefConst(id) => {
50345033
return ty::lookup_item_type(fcx.ccx.tcx, id);
50355034
}
50365035
def::DefTrait(_) |
@@ -5229,8 +5228,7 @@ pub fn instantiate_path(fcx: &FnCtxt,
52295228
}
52305229

52315230
fcx.add_obligations_for_parameters(
5232-
traits::ObligationCause::new(span,
5233-
traits::ItemObligation(def.def_id())),
5231+
traits::ObligationCause::new(span, traits::ItemObligation(def.def_id())),
52345232
&substs,
52355233
&polytype.generics);
52365234

branches/try/src/librustc/middle/typeck/collect.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ pub fn collect_item_types(ccx: &CrateCtxt) {
7777
}
7878

7979
match ccx.tcx.lang_items.ty_desc() {
80-
Some(id) => { collect_intrinsic_type(ccx, id); } None => {}
80+
Some(id) => { collect_intrinsic_type(ccx, id); }
81+
None => {}
8182
}
8283
match ccx.tcx.lang_items.opaque() {
83-
Some(id) => { collect_intrinsic_type(ccx, id); } None => {}
84+
Some(id) => { collect_intrinsic_type(ccx, id); }
85+
None => {}
8486
}
8587

8688
let mut visitor = CollectTraitDefVisitor{ ccx: ccx };
@@ -306,10 +308,7 @@ fn collect_trait_methods(ccx: &CrateCtxt,
306308
}
307309
});
308310

309-
if ty_method.explicit_self ==
310-
ty::StaticExplicitSelfCategory {
311-
make_static_method_ty(ccx, &*ty_method);
312-
}
311+
make_method_ty(ccx, &*ty_method);
313312

314313
tcx.impl_or_trait_items
315314
.borrow_mut()
@@ -364,7 +363,7 @@ fn collect_trait_methods(ccx: &CrateCtxt,
364363
_ => { /* Ignore things that aren't traits */ }
365364
}
366365

367-
fn make_static_method_ty(ccx: &CrateCtxt, m: &ty::Method) {
366+
fn make_method_ty(ccx: &CrateCtxt, m: &ty::Method) {
368367
ccx.tcx.tcache.borrow_mut().insert(
369368
m.def_id,
370369
Polytype {

branches/try/src/test/compile-fail/call-extern-trait-as-function.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)