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

Shouldn't be able to let-pattern-unwrap structs with dtors #3218

Closed
bblum opened this issue Aug 17, 2012 · 1 comment
Closed

Shouldn't be able to let-pattern-unwrap structs with dtors #3218

bblum opened this issue Aug 17, 2012 · 1 comment

Comments

@bblum
Copy link
Contributor

bblum commented Aug 17, 2012

struct X {
    x: ~str;
    drop {
        error!("destructing wrapper");
        error!("value: %s", self.x);
    }
}

fn foo(+x: X) -> ~str {
    let X { x: y } = x;
    error!("unwrapped it");
    y
}

fn main() {
    let x = X { x: ~"hello" };
    let y = foo(x);
    error!("got inner");
    error!("contents: %s", y);
}

prints:

rust: ~"unwrapped it"
rust: ~"destructing wrapper"
Segmentation fault (core dumped)
@bblum
Copy link
Contributor Author

bblum commented Aug 20, 2012

oops, dup of #3147

@bblum bblum closed this as completed Aug 20, 2012
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
Changes required due to:
- rust-lang/rust@a34c26e7ec Make body_owned_by return the body directly.
- rust-lang/rust@333458c2cb Uplift TypeRelation and Relate
- rust-lang/rust@459ce3f6bb Add an intrinsic for `ptr::metadata`
- rust-lang/rust@7e08f80b34 Split smir `Const` into `TyConst` and
`MirConst`
- rust-lang/rust@eb584a23bf offset_of: allow (unstably) taking the
offset of slice tail fields
- rust-lang/rust@16e8803579 Update cargo

Resolves: rust-lang#3218
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

No branches or pull requests

1 participant