Commit Graph

42854 Commits

Author SHA1 Message Date
bors
c3d60aba6c Auto merge of #25669 - GuillaumeGomez:typo-fix, r=Manishearth
r? @steveklabnik
2015-05-21 19:41:18 +00:00
Guillaume Gomez
86a821e5d1 Replace "more later" by "later" 2015-05-21 20:30:15 +02:00
bors
7044f4a394 Auto merge of #25601 - ericye16:master, r=steveklabnik 2015-05-21 17:01:51 +00:00
bors
59ba55ddbd Auto merge of #25473 - doomrobo:patch-3, r=steveklabnik
Added `Deref` to the "Special Traits" section
2015-05-21 15:24:16 +00:00
bors
bc6318d2be Auto merge of #25676 - dmgawel:patch-1, r=huonw
Earlier created vector `["Hello", "world"]` has two elements and we try to add a third element.
2015-05-21 13:00:04 +00:00
dmgawel
e30c6d131f Introduction vector example elements counting fix
Earlier created vector `["Hello", "world"]` has two elements and we try to add a third element.
2015-05-21 14:30:32 +02:00
bors
7bd3bbd78e Auto merge of #25552 - GuillaumeGomez:left-hand-error, r=pnkfelix
Part of #24407.
2015-05-21 10:00:04 +00:00
bors
d3543099d6 Auto merge of #25671 - Manishearth:rollup, r=Manishearth
- Successful merges: #25648, #25659, #25661, #25665
- Failed merges:
2015-05-21 08:19:17 +00:00
Manish Goregaokar
06d343b691 Rollup merge of #25665 - OlegTsyba:fix_documentation, r=Gankro
fix a small typo in the official tutorial. "coerce" instead of "coerece"
r? @steveklabnik
2015-05-21 13:38:26 +05:30
Manish Goregaokar
1fb2102498 Rollup merge of #25661 - Stebalien:macro, r=Gankro
They don't have to be followed by anything.
2015-05-21 13:38:26 +05:30
Manish Goregaokar
8007eada79 Rollup merge of #25659 - tshepang:improve-rendering, r=steveklabnik 2015-05-21 13:38:26 +05:30
Manish Goregaokar
02bce96e7b Rollup merge of #25648 - semarie:head-cut, r=luqmana
the "-c" option of head isn't a posix option, and it isn't supported
under openbsd.

prefer the use of cut -c 1-8 (which is posix) to extract the first 8
chars.

r? @alexcrichton
2015-05-21 13:38:26 +05:30
bors
4423748eb8 Auto merge of #25656 - tshepang:spell-em-out, r=brson 2015-05-21 05:37:01 +00:00
bors
d7e4d6351e Auto merge of #25644 - iven:fix_doc_warning, r=steveklabnik
The syntax with tailing semicolon is deprecated and the compiler will
complain about it.

r? @steveklabnik
2015-05-21 04:02:10 +00:00
bors
00b89831a9 Auto merge of #25631 - taiyaeisforks:master, r=steveklabnik
Saw one, decided to fix a few more :) Had to Google supercede because it looked funny, turns out it's a really common misspelling!
2015-05-21 02:26:46 +00:00
bors
9ee4eadb6f Auto merge of #25612 - petrochenkov:lintabs, r=@alexcrichton
Reported here https://github.com/rust-lang/rust/pull/25441#issuecomment-103513930
2015-05-21 00:52:27 +00:00
OlegTsyba
c5c508621d Fix the typo in The Rust Programming Language book, 5.18. Strings 2015-05-21 01:40:23 +03:00
bors
c575885e25 Auto merge of #25625 - bluss:doc-slice-order, r=Gankro
collections: Reorder slice methods to improve API docs

We have an evolutionary history whose traces are still visible in the
slice docs today.

Some heuristics:

* Group method and method_mut together
* Group method and method_by together
* Group by use case, here we have roughly:

  Basic interrogators (len)
  Mutation (swap)
  Iterators (iter)
  Segmentation (split)
  Searching (contains)
  Permutations (permutations)
  Misc (clone_from_slice)
2015-05-20 22:16:54 +00:00
Guillaume Gomez
db9b435749 Typo fix on E0067 2015-05-20 23:46:37 +02:00
Steven Allen
74fadfaeea Change "must" to "may only" in macro future proofing rules.
They don't have to be followed by anything.
2015-05-20 17:19:57 -04:00
Tshepang Lekhonkhobe
b55f0497db doc: that did not render well, so make it fit in one line 2015-05-20 23:09:49 +02:00
bors
82dc34a762 Auto merge of #25652 - arielb1:free-self, r=nikomatsakis
This is needed because `Self` can be substituted to a type with
lifetime parameters.

Fixes #24308
Fixes #25071
Fixes #25259
Fixes #25279
2015-05-20 20:42:22 +00:00
Tshepang Lekhonkhobe
edb21189e2 doc: 'reader' and 'writer' are nicer to read than 'r' and 'w' 2015-05-20 22:02:46 +02:00
Ariel Ben-Yehuda
7b1e8446d1 Substitute free lifetimes when Self is used within a method body
This is needed because `Self` can be substituted to a type with
lifetime parameters.

Fixes #24308
Fixes #25071
Fixes #25259
Fixes #25279
2015-05-20 21:23:41 +03:00
bors
d7185dcff1 Auto merge of #25571 - hirschenberger:master, r=nrc
It is hard to find the actual unstable feature which caused the error when using a list of stable and unstable features as the span marks the whole line

```
src/k8055.rs:22:1: 22:64 error: unstable feature
src/k8055.rs:22 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

This PR spawns an error for each unstable feature in the list:

```
est.rs:1:12: 1:26 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                     ^~~~~~~~~~~~~~
test.rs:1:28: 1:41 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                     ^~~~~~~~~~~~~
test.rs:1:43: 1:47 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                    ^~~~
test.rs:1:49: 1:56 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                          ^~~~~~~
test.rs:1:58: 1:62 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                                   ^~~~
```
2015-05-20 18:08:40 +00:00
Guillaume Gomez
c795406e19 Add error explanation for E0070 2015-05-20 18:53:02 +02:00
bors
cfceecafc6 Auto merge of #25390 - eddyb:typeck-pub, r=nrc
Needed for driving parts of type-checking manually.
2015-05-20 15:32:58 +00:00
bors
cec980a1a7 Auto merge of #25645 - luqmana:lnr, r=eddyb
This micro-optimization actually led to generating broken IR in certain cases.

Fixes #18845.
Fixes #25497.
2015-05-20 13:58:10 +00:00
bors
bacd8bc4b7 Auto merge of #25615 - petrochenkov:issue25542, r=alexcrichton
Closes https://github.com/rust-lang/rust/issues/25542

r? @alexcrichton
2015-05-20 12:22:34 +00:00
Sébastien Marie
0cac79181b use posix command to extract first 8 chars
the "-c" option of head isn't a posix option, and it isn't supported
under openbsd.

prefer the use of cut -c 1-8 (which is posix) to extract the first 8
chars.
2015-05-20 13:54:14 +02:00
bors
541fe5faf8 Auto merge of #25610 - mbrubeck:bufread-docs, r=alexcrichton
r? @steveklabnik
2015-05-20 10:47:44 +00:00
Ulrik Sverdrup
77dcaa5c58 collections: Reorder slice methods to improve API docs
We have an evolutionary history whose traces are still visible in the
slice docs today.

Some heuristics:

* Group method and method_mut together
* Group method and method_by together
* Group by use case, here we have roughly:

  Basic interrogators (len)
  Mutation (swap)
  Iterators (iter)
  Segmentation (split)
  Searching (contains)
  Permutations (permutations)
  Misc (clone_from_slice)
2015-05-20 12:27:09 +02:00
petrochenkov
7b1916d253 Fix panic in lint for out of range literals 2015-05-20 13:03:18 +03:00
bors
749cb1931f Auto merge of #25596 - Ms2ger:rbml-docs, r=alexcrichton
This leads to more idiomatic code in the callers.
2015-05-20 09:13:28 +00:00
Luqman Aden
54dbd0baad librustc_trans: Remove misoptimization in treating derefs of Box as rvalues. 2015-05-20 05:07:27 -04:00
Iven Hsu
2ca3dfd4ac
trpl: Remove tailing semicolon of an inner attribute
The syntax with tailing semicolon is deprecated and the compiler will
complain about it.
2015-05-20 16:55:38 +08:00
bors
6d718f236d Auto merge of #25595 - dotdash:issue25549, r=eddyb
When taking the address of an unsized field we generate a rvalue datum
for the field and then convert it to an lvalue datum. At that point,
cleanup is scheduled for the field, leading to multiple drop calls.

The problem is that we generate an rvalue datum for the field, since the
pointer does not own the data and there's already cleanup scheduled
elsewhere by the true owner. Instead, an lvalue datum must be created.

Thanks to @eddyb for identifying the underlying cause and suggesting the
correct fix.

Fixes #25549.
2015-05-20 07:38:45 +00:00
bors
720735b943 Auto merge of #25588 - bluss:doc-string-from, r=alexcrichton
Use stable code in doc examples (libcollections)

Main task is to change from String::from_str to String::from in examples for String
(the latter constructor is stable). While I'm at it, also remove redundant feature flags,
fix some other instances of unstable code in examples (in examples for stable
methods), and remove some use of usize in examples too.
2015-05-20 06:03:58 +00:00
bors
f6b446f4a9 Auto merge of #25624 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #25583, #25585, #25602, #25604, #25607, #25611, #25614, #25620
- Failed merges:
2015-05-20 04:28:47 +00:00
Steve Klabnik
395d01cf64 Fix for https://github.com/rust-lang/rust/pull/25583 2015-05-19 23:22:28 -04:00
Steve Klabnik
55da4c6975 Small fix for https://github.com/rust-lang/rust/pull/25611 2015-05-19 21:27:01 -04:00
Austin Hellyer
31026c846e Fix a few typos in the releases 2015-05-19 17:34:14 -07:00
bors
43cf733bfa Auto merge of #25350 - alexcrichton:msvc, r=brson
Special thanks to @retep998 for the [excellent writeup](https://github.com/rust-lang/rfcs/issues/1061) of tasks to be done and @ricky26 for initially blazing the trail here!

# MSVC Support

This goal of this series of commits is to add MSVC support to the Rust compiler
and build system, allowing it more easily interoperate with Visual Studio
installations and native libraries compiled outside of MinGW.

The tl;dr; of this change is that there is a new target of the compiler,
`x86_64-pc-windows-msvc`, which will not interact with the MinGW toolchain at
all and will instead use `link.exe` to assemble output artifacts.

## Why try to use MSVC?

With today's Rust distribution, when you install a compiler on Windows you also
install `gcc.exe` and a number of supporting libraries by default (this can be
opted out of). This allows installations to remain independent of MinGW
installations, but it still generally requires native code to be linked with
MinGW instead of MSVC. Some more background can also be found in #1768 about the
incompatibilities between MinGW and MSVC.

Overall the current installation strategy is quite nice so long as you don't
interact with native code, but once you do the usage of a MinGW-based `gcc.exe`
starts to get quite painful.

Relying on a nonstandard Windows toolchain has also been a long-standing "code
smell" of Rust and has been slated for remedy for quite some time now. Using a
standard toolchain is a great motivational factor for improving the
interoperability of Rust code with the native system.

## What does it mean to use MSVC?

"Using MSVC" can be a bit of a nebulous concept, but this PR defines it as:

* The build system for Rust will build as much code as possible with the MSVC
  compiler, `cl.exe`.
* The build system will use native MSVC tools for managing archives.
* The compiler will link all output with `link.exe` instead of `gcc.exe`.

None of these are currently implemented today, but all are required for the
compiler to fluently interoperate with MSVC.

## How does this all work?

At the highest level, this PR adds a new target triple to the Rust compiler:

    x86_64-pc-windows-msvc

All logic for using MSVC or not is scoped within this triple and code can
conditionally build for MSVC or MinGW via:

    #[cfg(target_env = "msvc")]

It is expected that auto builders will be set up for MSVC-based compiles in
addition to the existing MinGW-based compiles, and we will likely soon start
shipping MSVC nightlies where `x86_64-pc-windows-msvc` is the host target triple
of the compiler.

# Summary of changes

Here I'll explain at a high level what many of the changes made were targeted
at, but many more details can be found in the commits themselves. Many thanks to
@retep998 for the excellent writeup in rust-lang/rfcs#1061 and @rick26 for a lot
of the initial proof-of-concept work!

## Build system changes

As is probably expected, a large chunk of this PR is changes to Rust's build
system to build with MSVC. At a high level **it is an explicit non goal** to
enable building outside of a MinGW shell, instead all Makefile infrastructure we
have today is retrofitted with support to use MSVC instead of the standard MSVC
toolchain. Some of the high-level changes are:

* The configure script now detects when MSVC is being targeted and adds a number
  of additional requirements about the build environment:
  * The `--msvc-root` option must be specified or `cl.exe` must be in PATH to
    discover where MSVC is installed. The compiler in use is also required to
    target x86_64.
  * Once the MSVC root is known, the INCLUDE/LIB environment variables are
    scraped so they can be reexported by the build system.
  * CMake is required to build LLVM with MSVC (and LLVM is also configured with
    CMake instead of the normal configure script).
  * jemalloc is currently unconditionally disabled for MSVC targets as jemalloc
    isn't a hard requirement and I don't know how to build it with MSVC.
* Invocations of a C and/or C++ compiler are now abstracted behind macros to
  appropriately call the underlying compiler with the correct format of
  arguments, for example there is now a macro for "assemble an archive from
  objects" instead of hard-coded invocations of `$(AR) crus liboutput.a ...`
* The output filenames for standard libraries such as morestack/compiler-rt are
  now "more correct" on windows as they are shipped as `foo.lib` instead of
  `libfoo.a`.
* Rust targets can now depend on native tools provided by LLVM, and as you'll
  see in the commits the entire MSVC target depends on `llvm-ar.exe`.
* Support for custom arbitrary makefile dependencies of Rust targets has been
  added. The MSVC target for `rustc_llvm` currently requires a custom `.DEF`
  file to be passed to the linker to get further linkages to complete.

## Compiler changes

The modifications made to the compiler have so far largely been minor tweaks
here and there, mostly just adding a layer of abstraction over whether MSVC or a
GNU-like linker is being used. At a high-level these changes are:

* The section name for metadata storage in dynamic libraries is called `.rustc`
  for MSVC-based platorms as section names cannot contain more than 8
  characters.
* The implementation of `rustc_back::Archive` was refactored, but the
  functionality has remained the same.
* Targets can now specify the default `ar` utility to use, and for MSVC this
  defaults to `llvm-ar.exe`
* The building of the linker command in `rustc_trans:🔙:link` has been
  abstracted behind a trait for the same code path to be used between GNU and
  MSVC linkers.

## Standard library changes

Only a few small changes were required to the stadnard library itself, and only
for minor differences between the C runtime of msvcrt.dll and MinGW's libc.a

* Some function names for floating point functions have leading underscores, and
  some are not present at all.
* Linkage to the `advapi32` library for crypto-related functions is now
  explicit.
* Some small bits of C code here and there were fixed for compatibility with
  MSVC's cl.exe compiler.

# Future Work

This commit is not yet a 100% complete port to using MSVC as there are still
some key components missing as well as some unimplemented optimizations. This PR
is already getting large enough that I wanted to draw the line here, but here's
a list of what is not implemented in this PR, on purpose:

## Unwinding

The revision of our LLVM submodule [does not seem to implement][llvm] does not
support lowering SEH exception handling on the Windows MSVC targets, so
unwinding support is not currently implemented for the standard library (it's
lowered to an abort).

[llvm]: https://github.com/rust-lang/llvm/blob/rust-llvm-2015-02-19/lib/CodeGen/Passes.cpp#L454-L461

It looks like, however, that upstream LLVM has quite a bit more support for SEH
unwinding and landing pads than the current revision we have, so adding support
will likely just involve updating LLVM and then adding some shims of our own
here and there.

## dllimport and dllexport

An interesting part of Windows which MSVC forces our hand on (and apparently
MinGW didn't) is the usage of `dllimport` and `dllexport` attributes in LLVM IR
as well as native dependencies (in C these correspond to
`__declspec(dllimport)`).

Whenever a dynamic library is built by MSVC it must have its public interface
specified by functions tagged with `dllexport` or otherwise they're not
available to be linked against. This poses a few problems for the compiler, some
of which are somewhat fundamental, but this commit alters the compiler to attach
the `dllexport` attribute to all LLVM functions that are reachable (e.g. they're
already tagged with external linkage). This is suboptimal for a few reasons:

* If an object file will never be included in a dynamic library, there's no need
  to attach the dllexport attribute. Most object files in Rust are not destined
  to become part of a dll as binaries are statically linked by default.
* If the compiler is emitting both an rlib and a dylib, the same source object
  file is currently used but with MSVC this may be less feasible. The compiler
  may be able to get around this, but it may involve some invasive changes to
  deal with this.

The flipside of this situation is that whenever you link to a dll and you import
a function from it, the import should be tagged with `dllimport`. At this time,
however, the compiler does not emit `dllimport` for any declarations other than
constants (where it is required), which is again suboptimal for even more
reasons!

* Calling a function imported from another dll without using `dllimport` causes
  the linker/compiler to have extra overhead (one `jmp` instruction on x86) when
  calling the function.
* The same object file may be used in different circumstances, so a function may
  be imported from a dll if the object is linked into a dll, but it may be
  just linked against if linked into an rlib.
* The compiler has no knowledge about whether native functions should be tagged
  dllimport or not.

For now the compiler takes the perf hit (I do not have any numbers to this
effect) by marking very little as `dllimport` and praying the linker will take
care of everything. Fixing this problem will likely require adding a few
attributes to Rust itself (feature gated at the start) and then strongly
recommending static linkage on Windows! This may also involve shipping a
statically linked compiler on Windows instead of a dynamically linked compiler,
but these sorts of changes are pretty invasive and aren't part of this PR.

## CI integration

Thankfully we don't need to set up a new snapshot bot for the changes made here as our snapshots are freestanding already, we should be able to use the same snapshot to bootstrap both MinGW and MSVC compilers (once a new snapshot is made from these changes).

I plan on setting up a new suite of auto bots which are testing MSVC configurations for now as well, for now they'll just be bootstrapping and not running tests, but once unwinding is implemented they'll start running all tests as well and we'll eventually start gating on them as well.

---

I'd love as many eyes on this as we've got as this was one of my first interactions with MSVC and Visual Studio, so there may be glaring holes that I'm missing here and there!

cc @retep998, @ricky26, @vadimcn, @klutzy 

r? @brson
2015-05-20 00:31:55 +00:00
Steve Klabnik
ed3c64451c Rollup merge of #25620 - brson:betavers, r=alexcrichton 2015-05-19 18:38:54 -04:00
Steve Klabnik
51a0c6a6fa Rollup merge of #25614 - parir:patch-2, r=alexcrichton
r? @steveklabnik
2015-05-19 18:38:54 -04:00
Steve Klabnik
dd1c68e6a1 Rollup merge of #25611 - parir:patch-1, r=steveklabnik
r? @steveklabnik
2015-05-19 18:38:54 -04:00
Steve Klabnik
7f74212906 Rollup merge of #25607 - peferron:doc-macros-assert-fix, r=steveklabnik
"Truth passes, success `panic!`s" seems to be a typo. The closest fix would be something like "Success passes, failure `panic!`s" but to me a "comparison failure" suggests that we couldn't compare the two values at all, not that we could successfully compare them and that the result was non-equality. So I opted to rewrite the paragraph a bit. If there's a better alternative please let me know.

r? @steveklabnik
2015-05-19 18:38:54 -04:00
Steve Klabnik
1d961fde2d Rollup merge of #25604 - skeuomorf:docs-lifetime, r=steveklabnik
r? @steveklabnik
2015-05-19 18:38:53 -04:00
Steve Klabnik
6fc93b85bc Rollup merge of #25602 - parkr:patch-1, r=alexcrichton
Padding and alignment are often not implemented by types and can cause confusion in the user.  Per discussion with @alexcrichton, here is my PR.

/cc https://github.com/rust-lang/time/issues/98
2015-05-19 18:38:53 -04:00
Steve Klabnik
1bcfe5e5ad Rollup merge of #25585 - sferik:change-default-gender, r=steveklabnik
The paper from which this example was taken made the mistake of assuming that all five philosophers are men. This it is a hypothetical example—there are no actual philosophers eating 🍝—so there is no good reason to make this assumption. Since women make up about half of the human population, all things being equal, women should represent about half of the philosophers. However, because this mistake has stood since 1985, I have changed *all* of the pronouns to be female, to make up for lost time. If someone would like to revert this patch or switch to neutral pronouns after 30 years, feel free to set your alarm clock for 2045.

r? @steveklabnik, since this is a documentation change and was created after reading http://words.steveklabnik.com/ouroboros, where I noticed this mistake.
2015-05-19 18:38:53 -04:00