Add documentation to has_deref#114505
Conversation
compiler/rustc_middle/src/mir/mod.rs
Outdated
There was a problem hiding this comment.
Both of which conditions? And it only does that check in debug-mode, so really this is not checked most of the time! The caller can not rely on this check.
There was a problem hiding this comment.
Also there is no phase called "Derefered"? At least look at https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/syntax/enum.MirPhase.html I cannot find one. The AnalysisPhase::PostCleanup says that * must be the first projection, so maybe this should say "when in a Runtime MirPhase"?
There was a problem hiding this comment.
My bad, it should been MirPass not MirPhase, https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_mir_transform/lib.rs.html#454-463
There was a problem hiding this comment.
Passes get reordered though. MirPhase is the right concept to refer to here. MirPhase make certain guarantees. For example, the PostCleanup one makes the guarantee we care about here. So that's what it should reference.
|
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
compiler/rustc_middle/src/mir/mod.rs
Outdated
There was a problem hiding this comment.
MirPass doesn't implement PartialOrd so this doesn't make a lot of sense.
MirPhase does implement PartialOrd, on the other hand.
compiler/rustc_middle/src/mir/mod.rs
Outdated
There was a problem hiding this comment.
| // To make sure this is not accidentally used in wrong mir phase |
this comment referred to the debug assertion that is no longer here
compiler/rustc_middle/src/mir/mod.rs
Outdated
There was a problem hiding this comment.
The comment is wrong or confusing. It says that the function checks that "if there is a deref it is in the first place", but that's not what the function checks.
There was a problem hiding this comment.
Simplified the wording I think it's clearer now.
compiler/rustc_middle/src/mir/mod.rs
Outdated
There was a problem hiding this comment.
| /// Returns 'true' if this 'Place's first projection equals to 'Deref' projection else | |
| /// returns false. | |
| /// | |
| /// Must only be called, after `MirPass::Derefer`. | |
| /// Returns 'true' if this `Place`'s first projection is `Deref`. | |
| /// | |
| /// This is useful because for MIR phases `AnalysisPhase::PostCleanup` and later, | |
| /// `Deref` projections can only occur as the first projection. In that case this method | |
| /// is equivalent to `is_indirect`, but faster. |
There was a problem hiding this comment.
Well that's certainly way better than mine, thanks for the review
RalfJung
left a comment
There was a problem hiding this comment.
Missed that in my previous suggestions.
With that fix, r=me. Thanks for taking care of this!
compiler/rustc_middle/src/mir/mod.rs
Outdated
There was a problem hiding this comment.
| /// Returns 'true' if this `Place`'s first projection is `Deref`. | |
| /// Returns `true` if this `Place`'s first projection is `Deref`. |
compiler/rustc_middle/src/mir/mod.rs
Outdated
There was a problem hiding this comment.
| /// Returns 'true' if this `Place`'s first projection is `Deref`. | |
| /// Returns `true` if this `Place`'s first projection is `Deref`. |
|
@bors r=RalfJung edit: that doesn't seem like worked ? 🤔 |
|
@ouz-a: 🔑 Insufficient privileges: Not in reviewers |
|
@bors r+ rollup |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#114466 (Add Allocation to SMIR) - rust-lang#114505 (Add documentation to has_deref) - rust-lang#114519 (use offset_of! to calculate dirent64 field offsets) - rust-lang#114537 (Migrate GUI colors test to original CSS color format) - rust-lang#114539 (linkchecker: Remove unneeded FIXME about intra-doc links) Failed merges: - rust-lang#114485 (Add trait decls to SMIR) r? `@ghost` `@rustbot` modify labels: rollup
Add documentation to has_deref Documentation of `has_deref` needed some polish to be more clear about where it should be used and what's it's purpose. cc rust-lang#114401 r? `@RalfJung`
Documentation of
has_derefneeded some polish to be more clear about where it should be used and what's it's purpose.cc #114401
r? @RalfJung