Skip to content

[type error] when wrongly destructing boxes of ints #105946

Closed
@matthiaskrgr

Description

@matthiaskrgr

Given the following code:

#![feature(box_syntax)]
#![feature(half_open_range_patterns_in_slices)]
fn main() {
    let [_y..] = [box 1, box 2];
}

The current output is:

error[E0425]: cannot find value `_y` in this scope
 --> 4a310255aac576a3d3d7ede99bff59ef38f2fb87.rs:4:10
  |
4 |     let [_y..] = [box 1, box 2];
  |          ^^ not found in this scope

error[E0527]: pattern requires 1 element but array has 2
 --> 4a310255aac576a3d3d7ede99bff59ef38f2fb87.rs:4:9
  |
4 |     let [_y..] = [box 1, box 2];
  |         ^^^^^^ expected 2 elements

error[E0029]: only `char` and numeric types are allowed in range patterns
 --> 4a310255aac576a3d3d7ede99bff59ef38f2fb87.rs:4:10
  |
4 |     let [_y..] = [box 1, box 2];
  |          ^^ this is of type `[type error]` but it should be `char` or numeric

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0029, E0425, E0527.
For more information about an error, try `rustc --explain E0029`.

We shouldn't show [type error] here.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions