Bump ecow

This commit is contained in:
Laurenz 2023-03-01 11:27:10 +01:00
parent 8f246406c6
commit ab841188e3
19 changed files with 60 additions and 59 deletions

3
Cargo.lock generated
View File

@ -307,7 +307,8 @@ dependencies = [
[[package]] [[package]]
name = "ecow" name = "ecow"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/typst/ecow#36b624de42f12f90ebad3e0498d770e1700f2e90" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e60e2840fbfc397c7972b11a6e6bd99a0248921cc1e31f293c5f6c5ac24831da"
[[package]] [[package]]
name = "elsa" name = "elsa"

View File

@ -16,7 +16,7 @@ typst-macros = { path = "macros" }
bitflags = "1" bitflags = "1"
bytemuck = "1" bytemuck = "1"
comemo = { git = "https://github.com/typst/comemo" } comemo = { git = "https://github.com/typst/comemo" }
ecow = { git = "https://github.com/typst/ecow" } ecow = "0.1"
flate2 = "1" flate2 = "1"
if_chain = "1" if_chain = "1"
image = { version = "0.24", default-features = false, features = ["png", "jpeg", "gif"] } image = { version = "0.24", default-features = false, features = ["png", "jpeg", "gif"] }

View File

@ -13,7 +13,7 @@ bench = false
typst = { path = ".." } typst = { path = ".." }
comemo = { git = "https://github.com/typst/comemo" } comemo = { git = "https://github.com/typst/comemo" }
csv = "1" csv = "1"
ecow = { git = "https://github.com/typst/ecow" } ecow = "0.1"
hypher = "0.1" hypher = "0.1"
kurbo = "0.8" kurbo = "0.8"
lipsum = { git = "https://github.com/reknih/lipsum" } lipsum = { git = "https://github.com/reknih/lipsum" }

View File

@ -211,7 +211,7 @@ impl NumberingKind {
let mut n = n.get(); let mut n = n.get();
match self { match self {
Self::Arabic => { Self::Arabic => {
format_eco!("{n}") eco_format!("{n}")
} }
Self::Letter => { Self::Letter => {
n -= 1; n -= 1;

View File

@ -194,7 +194,7 @@ impl Show for OutlineNode {
} }
// Add the page number and linebreak. // Add the page number and linebreak.
let end = TextNode::packed(format_eco!("{}", loc.page)); let end = TextNode::packed(eco_format!("{}", loc.page));
seq.push(end.linked(Destination::Internal(loc))); seq.push(end.linked(Destination::Internal(loc)));
seq.push(LinebreakNode { justify: false }.pack()); seq.push(LinebreakNode { justify: false }.pack());

View File

@ -43,6 +43,6 @@ impl RefNode {
impl Show for RefNode { impl Show for RefNode {
fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult<Content> { fn show(&self, _: &mut Vt, _: &Content, _: StyleChain) -> SourceResult<Content> {
Ok(TextNode::packed(format_eco!("@{}", self.0))) Ok(TextNode::packed(eco_format!("@{}", self.0)))
} }
} }

View File

@ -8,7 +8,7 @@ pub use std::num::NonZeroUsize;
#[doc(no_inline)] #[doc(no_inline)]
pub use comemo::{Track, Tracked, TrackedMut}; pub use comemo::{Track, Tracked, TrackedMut};
#[doc(no_inline)] #[doc(no_inline)]
pub use ecow::{format_eco, EcoString}; pub use ecow::{eco_format, EcoString};
#[doc(no_inline)] #[doc(no_inline)]
pub use typst::diag::{bail, error, At, SourceResult, StrResult}; pub use typst::diag::{bail, error, At, SourceResult, StrResult};
#[doc(no_inline)] #[doc(no_inline)]

View File

@ -38,14 +38,14 @@ macro_rules! __error {
}; };
($span:expr, $fmt:expr, $($arg:expr),+ $(,)?) => { ($span:expr, $fmt:expr, $($arg:expr),+ $(,)?) => {
$crate::diag::error!($span, $crate::diag::format_eco!($fmt, $($arg),+)) $crate::diag::error!($span, $crate::diag::eco_format!($fmt, $($arg),+))
}; };
} }
#[doc(inline)] #[doc(inline)]
pub use crate::__error as error; pub use crate::__error as error;
#[doc(hidden)] #[doc(hidden)]
pub use ecow::format_eco; pub use ecow::eco_format;
/// A result that can carry multiple source errors. /// A result that can carry multiple source errors.
pub type SourceResult<T> = Result<T, Box<Vec<SourceError>>>; pub type SourceResult<T> = Result<T, Box<Vec<SourceError>>>;
@ -268,7 +268,7 @@ impl From<FromUtf8Error> for FileError {
impl From<FileError> for EcoString { impl From<FileError> for EcoString {
fn from(error: FileError) -> Self { fn from(error: FileError) -> Self {
format_eco!("{error}") eco_format!("{error}")
} }
} }

View File

@ -1,6 +1,6 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ecow::format_eco; use ecow::eco_format;
use pdf_writer::types::{CidFontType, FontFlags, SystemInfo, UnicodeCmap}; use pdf_writer::types::{CidFontType, FontFlags, SystemInfo, UnicodeCmap};
use pdf_writer::{Filter, Finish, Name, Rect, Str}; use pdf_writer::{Filter, Finish, Name, Rect, Str};
use ttf_parser::{name_id, GlyphId, Tag}; use ttf_parser::{name_id, GlyphId, Tag};
@ -26,7 +26,7 @@ pub fn write_fonts(ctx: &mut PdfContext) {
.find_name(name_id::POST_SCRIPT_NAME) .find_name(name_id::POST_SCRIPT_NAME)
.unwrap_or_else(|| "unknown".to_string()); .unwrap_or_else(|| "unknown".to_string());
let base_font = format_eco!("ABCDEF+{}", postscript_name); let base_font = eco_format!("ABCDEF+{}", postscript_name);
let base_font = Name(base_font.as_bytes()); let base_font = Name(base_font.as_bytes());
let cmap_name = Name(b"Custom"); let cmap_name = Name(b"Custom");
let system_info = SystemInfo { let system_info = SystemInfo {

View File

@ -1,4 +1,4 @@
use ecow::format_eco; use ecow::eco_format;
use pdf_writer::types::{ActionType, AnnotationType, ColorSpaceOperand}; use pdf_writer::types::{ActionType, AnnotationType, ColorSpaceOperand};
use pdf_writer::writers::ColorSpace; use pdf_writer::writers::ColorSpace;
use pdf_writer::{Content, Filter, Finish, Name, Rect, Ref, Str}; use pdf_writer::{Content, Filter, Finish, Name, Rect, Ref, Str};
@ -80,7 +80,7 @@ pub fn write_page_tree(ctx: &mut PdfContext) {
let mut fonts = resources.fonts(); let mut fonts = resources.fonts();
for (font_ref, f) in ctx.font_map.pdf_indices(&ctx.font_refs) { for (font_ref, f) in ctx.font_map.pdf_indices(&ctx.font_refs) {
let name = format_eco!("F{}", f); let name = eco_format!("F{}", f);
fonts.pair(Name(name.as_bytes()), font_ref); fonts.pair(Name(name.as_bytes()), font_ref);
} }
@ -88,7 +88,7 @@ pub fn write_page_tree(ctx: &mut PdfContext) {
let mut images = resources.x_objects(); let mut images = resources.x_objects();
for (image_ref, im) in ctx.image_map.pdf_indices(&ctx.image_refs) { for (image_ref, im) in ctx.image_map.pdf_indices(&ctx.image_refs) {
let name = format_eco!("Im{}", im); let name = eco_format!("Im{}", im);
images.pair(Name(name.as_bytes()), image_ref); images.pair(Name(name.as_bytes()), image_ref);
} }
@ -201,7 +201,7 @@ impl PageContext<'_, '_> {
fn set_font(&mut self, font: &Font, size: Abs) { fn set_font(&mut self, font: &Font, size: Abs) {
if self.state.font.as_ref().map(|(f, s)| (f, *s)) != Some((font, size)) { if self.state.font.as_ref().map(|(f, s)| (f, *s)) != Some((font, size)) {
self.parent.font_map.insert(font.clone()); self.parent.font_map.insert(font.clone());
let name = format_eco!("F{}", self.parent.font_map.map(font.clone())); let name = eco_format!("F{}", self.parent.font_map.map(font.clone()));
self.content.set_font(Name(name.as_bytes()), size.to_f32()); self.content.set_font(Name(name.as_bytes()), size.to_f32());
self.state.font = Some((font.clone(), size)); self.state.font = Some((font.clone(), size));
} }
@ -439,7 +439,7 @@ fn write_path(ctx: &mut PageContext, x: f32, y: f32, path: &geom::Path) {
/// Encode a vector or raster image into the content stream. /// Encode a vector or raster image into the content stream.
fn write_image(ctx: &mut PageContext, x: f32, y: f32, image: &Image, size: Size) { fn write_image(ctx: &mut PageContext, x: f32, y: f32, image: &Image, size: Size) {
ctx.parent.image_map.insert(image.clone()); ctx.parent.image_map.insert(image.clone());
let name = format_eco!("Im{}", ctx.parent.image_map.map(image.clone())); let name = eco_format!("Im{}", ctx.parent.image_map.map(image.clone()));
let w = size.x.to_f32(); let w = size.x.to_f32();
let h = size.y.to_f32(); let h = size.y.to_f32();
ctx.content.save_state(); ctx.content.save_state();

View File

@ -1,6 +1,6 @@
use std::collections::{BTreeSet, HashSet}; use std::collections::{BTreeSet, HashSet};
use ecow::{format_eco, EcoString}; use ecow::{eco_format, EcoString};
use if_chain::if_chain; use if_chain::if_chain;
use super::{analyze_expr, analyze_import, plain_docs_sentence, summarize_font_family}; use super::{analyze_expr, analyze_import, plain_docs_sentence, summarize_font_family};
@ -317,9 +317,9 @@ fn field_access_completions(ctx: &mut CompletionContext, value: &Value) {
kind: CompletionKind::Func, kind: CompletionKind::Func,
label: method.into(), label: method.into(),
apply: Some(if args { apply: Some(if args {
format_eco!("{method}(${{}})") eco_format!("{method}(${{}})")
} else { } else {
format_eco!("{method}()${{}}") eco_format!("{method}()${{}}")
}), }),
detail: None, detail: None,
}) })
@ -612,7 +612,7 @@ fn param_completions(
ctx.completions.push(Completion { ctx.completions.push(Completion {
kind: CompletionKind::Param, kind: CompletionKind::Param,
label: param.name.into(), label: param.name.into(),
apply: Some(format_eco!("{}: ${{}}", param.name)), apply: Some(eco_format!("{}: ${{}}", param.name)),
detail: Some(plain_docs_sentence(param.docs).into()), detail: Some(plain_docs_sentence(param.docs).into()),
}); });
} }
@ -872,7 +872,7 @@ impl<'a> CompletionContext<'a> {
fn enrich(&mut self, prefix: &str, suffix: &str) { fn enrich(&mut self, prefix: &str, suffix: &str) {
for Completion { label, apply, .. } in &mut self.completions { for Completion { label, apply, .. } in &mut self.completions {
let current = apply.as_ref().unwrap_or(label); let current = apply.as_ref().unwrap_or(label);
*apply = Some(format_eco!("{prefix}{current}{suffix}")); *apply = Some(eco_format!("{prefix}{current}{suffix}"));
} }
} }
@ -934,7 +934,7 @@ impl<'a> CompletionContext<'a> {
}); });
if parens && matches!(value, Value::Func(_)) { if parens && matches!(value, Value::Func(_)) {
apply = Some(format_eco!("{label}(${{}})")); apply = Some(eco_format!("{label}(${{}})"));
} }
self.completions.push(Completion { self.completions.push(Completion {
@ -998,8 +998,8 @@ impl<'a> CompletionContext<'a> {
self.completions.push(Completion { self.completions.push(Completion {
kind: CompletionKind::Syntax, kind: CompletionKind::Syntax,
label: (*ty).into(), label: (*ty).into(),
apply: Some(format_eco!("${{{ty}}}")), apply: Some(eco_format!("${{{ty}}}")),
detail: Some(format_eco!("A value of type {ty}.")), detail: Some(eco_format!("A value of type {ty}.")),
}); });
self.scope_completions(false, |value| value.type_name() == *ty); self.scope_completions(false, |value| value.type_name() == *ty);
} }

View File

@ -2,7 +2,7 @@ use std::cmp::Ordering;
use std::fmt::{self, Debug, Formatter, Write}; use std::fmt::{self, Debug, Formatter, Write};
use std::ops::{Add, AddAssign}; use std::ops::{Add, AddAssign};
use ecow::{format_eco, EcoString, EcoVec}; use ecow::{eco_format, EcoString, EcoVec};
use super::{ops, Args, Func, Value, Vm}; use super::{ops, Args, Func, Value, Vm};
use crate::diag::{bail, At, SourceResult, StrResult}; use crate::diag::{bail, At, SourceResult, StrResult};
@ -293,7 +293,7 @@ impl Array {
vec.make_mut().sort_by(|a, b| { vec.make_mut().sort_by(|a, b| {
a.partial_cmp(b).unwrap_or_else(|| { a.partial_cmp(b).unwrap_or_else(|| {
if result.is_ok() { if result.is_ok() {
result = Err(format_eco!( result = Err(eco_format!(
"cannot order {} and {}", "cannot order {} and {}",
a.type_name(), a.type_name(),
b.type_name(), b.type_name(),
@ -335,7 +335,7 @@ impl Array {
/// The out of bounds access error message. /// The out of bounds access error message.
#[cold] #[cold]
fn out_of_bounds(index: i64, len: i64) -> EcoString { fn out_of_bounds(index: i64, len: i64) -> EcoString {
format_eco!("array index out of bounds (index: {}, len: {})", index, len) eco_format!("array index out of bounds (index: {}, len: {})", index, len)
} }
/// The error message when the array is empty. /// The error message when the array is empty.
@ -389,7 +389,7 @@ impl FromIterator<Value> for Array {
impl IntoIterator for Array { impl IntoIterator for Array {
type Item = Value; type Item = Value;
type IntoIter = ecow::IntoIter<Value>; type IntoIter = ecow::vec::IntoIter<Value>;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
self.0.into_iter() self.0.into_iter()

View File

@ -3,7 +3,7 @@ use std::fmt::{self, Debug, Formatter, Write};
use std::ops::{Add, AddAssign}; use std::ops::{Add, AddAssign};
use std::sync::Arc; use std::sync::Arc;
use ecow::{format_eco, EcoString}; use ecow::{eco_format, EcoString};
use super::{array, Array, Str, Value}; use super::{array, Array, Str, Value};
use crate::diag::StrResult; use crate::diag::StrResult;
@ -66,7 +66,7 @@ impl Dict {
pub fn take(&mut self, key: &str) -> StrResult<Value> { pub fn take(&mut self, key: &str) -> StrResult<Value> {
Arc::make_mut(&mut self.0) Arc::make_mut(&mut self.0)
.remove(key) .remove(key)
.ok_or_else(|| format_eco!("missing key: {:?}", Str::from(key))) .ok_or_else(|| eco_format!("missing key: {:?}", Str::from(key)))
} }
/// Whether the dictionary contains a specific key. /// Whether the dictionary contains a specific key.
@ -123,7 +123,7 @@ impl Dict {
/// Return an "unexpected key" error if there is any remaining pair. /// Return an "unexpected key" error if there is any remaining pair.
pub fn finish(&self, expected: &[&str]) -> StrResult<()> { pub fn finish(&self, expected: &[&str]) -> StrResult<()> {
if let Some((key, _)) = self.iter().next() { if let Some((key, _)) = self.iter().next() {
let parts: Vec<_> = expected.iter().map(|s| format_eco!("\"{s}\"")).collect(); let parts: Vec<_> = expected.iter().map(|s| eco_format!("\"{s}\"")).collect();
let mut msg = format!("unexpected key {key:?}, valid keys are "); let mut msg = format!("unexpected key {key:?}, valid keys are ");
crate::diag::comma_list(&mut msg, &parts, "and"); crate::diag::comma_list(&mut msg, &parts, "and");
return Err(msg.into()); return Err(msg.into());
@ -135,7 +135,7 @@ impl Dict {
/// The missing key access error message. /// The missing key access error message.
#[cold] #[cold]
fn missing_key(key: &str) -> EcoString { fn missing_key(key: &str) -> EcoString {
format_eco!("dictionary does not contain key {:?}", Str::from(key)) eco_format!("dictionary does not contain key {:?}", Str::from(key))
} }
impl Debug for Dict { impl Debug for Dict {

View File

@ -1,7 +1,7 @@
use std::fmt::{self, Debug, Formatter}; use std::fmt::{self, Debug, Formatter};
use std::sync::Arc; use std::sync::Arc;
use ecow::{format_eco, EcoString}; use ecow::{eco_format, EcoString};
use super::{Content, Scope, Value}; use super::{Content, Scope, Value};
use crate::diag::StrResult; use crate::diag::StrResult;
@ -61,7 +61,7 @@ impl Module {
/// Try to access a definition in the module. /// Try to access a definition in the module.
pub fn get(&self, name: &str) -> StrResult<&Value> { pub fn get(&self, name: &str) -> StrResult<&Value> {
self.scope().get(&name).ok_or_else(|| { self.scope().get(&name).ok_or_else(|| {
format_eco!("module `{}` does not contain `{name}`", self.name()) eco_format!("module `{}` does not contain `{name}`", self.name())
}) })
} }

View File

@ -2,7 +2,7 @@
use std::cmp::Ordering; use std::cmp::Ordering;
use ecow::format_eco; use ecow::eco_format;
use super::{format_str, Regex, Value}; use super::{format_str, Regex, Value};
use crate::diag::StrResult; use crate::diag::StrResult;
@ -12,7 +12,7 @@ use Value::*;
/// Bail with a type mismatch error. /// Bail with a type mismatch error.
macro_rules! mismatch { macro_rules! mismatch {
($fmt:expr, $($value:expr),* $(,)?) => { ($fmt:expr, $($value:expr),* $(,)?) => {
return Err(format_eco!($fmt, $($value.type_name()),*)) return Err(eco_format!($fmt, $($value.type_name()),*))
}; };
} }
@ -117,7 +117,7 @@ pub fn add(lhs: Value, rhs: Value) -> StrResult<Value> {
(a.downcast::<GenAlign>(), b.downcast::<GenAlign>()) (a.downcast::<GenAlign>(), b.downcast::<GenAlign>())
{ {
if a.axis() == b.axis() { if a.axis() == b.axis() {
return Err(format_eco!("cannot add two {:?} alignments", a.axis())); return Err(eco_format!("cannot add two {:?} alignments", a.axis()));
} }
return Ok(Value::dynamic(match a.axis() { return Ok(Value::dynamic(match a.axis() {

View File

@ -15,14 +15,14 @@ use crate::geom::GenAlign;
#[doc(hidden)] #[doc(hidden)]
macro_rules! __format_str { macro_rules! __format_str {
($($tts:tt)*) => {{ ($($tts:tt)*) => {{
$crate::model::Str::from($crate::model::format_eco!($($tts)*)) $crate::model::Str::from($crate::model::eco_format!($($tts)*))
}}; }};
} }
#[doc(inline)] #[doc(inline)]
pub use crate::__format_str as format_str; pub use crate::__format_str as format_str;
#[doc(hidden)] #[doc(hidden)]
pub use ecow::format_eco; pub use ecow::eco_format;
/// An immutable reference counted string. /// An immutable reference counted string.
#[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
@ -297,13 +297,13 @@ impl Str {
/// The out of bounds access error message. /// The out of bounds access error message.
#[cold] #[cold]
fn out_of_bounds(index: i64, len: i64) -> EcoString { fn out_of_bounds(index: i64, len: i64) -> EcoString {
format_eco!("string index out of bounds (index: {}, len: {})", index, len) eco_format!("string index out of bounds (index: {}, len: {})", index, len)
} }
/// The char boundary access error message. /// The char boundary access error message.
#[cold] #[cold]
fn not_a_char_boundary(index: i64) -> EcoString { fn not_a_char_boundary(index: i64) -> EcoString {
format_eco!("string index {} is not a character boundary", index) eco_format!("string index {} is not a character boundary", index)
} }
/// The error message when the string is empty. /// The error message when the string is empty.
@ -449,7 +449,7 @@ pub struct Regex(regex::Regex);
impl Regex { impl Regex {
/// Create a new regular expression. /// Create a new regular expression.
pub fn new(re: &str) -> StrResult<Self> { pub fn new(re: &str) -> StrResult<Self> {
regex::Regex::new(re).map(Self).map_err(|err| format_eco!("{err}")) regex::Regex::new(re).map(Self).map_err(|err| eco_format!("{err}"))
} }
} }

View File

@ -4,7 +4,7 @@ use std::fmt::{self, Debug, Formatter};
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::sync::Arc; use std::sync::Arc;
use ecow::{format_eco, EcoString}; use ecow::{eco_format, EcoString};
use siphasher::sip128::{Hasher128, SipHasher}; use siphasher::sip128::{Hasher128, SipHasher};
use super::{ use super::{
@ -122,9 +122,9 @@ impl Value {
Self::Dict(dict) => dict.at(&field).cloned(), Self::Dict(dict) => dict.at(&field).cloned(),
Self::Content(content) => content Self::Content(content) => content
.field(&field) .field(&field)
.ok_or_else(|| format_eco!("unknown field `{field}`")), .ok_or_else(|| eco_format!("unknown field `{field}`")),
Self::Module(module) => module.get(&field).cloned(), Self::Module(module) => module.get(&field).cloned(),
v => Err(format_eco!("cannot access fields on type {}", v.type_name())), v => Err(eco_format!("cannot access fields on type {}", v.type_name())),
} }
} }
@ -146,8 +146,8 @@ impl Value {
pub fn display(self) -> Content { pub fn display(self) -> Content {
match self { match self {
Self::None => Content::empty(), Self::None => Content::empty(),
Self::Int(v) => item!(text)(format_eco!("{}", v)), Self::Int(v) => item!(text)(eco_format!("{}", v)),
Self::Float(v) => item!(text)(format_eco!("{}", v)), Self::Float(v) => item!(text)(eco_format!("{}", v)),
Self::Str(v) => item!(text)(v.into()), Self::Str(v) => item!(text)(v.into()),
Self::Symbol(v) => item!(text)(v.get().into()), Self::Symbol(v) => item!(text)(v.get().into()),
Self::Content(v) => v, Self::Content(v) => v,
@ -402,7 +402,7 @@ macro_rules! primitive {
match value { match value {
Value::$variant(v) => Ok(v), Value::$variant(v) => Ok(v),
$(Value::$other$(($binding))? => Ok($out),)* $(Value::$other$(($binding))? => Ok($out),)*
v => Err(format_eco!( v => Err(eco_format!(
"expected {}, found {}", "expected {}, found {}",
Self::TYPE_NAME, Self::TYPE_NAME,
v.type_name(), v.type_name(),

View File

@ -1,4 +1,4 @@
use ecow::{format_eco, EcoString}; use ecow::{eco_format, EcoString};
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use unicode_xid::UnicodeXID; use unicode_xid::UnicodeXID;
use unscanny::Scanner; use unscanny::Scanner;
@ -254,9 +254,9 @@ impl Lexer<'_> {
let remaining = backticks - found; let remaining = backticks - found;
let noun = if remaining == 1 { "backtick" } else { "backticks" }; let noun = if remaining == 1 { "backtick" } else { "backticks" };
return self.error_at_end(if found == 0 { return self.error_at_end(if found == 0 {
format_eco!("expected {} {}", remaining, noun) eco_format!("expected {} {}", remaining, noun)
} else { } else {
format_eco!("expected {} more {}", remaining, noun) eco_format!("expected {} more {}", remaining, noun)
}); });
} }

View File

@ -1,7 +1,7 @@
use std::collections::HashSet; use std::collections::HashSet;
use std::ops::Range; use std::ops::Range;
use ecow::{format_eco, EcoString}; use ecow::{eco_format, EcoString};
use unicode_math_class::MathClass; use unicode_math_class::MathClass;
use super::{ast, is_newline, ErrorPos, LexMode, Lexer, SyntaxKind, SyntaxNode}; use super::{ast, is_newline, ErrorPos, LexMode, Lexer, SyntaxKind, SyntaxNode};
@ -968,7 +968,7 @@ fn validate_array(p: &mut Parser, m: Marker) {
for child in p.post_process(m) { for child in p.post_process(m) {
let kind = child.kind(); let kind = child.kind();
if kind == SyntaxKind::Named || kind == SyntaxKind::Keyed { if kind == SyntaxKind::Named || kind == SyntaxKind::Keyed {
child.convert_to_error(format_eco!( child.convert_to_error(eco_format!(
"expected expression, found {}", "expected expression, found {}",
kind.name() kind.name()
)); ));
@ -998,7 +998,7 @@ fn validate_dict(p: &mut Parser, m: Marker) {
| SyntaxKind::Comma | SyntaxKind::Comma
| SyntaxKind::Colon => {} | SyntaxKind::Colon => {}
kind => { kind => {
child.convert_to_error(format_eco!( child.convert_to_error(eco_format!(
"expected named or keyed pair, found {}", "expected named or keyed pair, found {}",
kind.name() kind.name()
)); ));
@ -1026,7 +1026,7 @@ fn validate_params(p: &mut Parser, m: Marker) {
SyntaxKind::Spread => { SyntaxKind::Spread => {
let Some(within) = child.children_mut().last_mut() else { continue }; let Some(within) = child.children_mut().last_mut() else { continue };
if within.kind() != SyntaxKind::Ident { if within.kind() != SyntaxKind::Ident {
within.convert_to_error(format_eco!( within.convert_to_error(eco_format!(
"expected identifier, found {}", "expected identifier, found {}",
within.kind().name(), within.kind().name(),
)); ));
@ -1035,7 +1035,7 @@ fn validate_params(p: &mut Parser, m: Marker) {
} }
SyntaxKind::LeftParen | SyntaxKind::RightParen | SyntaxKind::Comma => {} SyntaxKind::LeftParen | SyntaxKind::RightParen | SyntaxKind::Comma => {}
kind => { kind => {
child.convert_to_error(format_eco!( child.convert_to_error(eco_format!(
"expected identifier, named pair or argument sink, found {}", "expected identifier, named pair or argument sink, found {}",
kind.name() kind.name()
)); ));
@ -1278,7 +1278,7 @@ impl<'s> Parser<'s> {
.last() .last()
.map_or(true, |child| child.kind() != SyntaxKind::Error) .map_or(true, |child| child.kind() != SyntaxKind::Error)
{ {
let message = format_eco!("expected {}", thing); let message = eco_format!("expected {}", thing);
self.nodes.push(SyntaxNode::error(message, "", ErrorPos::Full)); self.nodes.push(SyntaxNode::error(message, "", ErrorPos::Full));
} }
self.skip(); self.skip();
@ -1302,7 +1302,7 @@ impl<'s> Parser<'s> {
if !kind.is_error() { if !kind.is_error() {
self.nodes[offset] self.nodes[offset]
.convert_to_error(format_eco!("unexpected {}", kind.name())); .convert_to_error(eco_format!("unexpected {}", kind.name()));
} }
} }
} }