]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agolibcore: Deprecate advance method on Iterators.
Luqman Aden [Thu, 12 Jun 2014 06:56:40 +0000 (02:56 -0400)]
libcore: Deprecate advance method on Iterators.

10 years agoauto merge of #15471 : erickt/rust/push_all, r=acrichto
bors [Wed, 9 Jul 2014 20:21:29 +0000 (20:21 +0000)]
auto merge of #15471 : erickt/rust/push_all, r=acrichto

llvm is currently not able to conver `Vec::extend` into a memcpy for `Copy` types, which results in methods like `Vec::push_all` to run twice as slow as it should be running. This patch takes the unsafe `Vec::clone` optimization to speed up all the operations that are cloning a slice into a `Vec`.

before:

```
test vec::tests::bench_clone_from_0000_0000                ... bench:        12 ns/iter (+/- 2)
test vec::tests::bench_clone_from_0000_0010                ... bench:       125 ns/iter (+/- 4) = 80 MB/s
test vec::tests::bench_clone_from_0000_0100                ... bench:       360 ns/iter (+/- 33) = 277 MB/s
test vec::tests::bench_clone_from_0000_1000                ... bench:      2601 ns/iter (+/- 175) = 384 MB/s
test vec::tests::bench_clone_from_0010_0000                ... bench:        12 ns/iter (+/- 2)
test vec::tests::bench_clone_from_0010_0010                ... bench:       125 ns/iter (+/- 10) = 80 MB/s
test vec::tests::bench_clone_from_0010_0100                ... bench:       361 ns/iter (+/- 28) = 277 MB/s
test vec::tests::bench_clone_from_0100_0010                ... bench:       131 ns/iter (+/- 13) = 76 MB/s
test vec::tests::bench_clone_from_0100_0100                ... bench:       360 ns/iter (+/- 9) = 277 MB/s
test vec::tests::bench_clone_from_0100_1000                ... bench:      2575 ns/iter (+/- 168) = 388 MB/s
test vec::tests::bench_clone_from_1000_0100                ... bench:       356 ns/iter (+/- 20) = 280 MB/s
test vec::tests::bench_clone_from_1000_1000                ... bench:      2605 ns/iter (+/- 167) = 383 MB/s
test vec::tests::bench_from_slice_0000                     ... bench:        11 ns/iter (+/- 0)
test vec::tests::bench_from_slice_0010                     ... bench:       115 ns/iter (+/- 5) = 86 MB/s
test vec::tests::bench_from_slice_0100                     ... bench:       309 ns/iter (+/- 170) = 323 MB/s
test vec::tests::bench_from_slice_1000                     ... bench:      2065 ns/iter (+/- 198) = 484 MB/s
test vec::tests::bench_push_all_0000_0000                  ... bench:         7 ns/iter (+/- 0)
test vec::tests::bench_push_all_0000_0010                  ... bench:        79 ns/iter (+/- 7) = 126 MB/s
test vec::tests::bench_push_all_0000_0100                  ... bench:       342 ns/iter (+/- 18) = 292 MB/s
test vec::tests::bench_push_all_0000_1000                  ... bench:      2873 ns/iter (+/- 75) = 348 MB/s
test vec::tests::bench_push_all_0010_0010                  ... bench:       154 ns/iter (+/- 8) = 64 MB/s
test vec::tests::bench_push_all_0100_0100                  ... bench:       518 ns/iter (+/- 18) = 193 MB/s
test vec::tests::bench_push_all_1000_1000                  ... bench:      4490 ns/iter (+/- 223) = 222 MB/s
```

after:

```
test vec::tests::bench_clone_from_0000_0000                ... bench:        12 ns/iter (+/- 1)
test vec::tests::bench_clone_from_0000_0010                ... bench:       123 ns/iter (+/- 5) = 81 MB/s
test vec::tests::bench_clone_from_0000_0100                ... bench:       367 ns/iter (+/- 23) = 272 MB/s
test vec::tests::bench_clone_from_0000_1000                ... bench:      2618 ns/iter (+/- 252) = 381 MB/s
test vec::tests::bench_clone_from_0010_0000                ... bench:        12 ns/iter (+/- 1)
test vec::tests::bench_clone_from_0010_0010                ... bench:       124 ns/iter (+/- 7) = 80 MB/s
test vec::tests::bench_clone_from_0010_0100                ... bench:       369 ns/iter (+/- 34) = 271 MB/s
test vec::tests::bench_clone_from_0100_0010                ... bench:       123 ns/iter (+/- 6) = 81 MB/s
test vec::tests::bench_clone_from_0100_0100                ... bench:       371 ns/iter (+/- 25) = 269 MB/s
test vec::tests::bench_clone_from_0100_1000                ... bench:      2713 ns/iter (+/- 532) = 368 MB/s
test vec::tests::bench_clone_from_1000_0100                ... bench:       369 ns/iter (+/- 14) = 271 MB/s
test vec::tests::bench_clone_from_1000_1000                ... bench:      2611 ns/iter (+/- 194) = 382 MB/s
test vec::tests::bench_from_slice_0000                     ... bench:         7 ns/iter (+/- 0)
test vec::tests::bench_from_slice_0010                     ... bench:       108 ns/iter (+/- 4) = 92 MB/s
test vec::tests::bench_from_slice_0100                     ... bench:       235 ns/iter (+/- 24) = 425 MB/s
test vec::tests::bench_from_slice_1000                     ... bench:      1318 ns/iter (+/- 96) = 758 MB/s
test vec::tests::bench_push_all_0000_0000                  ... bench:         7 ns/iter (+/- 0)
test vec::tests::bench_push_all_0000_0010                  ... bench:        70 ns/iter (+/- 4) = 142 MB/s
test vec::tests::bench_push_all_0000_0100                  ... bench:       176 ns/iter (+/- 16) = 568 MB/s
test vec::tests::bench_push_all_0000_1000                  ... bench:      1125 ns/iter (+/- 94) = 888 MB/s
test vec::tests::bench_push_all_0010_0010                  ... bench:       159 ns/iter (+/- 15) = 62 MB/s
test vec::tests::bench_push_all_0100_0100                  ... bench:       363 ns/iter (+/- 12) = 275 MB/s
test vec::tests::bench_push_all_1000_1000                  ... bench:      2860 ns/iter (+/- 415) = 349 MB/s
```

This also includes extra benchmarks for `Vec` and `MemWriter`.

10 years agoauto merge of #15283 : kwantam/rust/master, r=alexcrichton
bors [Wed, 9 Jul 2014 18:36:30 +0000 (18:36 +0000)]
auto merge of #15283 : kwantam/rust/master, r=alexcrichton

Add libunicode; move unicode functions from core

- created new crate, libunicode, below libstd
- split `Char` trait into `Char` (libcore) and `UnicodeChar` (libunicode)
  - Unicode-aware functions now live in libunicode
    - `is_alphabetic`, `is_XID_start`, `is_XID_continue`, `is_lowercase`,
      `is_uppercase`, `is_whitespace`, `is_alphanumeric`, `is_control`, `is_digit`,
      `to_uppercase`, `to_lowercase`
  - added `width` method in UnicodeChar trait
    - determines printed width of character in columns, or None if it is a non-NULL control character
    - takes a boolean argument indicating whether the present context is CJK or not (characters with 'A'mbiguous widths are double-wide in CJK contexts, single-wide otherwise)
- split `StrSlice` into `StrSlice` (libcore) and `UnicodeStrSlice` (libunicode)
  - functionality formerly in `StrSlice` that relied upon Unicode functionality from `Char` is now in `UnicodeStrSlice`
    - `words`, `is_whitespace`, `is_alphanumeric`, `trim`, `trim_left`, `trim_right`
  - also moved `Words` type alias into libunicode because `words` method is in `UnicodeStrSlice`
- unified Unicode tables from libcollections, libcore, and libregex into libunicode
- updated `unicode.py` in `src/etc` to generate aforementioned tables
- generated new tables based on latest Unicode data
- added `UnicodeChar` and `UnicodeStrSlice` traits to prelude
- libunicode is now the collection point for the `std::char` module, combining the libunicode functionality with the `Char` functionality from libcore
  - thus, moved doc comment for `char` from `core::char` to `unicode::char`
- libcollections remains the collection point for `std::str`

The Unicode-aware functions that previously lived in the `Char` and `StrSlice` traits are no longer available to programs that only use libcore. To regain use of these methods, include the libunicode crate and `use` the `UnicodeChar` and/or `UnicodeStrSlice` traits:

    extern crate unicode;
    use unicode::UnicodeChar;
    use unicode::UnicodeStrSlice;
    use unicode::Words; // if you want to use the words() method

NOTE: this does *not* impact programs that use libstd, since UnicodeChar and UnicodeStrSlice have been added to the prelude.

closes #15224
[breaking-change]

10 years agoauto merge of #15220 : vhbit/rust/treemap-str-equiv, r=alexcrichton
bors [Wed, 9 Jul 2014 16:51:28 +0000 (16:51 +0000)]
auto merge of #15220 : vhbit/rust/treemap-str-equiv, r=alexcrichton

- it allows to lookup using any str-equiv object, making TreeMaps finally usable (for example, it is much easier to work with JSON with lookup values being static strs)
- actually provides pretty flexible solution which could be extended to other equivalent types (although it might be not that performant)

10 years agoTreeMap: find enhancements
Valerii Hiora [Wed, 9 Jul 2014 14:48:17 +0000 (17:48 +0300)]
TreeMap: find enhancements

find_with/find_mut_with which use provided closure for navigating tree
and searching as flexible as possible

10 years agofix test failures
kwantam [Tue, 8 Jul 2014 18:46:01 +0000 (14:46 -0400)]
fix test failures

- unicode tests live in coretest crate
- libcollections str tests need UnicodeChar trait.
- libregex perlw tests were checking a char in the Alphabetic category,
  \x2161. Confirmed perl 5.18 considers this a \w character. Changed to
  \x2961, which is not \w as the test expects.

10 years agoauto merge of #15483 : AlisdairO/rust/master, r=alexcrichton
bors [Wed, 9 Jul 2014 14:06:29 +0000 (14:06 +0000)]
auto merge of #15483 : AlisdairO/rust/master, r=alexcrichton

Noticed there wasn't an awful lot of info out there on using Any types, so added an example to the rustdocs.

10 years agoauto merge of #15540 : Gankro/rust/master, r=huonw
bors [Wed, 9 Jul 2014 12:21:29 +0000 (12:21 +0000)]
auto merge of #15540 : Gankro/rust/master, r=huonw

Removing recursion from TreeMap implementation, because we don't have TCO. No need to add ```O(logn)``` extra stack frames to search in a tree.

I find it curious that ```find_mut``` and ```find``` basically duplicated the same logic, but in different ways (iterative vs recursive), possibly to maneuvre around mutability rules, but that's a more fundamental issue to deal with elsewhere.

Thanks to acrichto for the magic trick to appease borrowck (another issue to deal with elsewhere).

10 years agoauto merge of #15530 : adrientetar/rust/proper-fonts, r=alexcrichton
bors [Wed, 9 Jul 2014 10:36:31 +0000 (10:36 +0000)]
auto merge of #15530 : adrientetar/rust/proper-fonts, r=alexcrichton

- Treat WOFF as binary files so that git does not perform newline normalization.
- Replace corrupt Heuristica files with Source Serif Pro — italics are [almost in production](https://github.com/adobe/source-serif-pro/issues/2) so I left Heuristica Italic which makes a good pair with SSP. Overall, Source Serif Pro is I think a better fit for rustdoc (cc @TheHydroImpulse). This ought to fix #15527.
- Store Source Code Pro locally in order to make offline docs freestanding. Fixes #14778.

Preview: http://adrientetar.legtux.org/cached/rust-docs/core.html

r? @alexcrichton

10 years agoauto merge of #15339 : cmr/rust/rewrite-lexer2, r=huonw
bors [Wed, 9 Jul 2014 08:46:35 +0000 (08:46 +0000)]
auto merge of #15339 : cmr/rust/rewrite-lexer2, r=huonw

Mostly minor things that rebasing is becoming painful.

10 years agoFix all the test fallout
Corey Richardson [Wed, 9 Jul 2014 05:28:52 +0000 (22:28 -0700)]
Fix all the test fallout

10 years agoast: make Name its own type
Corey Richardson [Sun, 6 Jul 2014 08:17:59 +0000 (01:17 -0700)]
ast: make Name its own type

10 years agolexer: lex WS/COMMENT/SHEBANG rather than skipping
Corey Richardson [Sat, 5 Jul 2014 05:30:39 +0000 (22:30 -0700)]
lexer: lex WS/COMMENT/SHEBANG rather than skipping

Now, the lexer will categorize every byte in its input according to the
grammar. The parser skips over these while parsing, thus avoiding their
presence in the input to syntax extensions.

10 years agosyntax: don't parse numeric literals in the lexer
Corey Richardson [Wed, 18 Jun 2014 17:44:20 +0000 (10:44 -0700)]
syntax: don't parse numeric literals in the lexer

This removes a bunch of token types. Tokens now store the original, unaltered
numeric literal (that is still checked for correctness), which is parsed into
an actual number later, as needed, when creating the AST.

This can change how syntax extensions work, but otherwise poses no visible
changes.

[breaking-change]

10 years agosyntax: don't process string/char/byte/binary lits
Corey Richardson [Thu, 3 Jul 2014 07:47:30 +0000 (00:47 -0700)]
syntax: don't process string/char/byte/binary lits

This shuffles things around a bit so that LIT_CHAR and co store an Ident
which is the original, unaltered literal in the source. When creating the AST,
unescape and postprocess them.

This changes how syntax extensions can work, slightly, but otherwise poses no
visible changes. To get a useful value out of one of these tokens, call
`parse::{char_lit, byte_lit, bin_lit, str_lit}`

[breaking-change]

10 years agoast: add an `as_str` method to Ident
Corey Richardson [Thu, 3 Jul 2014 07:45:59 +0000 (00:45 -0700)]
ast: add an `as_str` method to Ident

This is technically unsafe but interned strings are considered immortal.

10 years agolexer: add ident_from and ident_from_to methods
Corey Richardson [Wed, 25 Jun 2014 00:44:50 +0000 (17:44 -0700)]
lexer: add ident_from and ident_from_to methods

10 years agolexer: shuffle around some functions
Corey Richardson [Wed, 2 Jul 2014 16:39:48 +0000 (09:39 -0700)]
lexer: shuffle around some functions

10 years agocodemap: be less annoying in debug logging
Corey Richardson [Mon, 23 Jun 2014 20:37:30 +0000 (13:37 -0700)]
codemap: be less annoying in debug logging

10 years agosyntax: use a better Show impl for Ident
Corey Richardson [Tue, 17 Jun 2014 06:00:49 +0000 (23:00 -0700)]
syntax: use a better Show impl for Ident

Rather than just dumping the id in the interner, which is useless, actually
print the interned string. Adjust the lexer logging to use Show instead of
Poly.

10 years agotest: simplify numeric literal cfail tests
Corey Richardson [Wed, 18 Jun 2014 17:44:09 +0000 (10:44 -0700)]
test: simplify numeric literal cfail tests

10 years agostr: use more helpful assertion failure messages
Corey Richardson [Wed, 18 Jun 2014 17:40:38 +0000 (10:40 -0700)]
str: use more helpful assertion failure messages

10 years agotestsuite: merge some lexer testcases
Corey Richardson [Mon, 16 Jun 2014 21:12:44 +0000 (14:12 -0700)]
testsuite: merge some lexer testcases

Now that the lexer is more robust, these tests don't need to be in separate
files. Yay!

10 years agotoken: replace ast::Ident with just Ident
Corey Richardson [Mon, 9 Jun 2014 20:19:38 +0000 (13:19 -0700)]
token: replace ast::Ident with just Ident

10 years agosyntax: doc comments all the things
Corey Richardson [Mon, 9 Jun 2014 20:12:30 +0000 (13:12 -0700)]
syntax: doc comments all the things

10 years agoAdd example to Any documentation
Alisdair Owens [Sun, 6 Jul 2014 16:30:01 +0000 (17:30 +0100)]
Add example to Any documentation

10 years agoauto merge of #15537 : jbclements/rust/hygiene-for-methods, r=pcwalton
bors [Wed, 9 Jul 2014 05:11:38 +0000 (05:11 +0000)]
auto merge of #15537 : jbclements/rust/hygiene-for-methods, r=pcwalton

This patch adds hygiene for methods. This one was more difficult than the others, due principally to issues surrounding `self`. Specifically, there were a whole bunch of places in the code that assumed that a `self` identifier could be discarded and then made up again later, causing the discard of contexts and hygiene breakage.

10 years agoauto merge of #15422 : steveklabnik/rust/guide_compound_data_types, r=brson
bors [Wed, 9 Jul 2014 02:21:37 +0000 (02:21 +0000)]
auto merge of #15422 : steveklabnik/rust/guide_compound_data_types, r=brson

I'm not happy about the hand-waving around `cmp`, but I'm not sure how to get around it.

10 years agoRemoving recursion from find_mut in treemap
Alexis Beingessner [Wed, 9 Jul 2014 00:09:21 +0000 (20:09 -0400)]
Removing recursion from find_mut in treemap

10 years agoauto merge of #15374 : steveklabnik/rust/comments, r=brson
bors [Wed, 9 Jul 2014 00:36:40 +0000 (00:36 +0000)]
auto merge of #15374 : steveklabnik/rust/comments, r=brson

I'm leaving off `rustdoc` usage because it won't work unless this is a `pub fn`, and I want to talk about public/private in the context of modules. I'm also not mentioning `//!` because it is exclusively used to provide the overview of a module.

10 years agofix hygiene for test case
John Clements [Tue, 8 Jul 2014 22:02:33 +0000 (15:02 -0700)]
fix hygiene for test case

10 years agocarry self ident forward through re-parsing
John Clements [Sun, 6 Jul 2014 22:10:57 +0000 (15:10 -0700)]
carry self ident forward through re-parsing

formerly, the self identifier was being discarded during parsing, which
stymies hygiene. The best fix here seems to be to attach a self identifier
to ExplicitSelf_, a change that rippled through the rest of the compiler,
but without any obvious damage.

10 years agomacro literals should be compared by name only
John Clements [Tue, 8 Jul 2014 00:43:09 +0000 (17:43 -0700)]
macro literals should be compared by name only

10 years agomake macros non-capturing
John Clements [Mon, 7 Jul 2014 23:26:30 +0000 (16:26 -0700)]
make macros non-capturing

10 years agocomments
John Clements [Mon, 7 Jul 2014 22:10:18 +0000 (15:10 -0700)]
comments

10 years agoremove outdated comment
John Clements [Mon, 7 Jul 2014 21:27:07 +0000 (14:27 -0700)]
remove outdated comment

I believe this comment is now irrelevant, as a result of
commit 6757053cffb585249105fbd76f

10 years agoimplement hygiene for method args
John Clements [Fri, 4 Jul 2014 18:24:28 +0000 (11:24 -0700)]
implement hygiene for method args

10 years agotest case for expansion of method macro
John Clements [Mon, 7 Jul 2014 22:12:31 +0000 (15:12 -0700)]
test case for expansion of method macro

10 years agointroducing let-syntax
John Clements [Mon, 7 Jul 2014 16:54:08 +0000 (09:54 -0700)]
introducing let-syntax

The let-syntax expander is different in that it doesn't apply
a mark to its token trees before expansion. This is used
for macro_rules, and it's because macro_rules is essentially
MTWT's let-syntax. You don't want to mark before expand sees
let-syntax, because there's no "after" syntax to mark again.

In some sense, the cleaner approach might be to introduce a new
AST node that macro_rules expands into; this would make it clearer
that the expansion of a macro is distinct from the addition of a
new macro binding.

This should work for now, though...

10 years agoauto merge of #14832 : alexcrichton/rust/no-rpath, r=brson
bors [Tue, 8 Jul 2014 22:51:39 +0000 (22:51 +0000)]
auto merge of #14832 : alexcrichton/rust/no-rpath, r=brson

This commit disables rustc's emission of rpath attributes into dynamic libraries
and executables by default. The functionality is still preserved, but it must
now be manually enabled via a `-C rpath` flag.

This involved a few changes to the local build system:

* --disable-rpath is now the default configure option
* Makefiles now prefer our own LD_LIBRARY_PATH over the user's LD_LIBRARY_PATH
  in order to support building rust with rust already installed.
* The compiletest program was taught to correctly pass through the aux dir as a
  component of LD_LIBRARY_PATH in more situations.

The major impact of this change is that neither rustdoc nor rustc will work
out-of-the-box in all situations because they are dynamically linked. It must be
arranged to ensure that the libraries of a rust installation are part of the
LD_LIBRARY_PATH. The default installation paths for all platforms ensure this,
but if an installation is in a nonstandard location, then configuration may be
necessary.

Additionally, for all developers of rustc, it will no longer be possible to run
$target/stageN/bin/rustc out-of-the-box. The old behavior can be regained
through the `--enable-rpath` option to the configure script.

This change brings linux/mac installations in line with windows installations
where rpath is not possible.

Closes #11747
[breaking-change]

10 years agoself arg macro test case
John Clements [Mon, 7 Jul 2014 16:53:41 +0000 (09:53 -0700)]
self arg macro test case

10 years agoreplace idents with names
John Clements [Sun, 6 Jul 2014 23:02:48 +0000 (16:02 -0700)]
replace idents with names

10 years agoget rid of keyword idents, replace with names
John Clements [Sun, 6 Jul 2014 22:19:29 +0000 (15:19 -0700)]
get rid of keyword idents, replace with names

should prevent future bugs

10 years agopreserve context in parsing of `self` varref
John Clements [Sun, 6 Jul 2014 22:11:44 +0000 (15:11 -0700)]
preserve context in parsing of `self` varref

10 years agoremove unused fn, make SELF_KEYWORD_NAME public
John Clements [Sun, 6 Jul 2014 22:07:31 +0000 (15:07 -0700)]
remove unused fn, make SELF_KEYWORD_NAME public

10 years agotest harness cleanup
John Clements [Sun, 6 Jul 2014 22:06:32 +0000 (15:06 -0700)]
test harness cleanup

10 years agochange if/else to match
John Clements [Sun, 6 Jul 2014 21:29:29 +0000 (14:29 -0700)]
change if/else to match

10 years agoadded test for method arg hygiene
John Clements [Fri, 4 Jul 2014 17:57:17 +0000 (10:57 -0700)]
added test for method arg hygiene

10 years agoauto merge of #15493 : brson/rust/tostr, r=pcwalton
bors [Tue, 8 Jul 2014 20:06:40 +0000 (20:06 +0000)]
auto merge of #15493 : brson/rust/tostr, r=pcwalton

This updates https://github.com/rust-lang/rust/pull/15075.

Rename `ToStr::to_str` to `ToString::to_string`. The naive renaming ends up with two `to_string` functions defined on strings in the prelude (the other defined via `collections::str::StrAllocating`). To remedy this I removed `StrAllocating::to_string`, making all conversions from `&str` to `String` go through `Show`. This has a measurable impact on the speed of this conversion, but the sense I get from others is that it's best to go ahead and unify `to_string` and address performance for all `to_string` conversions in `core::fmt`. `String::from_str(...)` still works as a manual fast-path.

Note that the patch was done with a script, and ended up renaming a number of other `*_to_str` functions, particularly inside of rustc. All the ones I saw looked correct, and I didn't notice any additional API breakage.

Closes #15046.

10 years agostd: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.
Richo Healey [Sat, 21 Jun 2014 10:39:03 +0000 (03:39 -0700)]
std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.

[breaking-change]

10 years agowebfonts: check-in licenses
Adrien Tétar [Tue, 8 Jul 2014 19:55:37 +0000 (21:55 +0200)]
webfonts: check-in licenses

10 years agowebfonts: serve Source Code Pro locally
Adrien Tétar [Tue, 8 Jul 2014 18:26:23 +0000 (20:26 +0200)]
webfonts: serve Source Code Pro locally

So that we have freestanding docs.

10 years agowebfonts: proper fix
Adrien Tétar [Tue, 8 Jul 2014 17:51:06 +0000 (19:51 +0200)]
webfonts: proper fix

10 years agoGuide: comments
Steve Klabnik [Thu, 3 Jul 2014 17:11:15 +0000 (13:11 -0400)]
Guide: comments

10 years agoauto merge of #15521 : nick29581/rust/type, r=pcwalton
bors [Tue, 8 Jul 2014 16:01:41 +0000 (16:01 +0000)]
auto merge of #15521 : nick29581/rust/type, r=pcwalton

closes #13367

[breaking-change] Use `Sized?` to indicate a dynamically sized type parameter or trait (used to be `type`). E.g.,

```
trait Tr for Sized? {}

fn foo<Sized? X: Share>(x: X) {}
```

10 years agoGuide: complex data types
Steve Klabnik [Fri, 4 Jul 2014 19:07:27 +0000 (15:07 -0400)]
Guide: complex data types

10 years agoauto merge of #15518 : alexcrichton/rust/fix-some-crate-names, r=sfackler
bors [Tue, 8 Jul 2014 13:31:41 +0000 (13:31 +0000)]
auto merge of #15518 : alexcrichton/rust/fix-some-crate-names, r=sfackler

The output file was only being renamed based off #[crate_name], not #[crate_id]
or --crate-name. Both of these behaviors have been restored now.

10 years agorustc: Fix naming output files with --crate-name
Alex Crichton [Tue, 8 Jul 2014 02:04:34 +0000 (19:04 -0700)]
rustc: Fix naming output files with --crate-name

The output file was only being renamed based off #[crate_name], not #[crate_id]
or --crate-name. Both of these behaviors have been restored now.

10 years agoChange DST syntax: type -> Sized?
Nick Cameron [Tue, 8 Jul 2014 02:26:02 +0000 (14:26 +1200)]
Change DST syntax: type -> Sized?

closes #13367

[breaking-change] Use `Sized?` to indicate a dynamically sized type parameter or trait (used to be `type`). E.g.,

```
trait Tr for Sized? {}

fn foo<Sized? X: Share>(x: X) {}
```

10 years agoauto merge of #15516 : brson/rust/tidy, r=alexcrichton
bors [Tue, 8 Jul 2014 09:56:41 +0000 (09:56 +0000)]
auto merge of #15516 : brson/rust/tidy, r=alexcrichton

Tidy takes like forever to run. How many times have I wished I didn't have to sit through tidy before seeing my tests fail?

10 years agoauto merge of #15508 : jakub-/rust/struct-pattern-witness, r=alexcrichton
bors [Tue, 8 Jul 2014 04:21:40 +0000 (04:21 +0000)]
auto merge of #15508 : jakub-/rust/struct-pattern-witness, r=alexcrichton

10 years agoauto merge of #15443 : pcwalton/rust/module-and-type-with-same-name, r=nick29581
bors [Tue, 8 Jul 2014 02:36:43 +0000 (02:36 +0000)]
auto merge of #15443 : pcwalton/rust/module-and-type-with-same-name, r=nick29581

This will break code that looks like:

    struct Foo {
        ...
    }

    mod Foo {
        ...
    }

Change this code to:

    struct Foo {
        ...
    }

    impl Foo {
        ...
    }

Or rename the module.

Closes #15205.

[breaking-change]

r? @nick29581

10 years agomk: Run tidy after tests in 'make check'
Brian Anderson [Tue, 8 Jul 2014 01:02:59 +0000 (18:02 -0700)]
mk: Run tidy after tests in 'make check'

Tidy takes like forever to run.

10 years agoauto merge of #15406 : luqmana/rust/nop, r=pcwalton
bors [Tue, 8 Jul 2014 00:31:42 +0000 (00:31 +0000)]
auto merge of #15406 : luqmana/rust/nop, r=pcwalton

Extend the null ptr optimization to work with slices, closures, procs, & trait objects by using the internal pointers as the discriminant.

This decreases the size of `Option<&[int]>` (and similar) by one word.

10 years agoauto merge of #15394 : pcwalton/rust/new-index-traits, r=nick29581
bors [Mon, 7 Jul 2014 22:46:41 +0000 (22:46 +0000)]
auto merge of #15394 : pcwalton/rust/new-index-traits, r=nick29581

This will break code that used the old `Index` trait. Change this code
to use the new `Index` traits. For reference, here are their signatures:

    pub trait Index<Index,Result> {
        fn index<'a>(&'a self, index: &Index) -> &'a Result;
    }
    pub trait IndexMut<Index,Result> {
        fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Result;
    }

Closes #6515.

[breaking-change]

r? @nick29581

10 years agolibrustc: Update debuginfo.
Luqman Aden [Mon, 7 Jul 2014 21:41:18 +0000 (14:41 -0700)]
librustc: Update debuginfo.

10 years agoauto merge of #15440 : pcwalton/rust/struct-aliases, r=brson
bors [Mon, 7 Jul 2014 21:01:42 +0000 (21:01 +0000)]
auto merge of #15440 : pcwalton/rust/struct-aliases, r=brson

Closes #4508.

r? @nick29581

10 years agoImprove non-exhaustive pattern witnesses for structs with multiple fields
Jakub Wieczorek [Mon, 7 Jul 2014 18:54:50 +0000 (20:54 +0200)]
Improve non-exhaustive pattern witnesses for structs with multiple fields

10 years agoAdd libunicode; move unicode functions from core
kwantam [Mon, 30 Jun 2014 21:04:10 +0000 (17:04 -0400)]
Add libunicode; move unicode functions from core

- created new crate, libunicode, below libstd
- split Char trait into Char (libcore) and UnicodeChar (libunicode)
  - Unicode-aware functions now live in libunicode
    - is_alphabetic, is_XID_start, is_XID_continue, is_lowercase,
      is_uppercase, is_whitespace, is_alphanumeric, is_control,
      is_digit, to_uppercase, to_lowercase
  - added width method in UnicodeChar trait
    - determines printed width of character in columns, or None if it is
      a non-NULL control character
    - takes a boolean argument indicating whether the present context is
      CJK or not (characters with 'A'mbiguous widths are double-wide in
      CJK contexts, single-wide otherwise)
- split StrSlice into StrSlice (libcore) and UnicodeStrSlice
  (libunicode)
  - functionality formerly in StrSlice that relied upon Unicode
    functionality from Char is now in UnicodeStrSlice
    - words, is_whitespace, is_alphanumeric, trim, trim_left, trim_right
  - also moved Words type alias into libunicode because words method is
    in UnicodeStrSlice
- unified Unicode tables from libcollections, libcore, and libregex into
  libunicode
- updated unicode.py in src/etc to generate aforementioned tables
- generated new tables based on latest Unicode data
- added UnicodeChar and UnicodeStrSlice traits to prelude
- libunicode is now the collection point for the std::char module,
  combining the libunicode functionality with the Char functionality
  from libcore
  - thus, moved doc comment for char from core::char to unicode::char
- libcollections remains the collection point for std::str

The Unicode-aware functions that previously lived in the Char and
StrSlice traits are no longer available to programs that only use
libcore. To regain use of these methods, include the libunicode crate
and use the UnicodeChar and/or UnicodeStrSlice traits:

    extern crate unicode;
    use unicode::UnicodeChar;
    use unicode::UnicodeStrSlice;
    use unicode::Words; // if you want to use the words() method

NOTE: this does *not* impact programs that use libstd, since UnicodeChar
and UnicodeStrSlice have been added to the prelude.

closes #15224
[breaking-change]

10 years agolibrustc (RFC #34): Implement the new `Index` and `IndexMut` traits.
Patrick Walton [Thu, 3 Jul 2014 21:32:41 +0000 (14:32 -0700)]
librustc (RFC #34): Implement the new `Index` and `IndexMut` traits.

This will break code that used the old `Index` trait. Change this code
to use the new `Index` traits. For reference, here are their signatures:

    pub trait Index<Index,Result> {
        fn index<'a>(&'a self, index: &Index) -> &'a Result;
    }
    pub trait IndexMut<Index,Result> {
        fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Result;
    }

Closes #6515.

[breaking-change]

10 years agolibrustc: Disallow modules and types from having the same name.
Patrick Walton [Sat, 5 Jul 2014 00:59:55 +0000 (17:59 -0700)]
librustc: Disallow modules and types from having the same name.

This will break code that looks like:

    struct Foo {
        ...
    }

    mod Foo {
        ...
    }

Change this code to:

    struct Foo {
        ...
    }

    impl Foo {
        ...
    }

Or rename the module.

Closes #15205.

[breaking-change]

10 years agoauto merge of #15502 : sfackler/rust/link_args_spaces, r=alexcrichton
bors [Mon, 7 Jul 2014 17:16:34 +0000 (17:16 +0000)]
auto merge of #15502 : sfackler/rust/link_args_spaces, r=alexcrichton

Closes #15487

10 years agoStrip empty strings from link args
Steven Fackler [Mon, 7 Jul 2014 16:54:38 +0000 (09:54 -0700)]
Strip empty strings from link args

Closes #15487

10 years agocollections: merge unsafe_push_all_clone and push_all
Erick Tryzelaar [Mon, 7 Jul 2014 16:45:00 +0000 (09:45 -0700)]
collections: merge unsafe_push_all_clone and push_all

10 years agocollections: minimize code that's in unsafe blocks
Erick Tryzelaar [Mon, 7 Jul 2014 16:11:03 +0000 (09:11 -0700)]
collections: minimize code that's in unsafe blocks

This changes Vec::from_slice to call unsafe_push_all_clone
directly to avoid doing an unnecessary reserve_additional call

10 years agocollections: flesh out the Vec::clone_from benchmarks to cover reuse
Erick Tryzelaar [Mon, 7 Jul 2014 16:07:49 +0000 (09:07 -0700)]
collections: flesh out the Vec::clone_from benchmarks to cover reuse

10 years agoauto merge of #15496 : ruud-v-a/rust/patch-1, r=huonw
bors [Mon, 7 Jul 2014 08:16:29 +0000 (08:16 +0000)]
auto merge of #15496 : ruud-v-a/rust/patch-1, r=huonw

Also removes redundant newline in code block.

10 years agoauto merge of #15489 : jakub-/rust/issue-15488, r=pcwalton
bors [Mon, 7 Jul 2014 06:31:30 +0000 (06:31 +0000)]
auto merge of #15489 : jakub-/rust/issue-15488, r=pcwalton

Fixes #15488.

10 years agomanual: Fix typo.
Ruud van Asseldonk [Mon, 7 Jul 2014 05:51:34 +0000 (07:51 +0200)]
manual: Fix typo.

Also removes redundant newline in code block.

10 years agoauto merge of #15411 : mitchmindtree/rust/master, r=alexcrichton
bors [Mon, 7 Jul 2014 04:46:31 +0000 (04:46 +0000)]
auto merge of #15411 : mitchmindtree/rust/master, r=alexcrichton

I ran `make check` and everything went smoothly. I also tested `#[deriving(Decodable, Encodable)]` on a struct containing both Cell<T> and RefCell<T> and everything now seems to work fine.

10 years agoImplemented Decodable/Encodable for Cell and RefCell. Fixes #15395
mitchmindtree [Fri, 4 Jul 2014 12:24:50 +0000 (22:24 +1000)]
Implemented Decodable/Encodable for Cell and RefCell. Fixes #15395

Updated PR with fixme and test

Updated PR with fixme and test

10 years agoauto merge of #15464 : dotdash/rust/bool_stores, r=pcwalton
bors [Mon, 7 Jul 2014 03:01:34 +0000 (03:01 +0000)]
auto merge of #15464 : dotdash/rust/bool_stores, r=pcwalton

LLVM doesn't handle i1 value in allocas/memory very well and skips a number of optimizations if it hits it. So we have to do the same thing that Clang does, using i1 for SSA values, but storing i8 in memory.

Fixes #15203.

10 years agoauto merge of #15481 : alexcrichton/rust/fix-nightly, r=luqmana
bors [Sun, 6 Jul 2014 23:06:34 +0000 (23:06 +0000)]
auto merge of #15481 : alexcrichton/rust/fix-nightly, r=luqmana

The stage0 compiler for a non-CFG_BUILD architecture needs to have the new
`-C extra-filename` argument passed.

10 years agoProperly bind nested pattern bindings when there's more than one
Jakub Wieczorek [Sun, 6 Jul 2014 21:54:40 +0000 (23:54 +0200)]
Properly bind nested pattern bindings when there's more than one

Fixes #15488.

10 years agoauto merge of #15486 : jakub-/rust/test-case-12187, r=alexcrichton
bors [Sun, 6 Jul 2014 20:36:35 +0000 (20:36 +0000)]
auto merge of #15486 : jakub-/rust/test-case-12187, r=alexcrichton

Closes #12187.

10 years agoStore booleans as i8 in memory to improve optimizations by LLVM
Björn Steinbrink [Sat, 5 Jul 2014 19:47:14 +0000 (21:47 +0200)]
Store booleans as i8 in memory to improve optimizations by LLVM

LLVM doesn't really like types with a bit-width that isn't a multiple of
8 and disable various optimizations if it encounters such types used
with loads/stores. OTOH, booleans must be represented as i1 when used as
SSA values. To get the best results, we must use i1 for SSA values, and
i8 when storing the value to memory.

By using range asserts on loads, LLVM can eliminate the required
zero-extend and truncate operations.

Fixes #15203

10 years agoRemove remainders from when booleans were i8
Björn Steinbrink [Sat, 5 Jul 2014 19:43:47 +0000 (21:43 +0200)]
Remove remainders from when booleans were i8

10 years agoAdd a test case for #12187, which appears to have been fixed
Jakub Wieczorek [Sun, 6 Jul 2014 19:39:59 +0000 (21:39 +0200)]
Add a test case for #12187, which appears to have been fixed

Closes #12187.

10 years agoauto merge of #15467 : brson/rust/guideversion, r=alexcrichton
bors [Sun, 6 Jul 2014 18:51:34 +0000 (18:51 +0000)]
auto merge of #15467 : brson/rust/guideversion, r=alexcrichton

10 years agoauto merge of #15465 : SimonSapin/rust/patch-4, r=alexcrichton
bors [Sun, 6 Jul 2014 17:06:36 +0000 (17:06 +0000)]
auto merge of #15465 : SimonSapin/rust/patch-4, r=alexcrichton

`Vec::push_all` with a length 1 slice seems to have significant overhead compared to `Vec::push`.

```
test new_push_byte ... bench:      6985 ns/iter (+/- 487) = 17 MB/s
test old_push_byte ... bench:     19335 ns/iter (+/- 1368) = 6 MB/s
```

```rust
extern crate test;
use test::Bencher;

static TEXT: &'static str = "\
    Unicode est un standard informatique qui permet des échanges \
    de textes dans différentes langues, à un niveau mondial.";

#[bench]
fn old_push_byte(bencher: &mut Bencher) {
    bencher.bytes = TEXT.len() as u64;
    bencher.iter(|| {
        let mut new = String::new();
        for b in TEXT.bytes() {
            unsafe { new.as_mut_vec().push_all([b]) }
        }
    })
}

#[bench]
fn new_push_byte(bencher: &mut Bencher) {
    bencher.bytes = TEXT.len() as u64;
    bencher.iter(|| {
        let mut new = String::new();
        for b in TEXT.bytes() {
            unsafe { new.as_mut_vec().push(b) }
        }
    })
}
```

10 years agomk: Fix bootstrapping the nightly builds
Alex Crichton [Sun, 6 Jul 2014 15:28:06 +0000 (08:28 -0700)]
mk: Fix bootstrapping the nightly builds

The stage0 compiler for a non-CFG_BUILD architecture needs to have the new
`-C extra-filename` argument passed.

10 years agoauto merge of #15456 : aochagavia/rust/guide, r=alexcrichton
bors [Sun, 6 Jul 2014 13:26:35 +0000 (13:26 +0000)]
auto merge of #15456 : aochagavia/rust/guide, r=alexcrichton

Fixes https://github.com/rust-lang/rust/issues/15452

10 years agoauto merge of #15454 : jakub-/rust/15453, r=huonw
bors [Sun, 6 Jul 2014 11:41:37 +0000 (11:41 +0000)]
auto merge of #15454 : jakub-/rust/15453, r=huonw

I forget we now have byte string literals.

10 years agoauto merge of #15447 : patrickyevsukov/rust/patch-1, r=alexcrichton
bors [Sun, 6 Jul 2014 09:56:38 +0000 (09:56 +0000)]
auto merge of #15447 : patrickyevsukov/rust/patch-1, r=alexcrichton

Fix Typos

10 years agoauto merge of #15472 : luqmana/rust/snaps, r=alexcrichton
bors [Sun, 6 Jul 2014 07:31:38 +0000 (07:31 +0000)]
auto merge of #15472 : luqmana/rust/snaps, r=alexcrichton

10 years agoRegister snapshot.
Luqman Aden [Sun, 6 Jul 2014 06:13:35 +0000 (02:13 -0400)]
Register snapshot.

10 years agostd: flesh out MemWriter benchmarks
Erick Tryzelaar [Sun, 6 Jul 2014 05:31:57 +0000 (22:31 -0700)]
std: flesh out MemWriter benchmarks

10 years agocollections: Optimize Vec when cloning from a slice
Erick Tryzelaar [Sun, 6 Jul 2014 06:11:18 +0000 (23:11 -0700)]
collections: Optimize Vec when cloning from a slice

llvm is currently not able to conver `Vec::extend` into a memcpy
for `Copy` types, which results in methods like `Vec::push_all`
to run twice as slow as it should be running. This patch takes
the unsafe `Vec::clone` optimization to speed up all the operations
that are cloning a slice into a `Vec`.

before:

test vec::tests::bench_clone_from_0000_0000                ... bench:        12 ns/iter (+/- 2)
test vec::tests::bench_clone_from_0000_0010                ... bench:       125 ns/iter (+/- 4) = 80 MB/s
test vec::tests::bench_clone_from_0000_0100                ... bench:       360 ns/iter (+/- 33) = 277 MB/s
test vec::tests::bench_clone_from_0000_1000                ... bench:      2601 ns/iter (+/- 175) = 384 MB/s
test vec::tests::bench_clone_from_0010_0000                ... bench:        12 ns/iter (+/- 2)
test vec::tests::bench_clone_from_0010_0010                ... bench:       125 ns/iter (+/- 10) = 80 MB/s
test vec::tests::bench_clone_from_0010_0100                ... bench:       361 ns/iter (+/- 28) = 277 MB/s
test vec::tests::bench_clone_from_0100_0010                ... bench:       131 ns/iter (+/- 13) = 76 MB/s
test vec::tests::bench_clone_from_0100_0100                ... bench:       360 ns/iter (+/- 9) = 277 MB/s
test vec::tests::bench_clone_from_0100_1000                ... bench:      2575 ns/iter (+/- 168) = 388 MB/s
test vec::tests::bench_clone_from_1000_0100                ... bench:       356 ns/iter (+/- 20) = 280 MB/s
test vec::tests::bench_clone_from_1000_1000                ... bench:      2605 ns/iter (+/- 167) = 383 MB/s
test vec::tests::bench_from_slice_0000                     ... bench:        11 ns/iter (+/- 0)
test vec::tests::bench_from_slice_0010                     ... bench:       115 ns/iter (+/- 5) = 86 MB/s
test vec::tests::bench_from_slice_0100                     ... bench:       309 ns/iter (+/- 170) = 323 MB/s
test vec::tests::bench_from_slice_1000                     ... bench:      2065 ns/iter (+/- 198) = 484 MB/s
test vec::tests::bench_push_all_0000_0000                  ... bench:         7 ns/iter (+/- 0)
test vec::tests::bench_push_all_0000_0010                  ... bench:        79 ns/iter (+/- 7) = 126 MB/s
test vec::tests::bench_push_all_0000_0100                  ... bench:       342 ns/iter (+/- 18) = 292 MB/s
test vec::tests::bench_push_all_0000_1000                  ... bench:      2873 ns/iter (+/- 75) = 348 MB/s
test vec::tests::bench_push_all_0010_0010                  ... bench:       154 ns/iter (+/- 8) = 64 MB/s
test vec::tests::bench_push_all_0100_0100                  ... bench:       518 ns/iter (+/- 18) = 193 MB/s
test vec::tests::bench_push_all_1000_1000                  ... bench:      4490 ns/iter (+/- 223) = 222 MB/s

after:

test vec::tests::bench_clone_from_0000_0000                ... bench:        12 ns/iter (+/- 1)
test vec::tests::bench_clone_from_0000_0010                ... bench:       123 ns/iter (+/- 5) = 81 MB/s
test vec::tests::bench_clone_from_0000_0100                ... bench:       367 ns/iter (+/- 23) = 272 MB/s
test vec::tests::bench_clone_from_0000_1000                ... bench:      2618 ns/iter (+/- 252) = 381 MB/s
test vec::tests::bench_clone_from_0010_0000                ... bench:        12 ns/iter (+/- 1)
test vec::tests::bench_clone_from_0010_0010                ... bench:       124 ns/iter (+/- 7) = 80 MB/s
test vec::tests::bench_clone_from_0010_0100                ... bench:       369 ns/iter (+/- 34) = 271 MB/s
test vec::tests::bench_clone_from_0100_0010                ... bench:       123 ns/iter (+/- 6) = 81 MB/s
test vec::tests::bench_clone_from_0100_0100                ... bench:       371 ns/iter (+/- 25) = 269 MB/s
test vec::tests::bench_clone_from_0100_1000                ... bench:      2713 ns/iter (+/- 532) = 368 MB/s
test vec::tests::bench_clone_from_1000_0100                ... bench:       369 ns/iter (+/- 14) = 271 MB/s
test vec::tests::bench_clone_from_1000_1000                ... bench:      2611 ns/iter (+/- 194) = 382 MB/s
test vec::tests::bench_from_slice_0000                     ... bench:         7 ns/iter (+/- 0)
test vec::tests::bench_from_slice_0010                     ... bench:       108 ns/iter (+/- 4) = 92 MB/s
test vec::tests::bench_from_slice_0100                     ... bench:       235 ns/iter (+/- 24) = 425 MB/s
test vec::tests::bench_from_slice_1000                     ... bench:      1318 ns/iter (+/- 96) = 758 MB/s
test vec::tests::bench_push_all_0000_0000                  ... bench:         7 ns/iter (+/- 0)
test vec::tests::bench_push_all_0000_0010                  ... bench:        70 ns/iter (+/- 4) = 142 MB/s
test vec::tests::bench_push_all_0000_0100                  ... bench:       176 ns/iter (+/- 16) = 568 MB/s
test vec::tests::bench_push_all_0000_1000                  ... bench:      1125 ns/iter (+/- 94) = 888 MB/s
test vec::tests::bench_push_all_0010_0010                  ... bench:       159 ns/iter (+/- 15) = 62 MB/s
test vec::tests::bench_push_all_0100_0100                  ... bench:       363 ns/iter (+/- 12) = 275 MB/s
test vec::tests::bench_push_all_1000_1000                  ... bench:      2860 ns/iter (+/- 415) = 349 MB/s

10 years agocollections: flesh out Vec benchmarks
Erick Tryzelaar [Sun, 6 Jul 2014 06:07:28 +0000 (23:07 -0700)]
collections: flesh out Vec benchmarks

10 years agoauto merge of #15441 : P1start/rust/lifetime-suggest, r=pcwalton
bors [Sun, 6 Jul 2014 05:46:36 +0000 (05:46 +0000)]
auto merge of #15441 : P1start/rust/lifetime-suggest, r=pcwalton

Closes #15433.