Skip to content

Commit 1397f99

Browse files
committed
Cross crait inherant impls
1 parent d416d16 commit 1397f99

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

src/librustc/metadata/csearch.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use syntax::parse::token;
3232

3333
use std::collections::hashmap::HashMap;
3434

35-
pub struct StaticMethodInfo {
35+
pub struct MethodInfo {
3636
pub name: ast::Name,
3737
pub def_id: ast::DefId,
3838
pub vis: ast::Visibility,
@@ -177,11 +177,11 @@ pub fn get_type_name_if_impl(cstore: &cstore::CStore, def: ast::DefId)
177177
decoder::get_type_name_if_impl(&*cdata, def.node)
178178
}
179179

180-
pub fn get_static_methods_if_impl(cstore: &cstore::CStore,
180+
pub fn get_methods_if_impl(cstore: &cstore::CStore,
181181
def: ast::DefId)
182-
-> Option<Vec<StaticMethodInfo> > {
182+
-> Option<Vec<MethodInfo> > {
183183
let cdata = cstore.get_crate_data(def.krate);
184-
decoder::get_static_methods_if_impl(cstore.intr.clone(), &*cdata, def.node)
184+
decoder::get_methods_if_impl(cstore.intr.clone(), &*cdata, def.node)
185185
}
186186

187187
pub fn get_item_attrs(cstore: &cstore::CStore,

src/librustc/metadata/decoder.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use back::svh::Svh;
1616
use metadata::cstore::crate_metadata;
1717
use metadata::common::*;
18-
use metadata::csearch::StaticMethodInfo;
18+
use metadata::csearch::MethodInfo;
1919
use metadata::csearch;
2020
use metadata::cstore;
2121
use metadata::tydecode::{parse_ty_data, parse_region_data, parse_def_id,
@@ -902,10 +902,10 @@ pub fn get_type_name_if_impl(cdata: Cmd,
902902
ret
903903
}
904904

905-
pub fn get_static_methods_if_impl(intr: Rc<IdentInterner>,
905+
pub fn get_methods_if_impl(intr: Rc<IdentInterner>,
906906
cdata: Cmd,
907907
node_id: ast::NodeId)
908-
-> Option<Vec<StaticMethodInfo> > {
908+
-> Option<Vec<MethodInfo> > {
909909
let item = lookup_item(node_id, cdata.data());
910910
if item_family(item) != Impl {
911911
return None;
@@ -924,14 +924,14 @@ pub fn get_static_methods_if_impl(intr: Rc<IdentInterner>,
924924
true
925925
});
926926

927-
let mut static_impl_methods = Vec::new();
927+
let mut impl_methods = Vec::new();
928928
for impl_method_id in impl_method_ids.iter() {
929929
let impl_method_doc = lookup_item(impl_method_id.node, cdata.data());
930930
let family = item_family(impl_method_doc);
931931
match family {
932-
StaticMethod => {
933-
static_impl_methods.push(StaticMethodInfo {
934-
name: item_name(&*intr, impl_method_doc),
932+
StaticMethod | Method => {
933+
impl_methods.push(MethodInfo {
934+
ident: item_name(&*intr, impl_method_doc),
935935
def_id: item_def_id(impl_method_doc, cdata),
936936
vis: item_visibility(impl_method_doc),
937937
});
@@ -940,7 +940,7 @@ pub fn get_static_methods_if_impl(intr: Rc<IdentInterner>,
940940
}
941941
}
942942

943-
return Some(static_impl_methods);
943+
return Some(impl_methods);
944944
}
945945

946946
/// If node_id is the constructor of a tuple struct, retrieve the NodeId of

src/librustc/middle/resolve.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,15 +1950,14 @@ impl<'a> Resolver<'a> {
19501950
}
19511951
}
19521952
DlImpl(def) => {
1953-
// We only process static methods of impls here.
19541953
match csearch::get_type_name_if_impl(&self.session.cstore, def) {
19551954
None => {}
19561955
Some(final_name) => {
1957-
let static_methods_opt =
1958-
csearch::get_static_methods_if_impl(&self.session.cstore, def);
1959-
match static_methods_opt {
1960-
Some(ref static_methods) if
1961-
static_methods.len() >= 1 => {
1956+
let methods_opt =
1957+
csearch::get_methods_if_impl(&self.session.cstore, def);
1958+
match methods_opt {
1959+
Some(ref methods) if
1960+
methods.len() >= 1 => {
19621961
debug!("(building reduced graph for \
19631962
external crate) processing \
19641963
static methods for type name {}",
@@ -2008,9 +2007,8 @@ impl<'a> Resolver<'a> {
20082007
// Add each static method to the module.
20092008
let new_parent =
20102009
ModuleReducedGraphParent(type_module);
2011-
for static_method_info in
2012-
static_methods.iter() {
2013-
let name = static_method_info.name;
2010+
for method_info in methods.iter() {
2011+
let name = method_info.name;
20142012
debug!("(building reduced graph for \
20152013
external crate) creating \
20162014
static method '{}'",
@@ -2021,9 +2019,7 @@ impl<'a> Resolver<'a> {
20212019
new_parent.clone(),
20222020
OverwriteDuplicates,
20232021
DUMMY_SP);
2024-
let def = DefFn(
2025-
static_method_info.def_id,
2026-
false);
2022+
let def = DefFn(method_info.def_id, false);
20272023

20282024
method_name_bindings.define_value(
20292025
def, DUMMY_SP,

0 commit comments

Comments
 (0)