Allow for a missing adt_def
in NamePrivacyVisitor
.
This was caused by 72b172bdf6
in #121206. That commit removed an early
return from `analysis` when there are stashed errors. As a result, it's
possible to reach privacy analysis when there are stashed errors, which
means more code paths can be reached. One such code path was handled in
that commit, where a `span_bug` was changed to a `span_delayed_bug`.
This commit handles another such code path uncovered by fuzzing, in much
the same way.
Fixes #121455.
This commit is contained in:
parent
c5f69bdd51
commit
21bb1a4359
3 changed files with 19 additions and 1 deletions
|
@ -988,7 +988,10 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
|
|||
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
|
||||
if let hir::ExprKind::Struct(qpath, fields, ref base) = expr.kind {
|
||||
let res = self.typeck_results().qpath_res(qpath, expr.hir_id);
|
||||
let adt = self.typeck_results().expr_ty(expr).ty_adt_def().unwrap();
|
||||
let Some(adt) = self.typeck_results().expr_ty(expr).ty_adt_def() else {
|
||||
self.tcx.dcx().span_delayed_bug(expr.span, "no adt_def for expression");
|
||||
return;
|
||||
};
|
||||
let variant = adt.variant_of_res(res);
|
||||
if let Some(base) = *base {
|
||||
// If the expression uses FRU we need to make sure all the unmentioned fields
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue