mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
Replace some #[allow] with #[expect] (#40865)
Replaces some #[allow] with #[expect]. In case where the lint expectation was unfulfilled, I removed it. Testing: Refactor Part of: https://github.com/servo/servo/issues/40383 Signed-off-by: Dennis Kraus <kraus@posteo.de>
This commit is contained in:
@@ -15,7 +15,7 @@ pub trait Sampler: Send {
|
||||
pub struct DummySampler;
|
||||
|
||||
impl DummySampler {
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code)]
|
||||
pub fn new_boxed() -> Box<dyn Sampler> {
|
||||
Box::new(DummySampler)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ impl Sampler for DummySampler {
|
||||
pub type Address = *const u8;
|
||||
|
||||
/// The registers used for stack unwinding
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code)]
|
||||
pub struct Registers {
|
||||
/// Instruction pointer.
|
||||
pub instruction_ptr: Address,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
#![expect(unsafe_code)]
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
use std::{io, mem, process, thread};
|
||||
@@ -122,7 +122,7 @@ pub struct LinuxSampler {
|
||||
}
|
||||
|
||||
impl LinuxSampler {
|
||||
#[allow(unsafe_code, dead_code)]
|
||||
#[expect(unsafe_code)]
|
||||
pub fn new_boxed() -> Box<dyn Sampler> {
|
||||
let thread_id = unsafe { libc::syscall(libc::SYS_gettid) as libc::pid_t };
|
||||
let handler = SigHandler::SigAction(sigprof_handler);
|
||||
|
||||
@@ -12,7 +12,7 @@ pub struct WindowsSampler {
|
||||
}
|
||||
|
||||
impl WindowsSampler {
|
||||
#[allow(unsafe_code, dead_code)]
|
||||
#[expect(unsafe_code, dead_code)]
|
||||
pub fn new_boxed() -> Box<dyn Sampler> {
|
||||
let thread_id = 0; // TODO: use windows::Win32::System::Threading::GetThreadId
|
||||
Box::new(WindowsSampler { thread_id })
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// TODO: Is this actor still relevant?
|
||||
#![allow(dead_code)]
|
||||
|
||||
use serde::Serialize;
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// TODO: Is this actor still relevant?
|
||||
#![allow(dead_code)]
|
||||
#![expect(dead_code)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::net::TcpStream;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
#![expect(unsafe_code)]
|
||||
|
||||
use std::os::raw::{c_char, c_int, c_uint, c_void};
|
||||
use std::sync::LazyLock;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
#![expect(unsafe_code)]
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -116,7 +116,7 @@ impl taffy::LayoutPartialTree for TaffyContainerContext<'_> {
|
||||
(*self.source_child_nodes[id]).borrow_mut().taffy_layout = *layout;
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
#[expect(unsafe_code)]
|
||||
fn resolve_calc_value(&self, val: *const (), basis: f32) -> f32 {
|
||||
// SAFETY:
|
||||
// - The calc `val` here is the same pointer we return to Taffy in `convert::length_percentage`
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![cfg(test)]
|
||||
#![allow(dead_code)]
|
||||
#![expect(dead_code)]
|
||||
|
||||
mod cookie;
|
||||
mod cookie_http_state;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use stylo_atoms::Atom;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
#![expect(unsafe_code)]
|
||||
|
||||
#[cfg(feature = "webgpu")]
|
||||
use std::ffi::c_void;
|
||||
|
||||
@@ -67,7 +67,8 @@ impl<T> DomRefCell<T> {
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if this is called from anywhere other than the script thread.
|
||||
#[allow(unsafe_code, clippy::mut_from_ref)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(clippy::mut_from_ref)]
|
||||
pub(crate) unsafe fn borrow_for_script_deallocation(&self) -> &mut T {
|
||||
assert_in_script();
|
||||
unsafe { &mut *self.value.as_ptr() }
|
||||
@@ -85,7 +86,8 @@ impl<T> DomRefCell<T> {
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if this is called from anywhere other than the layout thread.
|
||||
#[allow(unsafe_code, clippy::mut_from_ref)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(clippy::mut_from_ref)]
|
||||
pub(crate) unsafe fn borrow_mut_for_layout(&self) -> &mut T {
|
||||
assert_in_layout();
|
||||
unsafe { &mut *self.value.as_ptr() }
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
//! Implementation of `setlike<...>` and `maplike<..., ...>` WebIDL declarations.
|
||||
|
||||
use std::cmp::Eq;
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
//! return `Err()` from the method with the appropriate [error value]
|
||||
//! (error/enum.Error.html).
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
#![expect(unsafe_code)]
|
||||
#![deny(missing_docs)]
|
||||
#![deny(non_snake_case)]
|
||||
|
||||
|
||||
@@ -1836,7 +1836,7 @@ impl CanvasState {
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata>
|
||||
#[allow(unsafe_code, clippy::too_many_arguments)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(super) fn put_image_data_(
|
||||
&self,
|
||||
canvas_size: Size2D<u32>,
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
@@ -456,7 +456,8 @@ impl WebGL2RenderingContext {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, clippy::too_many_arguments)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn read_pixels_into(
|
||||
&self,
|
||||
x: i32,
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(dead_code)] // this file is stub as wgpu does not provide info
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu_traits::ShaderCompilationInfo;
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(dead_code)] // this file is stub
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUQuerySetMethods;
|
||||
|
||||
@@ -937,7 +937,8 @@ fn parse_open_feature_boolean(tokenized_features: &IndexMap<String, String>, nam
|
||||
// This is only called from extern functions,
|
||||
// there's no use using the lifetimed handles here.
|
||||
// https://html.spec.whatwg.org/multipage/#accessing-other-browsing-contexts
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe fn GetSubframeWindowProxy(
|
||||
cx: *mut JSContext,
|
||||
proxy: RawHandleObject,
|
||||
@@ -991,7 +992,8 @@ unsafe fn GetSubframeWindowProxy(
|
||||
None
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn get_own_property_descriptor(
|
||||
cx: *mut JSContext,
|
||||
proxy: RawHandleObject,
|
||||
@@ -1018,7 +1020,8 @@ unsafe extern "C" fn get_own_property_descriptor(
|
||||
unsafe { JS_GetOwnPropertyDescriptorById(cx, target.handle().into(), id, desc, is_none) }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn define_property(
|
||||
cx: *mut JSContext,
|
||||
proxy: RawHandleObject,
|
||||
@@ -1319,7 +1322,8 @@ unsafe extern "C" fn delete_xorigin(
|
||||
throw_security_error(cx, InRealm::Already(&in_realm_proof))
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn getOwnPropertyDescriptor_xorigin(
|
||||
cx: *mut JSContext,
|
||||
proxy: RawHandleObject,
|
||||
@@ -1332,7 +1336,8 @@ unsafe extern "C" fn getOwnPropertyDescriptor_xorigin(
|
||||
found && unsafe { get_own_property_descriptor(cx, proxy, id, desc, is_none) }
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn defineProperty_xorigin(
|
||||
cx: *mut JSContext,
|
||||
_: RawHandleObject,
|
||||
@@ -1345,7 +1350,8 @@ unsafe extern "C" fn defineProperty_xorigin(
|
||||
throw_security_error(cx, InRealm::Already(&in_realm_proof))
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern "C" fn preventExtensions_xorigin(
|
||||
cx: *mut JSContext,
|
||||
_: RawHandleObject,
|
||||
|
||||
@@ -335,7 +335,8 @@ impl DedicatedWorkerGlobalScope {
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#run-a-worker>
|
||||
#[allow(unsafe_code, clippy::too_many_arguments)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn run_worker_scope(
|
||||
mut init: WorkerGlobalScopeInit,
|
||||
worker_url: ServoUrl,
|
||||
|
||||
@@ -256,7 +256,7 @@ impl ServiceWorkerGlobalScope {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, clippy::too_many_arguments)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn new(
|
||||
init: WorkerGlobalScopeInit,
|
||||
worker_url: ServoUrl,
|
||||
@@ -289,7 +289,8 @@ impl ServiceWorkerGlobalScope {
|
||||
}
|
||||
|
||||
/// <https://w3c.github.io/ServiceWorker/#run-service-worker-algorithm>
|
||||
#[allow(unsafe_code, clippy::too_many_arguments)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn run_serviceworker_scope(
|
||||
scope_things: ScopeThings,
|
||||
own_sender: Sender<ServiceWorkerScriptMsg>,
|
||||
|
||||
@@ -726,7 +726,7 @@ impl WorkerGlobalScopeMethods<crate::DomTypeHolder> for WorkerGlobalScope {
|
||||
},
|
||||
};
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
#[expect(unsafe_code)]
|
||||
let mut cx =
|
||||
unsafe { js::context::JSContext::from_ptr(js::rust::Runtime::get().unwrap()) };
|
||||
let options = CompileOptionsWrapper::new(&cx, url.as_str(), 1);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//! will race and cause spurious thread failure. (Note that I do not believe these races are
|
||||
//! exploitable, but they'll result in brokenness nonetheless.)
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
#![expect(unsafe_code)]
|
||||
|
||||
mod document;
|
||||
mod element;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
#![expect(unsafe_code)]
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
|
||||
@@ -452,7 +452,8 @@ impl crate::unminify::ScriptSource for ModuleSource {
|
||||
}
|
||||
|
||||
impl ModuleTree {
|
||||
#[allow(unsafe_code, clippy::too_many_arguments)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
/// <https://html.spec.whatwg.org/multipage/#creating-a-module-script>
|
||||
/// Step 7-11.
|
||||
/// Although the CanGc argument appears unused, it represents the GC operations that
|
||||
@@ -1385,7 +1386,8 @@ impl ResourceTimingListener for ModuleContext {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(non_snake_case)]
|
||||
/// A function to register module hooks (e.g. listening on resolving modules,
|
||||
/// getting module metadata, getting script private reference and resolving dynamic import)
|
||||
pub(crate) unsafe fn EnsureModuleHooksInitialized(rt: *mut JSRuntime) {
|
||||
@@ -1570,7 +1572,8 @@ fn fetch_an_import_module_script_graph(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(non_snake_case)]
|
||||
/// <https://tc39.es/ecma262/#sec-HostLoadImportedModule>
|
||||
/// <https://html.spec.whatwg.org/multipage/#hostloadimportedmodule>
|
||||
unsafe extern "C" fn HostResolveImportedModule(
|
||||
@@ -1615,7 +1618,8 @@ unsafe extern "C" fn HostResolveImportedModule(
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
#[expect(unsafe_code)]
|
||||
#[allow(non_snake_case)]
|
||||
/// <https://tc39.es/ecma262/#sec-hostgetimportmetaproperties>
|
||||
/// <https://html.spec.whatwg.org/multipage/#hostgetimportmetaproperties>
|
||||
unsafe extern "C" fn HostPopulateImportMeta(
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! The script runtime contains common traits and structs commonly used by the
|
||||
//! script thread, the dom, and the worker threads.
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![expect(dead_code)]
|
||||
|
||||
use core::ffi::c_char;
|
||||
use std::cell::Cell;
|
||||
|
||||
@@ -52,7 +52,7 @@ pub mod codegen {
|
||||
pub mod Globals {
|
||||
include!(concat!(env!("OUT_DIR"), "/Globals.rs"));
|
||||
}
|
||||
#[allow(dead_code, unused_imports, clippy::enum_variant_names)]
|
||||
#[allow(unused_imports, clippy::enum_variant_names)]
|
||||
pub mod InheritTypes {
|
||||
include!(concat!(env!("OUT_DIR"), "/InheritTypes.rs"));
|
||||
}
|
||||
@@ -64,7 +64,6 @@ pub mod codegen {
|
||||
include!(concat!(env!("OUT_DIR"), "/DomTypes.rs"));
|
||||
}
|
||||
#[allow(
|
||||
dead_code,
|
||||
clippy::extra_unused_type_parameters,
|
||||
clippy::missing_safety_doc,
|
||||
clippy::result_unit_err
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::script_runtime::JSContext;
|
||||
pub struct AlreadyInRealm(());
|
||||
|
||||
impl AlreadyInRealm {
|
||||
#![allow(unsafe_code)]
|
||||
#![expect(unsafe_code)]
|
||||
pub fn assert<D: DomTypes>() -> AlreadyInRealm {
|
||||
unsafe {
|
||||
assert!(!GetCurrentRealmOrNull(*D::GlobalScope::get_cx()).is_null());
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
#![expect(unsafe_code)]
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::Debug;
|
||||
|
||||
@@ -63,10 +63,9 @@ pub mod dummy_tracing {
|
||||
impl Entered<'_> {}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct Level();
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code)]
|
||||
impl Level {
|
||||
/// The "error" level.
|
||||
///
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
#![allow(unsafe_code)]
|
||||
#![expect(unsafe_code)]
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::thread;
|
||||
use log::{debug, error, info, warn};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code)]
|
||||
pub(crate) enum LogRedirectError {
|
||||
CreatePipeFailed(nix::Error),
|
||||
RedirectToPipeFailed(nix::Error),
|
||||
|
||||
@@ -822,7 +822,7 @@ struct HostCallbacks {
|
||||
ime_proxy: RefCell<Option<ohos_ime::ImeProxy>>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code)]
|
||||
#[derive(Debug)]
|
||||
enum ImeError {
|
||||
TextEditorProxy(CreateTextEditorProxyError),
|
||||
|
||||
@@ -165,7 +165,7 @@ impl RunningAppStateBase {
|
||||
|
||||
pub trait RunningAppStateTrait {
|
||||
fn base(&self) -> &RunningAppStateBase;
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code)]
|
||||
fn base_mut(&mut self) -> &mut RunningAppStateBase;
|
||||
fn webview_by_id(&self, _: WebViewId) -> Option<WebView>;
|
||||
fn dismiss_embedder_controls_for_webview(&self, _webview_id: WebViewId) {}
|
||||
|
||||
Reference in New Issue
Block a user