Skip to content

Commit 4dc935f

Browse files
committed
update macro rewrite functions to return RewriteResult
1 parent 4489061 commit 4dc935f

File tree

7 files changed

+198
-110
lines changed

7 files changed

+198
-110
lines changed

src/expr.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,16 @@ pub(crate) fn format_expr(
243243
| ast::ExprKind::MethodCall(..)
244244
| ast::ExprKind::Await(_, _) => rewrite_chain(expr, context, shape).ok(),
245245
ast::ExprKind::MacCall(ref mac) => {
246-
rewrite_macro(mac, None, context, shape, MacroPosition::Expression).or_else(|| {
247-
wrap_str(
248-
context.snippet(expr.span).to_owned(),
249-
context.config.max_width(),
250-
shape,
251-
)
252-
})
246+
rewrite_macro(mac, None, context, shape, MacroPosition::Expression)
247+
.or_else(|_| {
248+
wrap_str(
249+
context.snippet(expr.span).to_owned(),
250+
context.config.max_width(),
251+
shape,
252+
)
253+
.max_width_error(shape.width, expr.span)
254+
})
255+
.ok()
253256
}
254257
ast::ExprKind::Ret(None) => Some("return".to_owned()),
255258
ast::ExprKind::Ret(Some(ref expr)) => {

src/items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3427,7 +3427,7 @@ impl Rewrite for ast::ForeignItem {
34273427
rewrite_type_alias(ty_alias, context, shape.indent, kind, span)
34283428
}
34293429
ast::ForeignItemKind::MacCall(ref mac) => {
3430-
rewrite_macro(mac, None, context, shape, MacroPosition::Item)
3430+
rewrite_macro(mac, None, context, shape, MacroPosition::Item).ok()
34313431
}
34323432
}?;
34333433

0 commit comments

Comments
 (0)