clarify semantics of ConstantIndex MIR projection by RalfJung · Pull Request #131285 · rust-lang/rust (original) (raw)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation6 Commits1 Checks6 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

RalfJung

This documents what Miri does:

if n < min_length {
// This can only be reached in ConstProp and non-rustc-MIR.
throw_ub!(BoundsCheckFailed { len: min_length, index: n });
}

I am not sure what exactly the purpose of this min_length field is, TBH... but this seems like the most obvious meaning it could have?

@RalfJung

@rustbot

r? @cjgillot

rustbot has assigned @cjgillot.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Oct 5, 2024

@cjgillot

It's only meaningful use is in borrowck, where it's used to check conflict between two ConstantIndex projections.

@bors r+ rollup

@bors

📌 Commit f0ddc7b has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Oct 5, 2024

@RalfJung

What exactly needs to be true about the semantics of this for whatever borrowck is doing to be sound?

If we can declare this field as being entirely irrelevant for the semantics, that'd surely make things a bit simpler, but then borrowck couldn't "trust" its value.

@cjgillot

When checking conflict between [+offset1 of min_length1] and [-offset2 of min_length2], borrowck can conclude they are disjoint if offset1 + offset2 < max(min_length1, min_length2). If that inequality is not verified, the places may point to the same memory.

bors added a commit to rust-lang-ci/rust that referenced this pull request

Oct 5, 2024

@bors

…iaskrgr

Rollup of 5 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Oct 5, 2024

@rust-timer

Labels

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.