Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Values should be moved in deconstructed arguments #12534

Closed
qpliu opened this issue Feb 25, 2014 · 3 comments
Closed

Values should be moved in deconstructed arguments #12534

qpliu opened this issue Feb 25, 2014 · 3 comments
Milestone

Comments

@qpliu
Copy link
Contributor

qpliu commented Feb 25, 2014

This compiles without error:

struct A(~uint);

fn fail(a@A(u): A) -> ~uint {
    let _ = a;
    u
}
@alexcrichton
Copy link
Member

Seems bad. Nominating.

@pnkfelix
Copy link
Member

Assigning 1.0, P-backcompat-lang.

pcwalton added a commit to pcwalton/rust that referenced this issue Jun 24, 2014
bindings.

This will break code that incorrectly did things like:

    fn f(a @ box b: Box<String>) {}

Fix such code to not rely on undefined behavior.

Closes rust-lang#12534.

[breaking-change]
@dvmason
Copy link

dvmason commented Apr 16, 2016

This is very unfortunate, as code that is common in Haskell or Elixir is much uglier in Rust.

The following function doesn't type:

fn merge(l1 : Vec<(String,u32)>, l2 : Vec<(String,u32)>) -> Vec<(String,u32)> {
    let d1 = l1.drain(..);
    let d2 = l2.drain(..);
    let result = Vec::new();
    let mut v1 = d1.next();
    let mut v2 = d2.next();
    loop {
        match (v1,v2) {
            (None,None) => return result,
            (None,Some(x)) => {result.push(x);v2=d2.next()},
            (Some(x),None) => {result.push(x);v1=d1.next()},
            (Some(p1@(s1,t1)),Some(p2@(s2,t2))) => {
                if s1==s2 {
                    result.push((s1,t1+t2));
                    v1=d1.next();
                    v2=d2.next();
                } else if s1<s2 {
                    result.push(p1);
                    v1=d1.next();
                } else {
                    result.push(p2);
                    v2=d2.next();
                }
            },
        }
    }
}

flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 4, 2024
Fix typo in exhaustive_items.rs

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants