use strip_prefix over starts_with and manual slicing based on pattern length (clippy::manual_strip)
This commit is contained in:
parent
95386b656e
commit
012974da7a
8 changed files with 28 additions and 26 deletions
|
@ -492,8 +492,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
{
|
||||
if let Ok(pat_snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(pat_span)
|
||||
{
|
||||
if pat_snippet.starts_with('&') {
|
||||
let pat_snippet = pat_snippet[1..].trim_start();
|
||||
if let Some(stripped) = pat_snippet.strip_prefix('&') {
|
||||
let pat_snippet = stripped.trim_start();
|
||||
let (suggestion, to_remove) = if pat_snippet.starts_with("mut")
|
||||
&& pat_snippet["mut".len()..].starts_with(rustc_lexer::is_whitespace)
|
||||
{
|
||||
|
|
|
@ -631,9 +631,8 @@ fn suggest_ampmut<'tcx>(
|
|||
let lt_name = &src[1..ws_pos];
|
||||
let ty = &src[ws_pos..];
|
||||
return (assignment_rhs_span, format!("&{} mut {}", lt_name, ty));
|
||||
} else if src.starts_with('&') {
|
||||
let borrowed_expr = &src[1..];
|
||||
return (assignment_rhs_span, format!("&mut {}", borrowed_expr));
|
||||
} else if let Some(stripped) = src.strip_prefix('&') {
|
||||
return (assignment_rhs_span, format!("&mut {}", stripped));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue