From 433c1aec2195eb8864e46bf24f50f74123bbb284 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Tue, 8 Jun 2021 17:19:16 +0200 Subject: [PATCH] Check whether the closure's owner has a body before deferring to it in thir-unsafeck --- .../rustc_mir_build/src/check_unsafety.rs | 11 +++++++--- src/test/ui/thir-unsafeck-issue-85871.rs | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/thir-unsafeck-issue-85871.rs diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 2d52577829c71..72a55909e1552 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -368,10 +368,15 @@ pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam 42, // we may not call the closure here (E0015) + }], +} + +enum E { + V([(); { let _ = || 1; 42 }]), +} + +type Ty = [(); { let _ = || 1; 42 }]; + +fn main() {}