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

Ref bindings in irrefut patterns #7262

Conversation

nikomatsakis
Copy link
Contributor

Correct treatment of irrefutable patterns. The old code was wrong in many, many ways. ref bindings didn't work, it sometimes copied when it should have moved, the borrow checker didn't even look at such patterns at all, we weren't consistent about preventing values with destructors from being pulled apart, etc.

Fixes #3224.
Fixes #3225.
Fixes #3255.
Fixes #6225.
Fixes #6386.

r? @catamorphism

@catamorphism
Copy link
Contributor

I'm still at the conference but will look at this today.

@Aatch
Copy link
Contributor

Aatch commented Jun 21, 2013

@nikomatsakis @thestinger's patch conflicted with this.

@nikomatsakis
Copy link
Contributor Author

@Aatch I feared it might... will rebase...

@emberian
Copy link
Member

emberian commented Jul 7, 2013

This failed in a rusti test, segfault. Not sure if legitimate or not, and I thought the rusti tests were disabled.

@nikomatsakis
Copy link
Contributor Author

Maybe I need to rebase again.

In particular, it is not valid to go around passing uninitialized or zero'd
memory as arguments. Rust should generally be free to assume that the arguments
it gets are valid input values, but the output of intrinsics::uninit() and
intrinsics::init() are not (e.g., an @t is just null, leading to an error
if we should try to increment the ref count).
…(simpler

for cases where it's hard to decide what id to use for the lookup); modify
irrefutable bindings code to move or copy depending on the type, rather than
threading through a flag. Also updates how local variables and arguments are
registered. These changes were hard to isolate.
let and function arguments; modify type checker to store type
information for all patterns and handles some missing cases.
bors added a commit that referenced this pull request Jul 9, 2013
…rns, r=catamorphism

Correct treatment of irrefutable patterns. The old code was wrong in many, many ways. `ref` bindings didn't work, it sometimes copied when it should have moved, the borrow checker didn't even look at such patterns at all, we weren't consistent about preventing values with destructors from being pulled apart, etc.

Fixes #3224.
Fixes #3225.
Fixes #3255.
Fixes #6225.
Fixes #6386.

r? @catamorphism
@bors bors closed this Jul 9, 2013
@nikomatsakis nikomatsakis deleted the ref-bindings-in-irrefut-patterns branch March 30, 2016 16:16
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 17, 2021
…rednet,flip1995

fix `while_let_on_iterator` suggestion in a closure

fixes: rust-lang#7249

A future improvement would be to check if the closure is being used as `FnOnce`, in which case the original suggestion would be correct.

changelog: Suggest `&mut iter` inside a closure for `while_let_on_iterator`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants