Commit Graph

30867 Commits

Author SHA1 Message Date
Brian Anderson
9db1d35687 collections: Deprecate shift/unshift
Use insert/remove instead.
2014-07-23 13:20:16 -07:00
Brian Anderson
94e42c2d89 collections: Make push_back/pop_back default methods 2014-07-23 13:20:16 -07:00
Brian Anderson
2d79bfa415 vim: Add MutableSeq 2014-07-23 13:20:16 -07:00
Brian Anderson
7c61bb7213 collections: Move push/pop docs to MutableSeq 2014-07-23 13:20:16 -07:00
Brian Anderson
5599b69b6d Convert some push_back users to push 2014-07-23 13:20:16 -07:00
Brian Anderson
79a980558b collections: Deprecate push_back/pop_back 2014-07-23 13:20:16 -07:00
Brian Anderson
d36a8f3f9c collections: Move push/pop to MutableSeq
Implement for Vec, DList, RingBuf. Add MutableSeq to the prelude.

Since the collections traits are in the prelude most consumers of
these methods will continue to work without change.

[breaking-change]
2014-07-23 13:20:10 -07:00
bors
c080d26d32 auto merge of #15902 : nham/rust/hash_triemap, r=alexcrichton
cc #15294
2014-07-23 18:11:15 +00:00
bors
826b835813 auto merge of #15749 : vhbit/rust/treemap-doc-fixes, r=alexcrichton
1. Removed obsolete comment regarding recursive/iteration implementations of tree_find_with/tree_find_mut_with
2. Replaced easy breakable find_with example with simpler one (which only removes redundant allocation during search)
2014-07-23 14:06:08 +00:00
bors
b10dcbe53a auto merge of #15910 : sfackler/rust/nogc, r=cmr 2014-07-23 10:06:09 +00:00
bors
b13d6ea6c2 auto merge of #15900 : tbu-/rust/pr_numcleanup, r=kballard
This removes the special casing for `float`s where it was not necessary, as
`-0.0 == 0.0`.
2014-07-23 08:16:10 +00:00
Valerii Hiora
4a00d4e676 TreeMap examples fixes
1. Removed obsolete comment regarding recursive/iteration implementations of tree_find_with/tree_find_mut_with
2. Replaced easy breakable find_with example with simpler one (which only removes redundant allocation during search)
2014-07-23 10:58:46 +03:00
bors
83a8a56473 auto merge of #15899 : aochagavia/rust/guide, r=kballard
The removed code caused confusion because it is not clear that the type of `y` is actually `()`
2014-07-23 06:31:11 +00:00
Steven Fackler
3e62ad3fb9 Remove ancient GC cfg flags 2014-07-22 23:20:09 -07:00
bors
c4209d17a0 auto merge of #15897 : Gankro/rust/it-docs, r=kballard
I found these things to be ambiguous, or at least worth stating explicitly to reduce the amount a user/developer needs to think about the API.
2014-07-23 04:46:09 +00:00
bors
217f1fbfc8 auto merge of #15272 : jakub-/rust/issue-13041, r=pcwalton
Fixes #13041.
2014-07-22 23:11:12 +00:00
Jakub Wieczorek
59edfdd2ab Add Drop support for enums
Fixes #13041.
2014-07-22 23:45:49 +02:00
bors
43d84bf32e auto merge of #15894 : treeman/rust/vec-doc, r=alexcrichton
Fill in examples for missing methods. Opt for `vec![]` instead of `vec!()`.
2014-07-22 21:26:14 +00:00
nham
366c66e171 Implement PartialEq, Eq for TrieMap, TrieSet 2014-07-22 17:04:16 -04:00
nham
9e83d29f30 Derive Hash for TrieMap and TrieSet 2014-07-22 16:36:09 -04:00
bors
bc6bbc3db1 auto merge of #15869 : alexcrichton/rust/issue-15828, r=kballard
Closes #15828
2014-07-22 19:41:13 +00:00
Tobias Bucher
737d92e11f Clean up some trait impls in core::num.
This removes the special casing for `float`s where it was not necessary, as
`-0.0 == 0.0`.
2014-07-22 20:59:57 +02:00
Adolfo Ochagavía
2d1b87ce33 Remove misleading code example from The Guide
The removed code caused confusion because it is not clear that the type of `y` is actually `()`
2014-07-22 20:58:25 +02:00
Alexis Beingessner
7b83600ea2 clarifying iterator trait documentation 2014-07-22 14:24:04 -04:00
bors
31c908b7be auto merge of #15863 : dotdash/rust/lifetimes3, r=alexcrichton
Lifetime intrinsics help to reduce stack usage, because LLVM can apply
stack coloring to reuse the stack slots of dead allocas for new ones.

For example these functions now both use the same amount of stack, while
previous `bar()` used five times as much as `foo()`:

````rust
fn foo() {
  println("{}", 5);
}

fn bar() {
  println("{}", 5);
  println("{}", 5);
  println("{}", 5);
  println("{}", 5);
  println("{}", 5);
}
````

On top of that, LLVM can also optimize out certain operations when it
knows that memory is dead after a certain point. For example, it can
sometimes remove the zeroing used to cancel the drop glue. This is
possible when the glue drop itself was already removed because the
zeroing dominated the drop glue call. For example in:

````rust
pub fn bar(x: (Box<int>, int)) -> (Box<int>, int) {
    x
}
````

With optimizations, this currently results in:

````llvm
define void @_ZN3bar20h330fa42547df8179niaE({ i64*, i64 }* noalias nocapture nonnull sret, { i64*, i64 }* noalias nocapture nonnull) unnamed_addr #0 {
"_ZN29_$LP$Box$LT$int$GT$$C$int$RP$39glue_drop.$x22glue_drop$x22$LP$1347$RP$17h88cf42702e5a322aE.exit":
  %2 = bitcast { i64*, i64 }* %1 to i8*
  %3 = bitcast { i64*, i64 }* %0 to i8*
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 8, i1 false)
  tail call void @llvm.memset.p0i8.i64(i8* %2, i8 0, i64 16, i32 8, i1 false)
  ret void
}
````

But with lifetime intrinsics we get:

````llvm
define void @_ZN3bar20h330fa42547df8179niaE({ i64*, i64 }* noalias nocapture nonnull sret, { i64*, i64 }* noalias nocapture nonnull) unnamed_addr #0 {
"_ZN29_$LP$Box$LT$int$GT$$C$int$RP$39glue_drop.$x22glue_drop$x22$LP$1347$RP$17h88cf42702e5a322aE.exit":
  %2 = bitcast { i64*, i64 }* %1 to i8*
  %3 = bitcast { i64*, i64 }* %0 to i8*
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 8, i1 false)
  tail call void @llvm.lifetime.end(i64 16, i8* %2)
  ret void
}
````

Fixes #15665
2014-07-22 17:56:15 +00:00
bors
2ffccb76ce auto merge of #15857 : treeman/rust/doc-dijkstra-example, r=alexcrichton
I wanted to have a slightly larger example compared to the method examples, but I'm unsure how it worked out.

Feedback would nice.
2014-07-22 16:11:14 +00:00
Jonas Hietala
94500b84d4 Main example for priority queue using dijkstra's algorithm. 2014-07-22 16:50:48 +02:00
bors
5d3aaa87f8 auto merge of #15888 : mprobinson/rust/rustdoc-fixes, r=cmr
Allow "rustdoc --passes list" to work without specifying input files,
as shown in the examples section of the man page.
2014-07-22 14:16:14 +00:00
bors
915fb2b39c auto merge of #15884 : steveklabnik/rust/guide_fix_headings, r=huonw
I screwed this up a while back, and now that I have no outstanding PRs, it's a good time to fix this.
2014-07-22 12:31:13 +00:00
Jonas Hietala
8d54ec8f4b doc: Normalize example style
Remove unnecessary `use std::vec::Vec`. Use ``` code blocks
with rust as default instead of spelling it out.
2014-07-22 14:06:45 +02:00
Jonas Hietala
eafcf6ba41 doc: Vec::from_raw_parts.
Also more explicit raw pointer handling in unsafe examples.
2014-07-22 14:06:45 +02:00
bors
bfcde309e7 auto merge of #15876 : brson/rust/failfat, r=pcwalton
Adds a new runtime unwinding function that encapsulates the printing of the words "explicit failure" when `fail!()` is called w/o arguments.

The before/after optimized assembly:



```
        leaq    "str\"str\"(1412)"(%rip), %rax
        movq    %rax, 24(%rsp)
        movq    $16, 32(%rsp)
        leaq    "str\"str\"(1413)"(%rip), %rax
        movq    %rax, 8(%rsp)
        movq    $19, 16(%rsp)
        leaq    24(%rsp), %rdi
        leaq    8(%rsp), %rsi
        movl    $11, %edx
        callq   _ZN6unwind12begin_unwind21h15836560661922107792E
```

```
        leaq    "str\"str\"(1369)"(%rip), %rax
        movq    %rax, 8(%rsp)
        movq    $19, 16(%rsp)
        leaq    8(%rsp), %rdi
        movl    $11, %esi
        callq   _ZN6unwind31begin_unwind_no_time_to_explain20hd1c720cdde6a116480dE@PLT
```

Before/after filesizes:

rwxrwxr-x 1 brian brian 21479503 Jul 20 22:09 stage2-old/lib/librustc-4e7c5e5c.so
rwxrwxr-x 1 brian brian 21475415 Jul 20 22:30 x86_64-unknown-linux-gnu/stage2/lib/librustc-4e7c5e5c.so

This is the lowest-hanging fruit in the fail-bloat wars. Further fixes are going to require harder tradeoffs.

r? @pcwalton
2014-07-22 10:46:16 +00:00
Jonas Hietala
4357da3560 doc: Fill vec documentation with examples.
Add more useful functions to main example.
2014-07-22 11:07:49 +02:00
bors
62f1bb047b auto merge of #15871 : dotdash/rust/unnamed_fmtstr, r=pcwalton 2014-07-22 09:01:17 +00:00
Jonas Hietala
c004bebc9e doc: Use vec![] instead of vec!() in Vec. 2014-07-22 10:33:26 +02:00
Björn Steinbrink
92d1f155da Emit LLVM lifetime intrinsics to improve stack usage and codegen in general
Lifetime intrinsics help to reduce stack usage, because LLVM can apply
stack coloring to reuse the stack slots of dead allocas for new ones.

For example these functions now both use the same amount of stack, while
previous `bar()` used five times as much as `foo()`:

````rust
fn foo() {
  println("{}", 5);
}

fn bar() {
  println("{}", 5);
  println("{}", 5);
  println("{}", 5);
  println("{}", 5);
  println("{}", 5);
}
````

On top of that, LLVM can also optimize out certain operations when it
knows that memory is dead after a certain point. For example, it can
sometimes remove the zeroing used to cancel the drop glue. This is
possible when the glue drop itself was already removed because the
zeroing dominated the drop glue call. For example in:

````rust
pub fn bar(x: (Box<int>, int)) -> (Box<int>, int) {
    x
}
````

With optimizations, this currently results in:

````llvm
define void @_ZN3bar20h330fa42547df8179niaE({ i64*, i64 }* noalias nocapture nonnull sret, { i64*, i64 }* noalias nocapture nonnull) unnamed_addr #0 {
"_ZN29_$LP$Box$LT$int$GT$$C$int$RP$39glue_drop.$x22glue_drop$x22$LP$1347$RP$17h88cf42702e5a322aE.exit":
  %2 = bitcast { i64*, i64 }* %1 to i8*
  %3 = bitcast { i64*, i64 }* %0 to i8*
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 8, i1 false)
  tail call void @llvm.memset.p0i8.i64(i8* %2, i8 0, i64 16, i32 8, i1 false)
  ret void
}
````

But with lifetime intrinsics we get:

````llvm
define void @_ZN3bar20h330fa42547df8179niaE({ i64*, i64 }* noalias nocapture nonnull sret, { i64*, i64 }* noalias nocapture nonnull) unnamed_addr #0 {
"_ZN29_$LP$Box$LT$int$GT$$C$int$RP$39glue_drop.$x22glue_drop$x22$LP$1347$RP$17h88cf42702e5a322aE.exit":
  %2 = bitcast { i64*, i64 }* %1 to i8*
  %3 = bitcast { i64*, i64 }* %0 to i8*
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* %2, i64 16, i32 8, i1 false)
  tail call void @llvm.lifetime.end(i64 16, i8* %2)
  ret void
}
````

Fixes #15665
2014-07-22 09:17:41 +02:00
bors
8d43e4474a auto merge of #15867 : cmr/rust/rewrite-lexer4, r=alexcrichton 2014-07-22 07:16:17 +00:00
Corey Richardson
95a1ce6f3f Fix pretty test 2014-07-21 22:53:36 -07:00
bors
32f4d996ea auto merge of #15870 : jakub-/rust/issue-15793, r=alexcrichton
Fixes #15793.
2014-07-22 05:21:19 +00:00
Corey Richardson
857bb60fe0 Don't run lexer tests by default 2014-07-21 19:26:20 -07:00
bors
6e3e0a83aa auto merge of #15834 : Kimundi/rust/moved_syntax_env, r=cmr
- Made custom syntax extensions capable of expanding custom macros by moving `SyntaxEnv` into `ExtCtx`
- Added convenience method on `ExtCtx` for getting a macro expander.
- Made a few things private to force only a single way to use them (through `ExtCtx`)
- Removed some ancient commented-out code

Closes #14946
2014-07-22 02:06:21 +00:00
Corey Richardson
35c0bf3292 Add a ton of ignore-lexer-test 2014-07-21 18:38:40 -07:00
Corey Richardson
c41a7dfcc7 Shuffle around check-lexer conditions 2014-07-21 18:38:40 -07:00
Corey Richardson
dd3afb42d1 Break apart long lines in verify.rs 2014-07-21 18:37:17 -07:00
Corey Richardson
cbd6799110 lexer tests: makefile/configure 2014-07-21 18:37:17 -07:00
bors
aa0e35bc64 auto merge of #15217 : steveklabnik/rust/range, r=huonw
Inspired by http://www.reddit.com/r/rust/comments/298js2/what_is_the_rationale_behind_the_second_parameter/
2014-07-22 00:26:21 +00:00
Steve Klabnik
1e9f86b1dc Guide: fix headings 2014-07-21 19:39:16 -04:00
Steve Klabnik
ba769d833f Clarify range's exclusivity.
Inspired by http://www.reddit.com/r/rust/comments/298js2/what_is_the_rationale_behind_the_second_parameter/
2014-07-21 19:18:56 -04:00
Marvin Löbel
cef4378269 Refactoring: Only use MacroExpander for expanding outside of
`syntax::ext::expand`
2014-07-22 01:00:03 +02:00
Mike Robinson
6d3a623cc8 Fix rustdoc --passes list
Allow "rustdoc --passes list" to work without specifying input files,
as shown in the examples section of the man page.
2014-07-21 23:37:04 +01:00