Skip to content

Commit fbf0758

Browse files
committed
Auto merge of #117764 - cuviper:beta-next, r=cuviper
[beta] backports - dropck_outlives check whether generator witness needs_drop #117134 - Make sure that predicates with unmentioned bound vars are still considered global in the old solver #117589 - Check binders with bound vars for global bounds that don't hold #117637 - generator layout: ignore fake borrows #117712 r? ghost
2 parents efc300e + 015d4b6 commit fbf0758

File tree

57 files changed

+307
-183
lines changed

Some content is hidden

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

57 files changed

+307
-183
lines changed

compiler/rustc_borrowck/src/borrow_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> {
7171
fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
7272
let kind = match self.kind {
7373
mir::BorrowKind::Shared => "",
74-
mir::BorrowKind::Shallow => "shallow ",
74+
mir::BorrowKind::Fake => "fake ",
7575
mir::BorrowKind::Mut { kind: mir::MutBorrowKind::ClosureCapture } => "uniq ",
7676
// FIXME: differentiate `TwoPhaseBorrow`
7777
mir::BorrowKind::Mut {

compiler/rustc_borrowck/src/def_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn categorize(context: PlaceContext) -> Option<DefUse> {
4949
// cross suspension points so this behavior is unproblematic.
5050
PlaceContext::MutatingUse(MutatingUseContext::Borrow) |
5151
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
52-
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
52+
PlaceContext::NonMutatingUse(NonMutatingUseContext::FakeBorrow) |
5353

5454
// `PlaceMention` and `AscribeUserType` both evaluate the place, which must not
5555
// contain dangling references.

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10251025
self.cannot_uniquely_borrow_by_two_closures(span, &desc_place, issued_span, None)
10261026
}
10271027

1028-
(BorrowKind::Mut { .. }, BorrowKind::Shallow) => {
1028+
(BorrowKind::Mut { .. }, BorrowKind::Fake) => {
10291029
if let Some(immutable_section_description) =
10301030
self.classify_immutable_section(issued_borrow.assigned_place)
10311031
{
@@ -1117,11 +1117,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11171117
)
11181118
}
11191119

1120-
(BorrowKind::Shared, BorrowKind::Shared | BorrowKind::Shallow)
1121-
| (
1122-
BorrowKind::Shallow,
1123-
BorrowKind::Mut { .. } | BorrowKind::Shared | BorrowKind::Shallow,
1124-
) => unreachable!(),
1120+
(BorrowKind::Shared, BorrowKind::Shared | BorrowKind::Fake)
1121+
| (BorrowKind::Fake, BorrowKind::Mut { .. } | BorrowKind::Shared | BorrowKind::Fake) => {
1122+
unreachable!()
1123+
}
11251124
};
11261125

11271126
if issued_spans == borrow_spans {
@@ -2644,7 +2643,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
26442643
let loan_span = loan_spans.args_or_use();
26452644

26462645
let descr_place = self.describe_any_place(place.as_ref());
2647-
if loan.kind == BorrowKind::Shallow {
2646+
if loan.kind == BorrowKind::Fake {
26482647
if let Some(section) = self.classify_immutable_section(loan.assigned_place) {
26492648
let mut err = self.cannot_mutate_in_immutable_section(
26502649
span,

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ impl UseSpans<'_> {
628628
err.subdiagnostic(match kind {
629629
Some(kd) => match kd {
630630
rustc_middle::mir::BorrowKind::Shared
631-
| rustc_middle::mir::BorrowKind::Shallow => {
631+
| rustc_middle::mir::BorrowKind::Fake => {
632632
CaptureVarKind::Immut { kind_span: capture_kind_span }
633633
}
634634

compiler/rustc_borrowck/src/invalidation.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
253253
match rvalue {
254254
&Rvalue::Ref(_ /*rgn*/, bk, place) => {
255255
let access_kind = match bk {
256-
BorrowKind::Shallow => {
257-
(Shallow(Some(ArtificialField::ShallowBorrow)), Read(ReadKind::Borrow(bk)))
256+
BorrowKind::Fake => {
257+
(Shallow(Some(ArtificialField::FakeBorrow)), Read(ReadKind::Borrow(bk)))
258258
}
259259
BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))),
260260
BorrowKind::Mut { .. } => {
@@ -376,8 +376,8 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
376376
// have already taken the reservation
377377
}
378378

379-
(Read(_), BorrowKind::Shallow | BorrowKind::Shared)
380-
| (Read(ReadKind::Borrow(BorrowKind::Shallow)), BorrowKind::Mut { .. }) => {
379+
(Read(_), BorrowKind::Fake | BorrowKind::Shared)
380+
| (Read(ReadKind::Borrow(BorrowKind::Fake)), BorrowKind::Mut { .. }) => {
381381
// Reads don't invalidate shared or shallow borrows
382382
}
383383

@@ -422,7 +422,7 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
422422

423423
// only mutable borrows should be 2-phase
424424
assert!(match borrow.kind {
425-
BorrowKind::Shared | BorrowKind::Shallow => false,
425+
BorrowKind::Shared | BorrowKind::Fake => false,
426426
BorrowKind::Mut { .. } => true,
427427
});
428428

compiler/rustc_borrowck/src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ use self::ReadOrWrite::{Activation, Read, Reservation, Write};
837837
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
838838
enum ArtificialField {
839839
ArrayLength,
840-
ShallowBorrow,
840+
FakeBorrow,
841841
}
842842

843843
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
@@ -1076,18 +1076,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10761076
Control::Continue
10771077
}
10781078

1079-
(Read(_), BorrowKind::Shared | BorrowKind::Shallow)
1080-
| (Read(ReadKind::Borrow(BorrowKind::Shallow)), BorrowKind::Mut { .. }) => {
1079+
(Read(_), BorrowKind::Shared | BorrowKind::Fake)
1080+
| (Read(ReadKind::Borrow(BorrowKind::Fake)), BorrowKind::Mut { .. }) => {
10811081
Control::Continue
10821082
}
10831083

1084-
(Reservation(_), BorrowKind::Shallow | BorrowKind::Shared) => {
1084+
(Reservation(_), BorrowKind::Fake | BorrowKind::Shared) => {
10851085
// This used to be a future compatibility warning (to be
10861086
// disallowed on NLL). See rust-lang/rust#56254
10871087
Control::Continue
10881088
}
10891089

1090-
(Write(WriteKind::Move), BorrowKind::Shallow) => {
1090+
(Write(WriteKind::Move), BorrowKind::Fake) => {
10911091
// Handled by initialization checks.
10921092
Control::Continue
10931093
}
@@ -1195,8 +1195,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11951195
match rvalue {
11961196
&Rvalue::Ref(_ /*rgn*/, bk, place) => {
11971197
let access_kind = match bk {
1198-
BorrowKind::Shallow => {
1199-
(Shallow(Some(ArtificialField::ShallowBorrow)), Read(ReadKind::Borrow(bk)))
1198+
BorrowKind::Fake => {
1199+
(Shallow(Some(ArtificialField::FakeBorrow)), Read(ReadKind::Borrow(bk)))
12001200
}
12011201
BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))),
12021202
BorrowKind::Mut { .. } => {
@@ -1217,7 +1217,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12171217
flow_state,
12181218
);
12191219

1220-
let action = if bk == BorrowKind::Shallow {
1220+
let action = if bk == BorrowKind::Fake {
12211221
InitializationRequiringAction::MatchOn
12221222
} else {
12231223
InitializationRequiringAction::Borrow
@@ -1569,7 +1569,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15691569

15701570
// only mutable borrows should be 2-phase
15711571
assert!(match borrow.kind {
1572-
BorrowKind::Shared | BorrowKind::Shallow => false,
1572+
BorrowKind::Shared | BorrowKind::Fake => false,
15731573
BorrowKind::Mut { .. } => true,
15741574
});
15751575

@@ -2002,14 +2002,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
20022002
| WriteKind::Replace
20032003
| WriteKind::StorageDeadOrDrop
20042004
| WriteKind::MutableBorrow(BorrowKind::Shared)
2005-
| WriteKind::MutableBorrow(BorrowKind::Shallow),
2005+
| WriteKind::MutableBorrow(BorrowKind::Fake),
20062006
)
20072007
| Write(
20082008
WriteKind::Move
20092009
| WriteKind::Replace
20102010
| WriteKind::StorageDeadOrDrop
20112011
| WriteKind::MutableBorrow(BorrowKind::Shared)
2012-
| WriteKind::MutableBorrow(BorrowKind::Shallow),
2012+
| WriteKind::MutableBorrow(BorrowKind::Fake),
20132013
) => {
20142014
if self.is_mutable(place.as_ref(), is_local_mutation_allowed).is_err()
20152015
&& !self.has_buffered_errors()
@@ -2033,7 +2033,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
20332033
return false;
20342034
}
20352035
Read(
2036-
ReadKind::Borrow(BorrowKind::Mut { .. } | BorrowKind::Shared | BorrowKind::Shallow)
2036+
ReadKind::Borrow(BorrowKind::Mut { .. } | BorrowKind::Shared | BorrowKind::Fake)
20372037
| ReadKind::Copy,
20382038
) => {
20392039
// Access authorized

compiler/rustc_borrowck/src/places_conflict.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn place_components_conflict<'tcx>(
204204

205205
match (elem, &base_ty.kind(), access) {
206206
(_, _, Shallow(Some(ArtificialField::ArrayLength)))
207-
| (_, _, Shallow(Some(ArtificialField::ShallowBorrow))) => {
207+
| (_, _, Shallow(Some(ArtificialField::FakeBorrow))) => {
208208
// The array length is like additional fields on the
209209
// type; it does not overlap any existing data there.
210210
// Furthermore, if cannot actually be a prefix of any
@@ -272,10 +272,10 @@ fn place_components_conflict<'tcx>(
272272
// If the second example, where we did, then we still know
273273
// that the borrow can access a *part* of our place that
274274
// our access cares about, so we still have a conflict.
275-
if borrow_kind == BorrowKind::Shallow
275+
if borrow_kind == BorrowKind::Fake
276276
&& borrow_place.projection.len() < access_place.projection.len()
277277
{
278-
debug!("borrow_conflicts_with_place: shallow borrow");
278+
debug!("borrow_conflicts_with_place: fake borrow");
279279
false
280280
} else {
281281
debug!("borrow_conflicts_with_place: full borrow, CONFLICT");

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
745745
PlaceContext::MutatingUse(_) => ty::Invariant,
746746
PlaceContext::NonUse(StorageDead | StorageLive | VarDebugInfo) => ty::Invariant,
747747
PlaceContext::NonMutatingUse(
748-
Inspect | Copy | Move | PlaceMention | SharedBorrow | ShallowBorrow | AddressOf
748+
Inspect | Copy | Move | PlaceMention | SharedBorrow | FakeBorrow | AddressOf
749749
| Projection,
750750
) => ty::Covariant,
751751
PlaceContext::NonUse(AscribeUserTy(variance)) => variance,

compiler/rustc_codegen_ssa/src/mir/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
234234
| PlaceContext::NonMutatingUse(
235235
NonMutatingUseContext::Inspect
236236
| NonMutatingUseContext::SharedBorrow
237-
| NonMutatingUseContext::ShallowBorrow
237+
| NonMutatingUseContext::FakeBorrow
238238
| NonMutatingUseContext::AddressOf
239239
| NonMutatingUseContext::Projection,
240240
) => {

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
415415
BorrowKind::Shared => {
416416
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow)
417417
}
418-
BorrowKind::Shallow => {
419-
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow)
418+
BorrowKind::Fake => {
419+
PlaceContext::NonMutatingUse(NonMutatingUseContext::FakeBorrow)
420420
}
421421
BorrowKind::Mut { .. } => {
422422
PlaceContext::MutatingUse(MutatingUseContext::Borrow)
@@ -491,7 +491,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
491491
self.check_mut_borrow(place.local, hir::BorrowKind::Raw)
492492
}
493493

494-
Rvalue::Ref(_, BorrowKind::Shared | BorrowKind::Shallow, place)
494+
Rvalue::Ref(_, BorrowKind::Shared | BorrowKind::Fake, place)
495495
| Rvalue::AddressOf(Mutability::Not, place) => {
496496
let borrowed_place_has_mut_interior = qualifs::in_place::<HasMutInterior, _>(
497497
&self.ccx,

0 commit comments

Comments
 (0)