提交 73558160 编写于 作者: B bors

Auto merge of #73046 - marmeladema:save-analysis-fix-path, r=Xanewok

save_analysis: fix some ICEs

Fixes #73020
Fixes #73022
Fixes #73041
......@@ -210,9 +210,11 @@ fn write_sub_paths(&mut self, path: &'tcx hir::Path<'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);
}
}
}
}
......
......@@ -534,10 +534,14 @@ pub fn get_expr_data(&self, expr: &hir::Expr<'_>) -> Option<Data> {
}
}
}
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 {
......@@ -580,7 +584,7 @@ pub fn get_expr_data(&self, expr: &hir::Expr<'_>) -> Option<Data> {
}
_ => {
// FIXME
bug!();
bug!("invalid expression: {:?}", expr);
}
}
}
......
// compile-flags: -Zsave-analysis
use {self}; //~ ERROR E0431
fn main () {
}
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`.
// build-pass
// compile-flags: -Zsave-analysis
enum Enum2 {
Variant8 { _field: bool },
}
impl Enum2 {
fn new_variant8() -> Enum2 {
Self::Variant8 { _field: true }
}
}
fn main() {}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册