Skip to content

Commit

Permalink
Use single-char patter on {ends,starts}_with and remove clone on copy…
Browse files Browse the repository at this point in the history
… type.

These were introduced since I last fixed most of these occurences. (clippy::clone_on_copy, clippy::single_char_pattern)
  • Loading branch information
matthiaskrgr committed Mar 4, 2020
1 parent d8d2004 commit 80ed505
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/librustc_errors/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ impl Registry {
if !self.long_descriptions.contains_key(code) {
return Err(InvalidErrorCode);
}
Ok(self.long_descriptions.get(code).unwrap().clone())
Ok(*self.long_descriptions.get(code).unwrap())
}
}
6 changes: 3 additions & 3 deletions src/librustc_resolve/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
for param in params {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(param.span)
{
if snippet.starts_with("&") && !snippet.starts_with("&'") {
if snippet.starts_with('&') && !snippet.starts_with("&'") {
introduce_suggestion
.push((param.span, format!("&'a {}", &snippet[1..])));
} else if snippet.starts_with("&'_ ") {
Expand Down Expand Up @@ -1118,7 +1118,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
(1, Some(name), Some("'_")) => {
suggest_existing(err, name.to_string());
}
(1, Some(name), Some(snippet)) if !snippet.ends_with(">") => {
(1, Some(name), Some(snippet)) if !snippet.ends_with('>') => {
suggest_existing(err, format!("{}<{}>", snippet, name));
}
(0, _, Some("&")) => {
Expand All @@ -1127,7 +1127,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
(0, _, Some("'_")) => {
suggest_new(err, "'a");
}
(0, _, Some(snippet)) if !snippet.ends_with(">") => {
(0, _, Some(snippet)) if !snippet.ends_with('>') => {
suggest_new(err, &format!("{}<'a>", snippet));
}
_ => {
Expand Down

0 comments on commit 80ed505

Please sign in to comment.