use structured macro and path resolve suggestions
This commit is contained in:
parent
920192490f
commit
93b55365b5
@ -3321,7 +3321,12 @@ impl<'a> Resolver<'a> {
|
||||
if let Some(def) = def {
|
||||
match (def, source) {
|
||||
(Def::Macro(..), _) => {
|
||||
err.span_label(span, format!("did you mean `{}!(...)`?", path_str));
|
||||
err.span_suggestion_with_applicability(
|
||||
span,
|
||||
"use `!` to invoke the macro",
|
||||
format!("{}!", path_str),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
return (err, candidates);
|
||||
}
|
||||
(Def::TyAlias(..), PathSource::Trait(_)) => {
|
||||
@ -3333,13 +3338,22 @@ impl<'a> Resolver<'a> {
|
||||
}
|
||||
(Def::Mod(..), PathSource::Expr(Some(parent))) => match parent.node {
|
||||
ExprKind::Field(_, ident) => {
|
||||
err.span_label(parent.span, format!("did you mean `{}::{}`?",
|
||||
path_str, ident));
|
||||
err.span_suggestion_with_applicability(
|
||||
parent.span,
|
||||
"use the path separator to refer to an item",
|
||||
format!("{}::{}", path_str, ident),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
return (err, candidates);
|
||||
}
|
||||
ExprKind::MethodCall(ref segment, ..) => {
|
||||
err.span_label(parent.span, format!("did you mean `{}::{}(...)`?",
|
||||
path_str, segment.ident));
|
||||
let span = parent.span.with_hi(segment.ident.span.hi());
|
||||
err.span_suggestion_with_applicability(
|
||||
span,
|
||||
"use the path separator to refer to an item",
|
||||
format!("{}::{}", path_str, segment.ident),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
return (err, candidates);
|
||||
}
|
||||
_ => {}
|
||||
|
@ -2,7 +2,7 @@ error[E0423]: expected function, found macro `assert`
|
||||
--> $DIR/resolve-hint-macro.rs:2:5
|
||||
|
|
||||
LL | assert(true);
|
||||
| ^^^^^^ did you mean `assert!(...)`?
|
||||
| ^^^^^^ help: use `!` to invoke the macro: `assert!`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -4,15 +4,15 @@ error[E0423]: expected value, found module `a`
|
||||
LL | a.I
|
||||
| ^--
|
||||
| |
|
||||
| did you mean `a::I`?
|
||||
| help: use the path separator to refer to an item: `a::I`
|
||||
|
||||
error[E0423]: expected value, found module `a`
|
||||
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:22:5
|
||||
|
|
||||
LL | a.g()
|
||||
| ^----
|
||||
| ^--
|
||||
| |
|
||||
| did you mean `a::g(...)`?
|
||||
| help: use the path separator to refer to an item: `a::g`
|
||||
|
||||
error[E0423]: expected value, found module `a`
|
||||
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:27:5
|
||||
@ -20,16 +20,21 @@ error[E0423]: expected value, found module `a`
|
||||
LL | a.b.J
|
||||
| ^--
|
||||
| |
|
||||
| did you mean `a::b`?
|
||||
| help: use the path separator to refer to an item: `a::b`
|
||||
|
||||
error[E0423]: expected value, found module `a::b`
|
||||
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:32:5
|
||||
|
|
||||
LL | a::b.J
|
||||
| ^^^---
|
||||
| | |
|
||||
| | help: a constant with a similar name exists: `I`
|
||||
| did you mean `a::b::J`?
|
||||
| ^^^^
|
||||
help: a constant with a similar name exists
|
||||
|
|
||||
LL | a::I.J
|
||||
| ^
|
||||
help: use the path separator to refer to an item
|
||||
|
|
||||
LL | a::b::J
|
||||
|
|
||||
|
||||
error[E0423]: expected value, found module `a`
|
||||
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:37:5
|
||||
@ -37,7 +42,7 @@ error[E0423]: expected value, found module `a`
|
||||
LL | a.b.f();
|
||||
| ^--
|
||||
| |
|
||||
| did you mean `a::b`?
|
||||
| help: use the path separator to refer to an item: `a::b`
|
||||
|
||||
error[E0423]: expected value, found module `a::b`
|
||||
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:40:12
|
||||
@ -51,10 +56,15 @@ error[E0423]: expected value, found module `a::b`
|
||||
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:45:5
|
||||
|
|
||||
LL | a::b.f()
|
||||
| ^^^-----
|
||||
| | |
|
||||
| | help: a constant with a similar name exists: `I`
|
||||
| did you mean `a::b::f(...)`?
|
||||
| ^^^^
|
||||
help: a constant with a similar name exists
|
||||
|
|
||||
LL | a::I.f()
|
||||
| ^
|
||||
help: use the path separator to refer to an item
|
||||
|
|
||||
LL | a::b::f()
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0423]: expected value, found module `a::b`
|
||||
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:50:5
|
||||
|
@ -15,7 +15,7 @@ error[E0574]: expected struct, variant or union type, found macro `try`
|
||||
--> $DIR/try-block-in-edition2015.rs:4:33
|
||||
|
|
||||
LL | let try_result: Option<_> = try {
|
||||
| ^^^ did you mean `try!(...)`?
|
||||
| ^^^ help: use `!` to invoke the macro: `try!`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user