about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-02-01 20:07:58 +0000
committerbors <bors@rust-lang.org>2025-02-01 20:07:58 +0000
commit8239a37f9c0951a037cfc51763ea52a20e71e6bd (patch)
tree869cab603a15f4c6b1de22ec2ee905a12af7dc5b /compiler/rustc_trait_selection
parente08cd3cf05e5bfa3323cc21ea8f81f4a15a2f969 (diff)
parent2a82ebdcb7512b818da18eb04d1d11f623d6e38c (diff)
downloadrust-8239a37f9c0951a037cfc51763ea52a20e71e6bd.tar.gz
rust-8239a37f9c0951a037cfc51763ea52a20e71e6bd.zip
Auto merge of #136389 - matthiaskrgr:rollup-x453dy9, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #130514 (Implement MIR lowering for unsafe binders)
 - #135684 (docs: Documented Send and Sync requirements for Mutex + MutexGuard)
 - #136307 (Implement all mix/max functions in a (hopefully) more optimization amendable way)
 - #136360 (Stabilize `once_wait`)
 - #136364 (document that ptr cmp is unsigned)
 - #136374 (Add link attribute for Enzyme's LLVMRust FFI)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_trait_selection')
-rw-r--r--compiler/rustc_trait_selection/src/traits/wf.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs
index 37d49cc2f55..96051ad0aa5 100644
--- a/compiler/rustc_trait_selection/src/traits/wf.rs
+++ b/compiler/rustc_trait_selection/src/traits/wf.rs
@@ -830,8 +830,25 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
                 // Let the visitor iterate into the argument/return
                 // types appearing in the fn signature.
             }
-            ty::UnsafeBinder(_) => {
-                // FIXME(unsafe_binders): We should also recurse into the binder here.
+            ty::UnsafeBinder(ty) => {
+                // FIXME(unsafe_binders): For now, we have no way to express
+                // that a type must be `ManuallyDrop` OR `Copy` (or a pointer).
+                if !ty.has_escaping_bound_vars() {
+                    self.out.push(traits::Obligation::new(
+                        self.tcx(),
+                        self.cause(ObligationCauseCode::Misc),
+                        self.param_env,
+                        ty.map_bound(|ty| {
+                            ty::TraitRef::new(
+                                self.tcx(),
+                                self.tcx().require_lang_item(LangItem::Copy, Some(self.span)),
+                                [ty],
+                            )
+                        }),
+                    ));
+                }
+
+                // We recurse into the binder below.
             }
 
             ty::Dynamic(data, r, _) => {