Adds diagnostic message and UI test.

This commit is contained in:
Wesley Norris
2019-03-04 20:00:28 -05:00
committed by Vadim Petrochenkov
parent 88f755f8a8
commit 00887f39d1
3 changed files with 24 additions and 1 deletions

View File

@@ -6716,8 +6716,16 @@ impl<'a> Parser<'a> {
ast::ImplPolarity::Positive
};
let possible_missing_trait = self.look_ahead(0, |t| t.is_keyword(keywords::For));
// Parse both types and traits as a type, then reinterpret if necessary.
let ty_first = self.parse_ty()?;
let ty_first = self.parse_ty().map_err(|mut err| {
if possible_missing_trait {
err.help("did you forget a trait name after `impl`?");
}
err
})?;
// If `for` is missing we try to recover.
let has_for = self.eat_keyword(keywords::For);