Fix warns

This commit is contained in:
Shunsuke Shibayama 2023-01-27 11:10:14 +09:00
parent 0019147007
commit 44781cb030
19 changed files with 96 additions and 99 deletions

View file

@ -553,7 +553,7 @@ impl NestedDisplay for ArrayComprehension {
fn fmt_nest(&self, f: &mut fmt::Formatter<'_>, _level: usize) -> fmt::Result {
let mut generators = String::new();
for (name, gen) in self.generators.iter() {
write!(generators, "{} <- {}, ", name, gen).unwrap();
write!(generators, "{name} <- {gen}, ")?;
}
write!(
f,
@ -890,7 +890,7 @@ impl NestedDisplay for MixedRecord {
fn fmt_nest(&self, f: &mut fmt::Formatter<'_>, _level: usize) -> fmt::Result {
write!(f, "{{")?;
for attr in self.attrs.iter() {
write!(f, "{}; ", attr)?;
write!(f, "{attr}; ")?;
}
write!(f, "}}")
}
@ -1063,7 +1063,7 @@ impl NestedDisplay for Call {
write!(f, "{}", self.obj)?;
}
if let Some(attr_name) = self.attr_name.as_ref() {
write!(f, "{}", attr_name)?;
write!(f, "{attr_name}")?;
}
if self.args.is_empty() {
write!(f, "()")
@ -2654,11 +2654,11 @@ impl NestedDisplay for VarPattern {
fn fmt_nest(&self, f: &mut fmt::Formatter<'_>, _level: usize) -> fmt::Result {
match self {
Self::Discard(_) => write!(f, "_"),
Self::Ident(ident) => write!(f, "{}", ident),
Self::Array(a) => write!(f, "{}", a),
Self::Tuple(t) => write!(f, "{}", t),
Self::Record(r) => write!(f, "{}", r),
Self::DataPack(d) => write!(f, "{}", d),
Self::Ident(ident) => write!(f, "{ident}"),
Self::Array(a) => write!(f, "{a}"),
Self::Tuple(t) => write!(f, "{t}"),
Self::Record(r) => write!(f, "{r}"),
Self::DataPack(d) => write!(f, "{d}"),
}
}
}
@ -2921,14 +2921,14 @@ pub enum ParamPattern {
impl NestedDisplay for ParamPattern {
fn fmt_nest(&self, f: &mut fmt::Formatter<'_>, _level: usize) -> fmt::Result {
match self {
Self::Discard(tok) => write!(f, "{}", tok),
Self::VarName(var_name) => write!(f, "{}", var_name),
Self::Lit(lit) => write!(f, "{}", lit),
Self::Array(array) => write!(f, "{}", array),
Self::Tuple(tuple) => write!(f, "{}", tuple),
Self::Record(record) => write!(f, "{}", record),
Self::Ref(var_name) => write!(f, "ref {}", var_name),
Self::RefMut(var_name) => write!(f, "ref! {}", var_name),
Self::Discard(tok) => write!(f, "{tok}"),
Self::VarName(var_name) => write!(f, "{var_name}"),
Self::Lit(lit) => write!(f, "{lit}"),
Self::Array(array) => write!(f, "{array}"),
Self::Tuple(tuple) => write!(f, "{tuple}"),
Self::Record(record) => write!(f, "{record}"),
Self::Ref(var_name) => write!(f, "ref {var_name}"),
Self::RefMut(var_name) => write!(f, "ref! {var_name}"),
}
}
}

View file

@ -239,22 +239,22 @@ impl LexError {
let expect = switch_lang!(
"japanese" => {
expect.push_str("期待された構文: ");
expect.push_str_with_color(&format!("!{}", lit), HINT);
expect.push_str_with_color(&format!("!{lit}"), HINT);
expect
},
"simplified_chinese" => {
expect.push_str("预期语法: ");
expect.push_str_with_color(&format!("!{}", lit), HINT);
expect.push_str_with_color(&format!("!{lit}"), HINT);
expect
},
"traditional_chinese" => {
expect.push_str("預期語法: ");
expect.push_str_with_color(&format!("!{}", lit), HINT);
expect.push_str_with_color(&format!("!{lit}"), HINT);
expect
},
"english" => {
expect.push_str("expected: ");
expect.push_str_with_color(&format!("!{}", lit), HINT);
expect.push_str_with_color(&format!("!{lit}"), HINT);
expect
},
)
@ -263,22 +263,22 @@ impl LexError {
let found = switch_lang!(
"japanese" => {
found.push_str("見つかった構文: ");
found.push_str_with_color(&format!("{}!", lit), ERR);
found.push_str_with_color(&format!("{lit}!"), ERR);
found
},
"simplified_chinese" => {
found.push_str("找到语法: ");
found.push_str_with_color(&format!("{}!", lit), ERR);
found.push_str_with_color(&format!("{lit}!"), ERR);
found
},
"traditional_chinese" => {
found.push_str("找到語法: ");
found.push_str_with_color(&format!("{}!", lit), ERR);
found.push_str_with_color(&format!("{lit}!"), ERR);
found
},
"english" => {
found.push_str("but found: ");
found.push_str_with_color(&format!("{}!", lit), ERR);
found.push_str_with_color(&format!("{lit}!"), ERR);
found
},
)

View file

@ -393,10 +393,10 @@ impl Lexer /*<'a>*/ {
}
let comment = self.emit_token(Illegal, &s);
let hint = switch_lang!(
"japanese" => format!("`]#`の数があと{}個必要です", nest_level),
"simplified_chinese" => format!("需要{}个`]#`", nest_level),
"traditional_chinese" => format!("需要{}個`]#`", nest_level),
"english" => format!("{} `]#`(s) are needed", nest_level),
"japanese" => format!("`]#`の数があと{nest_level}個必要です"),
"simplified_chinese" => format!("需要{nest_level}个`]#`"),
"traditional_chinese" => format!("需要{nest_level}個`]#`"),
"english" => format!("{nest_level} `]#`(s) are needed"),
);
Err(LexError::syntax_error(
line!() as usize,
@ -731,10 +731,10 @@ impl Lexer /*<'a>*/ {
line!() as usize,
token.loc(),
switch_lang!(
"japanese" => format!("不正なエスケープシーケンスです: \\{}", ch),
"simplified_chinese" => format!("不合法的转义序列: \\{}", ch),
"traditional_chinese" => format!("不合法的轉義序列: \\{}", ch),
"english" => format!("illegal escape sequence: \\{}", ch),
"japanese" => format!("不正なエスケープシーケンスです: \\{ch}"),
"simplified_chinese" => format!("不合法的转义序列: \\{ch}"),
"traditional_chinese" => format!("不合法的轉義序列: \\{ch}"),
"english" => format!("illegal escape sequence: \\{ch}"),
),
None,
)