Skip to content

Commit 5e9cd1f

Browse files
committed
Mark some once-again-unreachable paths as unreachable.
This undoes the changes from #121482 and #121586, now that stashed errors will trigger more early aborts.
1 parent c48d5f6 commit 5e9cd1f

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

compiler/rustc_lint/src/array_into_iter.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,11 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
7070

7171
// Check if the method call actually calls the libcore
7272
// `IntoIterator::into_iter`.
73-
let trait_id = cx
74-
.typeck_results()
75-
.type_dependent_def_id(expr.hir_id)
76-
.and_then(|did| cx.tcx.trait_of_item(did));
77-
if trait_id.is_none()
78-
|| !cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_id.unwrap())
79-
{
80-
return;
81-
}
73+
let def_id = cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap();
74+
match cx.tcx.trait_of_item(def_id) {
75+
Some(trait_id) if cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_id) => {}
76+
_ => return,
77+
};
8278

8379
// As this is a method call expression, we have at least one argument.
8480
let receiver_ty = cx.typeck_results().expr_ty(receiver_arg);

compiler/rustc_privacy/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -988,10 +988,7 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
988988
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
989989
if let hir::ExprKind::Struct(qpath, fields, ref base) = expr.kind {
990990
let res = self.typeck_results().qpath_res(qpath, expr.hir_id);
991-
let Some(adt) = self.typeck_results().expr_ty(expr).ty_adt_def() else {
992-
self.tcx.dcx().span_delayed_bug(expr.span, "no adt_def for expression");
993-
return;
994-
};
991+
let adt = self.typeck_results().expr_ty(expr).ty_adt_def().unwrap();
995992
let variant = adt.variant_of_res(res);
996993
if let Some(base) = *base {
997994
// If the expression uses FRU we need to make sure all the unmentioned fields

0 commit comments

Comments
 (0)