about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Brüschweiler <blei42@gmail.com>2013-06-03 13:31:43 +0200
committerPhilipp Brüschweiler <blei42@gmail.com>2013-06-03 13:31:43 +0200
commit394ac1aae4d8b23b65a2165b2cf00c66936cd437 (patch)
tree2a7b9a012f0af8ae0d723aaaaebeed24e0f9a19a
parent45441e046b5de6216fe799bdb4d2d49dfe1bb1d3 (diff)
downloadrust-394ac1aae4d8b23b65a2165b2cf00c66936cd437.tar.gz
rust-394ac1aae4d8b23b65a2165b2cf00c66936cd437.zip
resolve: don't resolve paths that point to non-static methods
Fixes #6698
-rw-r--r--src/librustc/middle/resolve.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs
index a1eb0726c3d..db98407cc55 100644
--- a/src/librustc/middle/resolve.rs
+++ b/src/librustc/middle/resolve.rs
@@ -4595,7 +4595,7 @@ impl Resolver {
         }
 
         let name = *path.idents.last();
-        match self.resolve_definition_of_name_in_module(containing_module,
+        let def = match self.resolve_definition_of_name_in_module(containing_module,
                                                         name,
                                                         namespace,
                                                         xray) {
@@ -4604,9 +4604,28 @@ impl Resolver {
                 return None;
             }
             ChildNameDefinition(def) | ImportNameDefinition(def) => {
-                return Some(def);
+                def
             }
-        }
+        };
+        match containing_module.kind {
+            TraitModuleKind | ImplModuleKind => {
+                match self.method_map.find(&name) {
+                    Some(s) => {
+                        match containing_module.def_id {
+                            Some(def_id) if s.contains(&def_id) => {
+                                debug!("containing module was a trait or impl \
+                                        and name was a method -> not resolved");
+                                return None;
+                            },
+                            _ => (),
+                        }
+                    },
+                    None => (),
+                }
+            },
+            _ => (),
+        };
+        return Some(def);
     }
 
     /// Invariant: This must be called only during main resolution, not during