Skip to content

Commit

Permalink
Fix tyvar_behind_raw_pointer warning
Browse files Browse the repository at this point in the history
As tracked at rust-lang/rust#46906, checked
with rustc 1.26.0-nightly (9cb18a92a 2018-03-02) here and using patched
mozjs in Servo (rustc 1.25.0-nightly (15a1e2844 2018-01-20)).
  • Loading branch information
Xanewok committed Mar 8, 2018
1 parent 5891e73 commit faf032c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ impl<'a> CapturedJSStack<'a> {
pub fn as_string(&self, indent: Option<usize>) -> Option<String> {
unsafe {
let stack_handle = self.stack.handle();
rooted!(in(self.cx) let mut js_string = ptr::null_mut());
rooted!(in(self.cx) let mut js_string = ptr::null_mut::<JSString>());
let string_handle = js_string.handle_mut();

if !IsSavedFrame(stack_handle.get()) {
Expand Down
9 changes: 5 additions & 4 deletions tests/typedarray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use mozjs::jsapi::JS_NewGlobalObject;
use mozjs::jsapi::OnNewGlobalHookOption;
use mozjs::jsapi::Type;
use mozjs::jsval::UndefinedValue;
use mozjs::jsapi::JSObject;
use mozjs::rust::Runtime as Runtime_;
use mozjs::rust::SIMPLE_GLOBAL_CLASS;
use mozjs::typedarray::{CreateWith, Uint32Array};
Expand Down Expand Up @@ -44,7 +45,7 @@ fn typedarray() {
typedarray!(in(cx) let view: ArrayBufferView = rval.to_object());
assert_eq!(view.unwrap().get_array_type(), Type::Uint8);

rooted!(in(cx) let mut rval = ptr::null_mut());
rooted!(in(cx) let mut rval = ptr::null_mut::<JSObject>());
assert!(Uint32Array::create(cx, CreateWith::Slice(&[1, 3, 5]), rval.handle_mut()).is_ok());

typedarray!(in(cx) let array: Uint32Array = rval.get());
Expand All @@ -54,11 +55,11 @@ fn typedarray() {
array.as_mut().unwrap().update(&[2, 4, 6]);
assert_eq!(array.unwrap().as_slice(), &[2, 4, 6][..]);

rooted!(in(cx) let rval = ptr::null_mut());
rooted!(in(cx) let rval = ptr::null_mut::<JSObject>());
typedarray!(in(cx) let array: Uint8Array = rval.get());
assert!(array.is_err());

rooted!(in(cx) let mut rval = ptr::null_mut());
rooted!(in(cx) let mut rval = ptr::null_mut::<JSObject>());
assert!(Uint32Array::create(cx, CreateWith::Length(5), rval.handle_mut()).is_ok());

typedarray!(in(cx) let array: Uint32Array = rval.get());
Expand Down Expand Up @@ -87,7 +88,7 @@ fn typedarray_update_panic() {
);

let _ac = JSAutoCompartment::new(cx, global.get());
rooted!(in(cx) let mut rval = ptr::null_mut());
rooted!(in(cx) let mut rval = ptr::null_mut::<JSObject>());
let _ = Uint32Array::create(cx, CreateWith::Slice(&[1, 2, 3, 4, 5]), rval.handle_mut());
typedarray!(in(cx) let mut array: Uint32Array = rval.get());
array.as_mut().unwrap().update(&[0, 2, 4, 6, 8, 10]);
Expand Down

0 comments on commit faf032c

Please sign in to comment.