]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #13936 : Armavica/rust/lint_check-range, r=kballard
bors [Mon, 5 May 2014 08:41:39 +0000 (01:41 -0700)]
auto merge of #13936 : Armavica/rust/lint_check-range, r=kballard

Some cases were not correctly handled by this lint, for instance `let a = 42u8; a < 0` and `let a = 42u8; a > 255`.
It led to the discovery of two useless comparisons, which I removed.

10 years agoauto merge of #13930 : alexcrichton/rust/snapshots, r=huonw
bors [Mon, 5 May 2014 06:16:40 +0000 (23:16 -0700)]
auto merge of #13930 : alexcrichton/rust/snapshots, r=huonw

cc @pcwalton and @flaper87, this has box expressions and opt-in builtin kinds.

10 years agoRegister new snapshots
Alex Crichton [Sun, 4 May 2014 08:16:16 +0000 (01:16 -0700)]
Register new snapshots

10 years agoauto merge of #13924 : gmjosack/rust/master, r=alexcrichton
bors [Mon, 5 May 2014 03:51:43 +0000 (20:51 -0700)]
auto merge of #13924 : gmjosack/rust/master, r=alexcrichton

Most of the links I've removed are for types that don't exist anymore with the exception of `SendReceiver` though I'm not sure how useful it is to link to that without the accompanying `Receiver` and `Sender` and I don't know how useful those links are when they're discussed below and `channel`/`sync_channel` is on the `std::comm` page already linked.

10 years agoauto merge of #13865 : alexcrichton/rust/issue-13861, r=brson
bors [Mon, 5 May 2014 01:36:43 +0000 (18:36 -0700)]
auto merge of #13865 : alexcrichton/rust/issue-13861, r=brson

Previously, windows was using the CREATE_NEW flag which fails if the file
previously existed, which differed from the unix semantics. This alters the
opening to use the OPEN_ALWAYS flag to mirror the unix semantics.

Closes #13861

10 years agoauto merge of #13905 : alexcrichton/rust/issue-13337, r=thestinger
bors [Mon, 5 May 2014 00:11:42 +0000 (17:11 -0700)]
auto merge of #13905 : alexcrichton/rust/issue-13337, r=thestinger

This has long since not been too relevant since the introduction of many crate
type outputs. This commit removes the flag entirely, adjusting all logic to do
the most reasonable thing when building both a library and an executable.

Closes #13337

10 years agoauto merge of #13923 : Rufflewind/rust/patch-2, r=thestinger
bors [Sun, 4 May 2014 22:46:42 +0000 (15:46 -0700)]
auto merge of #13923 : Rufflewind/rust/patch-2, r=thestinger

Lazy loading with autoload will result in faster startup time for Emacs
users and is generally the recommended approach for major modes.

10 years agoauto merge of #13676 : mdinger/rust/tutorial_doc, r=pnkfelix
bors [Sun, 4 May 2014 21:21:52 +0000 (14:21 -0700)]
auto merge of #13676 : mdinger/rust/tutorial_doc, r=pnkfelix

Improve tutorial discussion of closures, e.g. with respect to type inference and variable capture.

Fix #13621

---- original description follows

I'd like this pulled to master if possible but if not I'd appreciate comments on what I need to change.  I found the closures difficult to understand as they were so I tried to explain it so I would've had an easier time understanding it.  I think it's better at least, somewhat.

I don't know that everyone liked the `-> ()` I included but I thought explicit is best to aid understanding.  I thought it was much harder to understand than it should have been.

[EDIT] - Clicked too early.
This doesn't `make check` without errors on my Xubuntu on Virtualbox machine.  Not sure why.  I don't think I changed anything problematic.  I'll try `make check` on master tomorrow.

Opened https://github.com/mozilla/rust/issues/13621 regarding this.

10 years agoauto merge of #13921 : TeXitoi/rust/shootout-spectralnorm-tweaks, r=alexcrichton
bors [Sun, 4 May 2014 19:06:50 +0000 (12:06 -0700)]
auto merge of #13921 : TeXitoi/rust/shootout-spectralnorm-tweaks, r=alexcrichton

- using libgreen to optimize CPU usage
- less tasks to limit wasted resources

Here, on a one core 2 threads CPU, new version is ~1.2 faster.  May
be better with more core.

10 years agoRemove two useless comparisons
Virgile Andreani [Sun, 4 May 2014 18:48:16 +0000 (20:48 +0200)]
Remove two useless comparisons

according to the updated type_limits lint.

10 years agoAdd missing cases to the type_limits lint
Virgile Andreani [Sun, 4 May 2014 18:42:45 +0000 (20:42 +0200)]
Add missing cases to the type_limits lint

and exhaustive testing for the `u8` type.

10 years agoauto merge of #13920 : Ryman/rust/inner_attr_doc, r=alexcrichton
bors [Sun, 4 May 2014 17:41:48 +0000 (10:41 -0700)]
auto merge of #13920 : Ryman/rust/inner_attr_doc, r=alexcrichton

Also updated the comment for `parse_inner_attrs_and_next` and removed extra whitespace on line endings.

10 years agoauto merge of #13916 : TeXitoi/rust/shootout-mandelbrot-rewrite, r=pcwalton
bors [Sun, 4 May 2014 15:26:47 +0000 (08:26 -0700)]
auto merge of #13916 : TeXitoi/rust/shootout-mandelbrot-rewrite, r=pcwalton

- removed warning
- improved performances
- parallelization

10 years agoauto merge of #13915 : nick29581/rust/rslt, r=luqmana
bors [Sun, 4 May 2014 14:01:48 +0000 (07:01 -0700)]
auto merge of #13915 : nick29581/rust/rslt, r=luqmana

10 years agoauto merge of #13908 : pcwalton/rust/box-pattern, r=alexcrichton
bors [Sun, 4 May 2014 12:36:49 +0000 (05:36 -0700)]
auto merge of #13908 : pcwalton/rust/box-pattern, r=alexcrichton

r? @alexcrichton

10 years agoauto merge of #13898 : nikomatsakis/rust/type-bounds-b, r=acrichto
bors [Sun, 4 May 2014 10:41:50 +0000 (03:41 -0700)]
auto merge of #13898 : nikomatsakis/rust/type-bounds-b, r=acrichto

This is needed to bootstrap fix for #5723.

10 years agoauto merge of #13391 : smesseim/rust/apache-copyright, r=alexcrichton
bors [Sun, 4 May 2014 09:16:50 +0000 (02:16 -0700)]
auto merge of #13391 : smesseim/rust/apache-copyright, r=alexcrichton

The years of copyright and the name of the copyright holder were not
present in the notice.

The Apache license was added to the project in 2012, so 2012 is the
starting year. The copyright holder is the Mozilla Foundation (taken
from the MIT license).

10 years agoauto merge of #13895 : adrientetar/rust/js-escape, r=alexcrichton
bors [Sun, 4 May 2014 07:51:50 +0000 (00:51 -0700)]
auto merge of #13895 : adrientetar/rust/js-escape, r=alexcrichton

See #13884 for the details. Closes #13884.

r? @alexcrichton

10 years agoSkip pretty printing for the regions bound test
Niko Matsakis [Sun, 4 May 2014 02:05:21 +0000 (22:05 -0400)]
Skip pretty printing for the regions bound test

10 years agoRemove/Update dead links on Tasks guide.
Gary M. Josack [Sat, 3 May 2014 23:53:26 +0000 (16:53 -0700)]
Remove/Update dead links on Tasks guide.

10 years agoauto merge of #13906 : alexcrichton/rust/issue-13620, r=luqmana
bors [Sat, 3 May 2014 22:56:51 +0000 (15:56 -0700)]
auto merge of #13906 : alexcrichton/rust/issue-13620, r=luqmana

This ensures that private functions exported through static initializers will
actually end up being public in the object file (so other objects can continue
to reference the function).

Closes #13620

10 years agoChange the licence holder to The Rust Project Developers
Ali Smesseim [Mon, 7 Apr 2014 22:24:54 +0000 (00:24 +0200)]
Change the licence holder to The Rust Project Developers

The copyright of this project belongs to The Rust Project Developers,
who are mentioned in AUTHORS.txt.

10 years agoshootout-spectralnorm tweaks
Guillaume Pinot [Sat, 3 May 2014 21:11:23 +0000 (23:11 +0200)]
shootout-spectralnorm tweaks

- using libgreen to optimize CPU usage
- less tasks to limit wasted resources

Here, on a one core 2 threads CPU, new version is ~1.2 faster.  May
be better with more core.

10 years agoRecommend autoload instead of require
Phil Ruffwind [Sat, 3 May 2014 20:36:54 +0000 (16:36 -0400)]
Recommend autoload instead of require

Lazy loading with autoload will result in faster startup time for Emacs
users and is generally the recommended approach for major modes.

10 years agoRemove comment about semicolons for inner attributes from docs and adjust comments.
Kevin Butler [Sat, 3 May 2014 20:24:06 +0000 (21:24 +0100)]
Remove comment about semicolons for inner attributes from docs and adjust comments.

10 years agoauto merge of #13685 : Ryman/rust/issue7575, r=alexcrichton
bors [Sat, 3 May 2014 19:21:47 +0000 (12:21 -0700)]
auto merge of #13685 : Ryman/rust/issue7575, r=alexcrichton

Closes #7575.

I don't think the change from a contains lookup to an iteration of the HashSet in the resolver should be much of a burden as the set of methods with the same name should be relatively small.

10 years agoauto merge of #13773 : brson/rust/boxxy, r=alexcrichton
bors [Sat, 3 May 2014 17:56:57 +0000 (10:56 -0700)]
auto merge of #13773 : brson/rust/boxxy, r=alexcrichton

`box` is the way you allocate in future-rust.

10 years agoTemporary patch to accept arbitrary lifetimes (behind feature gate) in bound lists...
Niko Matsakis [Fri, 2 May 2014 18:04:26 +0000 (14:04 -0400)]
Temporary patch to accept arbitrary lifetimes (behind feature gate) in bound lists. This is needed to bootstrap fix for #5723.

10 years agoauto merge of #13904 : pcwalton/rust/box, r=alexcrichton
bors [Sat, 3 May 2014 16:31:49 +0000 (09:31 -0700)]
auto merge of #13904 : pcwalton/rust/box, r=alexcrichton

r? @alexcrichton

RFC#14

Issue #13885.

10 years agoauto merge of #13868 : FlaPer87/rust/opt-in-phase1, r=alexcrichton
bors [Sat, 3 May 2014 15:06:49 +0000 (08:06 -0700)]
auto merge of #13868 : FlaPer87/rust/opt-in-phase1, r=alexcrichton

This is a first patch towards an opt-in built-in trait world. This patch removes the restriction on built-in traits and allows such traits to be derived.

[RFC#3]

cc #13231

@nikomatsakis r?

10 years agoauto merge of #13903 : alexcrichton/rust/issue-13890, r=thestinger
bors [Sat, 3 May 2014 13:41:53 +0000 (06:41 -0700)]
auto merge of #13903 : alexcrichton/rust/issue-13890, r=thestinger

The logic of the custom realpath function in metadata::loader was incorrect, but
the logic in util::fs was correct.

Closes #13890

10 years agoshootout-mandelbrot rewrite
Guillaume Pinot [Sat, 3 May 2014 12:53:52 +0000 (14:53 +0200)]
shootout-mandelbrot rewrite

- removed warning
- improved performances
- parallelization

10 years agoauto merge of #13899 : bjz/rust/simd, r=pcwalton
bors [Sat, 3 May 2014 11:21:51 +0000 (04:21 -0700)]
auto merge of #13899 : bjz/rust/simd, r=pcwalton

cc. @pcwalton

10 years agoRefactor `rslt` to `Result::new`
Nick Cameron [Sat, 3 May 2014 11:14:56 +0000 (23:14 +1200)]
Refactor `rslt` to `Result::new`

10 years agoauto merge of #13891 : hjr3/rust/serialize-vec, r=pcwalton
bors [Sat, 3 May 2014 08:26:49 +0000 (01:26 -0700)]
auto merge of #13891 : hjr3/rust/serialize-vec, r=pcwalton

Now that ~[T] is obsolete, we need to allow to_json() to work for
vectors.

10 years agoReplace most ~exprs with 'box'. #11779
Brian Anderson [Fri, 25 Apr 2014 08:08:02 +0000 (01:08 -0700)]
Replace most ~exprs with 'box'. #11779

10 years agoemacs: Add 'box' to keywords
Brian Anderson [Fri, 25 Apr 2014 05:40:45 +0000 (22:40 -0700)]
emacs: Add 'box' to keywords

10 years agoauto merge of #13880 : TeXitoi/rust/biguint-always-use-u64, r=pcwalton
bors [Sat, 3 May 2014 03:56:52 +0000 (20:56 -0700)]
auto merge of #13880 : TeXitoi/rust/biguint-always-use-u64, r=pcwalton

This change allow a speedup of ~1.5 on shootout-pidigits on a i32
system.  `MachineUint` is used to abstract the internal machine
unsigned integer to simplity future architecture specialization.

10 years agolibsyntax: Add `box PAT` to the pattern grammar. RFC #14.
Patrick Walton [Sat, 3 May 2014 00:21:36 +0000 (17:21 -0700)]
libsyntax: Add `box PAT` to the pattern grammar. RFC #14.

10 years agolibrustc: Implement the `Box<T>` type syntax. RFC #14. Issue #13885.
Patrick Walton [Fri, 2 May 2014 21:53:33 +0000 (14:53 -0700)]
librustc: Implement the `Box<T>` type syntax. RFC #14. Issue #13885.

10 years agoauto merge of #13579 : hirschenberger/rust/lint_unsigned_negate, r=alexcrichton
bors [Fri, 2 May 2014 23:51:50 +0000 (16:51 -0700)]
auto merge of #13579 : hirschenberger/rust/lint_unsigned_negate, r=alexcrichton

See #11273 and #13318

10 years agorustc: Crawl static initializers for reachability
Alex Crichton [Fri, 2 May 2014 22:40:07 +0000 (15:40 -0700)]
rustc: Crawl static initializers for reachability

This ensures that private functions exported through static initializers will
actually end up being public in the object file (so other objects can continue
to reference the function).

Closes #13620

10 years agorustc: Remove the session building_library flag
Alex Crichton [Fri, 2 May 2014 22:26:45 +0000 (15:26 -0700)]
rustc: Remove the session building_library flag

This has long since not been too relevant since the introduction of many crate
type outputs. This commit removes the flag entirely, adjusting all logic to do
the most reasonable thing when building both a library and an executable.

Closes #13337

10 years agoAdd lint check for negating uint literals and variables.
Falco Hirschenberger [Fri, 2 May 2014 22:13:26 +0000 (00:13 +0200)]
Add lint check for negating uint literals and variables.

See #11273 and #13318

10 years agoProvide a note if method lookup fails and there are static definitions with the same...
Kevin Butler [Tue, 22 Apr 2014 11:20:08 +0000 (12:20 +0100)]
Provide a note if method lookup fails and there are static definitions with the same name.

10 years agorustc: Use the "real" realpath function
Alex Crichton [Fri, 2 May 2014 20:50:24 +0000 (13:50 -0700)]
rustc: Use the "real" realpath function

The logic of the custom realpath function in metadata::loader was incorrect, but
the logic in util::fs was correct.

Closes #13890

10 years agoImplement comparison operators for int and uint SIMD vectors
Brendan Zabarauskas [Fri, 2 May 2014 18:04:46 +0000 (11:04 -0700)]
Implement comparison operators for int and uint SIMD vectors

10 years agorustdoc: escape shown input to prevent injection
Adrien Tétar [Fri, 2 May 2014 09:32:41 +0000 (11:32 +0200)]
rustdoc: escape shown input to prevent injection

10 years agoauto merge of #13879 : huonw/rust/more-re, r=alexcrichton
bors [Fri, 2 May 2014 14:06:50 +0000 (07:06 -0700)]
auto merge of #13879 : huonw/rust/more-re, r=alexcrichton

Commits for details.

This shouldn't change the generated code at all (except for switching to `LitBinary` from an explicit ExprVec of individual ExprLit bytes for `prefix_bytes`).

10 years agoregex_macros: simplify using AstBuilder & the improved quoting.
Huon Wilson [Thu, 1 May 2014 13:51:23 +0000 (23:51 +1000)]
regex_macros: simplify using AstBuilder & the improved quoting.

char literals now work in a quotation.

There were several instances of duplicated functionality in regex_macros
compared to AstBuilder so refactor those out.

10 years agosyntax: implement ToSource for more things in the quasiquoter.
Huon Wilson [Thu, 1 May 2014 13:39:00 +0000 (23:39 +1000)]
syntax: implement ToSource for more things in the quasiquoter.

The last few primitive types were missing.

10 years agosyntax: store char literals/tokens as `char`s rather than u32s.
Huon Wilson [Thu, 1 May 2014 13:35:06 +0000 (23:35 +1000)]
syntax: store char literals/tokens as `char`s rather than u32s.

Clearly storing them as `char` is semantically nicer, but this also
fixes a bug whereby `quote_expr!(cx, 'a')` wasn't working, because the
code created by quotation was not matching the actual AST definitions.

10 years agoImplement ToJson for Vec<T>
Herman J. Radtke III [Fri, 2 May 2014 07:02:15 +0000 (00:02 -0700)]
Implement ToJson for Vec<T>

Now that ~[T] is obsolete, we need to allow to_json() to work for
vectors.

10 years agoauto merge of #13789 : sfackler/rust/debug-assert, r=pcwalton
bors [Fri, 2 May 2014 06:41:46 +0000 (23:41 -0700)]
auto merge of #13789 : sfackler/rust/debug-assert, r=pcwalton

I switched the `assert!` calls in `RefCell` over to `debug_assert!`.
There are probably other instances that should be converted as well, but
I couldn't think of any off the top of my head.

RFC: 0015-assert

10 years agoauto merge of #13886 : japaric/rust/fix-an-typos, r=alexcrichton
bors [Fri, 2 May 2014 03:11:47 +0000 (20:11 -0700)]
auto merge of #13886 : japaric/rust/fix-an-typos, r=alexcrichton

Found the first one in the rust reference docs. I was going to submit a PR with one fix, but figured I could look for more... This is the result.

10 years agoRemove useless assert! case
Steven Fackler [Sun, 27 Apr 2014 02:55:26 +0000 (19:55 -0700)]
Remove useless assert! case

10 years agoAdd debug_assert and debug_assert_eq macros
Steven Fackler [Sun, 27 Apr 2014 01:25:20 +0000 (18:25 -0700)]
Add debug_assert and debug_assert_eq macros

I also switched some `assert!` calls over to `debug_assert!`.

Closes #12049.

RFC: 0015-assert

10 years agoFix a/an typos
Jorge Aparicio [Fri, 2 May 2014 01:02:11 +0000 (20:02 -0500)]
Fix a/an typos

10 years agoauto merge of #13877 : thestinger/rust/de-tilde-str-vec, r=alexcrichton
bors [Thu, 1 May 2014 23:06:48 +0000 (16:06 -0700)]
auto merge of #13877 : thestinger/rust/de-tilde-str-vec, r=alexcrichton

10 years agofix error message for obsolete &"foo" literal
Daniel Micay [Thu, 1 May 2014 07:00:19 +0000 (03:00 -0400)]
fix error message for obsolete &"foo" literal

10 years agoremove leftover obsolete string literals
Daniel Micay [Thu, 1 May 2014 05:32:13 +0000 (01:32 -0400)]
remove leftover obsolete string literals

10 years agoAllow built-in traits to be derived
Flavio Percoco [Wed, 30 Apr 2014 09:26:50 +0000 (11:26 +0200)]
Allow built-in traits to be derived

[RFC #3]

cc #13231

10 years agoauto merge of #13881 : aochagavia/rust/pr, r=alexcrichton
bors [Thu, 1 May 2014 20:31:59 +0000 (13:31 -0700)]
auto merge of #13881 : aochagavia/rust/pr, r=alexcrichton

10 years agoauto merge of #13878 : brutal-chaos/rust/tutorial_grammar, r=alexcrichton
bors [Thu, 1 May 2014 19:06:52 +0000 (12:06 -0700)]
auto merge of #13878 : brutal-chaos/rust/tutorial_grammar, r=alexcrichton

10 years agoBigUint always use u64 as the internal machine unsigned integer
Guillaume Pinot [Thu, 1 May 2014 14:02:44 +0000 (16:02 +0200)]
BigUint always use u64 as the internal machine unsigned integer

This change allow a speedup of ~1.5 on shootout-pidigits on a i32
system.  `DoubleBigDigit` is used to abstract the internal
unsigned integer used in computation to simplity future
architecture specialization.

`BigDigit::from_uint` and `BigDigit::to_uint` become
`BigDigit::from_doublebigdigit` and `BigDigit::to_doublebigdigit`.

[breaking-change]

10 years agoAdd more comprehensive unit tests for SIMD binops
Brendan Zabarauskas [Thu, 1 May 2014 16:05:13 +0000 (09:05 -0700)]
Add more comprehensive unit tests for SIMD binops

10 years agoauto merge of #13875 : hjr3/rust/serialize-strbuf, r=alexcrichton
bors [Thu, 1 May 2014 16:41:54 +0000 (09:41 -0700)]
auto merge of #13875 : hjr3/rust/serialize-strbuf, r=alexcrichton

- implement Encodable and Decodable for StrBuf
- implement to_json for StrBuf

10 years agoFixed outdated note in the tutorial
Adolfo Ochagavía [Thu, 1 May 2014 15:52:17 +0000 (17:52 +0200)]
Fixed outdated note in the tutorial

10 years agoauto merge of #13724 : nikomatsakis/rust/expr-use-visitor, r=pnkfelix
bors [Thu, 1 May 2014 11:36:50 +0000 (04:36 -0700)]
auto merge of #13724 : nikomatsakis/rust/expr-use-visitor, r=pnkfelix

Pre-step towards issue #12624 and others: Introduce ExprUseVisitor, remove the
moves computation. ExprUseVisitor is a visitor that walks the AST for a
function and calls a delegate to inform it where borrows, copies, and moves
occur.

In this patch, I rewrite the gather_loans visitor to use ExprUseVisitor, but in
future patches, I think we could rewrite regionck, check_loans, and possibly
other passes to use it as well. This would refactor the repeated code between
those places that tries to determine where copies/moves/etc occur.

r? @alexcrichton

10 years agorustdoc tutorial: grammar change in list comments
Justin Noah [Thu, 1 May 2014 08:16:30 +0000 (01:16 -0700)]
rustdoc tutorial: grammar change in list comments

10 years agoauto merge of #13873 : alexcrichton/rust/issue-13872, r=Aatch
bors [Thu, 1 May 2014 07:56:48 +0000 (00:56 -0700)]
auto merge of #13873 : alexcrichton/rust/issue-13872, r=Aatch

This was just a typo in the decoder using the source crate's number rather than
the destination crate's number of a reexport.

Closes #13872

10 years agoAdd serialization support for StrBuf
Herman J. Radtke III [Wed, 30 Apr 2014 22:55:04 +0000 (15:55 -0700)]
Add serialization support for StrBuf

- implement Encodable and Decodable for StrBuf
- implement to_json for StrBuf

10 years agorustc: Fix def ids of xcrate-reexported items
Alex Crichton [Thu, 1 May 2014 02:24:21 +0000 (19:24 -0700)]
rustc: Fix def ids of xcrate-reexported items

This was just a typo in the decoder using the source crate's number rather than
the destination crate's number of a reexport.

Closes #13872

10 years agoMerge pull request #1 from pnkfelix/clarify-omit-unit-vs-inference
mdinger [Thu, 1 May 2014 00:40:03 +0000 (20:40 -0400)]
Merge pull request #1 from pnkfelix/clarify-omit-unit-vs-inference

Suggested revisions to PR 13676.

10 years agoAddress nits from @pnkfelix
Niko Matsakis [Thu, 1 May 2014 00:22:36 +0000 (20:22 -0400)]
Address nits from @pnkfelix

10 years agolibrustc: Remove `~"string"` and `&"string"` from the language
Patrick Walton [Wed, 30 Apr 2014 23:49:12 +0000 (16:49 -0700)]
librustc: Remove `~"string"` and `&"string"` from the language

10 years agoAllow manual implementations of built-in traits
Flavio Percoco [Fri, 11 Apr 2014 21:48:02 +0000 (23:48 +0200)]
Allow manual implementations of built-in traits

[RFC #3]

cc #13231

10 years agoauto merge of #13648 : gereeter/rust/removed-rev, r=alexcrichton
bors [Wed, 30 Apr 2014 22:46:47 +0000 (15:46 -0700)]
auto merge of #13648 : gereeter/rust/removed-rev, r=alexcrichton

In the process, `Splits` got changed to be more like `CharSplits` in `str` to present the DEI interface.

Note that `treemap` still has a `rev_iter` function because it seems like it would be a significant interface change to expose a DEI - the iterator would have to gain an extra pointer, the completion checks would be more complicated, and it isn't easy to check that such an implementation is correct due to the use of unsafety to subvert the aliasing properties of `&mut`.

This fixes #9391.

10 years agoauto merge of #13864 : adrientetar/rust/fix-it-some-more, r=alexcrichton
bors [Wed, 30 Apr 2014 21:06:47 +0000 (14:06 -0700)]
auto merge of #13864 : adrientetar/rust/fix-it-some-more, r=alexcrichton

Two selector fixes for rustdoc:

- links colored in blue (#13807) was also affecting headers, which are anchored to their respective ids
- the header unstyling from #13776 was being applied to all headers also

Additionally, remove a stray title in the documentation. This makes the crate title of prelude appear as header instead of an inline paragraph of text (all others work normally and do not have that header tag).

The design is unchanged from my previous template (e.g. [here](http://adrientetar.legtux.org/cached/rust-docs/struct.CChars.htm)), however it is now properly applied.
The last fix remaining is to enable webfonts service from `static.rust-lang.org`, this is #13593.

r? @alexcrichton, @brson

10 years agonative: Always open a file with Open/Write modes
Alex Crichton [Wed, 30 Apr 2014 18:37:01 +0000 (11:37 -0700)]
native: Always open a file with Open/Write modes

Previously, windows was using the CREATE_NEW flag which fails if the file
previously existed, which differed from the unix semantics. This alters the
opening to use the OPEN_ALWAYS flag to mirror the unix semantics.

Closes #13861

10 years agoauto merge of #13072 : bjz/rust/bitset, r=alexcrichton
bors [Wed, 30 Apr 2014 18:11:49 +0000 (11:11 -0700)]
auto merge of #13072 : bjz/rust/bitset, r=alexcrichton

The `bitflags!` macro generates a `struct` that holds a set of C-style bitmask flags. It is useful for creating typesafe wrappers for C APIs.

For example:

~~~rust
#[feature(phase)];
#[phase(syntax)] extern crate collections;

bitflags!(Flags: u32 {
    FlagA       = 0x00000001,
    FlagB       = 0x00000010,
    FlagC       = 0x00000100,
    FlagABC     = FlagA.bits
                | FlagB.bits
                | FlagC.bits
})

fn main() {
    let e1 = FlagA | FlagC;
    let e2 = FlagB | FlagC;
    assert!((e1 | e2) == FlagABC);   // union
    assert!((e1 & e2) == FlagC);     // intersection
    assert!((e1 - e2) == FlagA);     // set difference
}
~~~

10 years agoUpdate for language changes
Brendan Zabarauskas [Wed, 30 Apr 2014 17:02:11 +0000 (10:02 -0700)]
Update for language changes

10 years agoMove bitflags module to libstd
Brendan Zabarauskas [Wed, 30 Apr 2014 03:05:51 +0000 (20:05 -0700)]
Move bitflags module to libstd

This will allow us to provide type-safe APIs in libstd that are C-compatible.

10 years agoauto merge of #13863 : huonw/rust/re-tweaks, r=pcwalton
bors [Wed, 30 Apr 2014 16:41:51 +0000 (09:41 -0700)]
auto merge of #13863 : huonw/rust/re-tweaks, r=pcwalton

Mostly code style e.g. avoiding `~` and using `for` + iterators.

10 years agoSuggested revisions to PR 13676.
Felix S. Klock II [Wed, 30 Apr 2014 16:34:43 +0000 (18:34 +0200)]
Suggested revisions to PR 13676.

Most important: distinguish function decl sugar for omitting `-> ()`
from type inference on closures.  I also tried to add a couple more
examples to further emphasize this distinction.  Note that this sugar
(of omitting `-> ()`) is actually already briefly mentioned in an
earlier section, so it is a little tricky deciding whether to put more
material here, or to move it up to the previous section.

Other drive-by fixes:

 * Fix the line length of the code blocks to fit in the width provided
   in the rendered HTML

 * Some minor revisions to wording (e.g. try to clarify in some cases
   where a type mismatch is arising).

10 years agorustdoc: fix overly broad selectors
Adrien Tétar [Wed, 30 Apr 2014 15:35:54 +0000 (17:35 +0200)]
rustdoc: fix overly broad selectors

10 years agoRemove extra semicolons
mdinger [Wed, 30 Apr 2014 13:29:53 +0000 (09:29 -0400)]
Remove extra semicolons

10 years agoFix typo
mdinger [Wed, 30 Apr 2014 13:10:15 +0000 (09:10 -0400)]
Fix typo

10 years agoauto merge of #12740 : nical/rust/json-streaming, r=erickt
bors [Wed, 30 Apr 2014 09:01:43 +0000 (02:01 -0700)]
auto merge of #12740 : nical/rust/json-streaming, r=erickt

Hi rust enthusiasts,

With this patch I propose to add a "streaming" API to the existing json parser in libserialize.

By "streaming" I mean a parser that let you act on JsonEvents that are generated as while parsing happens, as opposed to parsing the entire source, generating a big data structure and working with this data structure. I think both approaches have their pros and cons so this pull request adds the streaming API, preserving the existing one.

The streaming API is simple: It consist into an Iterator<JsonEvent> that consumes an Iterator<char>. JsonEvent is an enum with values such as NumberValue(f64), BeginList, EndList, BeginObject, etc.

The user would ideally use the API as follows:

```
for evt in StreamingParser::new(src) {
  match evt {
    BeginList => {
       // ...
    }
    // ...
  }
}
```

The iterator provides a stack() method returning a slice of StackNodes which represent "where we currently are" in the logical structure of the json stream (for instance at "foo.bar[3].x" you get [ Key("foo"), Key("bar"), Index(3), Key("x") ].)

I wrote "ideally" above because the current way rust expands for loops, you can't call the stack() method because the iterator is already borrowed. So for know you need to manually advance the iterator in the loop. I hope this is something we can cope with, until for loops are better integrated with the compiler.

Streaming parsers are useful when you want to read from a json stream, generate a custom data structure and you know how the json is going to be structured. For example, imagine you have to parse a 3D mesh file represented in the json format. In this case you probably expect to have large arrays of vertices and using the generic parser will be very inefficient because it will create a big list of all these vertices, which you will copy into a contiguous array afterwards (so you end up doing a lot of small allocations, parsing the json once and parsing the data structure afterwards). With a streaming parser, you can add the vertices to a contiguous array as they come in without paying the cost of creating the intermediate Json data structure. You have much fewer allocations since you write directly in the final data structure and you can be smart in how you will pre-allocate it.

I added added this directly into serialize::json rather than in its own library because it turns out I can reuse most of the existing code whereas maintaining a separate library (which I did originally) forces me to duplicate this code.

I wrote this trying to minimize the size of the patch so there may be places where the code could be nicer at the expenses of more changes (let me know what you prefer).

This is my first (potential) contribution to rust, so please let me know if I am doing something wrong (maybe I should have first introduced this proposition in the mailing list, or opened a github issue, etc.?). I work a few meters away from @pknfelix so I am not too hard to find :)

10 years agoauto merge of #13857 : alexcrichton/rust/add-dylib-paths, r=brson
bors [Wed, 30 Apr 2014 02:46:44 +0000 (19:46 -0700)]
auto merge of #13857 : alexcrichton/rust/add-dylib-paths, r=brson

When a syntax extension is loaded by the compiler, the dylib that is opened may
have other dylibs that it depends on. The dynamic linker must be able to find
these libraries on the system or else the library will fail to load.

Currently, unix gets by with the use of rpaths. This relies on the dylib not
moving around too drastically relative to its dependencies. For windows,
however, this is no rpath available, and in theory unix should work without
rpaths as well.

This modifies the compiler to add all -L search directories to the dynamic
linker's set of load paths. This is currently managed through environment
variables for each platform.

Closes #13848

10 years agorustc: Add search paths to dylib load paths
Alex Crichton [Tue, 29 Apr 2014 18:38:51 +0000 (11:38 -0700)]
rustc: Add search paths to dylib load paths

When a syntax extension is loaded by the compiler, the dylib that is opened may
have other dylibs that it depends on. The dynamic linker must be able to find
these libraries on the system or else the library will fail to load.

Currently, unix gets by with the use of rpaths. This relies on the dylib not
moving around too drastically relative to its dependencies. For windows,
however, this is no rpath available, and in theory unix should work without
rpaths as well.

This modifies the compiler to add all -L search directories to the dynamic
linker's set of load paths. This is currently managed through environment
variables for each platform.

Closes #13848

10 years agoDocument derived traits for bitset! macro
Brendan Zabarauskas [Sun, 23 Mar 2014 01:31:20 +0000 (12:31 +1100)]
Document derived traits for bitset! macro

10 years agoDocument how generated bitflags can be extended with type and trait implementations
Brendan Zabarauskas [Sun, 23 Mar 2014 00:34:07 +0000 (11:34 +1100)]
Document how generated bitflags can be extended with type and trait implementations

10 years agoAdd a bitflags! macro
Brendan Zabarauskas [Sat, 22 Mar 2014 08:38:15 +0000 (19:38 +1100)]
Add a bitflags! macro

The `bitflags!` macro generates a `struct` that holds a set of C-style bitmask flags. It is useful for creating typesafe wrappers for C APIs.

For example:

~~~rust
#[feature(phase)];
#[phase(syntax)] extern crate collections;

bitflags!(Flags: u32 {
    FlagA       = 0x00000001,
    FlagB       = 0x00000010,
    FlagC       = 0x00000100,
    FlagABC     = FlagA.bits
                | FlagB.bits
                | FlagC.bits
})

fn main() {
    let e1 = FlagA | FlagC;
    let e2 = FlagB | FlagC;
    assert!((e1 | e2) == FlagABC);   // union
    assert!((e1 & e2) == FlagC);     // intersection
    assert!((e1 - e2) == FlagA);     // set difference
}
~~~

10 years agoauto merge of #13776 : adrientetar/rust/rustdoc-fix, r=brson
bors [Wed, 30 Apr 2014 01:26:44 +0000 (18:26 -0700)]
auto merge of #13776 : adrientetar/rust/rustdoc-fix, r=brson

- Closes #13591. Relevant example: http://adrientetar.legtux.org/cached/rust-docs/struct.CChars.htm
(Had to use `!important` to override CSS selector precedence, namely matching over parent class.)
- Implement changes from #13780 feedback, namely:
  * Changed font-size from 18px to 15px
  * Reintroduced gray background for code samples
  * Tightened up the margins
- Fix point 1 and point 4 of #13804.

Samples:

- [enum.FileType](http://adrientetar.legtux.org/cached/rust-docs/enum.FileType.htm)
- [struct.CChars](http://adrientetar.legtux.org/cached/rust-docs/struct.CChars.htm)
- [std](http://adrientetar.legtux.org/cached/rust-docs/std.htm)
- [std::io](http://adrientetar.legtux.org/cached/rust-docs/io.htm).

r? @brson

10 years agoregex: General style tweaks.
Huon Wilson [Tue, 29 Apr 2014 14:55:28 +0000 (00:55 +1000)]
regex: General style tweaks.

For loops are nicer than manual whiles, etc.

10 years agoauto merge of #13833 : alexcrichton/rust/ffunction-sections, r=thestinger
bors [Tue, 29 Apr 2014 23:16:46 +0000 (16:16 -0700)]
auto merge of #13833 : alexcrichton/rust/ffunction-sections, r=thestinger

The compiler has previously been producing binaries on the order of 1.8MB for
hello world programs "fn main() {}". This is largely a result of the compilation
model used by compiling entire libraries into a single object file and because
static linking is favored by default.

When linking, linkers will pull in the entire contents of an object file if any
symbol from the object file is used. This means that if any symbol from a rust
library is used, the entire library is pulled in unconditionally, regardless of
whether the library is used or not.

Traditional C/C++ projects do not normally encounter these large executable
problems because their archives (rust's rlibs) are composed of many objects.
Because of this, linkers can eliminate entire objects from being in the final
executable. With rustc, however, the linker does not have the opportunity to
leave out entire object files.

In order to get similar benefits from dead code stripping at link time, this
commit enables the -ffunction-sections and -fdata-sections flags in LLVM, as
well as passing --gc-sections to the linker *by default*. This means that each
function and each global will be placed into its own section, allowing the
linker to GC all unused functions and data symbols.

By enabling these flags, rust is able to generate much smaller binaries default.
On linux, a hello world binary went from 1.8MB to 597K (a 67% reduction in
size). The output size of dynamic libraries remained constant, but the output
size of rlibs increased, as seen below:

    libarena       -  2.27% bigger
    libcollections -  0.64% bigger
    libflate       -  0.85% bigger
    libfourcc      - 14.67% bigger
    libgetopts     -  4.52% bigger
    libglob        -  2.74% bigger
    libgreen       -  9.68% bigger
    libhexfloat    - 13.68% bigger
    liblibc        - 10.79% bigger
    liblog         - 10.95% bigger
    libnative      -  8.34% bigger
    libnum         -  2.31% bigger
    librand        -  1.71% bigger
    libregex       -  6.43% bigger
    librustc       -  4.21% bigger
    librustdoc     -  8.98% bigger
    librustuv      -  4.11% bigger
    libsemver      -  2.68% bigger
    libserialize   -  1.92% bigger
    libstd         -  3.59% bigger
    libsync        -  3.96% bigger
    libsyntax      -  4.96% bigger
    libterm        - 13.96% bigger
    libtest        -  6.03% bigger
    libtime        -  2.86% bigger
    liburl         -  6.59% bigger
    libuuid        -  4.70% bigger
    libworkcache   -  8.44% bigger

This increase in size is a result of encoding many more section names into each
object file (rlib). These increases are moderate enough that this change seems
worthwhile to me, due to the drastic improvements seen in the final artifacts.
The overall increase of the stage2 target folder (not the size of an install)
went from 337MB to 348MB (3% increase).

Additionally, linking is generally slower when executed with all these new
sections plus the --gc-sections flag. The stage0 compiler takes 1.4s to link the
`rustc` binary, where the stage1 compiler takes 1.9s to link the binary. Three
megabytes are shaved off the binary. I found this increase in link time to be
acceptable relative to the benefits of code size gained.

This commit only enables --gc-sections for *executables*, not dynamic libraries.
LLVM does all the heavy lifting when producing an object file for a dynamic
library, so there is little else for the linker to do (remember that we only
have one object file).

I conducted similar experiments by putting a *module's* functions and data
symbols into its own section (granularity moved to a module level instead of a
function/static level). The size benefits of a hello world were seen to be on
the order of 400K rather than 1.2MB. It seemed that enough benefit was gained
using ffunction-sections that this route was less desirable, despite the lesser
increases in binary rlib size.

10 years agoauto merge of #13772 : brson/rust/cratedocs, r=alexcrichton
bors [Tue, 29 Apr 2014 21:26:49 +0000 (14:26 -0700)]
auto merge of #13772 : brson/rust/cratedocs, r=alexcrichton

Also move prelude explanation to the prelude module.

This tries to provide a guide to what's in the standard library, organized bottom up from primitives to I/O.

10 years agoauto merge of #13845 : alexcrichton/rust/regex-deps, r=brson
bors [Tue, 29 Apr 2014 19:31:52 +0000 (12:31 -0700)]
auto merge of #13845 : alexcrichton/rust/regex-deps, r=brson

There is currently not much precedent for target crates requiring syntax
extensions to compile their test versions. This dependency is possible, but
can't be encoded through the normal means of DEPS_regex because it is a
test-only dependency and it must be a *host* dependency (it's a syntax
extension).

Closes #13844

10 years agorustc: Enable -f{function,data}-sections
Alex Crichton [Tue, 29 Apr 2014 00:17:18 +0000 (17:17 -0700)]
rustc: Enable -f{function,data}-sections

The compiler has previously been producing binaries on the order of 1.8MB for
hello world programs "fn main() {}". This is largely a result of the compilation
model used by compiling entire libraries into a single object file and because
static linking is favored by default.

When linking, linkers will pull in the entire contents of an object file if any
symbol from the object file is used. This means that if any symbol from a rust
library is used, the entire library is pulled in unconditionally, regardless of
whether the library is used or not.

Traditional C/C++ projects do not normally encounter these large executable
problems because their archives (rust's rlibs) are composed of many objects.
Because of this, linkers can eliminate entire objects from being in the final
executable. With rustc, however, the linker does not have the opportunity to
leave out entire object files.

In order to get similar benefits from dead code stripping at link time, this
commit enables the -ffunction-sections and -fdata-sections flags in LLVM, as
well as passing --gc-sections to the linker *by default*. This means that each
function and each global will be placed into its own section, allowing the
linker to GC all unused functions and data symbols.

By enabling these flags, rust is able to generate much smaller binaries default.
On linux, a hello world binary went from 1.8MB to 597K (a 67% reduction in
size). The output size of dynamic libraries remained constant, but the output
size of rlibs increased, as seen below:

    libarena         -  2.27% bigger (   292872 =>    299508)
    libcollections   -  0.64% bigger (  6765884 =>   6809076)
    libflate         -  0.83% bigger (   186516 =>    188060)
    libfourcc        - 14.71% bigger (   307290 =>    352498)
    libgetopts       -  4.42% bigger (   761468 =>    795102)
    libglob          -  2.73% bigger (   899932 =>    924542)
    libgreen         -  9.63% bigger (  1281718 =>   1405124)
    libhexfloat      - 13.88% bigger (   333738 =>    380060)
    liblibc          - 10.79% bigger (   551280 =>    610736)
    liblog           - 10.93% bigger (   218208 =>    242060)
    libnative        -  8.26% bigger (  1362096 =>   1474658)
    libnum           -  2.34% bigger (  2583400 =>   2643916)
    librand          -  1.72% bigger (  1608684 =>   1636394)
    libregex         -  6.50% bigger (  1747768 =>   1861398)
    librustc         -  4.21% bigger (151820192 => 158218924)
    librustdoc       -  8.96% bigger ( 13142604 =>  14320544)
    librustuv        -  4.13% bigger (  4366896 =>   4547304)
    libsemver        -  2.66% bigger (   396166 =>    406686)
    libserialize     -  1.91% bigger (  6878396 =>   7009822)
    libstd           -  3.59% bigger ( 39485286 =>  40902218)
    libsync          -  3.95% bigger (  1386390 =>   1441204)
    libsyntax        -  4.96% bigger ( 35757202 =>  37530798)
    libterm          - 13.99% bigger (   924580 =>   1053902)
    libtest          -  6.04% bigger (  2455720 =>   2604092)
    libtime          -  2.84% bigger (  1075708 =>   1106242)
    liburl           -  6.53% bigger (   590458 =>    629004)
    libuuid          -  4.63% bigger (   326350 =>    341466)
    libworkcache     -  8.45% bigger (  1230702 =>   1334750)

This increase in size is a result of encoding many more section names into each
object file (rlib). These increases are moderate enough that this change seems
worthwhile to me, due to the drastic improvements seen in the final artifacts.
The overall increase of the stage2 target folder (not the size of an install)
went from 337MB to 348MB (3% increase).

Additionally, linking is generally slower when executed with all these new
sections plus the --gc-sections flag. The stage0 compiler takes 1.4s to link the
`rustc` binary, where the stage1 compiler takes 1.9s to link the binary. Three
megabytes are shaved off the binary. I found this increase in link time to be
acceptable relative to the benefits of code size gained.

This commit only enables --gc-sections for *executables*, not dynamic libraries.
LLVM does all the heavy lifting when producing an object file for a dynamic
library, so there is little else for the linker to do (remember that we only
have one object file).

I conducted similar experiments by putting a *module's* functions and data
symbols into its own section (granularity moved to a module level instead of a
function/static level). The size benefits of a hello world were seen to be on
the order of 400K rather than 1.2MB. It seemed that enough benefit was gained
using ffunction-sections that this route was less desirable, despite the lesser
increases in binary rlib size.