Clean up mut keyword check

This commit is contained in:
Deep Majumder 2022-12-14 10:30:44 +05:30
parent 9c8bf51f14
commit afefbb66c3

View File

@ -1369,13 +1369,9 @@ fn suggest_change_mut(
.span_take_while(span, |c| c.is_whitespace() || *c == '&');
if points_at_arg && mutability.is_not() && refs_number > 0 {
// If we have a call like foo(&mut buf), then don't suggest foo(&mut mut buf)
if "mut"
== snippet
.chars()
.filter(|c| !c.is_whitespace())
.skip(refs_number)
.take(3)
.collect::<String>()
if snippet
.trim_start_matches(|c: char| c.is_whitespace() || c == '&')
.starts_with("mut")
{
return;
}