`_with_applicability` methods are gone

The simpler `span_suggestion` method name now takes the applicability
argument, thanks to Andy Russell (rust-lang/rust@0897ffc28f).
This commit is contained in:
Zack M. Davis 2019-02-05 22:46:53 -08:00 committed by Who? Me?!
parent 1ad362e6d6
commit c0600a96b3
1 changed files with 6 additions and 7 deletions

View File

@ -85,11 +85,11 @@ Server][rls] and [`rustfix`][rustfix].
[rustfix]: https://github.com/rust-lang-nursery/rustfix [rustfix]: https://github.com/rust-lang-nursery/rustfix
Not all suggestions should be applied mechanically. Use the Not all suggestions should be applied mechanically. Use the
[`span_suggestion_with_applicability`][sswa] method of `DiagnosticBuilder` to [`span_suggestion`][span_suggestion] method of `DiagnosticBuilder` to
make a suggestion while providing a hint to tools whether the suggestion is make a suggestion. The last argument provides a hint to tools whether
mechanically applicable or not. the suggestion is mechanically applicable or not.
[sswa]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.DiagnosticBuilder.html#method.span_suggestion_with_applicability [span_suggestion]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.DiagnosticBuilder.html#method.span_suggestion
For example, to make our `qux` suggestion machine-applicable, we would do: For example, to make our `qux` suggestion machine-applicable, we would do:
@ -97,8 +97,7 @@ For example, to make our `qux` suggestion machine-applicable, we would do:
let mut err = sess.struct_span_err(sp, "oh no! this is an error!"); let mut err = sess.struct_span_err(sp, "oh no! this is an error!");
if let Ok(snippet) = sess.source_map().span_to_snippet(sp) { if let Ok(snippet) = sess.source_map().span_to_snippet(sp) {
// Add applicability info! err.span_suggestion(
err.span_suggestion_with_applicability(
suggestion_sp, suggestion_sp,
"try using a qux here", "try using a qux here",
format!("qux {}", snip), format!("qux {}", snip),
@ -145,7 +144,7 @@ error: aborting due to previous error
For more information about this error, try `rustc --explain E0999`. For more information about this error, try `rustc --explain E0999`.
``` ```
There are a few other [`Applicability`][appl] possibilities: The possible values of [`Applicability`][appl] are:
- `MachineApplicable`: Can be applied mechanically. - `MachineApplicable`: Can be applied mechanically.
- `HasPlaceholders`: Cannot be applied mechanically because it has placeholder - `HasPlaceholders`: Cannot be applied mechanically because it has placeholder