Remove invalid help diagnostics for const pointer · rust-lang/rust@b44a484 (original) (raw)

Original file line number Diff line number Diff line change
@@ -1198,18 +1198,21 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
1198 1198 sugg.push(s);
1199 1199 }
1200 1200
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 -);
1201 +if sugg.iter().all(|(span, _)
1202 +{
1203 + err.multipart_suggestion_verbose(
1204 +format!(
1205 +"consider changing this to be a mutable {pointer_desc}{}",
1206 +if is_trait_sig {
1207 +" in the `impl` method and the `trait` definition"
1208 +} else {
1209 +""
1210 +}
1211 +),
1212 + sugg,
1213 +Applicability::MachineApplicable,
1214 +);
1215 +}
1213 1216 }
1214 1217 Some((false, err_label_span, message, _)) => {
1215 1218 let def_id = self.body.source.def_id();