Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 27e38f8

Browse files
committedNov 5, 2024
Auto merge of #132626 - workingjubilee:rollup-hbmtbzk, r=workingjubilee
Rollup of 11 pull requests Successful merges: - #131153 (Improve duplicate derive Copy/Clone diagnostics) - #132025 (fix suggestion for diagnostic error E0027) - #132303 (More tests for non-exhaustive C-like enums in FFI) - #132492 (remove support for extern-block const intrinsics) - #132587 (Revert "Avoid nested replacement ranges" from #129346.) - #132596 ([rustdoc] Fix `--show-coverage` when JSON output format is used) - #132598 (Clippy: Move some attribute lints to be early pass (post expansion)) - #132601 (Update books) - #132606 (Improve example of `impl Pattern for &[char]`) - #132608 (document `type_implements_trait`) - #132609 (docs: fix grammar in doc comment at unix/process.rs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 96477c5 + 7bff6ff commit 27e38f8

File tree

82 files changed

+1705
-1401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1705
-1401
lines changed
 

‎compiler/rustc_attr/src/builtin.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ pub fn find_stability(
273273
/// Collects stability info from `rustc_const_stable`/`rustc_const_unstable`/`rustc_promotable`
274274
/// attributes in `attrs`. Returns `None` if no stability attributes are found.
275275
///
276-
/// `is_const_fn` indicates whether this is a function marked as `const`. It will always
277-
/// be false for intrinsics in an `extern` block!
276+
/// `is_const_fn` indicates whether this is a function marked as `const`.
278277
pub fn find_const_stability(
279278
sess: &Session,
280279
attrs: &[Attribute],
@@ -330,7 +329,7 @@ pub fn find_const_stability(
330329
}
331330
}
332331

333-
// Merge promotable and not_exposed_on_stable into stability info
332+
// Merge promotable and const_stable_indirect into stability info
334333
if promotable {
335334
match &mut const_stab {
336335
Some((stab, _)) => stab.promotable = promotable,
@@ -352,10 +351,7 @@ pub fn find_const_stability(
352351
})
353352
}
354353
}
355-
_ => {
356-
// We ignore the `#[rustc_const_stable_indirect]` here, it should be picked up by
357-
// the `default_const_unstable` logic.
358-
}
354+
_ => {}
359355
}
360356
}
361357
// Make sure if `const_stable_indirect` is present, that is recorded. Also make sure all `const

‎compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 17 additions & 0 deletions
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;
@@ -267,6 +268,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
267268
kind,
268269
self.is_upvar_field_projection(original_path.as_ref())
269270
);
271+
if self.has_ambiguous_copy(original_path.ty(self.body, self.infcx.tcx).ty) {
272+
// If the type may implement Copy, skip the error.
273+
// It's an error with the Copy implementation (e.g. duplicate Copy) rather than borrow check
274+
self.dcx().span_delayed_bug(
275+
span,
276+
"Type may implement copy, but there is no other error.",
277+
);
278+
return;
279+
}
270280
(
271281
match kind {
272282
&IllegalMoveOriginKind::BorrowedContent { target_place } => self
@@ -291,6 +301,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
291301
self.buffer_error(err);
292302
}
293303

304+
fn has_ambiguous_copy(&mut self, ty: Ty<'tcx>) -> bool {
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.
308+
self.infcx.type_implements_trait(copy_trait_def, [ty], self.param_env).may_apply()
309+
}
310+
294311
fn report_cannot_move_from_static(&mut self, place: Place<'tcx>, span: Span) -> Diag<'infcx> {
295312
let description = if place.projection.len() == 1 {
296313
format!("static item {}", self.describe_any_place(place.as_ref()))

0 commit comments

Comments
 (0)
Please sign in to comment.