Skip to content
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
wants to merge 15 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Fixed generating traits by codegen.

  • Loading branch information
mrowqa committed May 9, 2018
commit c1e333b726b2ddd0106db7a33c82fd4edd25c14b
@@ -5629,7 +5629,7 @@ def contains_unsafe_arg(arguments):

if methods:
self.cgRoot = CGWrapper(CGIndenter(CGList(methods, "")),
pre="pub trait %sMethods {\n" % descriptor.interface.identifier.name,
pre="#[must_root] pub trait %sMethods {\n" % descriptor.interface.identifier.name,

This comment has been minimized.

Copy link
@jdm

jdm May 31, 2018

Member

Why is this change required?

This comment has been minimized.

Copy link
@mrowqa

mrowqa Jun 4, 2018

Author

Because of this. We want traits to be #[must_root].

post="}")
else:
self.cgRoot = CGGeneric("")
@@ -126,7 +126,7 @@ where
}

/// A rooted reference to a DOM object.
pub type DomRoot<T> = Root<Dom<T>>;
pub type DomRoot<#[must_root] T> = Root<Dom<T>>;

impl<T: Castable> DomRoot<T> {
/// Cast a DOM object root upwards to one of the interfaces it derives from.
@@ -7,7 +7,6 @@ pub mod unrooted_must_root {
```
#![feature(plugin)]
#![plugin(script_plugins)]
#![feature(generic_param_attrs)]
#[derive(Clone, Debug)] // derive should not be checked
#[must_root] struct Foo(i32);
@@ -71,7 +70,6 @@ pub mod unrooted_must_root {
```compile_fail
#![feature(plugin)]
#![plugin(script_plugins)]
#![feature(generic_param_attrs)]
#[must_root] struct Foo(i32);
struct Bar<#[must_root] T>(T);
@@ -89,7 +87,6 @@ pub mod unrooted_must_root {
```compile_fail
#![feature(plugin)]
#![plugin(script_plugins)]
#![feature(generic_param_attrs)]
fn foo<T>() { }
fn bar<#[must_root] U>() { foo::<U>(); }
@@ -103,7 +100,6 @@ pub mod unrooted_must_root {
```compile_fail
#![feature(plugin)]
#![plugin(script_plugins)]
#![feature(generic_param_attrs)]
fn foo<#[must_root] T>() { }
fn bar<#[must_root] U>() {
@@ -235,7 +231,6 @@ pub mod unrooted_must_root {
```compile_fail
#![feature(plugin)]
#![plugin(script_plugins)]
#![feature(generic_param_attrs)]
#[must_root] struct Foo(i32);
struct SomeContainer<T>(T);
@@ -259,7 +254,6 @@ pub mod unrooted_must_root {
```
#![feature(plugin)]
#![plugin(script_plugins)]
#![feature(generic_param_attrs)]
#[must_root] struct Foo(i32);
#[allow_unrooted_interior] struct SomeContainer<T>(T);
@@ -280,11 +274,35 @@ pub mod unrooted_must_root {
*/
pub fn allowing_unrooted_interior() {}

/**
```
#![feature(plugin)]
#![plugin(script_plugins)]
#[must_root] struct Foo(i32);
#[must_root] //-- this is needed!
trait Bar {
fn extract(&self) -> i32;
}
impl Bar for Foo {
fn extract(&self) -> i32 { self.0 }
}
fn test() {
Foo(3).extract();
}
fn main() {}
```
*/
pub fn allow_impl_for_must_root() {}

/* *
```
#![feature(plugin)]
#![plugin(script_plugins)]
#![feature(generic_param_attrs)]
#[derive(Default)]
#[must_root] struct Foo(i32);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.