Commit Graph

46758 Commits

Author SHA1 Message Date
Manish Goregaokar
012f36947a Add note about Copy for drop() 2015-09-26 01:00:05 +05:30
bors
e7a73881e9 Auto merge of #28610 - nrc:fmt6, r=brson 2015-09-25 19:06:02 +00:00
Ulrik Sverdrup
804efdabcd Add AsMut<Vec<T>> for Vec<T> 2015-09-25 19:54:15 +02:00
Alex Crichton
d5f2d3b177 std: Update MatchIndices to return a subslice
This commit updates the `MatchIndices` and `RMatchIndices` iterators to follow
the same pattern as the `chars` and `char_indices` iterators. The `matches`
iterator currently yield `&str` elements, so the `MatchIndices` iterator now
yields the index of the match as well as the `&str` that matched (instead of
start/end indexes).

cc #27743
2015-09-25 09:29:23 -07:00
Andrew Paseltiner
db18718809 Simplify Debug for {EnumSet, VecDeque} 2015-09-25 12:03:03 -04:00
Ulrik Sverdrup
9b97264d81 Implement AsMut for Vec
Fixes #28549
2015-09-25 17:43:58 +02:00
Alfie John
29048c3a80 Keep examples consistent 2015-09-25 12:02:21 +00:00
Ben S
c6e1b12a58 Change the first line of the println macro doc
This makes the first lines of the print! and println! macros
different. Previously, they would show up exactly the same in the
documentation for the macros in libstd [1], with nothing about how
one of them also prints a newline.

[1]: https://doc.rust-lang.org/stable/std/#macros
2015-09-25 12:29:47 +01:00
Simon Sapin
761d16327a Docs: &A and &mut A are references, not pointers
Caught by Brian Smith: https://github.com/rust-lang/rust/issues/27774#issuecomment-143154735
2015-09-25 13:01:31 +02:00
Björn Steinbrink
91f7c60d2d Tell LLVM when a match is exhaustive
By putting an "unreachable" instruction into the default arm of a switch
instruction we can let LLVM know that the match is exhaustive, allowing
for better optimizations.

For example, this match:
```rust
pub enum Enum {
    One,
    Two,
    Three,
}

impl Enum {
    pub fn get_disc(self) -> u8 {
        match self {
            Enum::One => 0,
            Enum::Two => 1,
            Enum::Three => 2,
        }
    }
}
```

Currently compiles to this on x86_64:
```asm
  .cfi_startproc
  movzbl  %dil, %ecx
  cmpl  $1, %ecx
  setne %al
  testb %cl, %cl
  je  .LBB0_2
  incb  %al
  movb  %al, %dil
.LBB0_2:
  movb  %dil, %al
  retq
.Lfunc_end0:
```

But with this change we get:
```asm
  .cfi_startproc
  movb  %dil, %al
  retq
.Lfunc_end0:
```
2015-09-25 11:09:19 +02:00
Vadim Chugunov
e82bb915e4 Fix dllimports of static data from rlibs 2015-09-24 22:07:12 -07:00
Nick Howell
0bebbab41a rustbook: Decrease the max-width for the mobile view
This should fix #22682.

"max-width: 1023px" seems like a good compromise here. This way,
1024x768 monitors will still see the sidebar (plus, iPad in landscape
mode).
2015-09-25 00:36:30 -04:00
Nick Howell
b68e9162fe Cleanup rustbook.css and fix some padding issues 2015-09-25 00:23:14 -04:00
Nick Howell
9f770a7536 rustbook: Inline javascript.rs into build.rs
There's no need for javascript.rs now that its contents were moved into
.js files.

Also, adjust a couple variable names and some indentation in build.rs.
2015-09-24 22:43:18 -04:00
Nick Howell
115ec662b5 Add 'use strict' to playpen.js 2015-09-24 22:35:04 -04:00
Nick Howell
c8f5f6f70f Replace occurrences of "rust-book" with "rustbook" 2015-09-24 22:34:01 -04:00
bors
6c2e3fbe90 Auto merge of #28505 - apasel422:issue-28448, r=alexcrichton
Closes #28448.

r? @brson
2015-09-25 02:05:25 +00:00
Nick Howell
5ac899c8c2 Cleanup rustbook.js and add 'use strict'
Mostly indentation fixes, but a little refactoring, too.
2015-09-24 21:59:43 -04:00
Andrea Canciani
54c0231b14 Abort earlier upon multi-panics
The double-panic `abort` is run after the logging code, to provide
feedback in case of a double-panic. This means that if the panic
logging fails with a panic, the `abort` might never be reached.

This should not normally occur, but if the `on_panic` function detects
more than 2 panics, aborting *before* logging makes panic handling
somewhat more robust, as it avoids an infinite recursion, which would
eventually crash the process, but also make the problem harder to
debug.

This handles the FIXME about what to do if the thread printing panics.
2015-09-24 23:52:13 +02:00
Andrea Canciani
c7b84909b0 Explicitly count the number of panics
Move the panic handling logic from the `unwind` module to `panicking`
and use a panic counter to distinguish between normal state, panics
and double panics.
2015-09-24 23:49:38 +02:00
Andrea Canciani
44d1b149d2 Separate panic logging code
Move the panic logging code to a function separate from `on_panic` and
simplify the code to decide whether the backtrace should be logged.
2015-09-24 23:45:59 +02:00
bors
5ca60d9431 Auto merge of #28608 - eddyb:no-place-for-an-old-box, r=pnkfelix
While this is technically a [breaking-change], there is no excuse for touching `HEAP`.
r? @pnkfelix
2015-09-24 20:42:56 +00:00
Vadim Petrochenkov
f284cbc7af Cleanup interfaces of Name, SyntaxContext and Ident
Make sure Name, SyntaxContext and Ident are passed by value
Make sure Idents don't serve as keys (or parts of keys) in maps, Ident comparison is not well defined
2015-09-24 23:05:02 +03:00
bors
6a2187414a Auto merge of #28538 - alevy:make_fixedsizearray_unsafe, r=alexcrichton
[breaking-change]

`FixedSizeArray` is meant to be implemented for arrays of fixed size only, but can be implemented for anything at the moment. Marking the trait unsafe would make it more reasonable to write unsafe code which operates on fixed size arrays of any size.

For example, using `uninitialized` to create a fixed size array and immediately filling it with a fixed value is externally safe:

```
pub fn init_with_nones<T, A: FixedSizeArray<Option<T>>>() -> A {
    let mut res = unsafe { mem::uninitialized() };
    for elm in res.as_mut_slice().iter_mut() {
        *elm = None;
    }
    res
}
```

But the same code is not safe if `FixedSizeArray` is implemented for other types:

```
struct Foo { foo: usize }
impl FixedSizeArray<Option<usize>> for Foo {
    fn as_slice(&self) -> &[usize] { &[] }
    fn as_mut_slice(&self) -> &mut [usize] { &mut [] }
}
```

now `init_with_nones() : Foo` returns a `Foo` with an undefined value for the field `foo`.
2015-09-24 18:55:00 +00:00
critiqjo
09d4deef5b trpl: Refactor returning closures section 2015-09-25 00:17:54 +05:30
Sebastian Wicki
abfedb7d16 Fix target_vendor for Android 2015-09-24 19:44:53 +02:00
bors
e9801294a1 Auto merge of #28634 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #28616, #28617, #28618, #28619, #28620, #28622
- Failed merges: #28621
2015-09-24 17:07:04 +00:00
William Throwe
1e0c23d781 Allow multi-digit GDB minor version numbers
GDB 7.10 was recently released.
2015-09-24 13:04:22 -04:00
Simon Sapin
081278eb7a Utf8Error::valid_up_to: make documented semantics more precise/useful 2015-09-24 18:54:12 +02:00
Alex Crichton
81f0bf7667 std: Switch string::ParseError to an empty enum
It can never be instantiated, so signify this by having it actually be an empty
`enum`.

cc #27734
2015-09-24 09:40:50 -07:00
Steve Klabnik
c3ca182082 Rollup merge of #28622 - tshepang:known-as-structs, r=steveklabnik 2015-09-24 10:26:37 -06:00
Steve Klabnik
e314ac601a Rollup merge of #28620 - tshepang:not-filled, r=steveklabnik 2015-09-24 10:26:37 -06:00
Steve Klabnik
c104ba3755 Rollup merge of #28619 - tshepang:fix-link, r=steveklabnik 2015-09-24 10:26:37 -06:00
Steve Klabnik
668ffb1dd8 Rollup merge of #28618 - tshepang:repetition, r=steveklabnik 2015-09-24 10:26:36 -06:00
Steve Klabnik
c16b0f7060 Rollup merge of #28617 - tshepang:optional, r=steveklabnik 2015-09-24 10:26:36 -06:00
Steve Klabnik
6f0a095d05 Rollup merge of #28616 - tshepang:idiom, r=steveklabnik 2015-09-24 10:26:36 -06:00
Ariel Ben-Yehuda
77e8f33c3d early-prohibit objects with Self-containing supertraits
Fixes #28576
2015-09-24 18:27:29 +03:00
Eduard Burtescu
f293ea28b4 Remove the deprecated box(PLACE) syntax. 2015-09-24 18:00:08 +03:00
bors
355bbfb895 Auto merge of #28602 - apasel422:clone_from, r=bluss
r? @bluss
2015-09-24 14:19:20 +00:00
Andrew Paseltiner
97f2a32564 Optimize Vec::clone_from
Before:

test dst_bigger::src_100_dst_1000::clone      ... bench:  34 ns/iter (+/- 1)
test dst_bigger::src_100_dst_1000::clone_from ... bench:  75 ns/iter (+/- 3)

test dst_bigger::src_10_dst_100::clone        ... bench:  25 ns/iter (+/- 0)
test dst_bigger::src_10_dst_100::clone_from   ... bench:   9 ns/iter (+/- 1)

test eq::src_1000_dst_1000::clone             ... bench: 105 ns/iter (+/- 2)
test eq::src_1000_dst_1000::clone_from        ... bench: 593 ns/iter (+/- 21)

test eq::src_100_dst_100::clone               ... bench:  34 ns/iter (+/- 1)
test eq::src_100_dst_100::clone_from          ... bench:  75 ns/iter (+/- 1)

test src_bigger::src_1000_dst_100::clone      ... bench: 103 ns/iter (+/- 5)
test src_bigger::src_1000_dst_100::clone_from ... bench: 148 ns/iter (+/- 5)

test src_bigger::src_100_dst_10::clone        ... bench:  34 ns/iter (+/- 1)
test src_bigger::src_100_dst_10::clone_from   ... bench:  20 ns/iter (+/- 0)

After:

test dst_bigger::src_100_dst_1000::clone      ... bench:  34 ns/iter (+/- 2)
test dst_bigger::src_100_dst_1000::clone_from ... bench:  15 ns/iter (+/- 1)

test dst_bigger::src_10_dst_100::clone        ... bench:  26 ns/iter (+/- 1)
test dst_bigger::src_10_dst_100::clone_from   ... bench:   7 ns/iter (+/- 0)

test eq::src_1000_dst_1000::clone             ... bench: 103 ns/iter (+/- 1)
test eq::src_1000_dst_1000::clone_from        ... bench:  85 ns/iter (+/- 4)

test eq::src_100_dst_100::clone               ... bench:  34 ns/iter (+/- 2)
test eq::src_100_dst_100::clone_from          ... bench:  15 ns/iter (+/- 1)

test src_bigger::src_1000_dst_100::clone      ... bench: 103 ns/iter (+/- 4)
test src_bigger::src_1000_dst_100::clone_from ... bench:  90 ns/iter (+/- 2)

test src_bigger::src_100_dst_10::clone        ... bench:  34 ns/iter (+/- 2)
test src_bigger::src_100_dst_10::clone_from   ... bench:  20 ns/iter (+/- 0)

Closes #28601.
2015-09-24 08:47:33 -04:00
Tshepang Lekhonkhobe
0b13ee0ced reference: rename "structure" to the more familiar "struct" 2015-09-24 08:42:39 +02:00
Steven Fackler
e5ee13f139 Add accessors for Formatter flags
cc #27726
2015-09-23 23:35:12 -07:00
Tshepang Lekhonkhobe
f34eafdcf9 reference: follow idiom in code snippet 2015-09-24 08:25:43 +02:00
Tshepang Lekhonkhobe
996bd9d0d6 reference: 3 of the 4 things mentioned here are optional 2015-09-24 08:22:58 +02:00
Tshepang Lekhonkhobe
7077075372 doc: "familiarity" does not need to be repeated here 2015-09-24 08:04:55 +02:00
Tshepang Lekhonkhobe
e0f35da9c1 reference: fix anchor link 2015-09-24 07:55:59 +02:00
Tshepang Lekhonkhobe
5f73037b8a reference: not sure this is the right place to discuss design 2015-09-24 07:50:44 +02:00
bors
8fe79bdfda Auto merge of #28607 - remram44:doc-fix-str-pattern, r=alexcrichton
Reported by Moonlightning on #rust
> 17:13 EDT < Moonlightning> I think I found a bug in the str::matches() documentation. Was it copied from str::split()? :p
> 17:13 EDT < Moonlightning> Because it says “The pattern can be a simple `&str`, `char`, or a closure that determines the split.”

I changed "determines the split" to "determines if a character matches".

It's not super clear, "determines the split" is not super clear to begin with, maybe this can be made better? On the other hand following the link to Pattern provides enough details.
2015-09-24 02:39:02 +00:00
bors
f0666b45dd Auto merge of #28598 - semarie:openbsd-unbreak, r=alexcrichton
separate use code between openbsd/netbsd

netbsd use c_int and c_uint, but openbsd not, resulting a unused_import
error.

r? @alexcrichton 

problem introduced by #28543
2015-09-24 00:02:07 +00:00
Sebastian Wicki
af68cdfea1 rustc: Add target_vendor for target triples
This adds a new target property, `target_vendor` which can be used as a
matcher for conditional compilation. The vendor is part of the autoconf
target triple: <arch><sub>-<vendor>-<os>-<env>

The default value for `target_vendor` is "unknown".

Matching against the `target_vendor` with `#[cfg]` is currently feature
gated as `cfg_target_vendor`.
2015-09-24 01:44:55 +02:00