diff --git a/examples/shape.rs b/examples/shape.rs index e7a66a78..c4e82266 100644 --- a/examples/shape.rs +++ b/examples/shape.rs @@ -180,7 +180,7 @@ fn main() { for text in lines { let mut buffer = rustybuzz::UnicodeBuffer::new(); - buffer.push_str(&text); + buffer.push_str(text); if let Some(d) = args.direction { buffer.set_direction(d); @@ -250,7 +250,7 @@ fn parse_unicodes(s: &str) -> Result { fn parse_features(s: &str) -> Result, String> { let mut features = Vec::new(); for f in s.split(',') { - features.push(rustybuzz::Feature::from_str(&f)?); + features.push(rustybuzz::Feature::from_str(f)?); } Ok(features) @@ -259,7 +259,7 @@ fn parse_features(s: &str) -> Result, String> { fn parse_variations(s: &str) -> Result, String> { let mut variations = Vec::new(); for v in s.split(',') { - variations.push(rustybuzz::Variation::from_str(&v)?); + variations.push(rustybuzz::Variation::from_str(v)?); } Ok(variations) @@ -270,7 +270,7 @@ fn parse_cluster(s: &str) -> Result { "0" => Ok(rustybuzz::BufferClusterLevel::MonotoneGraphemes), "1" => Ok(rustybuzz::BufferClusterLevel::MonotoneCharacters), "2" => Ok(rustybuzz::BufferClusterLevel::Characters), - _ => Err(format!("invalid cluster level")), + _ => Err("invalid cluster level".to_string()), } } diff --git a/scripts/gen-vowel-constraints.py b/scripts/gen-vowel-constraints.py index 4ed4afd7..86122484 100755 --- a/scripts/gen-vowel-constraints.py +++ b/scripts/gen-vowel-constraints.py @@ -141,6 +141,8 @@ def __str__(self, index=0, depth=4): print('// WARNING: this file was generated by scripts/gen-vowel-constraints.py') print() +print('#![allow(clippy::single_match)]') +print() print('use super::buffer::hb_buffer_t;') print('use super::ot_layout::*;') print('use super::script;') diff --git a/src/hb/aat_layout_kerx_table.rs b/src/hb/aat_layout_kerx_table.rs index 0f52d128..276954ec 100644 --- a/src/hb/aat_layout_kerx_table.rs +++ b/src/hb/aat_layout_kerx_table.rs @@ -248,7 +248,7 @@ fn apply_state_machine_kerning( // go differently if we start from state 0 here. if state != START_OF_TEXT && buffer.backtrack_len() != 0 && buffer.idx < buffer.len { // If there's no value and we're just epsilon-transitioning to state 0, safe to break. - if entry.is_actionable() || !(entry.new_state == START_OF_TEXT && !entry.has_advance()) + if entry.is_actionable() || entry.new_state != START_OF_TEXT || entry.has_advance() { buffer.unsafe_to_break_from_outbuffer( Some(buffer.backtrack_len() - 1), diff --git a/src/hb/aat_layout_morx_table.rs b/src/hb/aat_layout_morx_table.rs index 6c4be101..6cddd098 100644 --- a/src/hb/aat_layout_morx_table.rs +++ b/src/hb/aat_layout_morx_table.rs @@ -29,7 +29,7 @@ pub fn compile_flags( }; let chains = face.tables().morx.as_ref()?.chains; - let chain_len = chains.clone().into_iter().count(); + let chain_len = chains.into_iter().count(); map.chain_flags.resize(chain_len, vec![]); for (chain, chain_flags) in chains.into_iter().zip(map.chain_flags.iter_mut()) { @@ -72,7 +72,7 @@ pub fn apply<'a>(c: &mut hb_aat_apply_context_t<'a>, map: &'a mut hb_aat_map_t) c.buffer.unsafe_to_concat(None, None); let chains = c.face.tables().morx.as_ref()?.chains; - let chain_len = chains.clone().into_iter().count(); + let chain_len = chains.into_iter().count(); map.chain_flags.resize(chain_len, vec![]); for (chain, chain_flags) in chains.into_iter().zip(map.chain_flags.iter_mut()) { @@ -256,18 +256,18 @@ fn drive( }; // 2c' - if c.is_actionable(&wouldbe_entry, &ac.buffer) { + if c.is_actionable(&wouldbe_entry, ac.buffer) { return false; } // 2c" - return next_state == wouldbe_entry.new_state - && c.can_advance(&entry) == c.can_advance(&wouldbe_entry); + next_state == wouldbe_entry.new_state + && c.can_advance(&entry) == c.can_advance(&wouldbe_entry) }; let is_safe_to_break = || { // 1 - if c.is_actionable(&entry, &ac.buffer) { + if c.is_actionable(&entry, ac.buffer) { return false; } @@ -285,7 +285,7 @@ fn drive( Some(v) => v, None => return false, }; - return !c.is_actionable(&end_entry, &ac.buffer); + !c.is_actionable(&end_entry, ac.buffer) }; if !is_safe_to_break() && ac.buffer.backtrack_len() > 0 && ac.buffer.idx < ac.buffer.len { diff --git a/src/hb/aat_layout_trak_table.rs b/src/hb/aat_layout_trak_table.rs index 271af31a..f1af6291 100644 --- a/src/hb/aat_layout_trak_table.rs +++ b/src/hb/aat_layout_trak_table.rs @@ -85,9 +85,7 @@ impl TrackTableDataExt for ttf_parser::trak::TrackData<'_> { .position(|s| s.0 >= ptem) .unwrap_or(self.sizes.len() as usize - 1); - if idx > 0 { - idx -= 1; - } + idx = idx.saturating_sub(1); self.interpolate_at(idx as u16, ptem, &track) .map(|n| n.round() as i32) diff --git a/src/hb/aat_map.rs b/src/hb/aat_map.rs index 494006b4..de16f005 100644 --- a/src/hb/aat_map.rs +++ b/src/hb/aat_map.rs @@ -102,7 +102,7 @@ impl hb_aat_map_builder_t { let exposes_feature = feat .names .find(HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES as u16) - .map(|f| f.setting_names.len() != 0) + .map(|f| !f.setting_names.is_empty()) .unwrap_or(false); if !exposes_feature { @@ -128,7 +128,7 @@ impl hb_aat_map_builder_t { let mut feature_name = feat.names.find(mapping.aat_feature_type as u16); match feature_name { - Some(feature) if feature.setting_names.len() != 0 => {} + Some(feature) if !feature.setting_names.is_empty() => {} _ => { // Special case: Chain::compile_flags will fall back to the deprecated version of // small-caps if necessary, so we need to check for that possibility. @@ -145,7 +145,7 @@ impl hb_aat_map_builder_t { } match feature_name { - Some(feature_name) if feature_name.setting_names.len() != 0 => { + Some(feature_name) if !feature_name.setting_names.is_empty() => { let setting = if feature.value != 0 { mapping.selector_to_enable } else { @@ -210,7 +210,7 @@ impl hb_aat_map_builder_t { self.range_first = last_index; self.range_last = event.index.wrapping_sub(1); - if self.current_features.len() != 0 { + if !self.current_features.is_empty() { self.current_features.sort(); let mut j = 0; for i in 1..self.current_features.len() { diff --git a/src/hb/buffer.rs b/src/hb/buffer.rs index 2da6e5d6..2ac1b16f 100644 --- a/src/hb/buffer.rs +++ b/src/hb/buffer.rs @@ -49,16 +49,16 @@ pub mod glyph_flag { /// line-break position, in the following way: /// /// 1. Iterate back from the line-break - /// position until the first cluster - /// start position that is NOT unsafe-to-concat, + /// position until the first cluster + /// start position that is NOT unsafe-to-concat, /// 2. shape the segment from there till the - /// end of line, 3. check whether the resulting - /// glyph-run also is clear of the unsafe-to-concat - /// at its start-of-text position; if it is, just - /// splice it into place and the line is shaped; - /// If not, move on to a position further back that - /// is clear of unsafe-to-concat and retry from - /// there, and repeat. + /// end of line, 3. check whether the resulting + /// glyph-run also is clear of the unsafe-to-concat + /// at its start-of-text position; if it is, just + /// splice it into place and the line is shaped; + /// If not, move on to a position further back that + /// is clear of unsafe-to-concat and retry from + /// there, and repeat. /// /// At the start of next line a similar /// algorithm can be implemented. @@ -87,7 +87,7 @@ pub mod glyph_flag { /// /// The UNSAFE_TO_BREAK flag will always imply this flag. /// To use this flag, you must enable the buffer flag - /// PRODUCE_UNSAFE_TO_CONCAT during shaping, otherwise + /// PRODUCE_UNSAFE_TO_CONCAT during shaping, otherwise /// the buffer flag will not be reliably produced. pub const UNSAFE_TO_CONCAT: u32 = 0x00000002; @@ -845,7 +845,7 @@ impl hb_buffer_t { let not_mask = !mask; value &= mask; - if cluster_start == 0 && cluster_end == core::u32::MAX { + if cluster_start == 0 && cluster_end == u32::MAX { for info in &mut self.info[..self.len] { info.mask = (info.mask & not_mask) | value; } @@ -1103,7 +1103,7 @@ impl hb_buffer_t { } else { let mut cluster = self._infos_find_min_cluster(&self.info, self.idx, end, None); cluster = self._infos_find_min_cluster( - &self.out_info(), + self.out_info(), start, self.out_len, Some(cluster), @@ -1325,7 +1325,7 @@ impl hb_buffer_t { end: usize, cluster: Option, ) -> u32 { - let mut cluster = cluster.unwrap_or(core::u32::MAX); + let mut cluster = cluster.unwrap_or(u32::MAX); if start == end { return cluster; diff --git a/src/hb/common.rs b/src/hb/common.rs index 432ee692..8ca4cf14 100644 --- a/src/hb/common.rs +++ b/src/hb/common.rs @@ -579,10 +579,10 @@ impl core::str::FromStr for Feature { p.advance(1); p.consume_i32().unwrap_or(-1) as u32 // negative value overflow is ok } else { - if start_opt.is_some() && start != core::u32::MAX { + if start_opt.is_some() && start != u32::MAX { start + 1 } else { - core::u32::MAX + u32::MAX } }; @@ -590,7 +590,7 @@ impl core::str::FromStr for Feature { (start, end) } else { - (0, core::u32::MAX) + (0, u32::MAX) }; // Parse postfix. @@ -657,7 +657,7 @@ mod tests_features { test!(parse_13, "kern[3:5]=2", b"kern", 2, 3..=5); test!(parse_14, "kern[3;5]=2", b"kern", 2, 3..=5); test!(parse_15, "kern[:-1]", b"kern", 1, ..); - test!(parse_16, "kern[-1]", b"kern", 1, core::u32::MAX as usize..); + test!(parse_16, "kern[-1]", b"kern", 1, u32::MAX as usize..); test!(parse_17, "kern=on", b"kern", 1, ..); test!(parse_18, "kern=off", b"kern", 0, ..); test!(parse_19, "kern=oN", b"kern", 1, ..); diff --git a/src/hb/face.rs b/src/hb/face.rs index 7d58928e..2025dbed 100644 --- a/src/hb/face.rs +++ b/src/hb/face.rs @@ -195,10 +195,10 @@ impl<'a> hb_font_t<'a> { if is_vertical { if face.tables().vmtx.is_some() { - return face.glyph_ver_advance(glyph).unwrap_or(0) as u32; + face.glyph_ver_advance(glyph).unwrap_or(0) as u32 } else { // TODO: Original code calls `h_extents_with_fallback` - return (face.ascender() - face.descender()) as u32; + (face.ascender() - face.descender()) as u32 } } else if !is_vertical && face.tables().hmtx.is_some() { face.glyph_hor_advance(glyph).unwrap_or(0) as u32 @@ -222,7 +222,7 @@ impl<'a> hb_font_t<'a> { } else { let advance = self.ttfp_face.ascender() - self.ttfp_face.descender(); let diff = advance as i32 - -extents.height; - return extents.y_bearing + (diff >> 1); + extents.y_bearing + (diff >> 1) } } else { // TODO: Original code calls `h_extents_with_fallback` @@ -253,10 +253,7 @@ impl<'a> hb_font_t<'a> { glyph: GlyphId, glyph_extents: &mut hb_glyph_extents_t, ) -> bool { - let pixels_per_em = match self.pixels_per_em { - Some(ppem) => ppem.0, - None => core::u16::MAX, - }; + let pixels_per_em = self.pixels_per_em.map_or(u16::MAX, |ppem| ppem.0); if let Some(img) = self.ttfp_face.glyph_raster_image(glyph, pixels_per_em) { // HarfBuzz also supports only PNG. @@ -334,7 +331,7 @@ impl<'a> hb_font_t<'a> { glyph_extents.width = i32::from(bbox.width()); glyph_extents.height = i32::from(bbox.y_min - bbox.y_max); - return true; + true } pub(crate) fn glyph_name(&self, glyph: GlyphId) -> Option<&str> { diff --git a/src/hb/kerning.rs b/src/hb/kerning.rs index 0a540861..305c187f 100644 --- a/src/hb/kerning.rs +++ b/src/hb/kerning.rs @@ -175,7 +175,7 @@ fn apply_state_machine_kerning( .class(buffer.info[buffer.idx].as_glyph()) .unwrap_or(1) } else { - apple_layout::class::END_OF_TEXT as u8 + apple_layout::class::END_OF_TEXT }; let entry = match state_table.entry(state, class) { @@ -191,7 +191,8 @@ fn apply_state_machine_kerning( { // If there's no value and we're just epsilon-transitioning to state 0, safe to break. if entry.has_offset() - || !(entry.new_state == apple_layout::state::START_OF_TEXT && !entry.has_advance()) + || entry.new_state != apple_layout::state::START_OF_TEXT + || entry.has_advance() { buffer.unsafe_to_break_from_outbuffer( Some(buffer.backtrack_len() - 1), diff --git a/src/hb/mod.rs b/src/hb/mod.rs index 7a4ffa9e..4ff0f3c1 100644 --- a/src/hb/mod.rs +++ b/src/hb/mod.rs @@ -2,6 +2,22 @@ #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] #![allow(non_snake_case)] +#![allow(clippy::collapsible_if)] +#![allow(clippy::collapsible_else_if)] +#![allow(clippy::comparison_chain)] +#![allow(clippy::needless_range_loop)] +#![allow(clippy::non_canonical_partial_ord_impl)] +#![allow(clippy::upper_case_acronyms)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::wildcard_in_or_patterns)] +#![allow(clippy::identity_op)] +#![allow(clippy::mut_range_bound)] +#![allow(clippy::enum_variant_names)] +#![allow(clippy::manual_range_patterns)] +#![allow(clippy::type_complexity)] +#![allow(clippy::wrong_self_convention)] +#![allow(clippy::match_like_matches_macro)] +#![allow(clippy::manual_range_contains)] mod algs; #[macro_use] diff --git a/src/hb/ot/layout/GPOS/mark_lig_pos.rs b/src/hb/ot/layout/GPOS/mark_lig_pos.rs index 132945ad..441de30e 100644 --- a/src/hb/ot/layout/GPOS/mark_lig_pos.rs +++ b/src/hb/ot/layout/GPOS/mark_lig_pos.rs @@ -65,7 +65,7 @@ impl Apply for MarkToLigatureAdjustment<'_> { // can directly use the component index. If not, we attach the mark // glyph to the last component of the ligature. let lig_id = _hb_glyph_info_get_lig_id(&buffer.info[idx]); - let mark_id = _hb_glyph_info_get_lig_id(&buffer.cur(0)); + let mark_id = _hb_glyph_info_get_lig_id(buffer.cur(0)); let mark_comp = u16::from(_hb_glyph_info_get_lig_comp(buffer.cur(0))); let matches = lig_id != 0 && lig_id == mark_id && mark_comp > 0; let comp_index = if matches { diff --git a/src/hb/ot/layout/GSUB/ligature.rs b/src/hb/ot/layout/GSUB/ligature.rs index 35ea4a73..b2d222fb 100644 --- a/src/hb/ot/layout/GSUB/ligature.rs +++ b/src/hb/ot/layout/GSUB/ligature.rs @@ -54,7 +54,7 @@ impl Apply for Ligature<'_> { total_component_count, self.glyph, ); - return Some(()); + Some(()) } } } diff --git a/src/hb/ot/layout/GSUB/reverse_chain_single_subst.rs b/src/hb/ot/layout/GSUB/reverse_chain_single_subst.rs index 628f7adb..25eb0cf2 100644 --- a/src/hb/ot/layout/GSUB/reverse_chain_single_subst.rs +++ b/src/hb/ot/layout/GSUB/reverse_chain_single_subst.rs @@ -62,6 +62,6 @@ impl Apply for ReverseChainSingleSubstitution<'_> { ctx.buffer .unsafe_to_concat_from_outbuffer(Some(start_index), Some(end_index)); - return None; + None } } diff --git a/src/hb/ot_layout_gpos_table.rs b/src/hb/ot_layout_gpos_table.rs index 09bfa9a2..c268e954 100644 --- a/src/hb/ot_layout_gpos_table.rs +++ b/src/hb/ot_layout_gpos_table.rs @@ -167,10 +167,10 @@ impl TryNumFrom for i32 { // We can't represent `MIN-1` exactly, but there's no fractional part // at this magnitude, so we can just use a `MIN` inclusive boundary. - const MIN: f32 = core::i32::MIN as f32; + const MIN: f32 = i32::MIN as f32; // We can't represent `MAX` exactly, but it will round up to exactly // `MAX+1` (a power of two) when we cast it. - const MAX_P1: f32 = core::i32::MAX as f32; + const MAX_P1: f32 = i32::MAX as f32; if v >= MIN && v < MAX_P1 { Some(v as i32) } else { diff --git a/src/hb/ot_layout_gsubgpos.rs b/src/hb/ot_layout_gsubgpos.rs index 94b9b4cc..02919538 100644 --- a/src/hb/ot_layout_gsubgpos.rs +++ b/src/hb/ot_layout_gsubgpos.rs @@ -475,11 +475,11 @@ impl Apply for ContextLookup<'_> { match_end, lookups, ); - return Some(()); + Some(()) } else { ctx.buffer .unsafe_to_concat(Some(ctx.buffer.idx), Some(match_end)); - return None; + None } } } @@ -556,7 +556,7 @@ impl WouldApply for ChainedContextLookup<'_> { .. } => { (!ctx.zero_context - || (backtrack_coverages.len() == 0 && lookahead_coverages.len() == 0)) + || (backtrack_coverages.is_empty() && lookahead_coverages.is_empty())) && (ctx.glyphs.len() == usize::from(input_coverages.len()) + 1 && input_coverages .into_iter() @@ -712,7 +712,7 @@ trait ChainRuleExt { impl ChainRuleExt for ChainedSequenceRule<'_> { fn would_apply(&self, ctx: &WouldApplyContext, match_func: &match_func_t) -> bool { - (!ctx.zero_context || (self.backtrack.len() == 0 && self.lookahead.len() == 0)) + (!ctx.zero_context || (self.backtrack.is_empty() && self.lookahead.is_empty())) && (ctx.glyphs.len() == usize::from(self.input.len()) + 1 && self .input @@ -981,7 +981,7 @@ fn apply_lookup( } /// Value represents glyph class. -fn match_class<'a>(class_def: ClassDefinition<'a>) -> impl Fn(GlyphId, u16) -> bool + 'a { +fn match_class(class_def: ClassDefinition<'_>) -> impl Fn(GlyphId, u16) -> bool + '_ { move |glyph, value| class_def.get(glyph) == value } diff --git a/src/hb/ot_shape.rs b/src/hb/ot_shape.rs index 5b3131b9..7d198ed1 100644 --- a/src/hb/ot_shape.rs +++ b/src/hb/ot_shape.rs @@ -173,7 +173,7 @@ impl<'a> hb_ot_shape_planner_t<'a> { .enable_feature(hb_tag_t::from_bytes(b"vert"), F_GLOBAL_SEARCH, 1); } - if user_features.len() != 0 { + if !user_features.is_empty() { self.ot_map.is_simple = false; } @@ -346,7 +346,7 @@ fn substitute_pre(ctx: &mut hb_ot_shape_context_t) { hb_ot_substitute_plan(ctx); if ctx.plan.apply_morx && ctx.plan.apply_gpos { - hb_aat_layout_remove_deleted_glyphs(&mut ctx.buffer); + hb_aat_layout_remove_deleted_glyphs(ctx.buffer); } } @@ -612,7 +612,7 @@ fn set_unicode_props(buffer: &mut hb_buffer_t) { let info = &mut later[0]; info.init_unicode_props(&mut buffer.scratch_flags); - let gen_cat = _hb_glyph_info_get_general_category(&info); + let gen_cat = _hb_glyph_info_get_general_category(info); if (rb_flag_unsafe(gen_cat.to_rb()) & (rb_flag(RB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER) @@ -858,7 +858,7 @@ fn zero_width_default_ignorables(buffer: &mut hb_buffer_t) { } fn deal_with_variation_selectors(buffer: &mut hb_buffer_t) { - if !(buffer.scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_VARIATION_SELECTOR_FALLBACK != 0) { + if buffer.scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_VARIATION_SELECTOR_FALLBACK == 0 { return; } diff --git a/src/hb/ot_shape_fallback.rs b/src/hb/ot_shape_fallback.rs index 50a9ed01..5d5cf18f 100644 --- a/src/hb/ot_shape_fallback.rs +++ b/src/hb/ot_shape_fallback.rs @@ -271,7 +271,7 @@ fn position_around_base( // Use horizontal advance for horizontal positioning. // Generally a better idea. Also works for zero-ink glyphs. See: // https://github.com/harfbuzz/harfbuzz/issues/1532 - base_extents.width = face.glyph_h_advance(base_glyph) as i32; + base_extents.width = face.glyph_h_advance(base_glyph); let lig_id = _hb_glyph_info_get_lig_id(base_info) as u32; let num_lig_components = _hb_glyph_info_get_lig_num_comps(base_info) as i32; @@ -422,7 +422,7 @@ pub fn _hb_ot_shape_fallback_spaces( let len = buffer.len; let horizontal = buffer.direction.is_horizontal(); for (info, pos) in buffer.info[..len].iter().zip(&mut buffer.pos[..len]) { - if _hb_glyph_info_is_unicode_space(&info) && !_hb_glyph_info_ligated(info) { + if _hb_glyph_info_is_unicode_space(info) && !_hb_glyph_info_ligated(info) { let space_type = _hb_glyph_info_get_unicode_space_fallback_type(info); match space_type { t::SPACE_EM @@ -454,7 +454,7 @@ pub fn _hb_ot_shape_fallback_spaces( for u in '0'..='9' { if let Some(glyph) = face.get_nominal_glyph(u as u32) { if horizontal { - pos.x_advance = face.glyph_h_advance(glyph) as i32; + pos.x_advance = face.glyph_h_advance(glyph); } else { pos.y_advance = face.glyph_v_advance(glyph); } @@ -470,7 +470,7 @@ pub fn _hb_ot_shape_fallback_spaces( if let Some(glyph) = punct { if horizontal { - pos.x_advance = face.glyph_h_advance(glyph) as i32; + pos.x_advance = face.glyph_h_advance(glyph); } else { pos.y_advance = face.glyph_v_advance(glyph); } diff --git a/src/hb/ot_shaper_arabic.rs b/src/hb/ot_shaper_arabic.rs index 4477b6bd..3f8f4958 100644 --- a/src/hb/ot_shaper_arabic.rs +++ b/src/hb/ot_shaper_arabic.rs @@ -492,7 +492,7 @@ fn apply_stch(face: &hb_font_t, buffer: &mut hb_buffer_t) { let end = i; while i != 0 && arabic_action_t::is_stch(buffer.info[i - 1].arabic_shaping_action()) { i -= 1; - let width = face.glyph_h_advance(buffer.info[i].as_glyph()) as i32; + let width = face.glyph_h_advance(buffer.info[i].as_glyph()); if buffer.info[i].arabic_shaping_action() == arabic_action_t::STRETCHING_FIXED { w_fixed += width; @@ -543,7 +543,7 @@ fn apply_stch(face: &hb_font_t, buffer: &mut hb_buffer_t) { buffer.unsafe_to_break(Some(context), Some(end)); let mut x_offset = w_remaining / 2; for k in (start + 1..=end).rev() { - let width = face.glyph_h_advance(buffer.info[k - 1].as_glyph()) as i32; + let width = face.glyph_h_advance(buffer.info[k - 1].as_glyph()); let mut repeat = 1; if buffer.info[k - 1].arabic_shaping_action() diff --git a/src/hb/ot_shaper_indic.rs b/src/hb/ot_shaper_indic.rs index d3284827..c45b527c 100644 --- a/src/hb/ot_shaper_indic.rs +++ b/src/hb/ot_shaper_indic.rs @@ -1129,7 +1129,7 @@ fn initial_reordering_consonant_syllable( for i in base + 1..end { if buffer.info[i].is_consonant() { for j in last + 1..i { - if (buffer.info[j].indic_position() as u8) < (ot_position_t::POS_SMVD as u8) { + if buffer.info[j].indic_position() < ot_position_t::POS_SMVD { let pos = buffer.info[i].indic_position(); buffer.info[j].set_indic_position(pos); } @@ -1152,7 +1152,7 @@ fn initial_reordering_consonant_syllable( buffer.info[i].set_syllable(u8::try_from(i - start).unwrap()); } - buffer.info[start..end].sort_by(|a, b| a.indic_position().cmp(&b.indic_position())); + buffer.info[start..end].sort_by_key(|a| a.indic_position()); // Find base again; also flip left-matra sequence. let mut first_left_mantra = end; @@ -1651,7 +1651,7 @@ fn final_reordering_impl( ^ _hb_glyph_info_ligated_and_didnt_multiply(&buffer.info[start]) { let mut new_reph_pos; - loop { + 'reph: { let reph_pos = indic_plan.config.reph_pos; // 1. If reph should be positioned after post-base consonant forms, @@ -1679,7 +1679,7 @@ fn final_reordering_impl( new_reph_pos += 1; } - break; + break 'reph; } } @@ -1689,14 +1689,14 @@ fn final_reordering_impl( if reph_pos == RephPosition::AfterMain { new_reph_pos = base; while new_reph_pos + 1 < end - && buffer.info[new_reph_pos + 1].indic_position() as u8 - <= ot_position_t::POS_AFTER_MAIN as u8 + && buffer.info[new_reph_pos + 1].indic_position() + <= ot_position_t::POS_AFTER_MAIN { new_reph_pos += 1; } if new_reph_pos < end { - break; + break 'reph; } } @@ -1719,7 +1719,7 @@ fn final_reordering_impl( } if new_reph_pos < end { - break; + break 'reph; } } } @@ -1743,7 +1743,7 @@ fn final_reordering_impl( new_reph_pos += 1; } - break; + break 'reph; } // See https://github.com/harfbuzz/harfbuzz/issues/2298#issuecomment-615318654 @@ -1775,7 +1775,7 @@ fn final_reordering_impl( } } - break; + break 'reph; } // Move diff --git a/src/hb/ot_shaper_vowel_constraints.rs b/src/hb/ot_shaper_vowel_constraints.rs index 02be6f5c..a1223ede 100644 --- a/src/hb/ot_shaper_vowel_constraints.rs +++ b/src/hb/ot_shaper_vowel_constraints.rs @@ -1,5 +1,7 @@ // WARNING: this file was generated by scripts/gen-vowel-constraints.py +#![allow(clippy::single_match)] + use super::buffer::hb_buffer_t; use super::ot_layout::*; use super::script; diff --git a/src/hb/paint_extents.rs b/src/hb/paint_extents.rs index fcb515ce..d41a4142 100644 --- a/src/hb/paint_extents.rs +++ b/src/hb/paint_extents.rs @@ -40,13 +40,13 @@ impl hb_extents_t { } } -impl Into for RectF { - fn into(self) -> hb_extents_t { - hb_extents_t { - x_min: self.x_min, - y_min: self.y_min, - x_max: self.x_max, - y_max: self.y_max, +impl From for hb_extents_t { + fn from(val: RectF) -> Self { + Self { + x_min: val.x_min, + y_min: val.y_min, + x_max: val.x_max, + y_max: val.y_max, } } } diff --git a/src/hb/tag_table.rs b/src/hb/tag_table.rs index 429b3253..d1804e7e 100644 --- a/src/hb/tag_table.rs +++ b/src/hb/tag_table.rs @@ -1684,7 +1684,7 @@ fn lang_matches(language: &str, spec: &str) -> bool { fn strncmp(s1: &str, s2: &str, n: usize) -> bool { let n1 = core::cmp::min(n, s1.len()); let n2 = core::cmp::min(n, s2.len()); - &s1[..n1] == &s2[..n2] + s1[..n1] == s2[..n2] } /// Converts a multi-subtag BCP 47 language tag to language tags. diff --git a/src/hb/unicode.rs b/src/hb/unicode.rs index 346e775b..f7bcb3dd 100644 --- a/src/hb/unicode.rs +++ b/src/hb/unicode.rs @@ -298,23 +298,19 @@ impl GeneralCategoryExt for hb_unicode_general_category_t { } fn is_mark(&self) -> bool { - match *self { + matches!(*self, hb_unicode_general_category_t::SpacingMark | hb_unicode_general_category_t::EnclosingMark | - hb_unicode_general_category_t::NonspacingMark => true, - _ => false, - } + hb_unicode_general_category_t::NonspacingMark) } fn is_letter(&self) -> bool { - match *self { + matches!(*self, hb_unicode_general_category_t::LowercaseLetter | hb_unicode_general_category_t::ModifierLetter | hb_unicode_general_category_t::OtherLetter | hb_unicode_general_category_t::TitlecaseLetter | - hb_unicode_general_category_t::UppercaseLetter => true, - _ => false, - } + hb_unicode_general_category_t::UppercaseLetter) } } @@ -497,7 +493,7 @@ impl CharExt for char { } fn general_category(self) -> hb_unicode_general_category_t { - unicode_properties::general_category::UnicodeGeneralCategory::general_category(self).into() + unicode_properties::general_category::UnicodeGeneralCategory::general_category(self) } fn space_fallback(self) -> hb_unicode_funcs_t::space_t { diff --git a/tests/shaping/main.rs b/tests/shaping/main.rs index 2aa8dc4d..2ec84786 100644 --- a/tests/shaping/main.rs +++ b/tests/shaping/main.rs @@ -86,14 +86,14 @@ fn parse_cluster(s: &str) -> Result { "0" => Ok(rustybuzz::BufferClusterLevel::MonotoneGraphemes), "1" => Ok(rustybuzz::BufferClusterLevel::MonotoneCharacters), "2" => Ok(rustybuzz::BufferClusterLevel::Characters), - _ => Err(format!("invalid cluster level")), + _ => Err("invalid cluster level".to_string()), } } fn parse_unicodes(s: &str) -> Result { s.split(',') .map(|s| { - let s = s.strip_prefix("U+").unwrap_or(&s); + let s = s.strip_prefix("U+").unwrap_or(s); let cp = u32::from_str_radix(s, 16).map_err(|e| format!("{e}"))?; char::from_u32(cp).ok_or_else(|| format!("{cp:X} is not a valid codepoint")) }) @@ -104,7 +104,7 @@ pub fn shape(font_path: &str, text: &str, options: &str) -> String { let args = options .split(' ') .filter(|s| !s.is_empty()) - .map(|s| std::ffi::OsString::from(s)) + .map(std::ffi::OsString::from) .collect(); let args = parse_args(args).unwrap();