Skip to content

Commit 80ed505

Browse files
committed
Use single-char patter on {ends,starts}_with and remove clone on copy type.
These were introduced since I last fixed most of these occurences. (clippy::clone_on_copy, clippy::single_char_pattern)
1 parent d8d2004 commit 80ed505

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/librustc_errors/registry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ impl Registry {
2727
if !self.long_descriptions.contains_key(code) {
2828
return Err(InvalidErrorCode);
2929
}
30-
Ok(self.long_descriptions.get(code).unwrap().clone())
30+
Ok(*self.long_descriptions.get(code).unwrap())
3131
}
3232
}

src/librustc_resolve/late/diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
10861086
for param in params {
10871087
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(param.span)
10881088
{
1089-
if snippet.starts_with("&") && !snippet.starts_with("&'") {
1089+
if snippet.starts_with('&') && !snippet.starts_with("&'") {
10901090
introduce_suggestion
10911091
.push((param.span, format!("&'a {}", &snippet[1..])));
10921092
} else if snippet.starts_with("&'_ ") {
@@ -1118,7 +1118,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
11181118
(1, Some(name), Some("'_")) => {
11191119
suggest_existing(err, name.to_string());
11201120
}
1121-
(1, Some(name), Some(snippet)) if !snippet.ends_with(">") => {
1121+
(1, Some(name), Some(snippet)) if !snippet.ends_with('>') => {
11221122
suggest_existing(err, format!("{}<{}>", snippet, name));
11231123
}
11241124
(0, _, Some("&")) => {
@@ -1127,7 +1127,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
11271127
(0, _, Some("'_")) => {
11281128
suggest_new(err, "'a");
11291129
}
1130-
(0, _, Some(snippet)) if !snippet.ends_with(">") => {
1130+
(0, _, Some(snippet)) if !snippet.ends_with('>') => {
11311131
suggest_new(err, &format!("{}<'a>", snippet));
11321132
}
11331133
_ => {

0 commit comments

Comments
 (0)