Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upValiation: Identify write locks using an abstract lvalue #336
Conversation
oli-obk
approved these changes
Sep 13, 2017
| } | ||
|
|
||
| fn test(r: &mut RefCell<i32>) { | ||
| let x = &*r; // releasing write lock, first suspension recorded |
This comment has been minimized.
This comment has been minimized.
oli-obk
Sep 13, 2017
Collaborator
If you want you can try using ui tests together with MIRI_LOG=rust_miri::interpret::validate=trace to be able to ensure that the trace does exactly what you want.
But I guess it would fail with an interpretation error if anything went wrong...
This comment has been minimized.
This comment has been minimized.
RalfJung
Sep 13, 2017
Author
Member
The test fails prior to the PR, so I think compile-fail is enough here.
| @@ -1466,7 +1466,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { | |||
|
|
|||
| /// ensures this Value is not a ByRef | |||
| pub(super) fn follow_by_ref_value( | |||
| &mut self, | |||
| &self, | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
RalfJung
Sep 13, 2017
Author
Member
Is there any way to get lints for "You used &mut but could have used &"?^^
This comment has been minimized.
This comment has been minimized.
oli-obk
Sep 13, 2017
Collaborator
No. But I've been trying to write a lint for that since forever: rust-lang/rust-clippy#353
This comment has been minimized.
This comment has been minimized.
eddyb
Sep 13, 2017
Member
It should be easier on MIR because you can look for uses that aren't immutable reborrows.
RalfJung
added some commits
Sep 13, 2017
RalfJung
force-pushed the
RalfJung:mir-validate
branch
from
ba66359
to
59a329d
Sep 13, 2017
This comment has been minimized.
This comment has been minimized.
|
I am somewhat confused by these ...except, it turns out, miri disagrees with rustc here. The following passes on miri, and fails on rustc: #[derive(Debug)]
struct A;
fn main() {
// can't use assert_eq, b/c that will try to print the pointer addresses with full MIR enabled
assert!(&A as *const A as *const () != &() as *const _);
assert!(&A as *const A != &A as *const A);
}Is this a bug? Why would we deliberately test for disagreeing with rustc? |
This comment has been minimized.
This comment has been minimized.
We don't deduplicate constants in all cases: #131 |
This comment has been minimized.
This comment has been minimized.
|
All right, I will then disable the test if it is buggy. |
RalfJung commentedSep 13, 2017
Fixes #296