]> git.lizzy.rs Git - rust.git/commitdiff
Fix ICE
authorCorey Richardson <corey@octayn.net>
Tue, 14 May 2013 23:49:04 +0000 (19:49 -0400)
committerCorey Richardson <corey@octayn.net>
Wed, 15 May 2013 00:34:05 +0000 (20:34 -0400)
src/librustc/middle/resolve.rs

index a50f78511cc562e469abd99620d3ed8fc868f791..3f1bd2b9a3c7facfa4af1b3fa60d216ea0e9637f 100644 (file)
@@ -2596,11 +2596,17 @@ fn resolve_module_path_for_import(@mut self,
         match module_prefix_result {
             Failed => {
                 let mpath = self.idents_to_str(module_path);
-                let idx = str::rfind(self.idents_to_str(module_path), |c| { c == ':' }).unwrap();
-                self.session.span_err(span, fmt!("unresolved import: could not find `%s` in `%s`",
-                                                 str::substr(mpath, idx, mpath.len() - idx),
-                                                 // idx - 1 to account for the extra semicolon
-                                                 str::substr(mpath, 0, idx - 1)));
+                match str::rfind(self.idents_to_str(module_path), |c| { c == ':' }) {
+                    Some(idx) => {
+                        self.session.span_err(span, fmt!("unresolved import: could not find `%s` \
+                                                         in `%s`", str::substr(mpath, idx,
+                                                                               mpath.len() - idx),
+                                                         // idx - 1 to account for the extra
+                                                         // colon
+                                                         str::substr(mpath, 0, idx - 1)));
+                    },
+                    None => (),
+                };
                 return Failed;
             }
             Indeterminate => {