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

Replace `static mut` with `const`, `static`+`AtomicPtr`, or `static`+`UnsafeCell` #26792

Merged
merged 4 commits into from Jun 5, 2020
Next

Use `const` instead of `static mut` in script/dom/eventtarget.rs

There is no mutability there.
  • Loading branch information
SimonSapin committed Jun 4, 2020
commit 36920abfe86e6a3a2d8c989a3ba1f21a5cee54e5
@@ -515,22 +515,16 @@ 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,
b"colno\0" as *const u8 as *const c_char,
b"error\0" as *const u8 as *const c_char,
];
let is_error = ty == &atom!("error") && self.is::<Window>();
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 {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.