-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fixes and cleanups #58000
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 and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes and cleanups #58000
Changes from 8 commits
7cfb05f
bc528d9
154c54c
4165c89
ab708f5
7017927
4e0af1f
5aa713e
a7a5cb6
765fa81
8c26c59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
use std::hash::{Hash, Hasher}; | ||
|
||
use rustc::ich::StableHashingContextProvider; | ||
use rustc::ich::{StableHashingContextProvider, StableHashingContext}; | ||
use rustc::mir; | ||
use rustc::mir::interpret::{ | ||
AllocId, Pointer, Scalar, | ||
|
@@ -19,12 +19,12 @@ use rustc::ty::{self, TyCtxt}; | |
use rustc::ty::layout::Align; | ||
use rustc_data_structures::fx::FxHashSet; | ||
use rustc_data_structures::indexed_vec::IndexVec; | ||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; | ||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; | ||
use syntax::ast::Mutability; | ||
use syntax::source_map::Span; | ||
|
||
use super::eval_context::{LocalValue, StackPopCleanup}; | ||
use super::{Frame, Memory, Operand, MemPlace, Place, Immediate, ScalarMaybeUndef}; | ||
use super::{Frame, Memory, Operand, MemPlace, Place, Immediate, ScalarMaybeUndef, LocalState}; | ||
use const_eval::CompileTimeInterpreter; | ||
|
||
#[derive(Default)] | ||
|
@@ -250,11 +250,11 @@ impl_snapshot_for!(enum Operand { | |
Indirect(m), | ||
}); | ||
|
||
impl_stable_hash_for!(enum ::interpret::LocalValue { | ||
impl_stable_hash_for!(enum ::interpret::LocalState { | ||
Dead, | ||
Live(x), | ||
}); | ||
impl_snapshot_for!(enum LocalValue { | ||
impl_snapshot_for!(enum LocalState { | ||
Live(v), | ||
Dead, | ||
}); | ||
|
@@ -309,7 +309,7 @@ struct FrameSnapshot<'a, 'tcx: 'a> { | |
span: &'a Span, | ||
return_to_block: &'a StackPopCleanup, | ||
return_place: Option<Place<(), AllocIdSnapshot<'a>>>, | ||
locals: IndexVec<mir::Local, LocalValue<(), AllocIdSnapshot<'a>>>, | ||
locals: IndexVec<mir::Local, LocalState<(), AllocIdSnapshot<'a>>>, | ||
block: &'a mir::BasicBlock, | ||
stmt: usize, | ||
} | ||
|
@@ -321,7 +321,6 @@ impl_stable_hash_for!(impl<'mir, 'tcx: 'mir> for struct Frame<'mir, 'tcx> { | |
return_to_block, | ||
return_place -> (return_place.as_ref().map(|r| &**r)), | ||
locals, | ||
local_layouts -> _, | ||
block, | ||
stmt, | ||
extra, | ||
|
@@ -340,7 +339,6 @@ impl<'a, 'mir, 'tcx, Ctx> Snapshot<'a, Ctx> for &'a Frame<'mir, 'tcx> | |
return_to_block, | ||
return_place, | ||
locals, | ||
local_layouts: _, | ||
block, | ||
stmt, | ||
extra: _, | ||
|
@@ -358,6 +356,27 @@ impl<'a, 'mir, 'tcx, Ctx> Snapshot<'a, Ctx> for &'a Frame<'mir, 'tcx> | |
} | ||
} | ||
|
||
impl<'a, 'tcx, Ctx> Snapshot<'a, Ctx> for &'a LocalValue<'tcx> | ||
where Ctx: SnapshotContext<'a>, | ||
{ | ||
type Item = LocalState<(), AllocIdSnapshot<'a>>; | ||
|
||
fn snapshot(&self, ctx: &'a Ctx) -> Self::Item { | ||
self.state.snapshot(ctx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We otherwise follow the pattern to use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, it's a very simple macro with no support for lifetimes or so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done and opened rust-lang/rust-clippy#3724 to make sure we take care of this issue once and for all at some point |
||
} | ||
} | ||
|
||
|
||
impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for LocalValue<'gcx> { | ||
fn hash_stable<W: StableHasherResult>( | ||
&self, | ||
hcx: &mut StableHashingContext<'a>, | ||
hasher: &mut StableHasher<W>, | ||
) { | ||
self.state.hash_stable(hcx, hasher); | ||
} | ||
} | ||
oli-obk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
impl<'a, 'b, 'mir, 'tcx: 'a+'mir> SnapshotContext<'b> | ||
for Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>> | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think swapping the names
LocalValue
andLocalState
is nicer. Thelayout
stuff looks much more state-y than value-y to me.