1
Fork 0

support default impl for specialization

`[default] [unsafe] impl` and typecheck
This commit is contained in:
Gianni Ciccarelli 2017-04-26 03:17:48 +00:00
parent 715811d0be
commit b48eb5e0be
7 changed files with 44 additions and 46 deletions

View file

@ -4918,12 +4918,9 @@ impl<'a> Parser<'a> {
allowed to have generics");
}
match defaultness {
ast::Defaultness::Default => {
self.span_err(impl_span, "`default impl` is not allowed for \
default trait implementations");
}
_ => {}
if let ast::Defaultness::Default = defaultness {
self.span_err(impl_span, "`default impl` is not allowed for \
default trait implementations");
}
self.expect(&token::OpenDelim(token::Brace))?;
@ -5768,13 +5765,13 @@ impl<'a> Parser<'a> {
}
if (self.check_keyword(keywords::Unsafe) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Impl))) ||
(self.check_keyword(keywords::Unsafe) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Default)) &&
(self.check_keyword(keywords::Default) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Unsafe)) &&
self.look_ahead(2, |t| t.is_keyword(keywords::Impl)))
{
// IMPL ITEM
self.expect_keyword(keywords::Unsafe)?;
let defaultness = self.parse_defaultness()?;
self.expect_keyword(keywords::Unsafe)?;
self.expect_keyword(keywords::Impl)?;
let (ident,
item_,