Change some #[allow]s to #[expect]s (#40458)

Removes some unneeded lints.

Testing: Refactor
Part of: #40383

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
This commit is contained in:
WaterWhisperer
2025-11-06 20:31:48 +08:00
committed by GitHub
parent 9193b1d310
commit 241bff962d
74 changed files with 153 additions and 188 deletions

View File

@@ -12,11 +12,10 @@ pub trait Sampler: Send {
fn suspend_and_sample_thread(&self) -> Result<NativeStack, ()>;
}
#[allow(dead_code)]
pub struct DummySampler;
impl DummySampler {
#[allow(dead_code)]
#[expect(dead_code)]
pub fn new_boxed() -> Box<dyn Sampler> {
Box::new(DummySampler)
}
@@ -29,11 +28,10 @@ impl Sampler for DummySampler {
}
// Several types in this file are currently not used in a Linux or Windows build.
#[allow(dead_code)]
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,
@@ -43,17 +41,13 @@ pub struct Registers {
pub frame_ptr: Address,
}
#[allow(dead_code)]
pub struct NativeStack {
instruction_ptrs: [*mut std::ffi::c_void; MAX_NATIVE_FRAMES],
#[allow(dead_code)]
stack_ptrs: [*mut std::ffi::c_void; MAX_NATIVE_FRAMES],
#[allow(dead_code)]
count: usize,
}
impl NativeStack {
#[allow(dead_code)]
pub fn new() -> Self {
NativeStack {
instruction_ptrs: [ptr::null_mut(); MAX_NATIVE_FRAMES],
@@ -62,7 +56,6 @@ impl NativeStack {
}
}
#[allow(dead_code)]
pub fn process_register(
&mut self,
instruction_ptr: *mut std::ffi::c_void,

View File

@@ -116,7 +116,6 @@ impl Drop for PosixSemaphore {
}
}
#[allow(dead_code)]
pub struct LinuxSampler {
thread_id: MonitoredThreadId,
old_handler: SigAction,
@@ -142,7 +141,7 @@ impl LinuxSampler {
}
impl Sampler for LinuxSampler {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn suspend_and_sample_thread(&self) -> Result<NativeStack, ()> {
// Warning: The "critical section" begins here.
// In the critical section:

View File

@@ -13,7 +13,7 @@ pub struct MacOsSampler {
}
impl MacOsSampler {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub fn new_boxed() -> Box<dyn Sampler> {
let thread_id = unsafe { mach2::mach_init::mach_thread_self() };
Box::new(MacOsSampler { thread_id })
@@ -21,7 +21,7 @@ impl MacOsSampler {
}
impl Sampler for MacOsSampler {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn suspend_and_sample_thread(&self) -> Result<NativeStack, ()> {
// Warning: The "critical section" begins here.
// In the critical section:
@@ -60,12 +60,12 @@ fn check_kern_return(kret: mach2::kern_return::kern_return_t) -> Result<(), ()>
Ok(())
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe fn suspend_thread(thread_id: MonitoredThreadId) -> Result<(), ()> {
check_kern_return(unsafe { mach2::thread_act::thread_suspend(thread_id) })
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe fn get_registers(thread_id: MonitoredThreadId) -> Result<Registers, ()> {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
{
@@ -106,12 +106,12 @@ unsafe fn get_registers(thread_id: MonitoredThreadId) -> Result<Registers, ()> {
})
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe fn resume_thread(thread_id: MonitoredThreadId) -> Result<(), ()> {
check_kern_return(unsafe { mach2::thread_act::thread_resume(thread_id) })
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe fn frame_pointer_stack_walk(regs: Registers) -> NativeStack {
// Note: this function will only work with code build with:
// --dev,

View File

@@ -6,7 +6,7 @@ use crate::sampler::{NativeStack, Sampler};
type MonitoredThreadId = usize; // TODO: use the `windows` crate to do this.
#[allow(dead_code)]
#[expect(dead_code)]
pub struct WindowsSampler {
thread_id: MonitoredThreadId,
}

View File

@@ -101,7 +101,6 @@ pub(crate) trait GenericDrawTarget {
fn snapshot(&mut self) -> Snapshot;
}
#[allow(dead_code)] // used by gated backends
/// A version of the `Into<T>` trait from the standard library that can be used
/// to convert between two types that are not defined in the canvas crate.
pub(crate) trait Convert<T> {

View File

@@ -590,7 +590,7 @@ impl GenericDrawTarget for VelloDrawTarget {
};
let data = SerializableImageData::Raw(if let Some(data) = data {
let mut data = IpcSharedMemory::from_bytes(data);
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe {
pixels::generic_transform_inplace::<1, false, false>(data.deref_mut());
};

View File

@@ -257,7 +257,6 @@ fn setup_common<C: CommandMethods>(command: &mut C, token: String) {
}
/// A trait to unify commands launched as multiprocess with or without a sandbox.
#[allow(dead_code)]
trait CommandMethods {
/// A command line argument.
fn arg<T>(&mut self, arg: T)

View File

@@ -292,7 +292,6 @@ impl RootActor {
tab_msg
}
#[allow(dead_code)]
pub fn active_tab(&self) -> Option<String> {
self.active_tab.borrow().clone()
}

View File

@@ -59,7 +59,6 @@ pub struct SourceActor {
pub content_type: Option<String>,
// TODO: use it in #37667, then remove this allow
#[allow(unused)]
pub spidermonkey_id: u32,
/// `introductionType` in SpiderMonkey `CompileOptionsWrapper`.
pub introduction_type: String,

View File

@@ -165,7 +165,6 @@ impl TabDescriptorActor {
self.is_top_level_global
}
#[allow(dead_code)]
pub fn browsing_context(&self) -> String {
self.browsing_context_actor.clone()
}

View File

@@ -20,7 +20,7 @@ use crate::protocol::{ClientRequest, JsonPacketStream};
use crate::resource::ResourceAvailable;
#[derive(Clone, Copy)]
#[allow(dead_code)]
#[expect(dead_code)]
pub enum WorkerType {
Dedicated = 0,
Shared = 1,

View File

@@ -37,7 +37,7 @@ fn expand_dom_object(input: syn::DeriveInput) -> proc_macro2::TokenStream {
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
let items = quote! {
impl #impl_generics ::js::conversions::ToJSValConvertible for #name #ty_generics #where_clause {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe fn to_jsval(&self,
cx: *mut js::jsapi::JSContext,
rval: js::rust::MutableHandleValue) {
@@ -85,7 +85,7 @@ fn expand_dom_object(input: syn::DeriveInput) -> proc_macro2::TokenStream {
impl<T: ?Sized> NoDomObjectInDomObject<()> for T {}
// Used for the specialized impl when DomObject is implemented.
#[allow(dead_code)]
#[expect(dead_code)]
struct Invalid;
// forbids DomObject
impl<T> NoDomObjectInDomObject<Invalid> for T where T: ?Sized + crate::DomObject {}

View File

@@ -8,7 +8,7 @@ mod font;
mod font_context;
mod font_store;
mod glyph;
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub mod platform; // Public because integration tests need this
mod shapers;
mod system_font_service;

View File

@@ -53,7 +53,6 @@ impl FontTableMethods for FontTable {
}
#[derive(Debug)]
#[allow(unused)]
pub struct PlatformFont {
face: ReentrantMutex<FreeTypeFace>,
requested_face_size: Au,

View File

@@ -61,7 +61,7 @@ unsafe impl Sync for FreeTypeLibraryHandle {}
unsafe impl Send for FreeTypeLibraryHandle {}
impl Drop for FreeTypeLibraryHandle {
#[allow(unused)]
#[expect(unused)]
fn drop(&mut self) {
assert!(!self.freetype_library.is_null());
unsafe {

View File

@@ -33,7 +33,7 @@ static OHOS_FONTS_DIR: &str = env!("OHOS_SDK_FONTS_DIR");
#[cfg(not(ohos_mock))]
static OHOS_FONTS_DIR: &str = "/system/fonts";
#[allow(unused)]
#[expect(unused)]
#[derive(Clone, Copy, Debug, Default)]
// HarmonyOS only comes in Condensed and Normal variants
enum FontWidth {

View File

@@ -93,12 +93,12 @@ fn assert_not_impl_traceable(ty: &syn::Type) -> proc_macro2::TokenStream {
impl<T: ?Sized> NoTraceOnJSTraceable<()> for T {}
// Used for the specialized impl when JSTraceable is implemented.
#[allow(dead_code)]
#[expect(dead_code)]
struct Invalid0;
// forbids JSTraceable
impl<T> NoTraceOnJSTraceable<Invalid0> for T where T: ?Sized + crate::JSTraceable {}
#[allow(dead_code)]
#[expect(dead_code)]
struct Invalid2;
// forbids HashMap<JSTraceble, _>
impl<K, V, S> NoTraceOnJSTraceable<Invalid2> for std::collections::HashMap<K, V, S>
@@ -108,7 +108,7 @@ fn assert_not_impl_traceable(ty: &syn::Type) -> proc_macro2::TokenStream {
{
}
#[allow(dead_code)]
#[expect(dead_code)]
struct Invalid3;
// forbids HashMap<_, JSTraceble>
impl<K, V, S> NoTraceOnJSTraceable<Invalid3> for std::collections::HashMap<K, V, S>
@@ -119,7 +119,7 @@ fn assert_not_impl_traceable(ty: &syn::Type) -> proc_macro2::TokenStream {
{
}
#[allow(dead_code)]
#[expect(dead_code)]
struct Invalid4;
// forbids BTreeMap<_, JSTraceble>
impl<K, V> NoTraceOnJSTraceable<Invalid4> for std::collections::BTreeMap<K, V> where
@@ -127,7 +127,7 @@ fn assert_not_impl_traceable(ty: &syn::Type) -> proc_macro2::TokenStream {
{
}
#[allow(dead_code)]
#[expect(dead_code)]
struct Invalid5;
// forbids BTreeMap<_, JSTraceble>
impl<K, V> NoTraceOnJSTraceable<Invalid5> for std::collections::BTreeMap<K, V>
@@ -177,10 +177,10 @@ fn js_traceable_derive(s: synstructure::Structure) -> proc_macro2::TokenStream {
let tokens = quote! {
#asserts
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl #impl_generics crate::JSTraceable for #name #ty_generics #where_clause {
#[inline]
#[allow(unused_variables, unused_imports)]
#[expect(unused_variables, unused_imports)]
unsafe fn trace(&self, tracer: *mut js::jsapi::JSTracer) {
use crate::JSTraceable;
match *self {

View File

@@ -390,9 +390,7 @@ pub(crate) struct TableLayoutStyle<'a> {
pub(crate) enum TableLevelBox {
Caption(ArcRefCell<TableCaption>),
Cell(ArcRefCell<TableSlotCell>),
#[allow(dead_code)]
TrackGroup(ArcRefCell<TableTrackGroup>),
#[allow(dead_code)]
Track(ArcRefCell<TableTrack>),
}

View File

@@ -26,7 +26,7 @@ static PANIC_HOOK_MUTEX: Mutex<()> = Mutex::new(());
// suppress panic messages from other failing tests. To work around this, run failing tests one at
// a time or use only a single test thread.
struct PanicMsgSuppressor<'a> {
#[allow(dead_code)]
#[expect(dead_code)]
mutex_guard: MutexGuard<'a, ()>,
prev_hook: Option<Box<dyn Fn(&PanicHookInfo<'_>) + 'static + Sync + Send>>,
}

View File

@@ -30,7 +30,7 @@ impl<'a> RecalcStyle<'a> {
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
impl<'dom, E> DomTraversal<E> for RecalcStyle<'_>
where
E: TElement,

View File

@@ -92,7 +92,7 @@ pub struct HstsList {
pub struct HstsPreloadList(pub fst::Map<Vec<u8>>);
impl MallocSizeOf for HstsPreloadList {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn size_of(&self, ops: &mut malloc_size_of::MallocSizeOfOps) -> usize {
unsafe { ops.malloc_size_of(self.0.as_fst().as_inner().as_ptr()) }
}

View File

@@ -232,7 +232,6 @@ fn create_http_states(
}
impl ResourceChannelManager {
#[allow(unsafe_code)]
fn start(
&mut self,
public_receiver: IpcReceiver<CoreResourceMsg>,

View File

@@ -5,7 +5,7 @@
#![deny(unsafe_code)]
pub mod mem;
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub mod system_reporter;
pub mod time;
pub mod trace_dump;

View File

@@ -336,7 +336,7 @@ impl Animations {
/// Ensure that all nodes with new animations are rooted. This should be called
/// immediately after a restyle, to ensure that these addresses are still valid.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn root_newly_animating_dom_nodes(
&self,
sets: &FxHashMap<AnimationSetKey, ElementAnimationSet>,

View File

@@ -763,7 +763,7 @@ fn run_text_data_algorithm(bytes: Vec<u8>) -> Fallible<FetchedData> {
))
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
/// <https://fetch.spec.whatwg.org/#ref-for-concept-body-consume-body%E2%91%A3>
fn run_json_data_algorithm(cx: JSContext, bytes: Vec<u8>) -> Fallible<FetchedData> {
// The JSON spec allows implementations to either ignore UTF-8 BOM or treat it as an error.
@@ -864,7 +864,7 @@ pub(crate) fn run_array_buffer_data_algorithm(
Ok(FetchedData::ArrayBuffer(rooted_heap))
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) fn decode_to_utf16_with_bom_removal(
bytes: &[u8],
encoding: &'static Encoding,

View File

@@ -47,7 +47,7 @@ use crate::realms::enter_realm;
use crate::script_module::ScriptFetchOptions;
use crate::script_runtime::{CanGc, IntroductionType};
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) fn handle_evaluate_js(
global: &GlobalScope,
eval: String,

View File

@@ -50,7 +50,7 @@ where
}
// https://www.w3.org/TR/IndexedDB-2/#convert-key-to-value
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub fn key_type_to_jsval(
cx: SafeJSContext,
key: &IndexedDBKeyType,
@@ -81,7 +81,7 @@ pub fn key_type_to_jsval(
/// <https://www.w3.org/TR/IndexedDB-2/#valid-key-path>
pub(crate) fn is_valid_key_path(key_path: &StrOrStringSequence) -> Result<bool, Error> {
// <https://tc39.es/ecma262/#prod-IdentifierName>
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let is_identifier_name = |name: &str| -> Result<bool, Error> {
let cx = GlobalScope::get_cx();
rooted!(in(*cx) let mut value = UndefinedValue());
@@ -151,7 +151,7 @@ impl ConversionResult {
}
// https://www.w3.org/TR/IndexedDB-2/#convert-value-to-key
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub fn convert_value_to_key(
cx: SafeJSContext,
input: HandleValue,
@@ -259,7 +259,7 @@ pub fn convert_value_to_key(
}
/// <https://www.w3.org/TR/IndexedDB-2/#convert-a-value-to-a-key-range>
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub fn convert_value_to_key_range(
cx: SafeJSContext,
input: HandleValue,
@@ -310,7 +310,7 @@ pub(crate) enum EvaluationResult {
}
/// <https://www.w3.org/TR/IndexedDB-2/#evaluate-a-key-path-on-a-value>
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) fn evaluate_key_path_on_value(
cx: SafeJSContext,
value: HandleValue,

View File

@@ -11,7 +11,7 @@ use crate::dom::bindings::utils::is_platform_object_static;
use crate::script_runtime::JSEngineSetup;
#[cfg(target_os = "linux")]
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn perform_platform_specific_initialization() {
// 4096 is default max on many linux systems
const MAX_FILE_LIMIT: libc::rlim_t = 4096;
@@ -53,7 +53,7 @@ fn perform_platform_specific_initialization() {
#[cfg(not(target_os = "linux"))]
fn perform_platform_specific_initialization() {}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn is_dom_object(obj: *mut JSObject) -> bool {
!obj.is_null() && (is_platform_object_static(obj) || is_dom_proxy(obj))
}
@@ -66,7 +66,7 @@ unsafe extern "C" fn is_dom_object(obj: *mut JSObject) -> bool {
/// Note: This implementation should work fine on all Linux systems, perhaps even Unix systems,
/// but for now we only enable it on OpenHarmony, since that is where it is most needed.
#[cfg(target_env = "ohos")]
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn jit_forbidden() -> bool {
debug!("Testing if JIT is allowed.");
@@ -76,7 +76,7 @@ fn jit_forbidden() -> bool {
// can be written to. `read` is a syscall and will return an error code
// if ptr can't be written (instead of a segfault as with a regular access).
// We also take care to always close `fd`.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe {
let fd = libc::open(c"/dev/zero".as_ptr(), libc::O_RDONLY);
if fd < 0 {
@@ -159,7 +159,7 @@ fn jit_forbidden() -> bool {
false
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub fn init() -> JSEngineSetup {
if pref!(js_disable_jit) || jit_forbidden() {
let reason = if pref!(js_disable_jit) {

View File

@@ -935,7 +935,6 @@ impl<'dom> ::selectors::Element for ServoLayoutElement<'dom> {
self.element.is::<HTMLSlotElement>()
}
#[allow(unsafe_code)]
fn assigned_slot(&self) -> Option<Self> {
self.as_node().assigned_slot()
}

View File

@@ -485,7 +485,7 @@ pub enum ServoThreadSafeLayoutNodeChildrenIterator<'dom> {
}
impl<'dom> ServoThreadSafeLayoutNodeChildrenIterator<'dom> {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn new(
parent: ServoThreadSafeLayoutNode<'dom>,
) -> ServoThreadSafeLayoutNodeChildrenIterator<'dom> {

View File

@@ -42,7 +42,6 @@ pub(crate) mod document_collection;
pub(crate) mod iframe_collection;
pub(crate) mod image_animation;
pub mod layout_dom;
#[allow(unsafe_code)]
pub(crate) mod messaging;
mod microtask;
pub(crate) mod mime;
@@ -50,11 +49,11 @@ mod navigation;
mod network_listener;
mod realms;
mod routed_promise;
#[allow(dead_code)]
#[expect(dead_code)]
mod script_module;
mod script_mutation_observers;
pub(crate) mod script_runtime;
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) mod script_thread;
pub(crate) mod security_manager;
pub(crate) mod serviceworker_manager;
@@ -64,7 +63,6 @@ mod task_manager;
mod task_queue;
mod task_source;
pub mod test;
#[allow(dead_code)]
pub mod textinput;
mod timers;
mod webdriver_handlers;

View File

@@ -76,7 +76,7 @@ pub(crate) struct UserMicrotask {
impl MicrotaskQueue {
/// Add a new microtask to this queue. It will be invoked as part of the next
/// microtask checkpoint.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) fn enqueue(&self, job: Microtask, cx: JSContext) {
self.microtask_queue.borrow_mut().push(job);
unsafe { JobQueueMayNotBeEmpty(*cx) };
@@ -84,7 +84,7 @@ impl MicrotaskQueue {
/// <https://html.spec.whatwg.org/multipage/#perform-a-microtask-checkpoint>
/// Perform a microtask checkpoint, executing all queued microtasks until the queue is empty.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) fn checkpoint<F>(
&self,
cx: JSContext,

View File

@@ -525,7 +525,7 @@ impl ModuleTree {
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
/// <https://html.spec.whatwg.org/multipage/#fetch-the-descendants-of-and-link-a-module-script>
/// Step 5-2.
pub(crate) fn instantiate_module_tree(
@@ -558,7 +558,7 @@ impl ModuleTree {
/// Execute the provided module, storing the evaluation return value in the provided
/// mutable handle. Although the CanGc appears unused, it represents the GC operations
/// possible when evluating arbitrary JS.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) fn execute_module(
&self,
global: &GlobalScope,
@@ -600,7 +600,7 @@ impl ModuleTree {
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) fn report_error(&self, global: &GlobalScope, can_gc: CanGc) {
let module_error = self.rethrow_error.borrow();
@@ -617,7 +617,7 @@ impl ModuleTree {
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn resolve_requested_module_specifiers(
&self,
global: &GlobalScope,
@@ -659,7 +659,6 @@ impl ModuleTree {
}
/// <https://html.spec.whatwg.org/multipage/#resolve-a-module-specifier>
#[allow(unsafe_code)]
fn resolve_module_specifier(
global: &GlobalScope,
script: Option<&ModuleScript>,
@@ -840,7 +839,6 @@ impl ModuleTree {
(None, parse_error)
}
#[allow(unsafe_code)]
// FIXME: spec links in this function are all broken, so its unclear what this algorithm does
/// <https://html.spec.whatwg.org/multipage/#fetch-the-descendants-of-a-module-script>
fn fetch_module_descendants(
@@ -1037,7 +1035,7 @@ impl Callback for ModuleHandler {
/// It can be `worker` or `script` element
#[derive(Clone)]
pub(crate) enum ModuleOwner {
#[allow(dead_code)]
#[expect(dead_code)]
Worker(TrustedWorkerAddress),
Window(Trusted<HTMLScriptElement>),
DynamicModule(Trusted<DynamicModuleOwner>),
@@ -1107,7 +1105,7 @@ impl ModuleOwner {
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
/// <https://html.spec.whatwg.org/multipage/#hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):fetch-an-import()-module-script-graph>
/// Step 6-9
fn finish_dynamic_module(
@@ -1255,7 +1253,6 @@ impl FetchResponseListener for ModuleContext {
/// <https://html.spec.whatwg.org/multipage/#fetch-a-single-module-script>
/// Step 9-12
#[allow(unsafe_code)]
fn process_response_eof(
&mut self,
_: RequestId,
@@ -1420,19 +1417,19 @@ pub(crate) unsafe fn EnsureModuleHooksInitialized(rt: *mut JSRuntime) {
SetModuleDynamicImportHook(rt, Some(host_import_module_dynamically));
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn host_add_ref_top_level_script(value: *const Value) {
let val = Rc::from_raw((*value).to_private() as *const ModuleScript);
mem::forget(val.clone());
mem::forget(val);
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn host_release_top_level_script(value: *const Value) {
let _val = Rc::from_raw((*value).to_private() as *const ModuleScript);
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
/// <https://tc39.es/ecma262/#sec-hostimportmoduledynamically>
/// <https://html.spec.whatwg.org/multipage/#hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability)>
pub(crate) unsafe extern "C" fn host_import_module_dynamically(
@@ -1503,7 +1500,7 @@ impl ScriptFetchOptions {
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe fn module_script_from_reference_private(
reference_private: &RawHandle<JSVal>,
) -> Option<&ModuleScript> {
@@ -1514,7 +1511,7 @@ unsafe fn module_script_from_reference_private(
}
/// <https://html.spec.whatwg.org/multipage/#fetch-an-import()-module-script-graph>
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn fetch_an_import_module_script_graph(
global: &GlobalScope,
module_request: RawHandle<*mut JSObject>,
@@ -1887,7 +1884,6 @@ fn fetch_single_module_script(
}
}
#[allow(unsafe_code)]
/// <https://html.spec.whatwg.org/multipage/#fetch-an-inline-module-script-graph>
pub(crate) fn fetch_inline_module_script(
owner: ModuleOwner,
@@ -2269,7 +2265,6 @@ pub(crate) fn parse_an_import_map_string(
}
/// <https://html.spec.whatwg.org/multipage/#sorting-and-normalizing-a-module-specifier-map>
#[allow(unsafe_code)]
fn sort_and_normalize_module_specifier_map(
global: &GlobalScope,
original_map: &JsonMap<String, JsonValue>,

View File

@@ -263,7 +263,7 @@ const INCUMBENT_SETTING_SLOT: u32 = 0;
const HOST_DEFINED_DATA_SLOTS: u32 = 1;
/// <https://searchfox.org/mozilla-central/rev/2a8a30f4c9b918b726891ab9d2d62b76152606f1/xpcom/base/CycleCollectedJSContext.cpp#316>
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn get_host_defined_data(
_: *const c_void,
cx: *mut RawJSContext,
@@ -291,7 +291,7 @@ unsafe extern "C" fn get_host_defined_data(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn run_jobs(microtask_queue: *const c_void, cx: *mut RawJSContext) {
let cx = JSContext::from_ptr(cx);
wrap_panic(&mut || {
@@ -302,7 +302,7 @@ unsafe extern "C" fn run_jobs(microtask_queue: *const c_void, cx: *mut RawJSCont
});
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn empty(extra: *const c_void) -> bool {
let mut result = false;
wrap_panic(&mut || {
@@ -312,7 +312,7 @@ unsafe extern "C" fn empty(extra: *const c_void) -> bool {
result
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn push_new_interrupt_queue(interrupt_queues: *mut c_void) -> *const c_void {
let mut result = std::ptr::null();
wrap_panic(&mut || {
@@ -325,7 +325,7 @@ unsafe extern "C" fn push_new_interrupt_queue(interrupt_queues: *mut c_void) ->
result
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn pop_interrupt_queue(interrupt_queues: *mut c_void) -> *const c_void {
let mut result = std::ptr::null();
wrap_panic(&mut || {
@@ -339,7 +339,7 @@ unsafe extern "C" fn pop_interrupt_queue(interrupt_queues: *mut c_void) -> *cons
result
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn drop_interrupt_queues(interrupt_queues: *mut c_void) {
wrap_panic(&mut || {
let interrupt_queues = Box::from_raw(interrupt_queues as *mut Vec<Rc<MicrotaskQueue>>);
@@ -350,7 +350,7 @@ unsafe extern "C" fn drop_interrupt_queues(interrupt_queues: *mut c_void) {
/// <https://searchfox.org/mozilla-central/rev/2a8a30f4c9b918b726891ab9d2d62b76152606f1/xpcom/base/CycleCollectedJSContext.cpp#355>
/// SM callback for promise job resolution. Adds a promise callback to the current
/// global's microtask queue.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn enqueue_promise_job(
extra: *const c_void,
cx: *mut RawJSContext,
@@ -396,7 +396,7 @@ unsafe extern "C" fn enqueue_promise_job(
result
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
/// <https://html.spec.whatwg.org/multipage/#the-hostpromiserejectiontracker-implementation>
unsafe extern "C" fn promise_rejection_tracker(
@@ -475,7 +475,7 @@ unsafe extern "C" fn promise_rejection_tracker(
})
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn safely_convert_null_to_string(cx: JSContext, str_: HandleString) -> DOMString {
DOMString::from(match std::ptr::NonNull::new(*str_) {
None => "".to_owned(),
@@ -483,7 +483,7 @@ fn safely_convert_null_to_string(cx: JSContext, str_: HandleString) -> DOMString
})
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn code_for_eval_gets(
cx: *mut RawJSContext,
code: HandleObject,
@@ -499,7 +499,7 @@ unsafe extern "C" fn code_for_eval_gets(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn content_security_policy_allows(
cx: *mut RawJSContext,
runtime_code: RuntimeCode,
@@ -585,7 +585,7 @@ unsafe extern "C" fn content_security_policy_allows(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
/// <https://html.spec.whatwg.org/multipage/#notify-about-rejected-promises>
pub(crate) fn notify_about_rejected_promises(global: &GlobalScope) {
@@ -681,7 +681,7 @@ impl Runtime {
/// invalid and undefined state.
///
/// This, like many calls to SpiderMoney API, is unsafe.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) fn new(networking_task_source: Option<SendableTaskSource>) -> Runtime {
unsafe { Self::new_with_parent(None, networking_task_source) }
}
@@ -698,7 +698,7 @@ impl Runtime {
/// The `parent` pointer in the [`ParentRuntime`] argument must point to a valid object in memory.
///
/// This, like many calls to the SpiderMoney API, is unsafe.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) unsafe fn new_with_parent(
parent: Option<ParentRuntime>,
networking_task_source: Option<SendableTaskSource>,
@@ -935,7 +935,7 @@ impl Runtime {
}
impl Drop for Runtime {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn drop(&mut self) {
// Clear our main microtask_queue.
self.microtask_queue.clear();
@@ -988,7 +988,7 @@ fn in_range<T: PartialOrd + Copy>(val: T, min: T, max: T) -> Option<T> {
thread_local!(static MALLOC_SIZE_OF_OPS: Cell<*mut MallocSizeOfOps> = const { Cell::new(ptr::null_mut()) });
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn get_size(obj: *mut JSObject) -> usize {
match get_dom_class(obj) {
Ok(v) => {
@@ -1007,7 +1007,7 @@ unsafe extern "C" fn get_size(obj: *mut JSObject) -> usize {
thread_local!(static GC_CYCLE_START: Cell<Option<Instant>> = const { Cell::new(None) });
thread_local!(static GC_SLICE_START: Cell<Option<Instant>> = const { Cell::new(None) });
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn gc_slice_callback(
_cx: *mut RawJSContext,
progress: GCProgress,
@@ -1045,7 +1045,7 @@ unsafe extern "C" fn gc_slice_callback(
let _ = stdout().flush();
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn debug_gc_callback(
_cx: *mut RawJSContext,
status: JSGCStatus,
@@ -1058,7 +1058,7 @@ unsafe extern "C" fn debug_gc_callback(
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn trace_rust_roots(tr: *mut JSTracer, _data: *mut os::raw::c_void) {
if !runtime_is_alive() {
return;
@@ -1071,13 +1071,13 @@ unsafe extern "C" fn trace_rust_roots(tr: *mut JSTracer, _data: *mut os::raw::c_
trace!("done custom root handler");
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn servo_build_id(build_id: *mut BuildIdCharVector) -> bool {
let servo_id = b"Servo\0";
SetBuildId(build_id, servo_id[0] as *const c_char, servo_id.len())
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
#[cfg(feature = "debugmozjs")]
unsafe fn set_gc_zeal_options(cx: *mut RawJSContext) {
use js::jsapi::SetGCZeal;
@@ -1094,7 +1094,7 @@ unsafe fn set_gc_zeal_options(cx: *mut RawJSContext) {
SetGCZeal(cx, level, frequency);
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
#[cfg(not(feature = "debugmozjs"))]
unsafe fn set_gc_zeal_options(_: *mut RawJSContext) {}
@@ -1107,7 +1107,7 @@ pub(crate) trait JSContextHelper {
}
impl JSContextHelper for JSContext {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn get_reports(&self, path_seg: String, ops: &mut MallocSizeOfOps) -> Vec<Report> {
MALLOC_SIZE_OF_OPS.with(|ops_tls| ops_tls.set(ops));
let stats = unsafe {
@@ -1171,7 +1171,7 @@ impl JSContextHelper for JSContext {
pub(crate) struct StreamConsumer(*mut JSStreamConsumer);
#[allow(unsafe_code)]
#[expect(unsafe_code)]
impl StreamConsumer {
pub(crate) fn consume_chunk(&self, stream: &[u8]) -> bool {
unsafe {
@@ -1217,7 +1217,7 @@ impl StreamConsumer {
/// Implements the steps to compile webassembly response mentioned here
/// <https://webassembly.github.io/spec/web-api/#compile-a-potential-webassembly-response>
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn consume_stream(
_cx: *mut RawJSContext,
obj: HandleObject,
@@ -1306,7 +1306,7 @@ unsafe extern "C" fn consume_stream(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn report_stream_error(_cx: *mut RawJSContext, error_code: usize) {
error!(
"Error initializing StreamConsumer: {:?}",
@@ -1316,12 +1316,12 @@ unsafe extern "C" fn report_stream_error(_cx: *mut RawJSContext, error_code: usi
pub(crate) struct Runnable(*mut DispatchablePointer);
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl Sync for Runnable {}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl Send for Runnable {}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
impl Runnable {
fn run(&self, cx: *mut RawJSContext, maybe_shutting_down: Dispatchable_MaybeShuttingDown) {
unsafe {

View File

@@ -382,7 +382,7 @@ impl BackgroundHangMonitorExitSignal for BHMExitSignal {
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn interrupt_callback(_cx: *mut UnsafeJSContext) -> bool {
let res = ScriptThread::can_continue_running();
if !res {
@@ -1003,7 +1003,7 @@ impl ScriptThread {
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) fn get_cx(&self) -> JSContext {
unsafe { JSContext::from_ptr(self.js_runtime.cx()) }
}

View File

@@ -80,7 +80,7 @@ impl ServiceWorker {
}
/// When updating a registration, which worker are we targetting?
#[allow(dead_code)]
#[expect(dead_code)]
enum RegistrationUpdateTarget {
Installing,
Waiting,

View File

@@ -15,9 +15,9 @@ macro_rules! task {
$($field: $field_type,)*
task: F,
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl<F> crate::JSTraceable for $name<F> {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe fn trace(&self, tracer: *mut ::js::jsapi::JSTracer) {
$(self.$field.trace(tracer);)*
// We cannot trace the actual task closure. This is safe because

View File

@@ -320,7 +320,7 @@ fn all_matching_links(
.map(|nodes| matching_links(&nodes, link_text, partial).collect())
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn object_has_to_json_property(
cx: SafeJSContext,
global_scope: &GlobalScope,
@@ -345,7 +345,7 @@ fn object_has_to_json_property(
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
/// <https://w3c.github.io/webdriver/#dfn-collection>
fn is_arguments_object(cx: SafeJSContext, value: HandleValue) -> bool {
rooted!(in(*cx) let class_name = unsafe { ToString(*cx, value) });
@@ -382,7 +382,7 @@ pub(crate) fn jsval_to_webdriver(
result
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
/// <https://w3c.github.io/webdriver/#dfn-internal-json-clone>
fn jsval_to_webdriver_inner(
cx: SafeJSContext,
@@ -485,7 +485,7 @@ fn jsval_to_webdriver_inner(
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
/// <https://w3c.github.io/webdriver/#dfn-clone-an-object>
fn clone_an_object(
cx: SafeJSContext,
@@ -1726,7 +1726,6 @@ pub(crate) fn handle_get_attribute(
.unwrap();
}
#[allow(unsafe_code)]
pub(crate) fn handle_get_property(
documents: &DocumentCollection,
pipeline: PipelineId,

View File

@@ -33,9 +33,9 @@ use crate::js::conversions::ToJSValConvertible;
use crate::script_runtime::JSContext as SafeJSContext;
struct SyncWrapper(*const libc::c_void);
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl Sync for SyncWrapper {}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl Send for SyncWrapper {}
static HANDLER: LazyLock<SyncWrapper> = LazyLock::new(|| {
@@ -72,13 +72,13 @@ static HANDLER: LazyLock<SyncWrapper> = LazyLock::new(|| {
isConstructor: None,
};
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe {
SyncWrapper(CreateProxyHandler(&traps, ptr::null()))
}
});
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn get_own_property_descriptor(
cx: *mut JSContext,
proxy: HandleObject,
@@ -154,7 +154,7 @@ unsafe extern "C" fn get_own_property_descriptor(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn own_property_keys(
cx: *mut JSContext,
_proxy: HandleObject,
@@ -170,7 +170,7 @@ unsafe extern "C" fn own_property_keys(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn define_property(
_cx: *mut JSContext,
_proxy: HandleObject,
@@ -184,7 +184,7 @@ unsafe extern "C" fn define_property(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn delete(
_cx: *mut JSContext,
_proxy: HandleObject,
@@ -197,7 +197,7 @@ unsafe extern "C" fn delete(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn get_prototype_if_ordinary(
_cx: *mut JSContext,
proxy: HandleObject,
@@ -211,7 +211,7 @@ unsafe extern "C" fn get_prototype_if_ordinary(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn prevent_extensions(
_cx: *mut JSContext,
_proxy: HandleObject,
@@ -223,7 +223,7 @@ unsafe extern "C" fn prevent_extensions(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn is_extensible(
_cx: *mut JSContext,
_proxy: HandleObject,
@@ -235,13 +235,13 @@ unsafe extern "C" fn is_extensible(
true
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn class_name(_cx: *mut JSContext, _proxy: HandleObject) -> *const libc::c_char {
c"WindowProperties".as_ptr()
}
// Maybe this should be a DOMJSClass. See https://bugzilla.mozilla.org/show_bug.cgi?id=787070
#[allow(unsafe_code)]
#[expect(unsafe_code)]
static CLASS: JSClass = JSClass {
name: c"WindowProperties".as_ptr(),
flags: JSClass_NON_NATIVE |
@@ -254,7 +254,7 @@ static CLASS: JSClass = JSClass {
oOps: unsafe { &ProxyObjectOps },
};
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) fn create(
cx: SafeJSContext,
proto: RustHandleObject,

View File

@@ -94,7 +94,7 @@ impl<D: DomTypes> CallbackObject<D> {
self.callback.get()
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe fn init(&mut self, cx: JSContext, callback: *mut JSObject) {
self.callback.set(callback);
self.permanent_js_root.set(ObjectValue(callback));
@@ -109,7 +109,7 @@ impl<D: DomTypes> CallbackObject<D> {
}
impl<D: DomTypes> Drop for CallbackObject<D> {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn drop(&mut self) {
unsafe {
if let Some(cx) = Runtime::get() {

View File

@@ -25,7 +25,7 @@ pub struct ConstantSpec {
/// Representation of an IDL constant value.
#[derive(Clone)]
#[allow(dead_code)]
#[expect(dead_code)]
pub enum ConstantVal {
/// `long` constant.
Int(i32),

View File

@@ -397,7 +397,7 @@ where
if !v.get().is_object() {
return Err(());
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe {
root_from_object(v.get().to_object(), *cx)
}
@@ -506,7 +506,7 @@ where
return Err(());
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe {
native_from_object(v.get().to_object(), *cx)
}

View File

@@ -78,7 +78,6 @@ enum DOMStringType {
}
impl DOMStringType {
#[allow(unused)]
/// Returns the str if Rust and otherwise panic. You need to call `make_rust`.
fn str(&self) -> &str {
match self {
@@ -378,7 +377,7 @@ impl DOMString {
}
/// Debug the current state of the string without modifying it.
#[allow(unused)]
#[expect(unused)]
fn debug_js(&self) {
match *self.0.borrow() {
DOMStringType::Rust(ref s) => info!("Rust String ({})", s),

View File

@@ -65,7 +65,7 @@ pub trait DomHelpers<D: DomTypes> {
}
/// Operations that must be invoked from the generated bindings.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub trait GlobalScopeHelpers<D: DomTypes> {
/// # Safety
/// `cx` must point to a valid, non-null RawJSContext.

View File

@@ -11,7 +11,7 @@ use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
/// Used by codegen to include the pointer to the `MallocSizeOf` implementation of each
/// IDL interface. This way we don't have to find the most-derived interface of DOM
/// objects by hand in code.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(crate) unsafe fn malloc_size_of_including_raw_self<T: MallocSizeOf>(
ops: &mut MallocSizeOfOps,
obj: *const c_void,

View File

@@ -12,7 +12,7 @@ use js::jsapi::JSContext as RawJSContext;
#[repr(transparent)]
pub struct JSContext(*mut RawJSContext);
#[allow(unsafe_code)]
#[expect(unsafe_code)]
impl JSContext {
/// Create a new [`JSContext`] object from the given raw pointer.
///
@@ -24,7 +24,6 @@ impl JSContext {
}
}
#[allow(unsafe_code)]
impl Deref for JSContext {
type Target = *mut RawJSContext;

View File

@@ -30,7 +30,7 @@ pub struct StackEntry<D: DomTypes> {
pub struct GenericAutoEntryScript<D: DomTypes> {
global: DomRoot<D::GlobalScope>,
#[cfg(feature = "tracing")]
#[allow(dead_code)]
#[expect(dead_code)]
span: tracing::span::EnteredSpan,
}

View File

@@ -165,7 +165,7 @@ pub fn serialize_jsval_to_json_utf8(cx: JSContext, data: HandleValue) -> Result<
let mut out_str = ToJSONCallbackData { string: None };
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe extern "C" fn write_callback(
string: *const u16,
len: u32,

View File

@@ -71,7 +71,7 @@ pub(crate) unsafe fn trace_object(
macro_rules! unsafe_no_jsmanaged_fields(
($($ty:ty),+) => (
$(
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl crate::JSTraceable for $ty {
#[inline]
unsafe fn trace(&self, _: *mut ::js::jsapi::JSTracer) {
@@ -288,7 +288,7 @@ unsafe impl<Handle: JSTraceable + Clone, Sink: TreeSink<Handle = Handle> + JSTra
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl<Handle: JSTraceable + Clone, Sink: TokenSink<Handle = Handle> + CustomTraceable>
CustomTraceable for Tokenizer<Sink>
{
@@ -297,7 +297,7 @@ unsafe impl<Handle: JSTraceable + Clone, Sink: TokenSink<Handle = Handle> + Cust
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl<Handle: JSTraceable + Clone, Sink: JSTraceable + XmlTreeSink<Handle = Handle>>
CustomTraceable for XmlTokenizer<XmlTreeBuilder<Handle, Sink>>
{
@@ -407,7 +407,7 @@ impl<T> From<T> for NoTrace<T> {
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl<T> JSTraceable for NoTrace<T> {
#[inline]
unsafe fn trace(&self, _: *mut ::js::jsapi::JSTracer) {}

View File

@@ -18,7 +18,6 @@ use servo::{
pub struct ServoTest {
pub servo: Rc<Servo>,
#[allow(dead_code)]
pub rendering_context: Rc<dyn RenderingContext>,
}
@@ -84,7 +83,6 @@ impl ServoTest {
/// any longer.
// The dead code exception here is because not all test suites that use `common` also
// use `spin()`.
#[allow(dead_code)]
pub fn spin(&self, callback: impl Fn() -> bool + 'static) {
while callback() {
std::thread::sleep(Duration::from_millis(1));

View File

@@ -9,7 +9,7 @@
//! of `assert!` for test assertions. `ensure!` will produce a `Result::Err` in
//! place of panicking.
#[allow(dead_code)]
#[expect(dead_code)]
mod common;
use std::rc::Rc;

View File

@@ -9,7 +9,7 @@
//! of `assert!` for test assertions. `ensure!` will produce a `Result::Err` in
//! place of panicking.
#[allow(dead_code)]
#[expect(dead_code)]
mod common;
use common::ServoTest;

View File

@@ -75,7 +75,7 @@ impl Sub<Duration> for CrossProcessInstant {
mod platform {
use libc::timespec;
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(super) fn now() -> u64 {
// SAFETY: libc::timespec is zero initializable.
let time = unsafe {
@@ -93,7 +93,7 @@ mod platform {
use mach2::mach_time::{mach_absolute_time, mach_timebase_info};
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn timebase_info() -> &'static mach_timebase_info {
static TIMEBASE_INFO: LazyLock<mach_timebase_info> = LazyLock::new(|| {
let mut timebase_info = mach_timebase_info { numer: 0, denom: 0 };
@@ -103,7 +103,7 @@ mod platform {
&TIMEBASE_INFO
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub(super) fn now() -> u64 {
let timebase_info = timebase_info();
let absolute_time = unsafe { mach_absolute_time() };
@@ -122,7 +122,7 @@ mod platform {
/// The frequency of the value returned by `QueryPerformanceCounter` in counts per
/// second. This is taken from the Rust source code at:
/// <https://github.com/rust-lang/rust/blob/1a1cc050d8efc906ede39f444936ade1fdc9c6cb/library/std/src/sys/pal/windows/time.rs#L197>
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn frequency() -> i64 {
// Either the cached result of `QueryPerformanceFrequency` or `0` for
// uninitialized. Storing this as a single `AtomicU64` allows us to use
@@ -147,7 +147,7 @@ mod platform {
frequency
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
/// Get the current instant value in nanoseconds.
/// Originally from: <https://github.com/rust-lang/rust/blob/1a1cc050d8efc906ede39f444936ade1fdc9c6cb/library/std/src/sys/pal/windows/time.rs#L175>
pub(super) fn now() -> u64 {

View File

@@ -118,7 +118,7 @@ impl<'de, T: Serialize + Deserialize<'de>> serde::de::Visitor<'de> for GenericSe
let ptr = addr as *mut crossbeam_channel::Sender<Result<T, ipc_channel::Error>>;
// SAFETY: We know we are in the same address space as the sender, so we can safely
// reconstruct the Box.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let sender = unsafe { Box::from_raw(ptr) };
Ok(GenericSender(GenericSenderVariants::Crossbeam(*sender)))
},
@@ -392,7 +392,7 @@ where
let ptr = addr as *mut RoutedReceiver<T>;
// SAFETY: We know we are in the same address space as the sender, so we can safely
// reconstruct the Box.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let receiver = unsafe { Box::from_raw(ptr) };
Ok(GenericReceiver(GenericReceiverVariants::Crossbeam(
*receiver,

View File

@@ -244,7 +244,7 @@ where
// serialization.
// Attention: Code reviewers should carefully compare the deserialization here
// with the serialization above.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let callback = unsafe { Box::from_raw(ptr) };
Ok(GenericCallback(GenericCallbackVariants::InProcess(
*callback,

View File

@@ -259,7 +259,7 @@ impl PipelineId {
}
impl From<WebRenderPipelineId> for PipelineId {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn from(pipeline: WebRenderPipelineId) -> Self {
let WebRenderPipelineId(namespace_id, index) = pipeline;
unsafe {

View File

@@ -617,7 +617,6 @@ macro_rules! define_resource_id {
}
}
#[allow(unsafe_code)]
impl<'de> ::serde::Deserialize<'de> for $name {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where

View File

@@ -119,7 +119,7 @@ impl SurfmanRenderingContext {
device.create_context_descriptor(&ContextAttributes { flags, version })?;
let context = device.create_context(&context_descriptor, None)?;
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let gleam_gl = {
match gl_api {
GLApi::GL => unsafe {
@@ -131,7 +131,7 @@ impl SurfmanRenderingContext {
}
};
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let glow_gl = unsafe {
glow::Context::from_loader_function(|function_name| {
device.get_proc_address(&context, function_name)
@@ -199,7 +199,7 @@ impl SurfmanRenderingContext {
})
}
#[allow(dead_code)]
#[expect(dead_code)]
fn native_context(&self) -> NativeContext {
let device = &self.device.borrow();
let context = &self.context.borrow();
@@ -710,7 +710,7 @@ impl OffscreenRenderingContext {
}))
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn blit_framebuffer(
gl: &glow::Context,
source_rect: Rect<i32>,
@@ -841,7 +841,7 @@ mod test {
use super::Framebuffer;
#[test]
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn test_read_pixels() -> Result<(), Error> {
let connection = Connection::new()?;
let adapter = connection.create_software_adapter()?;

View File

@@ -1065,7 +1065,7 @@ pub struct UntrustedNodeAddress(pub *const c_void);
malloc_size_of_is_0!(UntrustedNodeAddress);
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl Send for UntrustedNodeAddress {}
impl From<style_traits::dom::OpaqueNode> for UntrustedNodeAddress {

View File

@@ -64,7 +64,7 @@ mod platform {
}
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub fn font_data_and_index(&self) -> Option<FontDataAndIndex> {
let file = File::open(Path::new(&*self.path)).ok()?;
let mmap = unsafe { Mmap::map(&file).ok()? };
@@ -126,7 +126,7 @@ mod platform {
0
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
pub fn font_data_and_index(&self) -> Option<FontDataAndIndex> {
let file = File::open(Path::new(&*self.path)).ok()?;
let mmap = unsafe { Mmap::map(&file).ok()? };

View File

@@ -144,7 +144,7 @@ pub struct SVGElementData {
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct TrustedNodeAddress(pub *const c_void);
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe impl Send for TrustedNodeAddress {}
/// Whether the pending image needs to be fetched or is waiting on an existing fetch.

View File

@@ -772,7 +772,6 @@ pub struct ResourceFetchTiming {
}
pub enum RedirectStartValue {
#[allow(dead_code)]
Zero,
FetchStart,
}

View File

@@ -150,7 +150,6 @@ impl PartialEq for IndexedDBKeyType {
// <https://www.w3.org/TR/IndexedDB-2/#key-range>
#[derive(Clone, Debug, Default, Deserialize, MallocSizeOf, Serialize)]
#[allow(unused)]
pub struct IndexedDBKeyRange {
pub lower: Option<IndexedDBKeyType>,
pub upper: Option<IndexedDBKeyType>,

View File

@@ -374,7 +374,7 @@ where
if let Some(layers) = self.pending_layers.take() {
self.layers = layers;
}
#[allow(unused_mut)]
#[expect(unused_mut)]
let mut frame = match self.device.begin_animation_frame(&self.layers[..]) {
Some(frame) => frame,
None => {

View File

@@ -21,7 +21,6 @@ pub struct KvsOperation {
pub struct KvsTransaction {
// Mode could be used by a more optimal implementation of transactions
// that has different allocated threadpools for reading and writing
#[allow(unused)]
pub mode: IndexedDBTxnMode,
pub requests: VecDeque<KvsOperation>,
}

View File

@@ -13,7 +13,7 @@ pub enum Column {
Version,
}
#[allow(dead_code)]
#[expect(dead_code)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Model {
pub name: String,

View File

@@ -15,7 +15,7 @@ pub enum Column {
MultiEntryIndex,
}
#[allow(dead_code)]
#[expect(dead_code)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Model {
pub id: i32,

View File

@@ -65,7 +65,7 @@ pub(crate) enum InputSourceState {
/// <https://w3c.github.io/webdriver/#dfn-pointer-input-source>
/// TODO: subtype is used for <https://w3c.github.io/webdriver/#dfn-get-a-pointer-id>
/// Need to add pointer-id to the following struct
#[allow(dead_code)]
#[expect(dead_code)]
pub(crate) struct PointerInputState {
subtype: PointerType,
pressed: FxHashSet<u64>,

View File

@@ -216,7 +216,7 @@ trait GLExt {
macro_rules! create_fun {
($tryer:ident, $getter:ident, $gltype:ty, $glcall:ident, $rstype:ty) => {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
fn $tryer(self, parameter: GLenum) -> Option<$rstype> {
let mut value = [<$gltype>::default()];
unsafe {

View File

@@ -840,7 +840,7 @@ impl WebGLThread {
self.update_webrender_image_for_context(context_id, size, has_alpha, canvas_epoch);
}
#[allow(unused)]
#[expect(unused)]
let mut end_swap = 0;
}

View File

@@ -44,7 +44,6 @@ impl WebXRBridge {
}
impl WebXRBridge {
#[allow(unsafe_code)]
pub(crate) fn create_layer_manager(
&mut self,
device: &mut Device,

View File

@@ -128,7 +128,7 @@ fn get_matching_adapter(
}
}
#[allow(unused)]
#[expect(unused)]
pub fn create_surfman_adapter() -> Option<SurfmanAdapter> {
let instance = create_instance(false, false, false, &AppInfo::default()).ok()?;
let system = instance

View File

@@ -123,7 +123,7 @@ pub struct OpenXRInput {
click_state: ClickState,
squeeze_state: ClickState,
menu_gesture_sustain: u8,
#[allow(unused)]
#[expect(unused)]
hand_tracker: Option<HandTracker>,
action_buttons_common: Vec<Action<f32>>,
action_buttons_left: Vec<Action<f32>>,

View File

@@ -47,7 +47,7 @@ pub enum InteractionProfileType {
#[derive(Clone, Copy, Debug)]
pub struct InteractionProfile<'a> {
#[allow(dead_code)]
#[expect(dead_code)]
pub profile_type: InteractionProfileType,
/// The interaction profile path
pub path: &'static str,