]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #15605 : blake2-ppc/rust/rustdoc-const-t, r=alexcrichton
bors [Sat, 12 Jul 2014 14:36:35 +0000 (14:36 +0000)]
auto merge of #15605 : blake2-ppc/rust/rustdoc-const-t, r=alexcrichton

Update the formatting of raw immutable pointers to print *const T.

10 years agoauto merge of #15602 : adrientetar/rust/name-fix, r=huonw
bors [Sat, 12 Jul 2014 12:51:38 +0000 (12:51 +0000)]
auto merge of #15602 : adrientetar/rust/name-fix, r=huonw

Not sure how I did miss that in the first place...

r? @alexcrichton

10 years agoauto merge of #15601 : jbclements/rust/disable-default-macro-behavior, r=alexcrichton
bors [Sat, 12 Jul 2014 11:06:39 +0000 (11:06 +0000)]
auto merge of #15601 : jbclements/rust/disable-default-macro-behavior, r=alexcrichton

Our AST definition can include macro invocations, which can expand into all kinds of things. Macro invocations are expanded away during expansion time, and the rest of the compiler doesn't have to deal with them. However, we have no way of enforcing this.

This patch adds two protective mechanisms.

First, it adds a (quick) explicit check that ensures there are no macro invocations remaining in the AST after expansion. Second, it updates the visit and fold mechanisms so that by default, they will not traverse macro invocations. It's easy enough to add this, if desired (it's documented in the source, and examples appear, e.g. in the IdentFinder.

Along the way, I also consulted with @sfackler to refactor the macro export mechanism so that it stores macro text spans in a side table, rather than leaving them in the AST.

10 years agoauto merge of #15592 : arjantop/rust/bufwriter-write-fix, r=alexcrichton
bors [Sat, 12 Jul 2014 09:21:39 +0000 (09:21 +0000)]
auto merge of #15592 : arjantop/rust/bufwriter-write-fix, r=alexcrichton

First condition is not needed and just prevents 0 length writes

Fixes #15583

10 years agoauto merge of #15588 : alexcrichton/rust/issue-15478, r=cmr
bors [Sat, 12 Jul 2014 06:46:42 +0000 (06:46 +0000)]
auto merge of #15588 : alexcrichton/rust/issue-15478, r=cmr

If modified, you can safely unmap arbitrary memory. These fields are not
intended to be modified, so read-only accessors are the only ones that are
provided.

Closes #15478

10 years agostd: Move MemoryMap fields to methods
Alex Crichton [Thu, 10 Jul 2014 20:20:39 +0000 (13:20 -0700)]
std: Move MemoryMap fields to methods

If modified, you can safely unmap arbitrary memory. These fields are not
intended to be modified, so read-only accessors are the only ones that are
provided.

Closes #15478

10 years agoauto merge of #15597 : brson/rust/ldconfig, r=pcwalton
bors [Sat, 12 Jul 2014 04:16:44 +0000 (04:16 +0000)]
auto merge of #15597 : brson/rust/ldconfig, r=pcwalton

If ldconfig fails it emits a warning. This is very possible when installing
to a non-system directory, so the warning tries to indicate that it may
not be a problem.

10 years agoOnly run ldconfig on Linux
Brian Anderson [Sat, 12 Jul 2014 00:08:58 +0000 (17:08 -0700)]
Only run ldconfig on Linux

10 years agoauto merge of #15589 : Denommus/rust/master, r=alexcrichton
bors [Sat, 12 Jul 2014 00:31:46 +0000 (00:31 +0000)]
auto merge of #15589 : Denommus/rust/master, r=alexcrichton

I have noticed some errors and some absences that I considered essential to the usability of rustc in zsh, so I included them and updated some of the man page.

10 years agoauto merge of #15586 : aturon/rust/stability-dashboard, r=alexcrichton
bors [Fri, 11 Jul 2014 22:06:43 +0000 (22:06 +0000)]
auto merge of #15586 : aturon/rust/stability-dashboard, r=alexcrichton

This PR adds a crate-level dashboard summarizing the stability levels of all items for all submodules of the crate.

The information is also written as a json file, intended for consumption by pages like http://huonw.github.io/isrustfastyet/

Along the way, fixes a few bugs in stability tracking and places where rustdoc was not pulling the existing stability data.

Closes #13541

10 years agoauto merge of #15565 : alexcrichton/rust/issue-15475, r=huonw
bors [Fri, 11 Jul 2014 18:06:37 +0000 (18:06 +0000)]
auto merge of #15565 : alexcrichton/rust/issue-15475, r=huonw

If a plugin registrar is available, the library must be found in dylib form, not
just in rlib form.

Closes #15475

10 years agoadd Macro Exterminator
John Clements [Wed, 9 Jul 2014 23:41:13 +0000 (16:41 -0700)]
add Macro Exterminator

the Macro Exterminator ensures that there are no macro invocations in
an AST. This should help make later passes confident that there aren't
hidden items, methods, expressions, etc.

10 years agomake walk/visit_mac opt-in only
John Clements [Wed, 9 Jul 2014 21:48:12 +0000 (14:48 -0700)]
make walk/visit_mac opt-in only

macros can expand into arbitrary items, exprs, etc. This
means that using a default walker or folder on an AST before
macro expansion is complete will miss things (the things that
the macros expand into). As a partial fence against this, this
commit moves the default traversal of macros into a separate
procedure, and makes the default trait implementation signal
an error. This means that Folders and Visitors can traverse
macros if they want to, but they need to explicitly add an
impl that calls the walk_mac or fold_mac procedure

This should prevent problems down the road.

10 years agouse side table to store exported macros
John Clements [Thu, 10 Jul 2014 22:41:11 +0000 (15:41 -0700)]
use side table to store exported macros

Per discussion with @sfackler, refactored the expander to
change the way that exported macros are collected. Specifically,
a crate now contains a side table of spans that exported macros
go into.

This has two benefits. First, the encoder doesn't need to scan through
the expanded crate in order to discover exported macros. Second, the
expander can drop all expanded macros from the crate, with the pleasant
result that a fully expanded crate contains no macro invocations (which
include macro definitions).

10 years agorename one of the two confusing MacroExpanders
John Clements [Thu, 10 Jul 2014 19:09:56 +0000 (12:09 -0700)]
rename one of the two confusing MacroExpanders

There were two things named MacroExpander, which was confusing. I renamed
one of them TTMacroExpander.

[breaking change]

10 years agoauto merge of #15503 : pnkfelix/rust/fsk-linear-deriving-partialord, r=huonw
bors [Fri, 11 Jul 2014 15:56:38 +0000 (15:56 +0000)]
auto merge of #15503 : pnkfelix/rust/fsk-linear-deriving-partialord, r=huonw

Instead of generating a separate case (albeit trivial) for each of the N*N cases when comparing two instances of an enum with N variants, this `deriving` uses the strategy outlined here: https://github.com/rust-lang/rust/issues/15375#issuecomment-47994007

In particular, it generates code that looks more like this:

```rust
    match (this, that, ...) {
      (Variant1, Variant1, Variant1) => ... // delegate Matching on Variant1
      (Variant2, Variant2, Variant2) => ... // delegate Matching on Variant2
      ...
      _ => {
        let index_tup = {
          let idx_this = match this { Variant1 => 0u, Variant2 => 1u, ... };
          let idx_that = match that { Variant1 => 0u, Variant2 => 1u, ... };
          ...
          (idx_this, idx_that, ...)
        };
        ... // delegate to catch-all; it can inspect `index_tup` for its logic
      }
    }
```

While adding a new variant to the `const_nonmatching` flag (and renaming it to `on_nonmatching`) to allow expressing the above (while still allowing one to opt back into the old `O(N^2)` and in general `O(N^K)` (where `K` is the number of self arguments) code generation behavior), I had two realizations:

 1. Observation: Nothing except for the comparison derivings (`PartialOrd`, `Ord`, `PartialEq`, `Eq`) were even using the old `O(N^K)` code generator.  So after this hypothetically lands, *nothing* needs to use them, and thus that code generation strategy could be removed, under the assumption that it is very unlikely that any `deriving` mode will actually need that level of generality.
 2. Observation: The new code generator I am adding can actually be unified with all of the other code generators that just dispatch on the variant tag (they all assume that there is only one self argument).

These two observations mean that one can get rid of the `const_nonmatching` (aka `on_nonmatching`) entirely.  So I did that too in this PR.

The question is: Do we actually want to follow through on both of the above observations?  I'm pretty sure the second observation is a pure win.  But there *might* be someone out there with an example that invalidates the reasoning in the first observation.  That is, there might be a client out there with an example of hypothetical deriving mode that wants to opt into the `O(N^K)` behavior.  So, if that is true, then I can revise this PR to resurrect the `on_nonmatching` flag and provide a way to access the `O(N^K)` behavior.

The manner in which I choose to squash these commits during a post-review rebase depends on the answer to the above question.

Fix #15375.

10 years agoRemoved dead structures after changes to PartialOrd/Ord derivings.
Felix S. Klock II [Mon, 7 Jul 2014 07:13:49 +0000 (09:13 +0200)]
Removed dead structures after changes to PartialOrd/Ord derivings.

Remove the `NonMatchesExplode` variant now that no deriving impl uses it.
Removed `EnumNonMatching` entirely.
Remove now irrelevant `on_matching` field and `HandleNonMatchingEnums` type.
Removed unused `EnumNonMatchFunc` type def.

Drive-by: revise `EnumNonMatchCollapsedFunc` doc.
Made all calls to `expand_enum_method_body` go directly to
`build_enum_match_tuple`.

Alpha-rename `enum_nonmatch_g` back to `enum_nonmatch_f` to reduce overall diff noise.
Inline sole call of `some_ordering_const`.
Inline sole call of `ordering_const`.

Removed a bunch of code that became dead after the above changes.

10 years ago`O(n*k)` code-size deriving on enums (better than previous `O(n^k)`).
Felix S. Klock II [Sun, 6 Jul 2014 19:19:12 +0000 (21:19 +0200)]
`O(n*k)` code-size deriving on enums (better than previous `O(n^k)`).

In the above formulas, `n` is the number of variants, and `k` is the
number of self-args fed into deriving.  In the particular case of
interest (namely `PartialOrd` and `Ord`), `k` is always 2, so we are
basically comparing `O(n)` versus `O(n^2)`.

Also, the stage is set for having *all* enum deriving codes go through
`build_enum_match_tuple` and getting rid of `build_enum_match`.

Also, seriously attempted to clean up the code itself.  Added a bunch
of comments attempting to document what I learned as I worked through
the original code and adapted it to this new strategy.

10 years agoRevise the `const_nonmatching` flag with more info about author's intent.
Felix S. Klock II [Sat, 5 Jul 2014 06:04:07 +0000 (08:04 +0200)]
Revise the `const_nonmatching` flag with more info about author's intent.

In particular, I want authors of deriving modes to understand what
they are opting into (namely quadratic code size or worse) when they
select NonMatchesExplode.

10 years agoauto merge of #15580 : pnkfelix/rust/fsk-fix-15558, r=alexcrichton
bors [Fri, 11 Jul 2014 13:51:39 +0000 (13:51 +0000)]
auto merge of #15580 : pnkfelix/rust/fsk-fix-15558, r=alexcrichton

Fix #15558.

10 years agoAllow writes of length 0 to a full buffer
Arjan Topolovec [Thu, 10 Jul 2014 22:51:14 +0000 (00:51 +0200)]
Allow writes of length 0 to a full buffer

10 years agoauto merge of #15576 : mrmonday/rust/patch-1, r=alexcrichton
bors [Fri, 11 Jul 2014 12:06:40 +0000 (12:06 +0000)]
auto merge of #15576 : mrmonday/rust/patch-1, r=alexcrichton

Add a couple of lines mentioning event_loop_factory - no clear error message is given if you attempt to perform I/O in tasks created in this fashion. I spent a many hours debugging this yesterday which would have been avoided if it were documented.

10 years agoauto merge of #15575 : mvdnes/rust/spinlock_error, r=alexcrichton
bors [Fri, 11 Jul 2014 10:21:42 +0000 (10:21 +0000)]
auto merge of #15575 : mvdnes/rust/spinlock_error, r=alexcrichton

The current example of a spinlock was not correct. The lock is actually acquired
when `old == result`. So we only need to deschedule when this is not the case.

10 years agorustdoc: Change type name of raw pointer from *T to *const T
root [Fri, 11 Jul 2014 09:35:02 +0000 (11:35 +0200)]
rustdoc: Change type name of raw pointer from *T to *const T

Update the formatting of raw immutable pointers to print *const T.

10 years agoauto merge of #15574 : omasanori/rust/hidden, r=huonw
bors [Fri, 11 Jul 2014 08:36:40 +0000 (08:36 +0000)]
auto merge of #15574 : omasanori/rust/hidden, r=huonw

10 years agowebfonts: name fix
Adrien Tétar [Fri, 11 Jul 2014 07:49:59 +0000 (09:49 +0200)]
webfonts: name fix

10 years agoauto merge of #15570 : omasanori/rust/radix, r=alexcrichton
bors [Fri, 11 Jul 2014 05:36:37 +0000 (05:36 +0000)]
auto merge of #15570 : omasanori/rust/radix, r=alexcrichton

10 years agoBug fixes for stability tracking
Aaron Turon [Thu, 10 Jul 2014 18:17:40 +0000 (11:17 -0700)]
Bug fixes for stability tracking

This commit adds correct stability tracking for struct fields and
corrects some places where rustdoc was not pulling the stability data.

10 years agorustdoc: Add stability dashboard
Aaron Turon [Fri, 4 Jul 2014 07:51:46 +0000 (00:51 -0700)]
rustdoc: Add stability dashboard

This commit adds a crate-level dashboard summarizing the stability
levels of all items for all submodules of the crate.

The information is also written as a json file, intended for consumption
by pages like http://huonw.github.io/isrustfastyet/

Closes #13541

10 years agoinstall: Run ldconfig when installing on Unix. Closes #15596.
Brian Anderson [Fri, 11 Jul 2014 01:25:50 +0000 (18:25 -0700)]
install: Run ldconfig when installing on Unix. Closes #15596.

If ldconfig fails it emits a warning. This is very possible when installing
to a non-system directory, so the warning tries to indicate that it may
not be a problem.

10 years agoinstall: Make the LD_LIRARY_PATH warning more aesthetic
Brian Anderson [Fri, 11 Jul 2014 01:16:48 +0000 (18:16 -0700)]
install: Make the LD_LIRARY_PATH warning more aesthetic

10 years agoauto merge of #15564 : alexcrichton/rust/moar-hash, r=huonw
bors [Fri, 11 Jul 2014 01:11:36 +0000 (01:11 +0000)]
auto merge of #15564 : alexcrichton/rust/moar-hash, r=huonw

- semver::Version is now Eq, Ord, and Hash
- Path is now PartialOrd and Ord

10 years agoSome documentation fixes and improvements
Yuri Albuquerque [Thu, 10 Jul 2014 19:57:04 +0000 (15:57 -0400)]
Some documentation fixes and improvements

10 years agoauto merge of #15336 : jakub-/rust/diagnostics, r=brson
bors [Thu, 10 Jul 2014 23:26:39 +0000 (23:26 +0000)]
auto merge of #15336 : jakub-/rust/diagnostics, r=brson

This is a continuation of @brson's work from https://github.com/rust-lang/rust/pull/12144.

This implements the minimal scaffolding that allows mapping diagnostic messages to alpha-numeric codes, which could improve the searchability of errors. In addition, there's a new compiler option, `--explain {code}` which takes an error code and prints out a somewhat detailed explanation of the error. Example:

```rust
fn f(x: Option<bool>) {
match x {
Some(true) | Some(false) => (),
None => (),
Some(true) => ()
}
}
```

```shell
[~/rust]$ ./build/x86_64-apple-darwin/stage2/bin/rustc ./diagnostics.rs --crate-type dylib
diagnostics.rs:5:3: 5:13 error: unreachable pattern [E0001] (pass `--explain E0001` to see a detailed explanation)
diagnostics.rs:5  Some(true) => ()
                  ^~~~~~~~~~
error: aborting due to previous error
[~/rust]$ ./build/x86_64-apple-darwin/stage2/bin/rustc --explain E0001

    This error suggests that the expression arm corresponding to the noted pattern
    will never be reached as for all possible values of the expression being matched,
    one of the preceeding patterns will match.

    This means that perhaps some of the preceeding patterns are too general, this
    one is too specific or the ordering is incorrect.

```

I've refrained from migrating many errors to actually use the new macros as it can be done in an incremental fashion but if we're happy with the approach, it'd be good to do all of them sooner rather than later.

Originally, I was going to make libdiagnostics a separate crate but that's posing some interesting challenges with semi-circular dependencies. In particular, librustc would have a plugin-phase dependency on libdiagnostics, which itself depends on librustc. Per my conversation with @alexcrichton, it seems like the snapshotting process would also have to change. So for now the relevant modules from libdiagnostics are included using `#[path = ...] mod`.

10 years agoAdd scaffolding for assigning alpha-numeric codes to rustc diagnostics
Jakub Wieczorek [Tue, 1 Jul 2014 16:39:41 +0000 (18:39 +0200)]
Add scaffolding for assigning alpha-numeric codes to rustc diagnostics

10 years agoauto merge of #15353 : aturon/rust/env-hashmap, r=alexcrichton
bors [Thu, 10 Jul 2014 21:41:36 +0000 (21:41 +0000)]
auto merge of #15353 : aturon/rust/env-hashmap, r=alexcrichton

This commit adds `env_insert` and `env_remove` methods to the `Command`
builder, easing updates to the environment variables for the child
process. The existing method, `env`, is still available for overriding
the entire environment in one shot (after which the `env_insert` and
`env_remove` methods can be used to make further adjustments).

To support these new methods, the internal `env` representation for
`Command` has been changed to an optional `HashMap` holding owned
`CString`s (to support non-utf8 data). The `HashMap` is only
materialized if the environment is updated. The implementation does not
try hard to avoid allocation, since the cost of launching a process will
dwarf any allocation cost.

This patch also adds `PartialOrd`, `Eq`, and `Hash` implementations for
`CString`.

10 years agoio::process::Command: add fine-grained env builder
Aaron Turon [Wed, 2 Jul 2014 20:50:45 +0000 (13:50 -0700)]
io::process::Command: add fine-grained env builder

This commit changes the `io::process::Command` API to provide
fine-grained control over the environment:

* The `env` method now inserts/updates a key/value pair.
* The `env_remove` method removes a key from the environment.
* The old `env` method, which sets the entire environment in one shot,
  is renamed to `env_set_all`. It can be used in conjunction with the
  finer-grained methods. This renaming is a breaking change.

To support these new methods, the internal `env` representation for
`Command` has been changed to an optional `HashMap` holding owned
`CString`s (to support non-utf8 data). The `HashMap` is only
materialized if the environment is updated. The implementation does not
try hard to avoid allocation, since the cost of launching a process will
dwarf any allocation cost.

This patch also adds `PartialOrd`, `Eq`, and `Hash` implementations for
`CString`.

[breaking-change]

10 years agoauto merge of #15559 : fhahn/rust/issue-15445-mut-cast, r=alexcrichton
bors [Thu, 10 Jul 2014 19:06:59 +0000 (19:06 +0000)]
auto merge of #15559 : fhahn/rust/issue-15445-mut-cast, r=alexcrichton

I've added an error message for casts from raw pointers to floats #15445.

10 years agoMore robust install.sh: do runnability test in fresh subdirectory.
Felix S. Klock II [Thu, 10 Jul 2014 17:18:46 +0000 (19:18 +0200)]
More robust install.sh: do runnability test in fresh subdirectory.

Fix #15558.

10 years agoauto merge of #14519 : hirschenberger/rust/issue-10934, r=alexcrichton
bors [Thu, 10 Jul 2014 17:16:30 +0000 (17:16 +0000)]
auto merge of #14519 : hirschenberger/rust/issue-10934, r=alexcrichton

Issue #10934

10 years agoDocument event_loop_factory usage
Robert Clipsham [Thu, 10 Jul 2014 14:12:00 +0000 (15:12 +0100)]
Document event_loop_factory usage

Add a couple of lines mentioning event_loop_factory - no clear error message is
given if you attempt to perform I/O in tasks created in this fashion.

10 years agoauto merge of #15578 : alexcrichton/rust/fix-dist-again, r=pnkfelix
bors [Thu, 10 Jul 2014 15:34:02 +0000 (15:34 +0000)]
auto merge of #15578 : alexcrichton/rust/fix-dist-again, r=pnkfelix

This is already checked by the install script, no need to check it twice.

10 years agomk: Don't run rustc manually during distcheck
Alex Crichton [Thu, 10 Jul 2014 15:09:43 +0000 (08:09 -0700)]
mk: Don't run rustc manually during distcheck

This is already checked by the install script, no need to check it twice.

10 years agorustc: Forbid plugin_registrar in only rlib form
Alex Crichton [Thu, 10 Jul 2014 02:13:28 +0000 (19:13 -0700)]
rustc: Forbid plugin_registrar in only rlib form

If a plugin registrar is available, the library must be found in dylib form, not
just in rlib form.

Closes #15475

10 years agostd: Add some implementation of common traits
Alex Crichton [Thu, 10 Jul 2014 01:16:16 +0000 (18:16 -0700)]
std: Add some implementation of common traits

- semver::Version is now Eq, Ord, and Hash
- Path is now PartialOrd and Ord

10 years agoauto merge of #15569 : pcwalton/rust/reexport-intrinsics, r=cmr
bors [Thu, 10 Jul 2014 12:46:30 +0000 (12:46 +0000)]
auto merge of #15569 : pcwalton/rust/reexport-intrinsics, r=cmr

code bloat.

This didn't make a difference in any compile times that I saw, but it
fits what we're doing with `transmute` and seems prudent.

r? @alexcrichton

10 years agoRemove deprecated std::unstable module.
OGINO Masanori [Thu, 10 Jul 2014 10:45:00 +0000 (19:45 +0900)]
Remove deprecated std::unstable module.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agoauto merge of #15563 : luqmana/rust/nif, r=pcwalton
bors [Thu, 10 Jul 2014 11:01:32 +0000 (11:01 +0000)]
auto merge of #15563 : luqmana/rust/nif, r=pcwalton

10 years agotypeck: check casts from pointers to floats, closes #15445
Florian Hahn [Wed, 9 Jul 2014 20:01:31 +0000 (22:01 +0200)]
typeck: check casts from pointers to floats, closes #15445

10 years agoMistake in AtomicBool spinlock example
Mathijs van de Nes [Thu, 10 Jul 2014 09:51:19 +0000 (11:51 +0200)]
Mistake in AtomicBool spinlock example

The current example of a spinlock was not correct. The lock is actually acquired
when old == result. So we only need to deschedule when this is not the case.

10 years agoauto merge of #15566 : japaric/rust/command-clone, r=alexcrichton
bors [Thu, 10 Jul 2014 09:16:29 +0000 (09:16 +0000)]
auto merge of #15566 : japaric/rust/command-clone, r=alexcrichton

Allows use cases like this one:

``` rust
use std::io::Command;

fn main() {
    let mut cmd = Command::new("ls");
    cmd.arg("-l");

    for &dir in ["a", "b", "c"].iter() {
        println!("{}", cmd.clone().arg(dir));
    }
}
```

Output:
```
ls '-l' 'a'
ls '-l' 'b'
ls '-l' 'c'
```
Without the `clone()`, you'll end up with:
```
ls '-l' 'a'
ls '-l' 'a' 'b'
ls '-l' 'a' 'b' 'c'
```

cc #15294

10 years agoAdd range lint for float literals, fixing #10934
Falco Hirschenberger [Wed, 9 Jul 2014 07:45:32 +0000 (09:45 +0200)]
Add range lint for float literals, fixing #10934

10 years agoUse std::fmt::radix instead of to_str_radix.
OGINO Masanori [Thu, 10 Jul 2014 07:14:35 +0000 (16:14 +0900)]
Use std::fmt::radix instead of to_str_radix.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agolibcore: Reexport a couple of widely-used low-level intrinsics to reduce
Patrick Walton [Thu, 10 Jul 2014 05:24:23 +0000 (22:24 -0700)]
libcore: Reexport a couple of widely-used low-level intrinsics to reduce
code bloat.

This didn't make a difference in any compile times that I saw, but it
fits what we're doing with `transmute` and seems prudent.

10 years agoauto merge of #15561 : huonw/rust/must-use-iterators, r=alexcrichton
bors [Thu, 10 Jul 2014 05:16:28 +0000 (05:16 +0000)]
auto merge of #15561 : huonw/rust/must-use-iterators, r=alexcrichton

Similar to the stability attributes, a type annotated with `#[must_use =
"informative snippet"]` will print the normal warning message along with
"informative snippet". This allows the type author to provide some
guidance about why the type should be used.

---

It can be a little unintuitive that something like `v.iter().map(|x|
println!("{}", x));` does nothing: the majority of the iterator adaptors
are lazy and do not execute anything until something calls `next`, e.g.
a `for` loop, `collect`, `fold`, etc.

The majority of such errors can be seen by someone writing something
like the above, i.e. just calling an iterator adaptor and doing nothing
with it (and doing this is certainly useless), so we can co-opt the
`must_use` lint, using the message functionality to give a hint to the
reason why.

Fixes #14666.

10 years agoauto merge of #15556 : alexcrichton/rust/snapshots, r=brson
bors [Thu, 10 Jul 2014 03:21:30 +0000 (03:21 +0000)]
auto merge of #15556 : alexcrichton/rust/snapshots, r=brson

Closes #15544

10 years agolibrustc: Translate input for transmute directly into dest.
Luqman Aden [Thu, 10 Jul 2014 03:09:57 +0000 (20:09 -0700)]
librustc: Translate input for transmute directly into dest.

10 years agoauto merge of #15554 : steveklabnik/rust/gh_15539, r=brson
bors [Thu, 10 Jul 2014 01:36:28 +0000 (01:36 +0000)]
auto merge of #15554 : steveklabnik/rust/gh_15539, r=brson

This was super silly anyway.

Fixes #15539.

10 years agoDerive Clone for Command and StdioContainer
Jorge Aparicio [Thu, 10 Jul 2014 01:00:44 +0000 (20:00 -0500)]
Derive Clone for Command and StdioContainer

10 years agolibrustc: Update to reflect changes to how intrinsics are codegened.
Luqman Aden [Thu, 10 Jul 2014 00:51:05 +0000 (17:51 -0700)]
librustc: Update to reflect changes to how intrinsics are codegened.

10 years agolibrustc: Remove old codepaths for creating intrinsic functions.
Luqman Aden [Thu, 10 Jul 2014 00:25:52 +0000 (17:25 -0700)]
librustc: Remove old codepaths for creating intrinsic functions.

10 years agoauto merge of #15514 : luqmana/rust/die-advance-die, r=cmr
bors [Wed, 9 Jul 2014 23:51:27 +0000 (23:51 +0000)]
auto merge of #15514 : luqmana/rust/die-advance-die, r=cmr

Closes #15492.

10 years agotests: Remove uses of advance.
Luqman Aden [Mon, 7 Jul 2014 22:22:23 +0000 (15:22 -0700)]
tests: Remove uses of advance.

10 years agolibrustc: Remove uses of advance.
Luqman Aden [Thu, 12 Jun 2014 10:14:15 +0000 (06:14 -0400)]
librustc: Remove uses of advance.

10 years agolibsyntax: Remove uses of advance.
Luqman Aden [Thu, 12 Jun 2014 10:13:25 +0000 (06:13 -0400)]
libsyntax: Remove uses of advance.

10 years agolibgetopts: Use iterators instead of old-style loops.
Luqman Aden [Thu, 12 Jun 2014 09:35:02 +0000 (05:35 -0400)]
libgetopts: Use iterators instead of old-style loops.

10 years agolibcollections: Use iterators instead of old-style loops.
Luqman Aden [Thu, 12 Jun 2014 09:19:55 +0000 (05:19 -0400)]
libcollections: Use iterators instead of old-style loops.

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 agolibrustc: Don't emit call for intrinsics instead just trans at callsite.
Luqman Aden [Wed, 9 Jul 2014 22:31:45 +0000 (15:31 -0700)]
librustc: Don't emit call for intrinsics instead just trans at callsite.

10 years agoauto merge of #15550 : alexcrichton/rust/install-script, r=brson
bors [Wed, 9 Jul 2014 22:06:27 +0000 (22:06 +0000)]
auto merge of #15550 : alexcrichton/rust/install-script, r=brson

This adds detection of the relevant LD_LIBRARY_PATH-like environment variable
and appropriately sets it when testing whether binaries can run or not.
Additionally, the installation prints a recommended value if one is necessary.

Closes #15545

10 years agocore: add `#[must_use]` attributes to iterator adaptor structs.
Huon Wilson [Wed, 9 Jul 2014 12:13:14 +0000 (22:13 +1000)]
core: add `#[must_use]` attributes to iterator adaptor structs.

It can be a little unintuitive that something like `v.iter().map(|x|
println!("{}", x));` does nothing: the majority of the iterator adaptors
are lazy and do not execute anything until something calls `next`, e.g.
a `for` loop, `collect`, `fold`, etc.

The majority of such errors can be seen by someone writing something
like the above, i.e. just calling an iterator adaptor and doing nothing
with it (and doing this is certainly useless), so we can co-opt the
`must_use` lint, using the message functionality to give a hint to the
reason why.

Fixes #14666.

10 years agolint: extend `#[must_use]` to handle a message.
Huon Wilson [Wed, 9 Jul 2014 12:02:19 +0000 (22:02 +1000)]
lint: extend `#[must_use]` to handle a message.

Similar to the stability attributes, a type annotated with `#[must_use =
"informative snippet"]` will print the normal warning message along with
"informative snippet". This allows the type author to provide some
guidance about why the type should be used.

10 years agosyntax: De-doc comment to fix nightlies
Alex Crichton [Wed, 9 Jul 2014 21:44:40 +0000 (14:44 -0700)]
syntax: De-doc comment to fix nightlies

This reverts the promotion from line-comment to doc-comment in 4989a56 to fix
the compiler-docs target.

Closes #15553

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 agoRegister new snapshots
Alex Crichton [Wed, 9 Jul 2014 17:57:01 +0000 (10:57 -0700)]
Register new snapshots

Closes #15544

10 years agoRemove car analogy.
Steve Klabnik [Wed, 9 Jul 2014 17:04:52 +0000 (13:04 -0400)]
Remove car analogy.

This was super silly anyway.

Fixes #15539.

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 agoetc: Fix install script for rpath removal
Alex Crichton [Wed, 9 Jul 2014 14:44:49 +0000 (07:44 -0700)]
etc: Fix install script for rpath removal

This adds detection of the relevant LD_LIBRARY_PATH-like environment variable
and appropriately sets it when testing whether binaries can run or not.
Additionally, the installation prints a recommended value if one is necessary.

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 &mdash; 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