about summary refs log tree commit diff
path: root/src/test/ui/span
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2017-12-02 22:15:03 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-01-14 18:10:05 +0300
commitd19e4c4a8507da7e35d0de2b196c48e6621de1f9 (patch)
treedf1852ce3a472b0d835c02f9686bbde9e21cb9e9 /src/test/ui/span
parent48ab4cde5460f9f7c57249e4e62ad569dc843dd8 (diff)
downloadrust-d19e4c4a8507da7e35d0de2b196c48e6621de1f9.tar.gz
rust-d19e4c4a8507da7e35d0de2b196c48e6621de1f9.zip
syntax: Rewrite parsing of impls
Properly parse impls for the never type `!`
Recover from missing `for` in `impl Trait for Type`
Prohibit inherent default impls and default impls of auto traits
Change wording in more diagnostics to use "auto traits"
Some minor code cleanups in the parser
Diffstat (limited to 'src/test/ui/span')
-rw-r--r--src/test/ui/span/impl-parsing.rs21
-rw-r--r--src/test/ui/span/impl-parsing.stderr32
2 files changed, 53 insertions, 0 deletions
diff --git a/src/test/ui/span/impl-parsing.rs b/src/test/ui/span/impl-parsing.rs
new file mode 100644
index 00000000000..064e3c3ac48
--- /dev/null
+++ b/src/test/ui/span/impl-parsing.rs
@@ -0,0 +1,21 @@
+// 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.
+
+// compile-flags: -Z parse-only -Z continue-parse-after-error
+
+impl ! {} // OK
+impl ! where u8: Copy {} // OK
+
+impl Trait Type {} //~ ERROR missing `for` in a trait impl
+impl Trait .. {} //~ ERROR missing `for` in a trait impl
+impl ?Sized for Type {} //~ ERROR expected a trait, found type
+impl ?Sized for .. {} //~ ERROR expected a trait, found type
+
+default unsafe FAIL //~ ERROR expected `impl`, found `FAIL`
diff --git a/src/test/ui/span/impl-parsing.stderr b/src/test/ui/span/impl-parsing.stderr
new file mode 100644
index 00000000000..912638446b9
--- /dev/null
+++ b/src/test/ui/span/impl-parsing.stderr
@@ -0,0 +1,32 @@
+error: missing `for` in a trait impl
+  --> $DIR/impl-parsing.rs:16:11
+   |
+16 | impl Trait Type {} //~ ERROR missing `for` in a trait impl
+   |           ^
+
+error: missing `for` in a trait impl
+  --> $DIR/impl-parsing.rs:17:11
+   |
+17 | impl Trait .. {} //~ ERROR missing `for` in a trait impl
+   |           ^
+
+error: expected a trait, found type
+  --> $DIR/impl-parsing.rs:18:6
+   |
+18 | impl ?Sized for Type {} //~ ERROR expected a trait, found type
+   |      ^^^^^^
+
+error: expected a trait, found type
+  --> $DIR/impl-parsing.rs:19:6
+   |
+19 | impl ?Sized for .. {} //~ ERROR expected a trait, found type
+   |      ^^^^^^
+
+error: expected `impl`, found `FAIL`
+  --> $DIR/impl-parsing.rs:21:16
+   |
+21 | default unsafe FAIL //~ ERROR expected `impl`, found `FAIL`
+   |                ^^^^ expected `impl` here
+
+error: aborting due to 5 previous errors
+