# HG changeset patch
# User Emilio Cobos Ãlvarez <emilio@crisal.io>
# Date 1560893536 0
# Node ID 046dd0da3b8e606ae33895248cd41e4ef03a4fcc
# Parent 8567a308ac7a8e2087903aedd1d92032c9c7eb60
Bug 1556602 - Fix various warnings with rust 1.37 nightly. r=froydnj
In particular:
* trait objects without an explicit `dyn` are deprecated
* `...` range patterns are deprecated
I think these shouldn't really warn by default and should be clippy / opt-in
lints, but anyway, doesn't hurt.
Differential Revision: https://phabricator.services.mozilla.com/D35135
diff --git a/media/webrtc/signaling/src/sdp/rsdparsa_capi/src/lib.rs b/media/webrtc/signaling/src/sdp/rsdparsa_capi/src/lib.rs
--- a/media/webrtc/signaling/src/sdp/rsdparsa_capi/src/lib.rs
+++ b/media/webrtc/signaling/src/sdp/rsdparsa_capi/src/lib.rs
@@ -180,17 +180,17 @@ pub unsafe extern "C" fn sdp_add_media_s
}
};
// Check that the provided address type is valid. The rust parser will find out
// on his own which address type was provided
match addr_type {
// enum AddrType { kAddrTypeNone, kIPv4, kIPv6 };
// kAddrTypeNone is explicitly not covered as it is an 'invalid' flag
- 1...2 => (),
+ 1 | 2 => (),
_ => {
return NS_ERROR_INVALID_ARG;
}
}
match (*session).add_media(media_type, direction, port as u32, protocol, addr_str) {
Ok(_) => NS_OK,
Err(_) => NS_ERROR_INVALID_ARG
diff --git a/servo/components/malloc_size_of/lib.rs b/servo/components/malloc_size_of/lib.rs
--- a/servo/components/malloc_size_of/lib.rs
+++ b/servo/components/malloc_size_of/lib.rs
@@ -87,17 +87,17 @@ use std::ops::Range;
use std::ops::{Deref, DerefMut};
use std::os::raw::c_void;
use void::Void;
/// A C function that takes a pointer to a heap allocation and returns its size.
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 {
/// A function that returns the size of a heap allocation.
size_of_op: VoidPtrToSizeFn,
/// Like `size_of_op`, but can take an interior pointer. Optional because
/// not all allocators support this operation. If it's not provided, some
diff --git a/servo/components/selectors/context.rs b/servo/components/selectors/context.rs
--- a/servo/components/selectors/context.rs
+++ b/servo/components/selectors/context.rs
@@ -129,17 +129,17 @@ where
/// MatchingContext immutable again.
nesting_level: usize,
/// Whether we're inside a negation or not.
in_negation: bool,
/// 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,
quirks_mode: QuirksMode,
classes_and_ids_case_sensitivity: CaseSensitivity,
_impl: ::std::marker::PhantomData<Impl>,
}
diff --git a/servo/components/style/animation.rs b/servo/components/style/animation.rs
--- a/servo/components/style/animation.rs
+++ b/servo/components/style/animation.rs
@@ -483,17 +483,17 @@ pub fn start_transitions_if_applicable(
had_animations
}
fn compute_style_for_animation_step<E>(
context: &SharedStyleContext,
step: &KeyframesStep,
previous_style: &ComputedValues,
style_from_cascade: &Arc<ComputedValues>,
- font_metrics_provider: &FontMetricsProvider,
+ font_metrics_provider: &dyn FontMetricsProvider,
) -> Arc<ComputedValues>
where
E: TElement,
{
match step.value {
KeyframesStepValue::ComputedValues => style_from_cascade.clone(),
KeyframesStepValue::Declarations {
block: ref declarations,
@@ -668,17 +668,17 @@ pub enum AnimationUpdate {
/// transitions in response to a style change (that is,
/// consider_starting_transitions + maybe_start_animations, but handling
/// canceled animations, duration changes, etc, there instead of here), and this
/// function should be only about the style update in response of a transition.
pub fn update_style_for_animation<E>(
context: &SharedStyleContext,
animation: &Animation,
style: &mut Arc<ComputedValues>,
- font_metrics_provider: &FontMetricsProvider,
+ font_metrics_provider: &dyn FontMetricsProvider,
) -> AnimationUpdate
where
E: TElement,
{
debug!("update_style_for_animation: {:?}", animation);
debug_assert!(!animation.is_expired());
match *animation {
diff --git a/servo/components/style/parser.rs b/servo/components/style/parser.rs
--- a/servo/components/style/parser.rs
+++ b/servo/components/style/parser.rs
@@ -46,33 +46,33 @@ pub struct ParserContext<'a> {
pub url_data: &'a UrlExtraData,
/// The current rule type, if any.
pub rule_type: Option<CssRuleType>,
/// The mode to use when parsing.
pub parsing_mode: ParsingMode,
/// 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.
pub use_counters: Option<&'a UseCounters>,
}
impl<'a> ParserContext<'a> {
/// Create a parser context.
#[inline]
pub fn new(
stylesheet_origin: Origin,
url_data: &'a UrlExtraData,
rule_type: Option<CssRuleType>,
parsing_mode: ParsingMode,
quirks_mode: QuirksMode,
- error_reporter: Option<&'a ParseErrorReporter>,
+ error_reporter: Option<&'a dyn ParseErrorReporter>,
use_counters: Option<&'a UseCounters>,
) -> Self {
Self {
stylesheet_origin,
url_data,
rule_type,
parsing_mode,
quirks_mode,
@@ -84,17 +84,17 @@ impl<'a> ParserContext<'a> {
/// Create a parser context for on-the-fly parsing in CSSOM
#[inline]
pub fn new_for_cssom(
url_data: &'a UrlExtraData,
rule_type: Option<CssRuleType>,
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(
Origin::Author,
url_data,
rule_type,
parsing_mode,
quirks_mode,
diff --git a/servo/components/style/properties/cascade.rs b/servo/components/style/properties/cascade.rs
--- a/servo/components/style/properties/cascade.rs
+++ b/servo/components/style/properties/cascade.rs
@@ -77,17 +77,17 @@ pub fn cascade<E>(
device: &Device,
pseudo: Option<&PseudoElement>,
rule_node: &StrongRuleNode,
guards: &StylesheetGuards,
parent_style: Option<&ComputedValues>,
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,
element: Option<E>,
) -> Arc<ComputedValues>
where
E: TElement,
{
@@ -111,17 +111,17 @@ where
fn cascade_rules<E>(
device: &Device,
pseudo: Option<&PseudoElement>,
rule_node: &StrongRuleNode,
guards: &StylesheetGuards,
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>,
rule_cache_conditions: &mut RuleCacheConditions,
element: Option<E>,
) -> Arc<ComputedValues>
where
E: TElement,
@@ -208,17 +208,17 @@ pub fn apply_declarations<'a, E, F, I>(
device: &Device,
pseudo: Option<&PseudoElement>,
rules: &StrongRuleNode,
guards: &StylesheetGuards,
iter_declarations: F,
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>,
rule_cache_conditions: &mut RuleCacheConditions,
element: Option<E>,
) -> Arc<ComputedValues>
where
E: TElement,
diff --git a/servo/components/style/properties/declaration_block.rs b/servo/components/style/properties/declaration_block.rs
--- a/servo/components/style/properties/declaration_block.rs
+++ b/servo/components/style/properties/declaration_block.rs
@@ -1194,17 +1194,17 @@ where
/// A helper to parse the style attribute of an element, in order for this to be
/// shared between Servo and Gecko.
///
/// Inline because we call this cross-crate.
#[inline]
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(
Origin::Author,
url_data,
Some(CssRuleType::Style),
ParsingMode::DEFAULT,
quirks_mode,
@@ -1221,17 +1221,17 @@ pub fn parse_style_attribute(
///
/// This does not attempt to parse !important at all.
#[inline]
pub fn parse_one_declaration_into(
declarations: &mut SourcePropertyDeclaration,
id: PropertyId,
input: &str,
url_data: &UrlExtraData,
- error_reporter: Option<&ParseErrorReporter>,
+ error_reporter: Option<&dyn ParseErrorReporter>,
parsing_mode: ParsingMode,
quirks_mode: QuirksMode
) -> Result<(), ()> {
let context = ParserContext::new(
Origin::Author,
url_data,
Some(CssRuleType::Style),
parsing_mode,
diff --git a/servo/components/style/str.rs b/servo/components/style/str.rs
--- a/servo/components/style/str.rs
+++ b/servo/components/style/str.rs
@@ -55,17 +55,17 @@ pub fn split_html_space_chars<'a>(
#[inline]
pub fn split_commas<'a>(s: &'a str) -> Filter<Split<'a, char>, fn(&&str) -> bool> {
s.split(',').filter(not_empty as fn(&&str) -> bool)
}
/// Character is ascii digit
pub fn is_ascii_digit(c: &char) -> bool {
match *c {
- '0'...'9' => true,
+ '0'..='9' => true,
_ => false,
}
}
fn is_decimal_point(c: char) -> bool {
c == '.'
}
@@ -156,17 +156,17 @@ where
/// Returns true if a given string has a given prefix with case-insensitive match.
pub fn starts_with_ignore_ascii_case(string: &str, prefix: &str) -> bool {
string.len() >= prefix.len() &&
string.as_bytes()[0..prefix.len()].eq_ignore_ascii_case(prefix.as_bytes())
}
/// 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.
Cow::Borrowed(input)
}
}
/// To avoid accidentally instantiating multiple monomorphizations of large
diff --git a/servo/components/style/stylesheets/mod.rs b/servo/components/style/stylesheets/mod.rs
--- a/servo/components/style/stylesheets/mod.rs
+++ b/servo/components/style/stylesheets/mod.rs
@@ -347,17 +347,17 @@ impl CssRule {
///
/// Input state is None for a nested rule
pub fn parse(
css: &str,
insert_rule_context: InsertRuleContext,
parent_stylesheet_contents: &StylesheetContents,
shared_lock: &SharedRwLock,
state: State,
- loader: Option<&StylesheetLoader>,
+ loader: Option<&dyn StylesheetLoader>,
) -> Result<Self, RulesMutateError> {
let url_data = parent_stylesheet_contents.url_data.read();
let context = ParserContext::new(
parent_stylesheet_contents.origin,
&url_data,
None,
ParsingMode::DEFAULT,
parent_stylesheet_contents.quirks_mode,
diff --git a/servo/components/style/stylesheets/rule_list.rs b/servo/components/style/stylesheets/rule_list.rs
--- a/servo/components/style/stylesheets/rule_list.rs
+++ b/servo/components/style/stylesheets/rule_list.rs
@@ -122,29 +122,29 @@ pub trait CssRulesHelpers {
/// instead, but that seems overkill.
fn insert_rule(
&self,
lock: &SharedRwLock,
rule: &str,
parent_stylesheet_contents: &StylesheetContents,
index: usize,
nested: bool,
- loader: Option<&StylesheetLoader>,
+ loader: Option<&dyn StylesheetLoader>,
) -> Result<CssRule, RulesMutateError>;
}
impl CssRulesHelpers for RawOffsetArc<Locked<CssRules>> {
fn insert_rule(
&self,
lock: &SharedRwLock,
rule: &str,
parent_stylesheet_contents: &StylesheetContents,
index: usize,
nested: bool,
- loader: Option<&StylesheetLoader>,
+ loader: Option<&dyn StylesheetLoader>,
) -> Result<CssRule, RulesMutateError> {
let new_rule = {
let read_guard = lock.read();
let rules = self.read_with(&read_guard);
// Step 1, 2
if index > rules.0.len() {
return Err(RulesMutateError::IndexSize);
diff --git a/servo/components/style/stylesheets/rule_parser.rs b/servo/components/style/stylesheets/rule_parser.rs
--- a/servo/components/style/stylesheets/rule_parser.rs
+++ b/servo/components/style/stylesheets/rule_parser.rs
@@ -39,17 +39,17 @@ pub struct InsertRuleContext<'a> {
pub index: usize,
}
/// The parser for the top-level rules in a stylesheet.
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
/// `ParserContext::new_with_rule_type` will.
pub context: ParserContext<'a>,
/// The current state of the parser.
pub state: State,
/// Whether we have tried to parse was invalid due to being in the wrong
diff --git a/servo/components/style/stylesheets/stylesheet.rs b/servo/components/style/stylesheets/stylesheet.rs
--- a/servo/components/style/stylesheets/stylesheet.rs
+++ b/servo/components/style/stylesheets/stylesheet.rs
@@ -71,18 +71,18 @@ pub struct StylesheetContents {
impl StylesheetContents {
/// Parse a given CSS string, with a given url-data, origin, and
/// quirks mode.
pub fn from_str(
css: &str,
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>,
) -> Self {
let namespaces = RwLock::new(Namespaces::default());
let (rules, source_map_url, source_url) = Stylesheet::parse_rules(
css,
&url_data,
@@ -338,18 +338,18 @@ impl StylesheetInDocument for DocumentSt
}
impl Stylesheet {
/// Updates an empty stylesheet from a given string of text.
pub fn update_from_str(
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());
// FIXME: Consider adding use counters to Servo?
let (rules, source_map_url, source_url) = Self::parse_rules(
css,
&url_data,
@@ -377,18 +377,18 @@ impl Stylesheet {
}
fn parse_rules(
css: &str,
url_data: &UrlExtraData,
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>,
) -> (Vec<CssRule>, Option<String>, Option<String>) {
let mut rules = Vec::new();
let mut input = ParserInput::new_with_line_number_offset(css, line_number_offset);
let mut input = Parser::new(&mut input);
@@ -445,18 +445,18 @@ impl Stylesheet {
/// Effectively creates a new stylesheet and forwards the hard work to
/// `Stylesheet::update_from_str`.
pub fn from_str(
css: &str,
url_data: UrlExtraData,
origin: Origin,
media: Arc<Locked<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,
line_number_offset: u32,
) -> Self {
// FIXME: Consider adding use counters to Servo?
let contents = StylesheetContents::from_str(
css,
url_data,
origin,
diff --git a/servo/components/style/stylist.rs b/servo/components/style/stylist.rs
--- a/servo/components/style/stylist.rs
+++ b/servo/components/style/stylist.rs
@@ -646,17 +646,17 @@ impl Stylist {
/// Computes the style for a given "precomputed" pseudo-element, taking the
/// universal rules and applying them.
pub fn precomputed_values_for_pseudo<E>(
&self,
guards: &StylesheetGuards,
pseudo: &PseudoElement,
parent: Option<&ComputedValues>,
- font_metrics: &FontMetricsProvider,
+ font_metrics: &dyn FontMetricsProvider,
) -> Arc<ComputedValues>
where
E: TElement,
{
debug_assert!(pseudo.is_precomputed());
let rule_node = self.rule_node_for_precomputed_pseudo(guards, pseudo, None);
@@ -674,17 +674,17 @@ impl Stylist {
///
/// TODO(emilio): The type parameter could go away with a void type
/// implementing TElement.
pub fn precomputed_values_for_pseudo_with_rule_node<E>(
&self,
guards: &StylesheetGuards,
pseudo: &PseudoElement,
parent: Option<&ComputedValues>,
- font_metrics: &FontMetricsProvider,
+ font_metrics: &dyn FontMetricsProvider,
rules: StrongRuleNode,
) -> Arc<ComputedValues>
where
E: TElement,
{
self.compute_pseudo_element_style_with_inputs::<E>(
CascadeInputs {
rules: Some(rules),
@@ -769,18 +769,18 @@ impl Stylist {
pub fn lazily_compute_pseudo_element_style<E>(
&self,
guards: &StylesheetGuards,
element: E,
pseudo: &PseudoElement,
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<Arc<ComputedValues>>
where
E: TElement,
{
let cascade_inputs = self.lazy_pseudo_rules(
guards,
element,
parent_style,
@@ -805,17 +805,17 @@ impl Stylist {
/// selector matching for eager pseudo-elements when we need to recompute
/// their style with a new parent style.
pub fn compute_pseudo_element_style_with_inputs<E>(
&self,
inputs: CascadeInputs,
pseudo: &PseudoElement,
guards: &StylesheetGuards,
parent_style: Option<&ComputedValues>,
- font_metrics: &FontMetricsProvider,
+ font_metrics: &dyn FontMetricsProvider,
element: Option<E>,
) -> Arc<ComputedValues>
where
E: TElement,
{
// FIXME(emilio): The lack of layout_parent_style here could be
// worrying, but we're probably dropping the display fixup for
// pseudos other than before and after, so it's probably ok.
@@ -858,17 +858,17 @@ impl Stylist {
&self,
element: Option<E>,
pseudo: Option<&PseudoElement>,
inputs: CascadeInputs,
guards: &StylesheetGuards,
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<ComputedValues>
where
E: TElement,
{
debug_assert!(pseudo.is_some() || element.is_some(), "Huh?");
@@ -915,17 +915,17 @@ impl Stylist {
fn lazy_pseudo_rules<E>(
&self,
guards: &StylesheetGuards,
element: E,
parent_style: &ComputedValues,
pseudo: &PseudoElement,
is_probe: bool,
rule_inclusion: RuleInclusion,
- matching_fn: Option<&Fn(&PseudoElement) -> bool>,
+ matching_fn: Option<&dyn Fn(&PseudoElement) -> bool>,
) -> Option<CascadeInputs>
where
E: TElement,
{
debug_assert!(pseudo.is_lazy());
// Apply the selector flags. We should be in sequential mode
// already, so we can directly apply the parent flags.
diff --git a/servo/components/style/values/computed/mod.rs b/servo/components/style/values/computed/mod.rs
--- a/servo/components/style/values/computed/mod.rs
+++ b/servo/components/style/values/computed/mod.rs
@@ -142,17 +142,17 @@ pub struct Context<'a> {
/// painful.
///
/// TODO(emilio): Make constructors for Context, and drop this.
#[cfg(feature = "servo")]
pub cached_system_font: Option<()>,
/// 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,
/// The quirks mode of this context.
pub quirks_mode: QuirksMode,
/// Whether this computation is being done for a SMIL animation.
diff --git a/servo/components/style_traits/specified_value_info.rs b/servo/components/style_traits/specified_value_info.rs
--- a/servo/components/style_traits/specified_value_info.rs
+++ b/servo/components/style_traits/specified_value_info.rs
@@ -22,17 +22,17 @@ pub mod CssType {
pub const COLOR: u8 = 1 << 0;
/// <gradient>
pub const GRADIENT: u8 = 1 << 1;
/// <timing-function>
pub const TIMING_FUNCTION: u8 = 1 << 2;
}
/// 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.
///
/// This trait is derivable with `#[derive(SpecifiedValueInfo)]`.
///
/// The algorithm traverses the type definition. For `SUPPORTED_TYPES`,
/// it puts an or'ed value of `SUPPORTED_TYPES` of all types it finds.
/// For `collect_completion_keywords`, it recursively invokes this
diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -1378,28 +1378,28 @@ pub extern "C" fn Servo_StyleSheet_FromU
loader,
stylesheet,
load_data,
reusable_sheets,
))
};
// FIXME(emilio): loader.as_ref() doesn't typecheck for some reason?
- let loader: Option<&StyleStylesheetLoader> = match loader {
+ let loader: Option<&dyn StyleStylesheetLoader> = match loader {
None => None,
Some(ref s) => Some(s),
};
Arc::new(StylesheetContents::from_str(
input,
url_data.clone(),
mode_to_origin(mode),
&global_style_data.shared_lock,
loader,
- reporter.as_ref().map(|r| r as &ParseErrorReporter),
+ reporter.as_ref().map(|r| r as &dyn ParseErrorReporter),
quirks_mode.into(),
line_number_offset,
use_counters,
))
.into_strong()
}
#[no_mangle]
@@ -1903,17 +1903,17 @@ pub extern "C" fn Servo_CssRules_InsertR
loader,
gecko_stylesheet,
ptr::null_mut(),
ptr::null_mut(),
))
};
let loader = loader
.as_ref()
- .map(|loader| loader as &StyleStylesheetLoader);
+ .map(|loader| loader as &dyn StyleStylesheetLoader);
let rule = unsafe { rule.as_ref().unwrap().as_str_unchecked() };
let global_style_data = &*GLOBAL_STYLE_DATA;
let contents = StylesheetContents::as_arc(&contents);
let result = Locked::<CssRules>::as_arc(&rules).insert_rule(
&global_style_data.shared_lock,
rule,
contents,
@@ -3583,17 +3583,17 @@ fn get_pseudo_style(
guard: &SharedRwLockReadGuard,
element: GeckoElement,
pseudo: &PseudoElement,
rule_inclusion: RuleInclusion,
styles: &ElementStyles,
inherited_styles: Option<&ComputedValues>,
doc_data: &PerDocumentStyleDataImpl,
is_probe: bool,
- matching_func: Option<&Fn(&PseudoElement) -> bool>,
+ matching_func: Option<&dyn Fn(&PseudoElement) -> bool>,
) -> Option<Arc<ComputedValues>> {
let style = match pseudo.cascade_type() {
PseudoElementCascadeType::Eager => {
match *pseudo {
PseudoElement::FirstLetter => {
styles.pseudos.get(&pseudo).map(|pseudo_styles| {
// inherited_styles can be None when doing lazy resolution
// (e.g. for computed style) or when probing. In that case
@@ -3772,17 +3772,17 @@ pub unsafe extern "C" fn Servo_StyleSet_
fn parse_property_into(
declarations: &mut SourcePropertyDeclaration,
property_id: PropertyId,
value: *const nsACString,
data: *mut URLExtraData,
parsing_mode: structs::ParsingMode,
quirks_mode: QuirksMode,
- reporter: Option<&ParseErrorReporter>,
+ reporter: Option<&dyn ParseErrorReporter>,
) -> Result<(), ()> {
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
let url_data = unsafe { UrlExtraData::from_ptr_ref(&data) };
let parsing_mode = ParsingMode::from_bits_truncate(parsing_mode);
parse_one_declaration_into(
declarations,
property_id,
@@ -3809,17 +3809,17 @@ pub extern "C" fn Servo_ParseProperty(
let reporter = ErrorReporter::new(ptr::null_mut(), loader, data);
let result = parse_property_into(
&mut declarations,
id,
value,
data,
parsing_mode,
quirks_mode.into(),
- reporter.as_ref().map(|r| r as &ParseErrorReporter),
+ reporter.as_ref().map(|r| r as &dyn ParseErrorReporter),
);
match result {
Ok(()) => {
let global_style_data = &*GLOBAL_STYLE_DATA;
let mut block = PropertyDeclarationBlock::new();
block.extend(declarations.drain(), Importance::Normal);
Arc::new(global_style_data.shared_lock.wrap(block)).into_strong()
@@ -3961,17 +3961,17 @@ pub unsafe extern "C" fn Servo_ParseStyl
) -> Strong<RawServoDeclarationBlock> {
let global_style_data = &*GLOBAL_STYLE_DATA;
let value = (*data).as_str_unchecked();
let reporter = ErrorReporter::new(ptr::null_mut(), loader, raw_extra_data);
let url_data = UrlExtraData::from_ptr_ref(&raw_extra_data);
Arc::new(global_style_data.shared_lock.wrap(parse_style_attribute(
value,
url_data,
- reporter.as_ref().map(|r| r as &ParseErrorReporter),
+ reporter.as_ref().map(|r| r as &dyn ParseErrorReporter),
quirks_mode.into(),
)))
.into_strong()
}
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> Strong<RawServoDeclarationBlock> {
let global_style_data = &*GLOBAL_STYLE_DATA;
@@ -4190,17 +4190,17 @@ fn set_property(
let reporter = ErrorReporter::new(ptr::null_mut(), loader, data);
let result = parse_property_into(
&mut source_declarations,
property_id,
value,
data,
parsing_mode,
quirks_mode,
- reporter.as_ref().map(|r| r as &ParseErrorReporter),
+ reporter.as_ref().map(|r| r as &dyn ParseErrorReporter),
);
if result.is_err() {
return false;
}
let importance = if is_important {
Importance::Important
@@ -5224,17 +5224,17 @@ fn simulate_compute_values_failure(prope
#[cfg(not(feature = "gecko_debug"))]
fn simulate_compute_values_failure(_: &PropertyValuePair) -> bool {
false
}
fn create_context_for_animation<'a>(
per_doc_data: &'a PerDocumentStyleDataImpl,
- font_metrics_provider: &'a FontMetricsProvider,
+ font_metrics_provider: &'a dyn FontMetricsProvider,
style: &'a ComputedValues,
parent_style: Option<&'a ComputedValues>,
for_smil_animation: bool,
rule_cache_conditions: &'a mut RuleCacheConditions,
) -> Context<'a> {
Context {
is_root_element: false,
builder: StyleBuilder::for_animation(per_doc_data.stylist.device(), style, parent_style),
@@ -6158,17 +6158,17 @@ pub unsafe extern "C" fn Servo_SelectorL
#[no_mangle]
pub unsafe extern "C" fn Servo_SelectorList_Drop(list: *mut RawServoSelectorList) {
SelectorList::drop_ffi(list)
}
fn parse_color(
value: &str,
- error_reporter: Option<&ParseErrorReporter>,
+ error_reporter: Option<&dyn ParseErrorReporter>,
) -> Result<specified::Color, ()> {
let mut input = ParserInput::new(value);
let mut parser = Parser::new(&mut input);
let url_data = unsafe { dummy_url_data() };
let context = ParserContext::new(
Origin::Author,
url_data,
Some(CssRuleType::Style),
@@ -6222,17 +6222,17 @@ pub extern "C" fn Servo_ComputeColor(
let value = unsafe { (*value).to_string() };
let result_color = unsafe { result_color.as_mut().unwrap() };
let reporter = unsafe { loader.as_mut() }.and_then(|loader| {
// Make an ErrorReporter that will report errors as being "from DOM".
ErrorReporter::new(ptr::null_mut(), loader, ptr::null_mut())
});
- match parse_color(&value, reporter.as_ref().map(|r| r as &ParseErrorReporter)) {
+ match parse_color(&value, reporter.as_ref().map(|r| r as &dyn ParseErrorReporter)) {
Ok(specified_color) => {
let computed_color = match raw_data {
Some(raw_data) => {
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
let device = data.stylist.device();
let quirks_mode = data.stylist.quirks_mode();
Context::for_media_query_evaluation(device, quirks_mode, |context| {
specified_color.to_computed_color(Some(&context))
diff --git a/testing/geckodriver/src/marionette.rs b/testing/geckodriver/src/marionette.rs
--- a/testing/geckodriver/src/marionette.rs
+++ b/testing/geckodriver/src/marionette.rs
@@ -1273,17 +1273,17 @@ impl MarionetteConnection {
ErrorKind::Other,
"EOF reading marionette message",
))
}
1 => buf[0] as char,
_ => panic!("Expected one byte got more"),
};
match byte {
- '0'...'9' => {
+ '0'..='9' => {
bytes = bytes * 10;
bytes += byte as usize - '0' as usize;
}
':' => break,
_ => {}
}
}
diff --git a/testing/mozbase/rust/mozprofile/src/prefreader.rs b/testing/mozbase/rust/mozprofile/src/prefreader.rs
--- a/testing/mozbase/rust/mozprofile/src/prefreader.rs
+++ b/testing/mozbase/rust/mozprofile/src/prefreader.rs
@@ -9,17 +9,17 @@ use std::iter::Iterator;
use std::mem;
use std::ops::Deref;
use std::str;
impl PrefReaderError {
fn new(
message: &'static str,
position: Position,
- parent: Option<Box<Error>>,
+ parent: Option<Box<dyn Error>>,
) -> PrefReaderError {
PrefReaderError {
message,
position,
parent,
}
}
}
@@ -34,17 +34,17 @@ impl fmt::Display for PrefReaderError {
}
}
impl Error for PrefReaderError {
fn description(&self) -> &str {
self.message
}
- fn cause(&self) -> Option<&Error> {
+ fn cause(&self) -> Option<&dyn Error> {
match self.parent {
None => None,
Some(ref cause) => Some(cause.deref()),
}
}
}
impl From<io::Error> for PrefReaderError {
@@ -138,17 +138,17 @@ impl<'a> PrefToken<'a> {
}
}
}
#[derive(Debug)]
pub struct PrefReaderError {
message: &'static str,
position: Position,
- parent: Option<Box<Error>>,
+ parent: Option<Box<dyn Error>>,
}
struct TokenData<'a> {
token_type: TokenType,
complete: bool,
position: Position,
data: Cow<'a, str>,
start_pos: usize,
@@ -353,19 +353,19 @@ impl<'a> PrefTokenizer<'a> {
fn read_hex_escape(&mut self, hex_chars: isize, first: bool) -> Result<u32, PrefReaderError> {
let mut value = 0;
for _ in 0..hex_chars {
match self.get_char() {
Some(x) => {
value = value << 4;
match x {
- '0'...'9' => value += x as u32 - '0' as u32,
- 'a'...'f' => value += x as u32 - 'a' as u32,
- 'A'...'F' => value += x as u32 - 'A' as u32,
+ '0'..='9' => value += x as u32 - '0' as u32,
+ 'a'..='f' => value += x as u32 - 'a' as u32,
+ 'A'..='F' => value += x as u32 - 'A' as u32,
_ => {
return Err(PrefReaderError::new(
"Unexpected character in escape",
self.position,
None,
))
}
}
@@ -589,17 +589,17 @@ impl<'a> PrefTokenizer<'a> {
token_data.start(&self, TokenType::String);
token_data.start_pos = self.pos + 1;
TokenizerState::SingleQuotedString
}
't' | 'f' => {
self.unget_char();
TokenizerState::Bool
}
- '0'...'9' | '-' | '+' => {
+ '0'..='9' | '-' | '+' => {
token_data.start(&self, TokenType::Int);
TokenizerState::Number
}
_ => {
return Err(PrefReaderError::new(
"Invalid character at start of function argument",
self.position,
None,
@@ -640,17 +640,17 @@ impl<'a> PrefTokenizer<'a> {
}
'\\' => {
self.consume_escape(&mut token_data)?;
TokenizerState::SingleQuotedString
}
_ => TokenizerState::SingleQuotedString,
},
TokenizerState::Number => match c {
- '0'...'9' => TokenizerState::Number,
+ '0'..='9' => TokenizerState::Number,
')' | ',' => {
token_data.end(&self.data, self.pos)?;
self.unget_char();
self.next_state = Some(TokenizerState::AfterFunctionArg);
TokenizerState::Junk
}
x if PrefTokenizer::is_space(x) => {
token_data.end(&self.data, self.pos)?;
diff --git a/testing/mozbase/rust/mozrunner/src/bin/icecat-default-path.rs b/testing/mozbase/rust/mozrunner/src/bin/icecat-default-path.rs
--- a/testing/mozbase/rust/mozrunner/src/bin/icecat-default-path.rs
+++ b/testing/mozbase/rust/mozrunner/src/bin/icecat-default-path.rs
@@ -8,7 +8,7 @@
.map(|x| (x.to_string_lossy().into_owned(), 0))
.unwrap_or(("IceCat binary not found".to_owned(), 1));
- let mut writer: Box<Write> = match code {
+ let mut writer: Box<dyn Write> = match code {
0 => Box::new(std::io::stdout()),
_ => Box::new(std::io::stderr())
};
diff --git a/testing/mozbase/rust/mozrunner/src/runner.rs b/testing/mozbase/rust/mozrunner/src/runner.rs
--- a/testing/mozbase/rust/mozrunner/src/runner.rs
+++ b/testing/mozbase/rust/mozrunner/src/runner.rs
@@ -101,20 +101,20 @@ impl Error for RunnerError {
ErrorKind::NotFound => "no such file or directory",
_ => err.description(),
}
}
RunnerError::PrefReader(ref err) => err.description(),
}
}
- fn cause(&self) -> Option<&Error> {
+ fn cause(&self) -> Option<&dyn Error> {
Some(match *self {
- RunnerError::Io(ref err) => err as &Error,
- RunnerError::PrefReader(ref err) => err as &Error,
+ RunnerError::Io(ref err) => err as &dyn Error,
+ RunnerError::PrefReader(ref err) => err as &dyn Error,
})
}
}
impl From<io::Error> for RunnerError {
fn from(value: io::Error) -> RunnerError {
RunnerError::Io(value)
}
diff --git a/testing/webdriver/src/error.rs b/testing/webdriver/src/error.rs
--- a/testing/webdriver/src/error.rs
+++ b/testing/webdriver/src/error.rs
@@ -320,17 +320,17 @@ impl WebDriverError {
}
}
impl Error for WebDriverError {
fn description(&self) -> &str {
self.error_code()
}
- fn cause(&self) -> Option<&Error> {
+ fn cause(&self) -> Option<&dyn Error> {
None
}
}
impl fmt::Display for WebDriverError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.message.fmt(f)
}
@@ -349,18 +349,18 @@ impl From<io::Error> for WebDriverError
}
impl From<DecodeError> for WebDriverError {
fn from(err: DecodeError) -> WebDriverError {
WebDriverError::new(ErrorStatus::UnknownError, err.description().to_string())
}
}
-impl From<Box<Error>> for WebDriverError {
- fn from(err: Box<Error>) -> WebDriverError {
+impl From<Box<dyn Error>> for WebDriverError {
+ fn from(err: Box<dyn Error>) -> WebDriverError {
WebDriverError::new(ErrorStatus::UnknownError, err.description().to_string())
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::test::check_serialize;
diff --git a/testing/webdriver/src/server.rs b/testing/webdriver/src/server.rs
--- a/testing/webdriver/src/server.rs
+++ b/testing/webdriver/src/server.rs
@@ -171,17 +171,17 @@ impl<U: WebDriverExtensionRoute> HttpHan
}
}
impl<U: WebDriverExtensionRoute + 'static> Service for HttpHandler<U> {
type ReqBody = Body;
type ResBody = Body;
type Error = hyper::Error;
- type Future = Box<future::Future<Item = Response<Self::ResBody>, Error = hyper::Error> + Send>;
+ type Future = Box<dyn future::Future<Item = Response<Self::ResBody>, Error = hyper::Error> + Send>;
fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future {
let uri = req.uri().clone();
let method = req.method().clone();
let api = self.api.clone();
let chan = self.chan.clone();
Box::new(req.into_body().concat2().and_then(move |body| {
diff --git a/xpcom/rust/xpcom/xpcom_macros/src/lib.rs b/xpcom/rust/xpcom/xpcom_macros/src/lib.rs
--- a/xpcom/rust/xpcom/xpcom_macros/src/lib.rs
+++ b/xpcom/rust/xpcom/xpcom_macros/src/lib.rs
@@ -192,7 +192,7 @@
}
impl Interface {
- fn base(&self) -> Result<Option<&'static Interface>, Box<Error>> {
+ fn base(&self) -> Result<Option<&'static Interface>, Box<dyn Error>> {
Ok(if let Some(base) = self.base {
Some(*IFACES.get(base).ok_or_else(
|| format!("Base interface {} does not exist", base)
@@ -238,7 +238,7 @@
}
/// Scans through the attributes on a struct, and extracts the type of the refcount to use.
-fn get_refcnt_kind(attrs: &[Attribute]) -> Result<RefcntKind, Box<Error>> {
+fn get_refcnt_kind(attrs: &[Attribute]) -> Result<RefcntKind, Box<dyn Error>> {
for attr in attrs {
if let Some(Meta::NameValue(ref attr)) = attr.interpret_meta() {
if attr.ident.as_ref() != "refcnt" {
@@ -268,7 +268,7 @@
/// Scan the attributes looking for an #[xpimplements] attribute. The identifier
/// arguments passed to this attribute are the interfaces which the type wants to
/// directly implement.
-fn get_bases(attrs: &[Attribute]) -> Result<Vec<&'static Interface>, Box<Error>> {
+fn get_bases(attrs: &[Attribute]) -> Result<Vec<&'static Interface>, Box<dyn Error>> {
let mut inherits = Vec::new();
for attr in attrs {
if let Some(Meta::List(ref attr)) = attr.interpret_meta() {
@@ -294,7 +294,7 @@
}
/// Extract the fields list from the input struct.
-fn get_fields(di: &DeriveInput) -> Result<&Punctuated<Field, Token![,]>, Box<Error>> {
+fn get_fields(di: &DeriveInput) -> Result<&Punctuated<Field, Token![,]>, Box<dyn Error>> {
match di.data {
Data::Struct(DataStruct {
fields: Fields::Named(ref named), ..
@@ -305,7 +305,7 @@
}
/// Takes the `Init*` struct in, and generates a `DeriveInput` for the "real" struct.
-fn gen_real_struct(init: &DeriveInput, bases: &[&Interface], refcnt_ty: RefcntKind) -> Result<DeriveInput, Box<Error>> {
+fn gen_real_struct(init: &DeriveInput, bases: &[&Interface], refcnt_ty: RefcntKind) -> Result<DeriveInput, Box<dyn Error>> {
// Determine the name for the real struct based on the name of the
// initializer struct's name.
if !init.ident.as_ref().starts_with("Init") {