summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-10-05 15:45:45 +0200
committerLaurenz <laurmaedje@gmail.com>2020-10-05 15:45:45 +0200
commitfa3e2920c0be01874ba40eebc87ed30f97cdeec7 (patch)
treed1d7d4123f10c57efbb30d07d68eb4e675c3f438 /src/layout
parent2df8b964d0e6f40451183c207a20d0273907a524 (diff)
Remove @ syntax in diagnostics macros 🗑
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/mod.rs15
-rw-r--r--src/layout/tree.rs12
2 files changed, 20 insertions, 7 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 7803c747..5e4e020e 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -13,10 +13,11 @@ pub use tree::*;
use crate::geom::{Insets, Point, Rect, RectExt, Sides, Size, SizeExt};
+use crate::diag::Diag;
use crate::eval::{PageState, State, TextState};
use crate::font::SharedFontLoader;
use crate::shaping::Shaped;
-use crate::syntax::SynTree;
+use crate::syntax::{Deco, Spanned, SynTree};
use crate::{Feedback, Pass};
/// Layout a syntax tree and return the produced layout.
@@ -98,6 +99,18 @@ pub struct LayoutContext {
pub f: Feedback,
}
+impl LayoutContext {
+ /// Add a diagnostic to the feedback.
+ pub fn diag(&mut self, diag: Spanned<Diag>) {
+ self.f.diags.push(diag);
+ }
+
+ /// Add a decoration to the feedback.
+ pub fn deco(&mut self, deco: Spanned<Deco>) {
+ self.f.decos.push(deco);
+ }
+}
+
/// The constraints for layouting a single node.
#[derive(Debug, Clone)]
pub struct LayoutConstraints {
diff --git a/src/layout/tree.rs b/src/layout/tree.rs
index c5b6609b..435b7109 100644
--- a/src/layout/tree.rs
+++ b/src/layout/tree.rs
@@ -198,10 +198,10 @@ impl<'a> TreeLayouter<'a> {
if self.constraints.root {
self.layouter.finish_space(true)
} else {
- error!(
- @self.ctx.f, span,
+ self.ctx.diag(error!(
+ span,
"page break can only be issued from root context",
- );
+ ));
}
}
@@ -224,10 +224,10 @@ impl<'a> TreeLayouter<'a> {
self.constraints.base = space.usable();
self.layouter.set_spaces(vec![space], true);
} else {
- error!(
- @self.ctx.f, span,
+ self.ctx.diag(error!(
+ span,
"page style can only be changed from root context",
- );
+ ));
}
}