Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error_handling/errorsn.rs uses deprecated Trait - related syntax #211

Closed
sosnowski opened this issue Aug 20, 2019 · 0 comments · Fixed by #212
Closed

error_handling/errorsn.rs uses deprecated Trait - related syntax #211

sosnowski opened this issue Aug 20, 2019 · 0 comments · Fixed by #212

Comments

@sosnowski
Copy link
Contributor

Hi!

I've noticed, that the exercise:

/exercises/error_handling/errorsn.rs is using a deprecated syntax for traits related values.
It causes the compiler to display warning messages:

rustlings run exercises/error_handling/errorsn.rs
! Compiling of exercises/error_handling/errorsn.rs failed! Please try again. Here's the output:
warning: trait objects without an explicit `dyn` are deprecated
  --> exercises/error_handling/errorsn.rs:23:30
   |
23 | fn read_and_validate(b: &mut io::BufRead) -> Result<PositiveNonzeroInteger, Box<error::Error>> {
   |                              ^^^^^^^^^^^ help: use `dyn`: `dyn io::BufRead`
   |
   = note: #[warn(bare_trait_objects)] on by default

warning: trait objects without an explicit `dyn` are deprecated
  --> exercises/error_handling/errorsn.rs:23:81
   |
23 | fn read_and_validate(b: &mut io::BufRead) -> Result<PositiveNonzeroInteger, Box<error::Error>> {
   |                                                                                 ^^^^^^^^^^^^ help: use `dyn`: `dyn error::Error`

warning: trait objects without an explicit `dyn` are deprecated
  --> exercises/error_handling/errorsn.rs:32:65
   |
32 | fn test_with_str(s: &str) -> Result<PositiveNonzeroInteger, Box<error::Error>> {
   |                                                                 ^^^^^^^^^^^^ help: use `dyn`: `dyn error::Error`

warning: trait objects without an explicit `dyn` are deprecated
   --> exercises/error_handling/errorsn.rs:101:31
    |
101 |         f.write_str((self as &error::Error).description())
    |                               ^^^^^^^^^^^^ help: use `dyn`: `dyn error::Error`

Probably the solution is as simple as changing Box<Trait> to a recomended Box<dyn Trait> (or maybe impl Trait is better?

I will prepare a simple pull request with a fix.
I'm fairly new to Rust, so if what I'm saying does not make sense, just let me know ;)

rustc 1.37.0 (eae3437df 2019-08-13)
rustlings 1.4.1

sosnowski added a commit to sosnowski/rustlings-1 that referenced this issue Aug 20, 2019
sosnowski added a commit to sosnowski/rustlings-1 that referenced this issue Aug 21, 2019
@bors bors closed this as completed in f9987c8 Aug 21, 2019
@bors bors closed this as completed in #212 Aug 21, 2019
cedrickchee pushed a commit to cedrickchee/rustlings-solutions that referenced this issue Nov 15, 2019
fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait o…

fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait objects.

closes #211

Related issue: rust-lang/rustlings#211
pedantic79 pushed a commit to pedantic79/rustlings that referenced this issue Apr 11, 2020
panthervis added a commit to panthervis/rustlings that referenced this issue Oct 8, 2021
fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait o…

fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait objects.

closes #211

Related issue: rust-lang/rustlings#211
ppp3 pushed a commit to ppp3/rustlings that referenced this issue May 23, 2022
ppp3 pushed a commit to ppp3/rustlings that referenced this issue May 23, 2022
fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait o…

fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait objects.

closes rust-lang#211

Related issue: rust-lang#211
FancyGeekGuru added a commit to FancyGeekGuru/rust-lings that referenced this issue May 24, 2022
fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait o…

fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait objects.

closes #211

Related issue: rust-lang/rustlings#211
dmoore04 pushed a commit to dmoore04/rustlings that referenced this issue Sep 11, 2022
dmoore04 pushed a commit to dmoore04/rustlings that referenced this issue Sep 11, 2022
fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait o…

fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait objects.

closes rust-lang#211

Related issue: rust-lang#211
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant