Commit Graph

24267 Commits

Author SHA1 Message Date
klutzy
a130861d31 std::rt: Fix record_stack_bounds on win64 2013-11-24 19:15:09 +09:00
klutzy
52c8c1daba llvm: Disable pthreads on mingw-w64 platforms 2013-11-24 19:15:08 +09:00
klutzy
561277d791 std: Fix transmute error on win64 2013-11-24 19:15:05 +09:00
klutzy
e1091fd412 std::libc: Simplify win32/win64 type definitions 2013-11-24 19:08:41 +09:00
klutzy
8d990c3aaf std::libc: Remove TCHAR types 2013-11-24 19:08:40 +09:00
bors
ce45bb7f44 auto merge of #10625 : huonw/rust/json-errors, r=alexcrichton
Fixes #4244.
2013-11-24 01:26:30 -08:00
bors
738eb9b930 auto merge of #10620 : cmr/rust/linker_opts, r=thestinger 2013-11-23 23:56:30 -08:00
bors
9ba473f86f auto merge of #10578 : luqmana/rust/mingw64, r=alexcrichton
With these changes I was able to cross compile for windows from a linux box. (Using the mingw-w64 package on Debian Testing).

Fixed a bug where the `target_family` cfg would be wrong when targeting something with a different value than the host. (i.e windows -> unix or unix -> windows).

Also, removed `LIBUV_FLAGS` in `mk/rt.mk` because of the redundancy between it and `CFG_GCCISH_CFLAGS_(target)`.

After this we can create a snapshot and migrate to mingw64 instead of mingw32.
2013-11-23 21:36:50 -08:00
bors
33375a31e8 auto merge of #10514 : sfackler/rust/mut, r=cmr
This is based off of @blake2-ppc's work on #9429. That PR bitrotted and I haven't been able to contact the original author so I decided to take up the cause.

Overview
======
`Mut` encapsulates a mutable, non-nullable slot. The `Cell` type is currently used to do this, but `Cell` is much more commonly used as a workaround for the inability to move values into non-once functions. `Mut` provides a more robust API.

`Mut` duplicates the semantics of borrowed pointers with enforcement at runtime instead of compile time.
```rust
let x = Mut::new(0);

{
    // make some immutable borrows
    let p = x.borrow();
    let y = *p.get() + 10;

    // multiple immutable borrows are allowed simultaneously
    let p2 = x.borrow();

    // this would throw a runtime failure
    // let p_mut = x.borrow_mut();
}

// now we can mutably borrow
let p = x.borrow_mut();
*p.get() = 10;
```
`borrow` returns a `Ref` type and `borrow_mut` returns a `RefMut` type, both of which are simple smart pointer types with a single method, `get`, which returns a reference to the wrapped data.

This also allows `RcMut<T>` to be deleted, as it can be replaced with `Rc<Mut<T>>`.

Changes
======
I've done things a little bit differently than the original proposal.

* I've added `try_borrow` and `try_borrow_mut` methods that return `Option<Ref<T>>` and `Option<RefMut<T>>` respectively instead of failing on a borrow check failure. I'm not totally sure when that'd be useful, but I don't see any reason to not put them in and @cmr requested them.
* `ReadPtr` and `WritePtr` have been renamed to `Ref` and `RefMut` respectively, as `Ref` is to `ref foo` and `RefMut` is to `ref mut foo` as `Mut` is to `mut foo`.
* `get` on `MutRef` now takes `&self` instead of `&mut self` for consistency with `&mut`. As @alexcrichton pointed, out this violates soundness by allowing aliasing `&mut` references.
* `Cell` is being left as is. It solves a different problem than `Mut` is designed to solve.
* There are no longer methods implemented for `Mut<Option<T>>`. Since `Cell` isn't going away, there's less of a need for these, and I didn't feel like they provided a huge benefit, especially as that kind of `impl` is very uncommon in the standard library.

Open Questions
============
* `Cell` should now be used exclusively for movement into closures. Should this be enforced by reducing its API to `new` and `take`? It seems like this use case will be completely going away once the transition to `proc` and co. finishes.
* Should there be `try_map` and `try_map_mut` methods along with `map` and `map_mut`?
2013-11-23 20:01:42 -08:00
Huon Wilson
b052f28fd6 extra: improve the errors for the JSON Decoder.
Fixes #4244.
2013-11-24 10:34:27 +11:00
Steven Fackler
bdfaf04bd5 Move mutable::Mut to cell::RefCell 2013-11-23 13:45:05 -08:00
Corey Richardson
672549372c Use linker optimizations on Linux 2013-11-23 10:03:41 -05:00
Luqman Aden
ae5a13d643 Use CXX not CC for linking. 2013-11-23 04:49:16 -05:00
bors
6cbc57cadb auto merge of #10611 : cmr/rust/ascii_flesh, r=pcwalton
These are super boring. I can add tests if really desired, but they'd be long
and even more boring than the methods.
2013-11-22 23:06:24 -08:00
Corey Richardson
09af9d4856 Add ctype-likes to Ascii 2013-11-23 02:01:10 -05:00
Luqman Aden
84403eb897 Remove sjlj stuff from rust_upcall and don't pass -Werror to libuv. 2013-11-22 22:04:36 -08:00
Steven Fackler
c6ca9abcc6 Add Rc::from_mut 2013-11-22 21:19:53 -08:00
Steven Fackler
48cd8c646a More Mut tests 2013-11-22 21:19:53 -08:00
Steven Fackler
5759f2fc57 Strip down Cell functionality 2013-11-22 21:19:53 -08:00
Steven Fackler
8a26266f65 Change Mut::map to Mut::with 2013-11-22 21:19:53 -08:00
Steven Fackler
bb39cc3ae6 Make MutRef more consistent with &mut 2013-11-22 21:19:53 -08:00
Steven Fackler
2e4bb2b9e9 Cell -> Mut switch in comm 2013-11-22 21:19:53 -08:00
Steven Fackler
18119afbbe Move Rc tests away from Cell 2013-11-22 21:19:53 -08:00
Steven Fackler
7c9daa8ff7 Remove RcMut
Rc<Mut<T>> should be used instead
2013-11-22 21:19:53 -08:00
Steven Fackler
0fade3a714 Introduce Mut<T> to libstd
Based off of blake2-ppc's work in #9429.
2013-11-22 21:19:53 -08:00
Luqman Aden
a2c111abde mk: Get rid of redundant LIBUV_FLAGS. 2013-11-22 20:39:58 -05:00
Luqman Aden
6820ed4dcf Fix up mingw64 target. 2013-11-22 20:39:58 -05:00
bors
fb279aa02a auto merge of #10605 : huonw/rust/ascii-ident-gate, r=pcwalton
cf. https://mail.mozilla.org/pipermail/rust-dev/2013-November/006920.html
2013-11-22 13:51:34 -08:00
Huon Wilson
ab2a99f699 Put non-ascii identifiers behind a feature gate.
cf. https://mail.mozilla.org/pipermail/rust-dev/2013-November/006920.html
2013-11-23 08:18:50 +11:00
bors
09ed7913e4 auto merge of #10612 : pnkfelix/rust/remove-cut-and-pasted-rt-fixme, r=pcwalton
I cannot tell whether the original comment was unsure about the
arithmetic calculations, or if it was unsure about the assumptions
being made about the alignment of the current allocation pointer.

The arithmetic calculation looks fine to me, though.  This technique
is documented e.g. in Henry Warren's "Hacker's Delight" (section 3-1).

(I am sure one can find it elsewhere too, its not an obscure
property.)
2013-11-22 12:41:36 -08:00
bors
cd9069ca73 auto merge of #10583 : alexcrichton/rust/privacy-reexport, r=pcwalton
I added a test case which does not compile today, and required changes on
privacy's side of things to get right. Additionally, this moves a good bit of
logic which did not belong in reachability into privacy.

All of reachability should solely be responsible for determining what the
reachable surface area of a crate is given the exported surface area (where the
exported surface area is that which is usable by external crates).

Privacy will now correctly figure out what's exported by deeply looking
through reexports. Previously if a module were reexported under another name,
nothing in the module would actually get exported in the executable. I also
consolidated the phases of privacy to be clearer about what's an input to what.
The privacy checking pass no longer uses the notion of an "all public" path, and
the embargo visitor is no longer an input to the checking pass.

Currently the embargo visitor is built as a saturating analysis because it's
unknown what portions of the AST are going to get re-exported.

This also cracks down on exported methods from impl blocks and trait blocks. If you implement a private trait, none of the symbols are exported, and if you have an impl for a private type none of the symbols are exported either. On the other hand, if you implement a public trait for a private type, the symbols are still exported. I'm unclear on whether this last part is correct, but librustc will fail to link unless it's in place.
2013-11-22 10:06:35 -08:00
Alex Crichton
93a0dec202 Move more of the exportation burden into privacy
I added a test case which does not compile today, and required changes on
privacy's side of things to get right. Additionally, this moves a good bit of
logic which did not belong in reachability into privacy.

All of reachability should solely be responsible for determining what the
reachable surface area of a crate is given the exported surface area (where the
exported surface area is that which is usable by external crates).

Privacy will now correctly figure out what's exported by deeply looking
through reexports. Previously if a module were reexported under another name,
nothing in the module would actually get exported in the executable. I also
consolidated the phases of privacy to be clearer about what's an input to what.
The privacy checking pass no longer uses the notion of an "all public" path, and
the embargo visitor is no longer an input to the checking pass.

Currently the embargo visitor is built as a saturating analysis because it's
unknown what portions of the AST are going to get re-exported.
2013-11-22 10:02:10 -08:00
Felix S. Klock II
861e6f5cd2 The original fixme #2699 was removed back in PR #6053.
I cannot tell whether the original comment was unsure about the
arithmetic calculations, or if it was unsure about the assumptions
being made about the alignment of the current allocation pointer.

The arithmetic calculation looks fine to me, though.  This technique
is documented e.g. in Henry Warren's "Hacker's Delight" (section 3-1).

(I am sure one can find it elsewhere too, its not an obscure
property.)
2013-11-22 18:00:21 +01:00
bors
d3cb24b1fe auto merge of #10610 : thestinger/rust/breakpoint, r=pnkfelix
This can be used to grab the attention of a debugger, and unlike
`abort` execution can be resumed.
2013-11-22 07:31:35 -08:00
Daniel Micay
bf61641e9f add a breakpoint intrinsic for debugging
This can be used to grab the attention of a debugger, and unlike
`abort` execution can be resumed.
2013-11-22 10:29:04 -05:00
bors
cad1f89bb5 auto merge of #10608 : thestinger/rust/managed, r=huonw 2013-11-22 05:52:01 -08:00
bors
a9b1dcf24a auto merge of #10606 : huonw/rust/lint-unsafe-in-macro, r=thestinger
Add a test for the case I mentioned on #10599.
2013-11-22 04:41:33 -08:00
Huon Wilson
efe9d744f9 syntax: add a visit_ident method to the Visitor. 2013-11-22 23:24:49 +11:00
Daniel Micay
7d9fd62300 minor rewording in the tutorial's Rc coverage 2013-11-22 07:03:11 -05:00
Daniel Micay
d97ce15c14 mention Gc in the managed box feature gate 2013-11-22 07:02:56 -05:00
bors
8d87e9da21 auto merge of #10582 : g3xzh/rust/master, r=cmr
More new benchmark tests. some of them are benchmarking `starts_with` and `ends_with`.
Let me know if I am missing something.
Thanks in advance.
2013-11-22 03:31:37 -08:00
g3xzh
80dff18641 Add more benchmark tests to vec.rs
New benchmark tests in vec.rs:
`push`, `starts_with_same_vector`, `starts_with_single_element`,
`starts_with_diff_one_element_end`, `ends_with_same_vector`,
`ends_with_single_element`, `ends_with_diff_one_element_beginning` and
`contains_last_element`
2013-11-22 13:24:16 +02:00
Huon Wilson
971d306fe2 test: test that the unsafe_block lint picks up unsafe blocks in
macros.
2013-11-22 22:23:04 +11:00
bors
747213a280 auto merge of #10588 : huonw/rust/un@mutilate-task_rng, r=alexcrichton
Replace with some unsafe code by storing a pointer into TLS-owned heap
data.
2013-11-21 21:51:26 -08:00
Huon Wilson
020126ef75 std::rand: move TaskRng off @mut.
Replace with some unsafe code by storing a pointer into TLS-owned heap
data.
2013-11-22 16:47:01 +11:00
bors
1dea21f41d auto merge of #10599 : thestinger/rust/unsafe, r=cmr
This is just meant to be for containing usage of `unsafe`, much like `heap_memory`.
2013-11-21 17:26:31 -08:00
bors
6143400aaa auto merge of #10589 : thestinger/rust/doc, r=pcwalton
This replaces the old section on managed pointers because the syntax is
going to be removed and it's currently feature gated so the examples
don't work out-of-the-box. Dynamic mutability coverage can be added
after the `Mut<T>` work has landed.
2013-11-21 16:06:32 -08:00
Daniel Micay
c06ce4c9bf tutorial: alternatives to ownership
This replaces the old section on managed pointers because the syntax is
going to be removed and it's currently feature gated so the examples
don't work out-of-the-box. Dynamic mutability coverage can be added
after the `Mut<T>` work has landed.
2013-11-21 18:00:31 -05:00
Daniel Micay
a1afe9cc0a add lint for unsafe blocks 2013-11-21 17:58:49 -05:00
bors
76d4848050 auto merge of #10598 : alexcrichton/rust/rustdoc, r=thestinger
This prevents an assertion from being tripped because the generics weren't
categorized.

Closes #10597
2013-11-21 14:56:37 -08:00