set of clippy changes

This commit is contained in:
Maximilian Roos 2018-08-28 00:33:51 -04:00
parent c4d845f998
commit df72570b58
No known key found for this signature in database
GPG Key ID: 3232F28BEDA66FCD
7 changed files with 19 additions and 21 deletions

View File

@ -525,7 +525,7 @@ fn rewrite_comment_inner(
const RUSTFMT_CUSTOM_COMMENT_PREFIX: &str = "//#### ";
fn hide_sharp_behind_comment<'a>(s: &'a str) -> Cow<'a, str> {
fn hide_sharp_behind_comment(s: &str) -> Cow<str> {
if s.trim_left().starts_with("# ") {
Cow::from(format!("{}{}", RUSTFMT_CUSTOM_COMMENT_PREFIX, s))
} else {
@ -823,8 +823,8 @@ pub enum FullCodeCharKind {
}
impl FullCodeCharKind {
pub fn is_comment(&self) -> bool {
match *self {
pub fn is_comment(self) -> bool {
match self {
FullCodeCharKind::StartComment
| FullCodeCharKind::InComment
| FullCodeCharKind::EndComment => true,
@ -832,11 +832,11 @@ impl FullCodeCharKind {
}
}
pub fn is_string(&self) -> bool {
*self == FullCodeCharKind::InString
pub fn is_string(self) -> bool {
self == FullCodeCharKind::InString
}
fn to_codecharkind(&self) -> CodeCharKind {
fn to_codecharkind(self) -> CodeCharKind {
if self.is_comment() {
CodeCharKind::Comment
} else {
@ -987,9 +987,7 @@ impl<'a> Iterator for LineClasses<'a> {
type Item = (FullCodeCharKind, String);
fn next(&mut self) -> Option<Self::Item> {
if self.base.peek().is_none() {
return None;
}
self.base.peek()?;
let mut line = String::new();
@ -1174,7 +1172,7 @@ pub fn filter_normal_code(code: &str) -> String {
}
_ => (),
});
if !code.ends_with("\n") && buffer.ends_with("\n") {
if !code.ends_with('\n') && buffer.ends_with('\n') {
buffer.pop();
}
buffer

View File

@ -175,11 +175,11 @@ macro_rules! create_config {
}
)+
pub fn set<'a>(&'a mut self) -> ConfigSetter<'a> {
pub fn set(&mut self) -> ConfigSetter {
ConfigSetter(self)
}
pub fn was_set<'a>(&'a self) -> ConfigWasSet<'a> {
pub fn was_set(&self) -> ConfigWasSet {
ConfigWasSet(self)
}

View File

@ -80,12 +80,12 @@ pub enum SeparatorPlace {
impl_enum_serialize_and_deserialize!(SeparatorPlace, Front, Back);
impl SeparatorPlace {
pub fn is_front(&self) -> bool {
*self == SeparatorPlace::Front
pub fn is_front(self) -> bool {
self == SeparatorPlace::Front
}
pub fn is_back(&self) -> bool {
*self == SeparatorPlace::Back
pub fn is_back(self) -> bool {
self == SeparatorPlace::Back
}
pub fn from_tactic(

View File

@ -209,8 +209,8 @@ pub enum Separator {
}
impl Separator {
pub fn len(&self) -> usize {
match *self {
pub fn len(self) -> usize {
match self {
// 2 = `, `
Separator::Comma => 2,
// 3 = ` | `

View File

@ -289,7 +289,7 @@ fn rewrite_match_pattern(
guard,
shape,
trimmed_last_line_width(&pats_str),
pats_str.contains("\n"),
pats_str.contains('\n'),
)?;
Some(format!("{}{}", pats_str, guard_str))

View File

@ -223,7 +223,7 @@ impl<'a, T: 'a + Rewrite + ToExpr + Spanned> Context<'a, T> {
// 1 = "("
let combine_arg_with_callee = self.items.len() == 1
&& self.items[0].to_expr().is_some()
&& self.ident.len() + 1 <= self.context.config.tab_spaces();
&& self.ident.len() < self.context.config.tab_spaces();
let overflow_last = combine_arg_with_callee || can_be_overflowed(self.context, self.items);
// Replace the last item with its first line to see if it fits with

View File

@ -520,7 +520,7 @@ impl Rewrite for ast::GenericBounds {
}
let span = mk_sp(self.get(0)?.span().lo(), self.last()?.span().hi());
let has_paren = context.snippet(span).starts_with("(");
let has_paren = context.snippet(span).starts_with('(');
let bounds_shape = if has_paren {
shape.offset_left(1)?.sub_width(1)?
} else {