Skip to content

Commit 9c17f89

Browse files
committed
---
yaml --- r: 60540 b: refs/heads/auto c: 15f97ac h: refs/heads/master v: v3
1 parent 3ea8cb1 commit 9c17f89

File tree

8 files changed

+129
-118
lines changed

8 files changed

+129
-118
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 19dc72809daa0f53120f88b155459f877e854945
17+
refs/heads/auto: 15f97acdc87087e7747900be83d038757b86fb25
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libcore/hashmap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
303303

304304
/// Visit all key-value pairs
305305
fn each<'a>(&'a self, blk: &fn(&K, &'a V) -> bool) -> bool {
306-
for self.buckets.each |bucket| {
307-
for bucket.each |pair| {
308-
if !blk(&pair.key, &pair.value) {
306+
for uint::range(0, self.buckets.len()) |i| {
307+
for self.buckets[i].each |bucket| {
308+
if !blk(&bucket.key, &bucket.value) {
309309
return false;
310310
}
311311
}

branches/auto/src/libcore/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use old_iter;
2222
use iterator::Iterator;
2323
use kinds::Copy;
2424
use libc;
25-
use old_iter::{BaseIter, CopyableIter};
25+
use old_iter::CopyableIter;
2626
use option::{None, Option, Some};
2727
use ptr::to_unsafe_ptr;
2828
use ptr;

branches/auto/src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ pub fn compile_rest(sess: Session,
239239
let (llmod, link_meta) = {
240240

241241
let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars,
242-
region_map, rp_set, lang_items, crate);
242+
region_map, rp_set, lang_items);
243243

244244
// passes are timed inside typeck
245245
let (method_map, vtable_map) = typeck::check_crate(

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

Lines changed: 92 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ pub fn Resolver(session: Session,
734734

735735
graph_root: graph_root,
736736

737-
method_map: @mut HashMap::new(),
737+
trait_info: HashMap::new(),
738738
structs: HashSet::new(),
739739

740740
unresolved_imports: 0,
@@ -776,7 +776,7 @@ pub struct Resolver {
776776

777777
graph_root: @mut NameBindings,
778778

779-
method_map: @mut HashMap<ident, HashSet<def_id>>,
779+
trait_info: HashMap<def_id, HashSet<ident>>,
780780
structs: HashSet<def_id>,
781781

782782
// The number of imports that are currently unresolved.
@@ -1292,15 +1292,7 @@ pub impl Resolver {
12921292
}
12931293

12941294
let def_id = local_def(item.id);
1295-
for method_names.each |name| {
1296-
if !self.method_map.contains_key(name) {
1297-
self.method_map.insert(*name, HashSet::new());
1298-
}
1299-
match self.method_map.find_mut(name) {
1300-
Some(s) => { s.insert(def_id); },
1301-
_ => fail!("Can't happen"),
1302-
}
1303-
}
1295+
self.trait_info.insert(def_id, method_names);
13041296

13051297
name_bindings.define_type(privacy, def_trait(def_id), sp);
13061298
visit_item(item, new_parent, visitor);
@@ -1597,15 +1589,7 @@ pub impl Resolver {
15971589
interned_method_names.insert(method_name);
15981590
}
15991591
}
1600-
for interned_method_names.each |name| {
1601-
if !self.method_map.contains_key(name) {
1602-
self.method_map.insert(*name, HashSet::new());
1603-
}
1604-
match self.method_map.find_mut(name) {
1605-
Some(s) => { s.insert(def_id); },
1606-
_ => fail!("Can't happen"),
1607-
}
1608-
}
1592+
self.trait_info.insert(def_id, interned_method_names);
16091593

16101594
child_name_bindings.define_type(Public, def, dummy_sp());
16111595
}
@@ -1834,6 +1818,10 @@ pub impl Resolver {
18341818
debug!("(building import directive) bumping \
18351819
reference");
18361820
resolution.outstanding_references += 1;
1821+
1822+
// the source of this name is different now
1823+
resolution.privacy = privacy;
1824+
resolution.id = id;
18371825
}
18381826
None => {
18391827
debug!("(building import directive) creating new");
@@ -4951,111 +4939,118 @@ pub impl Resolver {
49514939
debug!("(searching for traits containing method) looking for '%s'",
49524940
*self.session.str_of(name));
49534941

4954-
49554942
let mut found_traits = ~[];
49564943
let mut search_module = self.current_module;
4957-
match self.method_map.find(&name) {
4958-
Some(candidate_traits) => loop {
4959-
// Look for the current trait.
4960-
match /*bad*/copy self.current_trait_refs {
4961-
Some(trait_def_ids) => {
4962-
for trait_def_ids.each |trait_def_id| {
4963-
if candidate_traits.contains(trait_def_id) {
4964-
self.add_trait_info(
4965-
&mut found_traits,
4966-
*trait_def_id, name);
4967-
}
4968-
}
4969-
}
4970-
None => {
4971-
// Nothing to do.
4944+
loop {
4945+
// Look for the current trait.
4946+
match /*bad*/copy self.current_trait_refs {
4947+
Some(trait_def_ids) => {
4948+
for trait_def_ids.each |trait_def_id| {
4949+
self.add_trait_info_if_containing_method(
4950+
&mut found_traits, *trait_def_id, name);
49724951
}
49734952
}
4953+
None => {
4954+
// Nothing to do.
4955+
}
4956+
}
49744957

4975-
// Look for trait children.
4976-
for search_module.children.each_value |&child_name_bindings| {
4977-
match child_name_bindings.def_for_namespace(TypeNS) {
4978-
Some(def) => {
4979-
match def {
4980-
def_trait(trait_def_id) => {
4981-
if candidate_traits.contains(&trait_def_id) {
4982-
self.add_trait_info(
4983-
&mut found_traits,
4984-
trait_def_id, name);
4985-
}
4986-
}
4987-
_ => {
4988-
// Continue.
4989-
}
4958+
// Look for trait children.
4959+
for search_module.children.each_value |&child_name_bindings| {
4960+
match child_name_bindings.def_for_namespace(TypeNS) {
4961+
Some(def) => {
4962+
match def {
4963+
def_trait(trait_def_id) => {
4964+
self.add_trait_info_if_containing_method(
4965+
&mut found_traits, trait_def_id, name);
4966+
}
4967+
_ => {
4968+
// Continue.
49904969
}
4991-
}
4992-
None => {
4993-
// Continue.
49944970
}
49954971
}
4972+
None => {
4973+
// Continue.
4974+
}
49964975
}
4976+
}
49974977

4998-
// Look for imports.
4999-
for search_module.import_resolutions.each_value
5000-
|&import_resolution| {
4978+
// Look for imports.
4979+
for search_module.import_resolutions.each_value
4980+
|&import_resolution| {
50014981

5002-
match import_resolution.target_for_namespace(TypeNS) {
5003-
None => {
5004-
// Continue.
5005-
}
5006-
Some(target) => {
5007-
match target.bindings.def_for_namespace(TypeNS) {
5008-
Some(def) => {
5009-
match def {
5010-
def_trait(trait_def_id) => {
5011-
if candidate_traits.contains(&trait_def_id) {
5012-
self.add_trait_info(
5013-
&mut found_traits,
5014-
trait_def_id, name);
5015-
self.used_imports.insert(
5016-
import_resolution.id);
5017-
}
5018-
}
5019-
_ => {
5020-
// Continue.
4982+
match import_resolution.target_for_namespace(TypeNS) {
4983+
None => {
4984+
// Continue.
4985+
}
4986+
Some(target) => {
4987+
match target.bindings.def_for_namespace(TypeNS) {
4988+
Some(def) => {
4989+
match def {
4990+
def_trait(trait_def_id) => {
4991+
let added = self.
4992+
add_trait_info_if_containing_method(
4993+
&mut found_traits,
4994+
trait_def_id, name);
4995+
if added {
4996+
self.used_imports.insert(
4997+
import_resolution.id);
50214998
}
50224999
}
5000+
_ => {
5001+
// Continue.
5002+
}
50235003
}
5024-
None => {
5025-
// Continue.
5026-
}
5004+
}
5005+
None => {
5006+
// Continue.
50275007
}
50285008
}
50295009
}
50305010
}
5011+
}
50315012

5032-
// Move to the next parent.
5033-
match search_module.parent_link {
5034-
NoParentLink => {
5035-
// Done.
5036-
break;
5037-
}
5038-
ModuleParentLink(parent_module, _) |
5039-
BlockParentLink(parent_module, _) => {
5040-
search_module = parent_module;
5041-
}
5013+
// Move to the next parent.
5014+
match search_module.parent_link {
5015+
NoParentLink => {
5016+
// Done.
5017+
break;
50425018
}
5043-
},
5044-
_ => ()
5019+
ModuleParentLink(parent_module, _) |
5020+
BlockParentLink(parent_module, _) => {
5021+
search_module = parent_module;
5022+
}
5023+
}
50455024
}
50465025

50475026
return found_traits;
50485027
}
50495028

5050-
fn add_trait_info(&self,
5051-
found_traits: &mut ~[def_id],
5052-
trait_def_id: def_id,
5053-
name: ident) {
5054-
debug!("(adding trait info) found trait %d:%d for method '%s'",
5029+
fn add_trait_info_if_containing_method(&self,
5030+
found_traits: &mut ~[def_id],
5031+
trait_def_id: def_id,
5032+
name: ident)
5033+
-> bool {
5034+
debug!("(adding trait info if containing method) trying trait %d:%d \
5035+
for method '%s'",
50555036
trait_def_id.crate,
50565037
trait_def_id.node,
50575038
*self.session.str_of(name));
5058-
found_traits.push(trait_def_id);
5039+
5040+
match self.trait_info.find(&trait_def_id) {
5041+
Some(trait_info) if trait_info.contains(&name) => {
5042+
debug!("(adding trait info if containing method) found trait \
5043+
%d:%d for method '%s'",
5044+
trait_def_id.crate,
5045+
trait_def_id.node,
5046+
*self.session.str_of(name));
5047+
found_traits.push(trait_def_id);
5048+
true
5049+
}
5050+
Some(_) | None => {
5051+
false
5052+
}
5053+
}
50595054
}
50605055

50615056
fn add_fixed_trait_for_expr(@mut self,

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ struct ctxt_ {
232232
diag: @syntax::diagnostic::span_handler,
233233
interner: @mut HashMap<intern_key, ~t_box_>,
234234
next_id: @mut uint,
235-
legacy_modes: bool,
236235
cstore: @mut metadata::cstore::CStore,
237236
sess: session::Session,
238237
def_map: resolve::DefMap,
@@ -906,24 +905,12 @@ pub fn mk_ctxt(s: session::Session,
906905
freevars: freevars::freevar_map,
907906
region_maps: @mut middle::region::RegionMaps,
908907
region_paramd_items: middle::region::region_paramd_items,
909-
lang_items: middle::lang_items::LanguageItems,
910-
crate: @ast::crate)
908+
lang_items: middle::lang_items::LanguageItems)
911909
-> ctxt {
912-
let mut legacy_modes = false;
913-
for crate.node.attrs.each |attribute| {
914-
match attribute.node.value.node {
915-
ast::meta_word(w) if *w == ~"legacy_modes" => {
916-
legacy_modes = true;
917-
}
918-
_ => {}
919-
}
920-
}
921-
922910
@ctxt_ {
923911
diag: s.diagnostic(),
924912
interner: @mut HashMap::new(),
925913
next_id: @mut primitives::LAST_PRIMITIVE_ID,
926-
legacy_modes: legacy_modes,
927914
cstore: s.cstore,
928915
sess: s,
929916
def_map: dm,

branches/auto/src/librustc/middle/typeck/infer/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn setup_env(test_name: &str, source_string: &str) -> Env {
6767
cfg, parse_sess);
6868

6969
let tcx = ty::mk_ctxt(sess, dm, amap, freevars, region_map,
70-
region_paramd_items, lang_items, crate);
70+
region_paramd_items, lang_items);
7171

7272
let infcx = infer::new_infer_ctxt(tcx);
7373

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[deny(unused_imports)];
12+
13+
// Regression test for issue #6633
14+
15+
use foo::name::name; //~ ERROR: unused import
16+
use foo::name;
17+
18+
pub mod foo {
19+
pub mod name {
20+
pub type a = int;
21+
pub mod name {
22+
pub type a = float;
23+
}
24+
}
25+
}
26+
27+
fn bar() -> name::a { 1 }
28+
29+
fn main(){}

0 commit comments

Comments
 (0)