add suggestion applicabilities to librustc and libsyntax by zackmdavis · Pull Request #50724 · rust-lang/rust (original) (raw)

Yeah, the bar is slightly higher for edition stuff. It's basically that _known_ and _likely_ problems should not be autofixed. But this is speculative, it's better to mark it machine applicable and then fix in case there are bugs.

On Mon, May 14, 2018, 1:08 AM Zack M. Davis ***@***.***> wrote: ***@***.**** commented on this pull request. ------------------------------ In src/librustc/infer/error_reporting/mod.rs <#50724 (comment)>: > @@ -1097,7 +1097,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if let Some((sp, has_lifetimes)) = type_param_span { let tail = if has_lifetimes { " + " } else { "" }; let suggestion = format!("{}: {}{}", bound_kind, sub, tail); - err.span_suggestion_short(sp, consider, suggestion); + err.span_suggestion_short_with_applicability( + sp, consider, suggestion, Applicability::MaybeIncorrect + ); In most cases, the explanation is just "I don't feel Overwhelmingly Confident that this suggestion will always be what the user wants, even if I don't have an explicit counterexample of reasonable code for which this suggestion is incorrect", because I was imagining MachineApplicability was a very high standard. (Like you said <#50476 (comment)>, we don't want rustfix to guess when it doesn't *know*.) If the standard is slightly lower than that (such that MaybeIncorrect requires a commentable justification stronger than "Well, I'm not *sure* that it's always correct"), then I'd want to change a lot of these to MachineApplicable. Thinking on it, that's probably the best long-term decision, for the same reason assertions and static typing are good ideas: better to make slightly too strong assumptions (and then fix the bugs as they're reported), rather than too weak assumptions (and have no way of knowing whether we could successfully auto-fix more things). — You are receiving this because you were assigned. Reply to this email directly, view it on GitHub <#50724 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABivSM54C8hp7ESzN8oKolLJ79-EG4cuks5tyR9rgaJpZM4T89d0> .