Skip to content

Commit a7c18e0

Browse files
committed
save_analysis: fix panic in write_sub_paths_truncated
1 parent 84e4777 commit a7c18e0

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/librustc_save_analysis/dump_visitor.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
210210
// As write_sub_paths, but does not process the last ident in the path (assuming it
211211
// will be processed elsewhere). See note on write_sub_paths about global.
212212
fn write_sub_paths_truncated(&mut self, path: &'tcx hir::Path<'tcx>) {
213-
for seg in &path.segments[..path.segments.len() - 1] {
214-
if let Some(data) = self.save_ctxt.get_path_segment_data(seg) {
215-
self.dumper.dump_ref(data);
213+
if let [segments @ .., _] = path.segments {
214+
for seg in segments {
215+
if let Some(data) = self.save_ctxt.get_path_segment_data(seg) {
216+
self.dumper.dump_ref(data);
217+
}
216218
}
217219
}
218220
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// compile-flags: -Zsave-analysis
2+
use {self}; //~ ERROR E0431
3+
4+
fn main () {
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0431]: `self` import can only appear in an import list with a non-empty prefix
2+
--> $DIR/issue-73020.rs:2:6
3+
|
4+
LL | use {self};
5+
| ^^^^ can only appear in an import list with a non-empty prefix
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0431`.

0 commit comments

Comments
 (0)