Skip to content

Commit ba91285

Browse files
Flatten match
1 parent 27dce30 commit ba91285

File tree

1 file changed

+67
-47
lines changed

1 file changed

+67
-47
lines changed

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+67-47
Original file line numberDiff line numberDiff line change
@@ -686,59 +686,79 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
686686
let mir_description = match kind {
687687
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
688688
hir::CoroutineDesugaring::Async,
689-
src,
690-
)) => match src {
691-
hir::CoroutineSource::Block => " of async block",
692-
hir::CoroutineSource::Closure => " of async closure",
693-
hir::CoroutineSource::Fn => {
694-
let parent_item =
695-
tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
696-
let output = &parent_item
697-
.fn_decl()
698-
.expect("coroutine lowered from async fn should be in fn")
699-
.output;
700-
span = output.span();
701-
if let hir::FnRetTy::Return(ret) = output {
702-
hir_ty = Some(self.get_future_inner_return_ty(*ret));
703-
}
704-
" of async function"
689+
hir::CoroutineSource::Block,
690+
)) => " of async block",
691+
692+
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
693+
hir::CoroutineDesugaring::Async,
694+
hir::CoroutineSource::Closure,
695+
)) => " of async closure",
696+
697+
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
698+
hir::CoroutineDesugaring::Async,
699+
hir::CoroutineSource::Fn,
700+
)) => {
701+
let parent_item =
702+
tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
703+
let output = &parent_item
704+
.fn_decl()
705+
.expect("coroutine lowered from async fn should be in fn")
706+
.output;
707+
span = output.span();
708+
if let hir::FnRetTy::Return(ret) = output {
709+
hir_ty = Some(self.get_future_inner_return_ty(*ret));
705710
}
706-
},
711+
" of async function"
712+
}
713+
707714
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
708715
hir::CoroutineDesugaring::Gen,
709-
src,
710-
)) => match src {
711-
hir::CoroutineSource::Block => " of gen block",
712-
hir::CoroutineSource::Closure => " of gen closure",
713-
hir::CoroutineSource::Fn => {
714-
let parent_item =
715-
tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
716-
let output = &parent_item
717-
.fn_decl()
718-
.expect("coroutine lowered from gen fn should be in fn")
719-
.output;
720-
span = output.span();
721-
" of gen function"
722-
}
723-
},
716+
hir::CoroutineSource::Block,
717+
)) => " of gen block",
718+
719+
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
720+
hir::CoroutineDesugaring::Gen,
721+
hir::CoroutineSource::Closure,
722+
)) => " of gen closure",
723+
724+
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
725+
hir::CoroutineDesugaring::Gen,
726+
hir::CoroutineSource::Fn,
727+
)) => {
728+
let parent_item =
729+
tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
730+
let output = &parent_item
731+
.fn_decl()
732+
.expect("coroutine lowered from gen fn should be in fn")
733+
.output;
734+
span = output.span();
735+
" of gen function"
736+
}
724737

725738
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
726739
hir::CoroutineDesugaring::AsyncGen,
727-
src,
728-
)) => match src {
729-
hir::CoroutineSource::Block => " of async gen block",
730-
hir::CoroutineSource::Closure => " of async gen closure",
731-
hir::CoroutineSource::Fn => {
732-
let parent_item =
733-
tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
734-
let output = &parent_item
735-
.fn_decl()
736-
.expect("coroutine lowered from async gen fn should be in fn")
737-
.output;
738-
span = output.span();
739-
" of async gen function"
740-
}
741-
},
740+
hir::CoroutineSource::Block,
741+
)) => " of async gen block",
742+
743+
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
744+
hir::CoroutineDesugaring::AsyncGen,
745+
hir::CoroutineSource::Closure,
746+
)) => " of async gen closure",
747+
748+
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
749+
hir::CoroutineDesugaring::AsyncGen,
750+
hir::CoroutineSource::Fn,
751+
)) => {
752+
let parent_item =
753+
tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
754+
let output = &parent_item
755+
.fn_decl()
756+
.expect("coroutine lowered from async gen fn should be in fn")
757+
.output;
758+
span = output.span();
759+
" of async gen function"
760+
}
761+
742762
hir::ClosureKind::Coroutine(hir::CoroutineKind::Coroutine(_)) => {
743763
" of coroutine"
744764
}

0 commit comments

Comments
 (0)