Re-add support for impl Trait for ..
to the parser
This commit is contained in:
parent
8b4d852f32
commit
22598776b0
4 changed files with 40 additions and 2 deletions
|
@ -215,8 +215,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
|
|
||||||
fn visit_item(&mut self, item: &'a Item) {
|
fn visit_item(&mut self, item: &'a Item) {
|
||||||
match item.node {
|
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);
|
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 {
|
for impl_item in impl_items {
|
||||||
self.invalid_visibility(&impl_item.vis, impl_item.span, None);
|
self.invalid_visibility(&impl_item.vis, impl_item.span, None);
|
||||||
if let ImplItemKind::Method(ref sig, _) = impl_item.node {
|
if let ImplItemKind::Method(ref sig, _) = impl_item.node {
|
||||||
|
|
|
@ -5422,7 +5422,11 @@ impl<'a> Parser<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if opt_trait.is_some() {
|
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()?;
|
generics.where_clause = self.parse_where_clause()?;
|
||||||
|
|
||||||
|
|
19
src/test/ui/obsolete-syntax-impl-for-dotdot.rs
Normal file
19
src/test/ui/obsolete-syntax-impl-for-dotdot.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// 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() {}
|
10
src/test/ui/obsolete-syntax-impl-for-dotdot.stderr
Normal file
10
src/test/ui/obsolete-syntax-impl-for-dotdot.stderr
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue