Merge pull request #3470 from topecongiro/issue-3051

Do not add a space after empty impl
This commit is contained in:
Stéphane Campinas 2019-03-25 11:04:42 +01:00 committed by GitHub
commit f910afde85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -667,9 +667,13 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>
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)),
ast::TyKind::ImplTrait(_, ref it) => {
// Empty trait is not a parser error.
it.rewrite(context, shape).map(|it_str| {
let space = if it_str.is_empty() { "" } else { " " };
format!("impl{}{}", space, it_str)
})
}
ast::TyKind::CVarArgs => Some("...".to_owned()),
ast::TyKind::Err | ast::TyKind::Typeof(..) => unreachable!(),
}

View File

@ -83,6 +83,10 @@ impl Future<Item = (), Error = SomeError> + 'a,
'c {
}
// #3051
token![impl];
token![ impl ];
// #3060
macro_rules! foo {
($foo_api: ty) => {

View File

@ -82,6 +82,10 @@ impl Future<Item = (), Error = SomeError> + 'a,
> + 'a + 'b + 'c {
}
// #3051
token![impl];
token![impl];
// #3060
macro_rules! foo {
($foo_api: ty) => {