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

@ -14,6 +14,6 @@ fn main() -> std::io::Result<()> {
version.micro.unwrap_or(0)
);
let magic_number = env_magic_number();
println!("cargo:rustc-env=PYTHON_MAGIC_NUMBER={}", magic_number);
println!("cargo:rustc-env=PYTHON_MAGIC_NUMBER={magic_number}");
Ok(())
}

View file

@ -84,7 +84,7 @@ impl<Checker: BuildRunnable> Server<Checker> {
let relative = relative
.strip_prefix(self.erg_path.to_str().unwrap())
.unwrap_or(relative);
format!("# {}, line {line}\n", relative)
format!("# {relative}, line {line}\n")
};
// display the definition line
if vi.kind.is_defined() {

View file

@ -201,7 +201,7 @@ impl<Checker: BuildRunnable> Server<Checker> {
if res.len() != 2 {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
format!("Header '{}' is malformed", buffer),
format!("Header '{buffer}' is malformed"),
));
}
let header_name = res[0].to_lowercase();
@ -217,7 +217,7 @@ impl<Checker: BuildRunnable> Server<Checker> {
if header_value != "utf8" && header_value != "utf-8" {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
format!("Content type '{}' is invalid", header_value),
format!("Content type '{header_value}' is invalid"),
));
}
}
@ -291,7 +291,7 @@ impl<Checker: BuildRunnable> Server<Checker> {
self.check_file(uri, &code)
}
// "textDocument/didChange"
_ => Self::send_log(format!("received notification: {}", method)),
_ => Self::send_log(format!("received notification: {method}")),
}
}

View file

@ -618,7 +618,7 @@ USAGE:
}
_ => {
let path = PathBuf::from_str(&arg[..])
.unwrap_or_else(|_| panic!("invalid file path: {}", arg));
.unwrap_or_else(|_| panic!("invalid file path: {arg}"));
let path = normalize_path(path);
cfg.input = Input::File(path);
if let Some("--") = args.next().as_ref().map(|s| &s[..]) {

View file

@ -374,10 +374,7 @@ fn format_context<E: ErrorDisplay + ?Sized>(
let (vbreak, vbar) = chars.gutters();
let offset = format!("{} {} ", &" ".repeat(max_digit), vbreak);
for (i, lineno) in (ln_begin..=ln_end).enumerate() {
context.push_str_with_color(
&format!("{:<max_digit$} {vbar} ", lineno, vbar = vbar),
gutter_color,
);
context.push_str_with_color(&format!("{lineno:<max_digit$} {vbar} "), gutter_color);
context.push_str(codes.get(i).unwrap_or(&String::new()));
context.push_str("\n");
context.push_str_with_color(&offset, gutter_color);
@ -578,7 +575,7 @@ impl SubMessage {
.remove(0)
};
let mut cxt = StyledStrings::default();
cxt.push_str_with_color(&format!(" {lineno} {} ", vbar), gutter_color);
cxt.push_str_with_color(&format!(" {lineno} {vbar} "), gutter_color);
cxt.push_str(&code);
cxt.push_str("\n");
for msg in self.msg.iter() {
@ -597,7 +594,7 @@ impl SubMessage {
other => {
let (_, vbar) = chars.gutters();
let mut cxt = StyledStrings::default();
cxt.push_str_with_color(&format!(" ? {} ", vbar), gutter_color);
cxt.push_str_with_color(&format!(" ? {vbar} "), gutter_color);
cxt.push_str(&other.reread());
cxt.push_str("\n");
for msg in self.msg.iter() {

View file

@ -348,7 +348,7 @@ impl StyledString {
}
impl std::fmt::Display for StyledString {
fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match (self.color, self.attribute) {
(None, None) => write!(f, "{}", self.text),
(None, Some(attr)) => write!(f, "{}{}{}", attr.as_str(), self.text, ATTR_RESET),
@ -493,7 +493,7 @@ impl StyledStrings {
impl std::fmt::Display for StyledStrings {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
for text in self.texts.iter() {
write!(f, "{}", text)?;
write!(f, "{text}")?;
}
Ok(())
}
@ -563,6 +563,6 @@ mod tests {
Color::Red,
Attribute::Reversed,
);
println!("{}", texts);
println!("{texts}");
}
}

View file

@ -290,7 +290,7 @@ pub fn __range_getitem__(mut args: ValueArgs, _ctx: &Context) -> EvalValueResult
} else {
Err(ErrorCore::new(
vec![SubMessage::only_loc(Location::Unknown)],
format!("Index out of range: {}", index),
format!("Index out of range: {index}"),
line!() as usize,
ErrorKind::IndexError,
Location::Unknown,

View file

@ -780,7 +780,7 @@ impl Context {
muty: Mutability,
) {
if self.patches.contains_key(name) {
panic!("{} has already been registered", name);
panic!("{name} has already been registered");
} else {
let name = VarName::from_static(name);
let vi = VarInfo::new(

View file

@ -127,8 +127,8 @@ impl LowerError {
found_t: &Type,
) -> Self {
let name = StyledString::new(readable_name(name), Some(WARN), None);
let expect = StyledString::new(format!("{}", spec_t), Some(HINT), Some(ATTR));
let found = StyledString::new(format!("{}", found_t), Some(ERR), Some(ATTR));
let expect = StyledString::new(format!("{spec_t}"), Some(HINT), Some(ATTR));
let found = StyledString::new(format!("{found_t}"), Some(ERR), Some(ATTR));
Self::new(
ErrorCore::new(
vec![SubMessage::only_loc(loc)],
@ -522,7 +522,7 @@ impl LowerError {
caused_by: S,
) -> Self {
let name = StyledString::new(name, Some(ERR), Some(ATTR));
let superclass = StyledString::new(format!("{}", superclass), Some(WARN), Some(ATTR));
let superclass = StyledString::new(format!("{superclass}"), Some(WARN), Some(ATTR));
let hint = Some(
switch_lang!(
"japanese" => {
@ -854,7 +854,7 @@ impl LowerError {
hint: Option<String>,
) -> Self {
let name = StyledString::new(name, Some(WARN), Some(ATTR));
let found = StyledString::new(format!("{}", cast_to), Some(ERR), Some(ATTR));
let found = StyledString::new(format!("{cast_to}"), Some(ERR), Some(ATTR));
Self::new(
ErrorCore::new(
vec![SubMessage::ambiguous_new(loc, vec![], hint)],

View file

@ -127,7 +127,7 @@ impl TyCheckError {
),
None => "".to_owned(),
};
let name = StyledString::new(format!("{}{}", name, ord), Some(WARN), Some(ATTR));
let name = StyledString::new(format!("{name}{ord}"), Some(WARN), Some(ATTR));
let mut expct = StyledStrings::default();
switch_lang!(
"japanese" => expct.push_str("予期した型: "),
@ -135,7 +135,7 @@ impl TyCheckError {
"traditional_chinese" => expct.push_str("預期: "),
"english" => expct.push_str("expected: "),
);
expct.push_str_with_color_and_attribute(format!("{}", expect), HINT, ATTR);
expct.push_str_with_color_and_attribute(format!("{expect}"), HINT, ATTR);
let mut fnd = StyledStrings::default();
switch_lang!(
@ -144,7 +144,7 @@ impl TyCheckError {
"traditional_chinese" => fnd.push_str("但找到: "),
"english" =>fnd.push_str("but found: "),
);
fnd.push_str_with_color_and_attribute(format!("{}", found), ERR, ATTR);
fnd.push_str_with_color_and_attribute(format!("{found}"), ERR, ATTR);
Self::new(
ErrorCore::new(
vec![SubMessage::ambiguous_new(
@ -183,7 +183,7 @@ impl TyCheckError {
"traditional_chinese" => expct.push_str("預期: "),
"english" => expct.push_str("expected: "),
);
expct.push_str_with_color_and_attribute(format!("{}", expect), HINT, ATTR);
expct.push_str_with_color_and_attribute(format!("{expect}"), HINT, ATTR);
let mut fnd = StyledStrings::default();
switch_lang!(
@ -192,7 +192,7 @@ impl TyCheckError {
"traditional_chinese" => fnd.push_str("但找到: "),
"english" =>fnd.push_str("but found: "),
);
fnd.push_str_with_color_and_attribute(format!("{}", found), ERR, ATTR);
fnd.push_str_with_color_and_attribute(format!("{found}"), ERR, ATTR);
Self::new(
ErrorCore::new(
@ -257,7 +257,7 @@ impl TyCheckError {
"traditional_chinese" => expct.push_str("預期: "),
"english" => expct.push_str("expected: "),
);
expct.push_str_with_color_and_attribute(format!("{}", expect), HINT, ATTR);
expct.push_str_with_color_and_attribute(format!("{expect}"), HINT, ATTR);
let mut fnd = StyledStrings::default();
switch_lang!(
@ -266,7 +266,7 @@ impl TyCheckError {
"traditional_chinese" => fnd.push_str("但找到: "),
"english" =>fnd.push_str("but found: "),
);
fnd.push_str_with_color_and_attribute(format!("{}", found), ERR, ATTR);
fnd.push_str_with_color_and_attribute(format!("{found}"), ERR, ATTR);
Self::new(
ErrorCore::new(
@ -305,7 +305,7 @@ impl TyCheckError {
"traditional_chinese" => expct.push_str("預期: "),
"english" => expct.push_str("expected: "),
);
expct.push_str_with_color_and_attribute(format!("{}", expect), HINT, ATTR);
expct.push_str_with_color_and_attribute(format!("{expect}"), HINT, ATTR);
let mut fnd = StyledStrings::default();
switch_lang!(
@ -314,7 +314,7 @@ impl TyCheckError {
"traditional_chinese" => fnd.push_str("但找到: "),
"english" =>fnd.push_str("but found: "),
);
fnd.push_str_with_color_and_attribute(format!("{}", found), ERR, ATTR);
fnd.push_str_with_color_and_attribute(format!("{found}"), ERR, ATTR);
Self::new(
ErrorCore::new(
@ -433,9 +433,9 @@ impl TyCheckError {
kw_args_len: usize,
) -> Self {
let name = readable_name(callee_name);
let expect = StyledString::new(format!("{}", params_len), Some(HINT), Some(ATTR));
let pos_args_len = StyledString::new(format!("{}", pos_args_len), Some(ERR), Some(ATTR));
let kw_args_len = StyledString::new(format!("{}", kw_args_len), Some(ERR), Some(ATTR));
let expect = StyledString::new(format!("{params_len}"), Some(HINT), Some(ATTR));
let pos_args_len = StyledString::new(format!("{pos_args_len}"), Some(ERR), Some(ATTR));
let kw_args_len = StyledString::new(format!("{kw_args_len}"), Some(ERR), Some(ATTR));
Self::new(
ErrorCore::new(
vec![SubMessage::only_loc(loc)],
@ -576,7 +576,7 @@ passed keyword args: {kw_args_len}"
"traditional_chinese" => lhs_typ.push_str("左邊: "),
"english" => lhs_typ.push_str("lhs: "),
);
lhs_typ.push_str_with_color_and_attribute(format!("{}", lhs_t), WARN, ATTR);
lhs_typ.push_str_with_color_and_attribute(format!("{lhs_t}"), WARN, ATTR);
let mut rhs_typ = StyledStrings::default();
switch_lang!(
"japanese" => rhs_typ.push_str("右辺: "),
@ -584,7 +584,7 @@ passed keyword args: {kw_args_len}"
"traditional_chinese" => rhs_typ.push_str("右邊: "),
"english" => rhs_typ.push_str("rhs: "),
);
rhs_typ.push_str_with_color_and_attribute(format!("{}", rhs_t), WARN, ATTR);
rhs_typ.push_str_with_color_and_attribute(format!("{rhs_t}"), WARN, ATTR);
Self::new(
ErrorCore::new(
vec![SubMessage::ambiguous_new(
@ -622,7 +622,7 @@ passed keyword args: {kw_args_len}"
"traditional_chinese" => lhs_typ.push_str("左邊: "),
"english" => lhs_typ.push_str("lhs: "),
);
lhs_typ.push_str_with_color_and_attribute(format!("{}", lhs_t), WARN, ATTR);
lhs_typ.push_str_with_color_and_attribute(format!("{lhs_t}"), WARN, ATTR);
let mut rhs_typ = StyledStrings::default();
switch_lang!(
"japanese" => rhs_typ.push_str("右辺: "),
@ -630,7 +630,7 @@ passed keyword args: {kw_args_len}"
"traditional_chinese" => rhs_typ.push_str("右邊: "),
"english" => rhs_typ.push_str("rhs: "),
);
rhs_typ.push_str_with_color_and_attribute(format!("{}", rhs_t), WARN, ATTR);
rhs_typ.push_str_with_color_and_attribute(format!("{rhs_t}"), WARN, ATTR);
Self::new(
ErrorCore::new(
vec![SubMessage::ambiguous_new(
@ -668,7 +668,7 @@ passed keyword args: {kw_args_len}"
"simplified_chinese" =>sub_type.push_str("子類型:"),
"english" => sub_type.push_str("subtype: "),
);
sub_type.push_str_with_color_and_attribute(format!("{}", sub_t), HINT, ATTR);
sub_type.push_str_with_color_and_attribute(format!("{sub_t}"), HINT, ATTR);
let mut sup_type = StyledStrings::default();
switch_lang!(
@ -677,7 +677,7 @@ passed keyword args: {kw_args_len}"
"simplified_chinese" => sup_type.push_str("父類型: "),
"english" =>sup_type.push_str("supertype: "),
);
sup_type.push_str_with_color_and_attribute(format!("{}", sup_t), ERR, ATTR);
sup_type.push_str_with_color_and_attribute(format!("{sup_t}"), ERR, ATTR);
let hint = switch_lang!(
"japanese" => "型推論が失敗している可能性があります。型を明示的に指定してみてください。",
"simplified_chinese" => "可能是编译器推断失败。请尝试明确指定类型。",
@ -720,7 +720,7 @@ passed keyword args: {kw_args_len}"
"traditional_chinese" => lhs_uni.push_str("左邊: "),
"english" => lhs_uni.push_str("lhs: "),
);
lhs_uni.push_str_with_color_and_attribute(format!("{}", lhs), HINT, ATTR);
lhs_uni.push_str_with_color_and_attribute(format!("{lhs}"), HINT, ATTR);
let mut rhs_uni = StyledStrings::default();
switch_lang!(
"japanese" => rhs_uni.push_str("右辺: "),
@ -728,7 +728,7 @@ passed keyword args: {kw_args_len}"
"traditional_chinese" => rhs_uni.push_str("右邊: "),
"english" => rhs_uni.push_str("rhs: "),
);
rhs_uni.push_str_with_color_and_attribute(format!("{}", rhs), ERR, ATTR);
rhs_uni.push_str_with_color_and_attribute(format!("{rhs}"), ERR, ATTR);
Self::new(
ErrorCore::new(
vec![SubMessage::ambiguous_new(
@ -854,23 +854,23 @@ passed keyword args: {kw_args_len}"
let mut expct = StyledStrings::default();
switch_lang!(
"japanese" => {
expct.push_str_with_color_and_attribute(format!("{}", trait_type), ACCENT, ATTR);
expct.push_str_with_color_and_attribute(format!("{trait_type}"), ACCENT, ATTR);
expct.push_str("で宣言された型: ");
},
"simplified_chinese" => {
expct.push_str_with_color_and_attribute(format!("{}", trait_type), ACCENT, ATTR);
expct.push_str_with_color_and_attribute(format!("{trait_type}"), ACCENT, ATTR);
expct.push_str("中声明的类型: ");
},
"traditional_chinese" => {
expct.push_str_with_color_and_attribute(format!("{}", trait_type), ACCENT, ATTR);
expct.push_str_with_color_and_attribute(format!("{trait_type}"), ACCENT, ATTR);
expct.push_str("中聲明的類型: ");
},
"english" => {
expct.push_str("declared in ");
expct.push_str_with_color(format!("{}: ", trait_type), ACCENT);
expct.push_str_with_color(format!("{trait_type}: "), ACCENT);
},
);
expct.push_str_with_color(format!("{}", expect), HINT);
expct.push_str_with_color(format!("{expect}"), HINT);
let mut fnd = StyledStrings::default();
switch_lang!(
"japanese" => fnd.push_str("与えられた型: "),
@ -878,7 +878,7 @@ passed keyword args: {kw_args_len}"
"traditional_chinese" => fnd.push_str("但找到: "),
"english" => fnd.push_str("but found: "),
);
fnd.push_str_with_color(format!("{}", found), ERR);
fnd.push_str_with_color(format!("{found}"), ERR);
let member_name = StyledStr::new(member_name, Some(WARN), Some(ATTR));
Self::new(
ErrorCore::new(

View file

@ -394,7 +394,7 @@ impl NestedDisplay for Identifier {
}
}
if let Some(qn) = &self.qual_name {
write!(f, "(qual_name: {})", qn)?;
write!(f, "(qual_name: {qn})")?;
}
if self.vi.t != Type::Uninited {
write!(f, "(: {})", self.vi.t)?;

View file

@ -489,7 +489,7 @@ impl CodeObj {
fn read_instr_308(&self, op: &u8, arg: &u8, idx: usize, instrs: &mut String) {
let op308 = Opcode308::from(*op);
let s_op = op308.to_string();
write!(instrs, "{:>15} {:<25}", idx, s_op).unwrap();
write!(instrs, "{idx:>15} {s_op:<25}").unwrap();
if let Ok(op) = CommonOpcode::try_from(*op) {
self.dump_additional_info(op, arg, idx, instrs);
}
@ -531,7 +531,7 @@ impl CodeObj {
fn read_instr_310(&self, op: &u8, arg: &u8, idx: usize, instrs: &mut String) {
let op310 = Opcode310::from(*op);
let s_op = op310.to_string();
write!(instrs, "{:>15} {:<25}", idx, s_op).unwrap();
write!(instrs, "{idx:>15} {s_op:<25}").unwrap();
if let Ok(op) = CommonOpcode::try_from(*op) {
self.dump_additional_info(op, arg, idx, instrs);
}

View file

@ -258,10 +258,10 @@ impl Deserializer {
0,
fn_name!(),
switch_lang!(
"japanese" => format!("このオブジェクトは復元できません: {}", other),
"simplified_chinese" => format!("无法反序列化此对象: {}", other),
"traditional_chinese" => format!("無法反序列化此對象: {}", other),
"english" => format!("cannot deserialize this object: {}", other),
"japanese" => format!("このオブジェクトは復元できません: {other}"),
"simplified_chinese" => format!("无法反序列化此对象: {other}"),
"traditional_chinese" => format!("無法反序列化此對象: {other}"),
"english" => format!("cannot deserialize this object: {other}"),
),
)),
}

View file

@ -149,13 +149,13 @@ impl fmt::Display for ParamTy {
match self {
Self::Pos { name, ty } => {
if let Some(name) = name {
write!(f, "{}", name)?;
write!(f, "{name}")?;
}
write!(f, ": {}", ty)
write!(f, ": {ty}")
}
Self::Kw { name, ty } => write!(f, "{}: {}", name, ty),
Self::Kw { name, ty } => write!(f, "{name}: {ty}"),
Self::KwWithDefault { name, ty, default } => {
write!(f, "{}: {} := {}", name, ty, default)
write!(f, "{name}: {ty} := {default}")
}
}
}
@ -397,7 +397,7 @@ impl LimitedDisplay for RefinementType {
write!(f, "{{")?;
for pred in self.preds.iter() {
let (_, rhs) = enum_unwrap!(pred, Predicate::Equal { lhs, rhs });
write!(f, "{}, ", rhs)?;
write!(f, "{rhs}, ")?;
}
write!(f, "}}")?;
if cfg!(feature = "debug") {

View file

@ -246,16 +246,16 @@ impl LimitedDisplay for TyParam {
Self::Type(t) => t.limited_fmt(f, limit - 1),
Self::FreeVar(fv) => fv.limited_fmt(f, limit - 1),
Self::UnaryOp { op, val } => {
write!(f, "{}", op)?;
write!(f, "{op}")?;
val.limited_fmt(f, limit - 1)
}
Self::BinOp { op, lhs, rhs } => {
lhs.limited_fmt(f, limit - 1)?;
write!(f, " {} ", op)?;
write!(f, " {op} ")?;
rhs.limited_fmt(f, limit - 1)
}
Self::App { name, args } => {
write!(f, "{}", name)?;
write!(f, "{name}")?;
write!(f, "(")?;
for (i, arg) in args.iter().enumerate() {
if i > 0 {
@ -270,10 +270,10 @@ impl LimitedDisplay for TyParam {
write!(f, "_: ")?;
t.limited_fmt(f, limit - 1)
}
Self::Mono(name) => write!(f, "{}", name),
Self::Mono(name) => write!(f, "{name}"),
Self::Proj { obj, attr } => {
write!(f, "{}.", obj)?;
write!(f, "{}", attr)
write!(f, "{obj}.")?;
write!(f, "{attr}")
}
Self::Array(arr) => {
write!(f, "[")?;

View file

@ -455,7 +455,7 @@ impl fmt::Debug for ValueObj {
if i != 0 {
write!(f, ", ")?;
}
write!(f, "{}: {}", k, v)?;
write!(f, "{k}: {v}")?;
}
write!(f, "}}")
}
@ -977,7 +977,7 @@ impl ValueObj {
(Self::Int(l), Self::Float(r)) => Some(Self::Float(l as f64 - r)),
(Self::Nat(l), Self::Float(r)) => Some(Self::Float(l as f64 - r)),
(Self::Float(l), Self::Int(r)) => Some(Self::Float(l - r as f64)),
(Self::Str(l), Self::Str(r)) => Some(Self::Str(Str::from(format!("{}{}", l, r)))),
(Self::Str(l), Self::Str(r)) => Some(Self::Str(Str::from(format!("{l}{r}")))),
(inf @ (Self::Inf | Self::NegInf), _) | (_, inf @ (Self::Inf | Self::NegInf)) => {
Some(inf)
}

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,
)