Readd suggestion in enum variants with incorrect args

This commit is contained in:
Esteban Küber 2018-01-01 16:37:14 -08:00
parent a317da42b1
commit ce9ef37fe6
3 changed files with 15 additions and 3 deletions

View file

@ -2730,6 +2730,18 @@ impl<'a> Resolver<'a> {
}
return (err, candidates);
}
(Def::VariantCtor(_, ctor_kind), _) if ns == ValueNS && is_struct_like(def) => {
let block = match ctor_kind {
CtorKind::Fn => "(/* fields */)",
CtorKind::Fictive => " { /* fields */ }",
def => bug!("found def `{:?}` when looking for a ctor",
def),
};
err.span_label(span, format!("did you mean `{}{}`?",
path_str,
block));
return (err, candidates);
}
_ => {}
}
}

View file

@ -2,7 +2,7 @@ error[E0423]: expected function, found struct variant `Foo::Variant`
--> $DIR/issue-18252.rs:16:13
|
16 | let f = Foo::Variant(42);
| ^^^^^^^^^^^^ not a function
| ^^^^^^^^^^^^ did you mean `Foo::Variant { /* fields */ }`?
error: aborting due to previous error

View file

@ -2,13 +2,13 @@ error[E0423]: expected value, found struct variant `Homura::Madoka`
--> $DIR/issue-19452.rs:19:18
|
19 | let homura = Homura::Madoka;
| ^^^^^^^^^^^^^^ not a value
| ^^^^^^^^^^^^^^ did you mean `Homura::Madoka { /* fields */ }`?
error[E0423]: expected value, found struct variant `issue_19452_aux::Homura::Madoka`
--> $DIR/issue-19452.rs:22:18
|
22 | let homura = issue_19452_aux::Homura::Madoka;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a value
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `issue_19452_aux::Homura::Madoka { /* fields */ }`?
error: aborting due to 2 previous errors