Lint on invalid usage of UnsafeCell::raw_get in reference casting#115166
Conversation
There was a problem hiding this comment.
@RalfJung can you confirm (or deny) that we can lint on those expressions ?
There was a problem hiding this comment.
Those expressions are definitely bogus.
Can you confirm that the lint will not fire if the type of x is changed to &Cell<i32>?
There was a problem hiding this comment.
Yes I can.
I already added some tests below to make sure we don't lint on them, but added a test with &Cell<i32> anyway (just to be on the safe side).
fc348de to
89800a2
Compare
|
@bors r+ |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (4e5b31c): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 628.074s -> 628.991s (0.15%) |
This PR proposes to take into account
UnsafeCell::raw_getmethod call for non-Freeze types for theinvalid_reference_castinglint.The goal of this is to catch those kind of invalid reference casting:
r? @est31