pub fn span_lint_and_sugg_for_edges(
    cx: &LateContext<'_>,
    lint: &'static Lint,
    sp: Span,
    msg: &str,
    helps: &[&str; 2],
    sugg: String,
    applicability: Applicability
)
Expand description

Like span_lint_and_sugg with a focus on the edges. The output will either emit single span or multispan suggestion depending on the number of its lines.

If the given suggestion string has more lines than the maximum display length defined by MAX_SUGGESTION_HIGHLIGHT_LINES, this function will split the suggestion and span to showcase the change for the top and bottom edge of the code. For normal suggestions, in one display window, the help message will be combined with a colon.

Multipart suggestions like the one being created here currently cannot be applied by rustfix (See rustfix#141). Testing rustfix with this lint emission function might require a file with suggestions that can be fixed and those that can’t. See clippy#8520 for an example and of this.

Example for a long suggestion

error: called `map(..).flatten()` on `Option`
  --> $DIR/map_flatten.rs:8:10
   |
LL |           .map(|x| {
   |  __________^
LL | |             if x <= 5 {
LL | |                 Some(x)
LL | |             } else {
...  |
LL | |         })
LL | |         .flatten();
   | |__________________^
   |
  = note: `-D clippy::map-flatten` implied by `-D warnings`
help: try replacing `map` with `and_then`
   |
LL ~         .and_then(|x| {
LL +             if x <= 5 {
LL +                 Some(x)
   |
help: and remove the `.flatten()`
   |
LL +                 None
LL +             }
LL ~         });
   |