@@ -1146,6 +1146,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { |
|
|
1146 |
1146 |
} |
1147 |
1147 |
// don't create labels for compiler-generated spans |
1148 |
1148 |
Some(_) => None, |
|
1149 |
+// don't create labels for the span not from user's code |
|
1150 |
+None if opt_assignment_rhs_span |
|
1151 |
+.is_some_and(|span |
|
1152 |
+{ |
|
1153 |
+None |
|
1154 |
+} |
1149 |
1155 |
None => { |
1150 |
1156 |
let (has_sugg, decl_span, sugg) = if name != kw::SelfLower { |
1151 |
1157 |
suggest_ampmut( |
@@ -1198,18 +1204,21 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { |
|
|
1198 |
1204 |
sugg.push(s); |
1199 |
1205 |
} |
1200 |
1206 |
|
1201 |
|
- err.multipart_suggestion_verbose( |
1202 |
|
-format!( |
1203 |
|
-"consider changing this to be a mutable {pointer_desc}{}", |
1204 |
|
-if is_trait_sig { |
1205 |
|
-" in the `impl` method and the `trait` definition" |
1206 |
|
-} else { |
1207 |
|
-"" |
1208 |
|
-} |
1209 |
|
-), |
1210 |
|
- sugg, |
1211 |
|
-Applicability::MachineApplicable, |
1212 |
|
-); |
|
1207 |
+if sugg.iter().all(|(span, _) |
|
1208 |
+{ |
|
1209 |
+ err.multipart_suggestion_verbose( |
|
1210 |
+format!( |
|
1211 |
+"consider changing this to be a mutable {pointer_desc}{}", |
|
1212 |
+if is_trait_sig { |
|
1213 |
+" in the `impl` method and the `trait` definition" |
|
1214 |
+} else { |
|
1215 |
+"" |
|
1216 |
+} |
|
1217 |
+), |
|
1218 |
+ sugg, |
|
1219 |
+Applicability::MachineApplicable, |
|
1220 |
+); |
|
1221 |
+} |
1213 |
1222 |
} |
1214 |
1223 |
Some((false, err_label_span, message, _)) => { |
1215 |
1224 |
let def_id = self.body.source.def_id(); |