tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 265e1bce8abba5d4405e2e1e72fb686ada40fe3e
parent 637cccbe8def959a1b1d1a2398c80939fae1d8c4
Author: Sylvestre Ledru <sylvestre@debian.org>
Date:   Tue, 30 Sep 2025 11:52:34 +0000

Bug 1617369 - Reformat recent rust changes with rustfmt r=emilio,webrtc-reviewers,toolkit-telemetry-reviewers,firefox-style-system-reviewers,janerik,mjf

Generated with rustfmt 1.8.0-stable (1159e78c47 2025-09-14)

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D266587

Diffstat:
Mdom/media/webrtc/sdp/rsdparsa_capi/src/types.rs | 3++-
Mgfx/webrender_bindings/src/bindings.rs | 111++++++++++++++++++++++++++++++++-----------------------------------------------
Mgfx/webrender_bindings/src/lib.rs | 2+-
Mgfx/webrender_bindings/src/program_cache.rs | 6+++---
Mservices/common/app_services_logger/src/lib.rs | 1+
Mservo/components/selectors/matching.rs | 15+++++++--------
Mservo/components/style/dom_apis.rs | 2+-
Mservo/components/style/gecko/selector_parser.rs | 2+-
Mservo/components/style/invalidation/element/invalidation_map.rs | 12+++++++++---
Mservo/components/style/invalidation/element/invalidator.rs | 125++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mservo/components/style/invalidation/element/relative_selector.rs | 46+++++++++++++++++++++++++++++++++-------------
Mservo/components/style/invalidation/element/state_and_attributes.rs | 154+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Mservo/components/style/servo/animation.rs | 2+-
Mservo/components/style/stylesheets/stylesheet.rs | 2+-
Mservo/components/style/stylist.rs | 6++----
Mservo/components/style/values/specified/position.rs | 46+++++++++++++++++++++++++++++++++-------------
Mtaskcluster/docker/image_builder/build-image/src/taskcluster.rs | 19+++++++++++++++----
Mtoolkit/components/glean/api/src/private/boolean.rs | 13++++++++++---
Mtoolkit/components/glean/api/src/private/counter.rs | 11+++++++++--
Mtoolkit/components/glean/api/src/private/custom_distribution.rs | 4+++-
Mtoolkit/components/glean/api/src/private/datetime.rs | 21++++++++++++++++++---
Mtoolkit/components/glean/api/src/private/denominator.rs | 11+++++++++--
Mtoolkit/components/glean/api/src/private/event.rs | 8++++++--
Mtoolkit/components/glean/api/src/private/labeled.rs | 51++++++++++++++++++++++++++++++++++++++++++---------
Mtoolkit/components/glean/api/src/private/labeled_boolean.rs | 5++++-
Mtoolkit/components/glean/api/src/private/labeled_counter.rs | 5++++-
Mtoolkit/components/glean/api/src/private/memory_distribution.rs | 8++++++--
Mtoolkit/components/glean/api/src/private/numerator.rs | 13+++++++++++--
Mtoolkit/components/glean/api/src/private/quantity.rs | 7++++++-
Mtoolkit/components/glean/api/src/private/rate.rs | 8++++++--
Mtoolkit/components/glean/api/src/private/string.rs | 9+++++++--
Mtoolkit/components/glean/api/src/private/string_list.rs | 8++++++--
Mtoolkit/components/glean/api/src/private/text.rs | 9+++++++--
Mtoolkit/components/glean/api/src/private/timing_distribution.rs | 4+++-
Mtoolkit/components/glean/api/src/private/url.rs | 9+++++++--
Mtoolkit/components/glean/api/src/private/uuid.rs | 11+++++++++--
Mtoolkit/components/glean/src/init/viaduct_uploader.rs | 6++++--
Mtoolkit/components/places/bookmark_sync/src/merger.rs | 4++--
Mtoolkit/components/uniffi-bindgen-gecko-js/src/pipeline/callables.rs | 3++-
Mtoolkit/crashreporter/crash_helper_common/src/ipc_connector/unix.rs | 8++------
Mtoolkit/crashreporter/crash_helper_common/src/ipc_connector/windows.rs | 9++++++---
Mtoolkit/crashreporter/crash_helper_common/src/platform/linux.rs | 4+---
Mtools/fuzzing/rust/src/lib.rs | 4+++-
43 files changed, 505 insertions(+), 302 deletions(-)

diff --git a/dom/media/webrtc/sdp/rsdparsa_capi/src/types.rs b/dom/media/webrtc/sdp/rsdparsa_capi/src/types.rs @@ -92,7 +92,8 @@ pub unsafe extern "C" fn string_vec_get_view( NS_OK } None => NS_ERROR_INVALID_ARG, - }} + } +} #[no_mangle] pub unsafe extern "C" fn free_boxed_string_vec(ptr: *mut Vec<String>) -> nsresult { diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs @@ -429,7 +429,8 @@ pub struct WrExternalImageHandler { impl ExternalImageHandler for WrExternalImageHandler { fn lock(&mut self, id: ExternalImageId, channel_index: u8, is_composited: bool) -> ExternalImage { - let image = unsafe { wr_renderer_lock_external_image(self.external_image_obj, id, channel_index, is_composited) }; + let image = + unsafe { wr_renderer_lock_external_image(self.external_image_obj, id, channel_index, is_composited) }; ExternalImage { uv: TexelRect::new(image.u0, image.v0, image.u1, image.v1), source: match image.image_type { @@ -1555,12 +1556,9 @@ impl WrLayerCompositor { } } - fn reuse_same_tree( - &mut self, - input: &CompositorInputConfig, - ) -> bool { - if input.layers.len() != self.visual_tree.len() { - return false; + fn reuse_same_tree(&mut self, input: &CompositorInputConfig) -> bool { + if input.layers.len() != self.visual_tree.len() { + return false; } for (request, layer) in input.layers.iter().zip(self.visual_tree.iter()) { @@ -1573,7 +1571,7 @@ impl WrLayerCompositor { if layer.size != request.clip_rect.size() { return false; } - } + }, CompositorSurfaceUsage::External { .. } => {}, CompositorSurfaceUsage::DebugOverlay => {}, }; @@ -1585,40 +1583,26 @@ impl WrLayerCompositor { // Copy across (potentially) updated external image id layer.usage = request.usage; match layer.usage { - CompositorSurfaceUsage::Content | CompositorSurfaceUsage::DebugOverlay => {} - CompositorSurfaceUsage::External { external_image_id, .. } => { - unsafe { - wr_compositor_attach_external_image( - self.compositor, - layer.id, - external_image_id, - ); - } - } + CompositorSurfaceUsage::Content | CompositorSurfaceUsage::DebugOverlay => {}, + CompositorSurfaceUsage::External { external_image_id, .. } => unsafe { + wr_compositor_attach_external_image(self.compositor, layer.id, external_image_id); + }, } } true } - fn use_multiple_layers_except_debug_layer( - &mut self, - input: &CompositorInputConfig, - ) -> bool { - + fn use_multiple_layers_except_debug_layer(&mut self, input: &CompositorInputConfig) -> bool { let is_debug_layer = |usage: &CompositorSurfaceUsage| -> bool { match usage { - CompositorSurfaceUsage::DebugOverlay => { - true - }, - CompositorSurfaceUsage::Content | - CompositorSurfaceUsage::External { .. } => { - false - }, + CompositorSurfaceUsage::DebugOverlay => true, + CompositorSurfaceUsage::Content | CompositorSurfaceUsage::External { .. } => false, } }; - let count = input.layers + let count = input + .layers .iter() .filter(|layer| !is_debug_layer(&layer.usage)) .count(); @@ -1629,11 +1613,8 @@ impl WrLayerCompositor { impl LayerCompositor for WrLayerCompositor { // Begin compositing a frame with the supplied input config - fn begin_frame( - &mut self, - input: &CompositorInputConfig, - ) -> bool { - const FRAME_COUNT_BEFORE_DISABLING_SYNC_DCOMP_COMMIT: u32 = 60; + fn begin_frame(&mut self, input: &CompositorInputConfig) -> bool { + const FRAME_COUNT_BEFORE_DISABLING_SYNC_DCOMP_COMMIT: u32 = 60; let mut destroy_all_layers = false; if self.enable_screenshot != input.enable_screenshot { @@ -1661,7 +1642,7 @@ impl LayerCompositor for WrLayerCompositor { match self.frames_since_using_multiple_layers { None => { // Do not request sync dcomp commit. - } + }, Some(count) => { if count < FRAME_COUNT_BEFORE_DISABLING_SYNC_DCOMP_COMMIT { // Keep to requet sync dcomp commit to avoid frequent layers creation. @@ -1671,7 +1652,7 @@ impl LayerCompositor for WrLayerCompositor { // Stop to requet sync dcomp commit. self.frames_since_using_multiple_layers = None; } - } + }, } }; @@ -1735,7 +1716,8 @@ impl LayerCompositor for WrLayerCompositor { id, size, request.is_opaque, - needs_sync_dcomp_commit); + needs_sync_dcomp_commit, + ); }, CompositorSurfaceUsage::External { .. } => { wr_compositor_create_external_surface(self.compositor, id, request.is_opaque); @@ -1779,38 +1761,20 @@ impl LayerCompositor for WrLayerCompositor { } // Bind a layer by index for compositing into - fn bind_layer( - &mut self, - index: usize, - dirty_rects: &[DeviceIntRect], - ) { + fn bind_layer(&mut self, index: usize, dirty_rects: &[DeviceIntRect]) { let layer = &self.visual_tree[index]; unsafe { - wr_compositor_bind_swapchain( - self.compositor, - layer.id, - dirty_rects.as_ptr(), - dirty_rects.len(), - ); + wr_compositor_bind_swapchain(self.compositor, layer.id, dirty_rects.as_ptr(), dirty_rects.len()); } } // Finish compositing a layer and present the swapchain - fn present_layer( - &mut self, - index: usize, - dirty_rects: &[DeviceIntRect], - ) { + fn present_layer(&mut self, index: usize, dirty_rects: &[DeviceIntRect]) { let layer = &self.visual_tree[index]; unsafe { - wr_compositor_present_swapchain( - self.compositor, - layer.id, - dirty_rects.as_ptr(), - dirty_rects.len(), - ); + wr_compositor_present_swapchain(self.compositor, layer.id, dirty_rects.as_ptr(), dirty_rects.len()); } } @@ -2156,7 +2120,6 @@ pub extern "C" fn wr_window_new( static_prefs::pref!("gfx.webrender.precise-linear-gradients") }; - let precise_radial_gradients = if software { static_prefs::pref!("gfx.webrender.precise-radial-gradients-swgl") } else { @@ -2456,7 +2419,13 @@ pub extern "C" fn wr_transaction_set_document_view(txn: &mut Transaction, doc_re } #[no_mangle] -pub extern "C" fn wr_transaction_generate_frame(txn: &mut Transaction, id: u64, present: bool, tracked: bool, reasons: RenderReasons) { +pub extern "C" fn wr_transaction_generate_frame( + txn: &mut Transaction, + id: u64, + present: bool, + tracked: bool, + reasons: RenderReasons, +) { txn.generate_frame(id, present, tracked, reasons); } @@ -2840,7 +2809,7 @@ fn generate_capture_path(path: *const c_char, moz_revision: *const c_char) -> Op match File::create(path.join("wr.txt")) { Ok(mut file) => { // The Gecko HG revision is available at compile time - if ! moz_revision.is_null() { + if !moz_revision.is_null() { if let Ok(moz_revision) = unsafe { CStr::from_ptr(moz_revision) }.to_str() { writeln!(file, "mozilla-central {}", moz_revision).unwrap() } @@ -2855,7 +2824,12 @@ fn generate_capture_path(path: *const c_char, moz_revision: *const c_char) -> Op } #[no_mangle] -pub extern "C" fn wr_api_capture(dh: &mut DocumentHandle, path: *const c_char, moz_revision: *const c_char, bits_raw: u32) { +pub extern "C" fn wr_api_capture( + dh: &mut DocumentHandle, + path: *const c_char, + moz_revision: *const c_char, + bits_raw: u32, +) { if let Some(path) = generate_capture_path(path, moz_revision) { let bits = CaptureBits::from_bits(bits_raw as _).unwrap(); dh.api.save_capture(path, bits); @@ -2863,7 +2837,12 @@ pub extern "C" fn wr_api_capture(dh: &mut DocumentHandle, path: *const c_char, m } #[no_mangle] -pub extern "C" fn wr_api_start_capture_sequence(dh: &mut DocumentHandle, path: *const c_char, moz_revision: *const c_char, bits_raw: u32) { +pub extern "C" fn wr_api_start_capture_sequence( + dh: &mut DocumentHandle, + path: *const c_char, + moz_revision: *const c_char, + bits_raw: u32, +) { if let Some(path) = generate_capture_path(path, moz_revision) { let bits = CaptureBits::from_bits(bits_raw as _).unwrap(); dh.api.start_capture_sequence(path, bits); diff --git a/gfx/webrender_bindings/src/lib.rs b/gfx/webrender_bindings/src/lib.rs @@ -8,12 +8,12 @@ extern crate app_units; extern crate bincode; extern crate euclid; -extern crate rustc_hash; extern crate gecko_profiler; extern crate gleam; extern crate nsstring; extern crate num_cpus; extern crate rayon; +extern crate rustc_hash; extern crate swgl; extern crate thin_vec; extern crate tracy_rs; diff --git a/gfx/webrender_bindings/src/program_cache.rs b/gfx/webrender_bindings/src/program_cache.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 http://mozilla.org/MPL/2.0/. */ +use nsstring::nsAString; +use rayon::ThreadPool; use std::cell::RefCell; use std::ffi::OsString; use std::fs::{create_dir_all, read_dir, read_to_string, File}; @@ -10,15 +12,13 @@ use std::io::{Read, Write}; use std::path::{Path, PathBuf}; use std::rc::Rc; use std::sync::Arc; -use nsstring::nsAString; -use rayon::ThreadPool; use webrender::{ProgramBinary, ProgramCache, ProgramCacheObserver, ProgramSourceDigest}; const MAX_LOAD_TIME_MS: u64 = 400; fn hash_bytes(v: &[u8]) -> u64 { - use std::hash::{Hash, Hasher}; use rustc_hash::FxHasher; + use std::hash::{Hash, Hasher}; let mut state = FxHasher::default(); v.hash(&mut state); state.finish() diff --git a/services/common/app_services_logger/src/lib.rs b/services/common/app_services_logger/src/lib.rs @@ -0,0 +1 @@ + diff --git a/servo/components/selectors/matching.rs b/servo/components/selectors/matching.rs @@ -1282,20 +1282,19 @@ where Component::Host(ref selector) => { return matches_host(element, selector.as_ref(), &mut context.shared, rightmost); }, - Component::ParentSelector => { - match context.shared.scope_element { - Some(ref scope_element) => element.opaque() == *scope_element, - None => element.is_root(), - } + Component::ParentSelector => match context.shared.scope_element { + Some(ref scope_element) => element.opaque() == *scope_element, + None => element.is_root(), }, - Component::Scope | Component::ImplicitScope =>{ - if let Some(may_return_unknown) = context.shared.matching_for_invalidation_comparison() { + Component::Scope | Component::ImplicitScope => { + if let Some(may_return_unknown) = context.shared.matching_for_invalidation_comparison() + { return if may_return_unknown { KleeneValue::Unknown } else { KleeneValue::from(!context.shared.in_negation()) }; - }else{ + } else { match context.shared.scope_element { Some(ref scope_element) => element.opaque() == *scope_element, None => element.is_root(), diff --git a/servo/components/style/dom_apis.rs b/servo/components/style/dom_apis.rs @@ -162,7 +162,7 @@ where true } - fn check_outer_dependency(&mut self, _: &Dependency, _: E, _:Option<OpaqueElement>) -> bool { + fn check_outer_dependency(&mut self, _: &Dependency, _: E, _: Option<OpaqueElement>) -> bool { debug_assert!( false, "How? We should only have parent-less dependencies here!" diff --git a/servo/components/style/gecko/selector_parser.rs b/servo/components/style/gecko/selector_parser.rs @@ -11,8 +11,8 @@ use crate::selector_parser::{Direction, HorizontalDirection, SelectorParser}; use crate::str::starts_with_ignore_ascii_case; use crate::string_cache::{Atom, Namespace, WeakAtom, WeakNamespace}; use crate::values::{AtomIdent, AtomString, CSSInteger}; -use cssparser::{CowRcStr, SourceLocation, ToCss, Token}; use cssparser::{BasicParseError, BasicParseErrorKind, Parser}; +use cssparser::{CowRcStr, SourceLocation, ToCss, Token}; use dom::{DocumentState, ElementState, HEADING_LEVEL_OFFSET}; use selectors::parser::SelectorParseErrorKind; use std::fmt; diff --git a/servo/components/style/invalidation/element/invalidation_map.rs b/servo/components/style/invalidation/element/invalidation_map.rs @@ -820,7 +820,10 @@ fn next_dependency( kind: get_non_relative_invalidation_kind( selector, selector_offset, - next_scope_dependencies.is_some().then(|| scope_kind).flatten(), + next_scope_dependencies + .is_some() + .then(|| scope_kind) + .flatten(), ), }; @@ -835,7 +838,7 @@ fn next_dependency( next_selector, &next_outer_dependency, &next_scope_dependencies, - scope_kind + scope_kind, ) } @@ -864,7 +867,10 @@ impl<'a, 'b, 'c> Collector for SelectorDependencyCollector<'a, 'b, 'c> { kind: get_non_relative_invalidation_kind( self.selector, offset, - scope_dependencies.is_some().then(|| self.scope_dependencies.scope_kind).flatten(), + scope_dependencies + .is_some() + .then(|| self.scope_dependencies.scope_kind) + .flatten(), ), } } diff --git a/servo/components/style/invalidation/element/invalidator.rs b/servo/components/style/invalidation/element/invalidator.rs @@ -15,7 +15,7 @@ use selectors::matching::matches_compound_selector_from; use selectors::matching::{CompoundSelectorMatchingResult, MatchingContext}; use selectors::parser::{Combinator, Component}; use selectors::OpaqueElement; -use smallvec::{SmallVec, smallvec}; +use smallvec::{smallvec, SmallVec}; use std::fmt; use std::fmt::Write; @@ -130,7 +130,12 @@ where /// /// Returning true unconditionally here is over-optimistic and may /// over-invalidate. - fn check_outer_dependency(&mut self, dependency: &Dependency, element: E, scope: Option<OpaqueElement>) -> bool; + fn check_outer_dependency( + &mut self, + dependency: &Dependency, + element: E, + scope: Option<OpaqueElement>, + ) -> bool; /// The matching context that should be used to process invalidations. fn matching_context(&mut self) -> &mut MatchingContext<'b, E::Impl>; @@ -241,7 +246,7 @@ enum InvalidationKind { } /// The kind of traversal an invalidation requires. -pub enum InvalidationAddOverride{ +pub enum InvalidationAddOverride { /// This invalidation should be added to descendant invalidation Descendant, /// This invalidation should be added to sibling invalidations @@ -283,11 +288,17 @@ pub struct Invalidation<'a> { impl<'a> Invalidation<'a> { /// Create a new invalidation for matching a dependency. - pub fn new(dependency: &'a Dependency, host: Option<OpaqueElement>, scope: Option<OpaqueElement>) -> Self { + pub fn new( + dependency: &'a Dependency, + host: Option<OpaqueElement>, + scope: Option<OpaqueElement>, + ) -> Self { debug_assert!( - dependency.selector_offset == dependency.selector.len() + 1 || - dependency.invalidation_kind() != - DependencyInvalidationKind::Normal(NormalDependencyInvalidationKind::Element), + dependency.selector_offset == dependency.selector.len() + 1 + || dependency.invalidation_kind() + != DependencyInvalidationKind::Normal( + NormalDependencyInvalidationKind::Element + ), "No point to this, if the dependency matched the element we should just invalidate it" ); Self { @@ -308,10 +319,10 @@ impl<'a> Invalidation<'a> { pub fn new_subject_invalidation( dependency: &'a Dependency, host: Option<OpaqueElement>, - scope: Option<OpaqueElement> + scope: Option<OpaqueElement>, ) -> Self { let mut compound_offset = 0; - for s in dependency.selector.iter_raw_match_order(){ + for s in dependency.selector.iter_raw_match_order() { if s.is_combinator() { break; } @@ -917,7 +928,7 @@ where invalidation: &Invalidation<'b>, descendant_invalidations: &mut DescendantInvalidationLists<'b>, sibling_invalidations: &mut InvalidationVector<'b>, - ) -> (ProcessInvalidationResult, SmallVec<[Invalidation<'b>; 1]>){ + ) -> (ProcessInvalidationResult, SmallVec<[Invalidation<'b>; 1]>) { debug!(" > Invalidation matched completely"); // We matched completely. If we're an inner selector now we need // to go outside our selector and carry on invalidating. @@ -932,19 +943,19 @@ where let mut next_dependencies: SmallVec<[&Dependency; 1]> = SmallVec::new(); while let Some(dependency) = to_process.pop() { - if dependency.invalidation_kind() == - DependencyInvalidationKind::Scope(ScopeDependencyInvalidationKind::ScopeEnd) + if dependency.invalidation_kind() + == DependencyInvalidationKind::Scope(ScopeDependencyInvalidationKind::ScopeEnd) { - let invalidations = note_scope_dependency_force_at_subject( - dependency, - invalidation.host, - ); - for (invalidation, override_type) in invalidations{ + let invalidations = + note_scope_dependency_force_at_subject(dependency, invalidation.host); + for (invalidation, override_type) in invalidations { match override_type { - InvalidationAddOverride::Descendant - => descendant_invalidations.dom_descendants.push(invalidation), - InvalidationAddOverride::Sibling - => sibling_invalidations.push(invalidation), + InvalidationAddOverride::Descendant => { + descendant_invalidations.dom_descendants.push(invalidation) + }, + InvalidationAddOverride::Sibling => { + sibling_invalidations.push(invalidation) + }, } } continue; @@ -955,8 +966,7 @@ where result.matched = true; }, Some(ref deps) => { - for n in deps.as_ref().slice(){ - + for n in deps.as_ref().slice() { let invalidation_kind = n.invalidation_kind(); match invalidation_kind { DependencyInvalidationKind::FullSelector => unreachable!(), @@ -979,30 +989,31 @@ where }; } - - for cur_dependency in next_dependencies.as_ref(){ - let scope = matches!(invalidation.dependency.invalidation_kind(), DependencyInvalidationKind::Scope(_)).then(|| self.element.opaque()); + for cur_dependency in next_dependencies.as_ref() { + let scope = matches!( + invalidation.dependency.invalidation_kind(), + DependencyInvalidationKind::Scope(_) + ) + .then(|| self.element.opaque()); debug!(" > Checking outer dependency {:?}", cur_dependency); // The inner selector changed, now check if the full // previous part of the selector did, before keeping // checking for descendants. if !self - .processor - .check_outer_dependency(cur_dependency, self.element, scope) + .processor + .check_outer_dependency(cur_dependency, self.element, scope) { // Dependency is not relevant, do not note it down continue; } let invalidation_kind = cur_dependency.invalidation_kind(); - if matches!(invalidation_kind, - DependencyInvalidationKind::Normal(NormalDependencyInvalidationKind::Element)) - || ( - matches!(invalidation_kind, - DependencyInvalidationKind::Scope(_)) - && cur_dependency.selector_offset == 0 - ) + if matches!( + invalidation_kind, + DependencyInvalidationKind::Normal(NormalDependencyInvalidationKind::Element) + ) || (matches!(invalidation_kind, DependencyInvalidationKind::Scope(_)) + && cur_dependency.selector_offset == 0) { // Add to dependency stack to process its next dependencies. to_process.push(cur_dependency); @@ -1010,13 +1021,14 @@ where } debug!(" > Generating invalidation"); - next_invalidations.push(Invalidation::new(cur_dependency, invalidation.host, scope)); + next_invalidations.push(Invalidation::new( + cur_dependency, + invalidation.host, + scope, + )); } } - return ( - result, - next_invalidations - ); + return (result, next_invalidations); } /// Processes a given invalidation, potentially invalidating the style of @@ -1041,7 +1053,7 @@ where let context = self.processor.matching_context(); context.current_host = invalidation.host; - context.nest_for_scope_condition(invalidation.scope,|ctx| { + context.nest_for_scope_condition(invalidation.scope, |ctx| { matches_compound_selector_from( &invalidation.dependency.selector, invalidation.offset, @@ -1058,9 +1070,11 @@ where matched: false, } }, - CompoundSelectorMatchingResult::FullyMatched => { - self.handle_fully_matched(invalidation, descendant_invalidations, sibling_invalidations) - }, + CompoundSelectorMatchingResult::FullyMatched => self.handle_fully_matched( + invalidation, + descendant_invalidations, + sibling_invalidations, + ), CompoundSelectorMatchingResult::Matched { next_combinator_offset, } => ( @@ -1079,7 +1093,7 @@ where }; let mut invalidated_self = result.invalidated_self; - for next_invalidation in next_invalidations{ + for next_invalidation in next_invalidations { debug_assert_ne!( next_invalidation.offset, 0, "Rightmost selectors shouldn't generate more invalidations", @@ -1236,15 +1250,19 @@ pub fn note_scope_dependency_force_at_subject<'selectors>( dependency: &'selectors Dependency, current_host: Option<OpaqueElement>, ) -> Vec<(Invalidation<'selectors>, InvalidationAddOverride)> { - let mut invalidations_and_override_types: Vec<(Invalidation, InvalidationAddOverride)> = Vec::new(); + let mut invalidations_and_override_types: Vec<(Invalidation, InvalidationAddOverride)> = + Vec::new(); if let Some(next) = dependency.next.as_ref() { for dep in next.slice() { - if dep.selector_offset == 0 { continue; } + if dep.selector_offset == 0 { + continue; + } - let invalidation = - Invalidation::new_subject_invalidation(dep, current_host, None); + let invalidation = Invalidation::new_subject_invalidation(dep, current_host, None); - let combinator = dep.selector.combinator_at_match_order(dep.selector_offset - 1); + let combinator = dep + .selector + .combinator_at_match_order(dep.selector_offset - 1); let invalidation_override = match combinator.is_sibling() { true => InvalidationAddOverride::Sibling, @@ -1253,12 +1271,7 @@ pub fn note_scope_dependency_force_at_subject<'selectors>( invalidations_and_override_types.push((invalidation, invalidation_override)); invalidations_and_override_types - .extend( - note_scope_dependency_force_at_subject( - dep, - current_host, - ) - ); + .extend(note_scope_dependency_force_at_subject(dep, current_host)); } } invalidations_and_override_types diff --git a/servo/components/style/invalidation/element/relative_selector.rs b/servo/components/style/invalidation/element/relative_selector.rs @@ -507,8 +507,9 @@ where for invalidation in self.invalidations { match invalidation.dependency.invalidation_kind() { DependencyInvalidationKind::FullSelector => unreachable!(), - DependencyInvalidationKind::Normal(_) | DependencyInvalidationKind::Scope(_) => - unreachable!("Inner selector in invalidation?"), + DependencyInvalidationKind::Normal(_) | DependencyInvalidationKind::Scope(_) => { + unreachable!("Inner selector in invalidation?") + }, DependencyInvalidationKind::Relative(kind) => { if let Some(context) = self.optimization_context.as_ref() { if context.can_be_ignored( @@ -1003,8 +1004,7 @@ where debug_assert!( matches!( outer_dependency.invalidation_kind(), - DependencyInvalidationKind::Normal(_) | - DependencyInvalidationKind::Scope(_) + DependencyInvalidationKind::Normal(_) | DependencyInvalidationKind::Scope(_) ), "Outer selector of relative selector is relative?" ); @@ -1048,7 +1048,12 @@ where true } - fn check_outer_dependency(&mut self, _dependency: &Dependency, _element: E, _: Option<OpaqueElement>) -> bool { + fn check_outer_dependency( + &mut self, + _dependency: &Dependency, + _element: E, + _: Option<OpaqueElement>, + ) -> bool { // At this point, we know a relative selector invalidated, and are ignoring them. true } @@ -1084,9 +1089,11 @@ where let mut d = self.dependency; loop { debug_assert!( - matches!(d.invalidation_kind(), - DependencyInvalidationKind::Normal(_) | - DependencyInvalidationKind::Scope(_)), + matches!( + d.invalidation_kind(), + DependencyInvalidationKind::Normal(_) + | DependencyInvalidationKind::Scope(_) + ), "Unexpected dependency kind" ); if !dependency_may_be_relevant(d, &element, false) { @@ -1102,9 +1109,11 @@ where break false; } let invalidation_kind = d.invalidation_kind(); - if matches!(invalidation_kind, - DependencyInvalidationKind::Normal(NormalDependencyInvalidationKind::Element) | - DependencyInvalidationKind::Scope(_)){ + if matches!( + invalidation_kind, + DependencyInvalidationKind::Normal(NormalDependencyInvalidationKind::Element) + | DependencyInvalidationKind::Scope(_) + ) { if let Some(ref deps) = d.next { d = &deps.as_ref().slice()[0]; continue; @@ -1268,10 +1277,21 @@ impl<'a, 'b, 'c, E> InvalidationProcessor<'a, 'b, E> where E: TElement + 'a, { - fn check_outer_dependency(&mut self, dependency: &Dependency, element: E, _: Option<OpaqueElement>) -> bool { + fn check_outer_dependency( + &mut self, + dependency: &Dependency, + element: E, + _: Option<OpaqueElement>, + ) -> bool { if let Some(snapshot_table) = self.snapshot_table { let wrapper = ElementWrapper::new(element, snapshot_table); - return check_dependency(dependency, &element, &wrapper, &mut self.matching_context, None); + return check_dependency( + dependency, + &element, + &wrapper, + &mut self.matching_context, + None, + ); } // Just invalidate if we don't have a snapshot. true diff --git a/servo/components/style/invalidation/element/state_and_attributes.rs b/servo/components/style/invalidation/element/state_and_attributes.rs @@ -11,7 +11,8 @@ use crate::dom::{TElement, TNode}; use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper}; use crate::invalidation::element::invalidation_map::*; use crate::invalidation::element::invalidator::{ - note_scope_dependency_force_at_subject, DescendantInvalidationLists, InvalidationAddOverride, InvalidationVector, SiblingTraversalMap + note_scope_dependency_force_at_subject, DescendantInvalidationLists, InvalidationAddOverride, + InvalidationVector, SiblingTraversalMap, }; use crate::invalidation::element::invalidator::{Invalidation, InvalidationProcessor}; use crate::invalidation::element::restyle_hints::RestyleHint; @@ -105,8 +106,7 @@ where W: selectors::Element<Impl = E::Impl>, { context.for_invalidation_comparison(|context| { - context.nest_for_scope_condition(scope, |context|{ - + context.nest_for_scope_condition(scope, |context| { let matches_now = matches_selector_kleene( &dependency.selector, dependency.selector_offset, @@ -230,12 +230,23 @@ where true } - fn check_outer_dependency(&mut self, dependency: &Dependency, element: E, scope: Option<OpaqueElement>) -> bool { + fn check_outer_dependency( + &mut self, + dependency: &Dependency, + element: E, + scope: Option<OpaqueElement>, + ) -> bool { // We cannot assert about `element` having a snapshot here (in fact it // most likely won't), because it may be an arbitrary descendant or // later-sibling of the element we started invalidating with. let wrapper = ElementWrapper::new(element, &*self.shared_context.snapshot_map); - check_dependency(dependency, &element, &wrapper, &mut self.matching_context, scope) + check_dependency( + dependency, + &element, + &wrapper, + &mut self.matching_context, + scope, + ) } fn matching_context(&mut self) -> &mut MatchingContext<'a, E::Impl> { @@ -552,7 +563,8 @@ where return; } - if self.check_dependency(dependency, set_scope) || matches!( + if self.check_dependency(dependency, set_scope) + || matches!( dependency.invalidation_kind(), DependencyInvalidationKind::Scope(_) ) @@ -564,7 +576,10 @@ where fn note_dependency(&mut self, dependency: &'selectors Dependency) { debug_assert!(self.dependency_may_be_relevant(dependency)); let invalidation_kind = dependency.invalidation_kind(); - if matches!(invalidation_kind, DependencyInvalidationKind::Normal(NormalDependencyInvalidationKind::Element)) { + if matches!( + invalidation_kind, + DependencyInvalidationKind::Normal(NormalDependencyInvalidationKind::Element) + ) { if let Some(ref next) = dependency.next { // We know something changed in the inner selector, go outwards // now. @@ -584,28 +599,37 @@ where ); for (invalidation, override_type) in invalidations { match override_type { - InvalidationAddOverride::Descendant - => self.descendant_invalidations.dom_descendants.push(invalidation), - InvalidationAddOverride::Sibling - => self.sibling_invalidations.push(invalidation), + InvalidationAddOverride::Descendant => self + .descendant_invalidations + .dom_descendants + .push(invalidation), + InvalidationAddOverride::Sibling => { + self.sibling_invalidations.push(invalidation) + }, } } self.invalidates_self = true; - - } else if let Some(ref next) = dependency.next{ - for dep in next.as_ref().slice(){ + } else if let Some(ref next) = dependency.next { + for dep in next.as_ref().slice() { self.scan_dependency(dep, true); } } } else { - let invalidation = - Invalidation::new(&dependency, self.matching_context.current_host.clone(), None); + let invalidation = Invalidation::new( + &dependency, + self.matching_context.current_host.clone(), + None, + ); - let combinator = dependency.selector.combinator_at_match_order(dependency.selector_offset - 1); + let combinator = dependency + .selector + .combinator_at_match_order(dependency.selector_offset - 1); if combinator.is_sibling() { self.sibling_invalidations.push(invalidation); } else { - self.descendant_invalidations.dom_descendants.push(invalidation); + self.descendant_invalidations + .dom_descendants + .push(invalidation); } } return; @@ -614,8 +638,11 @@ where debug_assert_ne!(dependency.selector_offset, 0); debug_assert_ne!(dependency.selector_offset, dependency.selector.len()); - let invalidation = - Invalidation::new(&dependency, self.matching_context.current_host.clone(), self.matching_context.scope_element.clone()); + let invalidation = Invalidation::new( + &dependency, + self.matching_context.current_host.clone(), + self.matching_context.scope_element.clone(), + ); self.invalidates_self |= push_invalidation( invalidation, @@ -629,20 +656,19 @@ where /// more elements than what we've already invalidated. fn dependency_may_be_relevant(&self, dependency: &Dependency) -> bool { match dependency.invalidation_kind() { - DependencyInvalidationKind::FullSelector | - DependencyInvalidationKind::Relative(_) => unreachable!(), + DependencyInvalidationKind::FullSelector | DependencyInvalidationKind::Relative(_) => { + unreachable!() + }, DependencyInvalidationKind::Scope(_) => true, - DependencyInvalidationKind::Normal(kind) => { - match kind { - NormalDependencyInvalidationKind::Element => !self.invalidates_self, - NormalDependencyInvalidationKind::SlottedElements => { - self.element.is_html_slot_element() - }, - NormalDependencyInvalidationKind::Parts => self.element.shadow_root().is_some(), - NormalDependencyInvalidationKind::ElementAndDescendants | - NormalDependencyInvalidationKind::Siblings | - NormalDependencyInvalidationKind::Descendants => true, - } + DependencyInvalidationKind::Normal(kind) => match kind { + NormalDependencyInvalidationKind::Element => !self.invalidates_self, + NormalDependencyInvalidationKind::SlottedElements => { + self.element.is_html_slot_element() + }, + NormalDependencyInvalidationKind::Parts => self.element.shadow_root().is_some(), + NormalDependencyInvalidationKind::ElementAndDescendants + | NormalDependencyInvalidationKind::Siblings + | NormalDependencyInvalidationKind::Descendants => true, }, } } @@ -661,33 +687,31 @@ pub(crate) fn push_invalidation<'a>( descendant_invalidations.dom_descendants.push(invalidation); true }, - DependencyInvalidationKind::Normal(kind) => { - match kind { - NormalDependencyInvalidationKind::Element => unreachable!(), - NormalDependencyInvalidationKind::ElementAndDescendants => { - descendant_invalidations.dom_descendants.push(invalidation); - true - }, - NormalDependencyInvalidationKind::Descendants => { - descendant_invalidations.dom_descendants.push(invalidation); - false - }, - NormalDependencyInvalidationKind::Siblings => { - sibling_invalidations.push(invalidation); - false - }, - NormalDependencyInvalidationKind::Parts => { - descendant_invalidations.parts.push(invalidation); - false - }, - NormalDependencyInvalidationKind::SlottedElements => { - descendant_invalidations + DependencyInvalidationKind::Normal(kind) => match kind { + NormalDependencyInvalidationKind::Element => unreachable!(), + NormalDependencyInvalidationKind::ElementAndDescendants => { + descendant_invalidations.dom_descendants.push(invalidation); + true + }, + NormalDependencyInvalidationKind::Descendants => { + descendant_invalidations.dom_descendants.push(invalidation); + false + }, + NormalDependencyInvalidationKind::Siblings => { + sibling_invalidations.push(invalidation); + false + }, + NormalDependencyInvalidationKind::Parts => { + descendant_invalidations.parts.push(invalidation); + false + }, + NormalDependencyInvalidationKind::SlottedElements => { + descendant_invalidations .slotted_descendants .push(invalidation); false - }, - } - } + }, + }, } } @@ -700,15 +724,13 @@ pub(crate) fn dependency_may_be_relevant<E: TElement>( DependencyInvalidationKind::FullSelector => unreachable!(), DependencyInvalidationKind::Relative(_) => unreachable!(), DependencyInvalidationKind::Scope(_) => true, - DependencyInvalidationKind::Normal(kind) => { - match kind { - NormalDependencyInvalidationKind::Element => !already_invalidated_self, - NormalDependencyInvalidationKind::SlottedElements => element.is_html_slot_element(), - NormalDependencyInvalidationKind::Parts => element.shadow_root().is_some(), - NormalDependencyInvalidationKind::ElementAndDescendants | - NormalDependencyInvalidationKind::Siblings | - NormalDependencyInvalidationKind::Descendants => true, - } + DependencyInvalidationKind::Normal(kind) => match kind { + NormalDependencyInvalidationKind::Element => !already_invalidated_self, + NormalDependencyInvalidationKind::SlottedElements => element.is_html_slot_element(), + NormalDependencyInvalidationKind::Parts => element.shadow_root().is_some(), + NormalDependencyInvalidationKind::ElementAndDescendants + | NormalDependencyInvalidationKind::Siblings + | NormalDependencyInvalidationKind::Descendants => true, }, } } diff --git a/servo/components/style/servo/animation.rs b/servo/components/style/servo/animation.rs @@ -29,8 +29,8 @@ use crate::values::computed::TimingFunction; use crate::values::generics::easing::BeforeFlag; use crate::values::specified::TransitionBehavior; use crate::Atom; -use rustc_hash::FxHashMap; use parking_lot::RwLock; +use rustc_hash::FxHashMap; use servo_arc::Arc; use std::fmt; diff --git a/servo/components/style/stylesheets/stylesheet.rs b/servo/components/style/stylesheets/stylesheet.rs @@ -16,10 +16,10 @@ use crate::stylesheets::{CssRule, CssRules, Origin, UrlExtraData}; use crate::use_counters::UseCounters; use crate::{Namespace, Prefix}; use cssparser::{Parser, ParserInput, StyleSheetParser}; -use rustc_hash::FxHashMap; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOfOps, MallocUnconditionalShallowSizeOf}; use parking_lot::RwLock; +use rustc_hash::FxHashMap; use servo_arc::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use style_traits::ParsingMode; diff --git a/servo/components/style/stylist.rs b/servo/components/style/stylist.rs @@ -3435,10 +3435,8 @@ impl CascadeData { nth_of_mapped_ids: &mut self.nth_of_mapped_ids, attribute_dependencies: &mut self.attribute_dependencies, nth_of_class_dependencies: &mut self.nth_of_class_dependencies, - nth_of_attribute_dependencies: &mut self - .nth_of_attribute_dependencies, - nth_of_custom_state_dependencies: &mut self - .nth_of_custom_state_dependencies, + nth_of_attribute_dependencies: &mut self.nth_of_attribute_dependencies, + nth_of_custom_state_dependencies: &mut self.nth_of_custom_state_dependencies, state_dependencies: &mut self.state_dependencies, nth_of_state_dependencies: &mut self.nth_of_state_dependencies, document_state_dependencies: &mut self.document_state_dependencies, diff --git a/servo/components/style/values/specified/position.rs b/servo/components/style/values/specified/position.rs @@ -885,7 +885,7 @@ pub enum PositionAreaKeyword { #[css(skip)] Span = 1u8 << 5, #[css(skip)] - SelfWM = 1u8 << 6, // use target's writing-mode to resolve logical edges + SelfWM = 1u8 << 6, // use target's writing-mode to resolve logical edges // Composite values with Span: SpanLeft = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::Left as u8, @@ -921,18 +921,38 @@ pub enum PositionAreaKeyword { SelfEnd = PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::End as u8, // Values with Span and SelfWM: - SpanXSelfStart = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::XStart as u8, - SpanXSelfEnd = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::XEnd as u8, - SpanYSelfStart = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::YStart as u8, - SpanYSelfEnd = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::YEnd as u8, - - SpanSelfBlockStart = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::BlockStart as u8, - SpanSelfBlockEnd = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::BlockEnd as u8, - SpanSelfInlineStart = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::InlineStart as u8, - SpanSelfInlineEnd = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::InlineEnd as u8, - - SpanSelfStart = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::Start as u8, - SpanSelfEnd = PositionAreaKeyword::Span as u8 | PositionAreaKeyword::SelfWM as u8 | PositionAreaKeyword::End as u8, + SpanXSelfStart = PositionAreaKeyword::Span as u8 + | PositionAreaKeyword::SelfWM as u8 + | PositionAreaKeyword::XStart as u8, + SpanXSelfEnd = PositionAreaKeyword::Span as u8 + | PositionAreaKeyword::SelfWM as u8 + | PositionAreaKeyword::XEnd as u8, + SpanYSelfStart = PositionAreaKeyword::Span as u8 + | PositionAreaKeyword::SelfWM as u8 + | PositionAreaKeyword::YStart as u8, + SpanYSelfEnd = PositionAreaKeyword::Span as u8 + | PositionAreaKeyword::SelfWM as u8 + | PositionAreaKeyword::YEnd as u8, + + SpanSelfBlockStart = PositionAreaKeyword::Span as u8 + | PositionAreaKeyword::SelfWM as u8 + | PositionAreaKeyword::BlockStart as u8, + SpanSelfBlockEnd = PositionAreaKeyword::Span as u8 + | PositionAreaKeyword::SelfWM as u8 + | PositionAreaKeyword::BlockEnd as u8, + SpanSelfInlineStart = PositionAreaKeyword::Span as u8 + | PositionAreaKeyword::SelfWM as u8 + | PositionAreaKeyword::InlineStart as u8, + SpanSelfInlineEnd = PositionAreaKeyword::Span as u8 + | PositionAreaKeyword::SelfWM as u8 + | PositionAreaKeyword::InlineEnd as u8, + + SpanSelfStart = PositionAreaKeyword::Span as u8 + | PositionAreaKeyword::SelfWM as u8 + | PositionAreaKeyword::Start as u8, + SpanSelfEnd = PositionAreaKeyword::Span as u8 + | PositionAreaKeyword::SelfWM as u8 + | PositionAreaKeyword::End as u8, } #[allow(missing_docs)] diff --git a/taskcluster/docker/image_builder/build-image/src/taskcluster.rs b/taskcluster/docker/image_builder/build-image/src/taskcluster.rs @@ -12,7 +12,9 @@ pub struct TaskCluster { impl TaskCluster { pub fn from_env() -> Result<Self> { let root_url = if let Ok(proxy_url) = std::env::var("TASKCLUSTER_PROXY_URL") { - proxy_url.parse().context("Couldn't parse TASKCLUSTER_PROXY_URL.")? + proxy_url + .parse() + .context("Couldn't parse TASKCLUSTER_PROXY_URL.")? } else { std::env::var("TASKCLUSTER_ROOT_URL") .context("TASKCLUSTER_ROOT_URL not set.") @@ -63,7 +65,10 @@ mod test { #[test] fn test_from_env_proxy_url() { env::set_var("TASKCLUSTER_PROXY_URL", "http://taskcluster"); - env::set_var("TASKCLUSTER_ROOT_URL", "https://firefox-ci-tc.services.mozilla.com"); + env::set_var( + "TASKCLUSTER_ROOT_URL", + "https://firefox-ci-tc.services.mozilla.com", + ); let cluster = super::TaskCluster::from_env().unwrap(); assert_eq!(cluster.root_url.as_str(), "http://taskcluster/"); @@ -75,10 +80,16 @@ mod test { #[test] fn test_from_env_fallback_to_root_url() { env::remove_var("TASKCLUSTER_PROXY_URL"); - env::set_var("TASKCLUSTER_ROOT_URL", "https://firefox-ci-tc.services.mozilla.com"); + env::set_var( + "TASKCLUSTER_ROOT_URL", + "https://firefox-ci-tc.services.mozilla.com", + ); let cluster = super::TaskCluster::from_env().unwrap(); - assert_eq!(cluster.root_url.as_str(), "https://firefox-ci-tc.services.mozilla.com/"); + assert_eq!( + cluster.root_url.as_str(), + "https://firefox-ci-tc.services.mozilla.com/" + ); env::remove_var("TASKCLUSTER_ROOT_URL"); } diff --git a/toolkit/components/glean/api/src/private/boolean.rs b/toolkit/components/glean/api/src/private/boolean.rs @@ -195,7 +195,9 @@ mod test { let metric = &metrics::test_only_ipc::a_bool; metric.set(true); - assert!(metric.test_get_value(Some("test-ping".to_string())).unwrap()); + assert!(metric + .test_get_value(Some("test-ping".to_string())) + .unwrap()); } #[test] @@ -223,7 +225,10 @@ mod test { assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok()); assert!( - false == parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(), + false + == parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(), "Boolean metrics should only work in the parent process" ); } @@ -249,7 +254,9 @@ mod test { assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok()); assert!( - !parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(), + !parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(), "Boolean metrics can unsafely work in child processes" ); } diff --git a/toolkit/components/glean/api/src/private/counter.rs b/toolkit/components/glean/api/src/private/counter.rs @@ -225,7 +225,12 @@ mod test { let metric = &metrics::test_only_ipc::a_counter; metric.add(1); - assert_eq!(1, metric.test_get_value(Some("test-ping".to_string())).unwrap()); + assert_eq!( + 1, + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() + ); } #[test] @@ -262,7 +267,9 @@ mod test { assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok()); assert!( - 45 == parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(), + 45 == parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(), "Values from the 'processes' should be summed" ); } diff --git a/toolkit/components/glean/api/src/private/custom_distribution.rs b/toolkit/components/glean/api/src/private/custom_distribution.rs @@ -225,7 +225,9 @@ mod test { metric.accumulate_samples_signed(vec![1, 2, 3]); - assert!(metric.test_get_value(Some("test-ping".to_string())).is_some()); + assert!(metric + .test_get_value(Some("test-ping".to_string())) + .is_some()); } #[test] diff --git a/toolkit/components/glean/api/src/private/datetime.rs b/toolkit/components/glean/api/src/private/datetime.rs @@ -339,7 +339,12 @@ mod test { let expected: glean::Datetime = DateTime::parse_from_rfc3339("2020-05-07T11:58:00+05:00") .unwrap() .into(); - assert_eq!(expected, metric.test_get_value(Some("test-ping".to_string())).unwrap()); + assert_eq!( + expected, + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() + ); } #[test] @@ -353,7 +358,12 @@ mod test { let expected: glean::Datetime = DateTime::parse_from_rfc3339("2020-05-07T11:58:00+05:00") .unwrap() .into(); - assert_eq!(expected, metric.test_get_value(Some("test-ping".to_string())).unwrap()); + assert_eq!( + expected, + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() + ); } #[test] @@ -387,6 +397,11 @@ mod test { let expected: glean::Datetime = DateTime::parse_from_rfc3339("2020-10-13T16:41:00+05:00") .unwrap() .into(); - assert_eq!(expected, parent_metric.test_get_value(Some("test-ping".to_string())).unwrap()); + assert_eq!( + expected, + parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() + ); } } diff --git a/toolkit/components/glean/api/src/private/denominator.rs b/toolkit/components/glean/api/src/private/denominator.rs @@ -142,7 +142,12 @@ mod test { let metric = &metrics::test_only_ipc::an_external_denominator; metric.add(1); - assert_eq!(1, metric.test_get_value(Some("test-ping".to_string())).unwrap()); + assert_eq!( + 1, + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() + ); } #[test] @@ -178,7 +183,9 @@ mod test { assert_eq!( 45, - parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(), + parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(), "Values from the 'processes' should be summed" ); } diff --git a/toolkit/components/glean/api/src/private/event.rs b/toolkit/components/glean/api/src/private/event.rs @@ -246,7 +246,9 @@ mod test { // No extra keys metric.record(None); - let recorded = metric.test_get_value(Some("test-ping".to_string())).unwrap(); + let recorded = metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(); assert!(recorded.iter().any(|e| e.name == "event_metric")); } @@ -286,7 +288,9 @@ mod test { assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok()); - let events = parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(); + let events = parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(); assert_eq!(events.len(), 4); // Events from the child process are last, they might get sorted later by Glean. diff --git a/toolkit/components/glean/api/src/private/labeled.rs b/toolkit/components/glean/api/src/private/labeled.rs @@ -518,8 +518,16 @@ mod test { metric.get("upload").set(true); - assert!(metric.get("upload").test_get_value(Some("test-ping".to_string())).unwrap()); - assert_eq!(None, metric.get("download").test_get_value(Some("test-ping".to_string()))); + assert!(metric + .get("upload") + .test_get_value(Some("test-ping".to_string())) + .unwrap()); + assert_eq!( + None, + metric + .get("download") + .test_get_value(Some("test-ping".to_string())) + ); } #[test] @@ -545,9 +553,17 @@ mod test { assert_eq!( "Glean", - metric.get("upload").test_get_value(Some("test-ping".to_string())).unwrap() + metric + .get("upload") + .test_get_value(Some("test-ping".to_string())) + .unwrap() + ); + assert_eq!( + None, + metric + .get("download") + .test_get_value(Some("test-ping".to_string())) ); - assert_eq!(None, metric.get("download").test_get_value(Some("test-ping".to_string()))); } #[test] @@ -573,9 +589,17 @@ mod test { assert_eq!( 10, - metric.get("upload").test_get_value(Some("test-ping".to_string())).unwrap() + metric + .get("upload") + .test_get_value(Some("test-ping".to_string())) + .unwrap() + ); + assert_eq!( + None, + metric + .get("download") + .test_get_value(Some("test-ping".to_string())) ); - assert_eq!(None, metric.get("download").test_get_value(Some("test-ping".to_string()))); } #[test] @@ -635,16 +659,25 @@ mod test { assert_eq!( true, - metric.get("label1").test_get_value(Some("test-ping".to_string())).unwrap() + metric + .get("label1") + .test_get_value(Some("test-ping".to_string())) + .unwrap() ); assert_eq!( false, - metric.get("label2").test_get_value(Some("test-ping".to_string())).unwrap() + metric + .get("label2") + .test_get_value(Some("test-ping".to_string())) + .unwrap() ); // The label not in the predefined set is recorded to the `other` bucket. assert_eq!( true, - metric.get("__other__").test_get_value(Some("test-ping".to_string())).unwrap() + metric + .get("__other__") + .test_get_value(Some("test-ping".to_string())) + .unwrap() ); assert_eq!( diff --git a/toolkit/components/glean/api/src/private/labeled_boolean.rs b/toolkit/components/glean/api/src/private/labeled_boolean.rs @@ -134,7 +134,10 @@ mod test { let metric = &metrics::test_only_ipc::an_unordered_labeled_boolean; metric.get("a_label").set(true); - assert!(metric.get("a_label").test_get_value(Some("test-ping".to_string())).unwrap()); + assert!(metric + .get("a_label") + .test_get_value(Some("test-ping".to_string())) + .unwrap()); } #[test] diff --git a/toolkit/components/glean/api/src/private/labeled_counter.rs b/toolkit/components/glean/api/src/private/labeled_counter.rs @@ -174,7 +174,10 @@ mod test { assert_eq!( 1, - metric.get("a_label").test_get_value(Some("test-ping".to_string())).unwrap() + metric + .get("a_label") + .test_get_value(Some("test-ping".to_string())) + .unwrap() ); } diff --git a/toolkit/components/glean/api/src/private/memory_distribution.rs b/toolkit/components/glean/api/src/private/memory_distribution.rs @@ -271,7 +271,9 @@ mod test { metric.accumulate(42); - let metric_data = metric.test_get_value(Some("test-ping".to_string())).unwrap(); + let metric_data = metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(); assert_eq!(1, metric_data.values[&42494]); assert_eq!(43008, metric_data.sum); } @@ -291,7 +293,9 @@ mod test { child_metric.accumulate(13 * 9); } - let metric_data = parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(); + let metric_data = parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(); assert_eq!(1, metric_data.values[&42494]); assert_eq!(43008, metric_data.sum); diff --git a/toolkit/components/glean/api/src/private/numerator.rs b/toolkit/components/glean/api/src/private/numerator.rs @@ -138,7 +138,13 @@ mod test { let metric = &metrics::test_only_ipc::rate_with_external_denominator; metric.add_to_numerator(1); - assert_eq!(1, metric.test_get_value(Some("test-ping".to_string())).unwrap().numerator); + assert_eq!( + 1, + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() + .numerator + ); } #[test] @@ -171,7 +177,10 @@ mod test { assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok()); assert!( - 45 == parent_metric.test_get_value(Some("test-ping".to_string())).unwrap().numerator, + 45 == parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() + .numerator, "Values from the 'processes' should be summed" ); } diff --git a/toolkit/components/glean/api/src/private/quantity.rs b/toolkit/components/glean/api/src/private/quantity.rs @@ -150,7 +150,12 @@ mod test { let metric = &metrics::test_only_ipc::a_quantity; metric.set(14); - assert_eq!(14, metric.test_get_value(Some("test-ping".to_string())).unwrap()); + assert_eq!( + 14, + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() + ); } #[test] diff --git a/toolkit/components/glean/api/src/private/rate.rs b/toolkit/components/glean/api/src/private/rate.rs @@ -178,7 +178,9 @@ mod test { numerator: 1, denominator: 100 }, - metric.test_get_value(Some("test-ping".to_string())).unwrap() + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() ); } @@ -219,7 +221,9 @@ mod test { numerator: 45, denominator: 33 }, - parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(), + parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(), "Values from the 'processes' should be summed" ); } diff --git a/toolkit/components/glean/api/src/private/string.rs b/toolkit/components/glean/api/src/private/string.rs @@ -172,7 +172,9 @@ mod test { assert_eq!( "test_string_value", - metric.test_get_value(Some("test-ping".to_string())).unwrap() + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() ); } @@ -200,7 +202,10 @@ mod test { assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok()); assert!( - "test_parent_value" == parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(), + "test_parent_value" + == parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(), "String metrics should only work in the parent process" ); } diff --git a/toolkit/components/glean/api/src/private/string_list.rs b/toolkit/components/glean/api/src/private/string_list.rs @@ -198,7 +198,9 @@ mod test { assert_eq!( vec!["test_string_value", "another test value"], - metric.test_get_value(Some("test-ping".to_string())).unwrap() + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() ); } @@ -231,7 +233,9 @@ mod test { assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok()); assert_eq!( vec!["test_string_value", "another test value"], - parent_metric.test_get_value(Some("test-ping".to_string())).unwrap() + parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() ); } } diff --git a/toolkit/components/glean/api/src/private/text.rs b/toolkit/components/glean/api/src/private/text.rs @@ -168,7 +168,9 @@ mod test { assert_eq!( "test_text_value", - metric.test_get_value(Some("test-ping".to_string())).unwrap() + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() ); } @@ -196,7 +198,10 @@ mod test { assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok()); assert!( - "test_parent_value" == parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(), + "test_parent_value" + == parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(), "Text metrics should only work in the parent process" ); } diff --git a/toolkit/components/glean/api/src/private/timing_distribution.rs b/toolkit/components/glean/api/src/private/timing_distribution.rs @@ -855,7 +855,9 @@ mod test { metric.cancel(id); // We can't inspect the values yet. - assert!(metric.test_get_value(Some("test-ping".to_string())).is_none()); + assert!(metric + .test_get_value(Some("test-ping".to_string())) + .is_none()); } #[test] diff --git a/toolkit/components/glean/api/src/private/url.rs b/toolkit/components/glean/api/src/private/url.rs @@ -169,7 +169,9 @@ mod test { assert_eq!( "https://example.com", - metric.test_get_value(Some("test-ping".to_string())).unwrap() + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() ); } @@ -197,7 +199,10 @@ mod test { assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok()); assert!( - "https://example.com/parent" == parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(), + "https://example.com/parent" + == parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(), "Url metrics should only work in the parent process" ); } diff --git a/toolkit/components/glean/api/src/private/uuid.rs b/toolkit/components/glean/api/src/private/uuid.rs @@ -179,7 +179,12 @@ mod test { let expected = Uuid::new_v4(); metric.set(expected.clone()); - assert_eq!(expected, metric.test_get_value(Some("test-ping".to_string())).unwrap()); + assert_eq!( + expected, + metric + .test_get_value(Some("test-ping".to_string())) + .unwrap() + ); } #[test] @@ -205,7 +210,9 @@ mod test { assert_eq!( expected, - parent_metric.test_get_value(Some("test-ping".to_string())).unwrap(), + parent_metric + .test_get_value(Some("test-ping".to_string())) + .unwrap(), "UUID metrics should only work in the parent process" ); } diff --git a/toolkit/components/glean/src/init/viaduct_uploader.rs b/toolkit/components/glean/src/init/viaduct_uploader.rs @@ -6,7 +6,7 @@ use glean::net::{CapablePingUploadRequest, PingUploadRequest, PingUploader, Uplo use once_cell::sync::OnceCell; use std::sync::Once; use url::Url; -use viaduct::{ViaductError::*, Request}; +use viaduct::{Request, ViaductError::*}; extern "C" { fn FOG_TooLateToSend() -> bool; @@ -68,7 +68,9 @@ impl PingUploader for ViaductUploader { match result { Ok(result) => result, Err(ViaductUploaderError::Viaduct(ve)) => match ve { - NonTlsUrl | UrlError(_) | BackendAlreadyInitialized => UploadResult::unrecoverable_failure(), + NonTlsUrl | UrlError(_) | BackendAlreadyInitialized => { + UploadResult::unrecoverable_failure() + } RequestHeaderError(_) | BackendError(_) | NetworkError(_) diff --git a/toolkit/components/places/bookmark_sync/src/merger.rs b/toolkit/components/places/bookmark_sync/src/merger.rs @@ -12,8 +12,8 @@ use nsstring::nsString; use storage::Conn; use xpcom::{ interfaces::{ - mozIPlacesPendingOperation, mozIStorageConnection, - mozISyncedBookmarksMirrorCallback, mozISyncedBookmarksMirrorProgressListener, + mozIPlacesPendingOperation, mozIStorageConnection, mozISyncedBookmarksMirrorCallback, + mozISyncedBookmarksMirrorProgressListener, }, RefPtr, XpCom, }; diff --git a/toolkit/components/uniffi-bindgen-gecko-js/src/pipeline/callables.rs b/toolkit/components/uniffi-bindgen-gecko-js/src/pipeline/callables.rs @@ -138,7 +138,8 @@ fn handle_callable( ); } callable.is_js_async = true; - callable.uniffi_scaffolding_method = "UniFFIScaffolding.callAsyncWrapper".to_string(); + callable.uniffi_scaffolding_method = + "UniFFIScaffolding.callAsyncWrapper".to_string(); } ConcurrencyMode::FireAndForget => { if !matches!( diff --git a/toolkit/crashreporter/crash_helper_common/src/ipc_connector/unix.rs b/toolkit/crashreporter/crash_helper_common/src/ipc_connector/unix.rs @@ -3,13 +3,9 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #[cfg(any(target_os = "android", target_os = "linux"))] -use crate::platform::linux::{ - set_socket_cloexec, set_socket_default_flags, -}; +use crate::platform::linux::{set_socket_cloexec, set_socket_default_flags}; #[cfg(target_os = "macos")] -use crate::platform::macos::{ - set_socket_cloexec, set_socket_default_flags, -}; +use crate::platform::macos::{set_socket_cloexec, set_socket_default_flags}; use crate::{ignore_eintr, ProcessHandle, IO_TIMEOUT}; use nix::{ diff --git a/toolkit/crashreporter/crash_helper_common/src/ipc_connector/windows.rs b/toolkit/crashreporter/crash_helper_common/src/ipc_connector/windows.rs @@ -303,10 +303,13 @@ impl IPCConnector { buffer.extend(handle.unwrap_or(INVALID_ANCILLARY_DATA).to_ne_bytes()); buffer.extend(buff); - let overlapped = - OverlappedOperation::sched_send(self.handle + let overlapped = OverlappedOperation::sched_send( + self.handle .try_clone() - .map_err(IPCError::CloneHandleFailed)?, self.event_raw_handle(), buffer)?; + .map_err(IPCError::CloneHandleFailed)?, + self.event_raw_handle(), + buffer, + )?; overlapped.complete_send(/* wait */ true) } diff --git a/toolkit/crashreporter/crash_helper_common/src/platform/linux.rs b/toolkit/crashreporter/crash_helper_common/src/platform/linux.rs @@ -11,9 +11,7 @@ use nix::{ sys::socket::{socketpair, AddressFamily, SockFlag, SockType}, Result, }; -use std::{ - os::fd::{BorrowedFd, OwnedFd}, -}; +use std::os::fd::{BorrowedFd, OwnedFd}; pub type ProcessHandle = (); diff --git a/tools/fuzzing/rust/src/lib.rs b/tools/fuzzing/rust/src/lib.rs @@ -66,7 +66,9 @@ pub extern "C" fn fuzz_rkv_db_name(raw_data: *const u8, size: libc::size_t) -> l println!("Checking string: '{:?}'", name); // Some strings are invalid database names, and are handled as store errors. // Ignore those errors, but not others. - let store = env.open_single(name.as_ref(), rkv::StoreOptions::create()).unwrap(); + let store = env + .open_single(name.as_ref(), rkv::StoreOptions::create()) + .unwrap(); let reader = env.read().unwrap(); store.get(&reader, &[0]).unwrap();