]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agodoc: miscellaneous improvements to std::path::Path examples
Tshepang Lekhonkhobe [Thu, 21 May 2015 01:29:46 +0000 (03:29 +0200)]
doc: miscellaneous improvements to std::path::Path examples

9 years agoAuto merge of #25571 - hirschenberger:master, r=nrc
bors [Wed, 20 May 2015 18:08:40 +0000 (18:08 +0000)]
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)]
                                                                   ^~~~
```

9 years agoAuto merge of #25390 - eddyb:typeck-pub, r=nrc
bors [Wed, 20 May 2015 15:32:58 +0000 (15:32 +0000)]
Auto merge of #25390 - eddyb:typeck-pub, r=nrc

Needed for driving parts of type-checking manually.

9 years agoAuto merge of #25645 - luqmana:lnr, r=eddyb
bors [Wed, 20 May 2015 13:58:10 +0000 (13:58 +0000)]
Auto merge of #25645 - luqmana:lnr, r=eddyb

This micro-optimization actually led to generating broken IR in certain cases.

Fixes #18845.
Fixes #25497.

9 years agoAuto merge of #25615 - petrochenkov:issue25542, r=alexcrichton
bors [Wed, 20 May 2015 12:22:34 +0000 (12:22 +0000)]
Auto merge of #25615 - petrochenkov:issue25542, r=alexcrichton

Closes https://github.com/rust-lang/rust/issues/25542

r? @alexcrichton

9 years agoAuto merge of #25610 - mbrubeck:bufread-docs, r=alexcrichton
bors [Wed, 20 May 2015 10:47:44 +0000 (10:47 +0000)]
Auto merge of #25610 - mbrubeck:bufread-docs, r=alexcrichton

r? @steveklabnik

9 years agoAuto merge of #25596 - Ms2ger:rbml-docs, r=alexcrichton
bors [Wed, 20 May 2015 09:13:28 +0000 (09:13 +0000)]
Auto merge of #25596 - Ms2ger:rbml-docs, r=alexcrichton

This leads to more idiomatic code in the callers.

9 years agolibrustc_trans: Remove misoptimization in treating derefs of Box as rvalues.
Luqman Aden [Wed, 20 May 2015 09:06:38 +0000 (05:06 -0400)]
librustc_trans: Remove misoptimization in treating derefs of Box as rvalues.

9 years agoAuto merge of #25595 - dotdash:issue25549, r=eddyb
bors [Wed, 20 May 2015 07:38:45 +0000 (07:38 +0000)]
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.

9 years agoAuto merge of #25588 - bluss:doc-string-from, r=alexcrichton
bors [Wed, 20 May 2015 06:03:58 +0000 (06:03 +0000)]
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.

9 years agoAuto merge of #25624 - steveklabnik:rollup, r=steveklabnik
bors [Wed, 20 May 2015 04:28:47 +0000 (04:28 +0000)]
Auto merge of #25624 - steveklabnik:rollup, r=steveklabnik

- Successful merges: #25583, #25585, #25602, #25604, #25607, #25611, #25614, #25620
- Failed merges:

9 years agoFix for https://github.com/rust-lang/rust/pull/25583
Steve Klabnik [Wed, 20 May 2015 03:22:28 +0000 (23:22 -0400)]
Fix for https://github.com/rust-lang/rust/pull/25583

9 years agoSmall fix for https://github.com/rust-lang/rust/pull/25611
Steve Klabnik [Wed, 20 May 2015 01:26:21 +0000 (21:26 -0400)]
Small fix for https://github.com/rust-lang/rust/pull/25611

9 years agoAuto merge of #25350 - alexcrichton:msvc, r=brson
bors [Wed, 20 May 2015 00:31:55 +0000 (00:31 +0000)]
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::back::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

9 years agoRollup merge of #25620 - brson:betavers, r=alexcrichton
Steve Klabnik [Tue, 19 May 2015 22:38:54 +0000 (18:38 -0400)]
Rollup merge of #25620 - brson:betavers, r=alexcrichton

9 years agoRollup merge of #25614 - parir:patch-2, r=alexcrichton
Steve Klabnik [Tue, 19 May 2015 22:38:54 +0000 (18:38 -0400)]
Rollup merge of #25614 - parir:patch-2, r=alexcrichton

r? @steveklabnik

9 years agoRollup merge of #25611 - parir:patch-1, r=steveklabnik
Steve Klabnik [Tue, 19 May 2015 22:38:54 +0000 (18:38 -0400)]
Rollup merge of #25611 - parir:patch-1, r=steveklabnik

r? @steveklabnik

9 years agoRollup merge of #25607 - peferron:doc-macros-assert-fix, r=steveklabnik
Steve Klabnik [Tue, 19 May 2015 22:38:54 +0000 (18:38 -0400)]
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

9 years agoRollup merge of #25604 - skeuomorf:docs-lifetime, r=steveklabnik
Steve Klabnik [Tue, 19 May 2015 22:38:53 +0000 (18:38 -0400)]
Rollup merge of #25604 - skeuomorf:docs-lifetime, r=steveklabnik

r? @steveklabnik

9 years agoRollup merge of #25602 - parkr:patch-1, r=alexcrichton
Steve Klabnik [Tue, 19 May 2015 22:38:53 +0000 (18:38 -0400)]
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

9 years agoRollup merge of #25585 - sferik:change-default-gender, r=steveklabnik
Steve Klabnik [Tue, 19 May 2015 22:38:53 +0000 (18:38 -0400)]
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 :spaghetti:—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.

9 years agoRollup merge of #25583 - steveklabnik:gh25517, r=alexcrichton
Steve Klabnik [Tue, 19 May 2015 22:38:53 +0000 (18:38 -0400)]
Rollup merge of #25583 - steveklabnik:gh25517, r=alexcrichton

Fixes #25517

9 years agoAuto merge of #24333 - arielb1:implement-rfc401, r=nrc
bors [Tue, 19 May 2015 20:56:51 +0000 (20:56 +0000)]
Auto merge of #24333 - arielb1:implement-rfc401, r=nrc

9 years agoChange default gender in the dining philosophers project
Erik Michaels-Ober [Mon, 18 May 2015 21:48:09 +0000 (23:48 +0200)]
Change default gender in the dining philosophers project

The paper from which this example was taken made the mistake of assuming
that all five philosophers are men. This is a hypothetical
example--there are no actual philosophers eating spaghetti--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.

9 years agoFix rebase conflicts
Ariel Ben-Yehuda [Tue, 19 May 2015 19:54:44 +0000 (22:54 +0300)]
Fix rebase conflicts

9 years agoAuto merge of #25495 - alexcrichton:process-pid, r=aturon
bors [Tue, 19 May 2015 19:20:20 +0000 (19:20 +0000)]
Auto merge of #25495 - alexcrichton:process-pid, r=aturon

This commits adds a method to the `std::process` module to get the process
identifier of the child as a `u32`. On Windows the underlying identifier is
already a `u32`, and on Unix the type is typically defined as `c_int` (`i32` for
almost all our supported platforms), but the actually pid is normally a small
positive number.

Eventually we may add functions to load information about a process based on its
identifier or the ability to terminate a process based on its identifier, but
for now this function should enable this sort of functionality to exist outside
the standard library.

9 years agomk: Report the prerelease version on beta again. Fixes #25618
Brian Anderson [Tue, 19 May 2015 18:34:34 +0000 (11:34 -0700)]
mk: Report the prerelease version on beta again. Fixes #25618

9 years agomk: Update `make dist` for MSVC targets
Alex Crichton [Wed, 13 May 2015 17:03:00 +0000 (10:03 -0700)]
mk: Update `make dist` for MSVC targets

This commit updates the `dist` target for MSVC to not build the mingw components
and to also ensure that the `llvm-ar.exe` binary is ferried along into the right
location for installs.

9 years agostd: Don't require rust_try as an exported symbol
Alex Crichton [Tue, 12 May 2015 22:52:33 +0000 (15:52 -0700)]
std: Don't require rust_try as an exported symbol

This commit adds a small non-generic non-inlineable shim function to
`rt::unwind::try` which the compiler can take care of for managing the exported
symbol instead of having to edit `src/rt/rust_try.ll`

9 years agorustc_trans: Apply dllexport attributes for MSVC
Alex Crichton [Tue, 12 May 2015 21:46:19 +0000 (14:46 -0700)]
rustc_trans: Apply dllexport attributes for MSVC

This commit modifies the compiler to emit `dllexport` for all reachable
functions and data on MSVC targets, regardless of whether a dynamic library is
being created or not. More details can be found in the commit itself.

9 years agostd: Mark rust_get_num_cpus as dllexport
Alex Crichton [Tue, 12 May 2015 20:29:09 +0000 (13:29 -0700)]
std: Mark rust_get_num_cpus as dllexport

This function is imported across the DLL boundary by the libtest dynamic
library, so it has to be marked as dllexport somehow, and for now this is done
with an attribute on the function specifically.

9 years agostd: Implement aborting stubs for MSVC unwinding
Alex Crichton [Tue, 12 May 2015 04:09:07 +0000 (21:09 -0700)]
std: Implement aborting stubs for MSVC unwinding

At this time unwinding support is not implemented for MSVC as
`libgcc_s_seh-1.dll` is not available by default (and this is used on MinGW),
but this should be investigated soon. For now this change is just aimed at
getting the compiler far enough to bootstrap everything instead of successfully
running tests.

This commit refactors the `std::rt::unwind` module a bit to prepare for SEH
support eventually by moving all GCC-specific functionality to its own submodule
and defining the interface needed.

9 years agorustc_llvm: Don't export constants across dlls
Alex Crichton [Tue, 12 May 2015 04:07:38 +0000 (21:07 -0700)]
rustc_llvm: Don't export constants across dlls

For imports of constants across DLLs to work on Windows it *requires* that the
import be marked with `dllimport` (unlike functions where the marker is
optional, but strongly recommended). This currently isn't working for importing
FFI constants across boundaries, however, so the one constant exported from
`rustc_llvm.dll` is now a function to be called instead.

9 years agomk: Generate a .def file for rustc_llvm on MSVC
Alex Crichton [Mon, 11 May 2015 22:49:30 +0000 (15:49 -0700)]
mk: Generate a .def file for rustc_llvm on MSVC

Windows needs explicit exports of functions from DLLs but LLVM does not mention
any of its symbols as being export-able from a DLL. The compiler, however,
relies on being able to use LLVM symbols across DLL boundaries so we need to
force many of LLVM's symbols to be exported from `rustc_llvm.dll`. This commit
adds support for generation of a `rustc_llvm.def` file which is passed along to
the linker when generating `rustc_llvm.dll` which should keep all these symbols
exportable and usable.

9 years agorustc_trans: Tidy up some style and line lengths
Alex Crichton [Mon, 11 May 2015 21:58:58 +0000 (14:58 -0700)]
rustc_trans: Tidy up some style and line lengths

Match the surrounding style in the rest of the `rustc_trans::trans` module.

9 years agorustc_trans: Add MSVC linker support
Alex Crichton [Mon, 11 May 2015 21:57:21 +0000 (14:57 -0700)]
rustc_trans: Add MSVC linker support

This commit adds an implementation of the `Linker` trait which is used to drive
MSVC's `link.exe` support. Nothing too surprising here as it's mostly just
filling out the necessary tidbits here and there.

9 years agorustc_trans: Clean up some style in back::link
Alex Crichton [Mon, 11 May 2015 21:56:49 +0000 (14:56 -0700)]
rustc_trans: Clean up some style in back::link

* Add some logging here and there
* Move some `err` + `abort_if_errors` to just using `fatal`
* Clean up some line-lengths

9 years agolibc: Add necessary libraries for MSVC
Alex Crichton [Mon, 11 May 2015 21:47:59 +0000 (14:47 -0700)]
libc: Add necessary libraries for MSVC

These libs seem to be required by the standard library at least to link
successfully!

9 years agomklldeps: Don't link stdc++/c++ on MSVC
Alex Crichton [Mon, 11 May 2015 21:47:04 +0000 (14:47 -0700)]
mklldeps: Don't link stdc++/c++ on MSVC

These libraries don't exist! The linker for MSVC is highly likely to not pass
`/NODEFAULTLIB` in which case the right standard library will automatically be
selected.

9 years agorustc_back: Tweak the MSVC target spec
Alex Crichton [Mon, 11 May 2015 21:41:27 +0000 (14:41 -0700)]
rustc_back: Tweak the MSVC target spec

This change primarily changes the default ar utility used by MSVC-targeting
compilers as `llvm-ar`, adding comments along the way as to why.

9 years agorustc_back: Remove unneeded explicit variable
Alex Crichton [Mon, 11 May 2015 21:34:41 +0000 (14:34 -0700)]
rustc_back: Remove unneeded explicit variable

This value is the default anyway

9 years agorustc_back: Refactor Archive to better express intent
Alex Crichton [Mon, 11 May 2015 21:32:53 +0000 (14:32 -0700)]
rustc_back: Refactor Archive to better express intent

This commit was initially written to target either `ar` or `lib.exe` for MSVC,
but it ended up not needing `lib.exe` support after all. I would personally like
to refactor this to one day not invoke processes at all (but rather use the
`llvm-ar.cpp` file in LLVM as alibrary) so I chose to preserve this refactoring
to allow it to be easily done in the future.

9 years agorustc: Shorten MSVC metadata section name
Alex Crichton [Mon, 11 May 2015 21:31:06 +0000 (14:31 -0700)]
rustc: Shorten MSVC metadata section name

It looks like section names in objects generated by `link.exe` are limited to at
most 8 characters in length, so shorten `.note.rustc` to just `.rustc`

9 years agomk: Add the ability to depend on native LLVM tools
Alex Crichton [Mon, 11 May 2015 21:14:11 +0000 (14:14 -0700)]
mk: Add the ability to depend on native LLVM tools

The compiler will require that `llvm-ar.exe` be available for MSVC-targeting
builds (more comments on this soon), so this commit adds support for targets to
depend on LLVM tools. The `core` library for MSVC depends on `llvm-ar.exe` which
will be copied into place for the target before the compiler starts to run.

Note that these targets all depend on `llvm-config.exe` to ensure that they're
built before they're attempted to be copied.

9 years agomk: Fix MSVC build for rustllvm.lib
Alex Crichton [Mon, 11 May 2015 21:11:37 +0000 (14:11 -0700)]
mk: Fix MSVC build for rustllvm.lib

This commit updates the rustllvm.mk file with the necessary flags and such to
build rustllvm.lib with cl.exe instead of gcc. Some comments can be found in the
commit itself.

9 years agomk: Fix building compiler-rt on MSVC
Alex Crichton [Mon, 11 May 2015 21:09:25 +0000 (14:09 -0700)]
mk: Fix building compiler-rt on MSVC

It looks like compiler-rt has a cmake build sytem inside its source, but I have
been unable to figure out how to use it and actually build the right library.
For now this commit hard-wires MSVC-targeting builds of libcompiler-rt to
continue using `make` as the primary bulid system, but some frobbing of the
flags are necessary to ensure that the right compiler is used.

9 years agomk: Don't add cross prefixes for MSVC
Alex Crichton [Mon, 11 May 2015 21:08:46 +0000 (14:08 -0700)]
mk: Don't add cross prefixes for MSVC

Currently the MSVC compilers don't have any cross prefixes and we're only able
to make an MSVC compiler with a cross compile, so just avoid this logic on msvc
for now.

9 years agomk: Add build system support for cl.exe
Alex Crichton [Mon, 11 May 2015 21:07:42 +0000 (14:07 -0700)]
mk: Add build system support for cl.exe

We have a number of support C/C++ files in Rust that we link into the standard
library and other various locations, and these all need to be built with cl.exe
instead of gcc.exe when targeting MSVC. This commit adds helper macros for this
functionality to use different sets of programs/flags/invocations on MSVC than
on GNU-like platforms.

9 years agomk: Enable building LLVM targeting MSVC
Alex Crichton [Mon, 11 May 2015 21:03:45 +0000 (14:03 -0700)]
mk: Enable building LLVM targeting MSVC

This commit modifies the makefiles to enable building LLVM with cmake and Visual
Studio to generate an LLVM that targets MSVC. Rust's configure script requires
cmake to be installed when targeting MSVC and will configure LLVM with cmake
instead of the normal `./configure` script LLVM provides. The build will then
run cmake to execute the build instead of the normal `make`.

Currently `make clean-llvm` isn't supported on MSVC as I can't figure out how to
run a "clean" target for the Visual Studio files.

9 years agoconfigure: Start adding MSVC support
Alex Crichton [Mon, 11 May 2015 20:59:51 +0000 (13:59 -0700)]
configure: Start adding MSVC support

This commit starts to add MSVC support to the ./configure script to enable the
build system to detect and build an MSVC target with the cl.exe compiler and
toolchain. The primary change here is a large sanity check when an MSVC target
is requested (and currently only `x86_64-pc-windows-msvc` is recognized).

When building an MSVC target, the configure script either requires the
`--msvc-root` argument or for `cl.exe` to be in `PATH`. It also requires that if
in the path `cl.exe` is the 64-bit version of the compiler.

Once detected the configure script will run the `vcvarsall.bat` script provided
by Visual Studio to learn about the `INCLUDE` and `LIB` variables needed by the
`cl.exe` compiler to run (the default include/lib paths for the
compiler/linker). These variables are then reexported when running `make` to
ensure that our own compiles are running the same toolchain.

The purpose of this detection and environment variable scraping is to avoid
requiring the build itself to be run inside of a `cmd.exe` shell but rather
allow it to run in the currently expected MinGW/MSYS shell.

9 years agoAdd example code and cross-link to BufReader docs
Matt Brubeck [Tue, 19 May 2015 16:49:04 +0000 (09:49 -0700)]
Add example code and cross-link to BufReader docs

9 years agoFix test run-pass-fulldeps\issue-15149.rs on Windows
petrochenkov [Tue, 19 May 2015 17:37:17 +0000 (20:37 +0300)]
Fix test run-pass-fulldeps\issue-15149.rs on Windows

9 years agodoc: fix a broken link
parir [Tue, 19 May 2015 17:36:10 +0000 (19:36 +0200)]
doc: fix a broken link

9 years agomk: Fix native LLVM deps for cross-host builds
Alex Crichton [Mon, 11 May 2015 19:30:47 +0000 (12:30 -0700)]
mk: Fix native LLVM deps for cross-host builds

We use a script called `mklldeps.py` to run `llvm-config` to generate a list
of LLVM libraries and native dependencies needed by LLVM, but all cross-compiled
LLVM builds were using the *host triple's* `llvm-config` instead of the
*target's* `llvm-config`. This commit alters this to require the right
`llvmdeps.rs` to be generated which will run the correct `llvm-config`.

9 years agomk: Correct names of installed libs on windows
Alex Crichton [Mon, 11 May 2015 19:29:08 +0000 (12:29 -0700)]
mk: Correct names of installed libs on windows

Previously libmorestack.a and libcompiler-rt.a were installed, but link.exe
looks for morestack.lib and compiler-rt.lib by default, so we need to install
these with the correct name

9 years agomk: Remove generation of .d files
Alex Crichton [Mon, 11 May 2015 19:27:26 +0000 (12:27 -0700)]
mk: Remove generation of .d files

Looks like cl.exe doesn't support this and we're also barely using them anyway
as we have very few header files and C code in general.

9 years agort: Clean up to build with cl.exe
Alex Crichton [Mon, 11 May 2015 19:24:56 +0000 (12:24 -0700)]
rt: Clean up to build with cl.exe

* Detect the #define _MSC_VER in addition to __WIN32__
* Don't include valgrind.h for windows
* Remove unused `rust_valgrind_stack_{un,}register` functions
* Add stub definition for `rust_running_on_valgrind` for windows
* Conditionally define `rust_dbg_extern_empty_struct` as empty structures are
  not allowed by cl.exe apparently.

9 years agoReturn the iterator from reader::docs.
Ms2ger [Sun, 17 May 2015 16:14:40 +0000 (18:14 +0200)]
Return the iterator from reader::docs.

9 years agodoc: add missing fences
parir [Tue, 19 May 2015 17:19:42 +0000 (19:19 +0200)]
doc: add missing fences

9 years agoAuto merge of #25605 - Manishearth:rollup, r=Manishearth
bors [Tue, 19 May 2015 16:44:52 +0000 (16:44 +0000)]
Auto merge of #25605 - Manishearth:rollup, r=Manishearth

- Successful merges: #25452, #25512, #25551, #25556, #25562, #25575, #25576, #25580, #25587, #25590, #25591
- Failed merges: #25585

9 years agoFix description of assert!
peferron [Mon, 18 May 2015 20:39:19 +0000 (13:39 -0700)]
Fix description of assert!

9 years agoFix translation of semi-constant if-statements
Ariel Ben-Yehuda [Tue, 19 May 2015 14:38:55 +0000 (17:38 +0300)]
Fix translation of semi-constant if-statements

Thanks @dotdash

9 years agoMake float -> int casts actually work
Ariel Ben-Yehuda [Fri, 15 May 2015 08:44:26 +0000 (11:44 +0300)]
Make float -> int casts actually work

9 years agoAddress review commets
Ariel Ben-Yehuda [Thu, 14 May 2015 12:04:49 +0000 (15:04 +0300)]
Address review commets

I think I didn't run tests properly - my second call to
select_all_obligations_or_error has made 3 tests fail. However, this is
just an error message change - integer fallback never worked with casts.

9 years agoremove todo
Ariel Ben-Yehuda [Wed, 13 May 2015 22:41:28 +0000 (01:41 +0300)]
remove todo

9 years agofix conflicts
Ariel Ben-Yehuda [Wed, 13 May 2015 18:58:26 +0000 (21:58 +0300)]
fix conflicts

9 years agoFix test fallout, and add some rather comprehensive tests.
Ariel Ben-Yehuda [Tue, 5 May 2015 16:39:27 +0000 (19:39 +0300)]
Fix test fallout, and add some rather comprehensive tests.

9 years agoOverhaul cast semantics and make them follow RFC401
Ariel Ben-Yehuda [Tue, 5 May 2015 16:36:47 +0000 (19:36 +0300)]
Overhaul cast semantics and make them follow RFC401

This should hopefully fix all cast-related ICEs once and for all.

I managed to make diagnostics hate me and give me spurious "decoder error"
 - removing $build/tmp/extended-errors seems to fix it.

9 years agoExpose enum discriminant signedness
Ariel Ben-Yehuda [Tue, 5 May 2015 16:34:37 +0000 (19:34 +0300)]
Expose enum discriminant signedness

9 years agoRollup merge of #25591 - rick68:patch-2, r=alexcrichton
Manish Goregaokar [Tue, 19 May 2015 13:17:16 +0000 (18:47 +0530)]
Rollup merge of #25591 - rick68:patch-2, r=alexcrichton

fixed a mistake.

9 years agoRollup merge of #25590 - michaelsproul:enum-struct-diagnostics, r=Manishearth
Manish Goregaokar [Tue, 19 May 2015 13:17:15 +0000 (18:47 +0530)]
Rollup merge of #25590 - michaelsproul:enum-struct-diagnostics, r=Manishearth

Part of #24407.

This covers various errors to do with struct and enum patterns.

9 years agoRollup merge of #25587 - bluss:rustdoc-type-margin, r=alexcrichton
Manish Goregaokar [Tue, 19 May 2015 13:17:15 +0000 (18:47 +0530)]
Rollup merge of #25587 - bluss:rustdoc-type-margin, r=alexcrichton

rustdoc: Fix left margin for type aliases

Fixes #24655

Margin for associated types was applied to type aliases (in return
value) by mistake.

9 years agoRollup merge of #25580 - killercup:trpl/unify-code-blocks, r=steveklabnik
Manish Goregaokar [Tue, 19 May 2015 13:17:15 +0000 (18:47 +0530)]
Rollup merge of #25580 - killercup:trpl/unify-code-blocks, r=steveklabnik

This adds strictly more information to the source files and reduces the need for customized tooling to render the book. (While this should not change the output of _rustbook_, it is very useful when rendering the sources with external tools like Pandoc.)

This only adds the language marker to "first level" code blocks (and not to code blocks in comments inside of code examples).

r? @steveklabnik

9 years agoRollup merge of #25576 - mbrubeck:pathext-doc, r=steveklabnik
Manish Goregaokar [Tue, 19 May 2015 13:17:15 +0000 (18:47 +0530)]
Rollup merge of #25576 - mbrubeck:pathext-doc, r=steveklabnik

This has been a frequently-asked question on IRC, and it isn't obvious where to
look for the fix.  r? @steveklabnik

9 years agoRollup merge of #25575 - clatour:patch-2, r=steveklabnik
Manish Goregaokar [Tue, 19 May 2015 13:17:14 +0000 (18:47 +0530)]
Rollup merge of #25575 - clatour:patch-2, r=steveklabnik

Looks like this was an issue in the source material. I've let the editor know and he has told me he is correcting it there as well.

r? @steveklabnik

9 years agoRollup merge of #25562 - svetlyak40wt:patch-1, r=alexcrichton
Manish Goregaokar [Tue, 19 May 2015 13:17:14 +0000 (18:47 +0530)]
Rollup merge of #25562 - svetlyak40wt:patch-1, r=alexcrichton

That way old versions won't be a subsections of the 1.0.0 release.

9 years agoRollup merge of #25556 - mdinger:patch-1, r=alexcrichton
Manish Goregaokar [Tue, 19 May 2015 13:17:14 +0000 (18:47 +0530)]
Rollup merge of #25556 - mdinger:patch-1, r=alexcrichton

9 years agoRollup merge of #25551 - cllns:add-active-class-to-rustbook-toc, r=alexcrichton
Manish Goregaokar [Tue, 19 May 2015 13:17:14 +0000 (18:47 +0530)]
Rollup merge of #25551 - cllns:add-active-class-to-rustbook-toc, r=alexcrichton

Currently the table of contents for `rustbook` doesn't signify which page you are on.

This PR adds an 'active' class to the link for the current page, and defines the CSS rule for that class to make the link underlined and bold.

Not sure about two things:
1) Is `current_page` is a good name for the function parameter? At first I thought `current_item` would be good, but then in the `walk_item` function, you'd have `item` and `current_item`.

2) For the CSS, is both bold and underline too much? At first I had it just be underlined, but that's also how the links look when they're hovered over.

9 years agoRollup merge of #25512 - peferron:doc-traits-error-fix, r=alexcrichton
Manish Goregaokar [Tue, 19 May 2015 13:17:13 +0000 (18:47 +0530)]
Rollup merge of #25512 - peferron:doc-traits-error-fix, r=alexcrichton

The source code snippet uses `"whatever".as_bytes()` but the compilation error message uses `b"whatever"`. Both should be consistent with each other.

r? @steveklabnik

9 years agoRollup merge of #25452 - jimblandy:master, r=steveklabnik
Manish Goregaokar [Tue, 19 May 2015 13:17:13 +0000 (18:47 +0530)]
Rollup merge of #25452 - jimblandy:master, r=steveklabnik

Minor tweak: the text explaining the Borrow trait talks about slices, but the example immediately following just uses a simple reference; there are no slices involved.

r? @steveklabnik

9 years agoFix lifetimes trpl typo
Mohammed Attia [Tue, 19 May 2015 12:38:54 +0000 (14:38 +0200)]
Fix lifetimes trpl typo

9 years agoDon't call drop when taking the address of unsized fields
Björn Steinbrink [Tue, 19 May 2015 07:50:48 +0000 (09:50 +0200)]
Don't call drop when taking the address of unsized fields

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
Fixes #25515

9 years agofmt.rs: add note about lack of padding support for some types
Parker Moore [Tue, 19 May 2015 12:21:52 +0000 (19:21 +0700)]
fmt.rs: add note about lack of padding support for some types

9 years agoAuto merge of #25550 - sfackler:derive-debug-unsized, r=alexcrichton
bors [Tue, 19 May 2015 07:38:24 +0000 (07:38 +0000)]
Auto merge of #25550 - sfackler:derive-debug-unsized, r=alexcrichton

Closes #25394

9 years agoAuto merge of #25548 - sfackler:debug-builders-by-ref, r=alexcrichton
bors [Tue, 19 May 2015 05:39:29 +0000 (05:39 +0000)]
Auto merge of #25548 - sfackler:debug-builders-by-ref, r=alexcrichton

Based on feedback from https://internals.rust-lang.org/t/final-comment-period-for-debug-builders-stabilization/2007/2

9 years agoUpdate iter.rs
Wei-Ming Yang [Tue, 19 May 2015 04:40:01 +0000 (12:40 +0800)]
Update iter.rs

fixed a mistake.

9 years agoExplain E0023, E0024, E0025, E0026, E0027, E0033.
Michael Sproul [Mon, 11 May 2015 12:15:16 +0000 (22:15 +1000)]
Explain E0023, E0024, E0025, E0026, E0027, E0033.

9 years agoFix debug builder examples examples
Steven Fackler [Tue, 19 May 2015 03:57:11 +0000 (20:57 -0700)]
Fix debug builder examples examples

9 years agoAuto merge of #25496 - alexcrichton:stabilize-cloned, r=aturon
bors [Tue, 19 May 2015 03:41:23 +0000 (03:41 +0000)]
Auto merge of #25496 - alexcrichton:stabilize-cloned, r=aturon

The method was stabilized but the structure was forgotten to be stabilized.

Closes #25480

9 years agocollections: Clean up feature flags doc examples
Ulrik Sverdrup [Tue, 19 May 2015 01:33:17 +0000 (03:33 +0200)]
collections: Clean up feature flags doc examples

9 years agocollections: Avoid unstable code in examples for Vec
Ulrik Sverdrup [Tue, 19 May 2015 01:33:17 +0000 (03:33 +0200)]
collections: Avoid unstable code in examples for Vec

9 years agocollections: Avoid unstable code in examples for String
Ulrik Sverdrup [Tue, 19 May 2015 01:33:17 +0000 (03:33 +0200)]
collections: Avoid unstable code in examples for String

Prefer String::from over from_str; String::from_str is unstable while
String::from is stable. Promote the latter by using it in examples.

Simply migrating unstable function to the closest alternative.

9 years agoAuto merge of #25441 - alexcrichton:debug-panic-neg, r=aturon
bors [Tue, 19 May 2015 01:08:54 +0000 (01:08 +0000)]
Auto merge of #25441 - alexcrichton:debug-panic-neg, r=aturon

Debug overflow checks for arithmetic negation landed in #24500, at which time
the `abs` method on signed integers was changed to using `wrapping_neg` to
ensure that the function never panicked. This implied that `abs` of `INT_MIN`
would return `INT_MIN`, another negative value. When this change was back-ported
to beta, however, in #24708, the `wrapping_neg` function had not yet been
backported, so the implementation was changed in #24785 to `!self + 1`. This
change had the unintended side effect of enabling debug overflow checks for the
`abs` function. Consequently, the current state of affairs is that the beta
branch checks for overflow in debug mode for `abs` and the nightly branch does
not.

This commit alters the behavior of nightly to have `abs` always check for
overflow in debug mode. This change is more consistent with the way the standard
library treats overflow as well, and it is also not a breaking change as it's
what the beta branch currently does (albeit if by accident).

cc #25378

9 years agostd: Make abs() panic on overflow in debug mode
Alex Crichton [Fri, 15 May 2015 16:18:14 +0000 (09:18 -0700)]
std: Make abs() panic on overflow in debug mode

Debug overflow checks for arithmetic negation landed in #24500, at which time
the `abs` method on signed integers was changed to using `wrapping_neg` to
ensure that the function never panicked. This implied that `abs` of `INT_MIN`
would return `INT_MIN`, another negative value. When this change was back-ported
to beta, however, in #24708, the `wrapping_neg` function had not yet been
backported, so the implementation was changed in #24785 to `!self + 1`. This
change had the unintended side effect of enabling debug overflow checks for the
`abs` function. Consequently, the current state of affairs is that the beta
branch checks for overflow in debug mode for `abs` and the nightly branch does
not.

This commit alters the behavior of nightly to have `abs` always check for
overflow in debug mode. This change is more consistent with the way the standard
library treats overflow as well, and it is also not a breaking change as it's
what the beta branch currently does (albeit if by accident).

cc #25378

9 years agorustdoc: Fix left margin for type aliases
Ulrik Sverdrup [Mon, 18 May 2015 23:44:04 +0000 (01:44 +0200)]
rustdoc: Fix left margin for type aliases

Fixes #24655

Margin for associated types was applied to type aliases (in return
value) by mistake.

9 years agoAuto merge of #25337 - bleibig:update-grammar, r=nikomatsakis
bors [Mon, 18 May 2015 23:29:26 +0000 (23:29 +0000)]
Auto merge of #25337 - bleibig:update-grammar, r=nikomatsakis

* Correctly lex CRLF in string literals
* Update `extern CRATE as NAME` syntax
* Allow leading `::` in view paths
* Allow TySums in type ascriptions and impls
* Allow macros to have visibility and attributes
* Update syntax for qualified path types and expressions
* Allow block expressions to be called () and indexed []

9 years agoAdd example for from_str_radix
Steve Klabnik [Mon, 18 May 2015 20:58:29 +0000 (16:58 -0400)]
Add example for from_str_radix

Fixes #25517

9 years agoAuto merge of #25230 - rayglover:patch-bitset, r=Gankro
bors [Mon, 18 May 2015 19:54:24 +0000 (19:54 +0000)]
Auto merge of #25230 - rayglover:patch-bitset, r=Gankro

Some modest running-time improvements to `std::collections::BitSet` on bit-sets of varying set-membership densities. This is work originally from [here](https://github.com/rayglover/alt_collections). (Benchmarks copied below)
```
std::collections::BitSet / alt_collections::BitSet

copy_dense         ... 3.08x
copy_sparse        ... 4.22x
count_dense        ... 11.01x
count_sparse       ... 8.11x
from_bytes         ... 1.47x
intersect_dense    ... 6.54x
intersect_sparse   ... 4.37x
union_dense        ... 5.53x
union_sparse       ... 5.60x
```

The exception is `from_bytes`, which I've left unaltered since the optimization is rather obscure.

Compiling with the cpu feature `popcnt` gave a further ~10% improvement on my machine, but this wasn't factored in to the benchmarks above.

Similar improvements could be made to `BitVec`, although that would probably require more substantial changes.

criticism welcome!

9 years agoTRPL: Normalize rust Code Block Markers
Pascal Hertleif [Mon, 18 May 2015 19:10:00 +0000 (21:10 +0200)]
TRPL: Normalize rust Code Block Markers

`{rust,ignore}` -> `rust,ignore

9 years agoTRPL: Add `rust` Marker to Some Code Block
Pascal Hertleif [Mon, 18 May 2015 18:56:00 +0000 (20:56 +0200)]
TRPL: Add `rust` Marker to Some Code Block

This adds strictly more information to the source files and reduces the
need for customized tooling to render the book.

(While this should not change the output of _rustbook_, it is very
useful when rendering the sources with external tools like Pandoc.)