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 @@ impl Rewrite for ast::Ty {
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 @@ pub fn do_something<'a, T: Trait1 + Trait2 + 'a>(
> + 'a + 'b + 'c {
}
// #3051
token![impl];
token![impl];
// #3060
macro_rules! foo {
($foo_api: ty) => {