diff --git a/compiler/rustc_error_codes/src/error_codes/E0782.md b/compiler/rustc_error_codes/src/error_codes/E0782.md index 933e37763f6..63c48506e7f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0782.md +++ b/compiler/rustc_error_codes/src/error_codes/E0782.md @@ -1,17 +1,26 @@ 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. +Erroneous code example: -In the following code the trait object should be formed with -`Box`, but `dyn` is left off. - -```no_run +```edition2021,compile_fail,E782 trait Foo {} fn test(arg: Box) {} ``` +Trait objects are a way to call methods on types that are not known until +runtime but conform to some trait. + +Trait objects should be formed with `Box`, but in the code above +`dyn` is left off. + This makes it harder to see that `arg` is a trait object and not a simply a heap allocated type called `Foo`. +To fix this issue, add `dyn` before the trait name. + +``` +trait Foo {} +fn test(arg: Box) {} +``` + 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 index 73c19cd7f02..41989b3ba2f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0783.md +++ b/compiler/rustc_error_codes/src/error_codes/E0783.md @@ -1,18 +1,26 @@ The range pattern `...` is no longer allowed. -Older Rust code using previous editions allowed `...` to stand for exclusive -ranges which are now signified using `..=`. +Erroneous code example: -The following code use to compile, but now it now longer does. - -```no_run +```edition2021,compile_fail,E782 fn main() { - let n = 2u8; - match n { - ...9 => println!("Got a number less than 10"), + match 2u8 { + 0...9 => println!("Got a number less than 10"), _ => println!("Got a number 10 or more") } } ``` +Older Rust code using previous editions allowed `...` to stand for exclusive +ranges which are now signified using `..=`. + To make this code compile replace the `...` with `..=`. + +``` +fn main() { + match 2u8 { + 0..=9 => println!("Got a number less than 10"), + _ => println!("Got a number 10 or more") + } +} +```