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

implement gc in rustc #235

Closed
graydon opened this issue Feb 23, 2011 · 2 comments
Closed

implement gc in rustc #235

graydon opened this issue Feb 23, 2011 · 2 comments
Assignees
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.

Comments

@graydon
Copy link
Contributor

graydon commented Feb 23, 2011

rustc lacks a majority of the machinery required for mark/sweep gc on the kind of cyclic values. implement it.

@ghost ghost assigned marijnh Jun 21, 2011
@ghost ghost assigned pcwalton Aug 12, 2011
@pcwalton
Copy link
Contributor

First cut at this is now in my repo. What's missing:

  • Destructors need to be run. This is a good time to migrate destructors over to shapes, I think.
  • Collection of dynamically-sized allocas.
  • Windows testing. It probably breaks on Windows due to the way we use GetProcAddress.
  • Kinding. Currently all boxes are in the GC layer. We should test both GC-for-everything and GC-only-for-cyclic to see what the performance is.

@pcwalton
Copy link
Contributor

Not a blocker for 0.1 anymore, since we have cycle collection.

@graydon graydon closed this as completed Feb 14, 2012
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 30, 2015
As per [RFC rust-lang#235][rfc], you can now do:

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0235-collections-conventions.md#intoiterator-and-iterable

``` rust
let mut v = vec![1];

// iterate over immutable references
for x in &v {
    assert_eq!(x, &1);
}

// iterate over mutable references
for x in &mut v {
    assert_eq!(x, &mut 1);
}

// iterate over values, this consumes `v`
for x in v {
    assert_eq!(x, 1);
}
```

[breaking-change]s

For loops now "consume" (move) the iterator, this breaks iterating over mutable references to iterators, and also breaks multiple iterations over the same iterator:

``` rust
fn foo(mut it: &mut Iter) {  // `Iter` implements `Iterator`
    for x in it { .. }  //~ error: `&mut Iter` doesn't implement Iterator
}

fn bar() {
    for x in it { .. }  //~ note: `it` moved here
    for x in it { .. }  //~ error: `it` has been moved
}
```

Both cases can be fixed using the `by_ref()` adapter to create an iterator from the mutable reference:

``` rust
fn foo(mut it: &mut Iter) {
    for x in it.by_ref() { .. }
}

fn bar() {
    for x in it.by_ref() { .. }
    for x in it { .. }
}
```

This PR also makes iterator non-implicitly copyable, as this was source of subtle bugs in the libraries. You can still use `clone()` to explictly copy the iterator.

Finally, since the for loops are implemented in the frontend and use global paths to `IntoIterator`, `Iterator` and `Option` variants, users of the `core` crate will have to use add an `std` module to the root of their crate to be able to use for loops:

``` rust
#![no_std]

extern crate core;

fn main() {
    for x in 0..10 {}
}

#[doc(hidden)]
mod std {
    // these imports are needed to use for-loops
    pub use core::iter;
    pub use core::option;
}
```

---

r? @nikomatsakis @aturon
cc rust-lang#18424
closes rust-lang#18045
oli-obk added a commit to oli-obk/rust that referenced this issue Jul 19, 2017
Implement some missing intrinsics
keeperofdakeys pushed a commit to keeperofdakeys/rust that referenced this issue Dec 12, 2017
Also move F_DUPFD_CLOEXEC up a level as it is available on Android.

This commit leaves file sealing related fcntls and bitflag constants
out, as they are defined in `linux/fcntl.h` rather than `fcntl.h`. They
can be included once an approach for verification has been figured out.
See rust-lang#235 for more detail.
kazcw pushed a commit to kazcw/rust that referenced this issue Oct 23, 2018
dlrobertson pushed a commit to dlrobertson/rust that referenced this issue Nov 29, 2018
ZuseZ4 pushed a commit to EnzymeAD/rust that referenced this issue Mar 7, 2023
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
For consistency with LLVM semantics, only codegen an implicit memcpy when the length is nonzero.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.
Projects
None yet
Development

No branches or pull requests

3 participants