clippy: Add safety documentation and clean up unsafe methods#33748
clippy: Add safety documentation and clean up unsafe methods#33748mrobinson merged 1 commit intoservo:mainfrom
Conversation
| /// | ||
| /// # Safety | ||
| /// | ||
| /// The address pointed to by `address` should point to a valid node in memory. |
There was a problem hiding this comment.
This seems redundant given that the documenation for TrustedNodeAddress claims that it represents a valid Node address. Perhaps this is still needed since the field in TrustedNodeAddress is public, but I wonder if that should be made private?
Also, are there no other conditions that need to be highlighted in this safety section? As an example (I'm not really familiar with this code), is there anything to be said about whether or not the DOM node is already rooted?
There was a problem hiding this comment.
Unfortunately, I don't think we can make those kind of guarantees as TrustedNodeAddress is sent over IPC channels. This is all very bad, of course, and we should remove TrustedNodeAddress entirely, but that's a much larger task.
28709d3 to
f6877b9
Compare
This change: 1. Adds safety documentation where it was missing. 2. Limits the scope of unsafe code in some cases to where it is actually unsafe. 3. Converts some free functions to associated functions and methods, thereby making them more likely to be called safely. Signed-off-by: Martin Robinson <[email protected]>
f6877b9 to
7fc0ce1
Compare
This change:
unsafe.
thereby making them more likely to be called safely.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errors