1
Fork 0

Rollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errors

Use the power of adding helper function to simplify code w/ `Mutability`

r? `@compiler-errors`
This commit is contained in:
Guillaume Gomez 2022-11-26 17:47:23 +01:00 committed by GitHub
commit a2e485c25c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 144 additions and 218 deletions

View file

@ -1055,7 +1055,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
{
(
mk_result(old_pred.map_bound(|trait_pred| (trait_pred, *ty))),
matches!(mutability, hir::Mutability::Mut),
mutability.is_mut(),
)
} else {
(false, false)
@ -1344,7 +1344,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
.sess
.source_map()
.span_take_while(span, |c| c.is_whitespace() || *c == '&');
if points_at_arg && mutability == hir::Mutability::Not && refs_number > 0 {
if points_at_arg && mutability.is_not() && refs_number > 0 {
err.span_suggestion_verbose(
sp,
"consider changing this borrow's mutability",