-
Notifications
You must be signed in to change notification settings - Fork 130
Description
Contrary to what we had thought, dashboard examples should be run using Rust 2015 edition by default, unless otherwise noted:
https://doc.rust-lang.org/edition-guide/rust-2015/index.html
Since it's the default edition, there's no way to port your code to Rust 2015; it just is. You'll be transitioning away from 2015, but never really to 2015. As such, there's not much else to say about it!
This is a bit counter-intuitive since only 4 examples out of the ~700 ones that we run specify the 2015 edition as a requirement. The rest do not specify the edition. Take for example Rust by Example/Functions/Closures/Examples in std/Iterator::any/22.rs, which is currently failing while using edition 2021:
stderr:
error[E0308]: mismatched types
--> src/test/dashboard/books/Rust by Example/Functions/Closures/Examples in std/Iterator::any/22.rs:19:57
|
19 | println!("2 in array2: {}", array2.into_iter().any(|&x| x == 2));
| ^--
| ||
| |expected due to this
| expected integer, found reference
| help: did you mean `x`: `&{integer}`
|
= note: expected type `{integer}`
found reference `&_`
error: aborting due to previous error
This does not happen when using the 2015 edition. So it is probably the best to:
- Not use any edition by default (this is essentially defaulting to 2015).
- Use an edition only if specified in the example (such cases do not exist at the moment except for the 4 mentioned examples, which use Rust 2015 anyway).