@@ -172,6 +172,24 @@ impl<'tcx> TyCtxt<'tcx> {
172172 }
173173 }
174174
175+ /// Checks whether `ty: Copy` holds while ignoring region constraints.
176+ ///
177+ /// This impacts whether values of `ty` are *moved* or *copied*
178+ /// when referenced. This means that we may generate MIR which
179+ /// does copies even when the type actually doesn't satisfy the
180+ /// full requirements for the `Copy` trait (cc #29149) -- this
181+ /// winds up being reported as an error during NLL borrow check.
182+ ///
183+ /// This function should not be used if there is an `InferCtxt` available.
184+ /// Use `InferCtxt::type_is_copy_modulo_regions` instead.
185+ pub fn type_is_copy_modulo_regions (
186+ self ,
187+ typing_env : ty:: TypingEnv < ' tcx > ,
188+ ty : Ty < ' tcx > ,
189+ ) -> bool {
190+ ty. is_trivially_pure_clone_copy ( ) || self . is_copy_raw ( typing_env. as_query_input ( ty) )
191+ }
192+
175193 /// Returns the deeply last field of nested structures, or the same type if
176194 /// not a structure at all. Corresponds to the only possible unsized field,
177195 /// and its type can be used to determine unsizing strategy.
@@ -1174,21 +1192,6 @@ impl<'tcx> Ty<'tcx> {
11741192 . map ( |( min, _) | ty:: Const :: from_bits ( tcx, min, typing_env, self ) )
11751193 }
11761194
1177- /// Checks whether values of this type `T` are *moved* or *copied*
1178- /// when referenced -- this amounts to a check for whether `T:
1179- /// Copy`, but note that we **don't** consider lifetimes when
1180- /// doing this check. This means that we may generate MIR which
1181- /// does copies even when the type actually doesn't satisfy the
1182- /// full requirements for the `Copy` trait (cc #29149) -- this
1183- /// winds up being reported as an error during NLL borrow check.
1184- pub fn is_copy_modulo_regions (
1185- self ,
1186- tcx : TyCtxt < ' tcx > ,
1187- typing_env : ty:: TypingEnv < ' tcx > ,
1188- ) -> bool {
1189- self . is_trivially_pure_clone_copy ( ) || tcx. is_copy_raw ( typing_env. as_query_input ( self ) )
1190- }
1191-
11921195 /// Checks whether values of this type `T` have a size known at
11931196 /// compile time (i.e., whether `T: Sized`). Lifetimes are ignored
11941197 /// for the purposes of this check, so it can be an
0 commit comments