From 1d38bc041967b88838ed7b006aab9908e2f24474 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 19 Jun 2019 16:07:13 +0200 Subject: [PATCH] Fix some new warnings --- .../background_hang_monitor.rs | 10 ++--- components/background_hang_monitor/sampler.rs | 2 +- .../background_hang_monitor/sampler_linux.rs | 2 +- .../background_hang_monitor/sampler_mac.rs | 2 +- .../sampler_windows.rs | 2 +- components/canvas/azure_backend.rs | 20 +++++----- components/canvas/canvas_data.rs | 38 +++++++++---------- components/canvas/raqote_backend.rs | 18 ++++----- components/compositing/compositor_thread.rs | 2 +- components/compositing/windowing.rs | 2 +- components/config/pref_util.rs | 4 +- components/constellation/constellation.rs | 2 +- components/constellation/pipeline.rs | 8 ++-- components/embedder_traits/lib.rs | 4 +- components/embedder_traits/resources.rs | 7 ++-- components/gfx/text/util.rs | 4 +- components/layout_thread/lib.rs | 6 +-- components/layout_traits/lib.rs | 2 +- components/malloc_size_of/lib.rs | 2 +- components/msg/constellation_msg.rs | 8 ++-- components/net/decoder.rs | 2 +- components/net/http_loader.rs | 2 +- components/script/dom/bindings/str.rs | 2 +- components/script/dom/bindings/xmlname.rs | 34 ++++++++--------- .../script/dom/dedicatedworkerglobalscope.rs | 4 +- components/script/dom/headers.rs | 4 +- components/script/dom/htmlareaelement.rs | 2 +- components/script/dom/htmlcollection.rs | 2 +- components/script/dom/htmlimageelement.rs | 2 +- components/script/dom/htmlmediaelement.rs | 4 +- components/script/dom/htmlscriptelement.rs | 2 +- .../script/dom/paintworkletglobalscope.rs | 2 +- components/script/dom/promisenativehandler.rs | 4 +- components/script/dom/rtcpeerconnection.rs | 2 +- components/script/dom/window.rs | 4 +- components/script/dom/xmlhttprequest.rs | 2 +- components/script/lib.rs | 1 - components/script/script_thread.rs | 10 ++--- components/script_layout_interface/message.rs | 2 +- .../script_plugins/webidl_must_inherit.rs | 6 +-- components/script_traits/lib.rs | 2 +- components/selectors/context.rs | 2 +- components/servo/lib.rs | 2 +- components/style/animation.rs | 4 +- components/style/attr.rs | 10 ++--- components/style/context.rs | 4 +- components/style/encoding_support.rs | 8 ++-- components/style/matching.rs | 2 +- components/style/parser.rs | 6 +-- components/style/properties/cascade.rs | 6 +-- .../style/properties/declaration_block.rs | 4 +- components/style/str.rs | 4 +- components/style/stylesheets/mod.rs | 2 +- components/style/stylesheets/rule_list.rs | 4 +- components/style/stylesheets/rule_parser.rs | 2 +- components/style/stylesheets/stylesheet.rs | 16 ++++---- components/style/stylist.rs | 14 +++---- components/style/values/computed/mod.rs | 2 +- .../style_traits/specified_value_info.rs | 2 +- ports/glutin/app.rs | 6 +-- ports/glutin/embedder.rs | 4 +- ports/libmlservo/src/lib.rs | 2 +- ports/libsimpleservo/api/src/gl_glue.rs | 2 + ports/libsimpleservo/api/src/lib.rs | 4 +- ports/libsimpleservo/jniapi/src/lib.rs | 2 +- 65 files changed, 179 insertions(+), 175 deletions(-) diff --git a/components/background_hang_monitor/background_hang_monitor.rs b/components/background_hang_monitor/background_hang_monitor.rs index f179681ba19..69e9a5d60bd 100644 --- a/components/background_hang_monitor/background_hang_monitor.rs +++ b/components/background_hang_monitor/background_hang_monitor.rs @@ -26,7 +26,7 @@ impl HangMonitorRegister { pub fn init( constellation_chan: IpcSender, control_port: IpcReceiver, - ) -> Box { + ) -> Box { let (sender, port) = unbounded(); let _ = thread::Builder::new().spawn(move || { let mut monitor = @@ -48,7 +48,7 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister { component_id: MonitoredComponentId, transient_hang_timeout: Duration, permanent_hang_timeout: Duration, - ) -> Box { + ) -> Box { let bhm_chan = BackgroundHangMonitorChan::new(self.sender.clone(), component_id); #[cfg(all( @@ -77,7 +77,7 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister { } impl BackgroundHangMonitorClone for HangMonitorRegister { - fn clone_box(&self) -> Box { + fn clone_box(&self) -> Box { Box::new(self.clone()) } } @@ -85,7 +85,7 @@ impl BackgroundHangMonitorClone for HangMonitorRegister { /// Messages sent from monitored components to the monitor. pub enum MonitoredComponentMsg { /// Register component for monitoring, - Register(Box, Option, Duration, Duration), + Register(Box, Option, Duration, Duration), /// Unregister component for monitoring. Unregister, /// Notify start of new activity for a given component, @@ -142,7 +142,7 @@ impl BackgroundHangMonitor for BackgroundHangMonitorChan { } struct MonitoredComponent { - sampler: Box, + sampler: Box, last_activity: Instant, last_annotation: Option, transient_hang_timeout: Duration, diff --git a/components/background_hang_monitor/sampler.rs b/components/background_hang_monitor/sampler.rs index 7a01bc51f20..c45e81bfd2c 100644 --- a/components/background_hang_monitor/sampler.rs +++ b/components/background_hang_monitor/sampler.rs @@ -17,7 +17,7 @@ pub struct DummySampler; impl DummySampler { #[allow(dead_code)] - pub fn new() -> Box { + pub fn new() -> Box { Box::new(DummySampler) } } diff --git a/components/background_hang_monitor/sampler_linux.rs b/components/background_hang_monitor/sampler_linux.rs index 5d981570a1d..793783fc109 100644 --- a/components/background_hang_monitor/sampler_linux.rs +++ b/components/background_hang_monitor/sampler_linux.rs @@ -128,7 +128,7 @@ pub struct LinuxSampler { impl LinuxSampler { #[allow(unsafe_code, dead_code)] - pub fn new() -> Box { + pub fn new() -> Box { let thread_id = unsafe { libc::syscall(libc::SYS_gettid) as libc::pid_t }; let handler = SigHandler::SigAction(sigprof_handler); let action = SigAction::new( diff --git a/components/background_hang_monitor/sampler_mac.rs b/components/background_hang_monitor/sampler_mac.rs index e9997215c73..e5a575ca3f3 100644 --- a/components/background_hang_monitor/sampler_mac.rs +++ b/components/background_hang_monitor/sampler_mac.rs @@ -16,7 +16,7 @@ pub struct MacOsSampler { impl MacOsSampler { #[allow(unsafe_code)] - pub fn new() -> Box { + pub fn new() -> Box { let thread_id = unsafe { mach::mach_init::mach_thread_self() }; Box::new(MacOsSampler { thread_id }) } diff --git a/components/background_hang_monitor/sampler_windows.rs b/components/background_hang_monitor/sampler_windows.rs index 7bc0fd29f0c..cbc88d42156 100644 --- a/components/background_hang_monitor/sampler_windows.rs +++ b/components/background_hang_monitor/sampler_windows.rs @@ -13,7 +13,7 @@ pub struct WindowsSampler { impl WindowsSampler { #[allow(unsafe_code, dead_code)] - pub fn new() -> Box { + pub fn new() -> Box { let thread_id = 0; // TODO: use winapi::um::processthreadsapi::GetThreadId Box::new(WindowsSampler { thread_id }) } diff --git a/components/canvas/azure_backend.rs b/components/canvas/azure_backend.rs index 037809b5a05..102cddd0565 100644 --- a/components/canvas/azure_backend.rs +++ b/components/canvas/azure_backend.rs @@ -55,7 +55,7 @@ impl Backend for AzureBackend { &mut self, style: FillOrStrokeStyle, state: &mut CanvasPaintState<'a>, - drawtarget: &GenericDrawTarget, + drawtarget: &dyn GenericDrawTarget, ) { if let Some(pattern) = style.to_azure_pattern(drawtarget) { state.fill_style = Pattern::Azure(pattern) @@ -66,7 +66,7 @@ impl Backend for AzureBackend { &mut self, style: FillOrStrokeStyle, state: &mut CanvasPaintState<'a>, - drawtarget: &GenericDrawTarget, + drawtarget: &dyn GenericDrawTarget, ) { if let Some(pattern) = style.to_azure_pattern(drawtarget) { state.stroke_style = Pattern::Azure(pattern) @@ -84,7 +84,7 @@ impl Backend for AzureBackend { .set_composition_op(op.to_azure_style()); } - fn create_drawtarget(&self, size: Size2D) -> Box { + fn create_drawtarget(&self, size: Size2D) -> Box { // FIXME(nox): Why is the size made of i32 values? Box::new(DrawTarget::new( BackendType::Skia, @@ -222,7 +222,7 @@ impl GenericDrawTarget for azure_hl::DrawTarget { GradientStops::Azure(self.create_gradient_stops(&gradient_stops, extend_mode.into_azure())) } - fn create_path_builder(&self) -> Box { + fn create_path_builder(&self) -> Box { Box::new(self.create_path_builder()) } @@ -230,7 +230,7 @@ impl GenericDrawTarget for azure_hl::DrawTarget { &self, size: &Size2D, format: SurfaceFormat, - ) -> Box { + ) -> Box { Box::new(self.create_similar_draw_target(size, format.into_azure())) } fn create_source_surface_from_data( @@ -378,7 +378,7 @@ impl GenericDrawTarget for azure_hl::DrawTarget { } #[allow(unsafe_code)] - fn snapshot_data(&self, f: &Fn(&[u8]) -> Vec) -> Vec { + fn snapshot_data(&self, f: &dyn Fn(&[u8]) -> Vec) -> Vec { unsafe { f(self.snapshot().get_data_surface().data()) } } @@ -619,11 +619,11 @@ impl ToAzureStyle for CompositionOrBlending { } pub trait ToAzurePattern { - fn to_azure_pattern(&self, drawtarget: &GenericDrawTarget) -> Option; + fn to_azure_pattern(&self, drawtarget: &dyn GenericDrawTarget) -> Option; } impl ToAzurePattern for FillOrStrokeStyle { - fn to_azure_pattern(&self, drawtarget: &GenericDrawTarget) -> Option { + fn to_azure_pattern(&self, drawtarget: &dyn GenericDrawTarget) -> Option { Some(match *self { FillOrStrokeStyle::Color(ref color) => { azure_hl::Pattern::Color(ColorPattern::new(color.to_azure_style())) @@ -747,7 +747,7 @@ impl Path { pub fn transformed_copy_to_builder( &self, transform: &Transform2D, - ) -> Box { + ) -> Box { Box::new(self.as_azure().transformed_copy_to_builder(transform)) } @@ -755,7 +755,7 @@ impl Path { self.as_azure().contains_point(x, y, path_transform) } - pub fn copy_to_builder(&self) -> Box { + pub fn copy_to_builder(&self) -> Box { Box::new(self.as_azure().copy_to_builder()) } } diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index eb2cf963e70..79adbee7df8 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -26,9 +26,9 @@ enum PathState { /// Path builder in user-space. If a transform has been applied /// but no further path operations have occurred, it is stored /// in the optional field. - UserSpacePathBuilder(Box, Option>), + UserSpacePathBuilder(Box, Option>), /// Path builder in device-space. - DeviceSpacePathBuilder(Box), + DeviceSpacePathBuilder(Box), /// Path in user-space. If a transform has been applied but /// but no further path operations have occurred, it is stored /// in the optional field. @@ -61,20 +61,20 @@ pub trait Backend { &mut self, style: FillOrStrokeStyle, state: &mut CanvasPaintState<'a>, - drawtarget: &GenericDrawTarget, + drawtarget: &dyn GenericDrawTarget, ); fn set_stroke_style<'a>( &mut self, style: FillOrStrokeStyle, state: &mut CanvasPaintState<'a>, - drawtarget: &GenericDrawTarget, + drawtarget: &dyn GenericDrawTarget, ); fn set_global_composition<'a>( &mut self, op: CompositionOrBlending, state: &mut CanvasPaintState<'a>, ); - fn create_drawtarget(&self, size: Size2D) -> Box; + fn create_drawtarget(&self, size: Size2D) -> Box; fn recreate_paint_state<'a>(&self, state: &CanvasPaintState<'a>) -> CanvasPaintState<'a>; fn size_from_pattern(&self, rect: &Rect, pattern: &Pattern) -> Option>; } @@ -117,7 +117,7 @@ pub trait GenericPathBuilder { /// A wrapper around a stored PathBuilder and an optional transformation that should be /// applied to any points to ensure they are in the matching device space. struct PathBuilderRef<'a> { - builder: &'a Box, + builder: &'a Box, transform: Transform2D, } @@ -215,12 +215,12 @@ pub trait GenericDrawTarget { gradient_stops: Vec, extend_mode: ExtendMode, ) -> GradientStops; - fn create_path_builder(&self) -> Box; + fn create_path_builder(&self) -> Box; fn create_similar_draw_target( &self, size: &Size2D, format: SurfaceFormat, - ) -> Box; + ) -> Box; fn create_source_surface_from_data( &self, data: &[u8], @@ -275,7 +275,7 @@ pub trait GenericDrawTarget { stroke_options: &StrokeOptions, draw_options: &DrawOptions, ); - fn snapshot_data(&self, f: &Fn(&[u8]) -> Vec) -> Vec; + fn snapshot_data(&self, f: &dyn Fn(&[u8]) -> Vec) -> Vec; fn snapshot_data_owned(&self) -> Vec; } @@ -377,8 +377,8 @@ pub enum Filter { } pub struct CanvasData<'a> { - backend: Box, - drawtarget: Box, + backend: Box, + drawtarget: Box, path_state: Option, state: CanvasPaintState<'a>, saved_states: Vec>, @@ -392,12 +392,12 @@ pub struct CanvasData<'a> { } #[cfg(feature = "azure_backend")] -fn create_backend() -> Box { +fn create_backend() -> Box { Box::new(crate::azure_backend::AzureBackend) } #[cfg(feature = "raqote_backend")] -fn create_backend() -> Box { +fn create_backend() -> Box { Box::new(crate::raqote_backend::RaqoteBackend) } @@ -442,7 +442,7 @@ impl<'a> CanvasData<'a> { image_data.into() }; - let writer = |draw_target: &GenericDrawTarget| { + let writer = |draw_target: &dyn GenericDrawTarget| { write_image( draw_target, image_data, @@ -498,7 +498,7 @@ impl<'a> CanvasData<'a> { ); if self.need_to_draw_shadow() { - self.draw_with_shadow(&draw_rect, |new_draw_target: &GenericDrawTarget| { + self.draw_with_shadow(&draw_rect, |new_draw_target: &dyn GenericDrawTarget| { new_draw_target.fill_rect( &draw_rect, self.state.fill_style.clone(), @@ -524,7 +524,7 @@ impl<'a> CanvasData<'a> { } if self.need_to_draw_shadow() { - self.draw_with_shadow(&rect, |new_draw_target: &GenericDrawTarget| { + self.draw_with_shadow(&rect, |new_draw_target: &dyn GenericDrawTarget| { new_draw_target.stroke_rect( rect, self.state.stroke_style.clone(), @@ -1023,7 +1023,7 @@ impl<'a> CanvasData<'a> { self.state.shadow_blur != 0.0f64) } - fn create_draw_target_for_shadow(&self, source_rect: &Rect) -> Box { + fn create_draw_target_for_shadow(&self, source_rect: &Rect) -> Box { let draw_target = self.drawtarget.create_similar_draw_target( &Size2D::new( source_rect.size.width as i32, @@ -1040,7 +1040,7 @@ impl<'a> CanvasData<'a> { fn draw_with_shadow(&self, rect: &Rect, draw_shadow_source: F) where - F: FnOnce(&GenericDrawTarget), + F: FnOnce(&dyn GenericDrawTarget), { let shadow_src_rect = self.state.transform.transform_rect(rect); let new_draw_target = self.create_draw_target_for_shadow(&shadow_src_rect); @@ -1116,7 +1116,7 @@ pub struct CanvasPaintState<'a> { /// dest_rect: Area of the destination target where the pixels will be copied /// smoothing_enabled: It determines if smoothing is applied to the image result fn write_image( - draw_target: &GenericDrawTarget, + draw_target: &dyn GenericDrawTarget, image_data: Vec, image_size: Size2D, dest_rect: Rect, diff --git a/components/canvas/raqote_backend.rs b/components/canvas/raqote_backend.rs index 6e49026606e..482ee4090c8 100644 --- a/components/canvas/raqote_backend.rs +++ b/components/canvas/raqote_backend.rs @@ -36,7 +36,7 @@ impl Backend for RaqoteBackend { &mut self, _style: FillOrStrokeStyle, _state: &mut CanvasPaintState<'a>, - _drawtarget: &GenericDrawTarget, + _drawtarget: &dyn GenericDrawTarget, ) { unimplemented!() } @@ -45,7 +45,7 @@ impl Backend for RaqoteBackend { &mut self, _style: FillOrStrokeStyle, _state: &mut CanvasPaintState<'a>, - _drawtarget: &GenericDrawTarget, + _drawtarget: &dyn GenericDrawTarget, ) { unimplemented!() } @@ -58,7 +58,7 @@ impl Backend for RaqoteBackend { unimplemented!() } - fn create_drawtarget(&self, size: Size2D) -> Box { + fn create_drawtarget(&self, size: Size2D) -> Box { Box::new(raqote::DrawTarget::new( size.width as i32, size.height as i32, @@ -121,7 +121,7 @@ impl Path { pub fn transformed_copy_to_builder( &self, _transform: &Transform2D, - ) -> Box { + ) -> Box { unimplemented!() } @@ -129,7 +129,7 @@ impl Path { unimplemented!() } - pub fn copy_to_builder(&self) -> Box { + pub fn copy_to_builder(&self) -> Box { unimplemented!() } } @@ -156,7 +156,7 @@ impl GenericDrawTarget for raqote::DrawTarget { unimplemented!() } - fn create_path_builder(&self) -> Box { + fn create_path_builder(&self) -> Box { unimplemented!() } @@ -164,7 +164,7 @@ impl GenericDrawTarget for raqote::DrawTarget { &self, _size: &Size2D, _format: SurfaceFormat, - ) -> Box { + ) -> Box { unimplemented!() } fn create_source_surface_from_data( @@ -246,13 +246,13 @@ impl GenericDrawTarget for raqote::DrawTarget { &self, _rect: &Rect, _pattern: Pattern, - _stroke_options: &StrokeOptions, + _stroke_options: &StrokeOptions<'_>, _draw_options: &DrawOptions, ) { unimplemented!() } - fn snapshot_data(&self, _f: &Fn(&[u8]) -> Vec) -> Vec { + fn snapshot_data(&self, _f: &dyn Fn(&[u8]) -> Vec) -> Vec { unimplemented!() } diff --git a/components/compositing/compositor_thread.rs b/components/compositing/compositor_thread.rs index 1a7ee9309cb..9e8a4e1f668 100644 --- a/components/compositing/compositor_thread.rs +++ b/components/compositing/compositor_thread.rs @@ -154,5 +154,5 @@ pub struct InitialCompositorState { pub webrender: webrender::Renderer, pub webrender_document: webrender_api::DocumentId, pub webrender_api: webrender_api::RenderApi, - pub webvr_heartbeats: Vec>, + pub webvr_heartbeats: Vec>, } diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index 21592419875..f925c2f5473 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -166,7 +166,7 @@ pub trait EmbedderMethods { fn register_vr_services( &mut self, _: &mut VRServiceManager, - _: &mut Vec>, + _: &mut Vec>, ) { } } diff --git a/components/config/pref_util.rs b/components/config/pref_util.rs index 3083e39b9f5..152719209bb 100644 --- a/components/config/pref_util.rs +++ b/components/config/pref_util.rs @@ -171,8 +171,8 @@ impl fmt::Display for PrefError { impl std::error::Error for PrefError {} pub struct Accessor { - pub getter: Box V + Sync>, - pub setter: Box, + pub getter: Box V + Sync>, + pub setter: Box, } impl Accessor { diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 2c5b2b6c603..6f8bfbcb849 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -227,7 +227,7 @@ pub struct Constellation { /// A handle to register components for hang monitoring. /// None when in multiprocess mode. - background_monitor_register: Option>, + background_monitor_register: Option>, /// Channels to control all sampling profilers. sampling_profiler_control: Vec>, diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index b89ce8a259c..4cc4462a4ca 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -121,7 +121,7 @@ pub struct InitialPipelineState { /// A handle to register components for hang monitoring. /// None when in multiprocess mode. - pub background_monitor_register: Option>, + pub background_monitor_register: Option>, /// A channel for the background hang monitor to send messages to the constellation. pub background_hang_monitor_to_constellation_chan: IpcSender, @@ -516,7 +516,7 @@ impl UnprivilegedPipelineContent { pub fn start_all( self, wait_for_completion: bool, - background_hang_monitor_register: Box, + background_hang_monitor_register: Box, ) where LTF: LayoutThreadFactory, STF: ScriptThreadFactory, @@ -704,7 +704,9 @@ impl UnprivilegedPipelineContent { } } - pub fn register_with_background_hang_monitor(&mut self) -> Box { + pub fn register_with_background_hang_monitor( + &mut self, + ) -> Box { HangMonitorRegister::init( self.background_hang_monitor_to_constellation_chan.clone(), self.sampling_profiler_port diff --git a/components/embedder_traits/lib.rs b/components/embedder_traits/lib.rs index 29431ebbb63..297972516b6 100644 --- a/components/embedder_traits/lib.rs +++ b/components/embedder_traits/lib.rs @@ -65,14 +65,14 @@ pub enum Cursor { /// Used to wake up the event loop, provided by the servo port/embedder. pub trait EventLoopWaker: 'static + Send { - fn clone(&self) -> Box; + fn clone(&self) -> Box; fn wake(&self); } /// Sends messages to the embedder. pub struct EmbedderProxy { pub sender: Sender<(Option, EmbedderMsg)>, - pub event_loop_waker: Box, + pub event_loop_waker: Box, } impl EmbedderProxy { diff --git a/components/embedder_traits/resources.rs b/components/embedder_traits/resources.rs index e1931765619..a29208fc67c 100644 --- a/components/embedder_traits/resources.rs +++ b/components/embedder_traits/resources.rs @@ -6,10 +6,11 @@ use std::path::PathBuf; use std::sync::{Once, RwLock}; lazy_static! { - static ref RES: RwLock>> = RwLock::new(None); + static ref RES: RwLock>> = + RwLock::new(None); } -pub fn set(reader: Box) { +pub fn set(reader: Box) { *RES.write().unwrap() = Some(reader); } @@ -67,7 +68,7 @@ pub trait ResourceReaderMethods { fn sandbox_access_files_dirs(&self) -> Vec; } -fn resources_for_tests() -> Box { +fn resources_for_tests() -> Box { use std::env; use std::fs::File; use std::io::Read; diff --git a/components/gfx/text/util.rs b/components/gfx/text/util.rs index a5d8cfef3a5..a2644b8b302 100644 --- a/components/gfx/text/util.rs +++ b/components/gfx/text/util.rs @@ -114,8 +114,8 @@ pub fn fixed_to_float(before: usize, f: i32) -> f64 { pub fn is_bidi_control(c: char) -> bool { match c { - '\u{202A}'...'\u{202E}' => true, - '\u{2066}'...'\u{2069}' => true, + '\u{202A}'..='\u{202E}' => true, + '\u{2066}'..='\u{2069}' => true, '\u{200E}' | '\u{200F}' | '\u{061C}' => true, _ => false, } diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 888bc227e87..3e76f02c69e 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -156,7 +156,7 @@ pub struct LayoutThread { font_cache_sender: IpcSender<()>, /// A means of communication with the background hang monitor. - background_hang_monitor: Box, + background_hang_monitor: Box, /// The channel on which messages can be sent to the constellation. constellation_chan: IpcSender, @@ -296,7 +296,7 @@ impl LayoutThreadFactory for LayoutThread { is_iframe: bool, chan: (Sender, Receiver), pipeline_port: IpcReceiver, - background_hang_monitor_register: Box, + background_hang_monitor_register: Box, constellation_chan: IpcSender, script_chan: IpcSender, image_cache: Arc, @@ -520,7 +520,7 @@ impl LayoutThread { is_iframe: bool, port: Receiver, pipeline_port: IpcReceiver, - background_hang_monitor: Box, + background_hang_monitor: Box, constellation_chan: IpcSender, script_chan: IpcSender, image_cache: Arc, diff --git a/components/layout_traits/lib.rs b/components/layout_traits/lib.rs index 4a8a171695c..b0526a4b915 100644 --- a/components/layout_traits/lib.rs +++ b/components/layout_traits/lib.rs @@ -36,7 +36,7 @@ pub trait LayoutThreadFactory { is_iframe: bool, chan: (Sender, Receiver), pipeline_port: IpcReceiver, - background_hang_monitor: Box, + background_hang_monitor: Box, constellation_chan: IpcSender, script_chan: IpcSender, image_cache: Arc, diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index f9d3420c32e..2be7f565a76 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -92,7 +92,7 @@ use void::Void; type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize; /// A closure implementing a stateful predicate on pointers. -type VoidPtrToBoolFnMut = FnMut(*const c_void) -> bool; +type VoidPtrToBoolFnMut = dyn FnMut(*const c_void) -> bool; /// Operations used when measuring heap usage of data structures. pub struct MallocSizeOfOps { diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 6090ff4b3a4..f936a39cf96 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -463,17 +463,17 @@ pub trait BackgroundHangMonitorRegister: BackgroundHangMonitorClone + Send { component: MonitoredComponentId, transient_hang_timeout: Duration, permanent_hang_timeout: Duration, - ) -> Box; + ) -> Box; } -impl Clone for Box { - fn clone(&self) -> Box { +impl Clone for Box { + fn clone(&self) -> Box { self.clone_box() } } pub trait BackgroundHangMonitorClone { - fn clone_box(&self) -> Box; + fn clone_box(&self) -> Box; } /// Proxy methods to communicate with the background hang monitor diff --git a/components/net/decoder.rs b/components/net/decoder.rs index bad25eb10cd..b54035fa4d9 100644 --- a/components/net/decoder.rs +++ b/components/net/decoder.rs @@ -220,7 +220,7 @@ impl Gzip { } #[allow(unsafe_code)] -fn poll_with_read(reader: &mut Read, buf: &mut BytesMut) -> Poll, Error> { +fn poll_with_read(reader: &mut dyn Read, buf: &mut BytesMut) -> Poll, Error> { if buf.remaining_mut() == 0 { buf.reserve(INIT_BUFFER_SIZE); } diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 3f8723ce051..4e27d1fb476 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -1054,7 +1054,7 @@ fn http_network_or_cache_fetch( let forward_response = http_network_fetch(http_request, credentials_flag, done_chan, context); // Substep 3 - if let Some((200...399, _)) = forward_response.raw_status { + if let Some((200..=399, _)) = forward_response.raw_status { if !http_request.method.is_safe() { if let Ok(mut http_cache) = context.state.http_cache.write() { http_cache.invalidate(&http_request, &forward_response); diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs index e08159bc1e2..ad4ce8bc621 100644 --- a/components/script/dom/bindings/str.rs +++ b/components/script/dom/bindings/str.rs @@ -140,7 +140,7 @@ pub fn is_token(s: &[u8]) -> bool { s.iter().all(|&x| { // http://tools.ietf.org/html/rfc2616#section-2.2 match x { - 0...31 | 127 => false, // CTLs + 0..=31 | 127 => false, // CTLs 40 | 41 | 60 | 62 | 64 | 44 | 59 | 58 | 92 | 34 | 47 | 91 | 93 | 63 | 61 | 123 | 125 | 32 => false, // separators x if x > 127 => false, // non-CHARs diff --git a/components/script/dom/bindings/xmlname.rs b/components/script/dom/bindings/xmlname.rs index ab1fe30c8a5..12c10620dd0 100644 --- a/components/script/dom/bindings/xmlname.rs +++ b/components/script/dom/bindings/xmlname.rs @@ -96,21 +96,21 @@ pub fn xml_name_type(name: &str) -> XMLName { fn is_valid_start(c: char) -> bool { match c { ':' | - 'A'...'Z' | + 'A'..='Z' | '_' | - 'a'...'z' | - '\u{C0}'...'\u{D6}' | - '\u{D8}'...'\u{F6}' | - '\u{F8}'...'\u{2FF}' | - '\u{370}'...'\u{37D}' | - '\u{37F}'...'\u{1FFF}' | - '\u{200C}'...'\u{200D}' | - '\u{2070}'...'\u{218F}' | - '\u{2C00}'...'\u{2FEF}' | - '\u{3001}'...'\u{D7FF}' | - '\u{F900}'...'\u{FDCF}' | - '\u{FDF0}'...'\u{FFFD}' | - '\u{10000}'...'\u{EFFFF}' => true, + 'a'..='z' | + '\u{C0}'..='\u{D6}' | + '\u{D8}'..='\u{F6}' | + '\u{F8}'..='\u{2FF}' | + '\u{370}'..='\u{37D}' | + '\u{37F}'..='\u{1FFF}' | + '\u{200C}'..='\u{200D}' | + '\u{2070}'..='\u{218F}' | + '\u{2C00}'..='\u{2FEF}' | + '\u{3001}'..='\u{D7FF}' | + '\u{F900}'..='\u{FDCF}' | + '\u{FDF0}'..='\u{FFFD}' | + '\u{10000}'..='\u{EFFFF}' => true, _ => false, } } @@ -120,10 +120,10 @@ pub fn xml_name_type(name: &str) -> XMLName { match c { '-' | '.' | - '0'...'9' | + '0'..='9' | '\u{B7}' | - '\u{300}'...'\u{36F}' | - '\u{203F}'...'\u{2040}' => true, + '\u{300}'..='\u{36F}' | + '\u{203F}'..='\u{2040}' => true, _ => false, } } diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index 66691a557e1..c3f564e17ff 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -174,9 +174,9 @@ pub struct DedicatedWorkerGlobalScope { worker: DomRefCell>, #[ignore_malloc_size_of = "Can't measure trait objects"] /// Sender to the parent thread. - parent_sender: Box, + parent_sender: Box, #[ignore_malloc_size_of = "Arc"] - image_cache: Arc, + image_cache: Arc, } impl WorkerEventLoopMethods for DedicatedWorkerGlobalScope { diff --git a/components/script/dom/headers.rs b/components/script/dom/headers.rs index 98b24dd1979..2f2af810df8 100644 --- a/components/script/dom/headers.rs +++ b/components/script/dom/headers.rs @@ -499,7 +499,7 @@ fn is_field_vchar(x: u8) -> bool { // https://tools.ietf.org/html/rfc5234#appendix-B.1 pub fn is_vchar(x: u8) -> bool { match x { - 0x21...0x7E => true, + 0x21..=0x7E => true, _ => false, } } @@ -507,7 +507,7 @@ pub fn is_vchar(x: u8) -> bool { // http://tools.ietf.org/html/rfc7230#section-3.2.6 pub fn is_obs_text(x: u8) -> bool { match x { - 0x80...0xFF => true, + 0x80..=0xFF => true, _ => false, } } diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index dfa84bb7ac4..2cbd4ed1e37 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -82,7 +82,7 @@ impl Area { while index < size { let val = num[index]; match val { - b'0'...b'9' | b'.' | b'-' | b'E' | b'e' => break, + b'0'..=b'9' | b'.' | b'-' | b'E' | b'e' => break, _ => {}, } diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 35561285909..6ad41be4652 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -57,7 +57,7 @@ pub struct HTMLCollection { reflector_: Reflector, root: Dom, #[ignore_malloc_size_of = "Contains a trait object; can't measure due to #6870"] - filter: Box, + filter: Box, // We cache the version of the root node and all its decendents, // the length of the collection, and a cursor into the collection. // FIXME: make the cached cursor element a weak pointer diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 62a369579a1..4a9a94dccde 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -210,7 +210,7 @@ impl FetchResponseListener for ImageContext { 0 => Err(NetworkError::Internal( "No http status code received".to_owned(), )), - 200...299 => Ok(()), // HTTP ok status codes + 200..=299 => Ok(()), // HTTP ok status codes _ => Err(NetworkError::Internal(format!( "HTTP error code {}", status_code diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index f39166657c5..690dd928f45 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -227,7 +227,7 @@ pub struct HTMLMediaElement { #[ignore_malloc_size_of = "promises are hard"] in_flight_play_promises_queue: DomRefCell]>, ErrorResult)>>, #[ignore_malloc_size_of = "servo_media"] - player: DomRefCell>>, + player: DomRefCell>>, #[ignore_malloc_size_of = "Arc"] frame_renderer: Arc>, /// https://html.spec.whatwg.org/multipage/#show-poster-flag @@ -1223,7 +1223,7 @@ impl HTMLMediaElement { }; let (action_sender, action_receiver) = ipc::channel().unwrap(); - let renderer: Option>> = match self.media_type_id() { + let renderer: Option>> = match self.media_type_id() { HTMLMediaElementTypeId::HTMLAudioElement => None, HTMLMediaElementTypeId::HTMLVideoElement => Some(self.frame_renderer.clone()), }; diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 8d44c4b9ffd..369f43b6019 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -198,7 +198,7 @@ impl FetchResponseListener for ScriptContext { 0 => Err(NetworkError::Internal( "No http status code received".to_owned(), )), - 200...299 => Ok(()), // HTTP ok status codes + 200..=299 => Ok(()), // HTTP ok status codes _ => Err(NetworkError::Internal(format!( "HTTP error code {}", status_code diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs index 36b57e266f9..7791456294d 100644 --- a/components/script/dom/paintworkletglobalscope.rs +++ b/components/script/dom/paintworkletglobalscope.rs @@ -72,7 +72,7 @@ pub struct PaintWorkletGlobalScope { worklet_global: WorkletGlobalScope, /// The image cache #[ignore_malloc_size_of = "Arc"] - image_cache: Arc, + image_cache: Arc, /// paint_definitions: DomRefCell>>, /// diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 85f08d776e5..147aad57fd5 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -19,8 +19,8 @@ pub trait Callback: JSTraceable + MallocSizeOf { #[dom_struct] pub struct PromiseNativeHandler { reflector: Reflector, - resolve: Option>, - reject: Option>, + resolve: Option>, + reject: Option>, } impl PromiseNativeHandler { diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index 2997698e309..9fbe4b8ce45 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -203,7 +203,7 @@ impl RTCPeerConnection { Ok(RTCPeerConnection::new(&window.global(), config)) } - fn make_signaller(&self) -> Box { + fn make_signaller(&self) -> Box { let trusted = Trusted::new(self); let (task_source, canceller) = self .global() diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index bb0e8198beb..ed87fa5e949 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -174,7 +174,7 @@ pub struct Window { task_manager: TaskManager, navigator: MutNullableDom, #[ignore_malloc_size_of = "Arc"] - image_cache: Arc, + image_cache: Arc, #[ignore_malloc_size_of = "channels are hard"] image_cache_chan: Sender, window_proxy: MutNullableDom, @@ -215,7 +215,7 @@ pub struct Window { /// A handle to perform RPC calls into the layout, quickly. #[ignore_malloc_size_of = "trait objects are hard"] - layout_rpc: Box, + layout_rpc: Box, /// The current size of the window, in pixels. window_size: Cell, diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 583a179e43a..443a0711815 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -1668,7 +1668,7 @@ pub fn is_field_value(slice: &[u8]) -> bool { false } }, - 0...31 | 127 => false, // CTLs + 0..=31 | 127 => false, // CTLs x if x > 127 => false, // non ASCII _ if prev == PreviousCharacter::Other || prev == PreviousCharacter::SPHT => { prev = PreviousCharacter::Other; diff --git a/components/script/lib.rs b/components/script/lib.rs index 88e553bcc1f..9bc2d929b13 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -4,7 +4,6 @@ #![cfg_attr(feature = "unstable", feature(core_intrinsics))] #![cfg_attr(feature = "unstable", feature(on_unimplemented))] -#![feature(borrow_state)] #![feature(const_fn)] #![feature(drain_filter)] #![feature(inner_deref)] diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 90012015b1c..9264b7b9312 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -508,8 +508,8 @@ unsafe_no_jsmanaged_fields!(RefCell); unsafe_no_jsmanaged_fields!(TaskQueue); -unsafe_no_jsmanaged_fields!(BackgroundHangMonitorRegister); -unsafe_no_jsmanaged_fields!(BackgroundHangMonitor); +unsafe_no_jsmanaged_fields!(dyn BackgroundHangMonitorRegister); +unsafe_no_jsmanaged_fields!(dyn BackgroundHangMonitor); #[derive(JSTraceable)] // ScriptThread instances are rooted on creation, so this is okay @@ -540,9 +540,9 @@ pub struct ScriptThread { task_queue: TaskQueue, /// A handle to register associated layout threads for hang-monitoring. - background_hang_monitor_register: Box, + background_hang_monitor_register: Box, /// The dedicated means of communication with the background-hang-monitor for this script-thread. - background_hang_monitor: Box, + background_hang_monitor: Box, /// A channel to hand out to script thread-based entities that need to be able to enqueue /// events in the event queue. @@ -2337,7 +2337,7 @@ impl ScriptThread { // 2. If response's status is 204 or 205, then abort these steps. match metadata { Some(Metadata { - status: Some((204...205, _)), + status: Some((204..=205, _)), .. }) => { // If we have an existing window that is being navigated: diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index 4304eef7a10..2c2c2229ba0 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -221,7 +221,7 @@ pub struct LayoutThreadInit { pub is_parent: bool, pub layout_pair: (Sender, Receiver), pub pipeline_port: IpcReceiver, - pub background_hang_monitor_register: Box, + pub background_hang_monitor_register: Box, pub constellation_chan: IpcSender, pub script_chan: IpcSender, pub image_cache: Arc, diff --git a/components/script_plugins/webidl_must_inherit.rs b/components/script_plugins/webidl_must_inherit.rs index 556136261ab..7670fb8378a 100644 --- a/components/script_plugins/webidl_must_inherit.rs +++ b/components/script_plugins/webidl_must_inherit.rs @@ -47,7 +47,7 @@ impl Error for ParentMismatchError { "ParentMismatchError" } - fn cause(&self) -> Option<&Error> { + fn cause(&self) -> Option<&dyn Error> { None } } @@ -111,7 +111,7 @@ fn is_webidl_ty(symbols: &crate::Symbols, cx: &LateContext, ty: &ty::TyS) -> boo ret } -fn check_inherits(code: &str, name: &str, parent_name: &str) -> Result<(), Box> { +fn check_inherits(code: &str, name: &str, parent_name: &str) -> Result<(), Box> { let idl = weedle::parse(code).expect("Invalid webidl provided"); let mut inherits = ""; @@ -156,7 +156,7 @@ fn check_inherits(code: &str, name: &str, parent_name: &str) -> Result<(), Box) -> Result<(), Box> { +fn check_webidl(name: &str, parent_name: &Option) -> Result<(), Box> { let path = get_webidl_path(&name)?; if let Some(parent) = parent_name { let code = fs::read_to_string(path)?; diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 28a6dbbfad4..2dbcf6fbde3 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -600,7 +600,7 @@ pub struct InitialScriptState { /// A channel on which messages can be sent to the constellation from script. pub script_to_constellation_chan: ScriptToConstellationChan, /// A handle to register script-(and associated layout-)threads for hang monitoring. - pub background_hang_monitor_register: Box, + pub background_hang_monitor_register: Box, /// A sender for the layout thread to communicate to the constellation. pub layout_to_constellation_chan: IpcSender, /// A channel to schedule timer events. diff --git a/components/selectors/context.rs b/components/selectors/context.rs index 95caa4055d7..3686513e79d 100644 --- a/components/selectors/context.rs +++ b/components/selectors/context.rs @@ -134,7 +134,7 @@ where /// An optional hook function for checking whether a pseudo-element /// should match when matching_mode is ForStatelessPseudoElement. - pub pseudo_element_matching_fn: Option<&'a Fn(&Impl::PseudoElement) -> bool>, + pub pseudo_element_matching_fn: Option<&'a dyn Fn(&Impl::PseudoElement) -> bool>, /// Extra implementation-dependent matching data. pub extra_data: Impl::ExtraMatchingData, diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 011b4a77b64..0e5ccf2c2ad 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -199,7 +199,7 @@ impl Servo where Window: WindowMethods + 'static + ?Sized, { - pub fn new(mut embedder: Box, window: Rc) -> Servo { + pub fn new(mut embedder: Box, window: Rc) -> Servo { // Global configuration options, parsed from the command line. let opts = opts::get(); diff --git a/components/style/animation.rs b/components/style/animation.rs index a325b46e6cd..c9b4fc5a6f1 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -471,7 +471,7 @@ fn compute_style_for_animation_step( step: &KeyframesStep, previous_style: &ComputedValues, style_from_cascade: &Arc, - font_metrics_provider: &FontMetricsProvider, + font_metrics_provider: &dyn FontMetricsProvider, ) -> Arc where E: TElement, @@ -656,7 +656,7 @@ pub fn update_style_for_animation( context: &SharedStyleContext, animation: &Animation, style: &mut Arc, - font_metrics_provider: &FontMetricsProvider, + font_metrics_provider: &dyn FontMetricsProvider, ) -> AnimationUpdate where E: TElement, diff --git a/components/style/attr.rs b/components/style/attr.rs index 22f524bc52e..1d0d555d509 100644 --- a/components/style/attr.rs +++ b/components/style/attr.rs @@ -508,9 +508,9 @@ pub fn parse_legacy_color(mut input: &str) -> Result { fn hex(ch: char) -> Result { match ch { - '0'...'9' => Ok((ch as u8) - b'0'), - 'a'...'f' => Ok((ch as u8) - b'a' + 10), - 'A'...'F' => Ok((ch as u8) - b'A' + 10), + '0'..='9' => Ok((ch as u8) - b'0'), + 'a'..='f' => Ok((ch as u8) - b'a' + 10), + 'A'..='F' => Ok((ch as u8) - b'A' + 10), _ => Err(()), } } @@ -550,7 +550,7 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto { // Steps 6 & 7 match value.chars().nth(0) { - Some('0'...'9') => {}, + Some('0'..='9') => {}, _ => return LengthOrPercentageOrAuto::Auto, } @@ -565,7 +565,7 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto { let (mut found_full_stop, mut found_percent) = (false, false); for (i, ch) in value.chars().enumerate() { match ch { - '0'...'9' => continue, + '0'..='9' => continue, '%' => { found_percent = true; end_index = i; diff --git a/components/style/context.rs b/components/style/context.rs index 0bb50217ef3..6d93b973b22 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -181,7 +181,7 @@ pub struct SharedStyleContext<'a> { /// Paint worklets #[cfg(feature = "servo")] - pub registered_speculative_painters: &'a RegisteredSpeculativePainters, + pub registered_speculative_painters: &'a dyn RegisteredSpeculativePainters, /// Data needed to create the thread-local style context from the shared one. #[cfg(feature = "servo")] @@ -826,5 +826,5 @@ pub trait RegisteredSpeculativePainter: SpeculativePainter { #[cfg(feature = "servo")] pub trait RegisteredSpeculativePainters: Sync { /// Look up a speculative painter - fn get(&self, name: &Atom) -> Option<&RegisteredSpeculativePainter>; + fn get(&self, name: &Atom) -> Option<&dyn RegisteredSpeculativePainter>; } diff --git a/components/style/encoding_support.rs b/components/style/encoding_support.rs index bde463c02d2..5544487179f 100644 --- a/components/style/encoding_support.rs +++ b/components/style/encoding_support.rs @@ -63,8 +63,8 @@ impl Stylesheet { origin: Origin, media: MediaList, shared_lock: SharedRwLock, - stylesheet_loader: Option<&StylesheetLoader>, - error_reporter: Option<&ParseErrorReporter>, + stylesheet_loader: Option<&dyn StylesheetLoader>, + error_reporter: Option<&dyn ParseErrorReporter>, quirks_mode: QuirksMode, ) -> Stylesheet { let string = decode_stylesheet_bytes(bytes, protocol_encoding_label, environment_encoding); @@ -89,8 +89,8 @@ impl Stylesheet { protocol_encoding_label: Option<&str>, environment_encoding: Option<&'static encoding_rs::Encoding>, url_data: UrlExtraData, - stylesheet_loader: Option<&StylesheetLoader>, - error_reporter: Option<&ParseErrorReporter>, + stylesheet_loader: Option<&dyn StylesheetLoader>, + error_reporter: Option<&dyn ParseErrorReporter>, ) { let string = decode_stylesheet_bytes(bytes, protocol_encoding_label, environment_encoding); Self::update_from_str( diff --git a/components/style/matching.rs b/components/style/matching.rs index 52d12037707..b4b472ea1c3 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -582,7 +582,7 @@ trait PrivateMatchMethods: TElement { context: &SharedStyleContext, style: &mut Arc, possibly_expired_animations: &mut Vec, - font_metrics: &crate::font_metrics::FontMetricsProvider, + font_metrics: &dyn crate::font_metrics::FontMetricsProvider, ) { use crate::animation::{self, Animation, AnimationUpdate}; use crate::dom::TNode; diff --git a/components/style/parser.rs b/components/style/parser.rs index f9322a7bcb3..c6f7321b25d 100644 --- a/components/style/parser.rs +++ b/components/style/parser.rs @@ -51,7 +51,7 @@ pub struct ParserContext<'a> { /// The quirks mode of this stylesheet. pub quirks_mode: QuirksMode, /// The active error reporter, or none if error reporting is disabled. - error_reporter: Option<&'a ParseErrorReporter>, + error_reporter: Option<&'a dyn ParseErrorReporter>, /// The currently active namespaces. pub namespaces: Option<&'a Namespaces>, /// The use counters we want to record while parsing style rules, if any. @@ -67,7 +67,7 @@ impl<'a> ParserContext<'a> { rule_type: Option, parsing_mode: ParsingMode, quirks_mode: QuirksMode, - error_reporter: Option<&'a ParseErrorReporter>, + error_reporter: Option<&'a dyn ParseErrorReporter>, use_counters: Option<&'a UseCounters>, ) -> Self { Self { @@ -89,7 +89,7 @@ impl<'a> ParserContext<'a> { rule_type: Option, parsing_mode: ParsingMode, quirks_mode: QuirksMode, - error_reporter: Option<&'a ParseErrorReporter>, + error_reporter: Option<&'a dyn ParseErrorReporter>, use_counters: Option<&'a UseCounters>, ) -> Self { Self::new( diff --git a/components/style/properties/cascade.rs b/components/style/properties/cascade.rs index b3f2acde7c3..af6c563b319 100644 --- a/components/style/properties/cascade.rs +++ b/components/style/properties/cascade.rs @@ -82,7 +82,7 @@ pub fn cascade( parent_style_ignoring_first_line: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValues>, visited_rules: Option<&StrongRuleNode>, - font_metrics_provider: &FontMetricsProvider, + font_metrics_provider: &dyn FontMetricsProvider, quirks_mode: QuirksMode, rule_cache: Option<&RuleCache>, rule_cache_conditions: &mut RuleCacheConditions, @@ -116,7 +116,7 @@ fn cascade_rules( parent_style: Option<&ComputedValues>, parent_style_ignoring_first_line: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValues>, - font_metrics_provider: &FontMetricsProvider, + font_metrics_provider: &dyn FontMetricsProvider, cascade_mode: CascadeMode, quirks_mode: QuirksMode, rule_cache: Option<&RuleCache>, @@ -213,7 +213,7 @@ pub fn apply_declarations<'a, E, F, I>( parent_style: Option<&ComputedValues>, parent_style_ignoring_first_line: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValues>, - font_metrics_provider: &FontMetricsProvider, + font_metrics_provider: &dyn FontMetricsProvider, cascade_mode: CascadeMode, quirks_mode: QuirksMode, rule_cache: Option<&RuleCache>, diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index fcbfb717aa8..6078f6712a7 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -1199,7 +1199,7 @@ where pub fn parse_style_attribute( input: &str, url_data: &UrlExtraData, - error_reporter: Option<&ParseErrorReporter>, + error_reporter: Option<&dyn ParseErrorReporter>, quirks_mode: QuirksMode, ) -> PropertyDeclarationBlock { let context = ParserContext::new( @@ -1226,7 +1226,7 @@ pub fn parse_one_declaration_into( id: PropertyId, input: &str, url_data: &UrlExtraData, - error_reporter: Option<&ParseErrorReporter>, + error_reporter: Option<&dyn ParseErrorReporter>, parsing_mode: ParsingMode, quirks_mode: QuirksMode ) -> Result<(), ()> { diff --git a/components/style/str.rs b/components/style/str.rs index b9e8db34536..01f70c1f963 100644 --- a/components/style/str.rs +++ b/components/style/str.rs @@ -60,7 +60,7 @@ pub fn split_commas<'a>(s: &'a str) -> Filter, fn(&&str) -> bool /// Character is ascii digit pub fn is_ascii_digit(c: &char) -> bool { match *c { - '0'...'9' => true, + '0'..='9' => true, _ => false, } } @@ -161,7 +161,7 @@ pub fn starts_with_ignore_ascii_case(string: &str, prefix: &str) -> bool { /// Returns an ascii lowercase version of a string, only allocating if needed. pub fn string_as_ascii_lowercase<'a>(input: &'a str) -> Cow<'a, str> { - if input.bytes().any(|c| matches!(c, b'A'...b'Z')) { + if input.bytes().any(|c| matches!(c, b'A'..=b'Z')) { input.to_ascii_lowercase().into() } else { // Already ascii lowercase. diff --git a/components/style/stylesheets/mod.rs b/components/style/stylesheets/mod.rs index 6f9c03abc5d..5853ff5f3a5 100644 --- a/components/style/stylesheets/mod.rs +++ b/components/style/stylesheets/mod.rs @@ -352,7 +352,7 @@ impl CssRule { parent_stylesheet_contents: &StylesheetContents, shared_lock: &SharedRwLock, state: State, - loader: Option<&StylesheetLoader>, + loader: Option<&dyn StylesheetLoader>, ) -> Result { let url_data = parent_stylesheet_contents.url_data.read(); let context = ParserContext::new( diff --git a/components/style/stylesheets/rule_list.rs b/components/style/stylesheets/rule_list.rs index ee2b5347c1e..05f93eca489 100644 --- a/components/style/stylesheets/rule_list.rs +++ b/components/style/stylesheets/rule_list.rs @@ -127,7 +127,7 @@ pub trait CssRulesHelpers { parent_stylesheet_contents: &StylesheetContents, index: usize, nested: bool, - loader: Option<&StylesheetLoader>, + loader: Option<&dyn StylesheetLoader>, ) -> Result; } @@ -139,7 +139,7 @@ impl CssRulesHelpers for RawOffsetArc> { parent_stylesheet_contents: &StylesheetContents, index: usize, nested: bool, - loader: Option<&StylesheetLoader>, + loader: Option<&dyn StylesheetLoader>, ) -> Result { let new_rule = { let read_guard = lock.read(); diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index e7f3fb15f80..da9ce0a9401 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -44,7 +44,7 @@ pub struct TopLevelRuleParser<'a> { /// A reference to the lock we need to use to create rules. pub shared_lock: &'a SharedRwLock, /// A reference to a stylesheet loader if applicable, for `@import` rules. - pub loader: Option<&'a StylesheetLoader>, + pub loader: Option<&'a dyn StylesheetLoader>, /// The top-level parser context. /// /// This won't contain any namespaces, and only nested parsers created with diff --git a/components/style/stylesheets/stylesheet.rs b/components/style/stylesheets/stylesheet.rs index 5b8c8753248..15c60402be4 100644 --- a/components/style/stylesheets/stylesheet.rs +++ b/components/style/stylesheets/stylesheet.rs @@ -76,8 +76,8 @@ impl StylesheetContents { url_data: UrlExtraData, origin: Origin, shared_lock: &SharedRwLock, - stylesheet_loader: Option<&StylesheetLoader>, - error_reporter: Option<&ParseErrorReporter>, + stylesheet_loader: Option<&dyn StylesheetLoader>, + error_reporter: Option<&dyn ParseErrorReporter>, quirks_mode: QuirksMode, line_number_offset: u32, use_counters: Option<&UseCounters>, @@ -343,8 +343,8 @@ impl Stylesheet { existing: &Stylesheet, css: &str, url_data: UrlExtraData, - stylesheet_loader: Option<&StylesheetLoader>, - error_reporter: Option<&ParseErrorReporter>, + stylesheet_loader: Option<&dyn StylesheetLoader>, + error_reporter: Option<&dyn ParseErrorReporter>, line_number_offset: u32, ) { let namespaces = RwLock::new(Namespaces::default()); @@ -382,8 +382,8 @@ impl Stylesheet { origin: Origin, namespaces: &mut Namespaces, shared_lock: &SharedRwLock, - stylesheet_loader: Option<&StylesheetLoader>, - error_reporter: Option<&ParseErrorReporter>, + stylesheet_loader: Option<&dyn StylesheetLoader>, + error_reporter: Option<&dyn ParseErrorReporter>, quirks_mode: QuirksMode, line_number_offset: u32, use_counters: Option<&UseCounters>, @@ -450,8 +450,8 @@ impl Stylesheet { origin: Origin, media: Arc>, shared_lock: SharedRwLock, - stylesheet_loader: Option<&StylesheetLoader>, - error_reporter: Option<&ParseErrorReporter>, + stylesheet_loader: Option<&dyn StylesheetLoader>, + error_reporter: Option<&dyn ParseErrorReporter>, quirks_mode: QuirksMode, line_number_offset: u32, ) -> Self { diff --git a/components/style/stylist.rs b/components/style/stylist.rs index cba1cbac524..a98b8a89eb5 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -650,7 +650,7 @@ impl Stylist { guards: &StylesheetGuards, pseudo: &PseudoElement, parent: Option<&ComputedValues>, - font_metrics: &FontMetricsProvider, + font_metrics: &dyn FontMetricsProvider, ) -> Arc where E: TElement, @@ -678,7 +678,7 @@ impl Stylist { guards: &StylesheetGuards, pseudo: &PseudoElement, parent: Option<&ComputedValues>, - font_metrics: &FontMetricsProvider, + font_metrics: &dyn FontMetricsProvider, rules: StrongRuleNode, ) -> Arc where @@ -773,8 +773,8 @@ impl Stylist { rule_inclusion: RuleInclusion, parent_style: &ComputedValues, is_probe: bool, - font_metrics: &FontMetricsProvider, - matching_fn: Option<&Fn(&PseudoElement) -> bool>, + font_metrics: &dyn FontMetricsProvider, + matching_fn: Option<&dyn Fn(&PseudoElement) -> bool>, ) -> Option> where E: TElement, @@ -809,7 +809,7 @@ impl Stylist { pseudo: &PseudoElement, guards: &StylesheetGuards, parent_style: Option<&ComputedValues>, - font_metrics: &FontMetricsProvider, + font_metrics: &dyn FontMetricsProvider, element: Option, ) -> Arc where @@ -862,7 +862,7 @@ impl Stylist { parent_style: Option<&ComputedValues>, parent_style_ignoring_first_line: Option<&ComputedValues>, layout_parent_style: Option<&ComputedValues>, - font_metrics: &FontMetricsProvider, + font_metrics: &dyn FontMetricsProvider, rule_cache: Option<&RuleCache>, rule_cache_conditions: &mut RuleCacheConditions, ) -> Arc @@ -919,7 +919,7 @@ impl Stylist { pseudo: &PseudoElement, is_probe: bool, rule_inclusion: RuleInclusion, - matching_fn: Option<&Fn(&PseudoElement) -> bool>, + matching_fn: Option<&dyn Fn(&PseudoElement) -> bool>, ) -> Option where E: TElement, diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 06579238e77..f9711947673 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -147,7 +147,7 @@ pub struct Context<'a> { /// A font metrics provider, used to access font metrics to implement /// font-relative units. - pub font_metrics_provider: &'a FontMetricsProvider, + pub font_metrics_provider: &'a dyn FontMetricsProvider, /// Whether or not we are computing the media list in a media query pub in_media_query: bool, diff --git a/components/style_traits/specified_value_info.rs b/components/style_traits/specified_value_info.rs index 5aaf64ac955..39740bc7262 100644 --- a/components/style_traits/specified_value_info.rs +++ b/components/style_traits/specified_value_info.rs @@ -27,7 +27,7 @@ pub mod CssType { } /// See SpecifiedValueInfo::collect_completion_keywords. -pub type KeywordsCollectFn<'a> = &'a mut FnMut(&[&'static str]); +pub type KeywordsCollectFn<'a> = &'a mut dyn FnMut(&[&'static str]); /// Information of values of a given specified value type. /// diff --git a/ports/glutin/app.rs b/ports/glutin/app.rs index ac219003988..46e84bdcc70 100644 --- a/ports/glutin/app.rs +++ b/ports/glutin/app.rs @@ -21,9 +21,9 @@ use std::rc::Rc; pub struct App { events_loop: Rc>, - window: Rc, - servo: RefCell>, - browser: RefCell>, + window: Rc, + servo: RefCell>, + browser: RefCell>, event_queue: RefCell>, suspended: Cell, } diff --git a/ports/glutin/embedder.rs b/ports/glutin/embedder.rs index 6b353fb76a0..b7c6b613426 100644 --- a/ports/glutin/embedder.rs +++ b/ports/glutin/embedder.rs @@ -24,7 +24,7 @@ pub struct EmbedderCallbacks { } impl EmbedderCallbacks { - pub fn new(events_loop: Rc>, gl: Rc) -> EmbedderCallbacks { + pub fn new(events_loop: Rc>, gl: Rc) -> EmbedderCallbacks { EmbedderCallbacks { events_loop, gl } } } @@ -37,7 +37,7 @@ impl EmbedderMethods for EmbedderCallbacks { fn register_vr_services( &mut self, services: &mut VRServiceManager, - heartbeats: &mut Vec>, + heartbeats: &mut Vec>, ) { if !opts::get().headless { if pref!(dom.webvr.test) { diff --git a/ports/libmlservo/src/lib.rs b/ports/libmlservo/src/lib.rs index ff989b64432..a9efb4fca34 100644 --- a/ports/libmlservo/src/lib.rs +++ b/ports/libmlservo/src/lib.rs @@ -393,7 +393,7 @@ enum ScrollState { struct EventLoopWakerInstance; impl EventLoopWaker for EventLoopWakerInstance { - fn clone(&self) -> Box { + fn clone(&self) -> Box { Box::new(EventLoopWakerInstance) } diff --git a/ports/libsimpleservo/api/src/gl_glue.rs b/ports/libsimpleservo/api/src/gl_glue.rs index 945cad97636..e722a4a59cd 100644 --- a/ports/libsimpleservo/api/src/gl_glue.rs +++ b/ports/libsimpleservo/api/src/gl_glue.rs @@ -2,6 +2,8 @@ * 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(bare_trait_objects)] // Until https://github.com/brendanzab/gl-rs/pull/493 + pub type ServoGl = std::rc::Rc; #[cfg(any(target_os = "android", target_os = "windows"))] diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs index 6418ca60b0c..ba660d9c173 100644 --- a/ports/libsimpleservo/api/src/lib.rs +++ b/ports/libsimpleservo/api/src/lib.rs @@ -52,7 +52,7 @@ pub struct InitOptions { pub enum VRInitOptions { None, VRExternal(*mut c_void), - VRService(Box, Box), + VRService(Box, Box), } #[derive(Clone, Debug)] @@ -571,7 +571,7 @@ impl EmbedderMethods for ServoEmbedderCallbacks { fn register_vr_services( &mut self, services: &mut VRServiceManager, - heartbeats: &mut Vec>, + heartbeats: &mut Vec>, ) { debug!("EmbedderMethods::register_vrexternal"); match mem::replace(&mut self.vr_init, VRInitOptions::None) { diff --git a/ports/libsimpleservo/jniapi/src/lib.rs b/ports/libsimpleservo/jniapi/src/lib.rs index c9b9d65ea56..f2379a3db0c 100644 --- a/ports/libsimpleservo/jniapi/src/lib.rs +++ b/ports/libsimpleservo/jniapi/src/lib.rs @@ -337,7 +337,7 @@ impl WakeupCallback { } impl EventLoopWaker for WakeupCallback { - fn clone(&self) -> Box { + fn clone(&self) -> Box { Box::new(WakeupCallback { callback: self.callback.clone(), jvm: self.jvm.clone(),