// and `(`/`)` have special meaning.
//
// We always try and format on one line.
-fn format_macro_args(toks: ThinTokenStream) -> Option<String> {
+// FIXME: Use multi-line when every thing does not fit on one line.
+fn format_macro_args(toks: ThinTokenStream, shape: Shape) -> Option<String> {
let mut result = String::with_capacity(128);
let mut insert_space = SpaceState::Never;
if let SpaceState::Always = insert_space {
result.push(' ');
}
- let formatted = format_macro_args(d.tts)?;
+ let formatted = format_macro_args(d.tts, shape)?;
match d.delim {
DelimToken::Paren => {
result.push_str(&format!("({})", formatted));
}
}
- Some(result)
+ if result.len() <= shape.width {
+ Some(result)
+ } else {
+ None
+ }
}
// We should insert a space if the next token is a:
/// a,
/// b,
/// c,
-// ),
+/// ),
/// }
/// ```
fn indent_macro_snippet(
return None;
}
- let mut result = format_macro_args(self.args.clone())?;
+ // 5 = " => {"
+ let mut result = format_macro_args(self.args.clone(), shape.sub_width(5)?)?;
if multi_branch_style {
result += " =>";
&ParseSess::new(FilePathMapping::empty()),
None,
);
- format_macro_args(input.into()).unwrap()
+ let shape = Shape {
+ width: 100,
+ indent: Indent::empty(),
+ offset: 0,
+ };
+ format_macro_args(input.into(), shape).unwrap()
}
#[test]
mod macro_item { struct $item ; }
}
}
+
+// #2439
+macro_rules! m {
+ (
+ $line0_xxxxxxxxxxxxxxxxx: expr,
+ $line1_xxxxxxxxxxxxxxxxx: expr,
+ $line2_xxxxxxxxxxxxxxxxx: expr,
+ $line3_xxxxxxxxxxxxxxxxx: expr,
+ ) => {};
+}
}
}
}
+
+// #2439
+macro_rules! m {
+ (
+ $line0_xxxxxxxxxxxxxxxxx: expr,
+ $line1_xxxxxxxxxxxxxxxxx: expr,
+ $line2_xxxxxxxxxxxxxxxxx: expr,
+ $line3_xxxxxxxxxxxxxxxxx: expr,
+ ) => {};
+}