mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 05:56:56 +00:00
Format source codes
This commit is contained in:
parent
a5138b1676
commit
8a6e9f689b
16
src/items.rs
16
src/items.rs
@ -684,13 +684,15 @@ fn format_impl_ref_and_type(
|
||||
item: &ast::Item,
|
||||
offset: Indent,
|
||||
) -> Option<String> {
|
||||
if let ast::ItemKind::Impl(unsafety,
|
||||
polarity,
|
||||
_,
|
||||
ref generics,
|
||||
ref trait_ref,
|
||||
ref self_ty,
|
||||
_) = item.node
|
||||
if let ast::ItemKind::Impl(
|
||||
unsafety,
|
||||
polarity,
|
||||
_,
|
||||
ref generics,
|
||||
ref trait_ref,
|
||||
ref self_ty,
|
||||
_,
|
||||
) = item.node
|
||||
{
|
||||
let mut result = String::new();
|
||||
|
||||
|
26
src/types.rs
26
src/types.rs
@ -371,11 +371,11 @@ impl Rewrite for ast::WherePredicate {
|
||||
// TODO: dead spans?
|
||||
let result = match *self {
|
||||
ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate {
|
||||
ref bound_lifetimes,
|
||||
ref bounded_ty,
|
||||
ref bounds,
|
||||
..
|
||||
}) => {
|
||||
ref bound_lifetimes,
|
||||
ref bounded_ty,
|
||||
ref bounds,
|
||||
..
|
||||
}) => {
|
||||
let type_str = try_opt!(bounded_ty.rewrite(context, shape));
|
||||
|
||||
let colon = type_bound_colon(context);
|
||||
@ -428,10 +428,10 @@ impl Rewrite for ast::WherePredicate {
|
||||
}
|
||||
}
|
||||
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
|
||||
ref lifetime,
|
||||
ref bounds,
|
||||
..
|
||||
}) => {
|
||||
ref lifetime,
|
||||
ref bounds,
|
||||
..
|
||||
}) => {
|
||||
try_opt!(rewrite_bounded_lifetime(
|
||||
lifetime,
|
||||
bounds.iter(),
|
||||
@ -440,10 +440,10 @@ impl Rewrite for ast::WherePredicate {
|
||||
))
|
||||
}
|
||||
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate {
|
||||
ref lhs_ty,
|
||||
ref rhs_ty,
|
||||
..
|
||||
}) => {
|
||||
ref lhs_ty,
|
||||
ref rhs_ty,
|
||||
..
|
||||
}) => {
|
||||
let lhs_ty_str = try_opt!(lhs_ty.rewrite(context, shape));
|
||||
// 3 = " = ".len()
|
||||
let used_width = 3 + lhs_ty_str.len();
|
||||
|
@ -99,6 +99,7 @@ pub fn last_line_width(s: &str) -> usize {
|
||||
None => s.len(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn trimmed_last_line_width(s: &str) -> usize {
|
||||
match s.rfind('\n') {
|
||||
|
Loading…
Reference in New Issue
Block a user