- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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 errorDesired 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
tgross35, dgiger42, thecatcore, sourcefrog and nanoqsh
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.