about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-08-23 18:31:43 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-08-27 18:47:59 -0700
commit2bd46e767c0fe5b6188df61cb9daf8f2e65a3ed0 (patch)
tree1de097b17cb353b0e9a8dad943c535c1c6905a8e /src
parent6c37e3b7f82b16229d7595b17cbefc5ed9339511 (diff)
librustc: Fix problem with cross-crate reexported static methods.
Diffstat (limited to 'src')
-rw-r--r--src/libextra/stats.rs2
-rw-r--r--src/librustc/metadata/decoder.rs56
-rw-r--r--src/librustc/metadata/encoder.rs8
-rw-r--r--src/librustc/middle/resolve.rs22
-rw-r--r--src/libstd/rt/uv/uvio.rs18
-rw-r--r--src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs3
-rw-r--r--src/test/compile-fail/map-types.rs4
-rw-r--r--src/test/compile-fail/private-variant-xc.rs1
-rw-r--r--src/test/compile-fail/xc-private-method.rs4
-rw-r--r--src/test/run-pass/issue-3026.rs2
10 files changed, 95 insertions, 25 deletions
diff --git a/src/libextra/stats.rs b/src/libextra/stats.rs
index 0cea4c1ac6c..2b6c53b3c86 100644
--- a/src/libextra/stats.rs
+++ b/src/libextra/stats.rs
@@ -368,7 +368,7 @@ pub fn write_boxplot(w: @io::Writer, s: &Summary, width_hint: uint) {
 /// Returns a HashMap with the number of occurrences of every element in the
 /// sequence that the iterator exposes.
 pub fn freq_count<T: Iterator<U>, U: Eq+Hash>(mut iter: T) -> hashmap::HashMap<U, uint> {
-    let mut map = hashmap::HashMap::new::<U, uint>();
+    let mut map: hashmap::HashMap<U,uint> = hashmap::HashMap::new();
     for elem in iter {
         map.insert_or_update_with(elem, 1, |_, count| *count += 1);
     }
diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs
index 4eea99293be..336c07c9d6e 100644
--- a/src/librustc/metadata/decoder.rs
+++ b/src/librustc/metadata/decoder.rs
@@ -733,6 +733,56 @@ fn each_child_of_item_or_crate(intr: @ident_interner,
                                                 child_def_id,
                                                 cdata.cnum);
                 callback(def_like, child_name);
+
+            }
+        }
+
+        true
+    };
+
+    // As a special case, iterate over all static methods of
+    // associated implementations too. This is a bit of a botch.
+    // --pcwalton
+    let _ = do reader::tagged_docs(item_doc,
+                                   tag_items_data_item_inherent_impl)
+            |inherent_impl_def_id_doc| {
+        let inherent_impl_def_id = item_def_id(inherent_impl_def_id_doc,
+                                               cdata);
+        let items = reader::get_doc(reader::Doc(cdata.data), tag_items);
+        match maybe_find_item(inherent_impl_def_id.node, items) {
+            None => {}
+            Some(inherent_impl_doc) => {
+                let _ = do reader::tagged_docs(inherent_impl_doc,
+                                               tag_item_impl_method)
+                        |impl_method_def_id_doc| {
+                    let impl_method_def_id =
+                        reader::with_doc_data(impl_method_def_id_doc,
+                                              parse_def_id);
+                    let impl_method_def_id =
+                        translate_def_id(cdata, impl_method_def_id);
+                    match maybe_find_item(impl_method_def_id.node, items) {
+                        None => {}
+                        Some(impl_method_doc) => {
+                            match item_family(impl_method_doc) {
+                                StaticMethod | UnsafeStaticMethod => {
+                                    // Hand off the static method
+                                    // to the callback.
+                                    let static_method_name =
+                                        item_name(intr, impl_method_doc);
+                                    let static_method_def_like =
+                                        item_to_def_like(impl_method_doc,
+                                                         impl_method_def_id,
+                                                         cdata.cnum);
+                                    callback(static_method_def_like,
+                                             static_method_name);
+                                }
+                                _ => {}
+                            }
+                        }
+                    }
+
+                    true
+                };
             }
         }
 
@@ -1403,15 +1453,9 @@ pub fn each_implementation_for_type(cdata: cmd,
                                     id: ast::NodeId,
                                     callback: &fn(ast::def_id)) {
     let item_doc = lookup_item(id, cdata.data);
-    /*println(fmt!(">>> reading inherent impls from %s",
-                 token::ident_to_str(&item_name(token::get_ident_interner(),
-                                                item_doc))));*/
     do reader::tagged_docs(item_doc, tag_items_data_item_inherent_impl)
             |impl_doc| {
         let implementation_def_id = item_def_id(impl_doc, cdata);
-        /*println(fmt!(">>>>> read inherent impl: %d:%d",
-                     implementation_def_id.crate,
-                     implementation_def_id.node));*/
         callback(implementation_def_id);
         true
     };
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index 1b701092551..790dff2886f 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -513,8 +513,12 @@ fn encode_reexports(ecx: &EncodeContext,
         Some(ref exports) => {
             debug!("(encoding info for module) found reexports for %d", id);
             for exp in exports.iter() {
-                debug!("(encoding info for module) reexport '%s' for %d",
-                       exp.name, id);
+                debug!("(encoding info for module) reexport '%s' (%d/%d) for \
+                        %d",
+                       exp.name,
+                       exp.def_id.crate,
+                       exp.def_id.node,
+                       id);
                 ebml_w.start_tag(tag_items_data_item_reexport);
                 ebml_w.start_tag(tag_items_data_item_reexport_def_id);
                 ebml_w.wr_str(def_to_str(exp.def_id));
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs
index 3174ee33cee..2989f104729 100644
--- a/src/librustc/middle/resolve.rs
+++ b/src/librustc/middle/resolve.rs
@@ -1658,7 +1658,8 @@ impl Resolver {
                            new_parent: ReducedGraphParent) {
         let privacy = visibility_to_privacy(visibility);
         match def {
-          def_mod(def_id) | def_foreign_mod(def_id) => {
+          def_mod(def_id) | def_foreign_mod(def_id) | def_struct(def_id) |
+          def_ty(def_id) => {
             match child_name_bindings.type_def {
               Some(TypeNsDef { module_def: Some(module_def), _ }) => {
                 debug!("(building reduced graph for external crate) \
@@ -1680,6 +1681,11 @@ impl Resolver {
               }
             }
           }
+          _ => {}
+        }
+
+        match def {
+          def_mod(_) | def_foreign_mod(_) => {}
           def_variant(*) => {
             debug!("(building reduced graph for external crate) building \
                     variant %s",
@@ -1691,7 +1697,7 @@ impl Resolver {
           }
           def_fn(*) | def_static_method(*) | def_static(*) => {
             debug!("(building reduced graph for external \
-                    crate) building value %s", final_ident);
+                    crate) building value (fn/static) %s", final_ident);
             child_name_bindings.define_value(privacy, def, dummy_sp());
           }
           def_trait(def_id) => {
@@ -1903,13 +1909,21 @@ impl Resolver {
 
     /// Builds the reduced graph rooted at the given external module.
     fn populate_external_module(@mut self, module: @mut Module) {
+        debug!("(populating external module) attempting to populate %s",
+               self.module_to_str(module));
+
         let def_id = match module.def_id {
-            None => return,
+            None => {
+                debug!("(populating external module) ... no def ID!");
+                return
+            }
             Some(def_id) => def_id,
         };
 
         do csearch::each_child_of_item(self.session.cstore, def_id)
                 |def_like, child_ident| {
+            debug!("(populating external module) ... found ident: %s",
+                   token::ident_to_str(&child_ident));
             self.build_reduced_graph_for_external_crate_def(module,
                                                             def_like,
                                                             child_ident)
@@ -3871,7 +3885,7 @@ impl Resolver {
                           generics: &Generics,
                           fields: &[@struct_field],
                           visitor: &mut ResolveVisitor) {
-        let mut ident_map = HashMap::new::<ast::ident, @struct_field>();
+        let mut ident_map: HashMap<ast::ident,@struct_field> = HashMap::new();
         for &field in fields.iter() {
             match field.node.kind {
                 named_field(ident, _) => {
diff --git a/src/libstd/rt/uv/uvio.rs b/src/libstd/rt/uv/uvio.rs
index 954bbc512d9..c2053b20983 100644
--- a/src/libstd/rt/uv/uvio.rs
+++ b/src/libstd/rt/uv/uvio.rs
@@ -1303,7 +1303,9 @@ fn test_simple_homed_udp_io_bind_then_move_task_then_home_and_close() {
         };
 
         let test_function: ~fn() = || {
-            let io = unsafe { Local::unsafe_borrow::<IoFactoryObject>() };
+            let io: *mut IoFactoryObject = unsafe {
+                Local::unsafe_borrow()
+            };
             let addr = next_test_ip4();
             let maybe_socket = unsafe { (*io).udp_bind(addr) };
             // this socket is bound to this event loop
@@ -1311,7 +1313,7 @@ fn test_simple_homed_udp_io_bind_then_move_task_then_home_and_close() {
 
             // block self on sched1
             do task::unkillable { // FIXME(#8674)
-                let scheduler = Local::take::<Scheduler>();
+                let scheduler: ~Scheduler = Local::take();
                 do scheduler.deschedule_running_task_and_then |_, task| {
                     // unblock task
                     do task.wake().map_move |task| {
@@ -1377,7 +1379,9 @@ fn test_simple_homed_udp_io_bind_then_move_handle_then_home_and_close() {
         let chan = Cell::new(chan);
 
         let body1: ~fn() = || {
-            let io = unsafe { Local::unsafe_borrow::<IoFactoryObject>() };
+            let io: *mut IoFactoryObject = unsafe {
+                Local::unsafe_borrow()
+            };
             let addr = next_test_ip4();
             let socket = unsafe { (*io).udp_bind(addr) };
             assert!(socket.is_ok());
@@ -1489,7 +1493,9 @@ fn test_simple_tcp_server_and_client_on_diff_threads() {
         };
 
         let server_fn: ~fn() = || {
-            let io = unsafe { Local::unsafe_borrow::<IoFactoryObject>() };
+            let io: *mut IoFactoryObject = unsafe {
+                Local::unsafe_borrow()
+            };
             let mut listener = unsafe { (*io).tcp_bind(server_addr).unwrap() };
             let mut stream = listener.accept().unwrap();
             let mut buf = [0, .. 2048];
@@ -1501,7 +1507,9 @@ fn test_simple_tcp_server_and_client_on_diff_threads() {
         };
 
         let client_fn: ~fn() = || {
-            let io = unsafe { Local::unsafe_borrow::<IoFactoryObject>() };
+            let io: *mut IoFactoryObject = unsafe {
+                Local::unsafe_borrow()
+            };
             let mut stream = unsafe { (*io).tcp_connect(client_addr) };
             while stream.is_err() {
                 stream = unsafe { (*io).tcp_connect(client_addr) };
diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
index bd87a57af25..c004b3d0e54 100644
--- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
+++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
@@ -13,8 +13,7 @@
 use std::hashmap::HashMap;
 
 fn main() {
-    let mut buggy_map :HashMap<uint, &uint> =
-      HashMap::new::<uint, &uint>();
+    let mut buggy_map: HashMap<uint, &uint> = HashMap::new();
     buggy_map.insert(42, &*~1); //~ ERROR borrowed value does not live long enough
 
     // but it is ok if we use a temporary
diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs
index f6fd8e29a4f..19423c6690f 100644
--- a/src/test/compile-fail/map-types.rs
+++ b/src/test/compile-fail/map-types.rs
@@ -14,8 +14,8 @@ use std::hashmap::HashMap;
 // Test that trait types printed in error msgs include the type arguments.
 
 fn main() {
-    let x: @Map<~str, ~str> = @HashMap::new::<~str, ~str>() as
-        @Map<~str, ~str>;
+    let x: @HashMap<~str, ~str> = @HashMap::new();
+    let x: @Map<~str, ~str> = x as @Map<~str, ~str>;
     let y: @Map<uint, ~str> = @x;
     //~^ ERROR expected trait std::container::Map but found @-ptr
 }
diff --git a/src/test/compile-fail/private-variant-xc.rs b/src/test/compile-fail/private-variant-xc.rs
index 9db023a779b..c3946b33010 100644
--- a/src/test/compile-fail/private-variant-xc.rs
+++ b/src/test/compile-fail/private-variant-xc.rs
@@ -1,4 +1,5 @@
 // aux-build:private_variant_xc.rs
+// xfail-test
 
 extern mod private_variant_xc;
 
diff --git a/src/test/compile-fail/xc-private-method.rs b/src/test/compile-fail/xc-private-method.rs
index 8314755af3b..371bac7a902 100644
--- a/src/test/compile-fail/xc-private-method.rs
+++ b/src/test/compile-fail/xc-private-method.rs
@@ -7,10 +7,10 @@ fn main() {
     // normal method on struct
     let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct();  //~ ERROR method `meth_struct` is private
     // static method on struct
-    let _ = xc_private_method_lib::Struct::static_meth_struct();  //~ ERROR function `static_meth_struct` is private
+    let _ = xc_private_method_lib::Struct::static_meth_struct();  //~ ERROR method `static_meth_struct` is private
 
     // normal method on enum
     let _ = xc_private_method_lib::Variant1(20).meth_enum();  //~ ERROR method `meth_enum` is private
     // static method on enum
-    let _ = xc_private_method_lib::Enum::static_meth_enum();  //~ ERROR function `static_meth_enum` is private
+    let _ = xc_private_method_lib::Enum::static_meth_enum();  //~ ERROR method `static_meth_enum` is private
 }
diff --git a/src/test/run-pass/issue-3026.rs b/src/test/run-pass/issue-3026.rs
index a4b37f0ba0f..ce471e5c827 100644
--- a/src/test/run-pass/issue-3026.rs
+++ b/src/test/run-pass/issue-3026.rs
@@ -13,7 +13,7 @@
 use std::hashmap::HashMap;
 
 pub fn main() {
-    let mut buggy_map: HashMap<uint, &uint> = HashMap::new::<uint, &uint>();
+    let mut buggy_map: HashMap<uint, &uint> = HashMap::new();
     let x = ~1;
     buggy_map.insert(42, &*x);
 }