From 36920abfe86e6a3a2d8c989a3ba1f21a5cee54e5 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 25 May 2020 22:13:52 +0200 Subject: [PATCH] Use `const` instead of `static mut` in script/dom/eventtarget.rs There is no mutability there. --- components/script/dom/eventtarget.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 0acc09ce599..746dbd83a72 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -515,8 +515,8 @@ impl EventTarget { let name = CString::new(&**ty).unwrap(); // Step 3.9, subsection ParameterList - static mut ARG_NAMES: [*const c_char; 1] = [b"event\0" as *const u8 as *const c_char]; - static mut ERROR_ARG_NAMES: [*const c_char; 5] = [ + const ARG_NAMES: &[*const c_char] = &[b"event\0" as *const u8 as *const c_char]; + const ERROR_ARG_NAMES: &[*const c_char] = &[ b"event\0" as *const u8 as *const c_char, b"source\0" as *const u8 as *const c_char, b"lineno\0" as *const u8 as *const c_char, @@ -524,13 +524,7 @@ impl EventTarget { b"error\0" as *const u8 as *const c_char, ]; let is_error = ty == &atom!("error") && self.is::(); - let args = unsafe { - if is_error { - &ERROR_ARG_NAMES[..] - } else { - &ARG_NAMES[..] - } - }; + let args = if is_error { ERROR_ARG_NAMES } else { ARG_NAMES }; let cx = window.get_cx(); let options = unsafe {