diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-12-28 13:58:03 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-12-28 13:58:03 +0100 |
| commit | 0c08022ffa5b08b16816ea9bf1e0df5cc8ad9159 (patch) | |
| tree | 21ba6c593700dc352b42046343d4e26ab6efc592 /crates/typst-macros | |
| parent | 67ead94cc25d6663dc6afaebb6c7e781ba9c26bb (diff) | |
Remove uses of `EcoString::inline`
EcoString::inline can produce runtime panics if things are changed later. It should only be used if really necessary (because of const context)
Diffstat (limited to 'crates/typst-macros')
| -rw-r--r-- | crates/typst-macros/src/elem.rs | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/crates/typst-macros/src/elem.rs b/crates/typst-macros/src/elem.rs index d237ba72..34c54737 100644 --- a/crates/typst-macros/src/elem.rs +++ b/crates/typst-macros/src/elem.rs @@ -837,13 +837,7 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream { let field_dict = element.inherent_fields().clone().map(|field| { let name = &field.name; let field_ident = &field.ident; - - let field_call = if name.len() > 15 { - quote! { ::ecow::EcoString::from(#name).into() } - } else { - quote! { ::ecow::EcoString::inline(#name).into() } - }; - + let field_call = quote! { ::ecow::EcoString::from(#name).into() }; quote! { fields.insert( #field_call, @@ -860,13 +854,7 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream { .map(|field| { let name = &field.name; let field_ident = &field.ident; - - let field_call = if name.len() > 15 { - quote! { ::ecow::EcoString::from(#name).into() } - } else { - quote! { ::ecow::EcoString::inline(#name).into() } - }; - + let field_call = quote! { ::ecow::EcoString::from(#name).into() }; if field.synthesized && field.default.is_some() { quote! { fields.insert( @@ -926,7 +914,7 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream { quote! { if let Some(label) = self.label() { fields.insert( - ::ecow::EcoString::inline("label").into(), + "label".into(), #foundations::IntoValue::into_value(label) ); } |
