Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
skius committed Aug 9, 2023
1 parent 2dd2ec8 commit cba53a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions experimental/transliterator_parser/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,9 @@ impl Pass1ResultGenerator {

// TODO: define type FilterSet that is just a CPIL (without strings) and use that everywhere

fn compile_one_direction<'p>(
fn compile_one_direction(
result: DirectedPass1Result,
variable_definitions: &HashMap<String, &'p [parse::Element]>,
variable_definitions: &HashMap<String, &[parse::Element]>,
) -> Result<icu_transliteration::provider::RuleBasedTransliterator<'static>> {
let mut p2 = Pass2::try_new(&result.data, variable_definitions)?;
let t = p2.run(result.groups, result.filter)?;
Expand Down
21 changes: 13 additions & 8 deletions experimental/transliterator_parser/src/compile/pass2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use core::fmt;
use std::fmt::{Display, Formatter};
use super::*;
use crate::parse::UnicodeSet;
use icu_collections::codepointinvlist::CodePointInversionList;
Expand Down Expand Up @@ -173,11 +175,12 @@ enum LiteralOrStandin<'a> {
Standin(char),
}

impl<'a> LiteralOrStandin<'a> {
fn to_string(&self) -> String {
// gives us `to_string` and makes clippy happy
impl<'a> Display for LiteralOrStandin<'a> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match *self {
LiteralOrStandin::Literal(s) => s.to_owned(),
LiteralOrStandin::Standin(c) => c.to_string(),
LiteralOrStandin::Literal(s) => write!(f, "{}", s),
LiteralOrStandin::Standin(c) => write!(f, "{}", c),
}
}
}
Expand Down Expand Up @@ -224,10 +227,10 @@ impl<'a, 'p> Pass2<'a, 'p> {
let mut compiled_conversion_group = Vec::new();
for rule in conversion_group {
// TODO: depending on source or target, remove the ignored special constructs (anchor, cursor)
let ante = self.compile_section(&rule.ante);
let key = self.compile_section(&rule.key);
let post = self.compile_section(&rule.post);
let replacer = self.compile_section(&rule.replacement);
let ante = self.compile_section(rule.ante);
let key = self.compile_section(rule.key);
let post = self.compile_section(rule.post);
let replacer = self.compile_section(rule.replacement);
let cursor_offset = rule.cursor_offset;
compiled_conversion_group.push(ds::Rule {
ante: ante.into(),
Expand Down Expand Up @@ -272,6 +275,8 @@ impl<'a, 'p> Pass2<'a, 'p> {
if let Some(c) = self.var_to_char.get(var) {
return *c;
}
// the first pass ensures that all variables are defined
#[allow(clippy::indexing_slicing)]
let definition = self.var_definitions[var];
let compiled = self.compile_section(definition);
let standin = self.var_table.insert_compound(compiled);
Expand Down
2 changes: 2 additions & 0 deletions experimental/transliterator_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
)]
#![warn(missing_docs)]

extern crate core;

use icu_properties::provider::*;
use icu_provider::prelude::*;
use icu_transliteration::provider::RuleBasedTransliterator;
Expand Down

0 comments on commit cba53a7

Please sign in to comment.