Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1a6f215

Browse files
authored
Merge pull request rust-lang#2975 from max-sixty/clippy
Some clippy changes
2 parents b784f23 + df72570 commit 1a6f215

File tree

7 files changed

+19
-21
lines changed

7 files changed

+19
-21
lines changed

src/comment.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ fn rewrite_comment_inner(
525525

526526
const RUSTFMT_CUSTOM_COMMENT_PREFIX: &str = "//#### ";
527527

528-
fn hide_sharp_behind_comment<'a>(s: &'a str) -> Cow<'a, str> {
528+
fn hide_sharp_behind_comment(s: &str) -> Cow<str> {
529529
if s.trim_left().starts_with("# ") {
530530
Cow::from(format!("{}{}", RUSTFMT_CUSTOM_COMMENT_PREFIX, s))
531531
} else {
@@ -823,20 +823,20 @@ pub enum FullCodeCharKind {
823823
}
824824

825825
impl FullCodeCharKind {
826-
pub fn is_comment(&self) -> bool {
827-
match *self {
826+
pub fn is_comment(self) -> bool {
827+
match self {
828828
FullCodeCharKind::StartComment
829829
| FullCodeCharKind::InComment
830830
| FullCodeCharKind::EndComment => true,
831831
_ => false,
832832
}
833833
}
834834

835-
pub fn is_string(&self) -> bool {
836-
*self == FullCodeCharKind::InString
835+
pub fn is_string(self) -> bool {
836+
self == FullCodeCharKind::InString
837837
}
838838

839-
fn to_codecharkind(&self) -> CodeCharKind {
839+
fn to_codecharkind(self) -> CodeCharKind {
840840
if self.is_comment() {
841841
CodeCharKind::Comment
842842
} else {
@@ -987,9 +987,7 @@ impl<'a> Iterator for LineClasses<'a> {
987987
type Item = (FullCodeCharKind, String);
988988

989989
fn next(&mut self) -> Option<Self::Item> {
990-
if self.base.peek().is_none() {
991-
return None;
992-
}
990+
self.base.peek()?;
993991

994992
let mut line = String::new();
995993

@@ -1174,7 +1172,7 @@ pub fn filter_normal_code(code: &str) -> String {
11741172
}
11751173
_ => (),
11761174
});
1177-
if !code.ends_with("\n") && buffer.ends_with("\n") {
1175+
if !code.ends_with('\n') && buffer.ends_with('\n') {
11781176
buffer.pop();
11791177
}
11801178
buffer

src/config/config_type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ macro_rules! create_config {
175175
}
176176
)+
177177

178-
pub fn set<'a>(&'a mut self) -> ConfigSetter<'a> {
178+
pub fn set(&mut self) -> ConfigSetter {
179179
ConfigSetter(self)
180180
}
181181

182-
pub fn was_set<'a>(&'a self) -> ConfigWasSet<'a> {
182+
pub fn was_set(&self) -> ConfigWasSet {
183183
ConfigWasSet(self)
184184
}
185185

src/config/lists.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ pub enum SeparatorPlace {
8080
impl_enum_serialize_and_deserialize!(SeparatorPlace, Front, Back);
8181

8282
impl SeparatorPlace {
83-
pub fn is_front(&self) -> bool {
84-
*self == SeparatorPlace::Front
83+
pub fn is_front(self) -> bool {
84+
self == SeparatorPlace::Front
8585
}
8686

87-
pub fn is_back(&self) -> bool {
88-
*self == SeparatorPlace::Back
87+
pub fn is_back(self) -> bool {
88+
self == SeparatorPlace::Back
8989
}
9090

9191
pub fn from_tactic(

src/lists.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ pub enum Separator {
209209
}
210210

211211
impl Separator {
212-
pub fn len(&self) -> usize {
213-
match *self {
212+
pub fn len(self) -> usize {
213+
match self {
214214
// 2 = `, `
215215
Separator::Comma => 2,
216216
// 3 = ` | `

src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ fn rewrite_match_pattern(
289289
guard,
290290
shape,
291291
trimmed_last_line_width(&pats_str),
292-
pats_str.contains("\n"),
292+
pats_str.contains('\n'),
293293
)?;
294294

295295
Some(format!("{}{}", pats_str, guard_str))

src/overflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<'a, T: 'a + Rewrite + ToExpr + Spanned> Context<'a, T> {
223223
// 1 = "("
224224
let combine_arg_with_callee = self.items.len() == 1
225225
&& self.items[0].to_expr().is_some()
226-
&& self.ident.len() + 1 <= self.context.config.tab_spaces();
226+
&& self.ident.len() < self.context.config.tab_spaces();
227227
let overflow_last = combine_arg_with_callee || can_be_overflowed(self.context, self.items);
228228

229229
// Replace the last item with its first line to see if it fits with

src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ impl Rewrite for ast::GenericBounds {
520520
}
521521

522522
let span = mk_sp(self.get(0)?.span().lo(), self.last()?.span().hi());
523-
let has_paren = context.snippet(span).starts_with("(");
523+
let has_paren = context.snippet(span).starts_with('(');
524524
let bounds_shape = if has_paren {
525525
shape.offset_left(1)?.sub_width(1)?
526526
} else {

0 commit comments

Comments
 (0)