Commit graph

102 commits

Author SHA1 Message Date
Alex Crichton
f94d671bfa core: Remove the cast module
This commit revisits the `cast` module in libcore and libstd, and scrutinizes
all functions inside of it. The result was to remove the `cast` module entirely,
folding all functionality into the `mem` module. Specifically, this is the fate
of each function in the `cast` module.

* transmute - This function was moved to `mem`, but it is now marked as
              #[unstable]. This is due to planned changes to the `transmute`
              function and how it can be invoked (see the #[unstable] comment).
              For more information, see RFC 5 and #12898

* transmute_copy - This function was moved to `mem`, with clarification that is
                   is not an error to invoke it with T/U that are different
                   sizes, but rather that it is strongly discouraged. This
                   function is now #[stable]

* forget - This function was moved to `mem` and marked #[stable]

* bump_box_refcount - This function was removed due to the deprecation of
                      managed boxes as well as its questionable utility.

* transmute_mut - This function was previously deprecated, and removed as part
                  of this commit.

* transmute_mut_unsafe - This function doesn't serve much of a purpose when it
                         can be achieved with an `as` in safe code, so it was
                         removed.

* transmute_lifetime - This function was removed because it is likely a strong
                       indication that code is incorrect in the first place.

* transmute_mut_lifetime - This function was removed for the same reasons as
                           `transmute_lifetime`

* copy_lifetime - This function was moved to `mem`, but it is marked
                  `#[unstable]` now due to the likelihood of being removed in
                  the future if it is found to not be very useful.

* copy_mut_lifetime - This function was also moved to `mem`, but had the same
                      treatment as `copy_lifetime`.

* copy_lifetime_vec - This function was removed because it is not used today,
                      and its existence is not necessary with DST
                      (copy_lifetime will suffice).

In summary, the cast module was stripped down to these functions, and then the
functions were moved to the `mem` module.

    transmute - #[unstable]
    transmute_copy - #[stable]
    forget - #[stable]
    copy_lifetime - #[unstable]
    copy_mut_lifetime - #[unstable]

[breaking-change]
2014-05-11 01:13:02 -07:00
Daniel Micay
138437956c initial port of the exchange allocator to jemalloc
In stage0, all allocations are 8-byte aligned. Passing a size and
alignment to free is not yet implemented everywhere (0 size and 8 align
are used as placeholders). Fixing this is part of #13994.

Closes #13616
2014-05-10 19:58:17 -04:00
Daniel Micay
03a5eb4b52 add an align parameter to exchange_malloc
Closes #13094
2014-05-10 19:58:17 -04:00
Patrick Walton
090040bf40 librustc: Remove ~EXPR, ~TYPE, and ~PAT from the language, except
for `~str`/`~[]`.

Note that `~self` still remains, since I forgot to add support for
`Box<self>` before the snapshot.

How to update your code:

* Instead of `~EXPR`, you should write `box EXPR`.

* Instead of `~TYPE`, you should write `Box<Type>`.

* Instead of `~PATTERN`, you should write `box PATTERN`.

[breaking-change]
2014-05-06 23:12:54 -07:00
Huon Wilson
781ac3e777 std: deprecate cast::transmute_mut.
Turning a `&T` into an `&mut T` carries a large risk of undefined
behaviour, and needs to be done very very carefully. Providing a
convenience function for exactly this task is a bad idea, just tempting
people into doing the wrong thing.

The right thing is to use types like `Cell`, `RefCell` or `Unsafe`.

For memory safety, Rust has that guarantee that `&mut` pointers do not
alias with any other pointer, that is, if you have a `&mut T` then that
is the only usable pointer to that `T`. This allows Rust to assume that
writes through a `&mut T` do not affect the values of any other `&` or
`&mut` references. `&` pointers have no guarantees about aliasing or
not, so it's entirely possible for the same pointer to be passed into
both arguments of a function like

    fn foo(x: &int, y: &int) { ... }

Converting either of `x` or `y` to a `&mut` pointer and modifying it
would affect the other value: invalid behaviour.

(Similarly, it's undefined behaviour to modify the value of an immutable
local, like `let x = 1;`.)

At a low-level, the *only* safe way to obtain an `&mut` out of a `&` is
using the `Unsafe` type (there are higher level wrappers around it, like
`Cell`, `RefCell`, `Mutex` etc.). The `Unsafe` type is registered with
the compiler so that it can reason a little about these `&` to `&mut`
casts, but it is still up to the user to ensure that the `&mut`s
obtained out of an `Unsafe` never alias.

(Note that *any* conversion from `&` to `&mut` can be invalid, including
a plain `transmute`, or casting `&T` -> `*T` -> `*mut T` -> `&mut T`.)

[breaking-change]
2014-05-05 18:20:41 +10:00
Brian Anderson
a5be12ce7e Replace most ~exprs with 'box'. #11779 2014-05-02 23:00:58 -07:00
Richo Healey
919889a1d6 Replace all ~"" with "".to_owned() 2014-04-18 17:25:34 -07:00
John Simon
133834084e Replace 'region' with 'lifetime' in a few transmute function names 2014-04-13 17:42:00 -04:00
Liigo Zhuang
408f484b66 libtest: rename BenchHarness to Bencher
Closes #12640
2014-04-11 17:31:13 +08:00
Alex Crichton
d250ec0bdd Register new snapshots 2014-04-04 13:23:08 -07:00
bors
2a2d0dce87 auto merge of #13296 : brson/rust/0.11-pre, r=alexcrichton
This also changes some of the download links in the documentation
to 'nightly'.
2014-04-03 19:56:45 -07:00
bors
e7fe207229 auto merge of #13290 : alexcrichton/rust/rollup, r=alexcrichton
Closes #13285 (rustc: Stop using LLVMGetSectionName)
Closes #13280 (std: override clone_from for Vec.)
Closes #13277 (serialize: add a few missing pubs to base64)
Closes #13275 (Add and remove some ignore-win32 flags)
Closes #13273 (Removed managed boxes from libarena.)
Closes #13270 (Minor copy-editing for the tutorial)
Closes #13267 (fix Option<~ZeroSizeType>)
Closes #13265 (Update emacs mode to support new `#![inner(attribute)]` syntax.)
Closes #13263 (syntax: Remove AbiSet, use one Abi)
2014-04-03 17:17:02 -07:00
Brian Anderson
0875ffcbff Bump version to 0.11-pre
This also changes some of the download links in the documentation
to 'nightly'.
2014-04-03 16:28:46 -07:00
bors
bb31cb8d2e auto merge of #13286 : alexcrichton/rust/release, r=brson
Merging the 0.10 release into the master branch.
2014-04-03 13:52:03 -07:00
Benjamin Adamson
2ae292473e Removed managed boxes from libarena. 2014-04-03 13:43:09 -07:00
Alex Crichton
c9024d2922 arena: Switch field privacy as necessary 2014-03-31 15:47:35 -07:00
Alex Crichton
a5681d2590 Bump version to 0.10 2014-03-31 14:40:44 -07:00
bors
d878df05ad auto merge of #13183 : erickt/rust/remove-list, r=alexcrichton
`collections::list::List` was decided in a [team meeting](https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-03-25) that it was unnecessary, so this PR removes it. Additionally, it removes an old and redundant purity test and fixes some warnings.
2014-03-29 11:41:37 -07:00
Brian Anderson
451e8c1c61 Convert most code to new inner attribute syntax.
Closes #2569
2014-03-28 17:12:21 -07:00
Erick Tryzelaar
a47d52c2f6 collections: remove List
It was decided in a meeting that this module wasn't needed,
and more thought should be put into a persistent collections
library.
2014-03-28 09:13:09 -07:00
Flavio Percoco
81ec1f3c18 Rename Pod into Copy
Summary:
So far, we've used the term POD "Plain Old Data" to refer to types that
can be safely copied. However, this term is not consistent with the
other built-in bounds that use verbs instead. This patch renames the Pod
kind into Copy.

RFC: 0003-opt-in-builtin-traits

Test Plan: make check

Reviewers: cmr

Differential Revision: http://phabricator.octayn.net/D3
2014-03-28 10:34:02 +01:00
Flavio Percoco
576e36e674 Register new snapshots 2014-03-23 11:37:31 +01:00
bors
7e7a5e3d3e auto merge of #13076 : FlaPer87/rust/remove-freeze, r=alexcrichton
This PR removes the `Freeze` kind and the `NoFreeze` marker completely.

Fixes #12577

cc @nikomatsakis r?
2014-03-22 13:01:52 -07:00
Alex Crichton
9a37416dbe arena: Fix fallout of removing get() 2014-03-22 08:48:20 -07:00
Flavio Percoco
392348f347 arena: Remove Freeze / NoFreeze 2014-03-22 15:47:33 +01:00
Huon Wilson
6d778ff610 Remove outdated and unnecessary std::vec_ng::Vec imports.
(And fix some tests.)
2014-03-22 01:08:57 +11:00
Patrick Walton
af79a5aa7d test: Make manual changes to deal with the fallout from removal of
`~[T]` in test, libgetopts, compiletest, librustdoc, and libnum.
2014-03-21 23:37:21 +11:00
Alex Crichton
84a91b8603 syntax: Tidy up parsing the new attribute syntax 2014-03-20 18:51:52 -07:00
Alex Crichton
da3625161d Removing imports of std::vec_ng::Vec
It's now in the prelude.
2014-03-20 09:30:14 -07:00
Daniel Micay
ce620320a2 rename std::vec -> std::slice
Closes #12702
2014-03-20 01:30:27 -04:00
Steven Fackler
9106c15ffd Add rustdoc html crate info 2014-03-15 14:26:12 -07:00
Huon Wilson
62792f09f2 lint: add lint for use of a ~[T].
This is useless at the moment (since pretty much every crate uses
`~[]`), but should help avoid regressions once completely removed from a
crate.
2014-03-14 11:28:39 +11:00
Eduard Burtescu
cdc18b96d6 Remove Rc's borrow method to avoid conflicts with RefCell's borrow in Rc<RefCell<T>>. 2014-03-13 14:21:45 +02:00
Bruno de Oliveira Abinader
0c8731e65c Replaced list::each with iter() in Arenas's Drop impl 2014-02-27 08:35:18 -04:00
Huon Wilson
9e8d5aa29e arena,std,serialize: remove some unnecessary transmutes.
`as`-able transmutes, duplication and manual slice decomposition are
silly.
2014-02-24 01:15:39 +11:00
Brian Anderson
4d10bdc5b9 std: Move intrinsics to std::intrinsics.
Issue #1457
2014-02-23 01:07:53 -08:00
Daniel Micay
4687e1d67d remove the TyDesc from TypedArena
This prevents generating visit glue when using a TypedArena. The problem
still exists for the untyped Arena.
2014-02-22 02:04:25 -05:00
Liigo Zhuang
53b9d1a324 move extra::test to libtest 2014-02-20 16:03:58 +08:00
Alex Crichton
a41b0c2529 extern mod => extern crate
This was previously implemented, and it just needed a snapshot to go through
2014-02-14 22:55:21 -08:00
Michael Darakananda
bf1464c413 Removed num::Orderable 2014-02-13 20:12:59 -05:00
JeremyLetang
60bc76fb78 remove duplicate function from std::ptr (is_null, is_not_null, offset, mut_offset) 2014-02-13 12:54:17 -08:00
Edward Wang
e9ff91e9be Move replace and swap to std::mem. Get rid of std::util
Also move Void to std::any, move drop to std::mem and reexport in
prelude.
2014-02-11 05:21:35 +08:00
Brian Anderson
c7710cdf45 std: Add move_val_init to mem. Replace direct intrinsic usage 2014-02-09 00:17:41 -08:00
Huon Wilson
38447344f1 arena: use the generic bh.iter to stop the benchmarks being DCE'd.
Before:

    test test::bench_nonpod_nonarena  ... bench:        62 ns/iter (+/- 6)
    test test::bench_pod_nonarena     ... bench:         0 ns/iter (+/- 0)

After:

    test test::bench_nonpod_nonarena  ... bench:       158 ns/iter (+/- 11)
    test test::bench_pod_nonarena     ... bench:        48 ns/iter (+/- 2)

The other tests show no change, but are adjusted to use the generic
return value of `.iter` anyway so that this doesn't change in future.
2014-02-09 12:31:45 +11:00
Daniel Micay
eced501226 allow generating drop glue without the TyDesc
Reflection is now the only user of type descriptors. Uses of drop glue
no longer cause a type descriptor to be generated.
2014-02-07 21:20:43 -05:00
HeroesGrave
d81bb441da moved collections from libextra into libcollections 2014-02-07 19:49:26 +13:00
Huon Wilson
f63c3fba4c arena: stop using @[]. 2014-02-02 02:59:03 +11:00
bors
1d494198bb auto merge of #11930 : bjz/rust/next_power_of_two, r=huonw 2014-02-01 04:11:21 -08:00
Niko Matsakis
81d8328517 Introduce marker types for indicating variance and for opting out
of builtin bounds.

Fixes #10834.
Fixes #11385.
cc #5922.
2014-01-31 21:18:48 -05:00
Brendan Zabarauskas
4109caffc3 Remove some unused imports 2014-02-01 13:03:01 +11:00
Brendan Zabarauskas
9a3583f06d Make next_power_of_two generic for unsigned integers
Also rename `next_power_of_two_opt` to `checked_next_power_of_two`.
2014-02-01 13:02:53 +11:00
David Manescu
4d0d3da9e4 extra: move arena to libarena
In line with the dissolution of libextra - #8784 - moves arena to its own library libarena.
Changes based on PR #11787. Updates .gitignore to ignore doc/arena.
2014-01-29 13:54:38 +11:00