Rollup merge of #46851 - petrochenkov:tospace, r=estebank
Fix whitespacing issues in pretty-printing of bounds cc https://github.com/rust-lang/rust/pull/46827#discussion_r157603277
This commit is contained in:
commit
0c29c7b1e4
6 changed files with 45 additions and 42 deletions
|
@ -408,15 +408,16 @@ impl<'a> State<'a> {
|
||||||
hir::TyTraitObject(ref bounds, ref lifetime) => {
|
hir::TyTraitObject(ref bounds, ref lifetime) => {
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for bound in bounds {
|
for bound in bounds {
|
||||||
self.nbsp()?;
|
|
||||||
if first {
|
if first {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
|
self.nbsp()?;
|
||||||
self.word_space("+")?;
|
self.word_space("+")?;
|
||||||
}
|
}
|
||||||
self.print_poly_trait_ref(bound)?;
|
self.print_poly_trait_ref(bound)?;
|
||||||
}
|
}
|
||||||
if !lifetime.is_elided() {
|
if !lifetime.is_elided() {
|
||||||
|
self.nbsp()?;
|
||||||
self.word_space("+")?;
|
self.word_space("+")?;
|
||||||
self.print_lifetime(lifetime)?;
|
self.print_lifetime(lifetime)?;
|
||||||
}
|
}
|
||||||
|
@ -764,6 +765,7 @@ impl<'a> State<'a> {
|
||||||
real_bounds.push(b.clone());
|
real_bounds.push(b.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.nbsp()?;
|
||||||
self.print_bounds("=", &real_bounds[..])?;
|
self.print_bounds("=", &real_bounds[..])?;
|
||||||
self.print_where_clause(&generics.where_clause)?;
|
self.print_where_clause(&generics.where_clause)?;
|
||||||
self.s.word(";")?;
|
self.s.word(";")?;
|
||||||
|
@ -788,6 +790,7 @@ impl<'a> State<'a> {
|
||||||
comma = true;
|
comma = true;
|
||||||
}
|
}
|
||||||
self.s.word(">")?;
|
self.s.word(">")?;
|
||||||
|
self.nbsp()?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -2016,30 +2019,29 @@ impl<'a> State<'a> {
|
||||||
self.s.word(prefix)?;
|
self.s.word(prefix)?;
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for bound in bounds {
|
for bound in bounds {
|
||||||
|
if !(first && prefix.is_empty()) {
|
||||||
self.nbsp()?;
|
self.nbsp()?;
|
||||||
|
}
|
||||||
if first {
|
if first {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
self.word_space("+")?;
|
self.word_space("+")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
match *bound {
|
match bound {
|
||||||
TraitTyParamBound(ref tref, TraitBoundModifier::None) => {
|
TraitTyParamBound(tref, modifier) => {
|
||||||
self.print_poly_trait_ref(tref)
|
if modifier == &TraitBoundModifier::Maybe {
|
||||||
}
|
|
||||||
TraitTyParamBound(ref tref, TraitBoundModifier::Maybe) => {
|
|
||||||
self.s.word("?")?;
|
self.s.word("?")?;
|
||||||
self.print_poly_trait_ref(tref)
|
|
||||||
}
|
}
|
||||||
RegionTyParamBound(ref lt) => {
|
self.print_poly_trait_ref(tref)?;
|
||||||
self.print_lifetime(lt)
|
}
|
||||||
|
RegionTyParamBound(lt) => {
|
||||||
|
self.print_lifetime(lt)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}?
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_lifetime(&mut self, lifetime: &hir::Lifetime) -> io::Result<()> {
|
pub fn print_lifetime(&mut self, lifetime: &hir::Lifetime) -> io::Result<()> {
|
||||||
|
|
|
@ -1398,6 +1398,7 @@ impl<'a> State<'a> {
|
||||||
real_bounds.push(b.clone());
|
real_bounds.push(b.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.nbsp()?;
|
||||||
self.print_bounds("=", &real_bounds[..])?;
|
self.print_bounds("=", &real_bounds[..])?;
|
||||||
self.print_where_clause(&generics.where_clause)?;
|
self.print_where_clause(&generics.where_clause)?;
|
||||||
self.s.word(";")?;
|
self.s.word(";")?;
|
||||||
|
@ -1444,6 +1445,7 @@ impl<'a> State<'a> {
|
||||||
comma = true;
|
comma = true;
|
||||||
}
|
}
|
||||||
self.s.word(">")?;
|
self.s.word(">")?;
|
||||||
|
self.nbsp()?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -2818,30 +2820,29 @@ impl<'a> State<'a> {
|
||||||
self.s.word(prefix)?;
|
self.s.word(prefix)?;
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for bound in bounds {
|
for bound in bounds {
|
||||||
|
if !(first && prefix.is_empty()) {
|
||||||
self.nbsp()?;
|
self.nbsp()?;
|
||||||
|
}
|
||||||
if first {
|
if first {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
self.word_space("+")?;
|
self.word_space("+")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
(match *bound {
|
match bound {
|
||||||
TraitTyParamBound(ref tref, TraitBoundModifier::None) => {
|
TraitTyParamBound(tref, modifier) => {
|
||||||
self.print_poly_trait_ref(tref)
|
if modifier == &TraitBoundModifier::Maybe {
|
||||||
}
|
|
||||||
TraitTyParamBound(ref tref, TraitBoundModifier::Maybe) => {
|
|
||||||
self.s.word("?")?;
|
self.s.word("?")?;
|
||||||
self.print_poly_trait_ref(tref)
|
|
||||||
}
|
}
|
||||||
RegionTyParamBound(ref lt) => {
|
self.print_poly_trait_ref(tref)?;
|
||||||
self.print_lifetime(lt)
|
}
|
||||||
|
RegionTyParamBound(lt) => {
|
||||||
|
self.print_lifetime(lt)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})?
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_lifetime(&mut self,
|
pub fn print_lifetime(&mut self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue