Commit Graph

61708 Commits

Author SHA1 Message Date
Matt Brubeck
b2ac1c9c6b Additional docs for Vec, String, and slice trait impls 2017-02-16 12:12:17 -08:00
Simonas Kazlauskas
0e45a5ed3f [rustbuild] add a way to run command after failure
This is a simple way to workaround the debugging issues caused by the rustc
wrapper used in the bootstrap process. Namely, it uses some obscure environment
variables and you can’t just copy the failed command and run it in the shell or
debugger to examine the failure more closely.

With `--on-fail` its possible to run an arbitrary command within exactly the
same environment under which rustc failed. Theres’s multiple ways to use this
new flag:

$ python x.py build --stage=1 --on-fail=env

    would print a list of environment variables and the failed command, so a
    few copy-pastes and you now can run the same rust in your shell outside the
    bootstrap system.

$ python x.py build --stage=1 --on-fail=bash

    Is a more useful variation of the command above in that it launches a whole
    shell with environment already in place! All that’s left to do is copy-paste
    the command just above the shell prompt!

Fixes #38686
Fixes #38221
2017-02-16 21:12:38 +02:00
Niko Matsakis
f2d8a00191 erase late bound regions in get_vtable_methods()
Higher-ranked object types can otherwise cause late-bound regions to
sneak into the substs, leading to the false conclusion that some method
is unreachable.  The heart of this patch is from @arielb1.
2017-02-16 13:56:06 -05:00
Josh Driver
2d91e7aab8 Refactor macro resolution errors + add derive macro suggestions 2017-02-16 22:03:15 +10:30
bors
ccd96c945f Auto merge of #39824 - alexcrichton:disable-dist-src, r=brson
travis: Disable source tarballs on most builders

Currently we create a source tarball on almost all of the `DEPLOY=1` builders
but this has the adverse side effect of all source tarballs overriding
themselves in the S3 bucket. Normally this is ok but unfortunately a source
tarball created on Windows is not buildable on Unix.

On Windows the vendored sources contain paths with `\` characters in them which
when interpreted on Unix end up in "file not found" errors.

Instead of this overwriting behavior, whitelist just one linux builder for
producing tarballs and avoid producing tarballs on all other hosts.
2017-02-16 08:20:29 +00:00
Benoît CORTIER
36b00cf217 Correct a typo in procedural macros chapter of the Book. (fixup [c8292fcd6a]) 2017-02-16 09:18:19 +01:00
Shawn Walker-Salas
5789539311 simplify home_dir by removing unnecessary getpwuid_r wrapper 2017-02-15 22:52:47 -08:00
Esteban Küber
a7f63d12a7 Remove noop method Substs::params()
Re: 48b3dd11f5
2017-02-15 22:17:07 -08:00
bors
d77af7f639 Auto merge of #39876 - frewsxcv:rollup, r=frewsxcv
Rollup of 12 pull requests

- Successful merges: #39775, #39793, #39804, #39834, #39836, #39839, #39840, #39843, #39844, #39846, #39857, #39861
- Failed merges:
2017-02-16 05:52:46 +00:00
Corey Farwell
c6edfdb261 Rollup merge of #39861 - retep998:small-fix, r=alexcrichton
Fix parameter to GetUserProfileDirectoryW
2017-02-15 23:48:23 -05:00
Corey Farwell
88f40f7878 Rollup merge of #39857 - binarycrusader:master, r=alexcrichton
use bash when invoking dist shell scripts on solaris

Partially fixes #25845

A separate, trivial fix is needed to the rust-installer scripts to completely resolve this issue.
2017-02-15 23:48:22 -05:00
Corey Farwell
23e2d2ff37 Rollup merge of #39846 - WRONGWAY4YOU:typo-fix, r=frewsxcv
Fix typo
2017-02-15 23:48:21 -05:00
Corey Farwell
12f3e45106 Rollup merge of #39844 - king6cong:sys, r=alexcrichton
sys/mod doc update and mod import order adjust

* Some doc updates.
* Racer currently use the first mod it finds regardless of cfg attrs. Moving #[cfg(unix)] up should be a temporary tweak that works as expected for more people.
2017-02-15 23:48:20 -05:00
Corey Farwell
a6b1c131a5 Rollup merge of #39843 - AndrewGaspar:natvis, r=brson
Vec, LinkedList, VecDeque, String, and Option NatVis visualizations

I've added some basic [NatVis](https://msdn.microsoft.com/en-us/library/jj620914.aspx) visualizations for core Rust collections and types. This helps address a need filed in issue #36503. NatVis visualizations are similar to gdb/lldb pretty printers, but for windbg and the Visual Studio debugger on Windows.

For example, Vec without the supplied NatVis looks like this in windbg using the "dx" command:
```
0:000> dx some_64_bit_vec
some_64_bit_vec                 [Type: collections::vec::Vec<u64>]
    [+0x000] buf              [Type: alloc::raw_vec::RawVec<u64>]
    [+0x010] len              : 0x4 [Type: unsigned __int64]
```

With the NatVis, the elements of the Vec are displayed:
```
0:000> dx some_64_bit_vec
some_64_bit_vec                 : { size=0x4 } [Type: collections::vec::Vec<u64>]
    [<Raw View>]     [Type: collections::vec::Vec<u64>]
    [size]           : 0x4 [Type: unsigned __int64]
    [capacity]       : 0x4 [Type: unsigned __int64]
    [0]              : 0x4 [Type: unsigned __int64]
    [1]              : 0x4f [Type: unsigned __int64]
    [2]              : 0x1a [Type: unsigned __int64]
    [3]              : 0x184 [Type: unsigned __int64]
```

In fact, the vector can be treated as an array by the NatVis expression evaluator:
```
0:000> dx some_64_bit_vec[2]
some_64_bit_vec[2] : 0x1a [Type: unsigned __int64]
```

In general, it works with any NatVis command that understands collections, such as NatVis LINQ expressions:
```
0:000> dx some_64_bit_vec.Select(x => x * 2)
some_64_bit_vec.Select(x => x * 2)
    [0]              : 0x8
    [1]              : 0x9e
    [2]              : 0x34
    [3]              : 0x308
```

std::string::String is implemented, as well:
```
0:000> dv
    hello_world = "Hello, world!"
          empty = ""
            new = ""
0:000> dx hello_world
hello_world                 : "Hello, world!" [Type: collections::string::String]
    [<Raw View>]     [Type: collections::string::String]
    [size]           : 0xd [Type: unsigned __int64]
    [capacity]       : 0xd [Type: unsigned __int64]
    [0]              : 72 'H' [Type: char]
    [1]              : 101 'e' [Type: char]
...
    [12]             : 33 '!' [Type: char]
0:000> dx empty
empty                 : "" [Type: collections::string::String]
    [<Raw View>]     [Type: collections::string::String]
    [size]           : 0x0 [Type: unsigned __int64]
    [capacity]       : 0x0 [Type: unsigned __int64]

```

VecDeque and LinkedList are also implemented.

My biggest concern is the implementation for Option due to the different layouts it can receive based on whether the sentinel value can be embedded with-in the Some value or must be stored separately.

It seems to work, but my testing isn't exhaustive:
```
0:000> dv
          three = { Some 3 }
           none = { None }
         no_str = { None }
       some_str = { Some "Hello!" }
0:000> dx three
three                 : { Some 3 } [Type: core::option::Option<i32>]
    [<Raw View>]     [Type: core::option::Option<i32>]
    [size]           : 0x1 [Type: ULONG]
    [value]          : 3 [Type: int]
    [0]              : 3 [Type: int]
0:000> dx none
none                 : { None } [Type: core::option::Option<i32>]
    [<Raw View>]     [Type: core::option::Option<i32>]
    [size]           : 0x0 [Type: ULONG]
    [value]          : 4 [Type: int]
0:000> dx no_str
no_str                 : { None } [Type: core::option::Option<collections::string::String>]
    [<Raw View>]     [Type: core::option::Option<collections::string::String>]
    [size]           : 0x0 [Type: ULONG]
0:000> dx some_str
some_str                 : { Some "Hello!" } [Type: core::option::Option<collections::string::String>]
    [<Raw View>]     [Type: core::option::Option<collections::string::String>]
    [size]           : 0x1 [Type: ULONG]
    [value]          : 0x4673df710 : "Hello!" [Type: collections::string::String *]
    [0]              : "Hello!" [Type: collections::string::String]
```

For now all of these visualizations work in windbg, but I've only gotten the visualizations in libcore.natvis working in the VS debugger. My priority is windbg, but somebody else may be interested in investigating the issues related to VS.

You can load these visualizations into a windbg sessions using the .nvload command:
```
0:000> .nvload ..\rust\src\etc\natvis\libcollections.natvis; .nvload ..\rust\src\etc\natvis\libcore.natvis
Successfully loaded visualizers in "..\rust\src\etc\natvis\libcollections.natvis"
Successfully loaded visualizers in "..\rust\src\etc\natvis\libcore.natvis"
```

There are some issues with the symbols that Rust and LLVM conspire to emit into the PDB that inhibit debugging in windbg generally, and by extension make writing visualizations more difficult. Additionally, there are some bugs in windbg itself that complicate or disable some use of the NatVis visualizations for Rust. Significantly, due to NatVis limitations in windbg around allowable type names, you cannot write a visualization for [T] or str. I'll report separate issues as I isolate them.

In the near term, I hope to fill out these NatVis files with more of Rust's core collections and types. In the long run, I hope that we can ship NatVis files with crates and streamline their deployment when debugging Rust programs on windows.
2017-02-15 23:48:19 -05:00
Corey Farwell
ce9b478392 Rollup merge of #39840 - DaseinPhaos:patch-2, r=frewsxcv
Update procedural-macros.md

Fix typo
2017-02-15 23:48:18 -05:00
Corey Farwell
35bf74b0ce Rollup merge of #39839 - king6cong:refine-doc, r=frewsxcv
make doc consistent with var name
2017-02-15 23:48:17 -05:00
Corey Farwell
46564d405c Rollup merge of #39836 - durka:patch-37, r=alexcrichton
fix types in to_owned doctest

Fixes #39831.
2017-02-15 23:48:15 -05:00
Corey Farwell
4a07be3bea Rollup merge of #39834 - cseale:feature-gate-static-recursion, r=est31
static recursion test added to compile-fail test suite

Issue #39059
r? @est31
2017-02-15 23:48:15 -05:00
Corey Farwell
01ccaa3673 Rollup merge of #39804 - seppo0010:recommend-five-traits, r=jonathandturner
Show five traits implementation in help when there are exactly five

Fixes #39802
2017-02-15 23:48:14 -05:00
Corey Farwell
3f95303db6 Rollup merge of #39793 - RalfJung:cell, r=alexcrichton
Allow more Cell methods for non-Copy types

Clearly, `get_mut` is safe for any `T`. The other two only provide unsafe pointers anyway.

The only remaining inherent method with `Copy` bound is `get`, which sounds about right to me.

I found the order if `impl` blocks in the file a little weird (first inherent impl, then some trait impls, then another inherent impl), but didn't change it to keep the diff small.

Contributes to #39264
2017-02-15 23:48:13 -05:00
Corey Farwell
ef45eca8a5 Rollup merge of #39775 - mina86:master, r=steveklabnik
book: don’t use GNU extensions in the example unnecessarily

The use of a GNU C extension for bloc expressions is immaterial to the
actual problem with C macros that the section tries to show so don’t
use it and instead use a plain C way of writing the macro which has
added benefit of being better C code (since the macro now behaves like
a function, syntax-wise).
2017-02-15 23:48:12 -05:00
Alex Crichton
c02c44db72 rustc: Link statically to the MSVCRT
This commit changes all MSVC rustc binaries to be compiled with
`-C target-feature=+crt-static` to link statically against the MSVCRT instead of
dynamically (as it does today). This also necessitates compiling LLVM in a
different fashion, ensuring it's compiled with `/MT` instead of `/MD`.

cc #37406
2017-02-15 19:36:29 -08:00
bors
1b6f1fe9dd Auto merge of #39761 - est31:master, r=aturon
Stabilize field init shorthand

Closes #37340.

~Still blocked by the documentation issue #38830.~ EDIT: seems that all parts required for stabilisation are fixed, so its not blocked.
2017-02-16 03:18:37 +00:00
Amos Onn
a2d176e8f4 std::io::cursor: Fixed Seek so test passes. 2017-02-16 03:20:49 +01:00
Alex Crichton
1902488228 travis: Disable source tarballs on most builders
Currently we create a source tarball on almost all of the `DEPLOY=1` builders
but this has the adverse side effect of all source tarballs overriding
themselves in the S3 bucket. Normally this is ok but unfortunately a source
tarball created on Windows is not buildable on Unix.

On Windows the vendored sources contain paths with `\` characters in them which
when interpreted on Unix end up in "file not found" errors.

Instead of this overwriting behavior, whitelist just one linux builder for
producing tarballs and avoid producing tarballs on all other hosts.
2017-02-15 18:07:16 -08:00
Shawn Walker-Salas
ebf70a9a20 libstd needs update for pending libc change
Fixes #39868
2017-02-15 17:52:24 -08:00
Amos Onn
ab57e7b868 std::io::cursor Added test for seeking beyond i64. 2017-02-16 02:16:41 +01:00
Stjepan Glavina
1fbbe79bcb Fix wording in LocalKey documentation 2017-02-15 23:31:51 +01:00
Peter Atashian
d5a4db3c16
Fix parameter to GetUserProfileDirectoryW 2017-02-15 17:31:51 -05:00
bors
4d6019d07a Auto merge of #39457 - bvinc:master, r=alexcrichton
Dont segfault if btree range is not in order

This is a first attempt to fix issue #33197.  The issue is that the BTree iterator uses next_unchecked for fast iteration, but it can be tricked into running off the end of the tree and segfaulting if range is called with a maximum that is less than the minimum.

Since a user defined Ord should not determine the safety of BTreeMap, and we still want fast iteration, I've implemented the idea of @gereeter and walk the tree simultaneously searching for both keys to make sure that if our keys diverge, the min key is to the left of our max key.  I currently panic if that is not the case.

Open questions:

1.  Do we want to panic in this error case or do we want to return an empty iterator?  The drain API panics if the range is bad, but drain is given a range of index values, while this is a generic key type.  Panicking is brittle and returning an empty iterator is probably the most flexible and matches what people would want it to do... but artificially returning a BTreeMap::Range with start==end seems like a pretty weird and unnatural thing to do, although it's doable since those fields are not accessible.

The same question for other weird cases:
2.  (Included(101), Excluded(100)) on a map that contains [1,2,3].  Both BTree edges end up on the same part of the map, but comparing the keys shows the range is backwards.
3.  (Excluded(5), Excluded(5)).  The keys are equal but BTree edges end up backwards if the map contains 5.
4.  (Included(5), Excluded(5)).  Should naturally produce an empty iterator, right?
2017-02-15 22:02:36 +00:00
Shawn Walker-Salas
087c2337c1 use bash when invoking dist shell scripts on solaris
Partially fixes #25845
2017-02-15 12:51:26 -08:00
Jakob Demler
97451996e6 fixed whitespace issues 2017-02-15 21:21:31 +01:00
Colm Seale
cf20d8e23c static recursion test added to compile-fail test suite
Issue #39059
    r? @est31
2017-02-15 20:13:24 +00:00
Simonas Kazlauskas
4a3c66ad2f [MIR] Make InlineAsm a Statement
Previously InlineAsm was an Rvalue, but its semantics doesn’t really match the semantics of an
Rvalue – rather it behaves more like a Statement.
2017-02-15 21:21:36 +02:00
Michal Nazarewicz
8685adb26b book: binary prefixed are defined by IEC and not in SI
Binary prefixes (such as Gi for ‘gibi-’ in GiB) are defined by
International Electrotechnical Commission (IEC) and not in the
International System of Units (SI).
2017-02-15 17:05:53 +01:00
Jeff Muizelaar
4ba6e1b688 Remove obsolete documentation about drop-flags 2017-02-15 11:03:59 -05:00
Michal Nazarewicz
b6a1618332 book: don’t use GNU extensions in the example unnecessarily
The use of a GNU C extension for bloc expressions is immaterial to the
actual problem with C macros that the section tries to show so don’t
use it and instead use a plain C way of writing the macro.
2017-02-15 15:57:57 +01:00
Jakob Demler
9a39994ee3 add bash to error-messages 2017-02-15 15:31:52 +01:00
bors
62eb6056d3 Auto merge of #39781 - nrc:save-impls, r=nikomatsakis
save-analysis: emit info about impls and super-traits in JSON
2017-02-15 13:48:09 +00:00
Benoît CORTIER
c8292fcd6a Correct a typo in procedural macros chapter of the Book. 2017-02-15 13:44:52 +01:00
Dmitry Guzeev
577497b541 Fix typo 2017-02-15 15:13:31 +03:00
Jakob Demler
5189c4f8c1 custom attributes and error reporting docs for procedural macros 2017-02-15 12:59:01 +01:00
king6cong
b821313327 sys/mod doc update and mod import order adjust 2017-02-15 18:42:18 +08:00
bors
e0044bd389 Auto merge of #39594 - clarcharr:cstr_box, r=aturon
Conversions between CStr, OsStr, Path and boxes

This closes a bit of the inconsistencies between `CStr`, `OsStr`, `Path`, and `str`, allowing people to create boxed versions of DSTs other than `str` and `[T]`.

Full list of additions:
* `Default` for `Box<str>`, `Box<CStr>`, `Box<OsStr>`, and `Box<Path>` (note: `Default` for `PathBuf` is already implemented)
* `CString::into_boxed_c_str` (feature gated)
* `OsString::into_boxed_os_str` (feature gated)
* `Path::into_boxed_path` (feature gated)
* `From<&CStr> for Box<CStr>`
* `From<&OsStr> for Box<OsStr>`
* `From<&Path> for Box<Path>`

This also includes adding the internal methods:
* `sys::*::os_str::Buf::into_box`
* `sys::*::os_str::Slice::{into_box, empty_box}`
* `sys_common::wtf8::Wtf8Buf::into_box`
* `sys_common::wtf8::Wtf8::{into_box, empty_box}`
2017-02-15 10:22:34 +00:00
Luxko
938fed7f0f Update procedural-macros.md
Fix typo
2017-02-15 03:53:27 -06:00
Andrew Gaspar
a8b7b28bab Vec, LinkedList, VecDeque, String, and Option NatVis visualizations 2017-02-15 01:51:19 -08:00
bors
ea8c62919e Auto merge of #39560 - F001:retainHashMap, r=alexcrichton
std: Add retain method for HashMap and HashSet

Fix #36648

r? @bluss
2017-02-15 07:30:10 +00:00
king6cong
5156dedec8 make doc consistent with var name 2017-02-15 14:52:13 +08:00
est31
aebd94fd3c Stabilize field init shorthand
Closes #37340.
2017-02-15 07:11:13 +01:00
Alex Burka
e3384e08ca fix types in to_owned doctest 2017-02-14 23:07:51 -05:00