From b3a328eecf539be2267b1373f8637f7d31cd6162 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Wed, 9 Nov 2022 02:08:22 +0000 Subject: [PATCH] Use `nominal_obligations_without_const` in wf for FnDef --- compiler/rustc_trait_selection/src/traits/wf.rs | 2 +- src/test/ui/consts/issue-104155.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/consts/issue-104155.rs diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 8908fe230b0eb..fc0a9f6900336 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -547,7 +547,7 @@ impl<'tcx> WfPredicates<'tcx> { } ty::FnDef(did, substs) => { - let obligations = self.nominal_obligations(did, substs); + let obligations = self.nominal_obligations_without_const(did, substs); self.out.extend(obligations); } diff --git a/src/test/ui/consts/issue-104155.rs b/src/test/ui/consts/issue-104155.rs new file mode 100644 index 0000000000000..1cc8f81b0d257 --- /dev/null +++ b/src/test/ui/consts/issue-104155.rs @@ -0,0 +1,5 @@ +// check-pass +const _: () = core::mem::forget(Box::::default); +const _: () = core::mem::forget(|| Box::::default()); + +fn main() {}