Skip to content

Commit 2077b07

Browse files
committed
---
yaml --- r: 185839 b: refs/heads/auto c: 7a3054f h: refs/heads/master i: 185837: 85b4d44 185835: 5337633 185831: 83dd0c8 185823: 5c09555 v: v3
1 parent 63f9192 commit 2077b07

File tree

17 files changed

+90
-160
lines changed

17 files changed

+90
-160
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 0f49254b31353a80710af50e4f387740d154e60b
13+
refs/heads/auto: 7a3054f55c48682d1458176863e0ccb08d505aa8
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/metadata/csearch.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,9 @@ pub fn get_trait_name(cstore: &cstore::CStore, def: ast::DefId) -> ast::Name {
150150
def.node)
151151
}
152152

153-
pub fn get_trait_item_name_and_kind(cstore: &cstore::CStore, def: ast::DefId)
154-
-> (ast::Name, def::TraitItemKind) {
153+
pub fn is_static_method(cstore: &cstore::CStore, def: ast::DefId) -> bool {
155154
let cdata = cstore.get_crate_data(def.krate);
156-
decoder::get_trait_item_name_and_kind(cstore.intr.clone(),
157-
&*cdata,
158-
def.node)
155+
decoder::is_static_method(&*cdata, def.node)
159156
}
160157

161158
pub fn get_trait_item_def_ids(cstore: &cstore::CStore, def: ast::DefId)

branches/auto/src/librustc/metadata/decoder.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,7 @@ fn item_to_def_like(item: rbml::Doc, did: ast::DefId, cnum: ast::CrateNum)
334334
def::FromImpl(item_reqd_and_translated_parent_item(cnum,
335335
item))
336336
};
337-
match fam {
338-
// We don't bother to get encode/decode the trait id, we don't need it.
339-
Method => DlDef(def::DefMethod(did, None, provenance)),
340-
StaticMethod => DlDef(def::DefStaticMethod(did, provenance)),
341-
_ => panic!()
342-
}
337+
DlDef(def::DefMethod(did, provenance))
343338
}
344339
Type => {
345340
if item_sort(item) == Some('t') {
@@ -853,22 +848,13 @@ pub fn get_trait_name(intr: Rc<IdentInterner>,
853848
item_name(&*intr, doc)
854849
}
855850

856-
pub fn get_trait_item_name_and_kind(intr: Rc<IdentInterner>,
857-
cdata: Cmd,
858-
id: ast::NodeId)
859-
-> (ast::Name, def::TraitItemKind) {
851+
pub fn is_static_method(cdata: Cmd, id: ast::NodeId) -> bool {
860852
let doc = lookup_item(id, cdata.data());
861-
let name = item_name(&*intr, doc);
862853
match item_sort(doc) {
863854
Some('r') | Some('p') => {
864-
let explicit_self = get_explicit_self(doc);
865-
(name, def::TraitItemKind::from_explicit_self_category(explicit_self))
866-
}
867-
Some('t') => (name, def::TypeTraitItemKind),
868-
c => {
869-
panic!("get_trait_item_name_and_kind(): unknown trait item kind \
870-
in metadata: `{:?}`", c)
855+
get_explicit_self(doc) == ty::StaticExplicitSelfCategory
871856
}
857+
_ => false
872858
}
873859
}
874860

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,8 @@ impl tr for def::Def {
423423
fn tr(&self, dcx: &DecodeContext) -> def::Def {
424424
match *self {
425425
def::DefFn(did, is_ctor) => def::DefFn(did.tr(dcx), is_ctor),
426-
def::DefStaticMethod(did, p) => {
427-
def::DefStaticMethod(did.tr(dcx), p.map(|did2| did2.tr(dcx)))
428-
}
429-
def::DefMethod(did0, did1, p) => {
430-
def::DefMethod(did0.tr(dcx),
431-
did1.map(|did1| did1.tr(dcx)),
432-
p.map(|did2| did2.tr(dcx)))
426+
def::DefMethod(did, p) => {
427+
def::DefMethod(did.tr(dcx), p.map(|did2| did2.tr(dcx)))
433428
}
434429
def::DefSelfTy(nid) => { def::DefSelfTy(dcx.tr_id(nid)) }
435430
def::DefMod(did) => { def::DefMod(did.tr(dcx)) }

branches/auto/src/librustc/middle/check_const.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
452452
v.add_qualif(NON_ZERO_SIZED);
453453
}
454454
}
455-
Some(def::DefFn(..)) |
456-
Some(def::DefStaticMethod(..)) | Some(def::DefMethod(..)) => {
455+
Some(def::DefFn(..)) | Some(def::DefMethod(..)) => {
457456
// Count the function pointer.
458457
v.add_qualif(NON_ZERO_SIZED);
459458
}

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

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111
pub use self::Def::*;
1212
pub use self::MethodProvenance::*;
13-
pub use self::TraitItemKind::*;
1413

1514
use middle::subst::ParamSpace;
16-
use middle::ty::{ExplicitSelfCategory, StaticExplicitSelfCategory};
1715
use util::nodemap::NodeMap;
1816
use syntax::ast;
1917
use syntax::ast_util::local_def;
@@ -23,7 +21,6 @@ use std::cell::RefCell;
2321
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
2422
pub enum Def {
2523
DefFn(ast::DefId, bool /* is_ctor */),
26-
DefStaticMethod(/* method */ ast::DefId, MethodProvenance),
2724
DefSelfTy(/* trait id */ ast::NodeId),
2825
DefMod(ast::DefId),
2926
DefForeignMod(ast::DefId),
@@ -51,7 +48,7 @@ pub enum Def {
5148
DefStruct(ast::DefId),
5249
DefRegion(ast::NodeId),
5350
DefLabel(ast::NodeId),
54-
DefMethod(ast::DefId /* method */, Option<ast::DefId> /* trait */, MethodProvenance),
51+
DefMethod(ast::DefId /* method */, MethodProvenance),
5552
}
5653

5754
/// The result of resolving the prefix of a path to a type:
@@ -99,25 +96,6 @@ impl MethodProvenance {
9996
}
10097
}
10198

102-
#[derive(Clone, Copy, Eq, PartialEq)]
103-
pub enum TraitItemKind {
104-
NonstaticMethodTraitItemKind,
105-
StaticMethodTraitItemKind,
106-
TypeTraitItemKind,
107-
}
108-
109-
impl TraitItemKind {
110-
pub fn from_explicit_self_category(explicit_self_category:
111-
ExplicitSelfCategory)
112-
-> TraitItemKind {
113-
if explicit_self_category == StaticExplicitSelfCategory {
114-
StaticMethodTraitItemKind
115-
} else {
116-
NonstaticMethodTraitItemKind
117-
}
118-
}
119-
}
120-
12199
impl Def {
122100
pub fn local_node_id(&self) -> ast::NodeId {
123101
let def_id = self.def_id();
@@ -127,11 +105,10 @@ impl Def {
127105

128106
pub fn def_id(&self) -> ast::DefId {
129107
match *self {
130-
DefFn(id, _) | DefStaticMethod(id, _) | DefMod(id) |
131-
DefForeignMod(id) | DefStatic(id, _) |
108+
DefFn(id, _) | DefMod(id) | DefForeignMod(id) | DefStatic(id, _) |
132109
DefVariant(_, id, _) | DefTy(id, _) | DefAssociatedTy(_, id) |
133110
DefTyParam(_, _, id, _) | DefUse(id) | DefStruct(id) | DefTrait(id) |
134-
DefMethod(id, _, _) | DefConst(id) => {
111+
DefMethod(id, _) | DefConst(id) => {
135112
id
136113
}
137114
DefLocal(id) |

branches/auto/src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
575575

576576
match def {
577577
def::DefStruct(..) | def::DefVariant(..) | def::DefConst(..) |
578-
def::DefFn(..) | def::DefStaticMethod(..) | def::DefMethod(..) => {
578+
def::DefFn(..) | def::DefMethod(..) => {
579579
Ok(self.cat_rvalue_node(id, span, expr_ty))
580580
}
581581
def::DefMod(_) | def::DefForeignMod(_) | def::DefUse(_) |

branches/auto/src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4584,7 +4584,7 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
45844584
def::DefFn(_, true) => RvalueDpsExpr,
45854585

45864586
// Fn pointers are just scalar values.
4587-
def::DefFn(..) | def::DefStaticMethod(..) | def::DefMethod(..) => RvalueDatumExpr,
4587+
def::DefFn(..) | def::DefMethod(..) => RvalueDatumExpr,
45884588

45894589
// Note: there is actually a good case to be made that
45904590
// DefArg's, particularly those of immediate type, ought to

branches/auto/src/librustc_privacy/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,6 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
795795
// be accurate and we can get slightly wonky error messages (but type
796796
// checking is always correct).
797797
match self.tcx.def_map.borrow()[path_id].clone() {
798-
def::DefStaticMethod(..) => ck("static method"),
799798
def::DefFn(..) => ck("function"),
800799
def::DefStatic(..) => ck("static"),
801800
def::DefConst(..) => ck("const"),
@@ -804,7 +803,6 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
804803
def::DefTy(_, true) => ck("enum"),
805804
def::DefTrait(..) => ck("trait"),
806805
def::DefStruct(..) => ck("struct"),
807-
def::DefMethod(_, Some(..), _) => ck("trait method"),
808806
def::DefMethod(..) => ck("method"),
809807
def::DefMod(..) => ck("module"),
810808
_ => {}

branches/auto/src/librustc_resolve/build_reduced_graph.rs

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ use syntax::ast::{Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn};
4040
use syntax::ast::{ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, ItemDefaultImpl};
4141
use syntax::ast::{ItemStruct, ItemTrait, ItemTy, ItemUse};
4242
use syntax::ast::{MethodImplItem, Name, NamedField, NodeId};
43-
use syntax::ast::{PathListIdent, PathListMod};
44-
use syntax::ast::{Public, SelfStatic};
43+
use syntax::ast::{PathListIdent, PathListMod, Public};
4544
use syntax::ast::StmtDecl;
4645
use syntax::ast::StructVariantKind;
4746
use syntax::ast::TupleVariantKind;
@@ -598,22 +597,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
598597
&new_parent,
599598
ForbidDuplicateValues,
600599
method.span);
601-
let def = match method.pe_explicit_self()
602-
.node {
603-
SelfStatic => {
604-
// Static methods become
605-
// `DefStaticMethod`s.
606-
DefStaticMethod(local_def(method.id),
607-
FromImpl(local_def(item.id)))
608-
}
609-
_ => {
610-
// Non-static methods become
611-
// `DefMethod`s.
612-
DefMethod(local_def(method.id),
613-
None,
614-
FromImpl(local_def(item.id)))
615-
}
616-
};
600+
let def = DefMethod(local_def(method.id),
601+
FromImpl(local_def(item.id)));
617602

618603
// NB: not IMPORTABLE
619604
let modifiers = if method.pe_vis() == ast::Public {
@@ -674,31 +659,16 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
674659

675660
// Add the names of all the items to the trait info.
676661
for trait_item in items {
677-
let (name, kind) = match *trait_item {
662+
let (name, trait_item_id) = match *trait_item {
678663
ast::RequiredMethod(_) |
679664
ast::ProvidedMethod(_) => {
680665
let ty_m = ast_util::trait_item_to_ty_method(trait_item);
681666

682667
let name = ty_m.ident.name;
683668

684669
// Add it as a name in the trait module.
685-
let (def, static_flag) = match ty_m.explicit_self
686-
.node {
687-
SelfStatic => {
688-
// Static methods become `DefStaticMethod`s.
689-
(DefStaticMethod(
690-
local_def(ty_m.id),
691-
FromTrait(local_def(item.id))),
692-
StaticMethodTraitItemKind)
693-
}
694-
_ => {
695-
// Non-static methods become `DefMethod`s.
696-
(DefMethod(local_def(ty_m.id),
697-
Some(local_def(item.id)),
698-
FromTrait(local_def(item.id))),
699-
NonstaticMethodTraitItemKind)
700-
}
701-
};
670+
let def = DefMethod(local_def(ty_m.id),
671+
FromTrait(local_def(item.id)));
702672

703673
let method_name_bindings =
704674
self.add_child(name,
@@ -710,7 +680,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
710680
ty_m.span,
711681
PUBLIC);
712682

713-
(name, static_flag)
683+
(name, local_def(ty_m.id))
714684
}
715685
ast::TypeTraitItem(ref associated_type) => {
716686
let def = DefAssociatedTy(local_def(item.id),
@@ -726,11 +696,12 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
726696
associated_type.ty_param.span,
727697
PUBLIC);
728698

729-
(associated_type.ty_param.ident.name, TypeTraitItemKind)
699+
(associated_type.ty_param.ident.name,
700+
local_def(associated_type.ty_param.id))
730701
}
731702
};
732703

733-
self.trait_item_map.insert((name, def_id), kind);
704+
self.trait_item_map.insert((name, def_id), trait_item_id);
734705
}
735706

736707
name_bindings.define_type(DefTrait(def_id), sp, modifiers);
@@ -889,7 +860,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
889860
csearch::get_tuple_struct_definition_if_ctor(&self.session.cstore, ctor_id)
890861
.map_or(def, |_| DefStruct(ctor_id)), DUMMY_SP, modifiers);
891862
}
892-
DefFn(..) | DefStaticMethod(..) | DefStatic(..) | DefConst(..) | DefMethod(..) => {
863+
DefFn(..) | DefStatic(..) | DefConst(..) | DefMethod(..) => {
893864
debug!("(building reduced graph for external \
894865
crate) building value (fn/static) {}", final_ident);
895866
// impl methods have already been defined with the correct importability modifier
@@ -911,21 +882,19 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
911882

912883
let trait_item_def_ids =
913884
csearch::get_trait_item_def_ids(&self.session.cstore, def_id);
914-
for trait_item_def_id in &trait_item_def_ids {
915-
let (trait_item_name, trait_item_kind) =
916-
csearch::get_trait_item_name_and_kind(
917-
&self.session.cstore,
918-
trait_item_def_id.def_id());
885+
for trait_item_def in &trait_item_def_ids {
886+
let trait_item_name = csearch::get_trait_name(&self.session.cstore,
887+
trait_item_def.def_id());
919888

920889
debug!("(building reduced graph for external crate) ... \
921890
adding trait item '{}'",
922891
token::get_name(trait_item_name));
923892

924-
self.trait_item_map.insert((trait_item_name, def_id), trait_item_kind);
893+
self.trait_item_map.insert((trait_item_name, def_id),
894+
trait_item_def.def_id());
925895

926896
if is_exported {
927-
self.external_exports
928-
.insert(trait_item_def_id.def_id());
897+
self.external_exports.insert(trait_item_def.def_id());
929898
}
930899
}
931900

0 commit comments

Comments
 (0)