@@ -10,6 +10,7 @@ use rustc_middle::ty::{self, Ty};
10
10
use rustc_mir_dataflow:: move_paths:: { LookupResult , MovePathIndex } ;
11
11
use rustc_span:: { BytePos , ExpnKind , MacroKind , Span } ;
12
12
use rustc_trait_selection:: error_reporting:: traits:: FindExprBySpan ;
13
+ use rustc_trait_selection:: infer:: InferCtxtExt ;
13
14
use tracing:: debug;
14
15
15
16
use crate :: MirBorrowckCtxt ;
@@ -270,6 +271,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
270
271
if self . maybe_copy ( original_path. ty ( self . body , self . infcx . tcx ) . ty ) {
271
272
// If the type may implement Copy, skip the error.
272
273
// 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
+ ) ;
273
278
return ;
274
279
}
275
280
(
@@ -297,8 +302,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
297
302
}
298
303
299
304
fn maybe_copy ( & mut self , ty : Ty < ' tcx > ) -> bool {
300
- use rustc_trait_selection:: infer:: InferCtxtExt ;
301
305
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.
302
308
self . infcx . type_implements_trait ( copy_trait_def, [ ty] , self . param_env ) . may_apply ( )
303
309
}
304
310
0 commit comments