Merge pull request #2238 from topecongiro/issue-1209

Format a macro in the type position
This commit is contained in:
Nick Cameron 2017-12-05 16:55:31 +13:00 committed by GitHub
commit c4c3f5ba1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -23,6 +23,7 @@ use expr::{rewrite_pair, rewrite_tuple, rewrite_unary_prefix, wrap_args_with_par
use items::{format_generics_item_list, generics_shape_from_config};
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListTactic, Separator,
SeparatorPlace, SeparatorTactic};
use macros::{rewrite_macro, MacroPosition};
use rewrite::{Rewrite, RewriteContext};
use shape::Shape;
use utils::{colon_spaces, extra_offset, first_line_width, format_abi, format_mutability,
@ -726,7 +727,9 @@ impl Rewrite for ast::Ty {
}
ast::TyKind::BareFn(ref bare_fn) => rewrite_bare_fn(bare_fn, self.span, context, shape),
ast::TyKind::Never => Some(String::from("!")),
ast::TyKind::Mac(..) => None,
ast::TyKind::Mac(ref mac) => {
rewrite_macro(mac, None, context, shape, MacroPosition::Expression)
}
ast::TyKind::ImplicitSelf => Some(String::from("")),
ast::TyKind::ImplTrait(ref it) => it.rewrite(context, shape)
.map(|it_str| format!("impl {}", it_str)),

View File

@ -224,3 +224,9 @@ fn special_case_macros() {
// assert!
assert!(result, "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", result, input, expected);
}
// #1209
impl Foo {
/// foo
pub fn foo(&self) -> Bar<foo!( )> {}
}

View File

@ -121,7 +121,7 @@ fn main() {
20, 21, 22);
// #1092
chain!(input, a:take!(max_size), || []);
chain!(input, a: take!(max_size), || []);
}
impl X {
@ -284,3 +284,9 @@ fn special_case_macros() {
result, input, expected
);
}
// #1209
impl Foo {
/// foo
pub fn foo(&self) -> Bar<foo!()> {}
}