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
#14902 Write a MIR lint for rooting analysis #20264
Changes from 1 commit
89177a7
ea0c1d4
011217b
4169308
41f4774
d5eafe0
2f4af72
53ed102
c6d04fa
88a1814
c1e333b
2f767d2
2416333
3c14830
fc4c611
File filter...
Jump to…
Added more exceptions to the plugin; servo should compile
- Loading branch information
| @@ -13,12 +13,13 @@ use std::sync::mpsc::{Receiver, Sender}; | ||
| /// common event loop messages. While this SendableWorkerScriptChan is alive, the associated | ||
| /// Worker object will remain alive. | ||
| #[derive(Clone, JSTraceable)] | ||
| pub struct SendableWorkerScriptChan<T: DomObject> { | ||
| #[must_root] | ||
| pub struct SendableWorkerScriptChan<#[must_root] T: DomObject> { | ||
mrowqa
Author
|
||
| pub sender: Sender<(Trusted<T>, CommonScriptMsg)>, | ||
| pub worker: Trusted<T>, | ||
| } | ||
|
|
||
| impl<T: JSTraceable + DomObject + 'static> ScriptChan for SendableWorkerScriptChan<T> { | ||
| impl<#[must_root] T: JSTraceable + DomObject + 'static> ScriptChan for SendableWorkerScriptChan<T> { | ||
| fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { | ||
| self.sender.send((self.worker.clone(), msg)).map_err(|_| ()) | ||
| } | ||
| @@ -35,12 +36,13 @@ impl<T: JSTraceable + DomObject + 'static> ScriptChan for SendableWorkerScriptCh | ||
| /// worker event loop messages. While this SendableWorkerScriptChan is alive, the associated | ||
| /// Worker object will remain alive. | ||
| #[derive(Clone, JSTraceable)] | ||
| pub struct WorkerThreadWorkerChan<T: DomObject> { | ||
| #[must_root] | ||
| pub struct WorkerThreadWorkerChan<#[must_root] T: DomObject> { | ||
| pub sender: Sender<(Trusted<T>, WorkerScriptMsg)>, | ||
| pub worker: Trusted<T>, | ||
| } | ||
|
|
||
| impl<T: JSTraceable + DomObject + 'static> ScriptChan for WorkerThreadWorkerChan<T> { | ||
| impl<#[must_root] T: JSTraceable + DomObject + 'static> ScriptChan for WorkerThreadWorkerChan<T> { | ||
| fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { | ||
| self.sender | ||
| .send((self.worker.clone(), WorkerScriptMsg::Common(msg))) | ||
| @@ -55,7 +57,7 @@ impl<T: JSTraceable + DomObject + 'static> ScriptChan for WorkerThreadWorkerChan | ||
| } | ||
| } | ||
|
|
||
| impl<T: DomObject> ScriptPort for Receiver<(Trusted<T>, WorkerScriptMsg)> { | ||
| impl<#[must_root] T: DomObject> ScriptPort for Receiver<(Trusted<T>, WorkerScriptMsg)> { | ||
| fn recv(&self) -> Result<CommonScriptMsg, ()> { | ||
| match self.recv().map(|(_, msg)| msg) { | ||
| Ok(WorkerScriptMsg::Common(script_msg)) => Ok(script_msg), | ||
| @@ -12,9 +12,9 @@ use style::thread_state::{self, ThreadState}; | ||
| /// This extends the API of `std::cell::RefCell` to allow unsafe access in | ||
| /// certain situations, with dynamic checking in debug builds. | ||
| #[derive(Clone, Debug, Default, MallocSizeOf, PartialEq)] | ||
| #[must_root] | ||
| //#[must_root] // TODO should it be #[must_root]? then -> there are usages with #[must_root] types and with normal ones; two different structs for them? or hacking plugin compiler further to mark structure as #[must_root] if it generic type is #[must_root]? | ||
jdm
Member
|
||
| pub struct DomRefCell<#[must_root] T> { | ||
| value: RefCell<T>, | ||
| value: RefCell<T>, // TODO currently a little bit hacky since RefCell is currently on the exception list | ||
| } | ||
|
|
||
| // Functionality specific to Servo's `DomRefCell` type | ||
| @@ -50,6 +50,7 @@ impl<#[must_root] T> DomRefCell<T> { | ||
| // =================================================== | ||
| impl<#[must_root] T> DomRefCell<T> { | ||
| /// Create a new `DomRefCell` containing `value`. | ||
| #[allow(unrooted_must_root)] // TODO don't know if it is okay; T is unrooted argument | ||
| pub fn new(value: T) -> DomRefCell<T> { | ||
| DomRefCell { | ||
| value: RefCell::new(value), | ||
I'm confused by these changes -
Trusted<T>is a type that does not require rooting (due to the allow_unrooted_interior attribute), so it's not clear why T needs to be marked must_root here.