Skip to content

Commit faf032c

Browse files
committed
Fix tyvar_behind_raw_pointer warning
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)).
1 parent 5891e73 commit faf032c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/rust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ impl<'a> CapturedJSStack<'a> {
14771477
pub fn as_string(&self, indent: Option<usize>) -> Option<String> {
14781478
unsafe {
14791479
let stack_handle = self.stack.handle();
1480-
rooted!(in(self.cx) let mut js_string = ptr::null_mut());
1480+
rooted!(in(self.cx) let mut js_string = ptr::null_mut::<JSString>());
14811481
let string_handle = js_string.handle_mut();
14821482

14831483
if !IsSavedFrame(stack_handle.get()) {

tests/typedarray.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use mozjs::jsapi::JS_NewGlobalObject;
1111
use mozjs::jsapi::OnNewGlobalHookOption;
1212
use mozjs::jsapi::Type;
1313
use mozjs::jsval::UndefinedValue;
14+
use mozjs::jsapi::JSObject;
1415
use mozjs::rust::Runtime as Runtime_;
1516
use mozjs::rust::SIMPLE_GLOBAL_CLASS;
1617
use mozjs::typedarray::{CreateWith, Uint32Array};
@@ -44,7 +45,7 @@ fn typedarray() {
4445
typedarray!(in(cx) let view: ArrayBufferView = rval.to_object());
4546
assert_eq!(view.unwrap().get_array_type(), Type::Uint8);
4647

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

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

57-
rooted!(in(cx) let rval = ptr::null_mut());
58+
rooted!(in(cx) let rval = ptr::null_mut::<JSObject>());
5859
typedarray!(in(cx) let array: Uint8Array = rval.get());
5960
assert!(array.is_err());
6061

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

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

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

0 commit comments

Comments
 (0)