Skip to content

Commit

Permalink
Bug 1556602 - Fix various warnings with rust 1.37 nightly. r=froydnj
Browse files Browse the repository at this point in the history
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
  • Loading branch information
emilio committed Jun 18, 2019
1 parent fa5178d commit be6bdae
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 74 deletions.
2 changes: 1 addition & 1 deletion media/webrtc/signaling/src/sdp/rsdparsa_capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub unsafe extern "C" fn sdp_add_media_section(session: *mut SdpSession,
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;
}
Expand Down
2 changes: 1 addition & 1 deletion servo/components/malloc_size_of/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ use void::Void;
type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize;

/// A closure implementing a stateful predicate on pointers.
type VoidPtrToBoolFnMut = FnMut(*const c_void) -> bool;
type VoidPtrToBoolFnMut = dyn FnMut(*const c_void) -> bool;

/// Operations used when measuring heap usage of data structures.
pub struct MallocSizeOfOps {
Expand Down
2 changes: 1 addition & 1 deletion servo/components/selectors/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ where

/// An optional hook function for checking whether a pseudo-element
/// should match when matching_mode is ForStatelessPseudoElement.
pub pseudo_element_matching_fn: Option<&'a Fn(&Impl::PseudoElement) -> bool>,
pub pseudo_element_matching_fn: Option<&'a dyn Fn(&Impl::PseudoElement) -> bool>,

/// Extra implementation-dependent matching data.
pub extra_data: Impl::ExtraMatchingData,
Expand Down
4 changes: 2 additions & 2 deletions servo/components/style/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ fn compute_style_for_animation_step<E>(
step: &KeyframesStep,
previous_style: &ComputedValues,
style_from_cascade: &Arc<ComputedValues>,
font_metrics_provider: &FontMetricsProvider,
font_metrics_provider: &dyn FontMetricsProvider,
) -> Arc<ComputedValues>
where
E: TElement,
Expand Down Expand Up @@ -673,7 +673,7 @@ 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,
Expand Down
6 changes: 3 additions & 3 deletions servo/components/style/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct ParserContext<'a> {
/// The quirks mode of this stylesheet.
pub quirks_mode: QuirksMode,
/// The active error reporter, or none if error reporting is disabled.
error_reporter: Option<&'a ParseErrorReporter>,
error_reporter: Option<&'a dyn ParseErrorReporter>,
/// The currently active namespaces.
pub namespaces: Option<&'a Namespaces>,
/// The use counters we want to record while parsing style rules, if any.
Expand All @@ -67,7 +67,7 @@ impl<'a> ParserContext<'a> {
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 {
Expand All @@ -89,7 +89,7 @@ impl<'a> ParserContext<'a> {
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(
Expand Down
6 changes: 3 additions & 3 deletions servo/components/style/properties/cascade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn cascade<E>(
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,
Expand Down Expand Up @@ -116,7 +116,7 @@ fn cascade_rules<E>(
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>,
Expand Down Expand Up @@ -213,7 +213,7 @@ pub fn apply_declarations<'a, E, F, I>(
parent_style: Option<&ComputedValues>,
parent_style_ignoring_first_line: Option<&ComputedValues>,
layout_parent_style: Option<&ComputedValues>,
font_metrics_provider: &FontMetricsProvider,
font_metrics_provider: &dyn FontMetricsProvider,
cascade_mode: CascadeMode,
quirks_mode: QuirksMode,
rule_cache: Option<&RuleCache>,
Expand Down
4 changes: 2 additions & 2 deletions servo/components/style/properties/declaration_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ where
pub fn parse_style_attribute(
input: &str,
url_data: &UrlExtraData,
error_reporter: Option<&ParseErrorReporter>,
error_reporter: Option<&dyn ParseErrorReporter>,
quirks_mode: QuirksMode,
) -> PropertyDeclarationBlock {
let context = ParserContext::new(
Expand All @@ -1226,7 +1226,7 @@ pub fn parse_one_declaration_into(
id: PropertyId,
input: &str,
url_data: &UrlExtraData,
error_reporter: Option<&ParseErrorReporter>,
error_reporter: Option<&dyn ParseErrorReporter>,
parsing_mode: ParsingMode,
quirks_mode: QuirksMode
) -> Result<(), ()> {
Expand Down
4 changes: 2 additions & 2 deletions servo/components/style/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn split_commas<'a>(s: &'a str) -> Filter<Split<'a, char>, fn(&&str) -> bool
/// Character is ascii digit
pub fn is_ascii_digit(c: &char) -> bool {
match *c {
'0'...'9' => true,
'0'..='9' => true,
_ => false,
}
}
Expand Down Expand Up @@ -161,7 +161,7 @@ pub fn starts_with_ignore_ascii_case(string: &str, prefix: &str) -> bool {

/// Returns an ascii lowercase version of a string, only allocating if needed.
pub fn string_as_ascii_lowercase<'a>(input: &'a str) -> Cow<'a, str> {
if input.bytes().any(|c| matches!(c, b'A'...b'Z')) {
if input.bytes().any(|c| matches!(c, b'A'..=b'Z')) {
input.to_ascii_lowercase().into()
} else {
// Already ascii lowercase.
Expand Down
2 changes: 1 addition & 1 deletion servo/components/style/stylesheets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ impl CssRule {
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(
Expand Down
4 changes: 2 additions & 2 deletions servo/components/style/stylesheets/rule_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub trait CssRulesHelpers {
parent_stylesheet_contents: &StylesheetContents,
index: usize,
nested: bool,
loader: Option<&StylesheetLoader>,
loader: Option<&dyn StylesheetLoader>,
) -> Result<CssRule, RulesMutateError>;
}

Expand All @@ -139,7 +139,7 @@ impl CssRulesHelpers for RawOffsetArc<Locked<CssRules>> {
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();
Expand Down
2 changes: 1 addition & 1 deletion servo/components/style/stylesheets/rule_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct TopLevelRuleParser<'a> {
/// A reference to the lock we need to use to create rules.
pub shared_lock: &'a SharedRwLock,
/// A reference to a stylesheet loader if applicable, for `@import` rules.
pub loader: Option<&'a StylesheetLoader>,
pub loader: Option<&'a dyn StylesheetLoader>,
/// The top-level parser context.
///
/// This won't contain any namespaces, and only nested parsers created with
Expand Down
16 changes: 8 additions & 8 deletions servo/components/style/stylesheets/stylesheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl StylesheetContents {
url_data: UrlExtraData,
origin: Origin,
shared_lock: &SharedRwLock,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: Option<&ParseErrorReporter>,
stylesheet_loader: Option<&dyn StylesheetLoader>,
error_reporter: Option<&dyn ParseErrorReporter>,
quirks_mode: QuirksMode,
line_number_offset: u32,
use_counters: Option<&UseCounters>,
Expand Down Expand Up @@ -343,8 +343,8 @@ impl Stylesheet {
existing: &Stylesheet,
css: &str,
url_data: UrlExtraData,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: Option<&ParseErrorReporter>,
stylesheet_loader: Option<&dyn StylesheetLoader>,
error_reporter: Option<&dyn ParseErrorReporter>,
line_number_offset: u32,
) {
let namespaces = RwLock::new(Namespaces::default());
Expand Down Expand Up @@ -382,8 +382,8 @@ impl Stylesheet {
origin: Origin,
namespaces: &mut Namespaces,
shared_lock: &SharedRwLock,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: Option<&ParseErrorReporter>,
stylesheet_loader: Option<&dyn StylesheetLoader>,
error_reporter: Option<&dyn ParseErrorReporter>,
quirks_mode: QuirksMode,
line_number_offset: u32,
use_counters: Option<&UseCounters>,
Expand Down Expand Up @@ -450,8 +450,8 @@ impl Stylesheet {
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 {
Expand Down
14 changes: 7 additions & 7 deletions servo/components/style/stylist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ impl Stylist {
guards: &StylesheetGuards,
pseudo: &PseudoElement,
parent: Option<&ComputedValues>,
font_metrics: &FontMetricsProvider,
font_metrics: &dyn FontMetricsProvider,
) -> Arc<ComputedValues>
where
E: TElement,
Expand Down Expand Up @@ -679,7 +679,7 @@ impl Stylist {
guards: &StylesheetGuards,
pseudo: &PseudoElement,
parent: Option<&ComputedValues>,
font_metrics: &FontMetricsProvider,
font_metrics: &dyn FontMetricsProvider,
rules: StrongRuleNode,
) -> Arc<ComputedValues>
where
Expand Down Expand Up @@ -774,8 +774,8 @@ impl Stylist {
rule_inclusion: RuleInclusion,
parent_style: &ComputedValues,
is_probe: bool,
font_metrics: &FontMetricsProvider,
matching_fn: Option<&Fn(&PseudoElement) -> bool>,
font_metrics: &dyn FontMetricsProvider,
matching_fn: Option<&dyn Fn(&PseudoElement) -> bool>,
) -> Option<Arc<ComputedValues>>
where
E: TElement,
Expand Down Expand Up @@ -810,7 +810,7 @@ impl Stylist {
pseudo: &PseudoElement,
guards: &StylesheetGuards,
parent_style: Option<&ComputedValues>,
font_metrics: &FontMetricsProvider,
font_metrics: &dyn FontMetricsProvider,
element: Option<E>,
) -> Arc<ComputedValues>
where
Expand Down Expand Up @@ -863,7 +863,7 @@ impl Stylist {
parent_style: Option<&ComputedValues>,
parent_style_ignoring_first_line: Option<&ComputedValues>,
layout_parent_style: Option<&ComputedValues>,
font_metrics: &FontMetricsProvider,
font_metrics: &dyn FontMetricsProvider,
rule_cache: Option<&RuleCache>,
rule_cache_conditions: &mut RuleCacheConditions,
) -> Arc<ComputedValues>
Expand Down Expand Up @@ -920,7 +920,7 @@ impl Stylist {
pseudo: &PseudoElement,
is_probe: bool,
rule_inclusion: RuleInclusion,
matching_fn: Option<&Fn(&PseudoElement) -> bool>,
matching_fn: Option<&dyn Fn(&PseudoElement) -> bool>,
) -> Option<CascadeInputs>
where
E: TElement,
Expand Down
2 changes: 1 addition & 1 deletion servo/components/style/values/computed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub struct Context<'a> {

/// A font metrics provider, used to access font metrics to implement
/// font-relative units.
pub font_metrics_provider: &'a FontMetricsProvider,
pub font_metrics_provider: &'a dyn FontMetricsProvider,

/// Whether or not we are computing the media list in a media query
pub in_media_query: bool,
Expand Down
2 changes: 1 addition & 1 deletion servo/components/style_traits/specified_value_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub mod CssType {
}

/// See SpecifiedValueInfo::collect_completion_keywords.
pub type KeywordsCollectFn<'a> = &'a mut FnMut(&[&'static str]);
pub type KeywordsCollectFn<'a> = &'a mut dyn FnMut(&[&'static str]);

/// Information of values of a given specified value type.
///
Expand Down
22 changes: 11 additions & 11 deletions servo/ports/geckolib/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(
};

// 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),
};
Expand All @@ -1394,7 +1394,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(
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,
Expand Down Expand Up @@ -1908,7 +1908,7 @@ pub extern "C" fn Servo_CssRules_InsertRule(
};
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;
Expand Down Expand Up @@ -3588,7 +3588,7 @@ fn get_pseudo_style(
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 => {
Expand Down Expand Up @@ -3777,7 +3777,7 @@ fn parse_property_into(
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) };
Expand Down Expand Up @@ -3814,7 +3814,7 @@ pub extern "C" fn Servo_ParseProperty(
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 {
Expand Down Expand Up @@ -3966,7 +3966,7 @@ pub unsafe extern "C" fn Servo_ParseStyleAttribute(
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()
Expand Down Expand Up @@ -4195,7 +4195,7 @@ fn set_property(
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() {
Expand Down Expand Up @@ -5229,7 +5229,7 @@ fn simulate_compute_values_failure(_: &PropertyValuePair) -> bool {

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,
Expand Down Expand Up @@ -6163,7 +6163,7 @@ pub unsafe extern "C" fn Servo_SelectorList_Drop(list: *mut RawServoSelectorList

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);
Expand Down Expand Up @@ -6227,7 +6227,7 @@ pub extern "C" fn Servo_ComputeColor(
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) => {
Expand Down
2 changes: 1 addition & 1 deletion testing/geckodriver/src/marionette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ impl MarionetteConnection {
_ => panic!("Expected one byte got more"),
};
match byte {
'0'...'9' => {
'0'..='9' => {
bytes = bytes * 10;
bytes += byte as usize - '0' as usize;
}
Expand Down
Loading

0 comments on commit be6bdae

Please sign in to comment.