mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix some Clippy lints.
This commit is contained in:
parent
c23adde5a3
commit
3e5cd8815d
14 changed files with 37 additions and 43 deletions
|
@ -8,10 +8,9 @@ use std::cell::RefCell;
|
|||
use std::collections::HashMap;
|
||||
use std::string::String;
|
||||
|
||||
const EXCLUDE_READS: &'static str = "exclude-reads";
|
||||
const EXCLUDE_WRITES: &'static str = "exclude-writes";
|
||||
const VALID_UUID_REGEX: &'static str =
|
||||
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
||||
const EXCLUDE_READS: &str = "exclude-reads";
|
||||
const EXCLUDE_WRITES: &str = "exclude-writes";
|
||||
const VALID_UUID_REGEX: &str = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
||||
|
||||
thread_local!(pub static BLUETOOTH_BLOCKLIST: RefCell<BluetoothBlocklist> =
|
||||
RefCell::new(BluetoothBlocklist(parse_blocklist())));
|
||||
|
@ -108,5 +107,5 @@ fn parse_blocklist() -> Option<HashMap<String, Blocklist>> {
|
|||
result.insert(uuid.to_string(), exclude_type);
|
||||
}
|
||||
// Step 5
|
||||
return Some(result);
|
||||
Some(result)
|
||||
}
|
||||
|
|
|
@ -44,16 +44,16 @@ impl BluetoothScanfilter {
|
|||
service_data: Option<ServiceData>,
|
||||
) -> BluetoothScanfilter {
|
||||
BluetoothScanfilter {
|
||||
name: name,
|
||||
name_prefix: name_prefix,
|
||||
name,
|
||||
name_prefix,
|
||||
services: ServiceUUIDSequence::new(services),
|
||||
manufacturer_data: manufacturer_data,
|
||||
service_data: service_data,
|
||||
service_data,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_name(&self) -> Option<&str> {
|
||||
self.name.as_ref().map(|s| s.as_str())
|
||||
self.name.as_deref()
|
||||
}
|
||||
|
||||
pub fn get_name_prefix(&self) -> &str {
|
||||
|
|
|
@ -432,7 +432,7 @@ fn print_debug_usage(app: &str) -> ! {
|
|||
"Emit native OS signposts for profile events (currently macOS only)",
|
||||
);
|
||||
|
||||
println!("");
|
||||
println!();
|
||||
|
||||
process::exit(0)
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ impl Build {
|
|||
self.path_stack.push(field.name.clone());
|
||||
|
||||
if let FieldType::NewTypeDef(new_def) = &field.field_type {
|
||||
self.walk(&new_def)?;
|
||||
self.walk(new_def)?;
|
||||
} else {
|
||||
let pref_name =
|
||||
self.pref_name(field, &self.path_stack[..self.path_stack.len() - 1]);
|
||||
|
@ -154,7 +154,7 @@ impl Build {
|
|||
}
|
||||
},
|
||||
FieldType::Existing(type_name) => {
|
||||
let pref_name = self.pref_name(field, &path_stack);
|
||||
let pref_name = self.pref_name(field, path_stack);
|
||||
let attributes = field.get_attributes(&pref_name);
|
||||
quote! {
|
||||
#attributes
|
||||
|
|
|
@ -334,7 +334,7 @@ pub enum NetworkEvent {
|
|||
impl TimelineMarker {
|
||||
pub fn start(name: String) -> StartedTimelineMarker {
|
||||
StartedTimelineMarker {
|
||||
name: name,
|
||||
name,
|
||||
start_time: PreciseTime::now(),
|
||||
start_stack: None,
|
||||
}
|
||||
|
|
|
@ -36,12 +36,11 @@ mod platform {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn alloc(size: usize, align: usize) -> *mut u8 {
|
||||
let ptr = if align <= MIN_ALIGN {
|
||||
if align <= MIN_ALIGN {
|
||||
libc::malloc(size) as *mut u8
|
||||
} else {
|
||||
aligned_malloc(size, align)
|
||||
};
|
||||
ptr
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -49,6 +49,7 @@ impl<T: 'static> Shared<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::mut_from_ref)]
|
||||
pub unsafe fn as_mut(&self) -> &mut T {
|
||||
&mut *self.ptr.as_ptr()
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ impl SafeHash {
|
|||
// effectively reducing the hashes by one bit.
|
||||
//
|
||||
// Truncate hash to fit in `HashUint`.
|
||||
let hash_bits = size_of::<HashUint>() * 8;
|
||||
let hash_bits = HashUint::BITS;
|
||||
SafeHash {
|
||||
hash: (1 << (hash_bits - 1)) | (hash as HashUint),
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ impl<K, V> RawBucket<K, V> {
|
|||
self.hash_start.offset(self.idx as isize)
|
||||
}
|
||||
unsafe fn pair(&self) -> *mut (K, V) {
|
||||
self.pair_start.offset(self.idx as isize) as *mut (K, V)
|
||||
self.pair_start.add(self.idx) as *mut (K, V)
|
||||
}
|
||||
unsafe fn hash_pair(&self) -> (*mut HashUint, *mut (K, V)) {
|
||||
(self.hash(), self.pair())
|
||||
|
@ -824,7 +824,7 @@ impl<K, V> RawTable<K, V> {
|
|||
unsafe {
|
||||
RawBucket {
|
||||
hash_start: buffer as *mut HashUint,
|
||||
pair_start: buffer.offset(pairs_offset as isize) as *const (K, V),
|
||||
pair_start: buffer.add(pairs_offset) as *const (K, V),
|
||||
idx: index,
|
||||
_marker: marker::PhantomData,
|
||||
}
|
||||
|
|
|
@ -637,7 +637,7 @@ impl fmt::Debug for HangProfile {
|
|||
|
||||
write!(fmt, "HangProfile backtrace:")?;
|
||||
|
||||
if self.backtrace.len() == 0 {
|
||||
if self.backtrace.is_empty() {
|
||||
write!(fmt, "backtrace failed to resolve")?;
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ impl RelativePos {
|
|||
pub fn from_opts(start: Option<i64>, end: Option<i64>) -> RelativePos {
|
||||
RelativePos {
|
||||
start: start.unwrap_or(0),
|
||||
end: end,
|
||||
end,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ impl Response {
|
|||
|
||||
/// Convert to a filtered response, of type `filter_type`.
|
||||
/// Do not use with type Error or Default
|
||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#[rustfmt::skip]
|
||||
pub fn to_filtered(self, filter_type: ResponseType) -> Response {
|
||||
match filter_type {
|
||||
ResponseType::Default |
|
||||
|
|
|
@ -286,21 +286,21 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
|||
}
|
||||
}
|
||||
|
||||
if !in_new_function {
|
||||
if is_unrooted_ty(&self.symbols, cx, sig.output().skip_binder(), false) {
|
||||
cx.lint(UNROOTED_MUST_ROOT, |lint| {
|
||||
lint.build("Type must be rooted")
|
||||
.set_span(decl.output.span())
|
||||
.emit()
|
||||
})
|
||||
}
|
||||
if !in_new_function &&
|
||||
is_unrooted_ty(&self.symbols, cx, sig.output().skip_binder(), false)
|
||||
{
|
||||
cx.lint(UNROOTED_MUST_ROOT, |lint| {
|
||||
lint.build("Type must be rooted")
|
||||
.set_span(decl.output.span())
|
||||
.emit()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let mut visitor = FnDefVisitor {
|
||||
symbols: &self.symbols,
|
||||
cx: cx,
|
||||
in_new_function: in_new_function,
|
||||
cx,
|
||||
in_new_function,
|
||||
};
|
||||
visit::walk_expr(&mut visitor, &body.value);
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
|
|||
|
||||
match expr.kind {
|
||||
// Trait casts from #[unrooted_must_root_lint::must_root] types are not allowed
|
||||
ExprKind::Cast(ref subexpr, _) => require_rooted(cx, self.in_new_function, &*subexpr),
|
||||
ExprKind::Cast(subexpr, _) => require_rooted(cx, self.in_new_function, &subexpr),
|
||||
// This catches assignments... the main point of this would be to catch mutable
|
||||
// references to `JS<T>`.
|
||||
// FIXME: Enable this? Triggers on certain kinds of uses of DomRefCell.
|
||||
|
@ -362,7 +362,7 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> {
|
|||
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, ..) |
|
||||
hir::PatKind::Binding(hir::BindingAnnotation::Mutable, ..) => {
|
||||
let ty = cx.typeck_results().pat_ty(pat);
|
||||
if is_unrooted_ty(&self.symbols, cx, ty, self.in_new_function) {
|
||||
if is_unrooted_ty(self.symbols, cx, ty, self.in_new_function) {
|
||||
cx.lint(UNROOTED_MUST_ROOT, |lint| {
|
||||
lint.build(&format!("Expression of type {:?} must be rooted", ty))
|
||||
.set_span(pat.span)
|
||||
|
|
|
@ -831,6 +831,7 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(clippy::uninit_vec)]
|
||||
unsafe fn allocate_buffer<W>(size: usize) -> *mut u8 {
|
||||
// We use Vec because the underlying allocation machinery isn't
|
||||
// available in stable Rust. To avoid alignment issues, we allocate
|
||||
|
@ -1101,9 +1102,7 @@ impl<T> Clone for RawOffsetArc<T> {
|
|||
|
||||
impl<T> Drop for RawOffsetArc<T> {
|
||||
fn drop(&mut self) {
|
||||
let _ = Arc::from_raw_offset(RawOffsetArc {
|
||||
ptr: self.ptr.clone(),
|
||||
});
|
||||
let _ = Arc::from_raw_offset(RawOffsetArc { ptr: self.ptr });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1117,10 +1116,6 @@ impl<T: PartialEq> PartialEq for RawOffsetArc<T> {
|
|||
fn eq(&self, other: &RawOffsetArc<T>) -> bool {
|
||||
*(*self) == *(*other)
|
||||
}
|
||||
|
||||
fn ne(&self, other: &RawOffsetArc<T>) -> bool {
|
||||
*(*self) != *(*other)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> RawOffsetArc<T> {
|
||||
|
@ -1252,7 +1247,7 @@ impl<'a, T> ArcBorrow<'a, T> {
|
|||
/// Compare two `ArcBorrow`s via pointer equality. Will only return
|
||||
/// true if they come from the same allocation
|
||||
pub fn ptr_eq(this: &Self, other: &Self) -> bool {
|
||||
this.0 as *const T == other.0 as *const T
|
||||
std::ptr::eq(this.0, other.0)
|
||||
}
|
||||
|
||||
/// Temporarily converts |self| into a bonafide Arc and exposes it to the
|
||||
|
|
|
@ -123,7 +123,7 @@ fn derive_variant_fields_expr(
|
|||
let mut iter = bindings
|
||||
.iter()
|
||||
.filter_map(|binding| {
|
||||
let attrs = cg::parse_field_attrs::<CssFieldAttrs>(&binding.ast());
|
||||
let attrs = cg::parse_field_attrs::<CssFieldAttrs>(binding.ast());
|
||||
if attrs.skip {
|
||||
return None;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue