Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
1e4cab7
update debuginfo testing information w/ GDB changes
Walnut356 Sep 15, 2026
4778ae5
Mark `rustfmt` as being managed by Josh
Kobzol Sep 23, 2026
0b5a220
Merge pull request #3032 from Kobzol/rustfmt-josh
Kobzol Sep 23, 2026
dc39f01
making clamp_magnitude functions const + adding clamp_magnitude to No…
Eleocraft Sep 24, 2026
d6d250c
adding coretests and fixing docs
Eleocraft Sep 24, 2026
3f2e9ee
Applying requested changes
Eleocraft Sep 25, 2026
c89c55d
sanitizers.md: improve text
tshepang Sep 25, 2026
29644a6
Merge pull request #3033 from rust-lang/tshepang-patch-3
tshepang Sep 25, 2026
8c3ae60
Don't build format string suggestions from `concat!` offsets
h-kurashina Sep 26, 2026
36c3cb9
ConstKind::Unevaluated -> ConstKind::Alias
reddevilmidzy Sep 26, 2026
5e11a26
fix ConstKind link
reddevilmidzy Sep 26, 2026
594f107
Merge pull request rust-lang/rustc-dev-guide#3034 from reddevilmidzy/…
reddevilmidzy Sep 26, 2026
645a2b9
Merge pull request #3016 from Walnut356/gdb_di_test
jieyouxu Sep 27, 2026
b9e7e71
nonzero doc: replacing tabs with spaces
Eleocraft Sep 28, 2026
d10b01c
Use `{IntTy,UintTy}::name` in `Ty::primitive_symbol`
nnethercote Sep 29, 2026
935c565
Factor out repeated `get_normal_item` calls
nnethercote Jul 27, 2026
bc7618a
Add test case for an invalid attribute with nested `cfg_attr`
nnethercote Jul 27, 2026
7af2cce
Remove unused `rustc_middle::ty::cast::IntTy::is_signed`
nnethercote Sep 29, 2026
3e5b244
Mark duplicate attr messages as not machine applicable
nnethercote Jul 28, 2026
b2c2077
Update expect messages in library/std/src/os/unix/net/ following styl…
literally-user Sep 26, 2026
bc0240c
Don't use the metadata based crate_hash for rustdoc runs
Daniel-B-Smith Sep 28, 2026
588c189
expose Rc::is_unique
malezjaa Sep 29, 2026
0883f59
x86_64: cleanup `reg_component`
folkertdev Sep 29, 2026
7f5fdab
x86 callconv: refactor into separate classify methods
folkertdev Sep 26, 2026
457af24
x86 callconv: put regparam into `Flavor::General`
folkertdev Sep 26, 2026
14d09db
cycle handling: mirror old solver
lcnr Sep 29, 2026
36358d0
gating f16 and f128 tests behind target_has_reliable
Eleocraft Sep 29, 2026
2eeeb39
Use more default field values in `Resolver`
estebank Sep 29, 2026
728205b
Forbid `Reborrow` impls for types with destructors
Jules-Bertholet Sep 30, 2026
a5e0df2
Remove `rustc_middle::ty::cast::IntTy`
nnethercote Sep 29, 2026
9bdf58f
Move `rustc_middle::ty::cast::CastKind`
nnethercote Sep 29, 2026
9970383
Document `Result` case for the `arena_cache` query modifier
nnethercote Sep 1, 2026
424d242
Attribute documentation for cfg_attr
kantnero Aug 3, 2026
63a9c85
fix CI failure
kantnero Aug 3, 2026
1e418da
fix merge conflict
kantnero Aug 3, 2026
1850727
fix ci
kantnero Sep 30, 2026
654d664
add regression test
lcnr Sep 30, 2026
8a04120
replace awkward wording
tshepang Sep 30, 2026
126eeb7
reflow src/external-repos.md
tshepang Sep 30, 2026
96bffc4
improve external-repos.md
tshepang Sep 30, 2026
ce15ffa
reflow src/external-repos.md
tshepang Sep 30, 2026
b0f32dc
Merge pull request #3037 from rust-lang/tshepang/misc
tshepang Sep 30, 2026
5b45912
Prepare for merging from rust-lang/rust
tshepang Sep 30, 2026
991a562
Merge ref '7d2cd0fbc092' from rust-lang/rust
tshepang Sep 30, 2026
6c8c024
Merge pull request #3038 from rust-lang/tshepang/pull
tshepang Sep 30, 2026
57be633
address feedback
kantnero Sep 30, 2026
937145b
PassWrapper: adapt for new PassPlugin load method
durin42 Sep 30, 2026
1eb5c52
Suggest `#[unsafe(no_mangle)]` for entry points in `no_std` binaries
simonether Sep 30, 2026
dd0f941
make mips64 `Complex` ABI GCC-compatible
folkertdev Jul 26, 2026
f25f4eb
sembr src/const-generics.md
tshepang Sep 30, 2026
dd00fa8
manual sembr
tshepang Sep 30, 2026
25a59cb
sometimes shortens lines, for looks
tshepang Sep 30, 2026
07ee9e0
reflow src/building/bootstrapping/what-bootstrapping-does.md
tshepang Sep 30, 2026
d3bfa9a
improve building/bootstrapping/what-bootstrapping-does.md
tshepang Sep 30, 2026
bb523e8
make it one big test
tshepang Sep 30, 2026
af57095
shorten, to match the other fn, "comply"
tshepang Sep 30, 2026
7884545
sembr src/diagnostics.md
tshepang Sep 30, 2026
2238f1b
improve diagnostics.md
tshepang Sep 30, 2026
56a6ee6
sembr src/mir/index.md
tshepang Sep 30, 2026
7710f70
improve mir/index.md
tshepang Sep 30, 2026
88e8e02
reflow src/mir/index.md
tshepang Sep 30, 2026
062f7ac
sembr src/tracing.md
tshepang Sep 30, 2026
bdd2007
improve tracing.md
tshepang Sep 30, 2026
e60b153
reflow src/tracing.md
tshepang Sep 30, 2026
543c24d
sembr src/debuginfo/llvm-codegen.md
tshepang Sep 30, 2026
1b5002d
improve debuginfo/llvm-codegen.md
tshepang Sep 30, 2026
0529c62
sembr src/profiling/with-perf.md
tshepang Sep 30, 2026
b5297f7
missing pauses
tshepang Sep 30, 2026
05c8132
sembr src/effects.md
tshepang Sep 30, 2026
666f648
missing pause
tshepang Sep 30, 2026
b3bd159
sembr src/query.md
tshepang Sep 30, 2026
954e7c0
reflow src/query.md
tshepang Sep 30, 2026
6bc3868
sembr src/ty.md
tshepang Sep 30, 2026
d1f4fd3
improve ty.md
tshepang Sep 30, 2026
96df2f5
extraneous
tshepang Sep 30, 2026
c792eb7
Merge pull request #3039 from rust-lang/tshepang/misc
tshepang Sep 30, 2026
81b9a58
remove dead cfg_select! arm
CAD97 Sep 30, 2026
262fa31
Provide more context on "not general enough" error
estebank Sep 20, 2026
3aba6fc
Add libs-nominated triagebot config
clarfonthey Sep 30, 2026
a2e82d0
Rollup merge of #163279 - Eleocraft:clamp-magnitude-unsigned-limit, r…
jhpratt Oct 1, 2026
47e11e2
Rollup merge of #163081 - estebank:not-general-enough, r=saethlin
jhpratt Oct 1, 2026
af85a6d
Rollup merge of #163455 - Daniel-B-Smith:smithdb3/163426, r=bjorn3
jhpratt Oct 1, 2026
c6d9e9c
Rollup merge of #159798 - kantnero:attribute-documentation, r=mejrs
jhpratt Oct 1, 2026
973d397
Rollup merge of #162921 - folkertdev:complex-mips64, r=beetrees
jhpratt Oct 1, 2026
3ea0d1e
Rollup merge of #163368 - h-kurashina:fix-156101, r=mejrs
jhpratt Oct 1, 2026
1b2b4b4
Rollup merge of #163375 - literally-user:better-expect-messages, r=Ch…
jhpratt Oct 1, 2026
fc36692
Rollup merge of #163470 - nnethercote:misc-attr-error-stuff, r=Jonath…
jhpratt Oct 1, 2026
0c13396
Rollup merge of #163489 - malezjaa:expose-rc-is_unique, r=clarfonthey
jhpratt Oct 1, 2026
1e919de
Rollup merge of #163492 - folkertdev:x86-callconv-refactor, r=oli-obk
jhpratt Oct 1, 2026
77efc48
Rollup merge of #163496 - lcnr:weaken-cycle-handling, r=jackh726
jhpratt Oct 1, 2026
275da97
Rollup merge of #163509 - estebank:default-more, r=petrochenkov
jhpratt Oct 1, 2026
9b013c5
Rollup merge of #163519 - Jules-Bertholet:no-reborrow-destructor, r=m…
jhpratt Oct 1, 2026
1bea8be
Rollup merge of #163520 - nnethercote:cast-cleanups, r=oli-obk
jhpratt Oct 1, 2026
e3e47e2
Rollup merge of #163524 - nnethercote:arena_cache-Result-doc, r=Zalathar
jhpratt Oct 1, 2026
f2e0f20
Rollup merge of #163546 - durin42:llvm-24-passplugin-load, r=cuviper
jhpratt Oct 1, 2026
fa3282c
Rollup merge of #163551 - clarfonthey:triagebot-libs, r=nia-e
jhpratt Oct 1, 2026
4f27b89
Rollup merge of #163559 - simonether:no-std-no-mangle-help, r=nnether…
jhpratt Oct 1, 2026
bad15af
Rollup merge of #163564 - tshepang:rdg-sync, r=tshepang
jhpratt Oct 1, 2026
aaae40b
Rollup merge of #163568 - CAD97:spurious-cfg-select, r=JonathanBrouwer
jhpratt Oct 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions compiler/rustc_attr_parsing/src/attributes/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ pub fn parse_cfg_attr(
features: Option<&Features>,
lint_node_id: ast::NodeId,
) -> Option<(CfgEntry, Vec<(WithTokens<AttrItem>, Span)>)> {
match &cfg_attr.get_normal_item().args {
let item = cfg_attr.get_normal_item();
match &item.args {
ast::AttrArgs::Delimited(ast::DelimArgs { dspan, delim, tokens }) if !tokens.is_empty() => {
check_cfg_attr_bad_delim(&sess.psess, *dspan, *delim);
match parse_in(&sess.psess, tokens.clone(), "`cfg_attr` input", |p| {
Expand All @@ -316,11 +317,11 @@ pub fn parse_cfg_attr(
Err(e) => {
let suggestions = CFG_ATTR_TEMPLATE.suggestions(
ParsedDescription::Attribute,
cfg_attr.get_normal_item().unsafety,
item.unsafety,
sym::cfg_attr,
);
e.with_span_suggestions(
cfg_attr.get_normal_item().span,
item.span,
"must be of the form",
suggestions,
Applicability::HasPlaceholders,
Expand All @@ -334,25 +335,24 @@ pub fn parse_cfg_attr(
}
}
_ => {
let (span, reason) = if let ast::AttrArgs::Delimited(ast::DelimArgs { dspan, .. }) =
cfg_attr.get_normal_item().args
{
(dspan.entire(), AttributeParseErrorReason::ExpectedAtLeastOneArgument)
} else {
(cfg_attr.get_normal_item().span, AttributeParseErrorReason::ExpectedList)
};
let (span, reason) =
if let ast::AttrArgs::Delimited(ast::DelimArgs { dspan, .. }) = item.args {
(dspan.entire(), AttributeParseErrorReason::ExpectedAtLeastOneArgument)
} else {
(item.span, AttributeParseErrorReason::ExpectedList)
};

sess.dcx().emit_err(AttributeParseError {
span,
inner_span: cfg_attr.get_normal_item().span,
inner_span: item.span,
template: CFG_ATTR_TEMPLATE,
path: AttrPath::from_ast(&cfg_attr.get_normal_item().path, identity),
path: AttrPath::from_ast(&item.path, identity),
description: ParsedDescription::Attribute,
reason,
suggestions: diagnostics::AttributeParseErrorSuggestions::CreatedByTemplate(
CFG_ATTR_TEMPLATE.suggestions(
ParsedDescription::Attribute,
cfg_attr.get_normal_item().unsafety,
item.unsafety,
sym::cfg_attr,
),
),
Expand Down Expand Up @@ -389,13 +389,14 @@ fn parse_cfg_attr_internal<'a>(
)?;
let pred_span = pred_start.with_hi(parser.token.span.hi());

let item = attribute.get_normal_item();
let cfg_predicate = AttributeParser::parse_single_args(
sess,
attribute.span,
attribute.get_normal_item().span,
item.span,
attribute.style,
AttrPath { segments: attribute.path().into_boxed_slice(), span: attribute.span },
Some(attribute.get_normal_item().unsafety),
Some(item.unsafety),
AttributeSafety::Normal,
ParsedDescription::Attribute,
pred_span,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ pub(crate) struct UnknownVersionLiteral {
#[diag("multiple `{$name}` attributes")]
pub(crate) struct UnusedMultiple {
#[primary_span]
#[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
#[suggestion("remove this attribute", code = "", applicability = "unspecified")]
pub this: Span,
#[note("attribute also specified here")]
pub other: Span,
Expand Down Expand Up @@ -2061,7 +2061,7 @@ pub(crate) struct AdditionalCommaSuggestion {
#[derive(Diagnostic)]
#[diag("unused attribute")]
pub(crate) struct UnusedDuplicate {
#[suggestion("remove this attribute", code = "", applicability = "machine-applicable")]
#[suggestion("remove this attribute", code = "", applicability = "unspecified")]
pub this: Span,
#[note("attribute also specified here")]
pub other: Span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
let mut preds = path
.iter()
.filter_map(|constraint| match constraint.category {
ConstraintCategory::Predicate(pred) if !pred.is_dummy() => Some(pred),
ConstraintCategory::Predicate(pred, _) if !pred.is_dummy() => Some(pred),
_ => None,
})
.collect::<Vec<Span>>();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
ConstraintCategory::ClosureUpvar(_) => "closure capture ",
ConstraintCategory::Usage => "this usage ",
ConstraintCategory::SolverRegionConstraint(_)
| ConstraintCategory::Predicate(_)
| ConstraintCategory::Predicate(_, _)
| ConstraintCategory::Boring
| ConstraintCategory::BoringNoLocation
| ConstraintCategory::Internal
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub struct ClosureOutlivesRequirement<'tcx> {

// Make sure this enum doesn't unintentionally grow
#[cfg(target_pointer_width = "64")]
rustc_data_structures::static_assert_size!(ConstraintCategory<'_>, 16);
rustc_data_structures::static_assert_size!(ConstraintCategory<'_>, 24);

/// The subject of a `ClosureOutlivesRequirement` -- that is, the thing
/// that must outlive some region.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ impl<'tcx> BestBlame<'tcx> {
.path
.iter()
.find_map(|constraint| {
if let ConstraintCategory::Predicate(predicate_span) = constraint.category {
if let ConstraintCategory::Predicate(predicate_span, def_id) = constraint.category {
// We currently do not store the `DefId` in the `ConstraintCategory`
// for performances reasons. The error reporting code used by NLL only
// uses the span, so this doesn't cause any problems at the moment.
Some(ObligationCauseCode::WhereClause(CRATE_DEF_ID.to_def_id(), predicate_span))
Some(ObligationCauseCode::WhereClause(def_id, predicate_span))
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/region_infer/region_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ impl<'tcx> RegionInferenceContextInner<'tcx> {
// Generic arguments are unlikely to be what relates regions together
ConstraintCategory::TypeAnnotation(AnnotationSource::GenericArg) => 3,
// We handle predicates and opaque types specially; don't prioritize them here.
ConstraintCategory::Predicate(_) | ConstraintCategory::OpaqueType => 4,
ConstraintCategory::Predicate(_, _) | ConstraintCategory::OpaqueType => 4,
// `Boring` constraints can correspond to user-written code and have useful spans,
// but don't provide any other useful information for diagnostics.
ConstraintCategory::Boring => 5,
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_borrowck/src/type_check/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
#[instrument(level = "debug", skip(self))]
pub(super) fn normalize_and_prove_instantiated_clauses(
&mut self,
// Keep this parameter for now, in case we start using
// it in `ConstraintCategory` at some point.
_def_id: DefId,
def_id: DefId,
instantiated_clauses: ty::InstantiatedClauses<'tcx>,
locations: Locations,
) {
for (clause, span) in instantiated_clauses {
debug!(?span, ?clause);
let category = ConstraintCategory::Predicate(span);
let category = ConstraintCategory::Predicate(span, def_id);
let clause = self.normalize_with_category(clause, locations, category);
self.prove_clause(clause, locations, category);
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
let cast_ty_from = CastTy::from_ty(ty_from);
let cast_ty_to = CastTy::from_ty(*ty);
match (cast_ty_from, cast_ty_to) {
(Some(CastTy::Ptr(_) | CastTy::FnPtr), Some(CastTy::Int(_))) => (),
(Some(CastTy::Ptr(_) | CastTy::FnPtr), Some(CastTy::Int)) => (),
_ => {
span_mirbug!(
self,
Expand All @@ -1379,7 +1379,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
let cast_ty_from = CastTy::from_ty(ty_from);
let cast_ty_to = CastTy::from_ty(*ty);
match (cast_ty_from, cast_ty_to) {
(Some(CastTy::Int(_)), Some(CastTy::Ptr(_))) => (),
(Some(CastTy::Int), Some(CastTy::Ptr(_))) => (),
_ => {
span_mirbug!(
self,
Expand All @@ -1396,7 +1396,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
let cast_ty_from = CastTy::from_ty(ty_from);
let cast_ty_to = CastTy::from_ty(*ty);
match (cast_ty_from, cast_ty_to) {
(Some(CastTy::Int(_)), Some(CastTy::Int(_))) => (),
(Some(from), Some(to)) if from.is_int_like() && to.is_int_like() => (),
_ => {
span_mirbug!(
self,
Expand All @@ -1413,7 +1413,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
let cast_ty_from = CastTy::from_ty(ty_from);
let cast_ty_to = CastTy::from_ty(*ty);
match (cast_ty_from, cast_ty_to) {
(Some(CastTy::Int(_)), Some(CastTy::Float)) => (),
(Some(CastTy::Int), Some(CastTy::Float)) => (),
_ => {
span_mirbug!(
self,
Expand All @@ -1430,7 +1430,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
let cast_ty_from = CastTy::from_ty(ty_from);
let cast_ty_to = CastTy::from_ty(*ty);
match (cast_ty_from, cast_ty_to) {
(Some(CastTy::Float), Some(CastTy::Int(_))) => (),
(Some(CastTy::Float), Some(CastTy::Int)) => (),
_ => {
span_mirbug!(
self,
Expand Down
26 changes: 16 additions & 10 deletions compiler/rustc_builtin_macros/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ fn make_format_args(
parse::Suggestion::UsePositional => {
let captured_arg_span =
fmt_span.from_inner(InnerSpan::new(err.span.start, err.span.end));
if let Ok(arg) = ecx.source_map().span_to_snippet(captured_arg_span) {
if is_source_literal
&& let Ok(arg) = ecx.source_map().span_to_snippet(captured_arg_span)
{
let span = match args.unnamed_args().last() {
Some(arg) => arg.expr.span,
None => fmt_span,
Expand All @@ -360,17 +362,21 @@ fn make_format_args(
}
}
parse::Suggestion::ReorderFormatParameter(span, replacement) => {
let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
e.sugg_ =
Some(diagnostics::InvalidFormatStringSuggestion::ReorderFormatParameter {
span,
replacement,
});
if is_source_literal {
let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
e.sugg_ =
Some(diagnostics::InvalidFormatStringSuggestion::ReorderFormatParameter {
span,
replacement,
});
}
}
parse::Suggestion::AddMissingColon(span) => {
let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
e.sugg_ =
Some(diagnostics::InvalidFormatStringSuggestion::AddMissingColon { span });
if is_source_literal {
let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end));
e.sugg_ =
Some(diagnostics::InvalidFormatStringSuggestion::AddMissingColon { span });
}
}
parse::Suggestion::UseRustDebugPrintingMacro => {
// This targets `println!("{=}", x);` and `println!("{0=}", x);`
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_data_structures/src/fx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ macro_rules! define_stable_id_collections {
}

pub mod default {
use super::{FxBuildHasher, FxHashMap, FxHashSet};
use super::{FxBuildHasher, FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};

// FIXME: These two functions will become unnecessary after
// <https://github.com/rust-lang/rustc-hash/pull/63> lands and we start using the corresponding
Expand All @@ -40,4 +40,12 @@ pub mod default {
pub const fn fx_hash_set<V>() -> FxHashSet<V> {
FxHashSet::with_hasher(FxBuildHasher)
}

pub const fn fx_index_map<K, V>() -> FxIndexMap<K, V> {
FxIndexMap::with_hasher(FxBuildHasher)
}

pub const fn fx_index_set<V>() -> FxIndexSet<V> {
FxIndexSet::with_hasher(FxBuildHasher)
}
}
15 changes: 14 additions & 1 deletion compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ fn visit_implementation_of_copy(checker: &Checker<'_>) -> Result<(), ErrorGuaran
Err(CopyImplementationError::HasDestructor(did)) => {
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
let impl_ = tcx.def_span(did);
Err(tcx.dcx().emit_err(diagnostics::CopyImplOnTypeWithDtor { span, impl_ }))
Err(tcx.dcx().emit_err(diagnostics::TraitImplOnTypeWithDtor {
span,
impl_,
trait_name: sym::Copy,
}))
}
Err(CopyImplementationError::HasUnsafeFields) => {
let span = tcx.hir_expect_item(impl_did).expect_impl().self_ty.span;
Expand Down Expand Up @@ -537,6 +541,15 @@ pub(crate) fn reborrow_info<'tcx>(
assert_field_type_is_copy(tcx, &infcx, impl_did, param_env, field.ty, field.span)?;
}

if let Some(did) = def.destructor(tcx).map(|dtor| dtor.did) {
let impl_ = tcx.def_span(did);
return Err(tcx.dcx().emit_err(diagnostics::TraitImplOnTypeWithDtor {
span,
impl_,
trait_name: sym::Reborrow,
}));
}

Ok(())
}

Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_hir_analysis/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,14 @@ pub(crate) struct FieldAlreadyDeclaredNestedHelp {
}

#[derive(Diagnostic)]
#[diag("the trait `Copy` cannot be implemented for this type; the type has a destructor", code = E0184)]
pub(crate) struct CopyImplOnTypeWithDtor {
#[diag("the trait `{$trait_name}` cannot be implemented for this type; the type has a destructor", code = E0184)]
pub(crate) struct TraitImplOnTypeWithDtor {
#[primary_span]
#[label("`Copy` not allowed on types with destructors")]
#[label("`{$trait_name}` not allowed on types with destructors")]
pub span: Span,
#[note("destructor declared here")]
pub impl_: Span,
pub trait_name: Symbol,
}

#[derive(Diagnostic)]
Expand Down
Loading
Loading