chore: Prepare for Rust edition bump to 2024 (without autofix) (#27791)

Successor to #27779 - in this PR I've applied changes manually, without
futzing with if let lifetimes at all.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-03-31 20:10:36 +02:00 committed by GitHub
parent d51aa2ffb0
commit 0729d24d77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
162 changed files with 2333 additions and 1937 deletions

View file

@ -333,7 +333,7 @@ impl DirectWriteState {
&self,
font_features: &FontFeatures,
) -> Result<IDWriteTypography> {
let direct_write_features = self.components.factory.CreateTypography()?;
let direct_write_features = unsafe { self.components.factory.CreateTypography()? };
apply_font_features(&direct_write_features, font_features)?;
Ok(direct_write_features)
}
@ -352,28 +352,32 @@ impl DirectWriteState {
} else {
&self.custom_font_collection
};
let fontset = collection.GetFontSet().log_err()?;
let font = fontset
.GetMatchingFonts(
&HSTRING::from(family_name),
font_weight.into(),
DWRITE_FONT_STRETCH_NORMAL,
font_style.into(),
)
.log_err()?;
let total_number = font.GetFontCount();
let fontset = unsafe { collection.GetFontSet().log_err()? };
let font = unsafe {
fontset
.GetMatchingFonts(
&HSTRING::from(family_name),
font_weight.into(),
DWRITE_FONT_STRETCH_NORMAL,
font_style.into(),
)
.log_err()?
};
let total_number = unsafe { font.GetFontCount() };
for index in 0..total_number {
let Some(font_face_ref) = font.GetFontFaceReference(index).log_err() else {
let Some(font_face_ref) = (unsafe { font.GetFontFaceReference(index).log_err() })
else {
continue;
};
let Some(font_face) = font_face_ref.CreateFontFace().log_err() else {
let Some(font_face) = (unsafe { font_face_ref.CreateFontFace().log_err() }) else {
continue;
};
let Some(identifier) = get_font_identifier(&font_face, &self.components.locale) else {
continue;
};
let is_emoji = font_face.IsColorFont().as_bool();
let Some(direct_write_features) = self.generate_font_features(font_features).log_err()
let is_emoji = unsafe { font_face.IsColorFont().as_bool() };
let Some(direct_write_features) =
(unsafe { self.generate_font_features(font_features).log_err() })
else {
continue;
};
@ -396,14 +400,14 @@ impl DirectWriteState {
}
unsafe fn update_system_font_collection(&mut self) {
let mut collection = std::mem::zeroed();
if self
.components
.factory
.GetSystemFontCollection(false, &mut collection, true)
.log_err()
.is_some()
{
let mut collection = unsafe { std::mem::zeroed() };
if unsafe {
self.components
.factory
.GetSystemFontCollection(false, &mut collection, true)
.log_err()
.is_some()
} {
self.system_font_collection = collection.unwrap();
}
}
@ -461,35 +465,37 @@ impl DirectWriteState {
fallbacks: Option<&FontFallbacks>,
) -> Option<FontId> {
// try to find target font in custom font collection first
self.get_font_id_from_font_collection(
family_name,
weight,
style,
features,
fallbacks,
false,
)
.or_else(|| {
unsafe {
self.get_font_id_from_font_collection(
family_name,
weight,
style,
features,
fallbacks,
true,
false,
)
})
.or_else(|| {
self.update_system_font_collection();
self.get_font_id_from_font_collection(
family_name,
weight,
style,
features,
fallbacks,
true,
)
})
.or_else(|| {
self.get_font_id_from_font_collection(
family_name,
weight,
style,
features,
fallbacks,
true,
)
})
.or_else(|| {
self.update_system_font_collection();
self.get_font_id_from_font_collection(
family_name,
weight,
style,
features,
fallbacks,
true,
)
})
}
}
fn layout_line(