Skip to content

Commit c4c3f5b

Browse files
authored
Merge pull request #2238 from topecongiro/issue-1209
Format a macro in the type position
2 parents 38d2fb4 + 289b5f4 commit c4c3f5b

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/types.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use expr::{rewrite_pair, rewrite_tuple, rewrite_unary_prefix, wrap_args_with_par
2323
use items::{format_generics_item_list, generics_shape_from_config};
2424
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListTactic, Separator,
2525
SeparatorPlace, SeparatorTactic};
26+
use macros::{rewrite_macro, MacroPosition};
2627
use rewrite::{Rewrite, RewriteContext};
2728
use shape::Shape;
2829
use utils::{colon_spaces, extra_offset, first_line_width, format_abi, format_mutability,
@@ -726,7 +727,9 @@ impl Rewrite for ast::Ty {
726727
}
727728
ast::TyKind::BareFn(ref bare_fn) => rewrite_bare_fn(bare_fn, self.span, context, shape),
728729
ast::TyKind::Never => Some(String::from("!")),
729-
ast::TyKind::Mac(..) => None,
730+
ast::TyKind::Mac(ref mac) => {
731+
rewrite_macro(mac, None, context, shape, MacroPosition::Expression)
732+
}
730733
ast::TyKind::ImplicitSelf => Some(String::from("")),
731734
ast::TyKind::ImplTrait(ref it) => it.rewrite(context, shape)
732735
.map(|it_str| format!("impl {}", it_str)),

tests/source/macros.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,9 @@ fn special_case_macros() {
224224
// assert!
225225
assert!(result, "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')", result, input, expected);
226226
}
227+
228+
// #1209
229+
impl Foo {
230+
/// foo
231+
pub fn foo(&self) -> Bar<foo!( )> {}
232+
}

tests/target/macros.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn main() {
121121
20, 21, 22);
122122

123123
// #1092
124-
chain!(input, a:take!(max_size), || []);
124+
chain!(input, a: take!(max_size), || []);
125125
}
126126

127127
impl X {
@@ -284,3 +284,9 @@ fn special_case_macros() {
284284
result, input, expected
285285
);
286286
}
287+
288+
// #1209
289+
impl Foo {
290+
/// foo
291+
pub fn foo(&self) -> Bar<foo!()> {}
292+
}

0 commit comments

Comments
 (0)