Skip to content

Commit afefbb6

Browse files
committed
Clean up mut keyword check
1 parent 9c8bf51 commit afefbb6

File tree

1 file changed

+3
-7
lines changed
  • compiler/rustc_trait_selection/src/traits/error_reporting

1 file changed

+3
-7
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1369,13 +1369,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
13691369
.span_take_while(span, |c| c.is_whitespace() || *c == '&');
13701370
if points_at_arg && mutability.is_not() && refs_number > 0 {
13711371
// If we have a call like foo(&mut buf), then don't suggest foo(&mut mut buf)
1372-
if "mut"
1373-
== snippet
1374-
.chars()
1375-
.filter(|c| !c.is_whitespace())
1376-
.skip(refs_number)
1377-
.take(3)
1378-
.collect::<String>()
1372+
if snippet
1373+
.trim_start_matches(|c: char| c.is_whitespace() || c == '&')
1374+
.starts_with("mut")
13791375
{
13801376
return;
13811377
}

0 commit comments

Comments
 (0)