Skip to content

Commit 357982f

Browse files
committed
Workaround for imports with empty braces
1 parent 50e42ea commit 357982f

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

src/librustc_front/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
218218
visitor.visit_path_list_item(prefix, item)
219219
}
220220
} else {
221-
// FIXME: uncomment this and fix the resulting ICE
222-
// visitor.visit_path(prefix, item.id);
221+
// FIXME(#28388) visit_path should be used instead of walk_path
222+
walk_path(visitor, prefix);
223223
}
224224
}
225225
}

src/librustc_privacy/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -980,15 +980,19 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
980980
}
981981

982982
fn visit_path(&mut self, path: &hir::Path, id: ast::NodeId) {
983-
self.check_path(path.span, id, path.segments.last().unwrap().identifier.name);
984-
visit::walk_path(self, path);
983+
if !path.segments.is_empty() {
984+
self.check_path(path.span, id, path.segments.last().unwrap().identifier.name);
985+
visit::walk_path(self, path);
986+
}
985987
}
986988

987989
fn visit_path_list_item(&mut self, prefix: &hir::Path, item: &hir::PathListItem) {
988990
let name = if let hir::PathListIdent { name, .. } = item.node {
989991
name.name
990-
} else {
992+
} else if !prefix.segments.is_empty() {
991993
prefix.segments.last().unwrap().identifier.name
994+
} else {
995+
self.tcx.sess.bug("`self` import in an import list with empty prefix");
992996
};
993997
self.check_path(item.span, item.node.id(), name);
994998
visit::walk_path_list_item(self, prefix, item);

src/libstd/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@
201201

202202
#![feature(alloc)]
203203
#![feature(allow_internal_unstable)]
204-
#![feature(arc_weak)]
205204
#![feature(associated_consts)]
206205
#![feature(borrow_state)]
207206
#![feature(box_syntax)]

src/libsyntax/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
224224
visitor.visit_path_list_item(prefix, item)
225225
}
226226
} else {
227-
// FIXME: uncomment this and fix the resulting ICE
228-
// visitor.visit_path(prefix, item.id);
227+
// FIXME(#28388) visit_path should be used instead of walk_path
228+
walk_path(visitor, prefix);
229229
}
230230
}
231231
}

src/test/compile-fail/issue-28075.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212

1313
#![allow(unused_imports)]
1414

15-
use std::thread::{catch_panic, sleep}; //~ ERROR use of unstable library feature 'catch_panic'
16-
//~^ ERROR use of unstable library feature 'thread_sleep'
15+
use std::thread::{catch_panic, ScopedKey}; //~ ERROR use of unstable library feature 'catch_panic'
16+
//~^ ERROR use of unstable library feature 'scoped_tls'
1717

1818
use std::rt::{self}; //~ ERROR use of unstable library feature 'rt'
19-
use std::rt::{};
2019

2120
fn main() {
2221
}

0 commit comments

Comments
 (0)