Skip to content

Commit

Permalink
Rollup merge of rust-lang#73046 - marmeladema:save-analysis-fix-path,…
Browse files Browse the repository at this point in the history
… r=Xanewok

save_analysis: fix some ICEs

Fixes rust-lang#73020
Fixes rust-lang#73022
Fixes rust-lang#73041
  • Loading branch information
RalfJung authored Jun 6, 2020
2 parents ce6e596 + 4d6a307 commit 9f4fce1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 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 path.segments.len() > 0 {
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);
}
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,14 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
}
}
}
hir::ExprKind::Struct(hir::QPath::Resolved(_, path), ..) => {
hir::ExprKind::Struct(qpath, ..) => {
let segment = match qpath {
hir::QPath::Resolved(_, path) => path.segments.last().unwrap(),
hir::QPath::TypeRelative(_, segment) => segment,
};
match self.tables.expr_ty_adjusted(&hir_node).kind {
ty::Adt(def, _) if !def.is_enum() => {
let sub_span = path.segments.last().unwrap().ident.span;
let sub_span = segment.ident.span;
filter!(self.span_utils, sub_span);
let span = self.span_from_span(sub_span);
Some(Data::RefData(Ref {
Expand Down Expand Up @@ -580,7 +584,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
}
_ => {
// FIXME
bug!();
bug!("invalid expression: {:?}", expr);
}
}
}
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`.
13 changes: 13 additions & 0 deletions src/test/ui/save-analysis/issue-73022.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// build-pass
// compile-flags: -Zsave-analysis
enum Enum2 {
Variant8 { _field: bool },
}

impl Enum2 {
fn new_variant8() -> Enum2 {
Self::Variant8 { _field: true }
}
}

fn main() {}

0 comments on commit 9f4fce1

Please sign in to comment.