Skip to content

Commit 82b311b

Browse files
committed
Auto merge of #112016 - GuillaumeGomez:rollup-fhqn4i6, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #111936 (Include test suite metadata in the build metrics) - #111952 (Remove DesugaringKind::Replace.) - #111966 (Add #[inline] to array TryFrom impls) - #111983 (Perform MIR type ops locally in new solver) - #111997 (Fix re-export of doc hidden macro not showing up) - #112014 (rustdoc: get unnormalized link destination for suggestions) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 786178b + 3089653 commit 82b311b

File tree

54 files changed

+1610
-749
lines changed

Some content is hidden

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

54 files changed

+1610
-749
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,34 +1635,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16351635
})
16361636
}
16371637

1638-
/// Reports StorageDeadOrDrop of `place` conflicts with `borrow`.
1639-
///
1640-
/// Depending on the origin of the StorageDeadOrDrop, this may be
1641-
/// reported as either a drop or an illegal mutation of a borrowed value.
1642-
/// The latter is preferred when the this is a drop triggered by a
1643-
/// reassignment, as it's more user friendly to report a problem with the
1644-
/// explicit assignment than the implicit drop.
1645-
#[instrument(level = "debug", skip(self))]
1646-
pub(crate) fn report_storage_dead_or_drop_of_borrowed(
1647-
&mut self,
1648-
location: Location,
1649-
place_span: (Place<'tcx>, Span),
1650-
borrow: &BorrowData<'tcx>,
1651-
) {
1652-
// It's sufficient to check the last desugaring as Replace is the last
1653-
// one to be applied.
1654-
if let Some(DesugaringKind::Replace) = place_span.1.desugaring_kind() {
1655-
self.report_illegal_mutation_of_borrowed(location, place_span, borrow)
1656-
} else {
1657-
self.report_borrowed_value_does_not_live_long_enough(
1658-
location,
1659-
borrow,
1660-
place_span,
1661-
Some(WriteKind::StorageDeadOrDrop),
1662-
)
1663-
}
1664-
}
1665-
16661638
/// This means that some data referenced by `borrow` needs to live
16671639
/// past the point where the StorageDeadOrDrop of `place` occurs.
16681640
/// This is usually interpreted as meaning that `place` has too

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,13 +641,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
641641
let Some(hir::Node::Item(item)) = node else { return; };
642642
let hir::ItemKind::Fn(.., body_id) = item.kind else { return; };
643643
let body = self.infcx.tcx.hir().body(body_id);
644-
let mut assign_span = span;
645-
// Drop desugaring is done at MIR build so it's not in the HIR
646-
if let Some(DesugaringKind::Replace) = span.desugaring_kind() {
647-
assign_span.remove_mark();
648-
}
649644

650-
let mut v = V { assign_span, err, ty, suggested: false };
645+
let mut v = V { assign_span: span, err, ty, suggested: false };
651646
v.visit_body(body);
652647
if !v.suggested {
653648
err.help(format!(

compiler/rustc_borrowck/src/invalidation.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
112112
TerminatorKind::SwitchInt { discr, targets: _ } => {
113113
self.consume_operand(location, discr);
114114
}
115-
TerminatorKind::Drop { place: drop_place, target: _, unwind: _ } => {
115+
TerminatorKind::Drop { place: drop_place, target: _, unwind: _, replace } => {
116+
let write_kind =
117+
if *replace { WriteKind::Replace } else { WriteKind::StorageDeadOrDrop };
116118
self.access_place(
117119
location,
118120
*drop_place,
119-
(AccessDepth::Drop, Write(WriteKind::StorageDeadOrDrop)),
121+
(AccessDepth::Drop, Write(write_kind)),
120122
LocalMutationIsAllowed::Yes,
121123
);
122124
}

compiler/rustc_borrowck/src/lib.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,17 +685,19 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
685685
TerminatorKind::SwitchInt { discr, targets: _ } => {
686686
self.consume_operand(loc, (discr, span), flow_state);
687687
}
688-
TerminatorKind::Drop { place, target: _, unwind: _ } => {
688+
TerminatorKind::Drop { place, target: _, unwind: _, replace } => {
689689
debug!(
690690
"visit_terminator_drop \
691691
loc: {:?} term: {:?} place: {:?} span: {:?}",
692692
loc, term, place, span
693693
);
694694

695+
let write_kind =
696+
if *replace { WriteKind::Replace } else { WriteKind::StorageDeadOrDrop };
695697
self.access_place(
696698
loc,
697699
(*place, span),
698-
(AccessDepth::Drop, Write(WriteKind::StorageDeadOrDrop)),
700+
(AccessDepth::Drop, Write(write_kind)),
699701
LocalMutationIsAllowed::Yes,
700702
flow_state,
701703
);
@@ -885,6 +887,7 @@ enum ReadKind {
885887
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
886888
enum WriteKind {
887889
StorageDeadOrDrop,
890+
Replace,
888891
MutableBorrow(BorrowKind),
889892
Mutate,
890893
Move,
@@ -1132,13 +1135,21 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11321135
this.buffer_error(err);
11331136
}
11341137
WriteKind::StorageDeadOrDrop => this
1135-
.report_storage_dead_or_drop_of_borrowed(location, place_span, borrow),
1138+
.report_borrowed_value_does_not_live_long_enough(
1139+
location,
1140+
borrow,
1141+
place_span,
1142+
Some(WriteKind::StorageDeadOrDrop),
1143+
),
11361144
WriteKind::Mutate => {
11371145
this.report_illegal_mutation_of_borrowed(location, place_span, borrow)
11381146
}
11391147
WriteKind::Move => {
11401148
this.report_move_out_while_borrowed(location, place_span, borrow)
11411149
}
1150+
WriteKind::Replace => {
1151+
this.report_illegal_mutation_of_borrowed(location, place_span, borrow)
1152+
}
11421153
}
11431154
Control::Break
11441155
}
@@ -1982,12 +1993,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
19821993

19831994
Reservation(
19841995
WriteKind::Move
1996+
| WriteKind::Replace
19851997
| WriteKind::StorageDeadOrDrop
19861998
| WriteKind::MutableBorrow(BorrowKind::Shared)
19871999
| WriteKind::MutableBorrow(BorrowKind::Shallow),
19882000
)
19892001
| Write(
19902002
WriteKind::Move
2003+
| WriteKind::Replace
19912004
| WriteKind::StorageDeadOrDrop
19922005
| WriteKind::MutableBorrow(BorrowKind::Shared)
19932006
| WriteKind::MutableBorrow(BorrowKind::Shallow),

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use rustc_index::bit_set::HybridBitSet;
33
use rustc_index::interval::IntervalSet;
44
use rustc_infer::infer::canonical::QueryRegionConstraints;
55
use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location};
6+
use rustc_middle::traits::query::DropckOutlivesResult;
67
use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt};
78
use rustc_span::DUMMY_SP;
8-
use rustc_trait_selection::traits::query::dropck_outlives::DropckOutlivesResult;
99
use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
1010
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
1111
use std::rc::Rc;

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
473473
| TerminatorKind::GeneratorDrop => {
474474
bug!("shouldn't exist at codegen {:?}", bb_data.terminator());
475475
}
476-
TerminatorKind::Drop { place, target, unwind: _ } => {
476+
TerminatorKind::Drop { place, target, unwind: _, replace: _ } => {
477477
let drop_place = codegen_place(fx, *place);
478478
crate::abi::codegen_drop(fx, source_info, drop_place);
479479

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12561256
MergingSucc::False
12571257
}
12581258

1259-
mir::TerminatorKind::Drop { place, target, unwind } => {
1259+
mir::TerminatorKind::Drop { place, target, unwind, replace: _ } => {
12601260
self.codegen_drop_terminator(helper, bx, place, target, unwind, mergeable_succ())
12611261
}
12621262

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
114114
}
115115
}
116116

117-
Drop { place, target, unwind } => {
117+
Drop { place, target, unwind, replace: _ } => {
118118
let frame = self.frame();
119119
let ty = place.ty(&frame.body.local_decls, *self.tcx).ty;
120120
let ty = self.subst_from_frame_and_normalize_erasing_regions(frame, ty)?;

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,11 @@ pub enum TerminatorKind<'tcx> {
603603
/// > The drop glue is executed if, among all statements executed within this `Body`, an assignment to
604604
/// > the place or one of its "parents" occurred more recently than a move out of it. This does not
605605
/// > consider indirect assignments.
606-
Drop { place: Place<'tcx>, target: BasicBlock, unwind: UnwindAction },
606+
///
607+
/// The `replace` flag indicates whether this terminator was created as part of an assignment.
608+
/// This should only be used for diagnostic purposes, and does not have any operational
609+
/// meaning.
610+
Drop { place: Place<'tcx>, target: BasicBlock, unwind: UnwindAction, replace: bool },
607611

608612
/// Roughly speaking, evaluates the `func` operand and the arguments, and starts execution of
609613
/// the referred to function. The operand types must match the argument types of the function.

compiler/rustc_middle/src/mir/visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ macro_rules! make_mir_visitor {
504504
place,
505505
target: _,
506506
unwind: _,
507+
replace: _,
507508
} => {
508509
self.visit_place(
509510
place,

0 commit comments

Comments
 (0)