Skip to content

Commit 5fd1ebe

Browse files
committed
Fix panic in 'remove semicolon' when types are not local
It's not possible to check if removing a semicolon fixes the type error when checking match arms and one or both of the last arm's and the current arm's return types are imported "opaque" types. In these cases we don't generate a "consider removing semicolon" suggestions. Fixes #81839
1 parent cb2effd commit 5fd1ebe

File tree

1 file changed

+10
-2
lines changed
  • compiler/rustc_typeck/src/check/fn_ctxt

1 file changed

+10
-2
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1078,8 +1078,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10781078
"both opaque, likely future {:?} {:?} {:?} {:?}",
10791079
last_def_id, last_bounds, exp_def_id, exp_bounds
10801080
);
1081-
let last_hir_id = self.tcx.hir().local_def_id_to_hir_id(last_def_id.expect_local());
1082-
let exp_hir_id = self.tcx.hir().local_def_id_to_hir_id(exp_def_id.expect_local());
1081+
1082+
let (last_local_id, exp_local_id) =
1083+
match (last_def_id.as_local(), exp_def_id.as_local()) {
1084+
(Some(last_hir_id), Some(exp_hir_id)) => (last_hir_id, exp_hir_id),
1085+
(_, _) => return None,
1086+
};
1087+
1088+
let last_hir_id = self.tcx.hir().local_def_id_to_hir_id(last_local_id);
1089+
let exp_hir_id = self.tcx.hir().local_def_id_to_hir_id(exp_local_id);
1090+
10831091
match (
10841092
&self.tcx.hir().expect_item(last_hir_id).kind,
10851093
&self.tcx.hir().expect_item(exp_hir_id).kind,

0 commit comments

Comments
 (0)