summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-01 11:27:10 +0100
committerLaurenz <laurmaedje@gmail.com>2023-03-01 11:27:10 +0100
commitab841188e3d2687ee8f436336e6fde337985a83e (patch)
tree23504e66ea84e62e4354fa76ac199fc1ff658e8a /src
parent8f246406c61f3710fa6659e85d7c715b001ea05d (diff)
Bump `ecow`
Diffstat (limited to 'src')
-rw-r--r--src/diag.rs6
-rw-r--r--src/export/pdf/font.rs4
-rw-r--r--src/export/pdf/page.rs10
-rw-r--r--src/ide/complete.rs16
-rw-r--r--src/model/array.rs8
-rw-r--r--src/model/dict.rs8
-rw-r--r--src/model/module.rs4
-rw-r--r--src/model/ops.rs6
-rw-r--r--src/model/str.rs10
-rw-r--r--src/model/value.rs12
-rw-r--r--src/syntax/lexer.rs6
-rw-r--r--src/syntax/parser.rs14
12 files changed, 52 insertions, 52 deletions
diff --git a/src/diag.rs b/src/diag.rs
index 2742a872..eca6827c 100644
--- a/src/diag.rs
+++ b/src/diag.rs
@@ -38,14 +38,14 @@ macro_rules! __error {
};
($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)]
pub use crate::__error as error;
#[doc(hidden)]
-pub use ecow::format_eco;
+pub use ecow::eco_format;
/// A result that can carry multiple source errors.
pub type SourceResult<T> = Result<T, Box<Vec<SourceError>>>;
@@ -268,7 +268,7 @@ impl From<FromUtf8Error> for FileError {
impl From<FileError> for EcoString {
fn from(error: FileError) -> Self {
- format_eco!("{error}")
+ eco_format!("{error}")
}
}
diff --git a/src/export/pdf/font.rs b/src/export/pdf/font.rs
index 53391105..60e7f0bb 100644
--- a/src/export/pdf/font.rs
+++ b/src/export/pdf/font.rs
@@ -1,6 +1,6 @@
use std::collections::BTreeMap;
-use ecow::format_eco;
+use ecow::eco_format;
use pdf_writer::types::{CidFontType, FontFlags, SystemInfo, UnicodeCmap};
use pdf_writer::{Filter, Finish, Name, Rect, Str};
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)
.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 cmap_name = Name(b"Custom");
let system_info = SystemInfo {
diff --git a/src/export/pdf/page.rs b/src/export/pdf/page.rs
index 7daf9d5e..35cb6441 100644
--- a/src/export/pdf/page.rs
+++ b/src/export/pdf/page.rs
@@ -1,4 +1,4 @@
-use ecow::format_eco;
+use ecow::eco_format;
use pdf_writer::types::{ActionType, AnnotationType, ColorSpaceOperand};
use pdf_writer::writers::ColorSpace;
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();
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);
}
@@ -88,7 +88,7 @@ pub fn write_page_tree(ctx: &mut PdfContext) {
let mut images = resources.x_objects();
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);
}
@@ -201,7 +201,7 @@ impl PageContext<'_, '_> {
fn set_font(&mut self, font: &Font, size: Abs) {
if self.state.font.as_ref().map(|(f, s)| (f, *s)) != Some((font, size)) {
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.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.
fn write_image(ctx: &mut PageContext, x: f32, y: f32, image: &Image, size: Size) {
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 h = size.y.to_f32();
ctx.content.save_state();
diff --git a/src/ide/complete.rs b/src/ide/complete.rs
index 97427130..fe1afe66 100644
--- a/src/ide/complete.rs
+++ b/src/ide/complete.rs
@@ -1,6 +1,6 @@
use std::collections::{BTreeSet, HashSet};
-use ecow::{format_eco, EcoString};
+use ecow::{eco_format, EcoString};
use if_chain::if_chain;
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,
label: method.into(),
apply: Some(if args {
- format_eco!("{method}(${{}})")
+ eco_format!("{method}(${{}})")
} else {
- format_eco!("{method}()${{}}")
+ eco_format!("{method}()${{}}")
}),
detail: None,
})
@@ -612,7 +612,7 @@ fn param_completions(
ctx.completions.push(Completion {
kind: CompletionKind::Param,
label: param.name.into(),
- apply: Some(format_eco!("{}: ${{}}", param.name)),
+ apply: Some(eco_format!("{}: ${{}}", param.name)),
detail: Some(plain_docs_sentence(param.docs).into()),
});
}
@@ -872,7 +872,7 @@ impl<'a> CompletionContext<'a> {
fn enrich(&mut self, prefix: &str, suffix: &str) {
for Completion { label, apply, .. } in &mut self.completions {
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(_)) {
- apply = Some(format_eco!("{label}(${{}})"));
+ apply = Some(eco_format!("{label}(${{}})"));
}
self.completions.push(Completion {
@@ -998,8 +998,8 @@ impl<'a> CompletionContext<'a> {
self.completions.push(Completion {
kind: CompletionKind::Syntax,
label: (*ty).into(),
- apply: Some(format_eco!("${{{ty}}}")),
- detail: Some(format_eco!("A value of type {ty}.")),
+ apply: Some(eco_format!("${{{ty}}}")),
+ detail: Some(eco_format!("A value of type {ty}.")),
});
self.scope_completions(false, |value| value.type_name() == *ty);
}
diff --git a/src/model/array.rs b/src/model/array.rs
index 0a84072d..746763ab 100644
--- a/src/model/array.rs
+++ b/src/model/array.rs
@@ -2,7 +2,7 @@ use std::cmp::Ordering;
use std::fmt::{self, Debug, Formatter, Write};
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 crate::diag::{bail, At, SourceResult, StrResult};
@@ -293,7 +293,7 @@ impl Array {
vec.make_mut().sort_by(|a, b| {
a.partial_cmp(b).unwrap_or_else(|| {
if result.is_ok() {
- result = Err(format_eco!(
+ result = Err(eco_format!(
"cannot order {} and {}",
a.type_name(),
b.type_name(),
@@ -335,7 +335,7 @@ impl Array {
/// The out of bounds access error message.
#[cold]
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.
@@ -389,7 +389,7 @@ impl FromIterator<Value> for Array {
impl IntoIterator for Array {
type Item = Value;
- type IntoIter = ecow::IntoIter<Value>;
+ type IntoIter = ecow::vec::IntoIter<Value>;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
diff --git a/src/model/dict.rs b/src/model/dict.rs
index b6198b2c..50a2275f 100644
--- a/src/model/dict.rs
+++ b/src/model/dict.rs
@@ -3,7 +3,7 @@ use std::fmt::{self, Debug, Formatter, Write};
use std::ops::{Add, AddAssign};
use std::sync::Arc;
-use ecow::{format_eco, EcoString};
+use ecow::{eco_format, EcoString};
use super::{array, Array, Str, Value};
use crate::diag::StrResult;
@@ -66,7 +66,7 @@ impl Dict {
pub fn take(&mut self, key: &str) -> StrResult<Value> {
Arc::make_mut(&mut self.0)
.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.
@@ -123,7 +123,7 @@ impl Dict {
/// Return an "unexpected key" error if there is any remaining pair.
pub fn finish(&self, expected: &[&str]) -> StrResult<()> {
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 ");
crate::diag::comma_list(&mut msg, &parts, "and");
return Err(msg.into());
@@ -135,7 +135,7 @@ impl Dict {
/// The missing key access error message.
#[cold]
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 {
diff --git a/src/model/module.rs b/src/model/module.rs
index 97c060e3..e911d859 100644
--- a/src/model/module.rs
+++ b/src/model/module.rs
@@ -1,7 +1,7 @@
use std::fmt::{self, Debug, Formatter};
use std::sync::Arc;
-use ecow::{format_eco, EcoString};
+use ecow::{eco_format, EcoString};
use super::{Content, Scope, Value};
use crate::diag::StrResult;
@@ -61,7 +61,7 @@ impl Module {
/// Try to access a definition in the module.
pub fn get(&self, name: &str) -> StrResult<&Value> {
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())
})
}
diff --git a/src/model/ops.rs b/src/model/ops.rs
index be7892f9..52b9b06a 100644
--- a/src/model/ops.rs
+++ b/src/model/ops.rs
@@ -2,7 +2,7 @@
use std::cmp::Ordering;
-use ecow::format_eco;
+use ecow::eco_format;
use super::{format_str, Regex, Value};
use crate::diag::StrResult;
@@ -12,7 +12,7 @@ use Value::*;
/// Bail with a type mismatch error.
macro_rules! mismatch {
($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>())
{
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() {
diff --git a/src/model/str.rs b/src/model/str.rs
index 3eee9506..5fcc1d05 100644
--- a/src/model/str.rs
+++ b/src/model/str.rs
@@ -15,14 +15,14 @@ use crate::geom::GenAlign;
#[doc(hidden)]
macro_rules! __format_str {
($($tts:tt)*) => {{
- $crate::model::Str::from($crate::model::format_eco!($($tts)*))
+ $crate::model::Str::from($crate::model::eco_format!($($tts)*))
}};
}
#[doc(inline)]
pub use crate::__format_str as format_str;
#[doc(hidden)]
-pub use ecow::format_eco;
+pub use ecow::eco_format;
/// An immutable reference counted string.
#[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
@@ -297,13 +297,13 @@ impl Str {
/// The out of bounds access error message.
#[cold]
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.
#[cold]
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.
@@ -449,7 +449,7 @@ pub struct Regex(regex::Regex);
impl Regex {
/// Create a new regular expression.
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}"))
}
}
diff --git a/src/model/value.rs b/src/model/value.rs
index 5c0ab618..f6ab95de 100644
--- a/src/model/value.rs
+++ b/src/model/value.rs
@@ -4,7 +4,7 @@ use std::fmt::{self, Debug, Formatter};
use std::hash::{Hash, Hasher};
use std::sync::Arc;
-use ecow::{format_eco, EcoString};
+use ecow::{eco_format, EcoString};
use siphasher::sip128::{Hasher128, SipHasher};
use super::{
@@ -122,9 +122,9 @@ impl Value {
Self::Dict(dict) => dict.at(&field).cloned(),
Self::Content(content) => content
.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(),
- 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 {
match self {
Self::None => Content::empty(),
- Self::Int(v) => item!(text)(format_eco!("{}", v)),
- Self::Float(v) => item!(text)(format_eco!("{}", v)),
+ Self::Int(v) => item!(text)(eco_format!("{}", v)),
+ Self::Float(v) => item!(text)(eco_format!("{}", v)),
Self::Str(v) => item!(text)(v.into()),
Self::Symbol(v) => item!(text)(v.get().into()),
Self::Content(v) => v,
@@ -402,7 +402,7 @@ macro_rules! primitive {
match value {
Value::$variant(v) => Ok(v),
$(Value::$other$(($binding))? => Ok($out),)*
- v => Err(format_eco!(
+ v => Err(eco_format!(
"expected {}, found {}",
Self::TYPE_NAME,
v.type_name(),
diff --git a/src/syntax/lexer.rs b/src/syntax/lexer.rs
index bd168f0a..31608d40 100644
--- a/src/syntax/lexer.rs
+++ b/src/syntax/lexer.rs
@@ -1,4 +1,4 @@
-use ecow::{format_eco, EcoString};
+use ecow::{eco_format, EcoString};
use unicode_segmentation::UnicodeSegmentation;
use unicode_xid::UnicodeXID;
use unscanny::Scanner;
@@ -254,9 +254,9 @@ impl Lexer<'_> {
let remaining = backticks - found;
let noun = if remaining == 1 { "backtick" } else { "backticks" };
return self.error_at_end(if found == 0 {
- format_eco!("expected {} {}", remaining, noun)
+ eco_format!("expected {} {}", remaining, noun)
} else {
- format_eco!("expected {} more {}", remaining, noun)
+ eco_format!("expected {} more {}", remaining, noun)
});
}
diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs
index 483a076e..b4321dbe 100644
--- a/src/syntax/parser.rs
+++ b/src/syntax/parser.rs
@@ -1,7 +1,7 @@
use std::collections::HashSet;
use std::ops::Range;
-use ecow::{format_eco, EcoString};
+use ecow::{eco_format, EcoString};
use unicode_math_class::MathClass;
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) {
let kind = child.kind();
if kind == SyntaxKind::Named || kind == SyntaxKind::Keyed {
- child.convert_to_error(format_eco!(
+ child.convert_to_error(eco_format!(
"expected expression, found {}",
kind.name()
));
@@ -998,7 +998,7 @@ fn validate_dict(p: &mut Parser, m: Marker) {
| SyntaxKind::Comma
| SyntaxKind::Colon => {}
kind => {
- child.convert_to_error(format_eco!(
+ child.convert_to_error(eco_format!(
"expected named or keyed pair, found {}",
kind.name()
));
@@ -1026,7 +1026,7 @@ fn validate_params(p: &mut Parser, m: Marker) {
SyntaxKind::Spread => {
let Some(within) = child.children_mut().last_mut() else { continue };
if within.kind() != SyntaxKind::Ident {
- within.convert_to_error(format_eco!(
+ within.convert_to_error(eco_format!(
"expected identifier, found {}",
within.kind().name(),
));
@@ -1035,7 +1035,7 @@ fn validate_params(p: &mut Parser, m: Marker) {
}
SyntaxKind::LeftParen | SyntaxKind::RightParen | SyntaxKind::Comma => {}
kind => {
- child.convert_to_error(format_eco!(
+ child.convert_to_error(eco_format!(
"expected identifier, named pair or argument sink, found {}",
kind.name()
));
@@ -1278,7 +1278,7 @@ impl<'s> Parser<'s> {
.last()
.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.skip();
@@ -1302,7 +1302,7 @@ impl<'s> Parser<'s> {
if !kind.is_error() {
self.nodes[offset]
- .convert_to_error(format_eco!("unexpected {}", kind.name()));
+ .convert_to_error(eco_format!("unexpected {}", kind.name()));
}
}
}