Migrate to the 2024 edition (#35755)

* Migrate to 2024 edition

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Allow unsafe_op_in_unsafe_fn lint

This lint warns by default in the 2024
edition, but is *way* too noisy for servo.

We might enable it in the future, but not now.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Compile using the 2024 edition

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-03-13 11:28:11 +01:00 committed by GitHub
parent eb2ca42824
commit bb0d08432e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 317 additions and 293 deletions

View file

@ -347,8 +347,8 @@ impl FontContext {
}
pub fn is_supported_web_font_source(source: &&Source) -> bool {
let url_source = match source {
Source::Url(ref url_source) => url_source,
let url_source = match &source {
Source::Url(url_source) => url_source,
Source::Local(_) => return true,
};
let format_hint = match url_source.format_hint {

View file

@ -606,7 +606,7 @@ impl GlyphStore {
pub fn iter_glyphs_for_byte_range(
&self,
range: &Range<ByteIndex>,
) -> impl Iterator<Item = GlyphInfo> {
) -> impl Iterator<Item = GlyphInfo> + use<'_> {
if range.begin() >= self.len() {
panic!("iter_glyphs_for_range: range.begin beyond length!");
}

View file

@ -573,7 +573,7 @@ struct TtHeader {
glyph_data_format: FT_Short,
}
extern "C" {
unsafe extern "C" {
fn FT_Load_Sfnt_Table(
face: FT_Face,
tag: FT_ULong,

View file

@ -293,7 +293,6 @@ fn font_weight_from_fontconfig_pattern(pattern: *mut FcPattern) -> Option<FontWe
/// Creates a String from the given null-terminated buffer.
/// Panics if the buffer does not contain UTF-8.
unsafe fn c_str_to_string(s: *const c_char) -> String {
std::str::from_utf8(CStr::from_ptr(s).to_bytes())
.unwrap()
.to_owned()
let c_str = unsafe { CStr::from_ptr(s) };
std::str::from_utf8(c_str.to_bytes()).unwrap().to_owned()
}

View file

@ -59,10 +59,10 @@ impl ShapedGlyphData {
/// Passing an invalid buffer pointer to this function results in undefined behavior.
pub unsafe fn new(buffer: *mut hb_buffer_t) -> ShapedGlyphData {
let mut glyph_count = 0;
let glyph_infos = hb_buffer_get_glyph_infos(buffer, &mut glyph_count);
let glyph_infos = unsafe { hb_buffer_get_glyph_infos(buffer, &mut glyph_count) };
assert!(!glyph_infos.is_null());
let mut pos_count = 0;
let pos_infos = hb_buffer_get_glyph_positions(buffer, &mut pos_count);
let pos_infos = unsafe { hb_buffer_get_glyph_positions(buffer, &mut pos_count) };
assert!(!pos_infos.is_null());
assert_eq!(glyph_count, pos_count);