diff options
| author | Sébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com> | 2024-09-02 15:33:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-02 13:33:43 +0000 |
| commit | 1ccfaba88eac41211a74b334fe0401cc12e72969 (patch) | |
| tree | 6b57db055546617be7934459f0c053f70abf33af /crates | |
| parent | 1997db00f3908967dc381d9a84c0b246700e7112 (diff) | |
Better hint for non-zero em length (#4873)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst/src/layout/length.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/crates/typst/src/layout/length.rs b/crates/typst/src/layout/length.rs index 8c883a6a..5e352f13 100644 --- a/crates/typst/src/layout/length.rs +++ b/crates/typst/src/layout/length.rs @@ -5,7 +5,7 @@ use std::ops::{Add, Div, Mul, Neg}; use comemo::Tracked; use ecow::{eco_format, EcoString}; -use crate::diag::{At, Hint, HintedStrResult, SourceResult}; +use crate::diag::{bail, HintedStrResult, SourceResult}; use crate::foundations::{func, scope, ty, Context, Fold, Repr, Resolve, StyleChain}; use crate::layout::{Abs, Em}; use crate::syntax::Span; @@ -81,12 +81,15 @@ impl Length { if self.em == Em::zero() { return Ok(()); } - Err(eco_format!( + + bail!( + span, "cannot convert a length with non-zero em units (`{}`) to {unit}", - self.repr() - )) - .hint(eco_format!("use `length.abs.{unit}()` instead to ignore its em component")) - .at(span) + self.repr(); + hint: "use `length.to-absolute()` to resolve its em component \ + (requires context)"; + hint: "or use `length.abs.{unit}()` instead to ignore its em component" + ) } } |
