Commit Graph

34158 Commits

Author SHA1 Message Date
Jakub Bukaj
7137c2cc83 rollup merge of #18910: aturon/borrow-traits
Following [the collections reform RFC](https://github.com/rust-lang/rfcs/pull/235), this PR:

* Adds a new `borrow` module to libcore. The module contains traits for borrowing data (`BorrowFrom` and `BorrowFromMut`), generalized cloning (`ToOwned`), and a clone-on-write smartpointer (`Cow`).

* Deprecates the `_equiv` family of methods on `HashMap` and `HashSet` by instead generalizing the "normal" methods like `get` and `remove` to use the new `std::borrow` infrastructure.

* Generalizes `TreeMap`, `TreeSet`, `BTreeMap` and `BTreeSet` to use the new `std::borrow` infrastructure for lookups.

[breaking-change]
2014-11-18 00:23:53 +01:00
Jakub Bukaj
fcf9fb6157 rollup merge of #18890: luqmana/tf
This is especially useful for declaring a static with external linkage in an executable. There isn't any way to do that currently since we mark everything in an executable as internal by default.

Also, a quick fix to have the no-compiler-rt target option respected when building staticlibs as well.
2014-11-18 00:23:50 +01:00
Luqman Aden
33893aebcf librustc: Whitelist linkage attribute for unused attribute lint since it's processed during trans. 2014-11-17 15:24:35 -05:00
Luqman Aden
acd890d96d Add tests. 2014-11-17 15:24:34 -05:00
Aaron Turon
46be8eb47c Remove bogus Duration::span test 2014-11-17 11:26:48 -08:00
Aaron Turon
9f1217da91 Further DSTify Index traits 2014-11-17 11:26:48 -08:00
Aaron Turon
ff88510535 libcollections: generalize BTree* to use BorrowFrom
Generalizes the BTree-based collections to use the new BorrowFrom
infrastructure for more flexible lookups and removals.
2014-11-17 11:26:48 -08:00
Aaron Turon
7213de1c49 Fallout from deprecation
This commit handles the fallout from deprecating `_with` and `_equiv` methods.
2014-11-17 11:26:48 -08:00
Aaron Turon
80a2867ea7 libstd: Deprecate _equiv methods
This commit deprecates the `_equiv` family of methods on `HashMap` and
`HashSet` by instead generalizing the "normal" methods like `get` and
`remove` to use the new `std::borrow` infrastructure.

[breaking-change]
2014-11-17 11:26:47 -08:00
Aaron Turon
5eec666c8c libcollections: use BorrowFrom in TreeSet, Map
This commit generalizes methods like `get` and `remove` for `TreeMap`
and `TreeSet` to use the new `std::borrow` infrastructure.

[breaking-change]
2014-11-17 11:26:30 -08:00
Aaron Turon
4ab22355d4 libcore: add borrow module
Following [the collections reform
RFC](https://github.com/rust-lang/rfcs/pull/235),
this commit adds a new `borrow` module to libcore.

The module contains traits for borrowing data (`BorrowFrom` and
`BorrowFromMut`),
generalized cloning (`ToOwned`), and a clone-on-write smartpointer (`Cow`).
2014-11-17 11:26:30 -08:00
bors
f09279395b auto merge of #18973 : sfackler/rust/enum-namespace-pt2, r=pcwalton
This breaks code that referred to variant names in the same namespace as
their enum. Reexport the variants in the old location or alter code to
refer to the new locations:

```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
=>
```
pub use self::Foo::{A, B};

pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
or
```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = Foo::A;
}
```

[breaking-change]
2014-11-17 17:22:06 +00:00
Steven Fackler
3dcd215740 Switch to purely namespaced enums
This breaks code that referred to variant names in the same namespace as
their enum. Reexport the variants in the old location or alter code to
refer to the new locations:

```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
=>
```
pub use self::Foo::{A, B};

pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
or
```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = Foo::A;
}
```

[breaking-change]
2014-11-17 07:35:51 -08:00
bors
88c743def3 auto merge of #19007 : huonw/rust/more-marker-impls, r=alexcrichton
Useful for #[deriving].
2014-11-17 14:22:03 +00:00
bors
0047dbe59c auto merge of #19027 : nick29581/rust/coercions-4, r=alexcrichton
The forwards compatible parts of #18645, rebased. Converts implicit coercions from `[T, ..n]` to `&[T]` into explicit references.
2014-11-17 11:22:00 +00:00
Nick Cameron
ca08540a00 Fix fallout from coercion removal 2014-11-17 22:41:33 +13:00
bors
edfb83c9e2 auto merge of #18914 : Gankro/rust/cloned, r=aturon
Part of #18424. r? @aturon 

[breaking-change]
2014-11-17 09:26:57 +00:00
bors
803aacd5ae auto merge of #18927 : areski/rust/pr-improve-option-match-readl, r=jakub-
**match** are much more easy to read when it's not in 1 single line
2014-11-17 02:56:55 +00:00
bors
0b7b4f075a auto merge of #18747 : csherratt/rust/ringbuf-remove-option, r=huonw
Fix for task in Metabug #18009 (Rebased version of https://github.com/rust-lang/rust/pull/18170)

This changes much of about how RingBuf functions. `lo`, `nelts` are replaced by a more traditional `head` and`tail`. The `Vec<Option<T>>` is replaced by a bare pointer that is managed by the `RingBuf` itself. This also expects the ring buffer to always be size that is a power of 2.

This change also includes a number of new tests to cover the some areas that could be of concern with manual memory management.

The benchmarks have been reworked since the old ones were benchmarking of the Ring buffers growth rather then the actual test.

The unit test suite have been expanded, and exposed some bugs in `fn get()` and `fn get_mut()`

## Benchmark
**Before:**
```
test ring_buf::tests::bench_grow_1025                      ... bench:      8919 ns/iter (+/- 87)
test ring_buf::tests::bench_iter_1000                      ... bench:       924 ns/iter (+/- 28)
test ring_buf::tests::bench_mut_iter_1000                  ... bench:       918 ns/iter (+/- 6)
test ring_buf::tests::bench_new                            ... bench:        15 ns/iter (+/- 0)
test ring_buf::tests::bench_pop_100                        ... bench:       294 ns/iter (+/- 9)
test ring_buf::tests::bench_pop_front_100                  ... bench:       948 ns/iter (+/- 32)
test ring_buf::tests::bench_push_back_100                  ... bench:       291 ns/iter (+/- 16)
test ring_buf::tests::bench_push_front_100                 ... bench:       311 ns/iter (+/- 27
```
**After:**
```
test ring_buf::tests::bench_grow_1025                      ... bench:      2209 ns/iter (+/- 169)
test ring_buf::tests::bench_iter_1000                      ... bench:       534 ns/iter (+/- 27)
test ring_buf::tests::bench_mut_iter_1000                  ... bench:       515 ns/iter (+/- 28)
test ring_buf::tests::bench_new                            ... bench:        11 ns/iter (+/- 0)
test ring_buf::tests::bench_pop_100                        ... bench:       170 ns/iter (+/- 5)
test ring_buf::tests::bench_pop_front_100                  ... bench:       171 ns/iter (+/- 11)
test ring_buf::tests::bench_push_back_100                  ... bench:       172 ns/iter (+/- 13)
test ring_buf::tests::bench_push_front_100                 ... bench:       158 ns/iter (+/- 12)

```
2014-11-16 22:36:50 +00:00
Huon Wilson
f97524387d Implement more basic traits for the marker types. 2014-11-17 09:25:49 +11:00
bors
245c7fbef5 auto merge of #18995 : alfie/rust/comment-docs, r=aturon
Start comment is a string literal while end comment is made up of two character literals. This change is to make them consistent.
2014-11-16 20:32:12 +00:00
bors
aad75471fd auto merge of #18994 : sfackler/rust/struct-variants-pt2, r=jakub-
Struct variant field visibility is now inherited. Remove `pub` keywords
from declarations.

Closes #18641

[breaking-change]

r? @alexcrichton
2014-11-16 18:27:10 +00:00
Alexis Beingessner
dfb7a811ae fallout from deprecating find_copy and get_copy 2014-11-16 10:40:25 -05:00
Alexis Beingessner
64efd2650c Deprecate hashmap's find_copy and get_copy in favour of cloned and clone 2014-11-16 10:40:23 -05:00
Alexis Beingessner
04f7b690ba implement cloned for Option 2014-11-16 10:39:03 -05:00
bors
321488b675 auto merge of #18752 : jakub-/rust/remove-unit, r=eddyb
Closes https://github.com/rust-lang/rust/issues/18614.
2014-11-16 14:27:08 +00:00
Jakub Bukaj
c425ed2a8d Update the reference 2014-11-16 14:23:15 +01:00
Jakub Bukaj
28b1b2ec39 Update tests accordingly 2014-11-16 14:23:15 +01:00
Jakub Bukaj
eb01b17b06 Complete the removal of ty_nil, ast::LitNil, ast::TyBot and ast::TyUniq
[breaking-change]

This will break any uses of macros that assumed () being a valid literal.
2014-11-16 14:23:15 +01:00
Niko Matsakis
08d6774f39 Try to remove ty_nil, some kind of error in exhaustiveness checking 2014-11-16 14:23:14 +01:00
bors
0c7a3d6c16 auto merge of #18978 : jakub-/rust/roll-up, r=cmr 2014-11-16 11:27:35 +00:00
Jakub Bukaj
892d4e28f4 Fix doctests 2014-11-16 12:22:40 +01:00
Jakub Bukaj
3ee9f0df54 Fix warnings 2014-11-16 10:40:34 +01:00
Jakub Bukaj
b22afe9ee7 rollup merge of #18990: alfie/master 2014-11-16 10:22:43 +01:00
Jakub Bukaj
a9f9e80de5 rollup merge of #18989: alex/fix-typos 2014-11-16 10:22:35 +01:00
Jakub Bukaj
086b2974de rollup merge of #18985: alexcrichton/issue-18900 2014-11-16 10:22:28 +01:00
Jakub Bukaj
94c8bb4696 rollup merge of #18979: inrustwetrust/codegen-options-parsing 2014-11-16 10:22:00 +01:00
Jakub Bukaj
4c30cb2564 rollup merge of #18976: bjz/rfc369-numerics 2014-11-16 10:21:42 +01:00
Jakub Bukaj
42c77f4958 rollup merge of #18970: aturon/fixup-stable 2014-11-16 10:21:33 +01:00
Jakub Bukaj
f3fd09a6f5 rollup merge of #18965: cmr/master 2014-11-16 10:21:18 +01:00
Jakub Bukaj
c01c6e2cac rollup merge of #18964: coyotebush/rustdoc-print 2014-11-16 10:21:11 +01:00
Jakub Bukaj
c46b5b5314 rollup merge of #18960: stepancheg/cell-default 2014-11-16 10:21:01 +01:00
Jakub Bukaj
f7be5966dc rollup merge of #18949: tomjakubowski/tojson-str 2014-11-16 10:20:35 +01:00
Jakub Bukaj
12144098eb rollup merge of #18948: barosl/doc-encodable-fix 2014-11-16 10:20:28 +01:00
Jakub Bukaj
b45dbfbd2b rollup merge of #18942: jbcrail/tree-set-docs 2014-11-16 10:20:10 +01:00
Jakub Bukaj
c7fc332a22 rollup merge of #18941: reem/better-task-pool 2014-11-16 10:20:03 +01:00
Jakub Bukaj
0d97b95d43 rollup merge of #18935: jmesmon/cody/no-vendor-triplle 2014-11-16 10:19:47 +01:00
Jakub Bukaj
ecf765d97b rollup merge of #18933: IanConnolly/doc-fake-rust 2014-11-16 10:19:22 +01:00
bors
cb51567e19 auto merge of #18788 : ricky26/rust/master, r=aturon
This moves chars() and lines() out of Buffer and into separate traits (CharsBuffer and LinesBuffer respectively) - this matches the pattern used for bytes() on Reader (with BytesReader).

(I came across this when I wanted a trait object of a Buffer, so that I could use read_line(); rustc errors about std::io::Buffer not being object-safe.)

[breaking-change]
Any uses of Buffer::lines() will need to use the new trait std::io::LinesBuffer.
The same is true for Buffer::chars() with std::io::CharsBuffer.
2014-11-16 04:37:36 +00:00
Alfie John
a8933973f9 doc: make end comment consistent with start comment 2014-11-16 04:12:43 +00:00