clippy: Fix warnings in shared and config, fonts, layout, and layout_2020 components (#32674)

This commit is contained in:
Martin Robinson 2024-07-04 16:18:58 +02:00 committed by GitHub
parent 99c1f886b8
commit 4b63043c6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 72 additions and 78 deletions

View file

@ -109,7 +109,7 @@ impl DisplayList {
/// Return the bounds of this display list based on the dimensions of the root
/// stacking context.
pub fn bounds(&self) -> LayoutRect {
match self.list.get(0) {
match self.list.first() {
Some(DisplayItem::PushStackingContext(item)) => item.stacking_context.bounds,
Some(_) => unreachable!("Root element of display list not stacking context."),
None => LayoutRect::zero(),

View file

@ -74,8 +74,11 @@ use crate::table_wrapper::TableWrapperFlow;
/// This marker trait indicates that a type is a struct with `#[repr(C)]` whose first field
/// is of type `BaseFlow` or some type that also implements this trait.
///
/// In other words, the memory representation of `BaseFlow` must be a prefix
/// of the memory representation of types implementing `HasBaseFlow`.
/// # Safety
///
/// The memory representation of `BaseFlow` must be a prefix of the memory representation of types
/// implementing `HasBaseFlow`. If this isn't the case, calling [`GetBaseFlow::base`] or
/// [`GetBaseFlow::mut_base`] could lead to memory errors.
#[allow(unsafe_code)]
pub unsafe trait HasBaseFlow {}

View file

@ -18,7 +18,7 @@ use serde_json::{to_string, to_value, Value};
use crate::flow::GetBaseFlow;
use crate::flow_ref::FlowRef;
thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None));
thread_local!(static STATE_KEY: RefCell<Option<State>> = const { RefCell::new(None) });
#[cfg(debug_assertions)]
static DEBUG_ID_COUNTER: AtomicUsize = AtomicUsize::new(0);

View file

@ -833,6 +833,7 @@ fn is_specific(script: Script) -> bool {
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[allow(clippy::enum_variant_names)]
pub enum CompressionMode {
CompressNone,
CompressWhitespace,

View file

@ -21,7 +21,7 @@ use xi_unicode::LineBreakLeafIter;
thread_local! {
static INDEX_OF_FIRST_GLYPH_RUN_CACHE: Cell<Option<(*const TextRun, ByteIndex, usize)>> =
Cell::new(None)
const { Cell::new(None) }
}
/// A single "paragraph" of text in one font size and style.

View file

@ -187,8 +187,12 @@ where
fn process(&mut self, node: &ConcreteThreadSafeLayoutNode);
}
#[allow(unsafe_code)]
/// # Safety
///
/// This function modifies the DOM node represented by the `node` argument, so it is imperitive
/// that no other thread is modifying the node at the same time.
#[inline]
#[allow(unsafe_code)]
pub unsafe fn construct_flows_at_ancestors<'dom>(
context: &LayoutContext,
mut node: impl LayoutNode<'dom>,