Skip to content

Commit 780b385

Browse files
committed
rustc: Remove some uses of impl_map
1 parent 71bc267 commit 780b385

File tree

4 files changed

+3
-119
lines changed

4 files changed

+3
-119
lines changed

src/rustc/driver/driver.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
195195

196196
let (method_map, vtable_map) = time(time_passes, ~"typechecking", ||
197197
typeck::check_crate(ty_cx,
198-
impl_map,
199198
trait_map,
200199
crate));
201200
// These next two const passes can probably be merged

src/rustc/middle/resolve3.rs

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import driver::session::session;
2-
import metadata::csearch::{each_path, get_impls_for_mod};
2+
import metadata::csearch::{each_path};
33
import metadata::csearch::{get_method_names_if_trait, lookup_defs};
44
import metadata::cstore::find_use_stmt_cnum;
55
import metadata::decoder::{def_like, dl_def, dl_field, dl_impl};
@@ -1565,83 +1565,6 @@ class Resolver {
15651565
}
15661566
}
15671567
}
1568-
1569-
// Create nodes for all the impls.
1570-
self.build_reduced_graph_for_impls_in_external_module_subtree(root);
1571-
}
1572-
1573-
fn build_reduced_graph_for_impls_in_external_module_subtree(module_:
1574-
@Module) {
1575-
self.build_reduced_graph_for_impls_in_external_module(module_);
1576-
1577-
for module_.children.each |_name, child_node| {
1578-
match (*child_node).get_module_if_available() {
1579-
none => {
1580-
// Nothing to do.
1581-
}
1582-
some(child_module) => {
1583-
self.
1584-
build_reduced_graph_for_impls_in_external_module_subtree
1585-
(child_module);
1586-
}
1587-
}
1588-
}
1589-
}
1590-
1591-
fn build_reduced_graph_for_impls_in_external_module(module_: @Module) {
1592-
// XXX: This is really unfortunate. decoder::each_path can produce
1593-
// false positives, since, in the crate metadata, a trait named 'bar'
1594-
// in module 'foo' defining a method named 'baz' will result in the
1595-
// creation of a (bogus) path entry named 'foo::bar::baz', and we will
1596-
// create a module node for "bar". We can identify these fake modules
1597-
// by the fact that they have no def ID, which we do here in order to
1598-
// skip them.
1599-
1600-
debug!{"(building reduced graph for impls in external crate) looking \
1601-
for impls in `%s` (%?)",
1602-
self.module_to_str(module_),
1603-
copy module_.def_id};
1604-
1605-
match module_.def_id {
1606-
none => {
1607-
debug!{"(building reduced graph for impls in external \
1608-
module) no def ID for `%s`, skipping",
1609-
self.module_to_str(module_)};
1610-
return;
1611-
}
1612-
some(_) => {
1613-
// Continue.
1614-
}
1615-
}
1616-
1617-
let impls_in_module = get_impls_for_mod(self.session.cstore,
1618-
get(module_.def_id),
1619-
none);
1620-
1621-
// Intern def IDs to prevent duplicates.
1622-
let def_ids = new_def_hash();
1623-
1624-
for (*impls_in_module).each |implementation| {
1625-
if def_ids.contains_key(implementation.did) {
1626-
again;
1627-
}
1628-
def_ids.insert(implementation.did, ());
1629-
1630-
debug!{"(building reduced graph for impls in external module) \
1631-
added impl `%s` (%?) to `%s`",
1632-
*implementation.ident,
1633-
implementation.did,
1634-
self.module_to_str(module_)};
1635-
1636-
let name = (*self.atom_table).intern(implementation.ident);
1637-
1638-
let (name_bindings, _) =
1639-
// Might want a better span
1640-
self.add_child(name, ModuleReducedGraphParent(module_),
1641-
~[ImplNS], dummy_sp());
1642-
1643-
name_bindings.impl_defs += ~[implementation];
1644-
}
16451568
}
16461569

16471570
/// Creates and adds an import directive to the given module.

src/rustc/middle/typeck.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ type provided_methods_map = hashmap<ast::node_id,
158158

159159
type ty_param_substs_and_ty = {substs: ty::substs, ty: ty::t};
160160

161-
type crate_ctxt_ = {impl_map: resolve3::ImplMap,
162-
163-
// A mapping from method call sites to traits that have
161+
type crate_ctxt_ = {// A mapping from method call sites to traits that have
164162
// that method.
165163
trait_map: resolve3::TraitMap,
166164
method_map: method_map,
@@ -299,13 +297,11 @@ fn check_for_main_fn(ccx: @crate_ctxt) {
299297
}
300298

301299
fn check_crate(tcx: ty::ctxt,
302-
impl_map: resolve3::ImplMap,
303300
trait_map: resolve3::TraitMap,
304301
crate: @ast::crate)
305302
-> (method_map, vtable_map) {
306303

307-
let ccx = @crate_ctxt_({impl_map: impl_map,
308-
trait_map: trait_map,
304+
let ccx = @crate_ctxt_({trait_map: trait_map,
309305
method_map: std::map::int_hash(),
310306
vtable_map: std::map::int_hash(),
311307
coherence_info: @coherence::CoherenceInfo(),

src/rustc/middle/typeck/check/method.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,13 @@ class lookup {
138138
// it.
139139
if self.candidates.len() > 0u { break; }
140140

141-
// now look for impls in scope, but don't look for impls that
142-
// would require doing an implicit borrow of the lhs.
143-
self.add_candidates_from_scope(false);
144-
145141
// Look for inherent methods.
146142
self.add_inherent_and_extension_candidates
147143
(optional_inherent_methods, false);
148144

149145
// if we found anything, stop before trying borrows
150146
if self.candidates.len() > 0u { break; }
151147

152-
// now look for impls in scope that might require a borrow
153-
self.add_candidates_from_scope(true);
154-
155148
// Again, look for inherent methods.
156149
self.add_inherent_and_extension_candidates
157150
(optional_inherent_methods, true);
@@ -364,33 +357,6 @@ class lookup {
364357
*/
365358
}
366359

367-
fn add_candidates_from_scope(use_assignability: bool) {
368-
369-
// If we're using coherence and this is one of the method invocation
370-
// forms it supports, don't use this method; it'll result in lots of
371-
// multiple-methods-in-scope errors.
372-
if self.fcx.ccx.trait_map.contains_key(self.expr.id) {
373-
return;
374-
}
375-
376-
let impls_vecs = self.fcx.ccx.impl_map.get(self.expr.id);
377-
let mut added_any = false;
378-
379-
debug!{"method_from_scope"};
380-
381-
for list::each(impls_vecs) |impls| {
382-
for vec::each(*impls) |im| {
383-
if self.add_candidates_from_impl(im, use_assignability) {
384-
added_any = true;
385-
}
386-
}
387-
388-
// we want to find the innermost scope that has any
389-
// matches and then ignore outer scopes
390-
if added_any {return;}
391-
}
392-
}
393-
394360
// Returns true if any were added and false otherwise.
395361
fn add_candidates_from_impl(im: @resolve3::Impl,
396362
use_assignability: bool) -> bool {

0 commit comments

Comments
 (0)