about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
diff options
context:
space:
mode:
authorRyan Levick <me@ryanlevick.com>2021-03-16 21:47:06 +0100
committerRyan Levick <me@ryanlevick.com>2021-04-08 15:36:27 +0200
commitc2d0f1457ac71342fb6411ecf6d8253a04686dc1 (patch)
treed8f65dd10ae5709701aa2ac89c4dbba2e745959f /compiler/rustc_error_codes/src
parent69e1d22ddbc67b25141a735a22a8895a678b32ca (diff)
downloadrust-c2d0f1457ac71342fb6411ecf6d8253a04686dc1.tar.gz
rust-c2d0f1457ac71342fb6411ecf6d8253a04686dc1.zip
Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021
Diffstat (limited to 'compiler/rustc_error_codes/src')
-rw-r--r--compiler/rustc_error_codes/src/error_codes.rs2
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0782.md17
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0783.md18
3 files changed, 37 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs
index 4b529734328..ab7a13dee69 100644
--- a/compiler/rustc_error_codes/src/error_codes.rs
+++ b/compiler/rustc_error_codes/src/error_codes.rs
@@ -471,6 +471,8 @@ E0778: include_str!("./error_codes/E0778.md"),
 E0779: include_str!("./error_codes/E0779.md"),
 E0780: include_str!("./error_codes/E0780.md"),
 E0781: include_str!("./error_codes/E0781.md"),
+E0782: include_str!("./error_codes/E0782.md"),
+E0783: include_str!("./error_codes/E0783.md"),
 ;
 //  E0006, // merged with E0005
 //  E0008, // cannot bind by-move into a pattern guard
diff --git a/compiler/rustc_error_codes/src/error_codes/E0782.md b/compiler/rustc_error_codes/src/error_codes/E0782.md
new file mode 100644
index 00000000000..e001aa8bc9b
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0782.md
@@ -0,0 +1,17 @@
+Trait objects must include the `dyn` keyword.
+
+Trait objects are a way to call methods on types that are not known until
+runtime but conform to some trait.
+
+In the following code the trait object should be formed with
+`Box<dyn Foo>`, but `dyn` is left off.
+
+```compile_fail,E0782
+trait Foo {}
+fn test(arg: Box<Foo>) {}
+```
+
+This makes it harder to see that `arg` is a trait object and not a
+simply a heap allocated type called `Foo`.
+
+This used to be allowed before edition 2021, but is now an error.
diff --git a/compiler/rustc_error_codes/src/error_codes/E0783.md b/compiler/rustc_error_codes/src/error_codes/E0783.md
new file mode 100644
index 00000000000..cc904543b0d
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0783.md
@@ -0,0 +1,18 @@
+The range pattern `...` is no longer allowed.
+
+Older Rust code using previous editions allowed `...` to stand for exclusive
+ranges which are now signified using `..=`.
+
+The following code use to compile, but now it now longer does.
+
+```compile_fail,E0783
+fn main() {
+    let n = 2u8;
+    match n {
+        ...9 => println!("Got a number less than 10),
+        _ => println!("Got a number 10 or more")
+    }
+}
+```
+
+To make this code compile replace the `...` with `..=`.