@@ -10,6 +10,7 @@ use rustc_middle::ty::{self, Ty};
1010use rustc_mir_dataflow:: move_paths:: { LookupResult , MovePathIndex } ;
1111use rustc_span:: { BytePos , ExpnKind , MacroKind , Span } ;
1212use rustc_trait_selection:: error_reporting:: traits:: FindExprBySpan ;
13+ use rustc_trait_selection:: infer:: InferCtxtExt ;
1314use tracing:: debug;
1415
1516use crate :: MirBorrowckCtxt ;
@@ -270,6 +271,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
270271 if self . maybe_copy ( original_path. ty ( self . body , self . infcx . tcx ) . ty ) {
271272 // If the type may implement Copy, skip the error.
272273 // It's an error with the Copy implementation (e.g. duplicate Copy) rather than borrow check
274+ self . span_delayed_bug (
275+ span,
276+ "Type may implement copy, but there is no other error." ,
277+ ) ;
273278 return ;
274279 }
275280 (
@@ -297,8 +302,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
297302 }
298303
299304 fn maybe_copy ( & mut self , ty : Ty < ' tcx > ) -> bool {
300- use rustc_trait_selection:: infer:: InferCtxtExt ;
301305 let Some ( copy_trait_def) = self . infcx . tcx . lang_items ( ) . copy_trait ( ) else { return false } ;
306+ // This is only going to be ambiguous if there are incoherent impls, because otherwise
307+ // ambiguity should never happen in MIR.
302308 self . infcx . type_implements_trait ( copy_trait_def, [ ty] , self . param_env ) . may_apply ( )
303309 }
304310
0 commit comments