Skip to content

Commit 5faba28

Browse files
committed
Fix ICE when use trees have multiple empty nested groups
1 parent 3a39b2a commit 5faba28

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/librustc_resolve/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,7 @@ impl<'a> Resolver<'a> {
20452045
segments: vec![],
20462046
span: use_tree.span,
20472047
};
2048-
self.resolve_use_tree(item, use_tree, &path);
2048+
self.resolve_use_tree(item.id, use_tree, &path);
20492049
}
20502050

20512051
ItemKind::ExternCrate(_) | ItemKind::MacroDef(..) | ItemKind::GlobalAsm(_) => {
@@ -2056,7 +2056,7 @@ impl<'a> Resolver<'a> {
20562056
}
20572057
}
20582058

2059-
fn resolve_use_tree(&mut self, item: &Item, use_tree: &ast::UseTree, prefix: &Path) {
2059+
fn resolve_use_tree(&mut self, id: NodeId, use_tree: &ast::UseTree, prefix: &Path) {
20602060
match use_tree.kind {
20612061
ast::UseTreeKind::Nested(ref items) => {
20622062
let path = Path {
@@ -2070,10 +2070,10 @@ impl<'a> Resolver<'a> {
20702070

20712071
if items.len() == 0 {
20722072
// Resolve prefix of an import with empty braces (issue #28388).
2073-
self.smart_resolve_path(item.id, None, &path, PathSource::ImportPrefix);
2073+
self.smart_resolve_path(id, None, &path, PathSource::ImportPrefix);
20742074
} else {
2075-
for &(ref tree, _) in items {
2076-
self.resolve_use_tree(item, tree, &path);
2075+
for &(ref tree, nested_id) in items {
2076+
self.resolve_use_tree(nested_id, tree, &path);
20772077
}
20782078
}
20792079
}

src/test/run-pass/issue-47673.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 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+
#![feature(use_nested_groups)]
12+
#![allow(unused_import)]
13+
14+
use {{}, {}};
15+
16+
fn main() {}

0 commit comments

Comments
 (0)