Skip to content

Slice/Array patterns are not correctly move checked #66502

Closed
@matthewjasper

Description

@matthewjasper
Contributor

The following should error, but doesn't

#![feature(slice_patterns)]

fn main() {
    let a = [String::from("HELLO"), String::from("WORLD")];
    let [_, mut x] = a;
    x = String::from("RUST");
    let [ref y @ ..] = a;
    println!("{:?}", y); 
}

Activity

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
A-slice-patternsArea: Slice patterns, https://github.com/rust-lang/rust/issues/23121
C-bugCategory: This is a bug.
requires-nightlyThis issue requires a nightly compiler in some way.
on Nov 17, 2019
jonas-schievink

jonas-schievink commented on Nov 17, 2019

@jonas-schievink
Contributor
matthewjasper

matthewjasper commented on Nov 21, 2019

@matthewjasper
ContributorAuthor

This doesn't require nightly:

#![allow(unused)]

fn main() {
    let a = [(String::from("HELLO"), String::from("WORLD"))];
    let [mut x] = a;
    x = (String::from("GOODBYE"), String::from("RUST"));
    let [(ref y, ref z)] = a;
    println!("{:?}", (y, z));
}

playground

changed the title [-]Slice patterns are not correctly move checked[/-] [+]Slice/Array patterns are not correctly move checked[/+] on Nov 21, 2019
added a commit that references this issue on Dec 11, 2019

Auto merge of #66650 - matthewjasper:nonuniform-array-move, r=pnkfelix

de0abf7

4 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-borrow-checkerArea: The borrow checkerA-slice-patternsArea: Slice patterns, https://github.com/rust-lang/rust/issues/23121C-bugCategory: This is a bug.F-slice_patterns`#![feature(slice_patterns)]`I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-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

    Participants

    @jonas-schievink@matthewjasper

    Issue actions

      Slice/Array patterns are not correctly move checked · Issue #66502 · rust-lang/rust