about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2025-04-08 00:34:35 +0200
committerlcnr <rust@lcnr.de>2025-04-08 00:34:40 +0200
commitd35ad8d8362071410fd934dbb737379d736019ca (patch)
treea1cb48de06eb37f1c1b13ddf021803df8d0bffdc
parent474ec7a3f4da6bdedf2d967d72bc9c6282dfcbb2 (diff)
downloadrust-d35ad8d8362071410fd934dbb737379d736019ca.tar.gz
rust-d35ad8d8362071410fd934dbb737379d736019ca.zip
add negative impl
-rw-r--r--compiler/rustc_borrowck/src/lib.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs
index d4924e1514d..64ad1c96856 100644
--- a/compiler/rustc_borrowck/src/lib.rs
+++ b/compiler/rustc_borrowck/src/lib.rs
@@ -9,6 +9,7 @@
 #![feature(file_buffered)]
 #![feature(if_let_guard)]
 #![feature(let_chains)]
+#![feature(negative_impls)]
 #![feature(never_type)]
 #![feature(rustc_attrs)]
 #![feature(rustdoc_internals)]
@@ -36,7 +37,9 @@ use rustc_infer::infer::{
 };
 use rustc_middle::mir::*;
 use rustc_middle::query::Providers;
-use rustc_middle::ty::{self, ParamEnv, RegionVid, Ty, TyCtxt, TypingMode, fold_regions};
+use rustc_middle::ty::{
+    self, ParamEnv, RegionVid, Ty, TyCtxt, TypeFoldable, TypeVisitable, TypingMode, fold_regions,
+};
 use rustc_middle::{bug, span_bug};
 use rustc_mir_dataflow::impls::{
     EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces,
@@ -236,13 +239,14 @@ pub enum ClosureOutlivesSubject<'tcx> {
 /// This abstraction is necessary because the type may include `ReVar` regions,
 /// which is what we use internally within NLL code, and they can't be used in
 /// a query response.
-///
-/// DO NOT implement `TypeVisitable` or `TypeFoldable` traits, because this
-/// type is not recognized as a binder for late-bound region.
 #[derive(Copy, Clone, Debug)]
 pub struct ClosureOutlivesSubjectTy<'tcx> {
     inner: Ty<'tcx>,
 }
+// DO NOT implement `TypeVisitable` or `TypeFoldable` traits, because this
+// type is not recognized as a binder for late-bound region.
+impl<'tcx, I> !TypeVisitable<I> for ClosureOutlivesSubjectTy<'tcx> {}
+impl<'tcx, I> !TypeFoldable<I> for ClosureOutlivesSubjectTy<'tcx> {}
 
 impl<'tcx> ClosureOutlivesSubjectTy<'tcx> {
     /// All regions of `ty` must be of kind `ReVar` and must represent