Skip to content

Commit e4a1ac5

Browse files
committed
Address code reviews
1 parent eb67ab7 commit e4a1ac5

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_middle::ty::{self, Ty};
1010
use rustc_mir_dataflow::move_paths::{LookupResult, MovePathIndex};
1111
use rustc_span::{BytePos, ExpnKind, MacroKind, Span};
1212
use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
13+
use rustc_trait_selection::infer::InferCtxtExt;
1314
use tracing::debug;
1415

1516
use 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

tests/ui/derives/duplicate-derive-copy-clone-diagnostics.rs

100755100644
+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
//~^ ERROR conflicting implementations of trait `Copy`
44
enum E {}
55

6-
fn main() {}
6+
fn main() {}

tests/ui/derives/duplicate-derive-copy-clone-diagnostics.stderr

100755100644
File mode changed.

0 commit comments

Comments
 (0)