fix span for suggestion
This commit is contained in:
parent
1225c3f6b8
commit
f90bf50d47
2 changed files with 10 additions and 15 deletions
|
@ -697,21 +697,15 @@ impl<'a> Resolver<'a> {
|
|||
let mut suggestion = None;
|
||||
let (span, label) = if let PathResult::Failed { span, label, .. } = path_res {
|
||||
// try to suggest if it's not a macro, maybe a function
|
||||
if let PathResult::NonModule(partial_res) = self.resolve_path(
|
||||
&path,
|
||||
Some(ValueNS),
|
||||
&parent_scope,
|
||||
Some(Finalize::new(ast::CRATE_NODE_ID, path_span)),
|
||||
None,
|
||||
) && partial_res.unresolved_segments() == 0 {
|
||||
if let PathResult::NonModule(partial_res) = self.maybe_resolve_path(&path, Some(ValueNS), &parent_scope)
|
||||
&& partial_res.unresolved_segments() == 0 {
|
||||
let sm = self.session.source_map();
|
||||
let span = sm.span_extend_while(span, |c| c == '!').unwrap_or(span);
|
||||
let code = sm.span_to_snippet(span).unwrap();
|
||||
suggestion = Some(
|
||||
(vec![(span, code.trim_end_matches('!').to_string())],
|
||||
let exclamation_span = sm.next_point(span);
|
||||
suggestion = Some((
|
||||
vec![(exclamation_span, "".to_string())],
|
||||
format!("{} is not a macro, but a {}, try to remove `!`", Segment::names_to_string(&path), partial_res.base_res().descr()),
|
||||
Applicability::MaybeIncorrect)
|
||||
);
|
||||
Applicability::MaybeIncorrect
|
||||
));
|
||||
}
|
||||
(span, label)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue