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

Remove <- and <-> forms #3466

Closed
nikomatsakis opened this issue Sep 12, 2012 · 7 comments
Closed

Remove <- and <-> forms #3466

nikomatsakis opened this issue Sep 12, 2012 · 7 comments
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@nikomatsakis
Copy link
Contributor

This involves:

  • Converting a <- b to a = move b
  • Converting a <-> b to util::swap(&mut a, &mut b) or util::replace() (I suspect most uses would be better written with the latter)
  • Implementing util::swap() and util::replace() unsafely, probably by converting the arguments to unsafe pointers and then using the move_val_init intrinsic, which moves a value without dropping the previous value
@ghost ghost assigned catamorphism Oct 23, 2012
@catamorphism
Copy link
Contributor

I have a patch to remove <- that I'm just running tests on.

catamorphism added a commit to catamorphism/rust that referenced this issue Oct 23, 2012
Yield an obsolete syntax error on things like "let foo <- bar;"
and "foo <- bar;"

Progress on rust-lang#3466
catamorphism added a commit that referenced this issue Oct 23, 2012
Yield an obsolete syntax error on things like "let foo <- bar;"
and "foo <- bar;" r=brson

Progress on #3466
@catamorphism
Copy link
Contributor

Just curious, why is replace better than swap?

@catamorphism
Copy link
Contributor

There is a problem with removing <->: for example, in code that appears in pop_internal in send_map

bucket <-> self.buckets[idx];

Changing this to

swap(&mut bucket, &mut self.buckets[idx]);

doesn't work:

/Users/tchevalier/rust/src/libcore/send_map.rs:227:22: 227:38 error: illegal borrow unless pure: unique value in aliasable, mutable location
/Users/tchevalier/rust/src/libcore/send_map.rs:227             swap(&mut self.buckets[idx], &mut x);
                                                                         ^~~~~~~~~~~~~~~~
/Users/tchevalier/rust/src/libcore/send_map.rs:227:12: 227:16 note: impure due to access to impure function
/Users/tchevalier/rust/src/libcore/send_map.rs:227             swap(&mut self.buckets[idx], &mut x);

replace doesn't work either, for the same reason.

This may be a reason to keep <->. Or I guess we could cheat and make swap pure (it's going to use unsafe code anyway)? I'm not sure.

@brson
Copy link
Contributor

brson commented Oct 24, 2012

If pure functions are allowed to mutate mutable in pointers (as was discussed at some point) then swap can be pure.

@nikomatsakis
Copy link
Contributor Author

That ... is true. Interesting observation.

@catamorphism
Copy link
Contributor

Left-arrow was removed already, but removing the swap operator is blocked on #5384. De-milestoning

@thestinger
Copy link
Contributor

Fixed as by 9f106a6.

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
RalfJung pushed a commit to RalfJung/rust that referenced this issue Apr 16, 2024
add some basic support for GetFullPathNameW

This is the last missing piece to make std `path::` tests work on Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants