Closed
Description
Code
fn main() {
let a = &[1, 2, 3][1:2];
}
Current output
Compiling playground v0.0.1 (/playground)
error: expected type, found `2`
--> src/main.rs:2:26
|
2 | let a = &[1, 2, 3][1:2];
| -^ expected type
| |
| tried to parse a type due to this type ascription
|
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
= note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information
error: could not compile `playground` due to previous error
Desired output
help: did you mean [1..2]?
Rationale and extra context
Having written Python for several hours, I made this mistake and couldn't realize what was wrong for a while.
Other cases
No response
Anything else?
@rustbot claim