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
Closed
+688
−191
Closed
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
89177a7
#14902 Write a MIR lint for rooting analysis
mrowqa ea0c1d4
Skip checking subexpressions (temporary variables).
mrowqa 011217b
Further progress (theoretically it should be able to detect some impr…
mrowqa 4169308
Moved forward with generics checking & refactored the code
mrowqa 41f4774
Calls to generic functions should be detected
mrowqa d5eafe0
Generic ADT with unrooted substs are detected.
mrowqa 2f4af72
Checking recursively parent generics + some proof work for allowing n…
mrowqa 53ed102
Updated way of detecting "new" methods and added test for closures.
mrowqa c6d04fa
Fixed problem with unrooted interior.
mrowqa 88a1814
Merge branch 'master' into mir-must-root
mrowqa c1e333b
Fixed generating traits by codegen.
mrowqa 2f767d2
Fixed some #[must_root] errors and added debugging code.
mrowqa 2416333
Fixed more violations.
mrowqa 3c14830
Added more exceptions to the plugin; servo should compile
mrowqa fc4c611
Temporarily commented out one test
mrowqa File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
Fixed more violations.
- Loading branch information
commit 2416333a287c73f337ae43ae9637866e9baea774
| @@ -62,6 +62,7 @@ use servo_config::opts; | ||
| use std::{char, ffi, ptr, slice}; | ||
|
|
||
| /// A trait to check whether a given `JSObject` implements an IDL interface. | ||
| #[must_root] | ||
mrowqa
Author
|
||
| pub trait IDLInterface { | ||
| /// Returns whether the given DOM class derives that interface. | ||
| fn derives(&'static DOMClass) -> bool; | ||
| @@ -105,7 +106,7 @@ impl<T: Float + FromJSValConvertible<Config=()>> FromJSValConvertible for Finite | ||
| } | ||
| } | ||
|
|
||
| impl <T: DomObject + IDLInterface> FromJSValConvertible for DomRoot<T> { | ||
| impl <#[must_root] T: DomObject + IDLInterface> FromJSValConvertible for DomRoot<T> { | ||
| type Config = (); | ||
|
|
||
| unsafe fn from_jsval(_cx: *mut JSContext, | ||
| @@ -420,7 +421,7 @@ pub unsafe fn private_from_proto_check<F>(mut obj: *mut JSObject, | ||
| } | ||
|
|
||
| /// Get a `*const T` for a DOM object accessible from a `JSObject`. | ||
| pub fn native_from_object<T>(obj: *mut JSObject) -> Result<*const T, ()> | ||
| pub fn native_from_object<#[must_root] T>(obj: *mut JSObject) -> Result<*const T, ()> | ||
| where T: DomObject + IDLInterface | ||
| { | ||
| unsafe { | ||
| @@ -434,15 +435,15 @@ pub fn native_from_object<T>(obj: *mut JSObject) -> Result<*const T, ()> | ||
| /// Returns Err(()) if `obj` is an opaque security wrapper or if the object is | ||
| /// not a reflector for a DOM object of the given type (as defined by the | ||
| /// proto_id and proto_depth). | ||
| pub fn root_from_object<T>(obj: *mut JSObject) -> Result<DomRoot<T>, ()> | ||
| pub fn root_from_object<#[must_root] T>(obj: *mut JSObject) -> Result<DomRoot<T>, ()> | ||
| where T: DomObject + IDLInterface | ||
| { | ||
| native_from_object(obj).map(|ptr| unsafe { DomRoot::from_ref(&*ptr) }) | ||
| } | ||
|
|
||
| /// Get a `*const T` for a DOM object accessible from a `HandleValue`. | ||
| /// Caller is responsible for throwing a JS exception if needed in case of error. | ||
| pub fn native_from_handlevalue<T>(v: HandleValue) -> Result<*const T, ()> | ||
| pub fn native_from_handlevalue<#[must_root] T>(v: HandleValue) -> Result<*const T, ()> | ||
| where T: DomObject + IDLInterface | ||
| { | ||
| if !v.get().is_object() { | ||
| @@ -453,7 +454,7 @@ pub fn native_from_handlevalue<T>(v: HandleValue) -> Result<*const T, ()> | ||
|
|
||
| /// Get a `DomRoot<T>` for a DOM object accessible from a `HandleValue`. | ||
| /// Caller is responsible for throwing a JS exception if needed in case of error. | ||
| pub fn root_from_handlevalue<T>(v: HandleValue) -> Result<DomRoot<T>, ()> | ||
| pub fn root_from_handlevalue<#[must_root] T>(v: HandleValue) -> Result<DomRoot<T>, ()> | ||
| where T: DomObject + IDLInterface | ||
| { | ||
| if !v.get().is_object() { | ||
| @@ -463,13 +464,13 @@ pub fn root_from_handlevalue<T>(v: HandleValue) -> Result<DomRoot<T>, ()> | ||
| } | ||
|
|
||
| /// Get a `DomRoot<T>` for a DOM object accessible from a `HandleObject`. | ||
| pub fn root_from_handleobject<T>(obj: HandleObject) -> Result<DomRoot<T>, ()> | ||
| pub fn root_from_handleobject<#[must_root] T>(obj: HandleObject) -> Result<DomRoot<T>, ()> | ||
| where T: DomObject + IDLInterface | ||
| { | ||
| root_from_object(obj.get()) | ||
| } | ||
|
|
||
| impl<T: DomObject> ToJSValConvertible for DomRoot<T> { | ||
| impl<#[must_root] T: DomObject> ToJSValConvertible for DomRoot<T> { | ||
| unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { | ||
| self.reflector().to_jsval(cx, rval); | ||
| } | ||
Oops, something went wrong.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Why is this change required?