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

Fix unrooted_must_root lint to handle arguments/return types properly #8030

Merged
merged 2 commits into from Oct 15, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Update script to work with lint changes

  • Loading branch information
Manishearth committed Oct 15, 2015
commit 8819f0d8b86a59acbad9b3127171fce4728b0cdd
@@ -210,6 +210,7 @@ impl GlobalRoot {

impl GlobalField {
/// Create a new `GlobalField` from a rooted reference.
#[allow(unrooted_must_root)]
pub fn from_rooted(global: &GlobalRef) -> GlobalField {
match *global {
GlobalRef::Window(window) => GlobalField::Window(JS::from_ref(window)),
@@ -67,12 +67,14 @@ impl<T: Reflectable> JS<T> {
}
/// Create a JS<T> from a Root<T>
/// XXX Not a great API. Should be a call on Root<T> instead
#[allow(unrooted_must_root)]
pub fn from_rooted(root: &Root<T>) -> JS<T> {
JS {
ptr: unsafe { NonZero::new(&**root) }
}
}
/// Create a JS<T> from a &T
#[allow(unrooted_must_root)]
pub fn from_ref(obj: &T) -> JS<T> {
JS {
ptr: unsafe { NonZero::new(&*obj) }
@@ -125,6 +127,7 @@ impl<T> PartialEq for LayoutJS<T> {

impl <T> Clone for JS<T> {
#[inline]
#[allow(unrooted_must_root)]
fn clone(&self) -> JS<T> {
JS {
ptr: self.ptr.clone()
@@ -288,6 +291,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
}

impl<T: HeapGCValue + Copy> Default for MutNullableHeap<T> {
#[allow(unrooted_must_root)]
fn default() -> MutNullableHeap<T> {
MutNullableHeap {
ptr: Cell::new(None)
@@ -1352,10 +1352,12 @@ impl Node {
Node::new_(flags, Some(doc))
}

#[allow(unrooted_must_root)]
pub fn new_document_node() -> Node {
Node::new_(NodeFlags::new() | IS_IN_DOC, None)
}

#[allow(unrooted_must_root)]
fn new_(flags: NodeFlags, doc: Option<&Document>) -> Node {
Node {
eventtarget: EventTarget::new_inherited(),
@@ -43,6 +43,7 @@ pub struct Sink {
}

impl Sink {
#[allow(unrooted_must_root)] // method is only run at parse time
pub fn get_or_create(&self, child: NodeOrText<JS<Node>>) -> Root<Node> {
match child {
NodeOrText::AppendNode(n) => n.root(),
@@ -147,10 +147,10 @@ impl WebGLRenderingContext {
}
}

pub fn bound_texture_for(&self, target: u32) -> Option<JS<WebGLTexture>> {
pub fn bound_texture_for(&self, target: u32) -> Option<Root<WebGLTexture>> {
match target {
constants::TEXTURE_2D => self.bound_texture_2d.get(),
constants::TEXTURE_CUBE_MAP => self.bound_texture_cube_map.get(),
constants::TEXTURE_2D => self.bound_texture_2d.get().map(|t| t.root()),
constants::TEXTURE_CUBE_MAP => self.bound_texture_cube_map.get().map(|t| t.root()),

_ => unreachable!(),
}
@@ -906,7 +906,6 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
constants::TEXTURE_2D |
constants::TEXTURE_CUBE_MAP => {
if let Some(texture) = self.bound_texture_for(target) {
let texture = texture.root();
let result = texture.r().tex_parameter(target, name, TexParameterValue::Float(value));
handle_potential_webgl_error!(self, result);
} else {
@@ -924,7 +923,6 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
constants::TEXTURE_2D |
constants::TEXTURE_CUBE_MAP => {
if let Some(texture) = self.bound_texture_for(target) {
let texture = texture.root();
let result = texture.r().tex_parameter(target, name, TexParameterValue::Int(value));
handle_potential_webgl_error!(self, result);
} else {
@@ -119,6 +119,7 @@ impl Page {
old
}

#[allow(unrooted_must_root)]
pub fn set_frame(&self, frame: Option<Frame>) {
*self.frame.borrow_mut() = frame;
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.