提交 22598776 编写于 作者: V Vadim Petrochenkov

Re-add support for `impl Trait for ..` to the parser

上级 8b4d852f
......@@ -215,8 +215,13 @@ fn visit_lifetime(&mut self, lifetime: &'a Lifetime) {
fn visit_item(&mut self, item: &'a Item) {
match item.node {
ItemKind::Impl(.., Some(..), _, ref impl_items) => {
ItemKind::Impl(.., Some(..), ref ty, ref impl_items) => {
self.invalid_visibility(&item.vis, item.span, None);
if ty.node == TyKind::Err {
self.err_handler()
.struct_span_err(item.span, "`impl Trait for .. {}` is an obsolete syntax")
.help("use `auto trait Trait {}` instead").emit();
}
for impl_item in impl_items {
self.invalid_visibility(&impl_item.vis, impl_item.span, None);
if let ImplItemKind::Method(ref sig, _) = impl_item.node {
......
......@@ -5422,7 +5422,11 @@ fn parse_item_impl(&mut self,
};
if opt_trait.is_some() {
ty = self.parse_ty()?;
ty = if self.eat(&token::DotDot) {
P(Ty { node: TyKind::Err, span: self.prev_span, id: ast::DUMMY_NODE_ID })
} else {
self.parse_ty()?
}
}
generics.where_clause = self.parse_where_clause()?;
......
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
trait Trait1 {}
trait Trait2 {}
#[cfg(not_enabled)]
impl Trait1 for .. {}
impl Trait2 for .. {} //~ ERROR `impl Trait for .. {}` is an obsolete syntax
fn main() {}
error: `impl Trait for .. {}` is an obsolete syntax
--> $DIR/obsolete-syntax-impl-for-dotdot.rs:17:1
|
17 | impl Trait2 for .. {} //~ ERROR `impl Trait for .. {}` is an obsolete syntax
| ^^^^^^^^^^^^^^^^^^^^^
|
= help: use `auto trait Trait {}` instead
error: aborting due to previous error
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册