Commit Graph

34239 Commits

Author SHA1 Message Date
Jakub Bukaj
76daa0c77c rollup merge of #18921: oli-obk/refactoring/graphviz/id/new/result_instead_of_fail
creating a new Id object requires the format to match a subset of `ID` format defined by the DOT language. When the format did not match, the function called assert. This was not mentioned in the docs or the spec. I made the failure explicit by returning an Result<Id, ()>.
2014-11-18 00:23:57 +01:00
Jakub Bukaj
db4d60afb0 rollup merge of #18911: canndrew/slice_shift_char
`slice_shift_char` splits a `str` into it's leading `char` and the remainder of the `str`. Currently, it returns a `(Option<char>, &str)` such that:

    "bar".slice_shift_char() => (Some('b'), "ar")
    "ar".slice_shift_char()  => (Some('a'), "r")
    "r".slice_shift_char()   => (Some('r'), "")
    "".slice_shift_char()    => (None,      "")

This is a little odd. Either a `str` can be split into both a head and a tail or it cannot. So the return type should be `Option<(char, &str)>`. With the current behaviour, in the case of the empty string, the `str` returned is meaningless - it is always the empty string.

This PR changes `slice_shift_char` so that:

    "bar".slice_shift_char() => Some(('b', "ar"))
    "ar".slice_shift_char()  => Some(('a', "r"))
    "r".slice_shift_char()   => Some(('r', ""))
    "".slice_shift_char()    => None
2014-11-18 00:23:55 +01:00
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
Cody P Schafer
600cec1cd8 mk/rt/jemalloc: pass CFG_GCCISH_CFLAGS inside CC instead of passing CFG_CFLAGS in EXTRA_CFLAGS
- CFG_CFLAGS is gone (it was previously only used by jemalloc anyhow).
 - CFG_JEMALLOC_CFLAGS may contain flags needed for the compiler to
   function (produce a binary output).
 - jemalloc's configure runs $(CC) without EXTRA_CFLAGS, and (without
   this change) will fail if any flags are required for CC to work.
2014-11-17 16:41:15 -05:00
Cody P Schafer
61e53c94f2 CFG_CFLAGS is only used for jemalloc, rename all uses to CFG_JEMALLOC_CFLAGS
i386-apple-ios already used CFG_JEMALLOC_CFLAGS, so merge that one
2014-11-17 16:41:09 -05:00
Nick Cameron
d46f7adb53 Regression test 2014-11-18 10:02:27 +13:00
Nick Cameron
85914df05a Disallow coercions from [T, ..n] to &[T]or *[T]
[breaking-change]

Insert an `&` to fix
2014-11-18 10:02:27 +13:00
Jakub Bukaj
54c76e6e81 Fix an ICE when using struct patterns with traits
Fixes #18986.
2014-11-17 21:49:41 +01:00
Jorge Aparicio
daa949e516 libsyntax: DSTify ToSource and ToSourceWithHygiene 2014-11-17 15:40:35 -05:00
bors
336349c932 auto merge of #18694 : nikomatsakis/rust/issue-18208-method-dispatch-2, r=nrc
This is a pretty major refactoring of the method dispatch infrastructure. It is intended to avoid gross inefficiencies and enable caching and other optimizations (e.g. #17995), though it itself doesn't seem to execute particularly faster yet. It also solves some cases where we were failing to resolve methods that we theoretically should have succeeded with.

Fixes #18674.

cc #18208
2014-11-17 20:37:19 +00:00
Niko Matsakis
99fbd34d7e Fix merge conflicts from making enum variants namespaced. 2014-11-17 15:25:56 -05: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
Jorge Aparicio
38c17dc324 libtest: DSTify Stats 2014-11-17 15:19:56 -05:00
jmu303
215f693400 Fix several typos in comments
liblog, libregex, librustc, libstd
2014-11-17 14:41:47 -05:00
Jorge Aparicio
d429039e7b DSTify impl Clone for &T
Closes #19037
2014-11-17 14:35:27 -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
Niko Matsakis
d7bb01eb52 Use the quick reject mechanism during trait matching as well. Seems to
yield an incremental improvement (type-checking rustc drops from ~9s
to ~8s).
2014-11-17 14:25:11 -05:00
Niko Matsakis
d93921b348 Port a simplified versions of pcwalton's "quick reject" mechanism for quickly throwing out method candidates. Yields a 40%-50% improvement in typechecking time as well as lowering peak memory use from 2.2GB to 1.8GB (due to creating fewer types).
Conflicts:
	src/librustc/driver/config.rs
	src/librustc/middle/ty.rs
	src/librustc/middle/typeck/check/method.rs
	src/librustc/middle/typeck/check/mod.rs
	src/librustc/middle/typeck/coherence/mod.rs
2014-11-17 14:25:11 -05:00
Niko Matsakis
0ed0a4633b Correct indentation 2014-11-17 14:25:11 -05:00
Niko Matsakis
70aecde11d Correct long line 2014-11-17 14:25:11 -05:00
Niko Matsakis
e691192042 Substitute type/lifetimeInstatiate method type/early-bound lifetime parameters too when creating xform-self-type.
Fixes #18208.
2014-11-17 14:25:11 -05:00
Niko Matsakis
f8403aac81 Rewrite method resolution to be cleaner, more correct, and to lay
groundwork for better performance.

Key points:

- Separate out determining which method to use from actually selecting
  a method (this should enable caching, as well as the pcwalton fast-reject strategy).
- Merge the impl selection back into method resolution and don't rely on
  trait matching (this should perform better but also is needed to resolve some
  kind of conflicts, see e.g. `method-two-traits-distinguished-via-where-clause.rs`)
- Purge a lot of out-of-date junk and coercions from method lookups.
2014-11-17 14:25:11 -05: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
Gleb Kozyrev
8b16ccdd7b Return proper errors with update_err 2014-11-17 19:18:26 +02:00
Gleb Kozyrev
b7908febca Remove duplicate code by using util::copy() 2014-11-17 19:18:26 +02:00
Victor Berger
55200504f0 Don't inherit stability to items in a function body.
Items defined in the body of a function has no visibility
outside it, and thus have no reason to be marked with
stability attributes.

Closes #17488
2014-11-17 18:14:42 +01:00
Ivan Ukhov
5a12cb8e56 Bring back the dylib kind of the link attribute 2014-11-17 18:00:30 +01: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
oli-obk
70bf4f72ef libgraphviz: Id::new returns Result<Id, ()> instead of panicking on error
creating a new Id object requires the format to match a subset of `ID` format defined by the DOT language. When the format did not match, the function called assert. This was not mentioned in the docs or the spec. I made the failure explicit by returning an Result<Id, ()>.
2014-11-17 15:08:25 +01: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
Andrew Cann
197a0ac481 change return type of slice_shift_char
`slice_shift_char` splits a `str` into it's leading `char` and the remainder
of the `str`. Currently, it returns a `(Option<char>, &str)` such that:

    "bar".slice_shift_char() => (Some('b'), "ar")
    "ar".slice_shift_char()  => (Some('a'), "r")
    "r".slice_shift_char()   => (Some('r'), "")
    "".slice_shift_char()    => (None,      "")

This is a little odd. Either a `str` can be split into both a head and a
tail or it cannot. So the return type should be `Option<(char, &str)>`.
With the current behaviour, in the case of the empty string, the `str`
returned is meaningless - it is always the empty string.

This commit changes slice_shift_char so that:

    "bar".slice_shift_char() => Some(('b', "ar"))
    "ar".slice_shift_char()  => Some(('a', "r"))
    "r".slice_shift_char()   => Some(('r', ""))
    "".slice_shift_char()    => None

[breaking-change]
2014-11-17 17:35:18 +08: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
Alexis Beingessner
8c467f75e3 slightly better deprecation message for fn syntax 2014-11-17 00:42:56 -05:00
Alfie John
9a5237d7ae doc: extend a893397 to make whole document consistent 2014-11-17 05:15:24 +00:00
Tom Jakubowski
8000482e86 Disallow parsing of struct variants with 0 fields
Make struct variant syntax more consistent with struct syntax and fix an
assert in middle::typeck.

Fix #19003
2014-11-16 19:10:47 -08: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
Alex Gaynor
1128a7f08f Fixed a few typos in libcore 2014-11-16 16:51:22 -08: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