diff options
| author | Deep Majumder <deep.majumder2019@gmail.com> | 2022-12-14 10:30:44 +0530 |
|---|---|---|
| committer | Deep Majumder <deep.majumder2019@gmail.com> | 2022-12-14 10:30:44 +0530 |
| commit | afefbb66c3abea2e9b3acacddf7516b24c2bbeb8 (patch) | |
| tree | bc412a9bc72459ddad7a004eda38572e05ef6c7d | |
| parent | 9c8bf51f142090de5c30341b744a7d7456bc309e (diff) | |
| download | rust-afefbb66c3abea2e9b3acacddf7516b24c2bbeb8.tar.gz rust-afefbb66c3abea2e9b3acacddf7516b24c2bbeb8.zip | |
Clean up mut keyword check
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 2323161039a..554cab3fb6c 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1369,13 +1369,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { .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; } |
