Flatten match

This commit is contained in:
Michael Goulet 2023-12-25 18:05:32 +00:00
parent 27dce304cb
commit ba912855cc

View File

@ -686,59 +686,79 @@ fn give_name_if_anonymous_region_appears_in_output(&self, fr: RegionVid) -> Opti
let mir_description = match kind { let mir_description = match kind {
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared( hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
hir::CoroutineDesugaring::Async, hir::CoroutineDesugaring::Async,
src, hir::CoroutineSource::Block,
)) => match src { )) => " of async block",
hir::CoroutineSource::Block => " of async block",
hir::CoroutineSource::Closure => " of async closure", hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
hir::CoroutineSource::Fn => { hir::CoroutineDesugaring::Async,
let parent_item = hir::CoroutineSource::Closure,
tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id); )) => " of async closure",
let output = &parent_item
.fn_decl() hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
.expect("coroutine lowered from async fn should be in fn") hir::CoroutineDesugaring::Async,
.output; hir::CoroutineSource::Fn,
span = output.span(); )) => {
if let hir::FnRetTy::Return(ret) = output { let parent_item =
hir_ty = Some(self.get_future_inner_return_ty(*ret)); tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
} let output = &parent_item
" of async function" .fn_decl()
.expect("coroutine lowered from async fn should be in fn")
.output;
span = output.span();
if let hir::FnRetTy::Return(ret) = output {
hir_ty = Some(self.get_future_inner_return_ty(*ret));
} }
}, " of async function"
}
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared( hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
hir::CoroutineDesugaring::Gen, hir::CoroutineDesugaring::Gen,
src, hir::CoroutineSource::Block,
)) => match src { )) => " of gen block",
hir::CoroutineSource::Block => " of gen block",
hir::CoroutineSource::Closure => " of gen closure", hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
hir::CoroutineSource::Fn => { hir::CoroutineDesugaring::Gen,
let parent_item = hir::CoroutineSource::Closure,
tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id); )) => " of gen closure",
let output = &parent_item
.fn_decl() hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
.expect("coroutine lowered from gen fn should be in fn") hir::CoroutineDesugaring::Gen,
.output; hir::CoroutineSource::Fn,
span = output.span(); )) => {
" of gen function" let parent_item =
} tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
}, let output = &parent_item
.fn_decl()
.expect("coroutine lowered from gen fn should be in fn")
.output;
span = output.span();
" of gen function"
}
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared( hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
hir::CoroutineDesugaring::AsyncGen, hir::CoroutineDesugaring::AsyncGen,
src, hir::CoroutineSource::Block,
)) => match src { )) => " of async gen block",
hir::CoroutineSource::Block => " of async gen block",
hir::CoroutineSource::Closure => " of async gen closure", hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
hir::CoroutineSource::Fn => { hir::CoroutineDesugaring::AsyncGen,
let parent_item = hir::CoroutineSource::Closure,
tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id); )) => " of async gen closure",
let output = &parent_item
.fn_decl() hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(
.expect("coroutine lowered from async gen fn should be in fn") hir::CoroutineDesugaring::AsyncGen,
.output; hir::CoroutineSource::Fn,
span = output.span(); )) => {
" of async gen function" let parent_item =
} tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
}, let output = &parent_item
.fn_decl()
.expect("coroutine lowered from async gen fn should be in fn")
.output;
span = output.span();
" of async gen function"
}
hir::ClosureKind::Coroutine(hir::CoroutineKind::Coroutine(_)) => { hir::ClosureKind::Coroutine(hir::CoroutineKind::Coroutine(_)) => {
" of coroutine" " of coroutine"
} }