Skip to content

Commit

Permalink
save_analysis: fix panic in write_sub_paths_truncated
Browse files Browse the repository at this point in the history
  • Loading branch information
marmeladema committed Jun 6, 2020
1 parent 84e4777 commit a7c18e0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,11 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
// As write_sub_paths, but does not process the last ident in the path (assuming it
// will be processed elsewhere). See note on write_sub_paths about global.
fn write_sub_paths_truncated(&mut self, path: &'tcx hir::Path<'tcx>) {
for seg in &path.segments[..path.segments.len() - 1] {
if let Some(data) = self.save_ctxt.get_path_segment_data(seg) {
self.dumper.dump_ref(data);
if let [segments @ .., _] = path.segments {
for seg in segments {
if let Some(data) = self.save_ctxt.get_path_segment_data(seg) {
self.dumper.dump_ref(data);
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/save-analysis/issue-73020.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// compile-flags: -Zsave-analysis
use {self}; //~ ERROR E0431

fn main () {
}
9 changes: 9 additions & 0 deletions src/test/ui/save-analysis/issue-73020.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0431]: `self` import can only appear in an import list with a non-empty prefix
--> $DIR/issue-73020.rs:2:6
|
LL | use {self};
| ^^^^ can only appear in an import list with a non-empty prefix

error: aborting due to previous error

For more information about this error, try `rustc --explain E0431`.

0 comments on commit a7c18e0

Please sign in to comment.