Skip to content

Commit

Permalink
code cleanup with err.emit_unless
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Nov 8, 2022
1 parent 465ac26 commit 3320879
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,11 +1096,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

// If the assignment expression itself is ill-formed, don't
// bother emitting another error
let reported = if lhs_ty.references_error() || rhs_ty.references_error() {
err.delay_as_bug()
} else {
err.emit()
};
let reported = err.emit_unless(lhs_ty.references_error() || rhs_ty.references_error());
return self.tcx.ty_error_with_guaranteed(reported);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ impl<'tcx> TyCtxt<'tcx> {
ty: Ty<'tcx>,
reported: ErrorGuaranteed,
) -> Const<'tcx> {
self.mk_const(ty::ConstS { kind: ty::ConstKind::Error(reported), ty })
self.mk_const(ty::ConstKind::Error(reported), ty)
}

/// Like [TyCtxt::ty_error] but for constants.
Expand Down

0 comments on commit 3320879

Please sign in to comment.