Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c62b732

Browse files
committedJan 19, 2025·
Auto merge of rust-lang#135709 - lqd:bring-back-len, r=compiler-errors
Temporarily bring back `Rvalue::Len` r? `@compiler-errors` as requested in rust-lang#135671 (comment) > However, in the mean time, I'd rather we not crunch trying to find and more importantly validate the soundness of a solution 🤔 Agreed. To fix the IMO P-critical rust-lang#135671 for which we somehow didn't have test coverage, this PR temporarily reverts: - rust-lang#133734 - its bugfix rust-lang#134371 - rust-lang#134330 cc `@scottmcm` I added the few samples from that issue as a test, but we can add more in the future, in particular it seems `@steffahn` [will work on that](rust-lang#135671 (comment)). Fixes rust-lang#135671. And if we want to land this, it should also be nominated for beta backport.
2 parents 9857284 + c69dea9 commit c62b732

File tree

136 files changed

+1964
-1542
lines changed

Some content is hidden

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

136 files changed

+1964
-1542
lines changed
 

‎compiler/rustc_borrowck/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ use self::ReadOrWrite::{Activation, Read, Reservation, Write};
829829

830830
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
831831
enum ArtificialField {
832+
ArrayLength,
832833
FakeBorrow,
833834
}
834835

@@ -1338,11 +1339,16 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
13381339
);
13391340
}
13401341

1341-
&Rvalue::Discriminant(place) => {
1342+
&(Rvalue::Len(place) | Rvalue::Discriminant(place)) => {
1343+
let af = match *rvalue {
1344+
Rvalue::Len(..) => Some(ArtificialField::ArrayLength),
1345+
Rvalue::Discriminant(..) => None,
1346+
_ => unreachable!(),
1347+
};
13421348
self.access_place(
13431349
location,
13441350
(place, span),
1345-
(Shallow(None), Read(ReadKind::Copy)),
1351+
(Shallow(af), Read(ReadKind::Copy)),
13461352
LocalMutationIsAllowed::No,
13471353
state,
13481354
);

‎compiler/rustc_borrowck/src/places_conflict.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ fn place_components_conflict<'tcx>(
203203
let base_ty = base.ty(body, tcx).ty;
204204

205205
match (elem, base_ty.kind(), access) {
206-
(_, _, Shallow(Some(ArtificialField::FakeBorrow))) => {
206+
(_, _, Shallow(Some(ArtificialField::ArrayLength)))
207+
| (_, _, Shallow(Some(ArtificialField::FakeBorrow))) => {
207208
// The array length is like additional fields on the
208209
// type; it does not overlap any existing data there.
209210
// Furthermore, if cannot actually be a prefix of any

0 commit comments

Comments
 (0)
This repository has been archived.