about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-01-25 12:49:00 -0600
committerAlex Crichton <alex@alexcrichton.com>2018-01-25 13:49:53 -0800
commitf7706d5816b48a9dcc31b06472ecb630eab2ea44 (patch)
treeb99a1d4813248b12693fd0a00fd17891b6bd5528
parentb335b10b2296c4dad734419f6c2ae106ed4911cc (diff)
parent5faba281ad08e6d57dc015f9547e18256eb8247f (diff)
downloadrust-f7706d5816b48a9dcc31b06472ecb630eab2ea44.tar.gz
rust-f7706d5816b48a9dcc31b06472ecb630eab2ea44.zip
Rollup merge of #47705 - pietroalbini:fix-47673, r=petrochenkov
Fix ICE when use trees have multiple empty nested groups

The issue was caused by an oversight of mine in the original use_nested_groups PR, where different paths were resolved with the same `NodeId` in some cases (such as in `use {{}, {}};`).

Fixes #47673
r? @petrochenkov
-rw-r--r--src/librustc_resolve/lib.rs10
-rw-r--r--src/test/run-pass/issue-47673.rs16
2 files changed, 21 insertions, 5 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 1df19b6b678..557ff887a3e 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -2045,7 +2045,7 @@ impl<'a> Resolver<'a> {
                     segments: vec![],
                     span: use_tree.span,
                 };
-                self.resolve_use_tree(item, use_tree, &path);
+                self.resolve_use_tree(item.id, use_tree, &path);
             }
 
             ItemKind::ExternCrate(_) | ItemKind::MacroDef(..) | ItemKind::GlobalAsm(_) => {
@@ -2056,7 +2056,7 @@ impl<'a> Resolver<'a> {
         }
     }
 
-    fn resolve_use_tree(&mut self, item: &Item, use_tree: &ast::UseTree, prefix: &Path) {
+    fn resolve_use_tree(&mut self, id: NodeId, use_tree: &ast::UseTree, prefix: &Path) {
         match use_tree.kind {
             ast::UseTreeKind::Nested(ref items) => {
                 let path = Path {
@@ -2070,10 +2070,10 @@ impl<'a> Resolver<'a> {
 
                 if items.len() == 0 {
                     // Resolve prefix of an import with empty braces (issue #28388).
-                    self.smart_resolve_path(item.id, None, &path, PathSource::ImportPrefix);
+                    self.smart_resolve_path(id, None, &path, PathSource::ImportPrefix);
                 } else {
-                    for &(ref tree, _) in items {
-                        self.resolve_use_tree(item, tree, &path);
+                    for &(ref tree, nested_id) in items {
+                        self.resolve_use_tree(nested_id, tree, &path);
                     }
                 }
             }
diff --git a/src/test/run-pass/issue-47673.rs b/src/test/run-pass/issue-47673.rs
new file mode 100644
index 00000000000..92f54a44f63
--- /dev/null
+++ b/src/test/run-pass/issue-47673.rs
@@ -0,0 +1,16 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(use_nested_groups)]
+#![allow(unused_import)]
+
+use {{}, {}};
+
+fn main() {}