When suggesting to import an item, also suggest changing the path if appropriate

When we don't find an item we search all of them for an appropriate
import and suggest `use`ing it. This is sometimes done for expressions
that have paths with more than one segment. We now also suggest changing
that path to work with the `use`.

Fix #95413
This commit is contained in:
Esteban Küber 2022-04-23 16:41:36 -07:00 committed by Esteban Kuber
parent 3d0ac7ea23
commit 57967269e9
14 changed files with 149 additions and 17 deletions

View file

@ -696,6 +696,9 @@ struct UseError<'a> {
instead: bool,
/// Extra free-form suggestion.
suggestion: Option<(Span, &'static str, String, Applicability)>,
/// Path `Segment`s at the place of use that failed. Used for accurate suggestion after telling
/// the user to import the item directly.
path: Vec<Segment>,
}
#[derive(Clone, Copy, PartialEq, Debug)]