Skip to content

Commit

Permalink
Fix warnings introduced in newer Rust Nightly
Browse files Browse the repository at this point in the history
This does not (yet) upgrade ./rust-toolchain

The warnings:

* dead_code "field is never read"
* redundant_semicolons "unnecessary trailing semicolon"
* non_fmt_panic "panic message is not a string literal, this is no longer accepted in Rust 2021"
* unstable_name_collisions "a method with this name may be added to the standard library in the future"
* legacy_derive_helpers "derive helper attribute is used before it is introduced" rust-lang/rust#79202
  • Loading branch information
SimonSapin committed Feb 25, 2021
1 parent 4353d53 commit a0d9f97
Show file tree
Hide file tree
Showing 35 changed files with 75 additions and 116 deletions.
2 changes: 1 addition & 1 deletion components/compositing/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ fn main() {
_ => panic!("Cannot find package definitions in lockfile"),
}
},
Err(e) => panic!(e),
Err(e) => panic!("{}", e),
}
}
6 changes: 0 additions & 6 deletions components/compositing/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ pub struct IOCompositor<Window: WindowMethods + ?Sized> {
/// the compositor.
pub shutdown_state: ShutdownState,

/// Tracks the last composite time.
last_composite_time: u64,

/// Tracks whether the zoom action has happened recently.
zoom_action: bool,

Expand Down Expand Up @@ -320,7 +317,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
frame_tree_id: FrameTreeId(0),
constellation_chan: state.constellation_chan,
time_profiler_chan: state.time_profiler_chan,
last_composite_time: 0,
ready_to_save_state: ReadyState::Unknown,
webrender: state.webrender,
webrender_document: state.webrender_document,
Expand Down Expand Up @@ -1580,8 +1576,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
warn!("Failed to present surface: {:?}", err);
}

self.last_composite_time = precise_time_ns();

self.composition_request = CompositionRequest::NoCompositingNecessary;

self.process_animations();
Expand Down
7 changes: 1 addition & 6 deletions components/config/pref_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,7 @@ macro_rules! impl_from_pref {
if let $variant(value) = other {
value.into()
} else {
panic!(
format!("Cannot convert {:?} to {:?}",
other,
std::any::type_name::<$t>()
)
);
panic!("Cannot convert {:?} to {:?}", other, std::any::type_name::<$t>())
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions components/config_plugins/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,14 @@ impl Build {
.get_field_name_mapping()
.map(|pref_attr| pref_attr.value())
.unwrap_or_else(|| {
path_stack
.iter()
.chain(iter::once(&field.name))
.map(Ident::to_string)
.intersperse(String::from("."))
.collect()
Itertools::intersperse(
path_stack
.iter()
.chain(iter::once(&field.name))
.map(Ident::to_string),
String::from("."),
)
.collect()
})
}

Expand Down
6 changes: 1 addition & 5 deletions components/devtools/actors/framerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ use msg::constellation_msg::PipelineId;
use serde_json::{Map, Value};
use std::mem;
use std::net::TcpStream;
use time::precise_time_ns;

pub struct FramerateActor {
name: String,
pipeline: PipelineId,
script_sender: IpcSender<DevtoolScriptControlMsg>,
start_time: Option<u64>,

is_recording: bool,
ticks: Vec<HighResolutionStamp>,
}
Expand Down Expand Up @@ -51,7 +50,6 @@ impl FramerateActor {
name: actor_name.clone(),
pipeline: pipeline_id,
script_sender: script_sender,
start_time: None,
is_recording: false,
ticks: Vec::new(),
};
Expand Down Expand Up @@ -79,7 +77,6 @@ impl FramerateActor {
return;
}

self.start_time = Some(precise_time_ns());
self.is_recording = true;

let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline, self.name());
Expand All @@ -91,7 +88,6 @@ impl FramerateActor {
return;
}
self.is_recording = false;
self.start_time = None;
}
}

Expand Down
8 changes: 5 additions & 3 deletions components/layout/table_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl TableWrapperFlow {
.zip(guesses.iter())
{
intermediate_column_inline_size.size = guess.calculate(selection);
intermediate_column_inline_size.percentage = 0.0;
// intermediate_column_inline_size.percentage = 0.0;
total_used_inline_size = total_used_inline_size + intermediate_column_inline_size.size
}

Expand Down Expand Up @@ -382,7 +382,7 @@ impl Flow for TableWrapperFlow {
.map(
|column_intrinsic_inline_size| IntermediateColumnInlineSize {
size: column_intrinsic_inline_size.minimum_length,
percentage: column_intrinsic_inline_size.percentage,
// percentage: column_intrinsic_inline_size.percentage,
},
)
.collect::<Vec<_>>();
Expand Down Expand Up @@ -822,7 +822,9 @@ impl ExcessInlineSizeDistributionInfo {
/// An intermediate column size assignment.
struct IntermediateColumnInlineSize {
size: Au,
percentage: f32,
// This used to be stored here but nothing used it,
// which started emitting a compiler warning: https://github.com/servo/servo/pull/28202
// percentage: f32,
}

/// Returns the computed inline size of the table wrapper represented by `block`.
Expand Down
5 changes: 0 additions & 5 deletions components/layout_thread/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ pub struct LayoutThread {
/// The root of the flow tree.
root_flow: RefCell<Option<FlowRef>>,

/// The document-specific shared lock used for author-origin stylesheets
document_shared_lock: Option<SharedRwLock>,

/// A counter for epoch messages
epoch: Cell<Epoch>,

Expand Down Expand Up @@ -543,7 +540,6 @@ impl LayoutThread {
generation: Cell::new(0),
outstanding_web_fonts: Arc::new(AtomicUsize::new(0)),
root_flow: RefCell::new(None),
document_shared_lock: None,
// Epoch starts at 1 because of the initial display list for epoch 0 that we send to WR
epoch: Cell::new(Epoch(1)),
viewport_size: Size2D::new(Au(0), Au(0)),
Expand Down Expand Up @@ -1261,7 +1257,6 @@ impl LayoutThread {
// Calculate the actual viewport as per DEVICE-ADAPT § 6
// If the entire flow tree is invalid, then it will be reflowed anyhow.
let document_shared_lock = document.style_shared_lock();
self.document_shared_lock = Some(document_shared_lock.clone());
let author_guard = document_shared_lock.read();

let ua_stylesheets = &*UA_STYLESHEETS;
Expand Down
5 changes: 0 additions & 5 deletions components/layout_thread_2020/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ pub struct LayoutThread {
/// The fragment tree.
fragment_tree: RefCell<Option<Arc<FragmentTree>>>,

/// The document-specific shared lock used for author-origin stylesheets
document_shared_lock: Option<SharedRwLock>,

/// A counter for epoch messages
epoch: Cell<Epoch>,

Expand Down Expand Up @@ -510,7 +507,6 @@ impl LayoutThread {
outstanding_web_fonts: Arc::new(AtomicUsize::new(0)),
box_tree: Default::default(),
fragment_tree: Default::default(),
document_shared_lock: None,
// Epoch starts at 1 because of the initial display list for epoch 0 that we send to WR
epoch: Cell::new(Epoch(1)),
viewport_size: Size2D::new(Au(0), Au(0)),
Expand Down Expand Up @@ -947,7 +943,6 @@ impl LayoutThread {
// Calculate the actual viewport as per DEVICE-ADAPT § 6
// If the entire flow tree is invalid, then it will be reflowed anyhow.
let document_shared_lock = document.style_shared_lock();
self.document_shared_lock = Some(document_shared_lock.clone());
let author_guard = document_shared_lock.read();

let ua_stylesheets = &*UA_STYLESHEETS;
Expand Down
2 changes: 1 addition & 1 deletion components/net/tests/data_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn assert_parse(
filtered: FilteredMetadata::Basic(m),
..
}) => m,
result => panic!(result),
result => panic!("{:?}", result),
};
assert_eq!(metadata.content_type.map(Serde::into_inner), content_type);
assert_eq!(metadata.charset.as_ref().map(String::deref), charset);
Expand Down
2 changes: 1 addition & 1 deletion components/net_traits/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl Response {
metadata.referrer_policy = response.referrer_policy.clone();
metadata.redirected = response.actual_response().url_list.len() > 1;
metadata
};
}

if let Some(error) = self.get_network_error() {
return Err(error.clone());
Expand Down
7 changes: 2 additions & 5 deletions components/profile/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,15 @@ impl Profiler {
let name_clone = name.clone();
match self.reporters.insert(name, reporter) {
None => true,
Some(_) => panic!(format!(
"RegisterReporter: '{}' name is already in use",
name_clone
)),
Some(_) => panic!("RegisterReporter: '{}' name is already in use", name_clone),
}
},

ProfilerMsg::UnregisterReporter(name) => {
// Panic if it hasn't previously been registered.
match self.reporters.remove(&name) {
Some(_) => true,
None => panic!(format!("UnregisterReporter: '{}' name is unknown", &name)),
None => panic!("UnregisterReporter: '{}' name is unknown", &name),
}
},

Expand Down
2 changes: 1 addition & 1 deletion components/style/gecko/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use style_traits::{CssWriter, ParseError, ToCss};
use to_shmem::{self, SharedMemoryBuilder, ToShmem};

/// A CSS url() value for gecko.
#[css(function = "url")]
#[derive(Clone, Debug, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
#[css(function = "url")]
#[repr(C)]
pub struct CssUrl(pub Arc<CssUrlData>);

Expand Down
2 changes: 1 addition & 1 deletion components/style/media_queries/media_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use cssparser::{Delimiter, Parser};
use cssparser::{ParserInput, Token};

/// A type that encapsulates a media query list.
#[css(comma, derive_debug)]
#[derive(Clone, MallocSizeOf, ToCss, ToShmem)]
#[css(comma, derive_debug)]
pub struct MediaList {
/// The list of media queries.
#[css(iterable)]
Expand Down
14 changes: 7 additions & 7 deletions components/style/properties/helpers.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@
/// Making this type generic allows the compiler to figure out the
/// animated value for us, instead of having to implement it
/// manually for every type we care about.
% if separator == "Comma":
#[css(comma)]
% endif
#[derive(
Clone,
Debug,
Expand All @@ -182,6 +179,9 @@
ToResolvedValue,
ToCss,
)]
% if separator == "Comma":
#[css(comma)]
% endif
pub struct OwnedList<T>(
% if not allow_empty:
#[css(iterable)]
Expand All @@ -198,16 +198,16 @@
% else:
pub use self::ComputedList as List;

% if separator == "Comma":
#[css(comma)]
% endif
#[derive(
Clone,
Debug,
MallocSizeOf,
PartialEq,
ToCss,
)]
% if separator == "Comma":
#[css(comma)]
% endif
pub struct ComputedList(
% if not allow_empty:
#[css(iterable)]
Expand Down Expand Up @@ -324,10 +324,10 @@
}

/// The specified value of ${name}.
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
% if separator == "Comma":
#[css(comma)]
% endif
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
pub struct SpecifiedValue(
% if not allow_empty:
#[css(iterable)]
Expand Down
2 changes: 1 addition & 1 deletion components/style/stylesheets/document_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ impl DocumentMatchingFunction {
/// The `@document` rule's condition is written as a comma-separated list of
/// URL matching functions, and the condition evaluates to true whenever any
/// one of those functions evaluates to true.
#[css(comma)]
#[derive(Clone, Debug, ToCss, ToShmem)]
#[css(comma)]
pub struct DocumentCondition(#[css(iterable)] Vec<DocumentMatchingFunction>);

impl DocumentCondition {
Expand Down
2 changes: 1 addition & 1 deletion components/style/stylesheets/keyframes_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ impl KeyframePercentage {

/// A keyframes selector is a list of percentages or from/to symbols, which are
/// converted at parse time to percentages.
#[css(comma)]
#[derive(Clone, Debug, Eq, PartialEq, ToCss, ToShmem)]
#[css(comma)]
pub struct KeyframeSelector(#[css(iterable)] Vec<KeyframePercentage>);

impl KeyframeSelector {
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/animated/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<'a> FontSettingTagIter<'a> {
let mut sorted_tags = Vec::from_iter(tags.iter());
sorted_tags.sort_by_key(|k| k.tag.0);
sorted_tags
};
}

Ok(FontSettingTagIter {
a_state: FontSettingTagIterState::new(as_new_sorted_tags(&a_settings.0)),
Expand Down
Loading

0 comments on commit a0d9f97

Please sign in to comment.