mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
Don't ICE while suggesting updating item path.
When an item isn't found, we may suggest an appropriate import to `use`. Along with that, we also suggest updating the path to work with the `use`. Unfortunately, if the code in question originates from a macro, the span used to indicate which part of the path needs updating may not be suitable and cause an ICE. Since, such code is not adjustable directly by the user without modifying the macro, just skip the suggestion in such cases.
This commit is contained in:
parent
e141246cbb
commit
fc83a0cb57
@ -2544,13 +2544,16 @@ fn show_candidates(
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
if let [first, .., last] = &path[..] {
|
||||
let sp = first.ident.span.until(last.ident.span);
|
||||
if sp.can_be_used_for_suggestions() {
|
||||
err.span_suggestion_verbose(
|
||||
first.ident.span.until(last.ident.span),
|
||||
sp,
|
||||
&format!("if you import `{}`, refer to it directly", last.ident),
|
||||
"",
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
msg.push(':');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user