]> git.lizzy.rs Git - rust.git/log
rust.git
7 years agoImplement O(1)-time Iterator::nth for Range*
Simon Sapin [Wed, 5 Jul 2017 23:14:20 +0000 (01:14 +0200)]
Implement O(1)-time Iterator::nth for Range*

7 years agoFactorize some macros in iter/range.rs
Simon Sapin [Wed, 5 Jul 2017 22:32:54 +0000 (00:32 +0200)]
Factorize some macros in iter/range.rs

7 years agoRemove Step::steps_between, rename steps_between_by_one to steps_between
Simon Sapin [Wed, 5 Jul 2017 22:10:40 +0000 (00:10 +0200)]
Remove Step::steps_between, rename steps_between_by_one to steps_between

7 years agoRemove unused Step methods
Simon Sapin [Wed, 5 Jul 2017 21:54:08 +0000 (23:54 +0200)]
Remove unused Step methods

7 years agoRemove unused Add bounds in iterator for ranges impls.
Simon Sapin [Wed, 5 Jul 2017 21:49:33 +0000 (23:49 +0200)]
Remove unused Add bounds in iterator for ranges impls.

7 years agoAuto merge of #43072 - cuviper:linux-stack-guard, r=alexcrichton
bors [Sat, 8 Jul 2017 04:22:49 +0000 (04:22 +0000)]
Auto merge of #43072 - cuviper:linux-stack-guard, r=alexcrichton

Skip the main thread's manual stack guard on Linux

Linux doesn't allocate the whole stack right away, and the kernel has its own stack-guard mechanism to fault when growing too close to an existing mapping.  If we map our own guard, then the kernel starts enforcing a rather large gap above that, rendering much of the possible stack space useless.

Instead, we'll just note where we expect rlimit to start faulting, so our handler can report "stack overflow", and trust that the kernel's own stack guard will work.

Fixes #43052.
r? @alexcrichton

### Kernel compatibility:

Strictly speaking, Rust claims support for Linux kernels >= 2.6.18, and stack guards were only added to mainline in 2.6.36 for [CVE-2010-2240].  But since that vulnerability was so severe, the guards were backported to many stable branches, and Red Hat patched this all the way back to RHEL3's 2.4.21!  I think it's reasonable for us to assume that any *supportable* kernel should have these stack guards.

At that time, the kernel only enforced one page of padding between the stack and other mappings, but thanks to [Stack Clash] that padding is now much larger, causing #43052.  The kernel side of those fixes are in [CVE-2017-1000364], which Red Hat has backported to at least RHEL5's 2.6.18 so far.

[CVE-2010-2240]: https://access.redhat.com/security/cve/CVE-2010-2240
[CVE-2017-1000364]: https://access.redhat.com/security/cve/CVE-2017-1000364
[Stack Clash]: https://access.redhat.com/security/vulnerabilities/stackguard

7 years agoAuto merge of #42894 - petrochenkov:deny, r=nikomatsakis
bors [Sat, 8 Jul 2017 02:03:38 +0000 (02:03 +0000)]
Auto merge of #42894 - petrochenkov:deny, r=nikomatsakis

Make sufficiently old or low-impact compatibility lints deny-by-default

Needs crater run before proceeding.

r? @nikomatsakis

7 years agoMake `patterns_in_fns_without_body` warn-by-default again
Vadim Petrochenkov [Sat, 8 Jul 2017 00:01:11 +0000 (03:01 +0300)]
Make `patterns_in_fns_without_body` warn-by-default again

Fix some tests on Linux

7 years agoMove public reexports of private extern crates into a separate lint
Vadim Petrochenkov [Sun, 25 Jun 2017 02:50:51 +0000 (05:50 +0300)]
Move public reexports of private extern crates into a separate lint

This is going to be a hard error while all private-in-public errors from rustc_privacy will be reclassified into lints.

7 years agoMake sufficiently old or low-impact compatibility lints deny-by-default
Vadim Petrochenkov [Sun, 25 Jun 2017 02:30:20 +0000 (05:30 +0300)]
Make sufficiently old or low-impact compatibility lints deny-by-default

7 years agoRemove more anonymous trait method parameters
Vadim Petrochenkov [Sun, 25 Jun 2017 02:29:10 +0000 (05:29 +0300)]
Remove more anonymous trait method parameters

7 years agoAuto merge of #42840 - arielb1:poison-smoke-and-mirrors, r=nikomatsakis
bors [Fri, 7 Jul 2017 21:15:30 +0000 (21:15 +0000)]
Auto merge of #42840 - arielb1:poison-smoke-and-mirrors, r=nikomatsakis

Replace the global fulfillment cache with the evaluation cache

This uses the new "Chalk" ParamEnv refactoring to check "global" predicates in an empty environment, which should be correct because global predicates aren't affected by a consistent environment.

Fixes #39970.
Fixes #42796.

r? @nikomatsakis

7 years agoAuto merge of #42809 - seanmonstar:stable-associated-consts, r=nikomatsakis
bors [Fri, 7 Jul 2017 18:42:14 +0000 (18:42 +0000)]
Auto merge of #42809 - seanmonstar:stable-associated-consts, r=nikomatsakis

remove associated_consts feature gate

Currently struggling to run tests locally (something about jemalloc target missing).

cc #29646

7 years agoreturn EvaluatedToRecur when evaluating a recursive obligation tree
Ariel Ben-Yehuda [Fri, 30 Jun 2017 11:18:04 +0000 (14:18 +0300)]
return EvaluatedToRecur when evaluating a recursive obligation tree

This helps avoid cache pollution. Also add more comments explaining
that.

7 years agouse the evaluation cache instead of the global fulfillment cache
Ariel Ben-Yehuda [Thu, 22 Jun 2017 21:27:47 +0000 (00:27 +0300)]
use the evaluation cache instead of the global fulfillment cache

The evaluation cache already exists, and it can handle differing
parameter environments natively.

Fixes #39970.
Fixes #42796.

7 years agouse dep-graph reads for the evaluation cache
Ariel Ben-Yehuda [Mon, 26 Jun 2017 15:39:52 +0000 (18:39 +0300)]
use dep-graph reads for the evaluation cache

This is just duplicating the logic from the old fulfillment cache, so
I'm not sure it is 100% correct, but it should not be more wrong than
the old logic.

7 years agoprevent illegal coinductive matching in trait evaluation
Ariel Ben-Yehuda [Mon, 26 Jun 2017 14:23:15 +0000 (17:23 +0300)]
prevent illegal coinductive matching in trait evaluation

Previously, coinductive matching was only blocked on the fulfillment
path, and ignored on the evaluation path.

7 years agoSkip the main thread's manual stack guard on Linux
Josh Stone [Wed, 5 Jul 2017 19:03:17 +0000 (12:03 -0700)]
Skip the main thread's manual stack guard on Linux

Linux doesn't allocate the whole stack right away, and the kernel has
its own stack-guard mechanism to fault when growing too close to an
existing mapping.  If we map our own guard, then the kernel starts
enforcing a rather large gap above that, rendering much of the possible
stack space useless.

Instead, we'll just note where we expect rlimit to start faulting, so
our handler can report "stack overflow", and trust that the kernel's own
stack guard will work.

Fixes #43052.

7 years agoAuto merge of #43099 - japaric:msp430, r=alexcrichton
bors [Fri, 7 Jul 2017 15:27:49 +0000 (15:27 +0000)]
Auto merge of #43099 - japaric:msp430, r=alexcrichton

add a built-in MSP430 target

the MSP430 backend has been enabled for a while but no target was added to rustc
to encourage out of tree experimentation.

We believe the out of tree (custom) target has been iterated long enough and is
stable enough for inclusion in the compiler. Kudos to @pftbest and @awygle for
fixing several LLVM / codegen bugs this target had!

The target name chosen is a slight variation of the triple gcc uses, which is
simply `msp430-elf`. We picked `msp430-none-elf` to leave room for custom
targets that target some embedded OS running on MSP430 devices. (cf. the
custom `thumbv7m-tockos-eabi` target TockOS uses vs the built-in
`thumbv7m-none-eabi`).

There's one expected change in the specification of the proposed target: the
`asm_args` and `no_integrated_as` fields will change to their default values.
Once the LLVM backend gains the ability to directly produce MSP430 object files
we can stop depending on `msp430-elf-gcc` for producing object files; when that
occurs the `asm` related fields will change. This change won't break existing
user code.

r? @alexcrichton
cc @brson

7 years agoAuto merge of #43093 - rthomas:39791-hashmap, r=alexcrichton
bors [Fri, 7 Jul 2017 12:54:46 +0000 (12:54 +0000)]
Auto merge of #43093 - rthomas:39791-hashmap, r=alexcrichton

Add annotations to the resize fn #39791

This adds the `inline(never)` and `cold` annotations to the
HashMap::resize function.

7 years agoAuto merge of #43060 - petrochenkov:asless, r=estebank
bors [Fri, 7 Jul 2017 10:37:38 +0000 (10:37 +0000)]
Auto merge of #43060 - petrochenkov:asless, r=estebank

syntax: Apply `x as usize < y` recovery to type ascription as well

Also correct spans, add some comments.

r? @estebank

7 years agosyntax: Apply recovery for casts to type ascription
Vadim Petrochenkov [Mon, 3 Jul 2017 23:17:01 +0000 (02:17 +0300)]
syntax: Apply recovery for casts to type ascription

Fix spans, add some comments

7 years agoFix spans for binary operator expression with interpolated identifiers
Vadim Petrochenkov [Tue, 4 Jul 2017 14:04:34 +0000 (17:04 +0300)]
Fix spans for binary operator expression with interpolated identifiers

7 years agoAuto merge of #43091 - aidanhs:aphs-no-docker-priv, r=alexcrichton
bors [Fri, 7 Jul 2017 08:13:20 +0000 (08:13 +0000)]
Auto merge of #43091 - aidanhs:aphs-no-docker-priv, r=alexcrichton

Privileged in docker run isn't necessary

Added relatively recently in https://github.com/rust-lang/rust/pull/40199/files#diff-71609a365528e4649836825d8250c241R57, but I don't see anything in that PR that requires it. If it's not strictly necessary, we shouldn't use it.

(if this lands I'll make a PR against libc which also uses privileged)

r? @alexcrichton

7 years agoAuto merge of #43068 - ollie27:rustdoc_markdown_tests, r=GuillaumeGomez
bors [Fri, 7 Jul 2017 06:01:30 +0000 (06:01 +0000)]
Auto merge of #43068 - ollie27:rustdoc_markdown_tests, r=GuillaumeGomez

rustdoc: Don't run Markdown tests twice

This matches the behaviour for finding tests in Rust files.

This was a regression from 1.17 to 1.18 so it would be a good idea to backport this to beta so at least 1.19 won't also be affected.

Fixes #42726

r? @GuillaumeGomez

7 years agoAuto merge of #43062 - sfackler:connect-timeout, r=alexcrichton
bors [Fri, 7 Jul 2017 03:43:14 +0000 (03:43 +0000)]
Auto merge of #43062 - sfackler:connect-timeout, r=alexcrichton

Implement TcpStream::connect_timeout

This breaks the "single syscall rule", but it's really annoying to hand
write and is pretty foundational.

r? @alexcrichton

cc @rust-lang/libs

7 years agoImplement TcpStream::connect_timeout
Steven Fackler [Wed, 5 Jul 2017 06:46:24 +0000 (23:46 -0700)]
Implement TcpStream::connect_timeout

This breaks the "single syscall rule", but it's really annoying to hand
write and is pretty foundational.

7 years agoAuto merge of #42125 - petrochenkov:privty, r=nikomatsakis
bors [Fri, 7 Jul 2017 01:32:13 +0000 (01:32 +0000)]
Auto merge of #42125 - petrochenkov:privty, r=nikomatsakis

Check types for privacy

This PR implements late post factum checking of type privacy, as opposed to early preventive "private-in-public" checking.
This will allow to turn private-in-public checks into a lint and make them more heuristic-based, and more aligned with what people may expect (e.g. reachability-based behavior).

Types are privacy-checked if they are written explicitly, and also if they are inferred as expression or pattern types.
This PR checks "semantic" types and does it unhygienically, this significantly restricts what macros 2.0 (as implemented in https://github.com/rust-lang/rust/pull/40847) can do (sorry @jseyfried) - they still can use private *names*, but can't use private *types*.
This is the most conservative solution, but hopefully it's temporary and can be relaxed in the future, probably using macro contexts of expression/pattern spans.

Traits are also checked in preparation for [trait aliases](https://github.com/rust-lang/rust/issues/41517), which will be able to leak private traits, and macros 2.0 which will be able to leak pretty much anything.

This is a [breaking-change], but the code that is not contrived and can be broken by this patch should be guarded by `private_in_public` lint. [Previous crater run](https://github.com/rust-lang/rust/issues/34537#issuecomment-262865768) discovered a few abandoned crates that weren't updated since `private_in_public` has been introduced in 2015.

cc https://github.com/rust-lang/rust/issues/34537 https://internals.rust-lang.org/t/lang-team-minutes-private-in-public-rules/4504
Fixes https://github.com/rust-lang/rust/issues/30476
Fixes https://github.com/rust-lang/rust/issues/33479

cc @nikomatsakis
r? @eddyb

7 years agoAddress review comments
petrochenkov [Thu, 29 Jun 2017 13:06:24 +0000 (16:06 +0300)]
Address review comments

Fix regressions after rebase

7 years agoAuto merge of #42904 - estebank:number-suggestions, r=nikomatsakis
bors [Thu, 6 Jul 2017 22:22:21 +0000 (22:22 +0000)]
Auto merge of #42904 - estebank:number-suggestions, r=nikomatsakis

Make suggestion include the line number

When there're more than one suggestions in the same diagnostic, they are
displayed in their own block, instead of inline. In order to reduce
confusion, those blocks now display the line number.

New output:

```
error[E0308]: mismatched types
  --> ../../src/test/ui/block-result/unexpected-return-on-unit.rs:19:5
   |
19 |     foo()
   |     ^^^^^ expected (), found usize
   |
   = note: expected type `()`
              found type `usize`
help: did you mean to add a semicolon here?
   |
19 |     foo();
   |          ^
help: possibly return type missing here?
   |
18 | fn bar() -> usize {
   |          ^^^^^^^^

error: aborting due to previous error(s)
```

Fix #39152.

7 years agoPrivileged in docker run isn't necessary
Aidan Hobson Sayers [Thu, 6 Jul 2017 17:42:49 +0000 (18:42 +0100)]
Privileged in docker run isn't necessary

7 years agoadd a built-in MSP430 target
Jorge Aparicio [Thu, 6 Jul 2017 20:15:44 +0000 (15:15 -0500)]
add a built-in MSP430 target

7 years agoOnly underline suggestion if it is not the only code being shown
Esteban Küber [Wed, 5 Jul 2017 23:39:06 +0000 (16:39 -0700)]
Only underline suggestion if it is not the only code being shown

7 years agoAdd extra whitespace for suggestions
Esteban Küber [Wed, 28 Jun 2017 06:16:04 +0000 (23:16 -0700)]
Add extra whitespace for suggestions

7 years agoMake suggestion include the line number
Esteban Küber [Sun, 25 Jun 2017 20:11:22 +0000 (13:11 -0700)]
Make suggestion include the line number

When there're more than one suggestions in the same diagnostic, they are
displayed in their own block, instead of inline. In order to reduce
confusion, those blocks now display the line number.

7 years agoCheck adjustments and node substs
Vadim Petrochenkov [Sat, 3 Jun 2017 14:51:32 +0000 (17:51 +0300)]
Check adjustments and node substs

Cleanup checking of inherent static methods and fix checking of inherent associated constants
Add more tests

7 years agoCheck types for privacy
Vadim Petrochenkov [Sat, 22 Apr 2017 19:46:34 +0000 (22:46 +0300)]
Check types for privacy

7 years agoAuto merge of #43092 - aidanhs:aphs-retry-llvm-tarball, r=alexcrichton
bors [Thu, 6 Jul 2017 19:56:55 +0000 (19:56 +0000)]
Auto merge of #43092 - aidanhs:aphs-retry-llvm-tarball, r=alexcrichton

Retry downloading llvm commit tarball

As promised on https://github.com/rust-lang/rust/pull/42816#issuecomment-312890169

r? @alexcrichton

7 years agoAdd annotations to the resize fn #39791
Ryan Thomas [Thu, 6 Jul 2017 19:25:53 +0000 (20:25 +0100)]
Add annotations to the resize fn #39791

This adds the `inline(never)` and `cold` annotations to the
HashMap::resize function.

7 years agoremove associated_consts feature gate
Sean McArthur [Thu, 6 Jul 2017 18:52:25 +0000 (11:52 -0700)]
remove associated_consts feature gate

7 years agoRetry downloading llvm commit tarball
Aidan Hobson Sayers [Thu, 6 Jul 2017 17:55:07 +0000 (18:55 +0100)]
Retry downloading llvm commit tarball

7 years agoAuto merge of #42816 - alexcrichton:probestack, r=nikomatsakis
bors [Thu, 6 Jul 2017 17:15:14 +0000 (17:15 +0000)]
Auto merge of #42816 - alexcrichton:probestack, r=nikomatsakis

rustc: Implement stack probes for x86

This commit implements stack probes on x86/x86_64 using the freshly landed
support upstream in LLVM. The purpose of stack probes here are to guarantee a
segfault on stack overflow rather than having a chance of running over the guard
page already present on all threads by accident.

At this time there's no support for any other architecture because LLVM itself
does not have support for other architectures.

7 years agorustc: Implement stack probes for x86
Alex Crichton [Wed, 21 Jun 2017 19:08:18 +0000 (12:08 -0700)]
rustc: Implement stack probes for x86

This commit implements stack probes on x86/x86_64 using the freshly landed
support upstream in LLVM. The purpose of stack probes here are to guarantee a
segfault on stack overflow rather than having a chance of running over the guard
page already present on all threads by accident.

At this time there's no support for any other architecture because LLVM itself
does not have support for other architectures.

7 years agorustdoc: Don't run Markdown tests twice
Oliver Middleton [Wed, 5 Jul 2017 14:47:54 +0000 (15:47 +0100)]
rustdoc: Don't run Markdown tests twice

This matches the behaviour for finding tests in Rust files.

7 years agoAuto merge of #43066 - pornel:patch-1, r=Mark-Simulacrum
bors [Thu, 6 Jul 2017 14:46:13 +0000 (14:46 +0000)]
Auto merge of #43066 - pornel:patch-1, r=Mark-Simulacrum

Suggest rustup toolchain link

The contributing instructions only explain how to build the compiler, but not how to try it out.

I found `rustup toolchain link` to be super useful for this, so I think it's good to suggest it.

7 years agoAuto merge of #43078 - kennytm:fix-42755-vis-can-be-empty, r=petrochenkov
bors [Thu, 6 Jul 2017 11:28:32 +0000 (11:28 +0000)]
Auto merge of #43078 - kennytm:fix-42755-vis-can-be-empty, r=petrochenkov

Disallow `$($v:vis)*`. Fix #42755.

#42755

7 years agoSuggest rustup toolchain link
Kornel [Wed, 5 Jul 2017 14:24:41 +0000 (15:24 +0100)]
Suggest rustup toolchain link

7 years agoDisallow `$($v:vis)*`. Fix #42755.
kennytm [Thu, 6 Jul 2017 00:18:58 +0000 (08:18 +0800)]
Disallow `$($v:vis)*`. Fix #42755.

7 years agoAuto merge of #43008 - zackmdavis:field_init_shorthand_in_librustc, r=estebank
bors [Thu, 6 Jul 2017 07:49:44 +0000 (07:49 +0000)]
Auto merge of #43008 - zackmdavis:field_init_shorthand_in_librustc, r=estebank

use field init shorthand in src/librustc/

Commentary on #37340 [suggested](https://github.com/rust-lang/rust/issues/37340#issuecomment-255513390) using the new field init syntax in the compiler. Do we care about this? If so, here's a pull request for the librustc/ directory. While [`rustfmt` might do this in the future](https://github.com/rust-lang/rust/issues/37340#issuecomment-255513712), in the meantime, some simple Python will do:

```python
#!/usr/bin/env python3

import os, re, sys

OPPORTUNITY = re.compile(r" (\w+): \1,?\n")

def field_init_shorthand_substitution(filename):
    with open(filename) as f:
        text = f.read()
        revised = OPPORTUNITY.sub(r" \1,\n", text)
    with open(filename, 'w') as f:
        f.write(revised)

def substitute_in_directory(path):
    for dirname, _subdirs, basenames in os.walk(path):
        for basename in basenames:
            field_init_shorthand_substitution(os.path.join(dirname, basename))

if __name__ == "__main__":
    substitute_in_directory(sys.argv[1])
```

**Update 3 July**: edited the search (respectively replace) regex to ` (\w+): \1,?\n` (` \1,\n`) from ` (\w+): \1,` (` \1,`)

7 years agouse field init shorthand in src/librustc
Zack M. Davis [Mon, 3 Jul 2017 18:19:51 +0000 (11:19 -0700)]
use field init shorthand in src/librustc

The field init shorthand syntax was stabilized in 1.17.0 (aebd94f); we
are now free to use it in the compiler.

7 years agoAuto merge of #43001 - estebank:try-on-unimplemented, r=aturon
bors [Thu, 6 Jul 2017 05:29:09 +0000 (05:29 +0000)]
Auto merge of #43001 - estebank:try-on-unimplemented, r=aturon

Add `rustc_on_unimplemented` message to `std::ops::Try`

#42694, #35946.

7 years agoAdd `rustc_on_unimplemented` message to `std::ops::Try`
Esteban Küber [Sat, 1 Jul 2017 00:11:12 +0000 (17:11 -0700)]
Add `rustc_on_unimplemented` message to `std::ops::Try`

7 years agoAuto merge of #42899 - alexcrichton:compiler-builtins, r=nikomatsakis
bors [Thu, 6 Jul 2017 02:34:29 +0000 (02:34 +0000)]
Auto merge of #42899 - alexcrichton:compiler-builtins, r=nikomatsakis

Switch to rust-lang-nursery/compiler-builtins

This commit migrates the in-tree `libcompiler_builtins` to the upstream version
at https://github.com/rust-lang-nursery/compiler-builtins. The upstream version
has a number of intrinsics written in Rust and serves as an in-progress rewrite
of compiler-rt into Rust. Additionally it also contains all the existing
intrinsics defined in `libcompiler_builtins` for 128-bit integers.

It's been the intention since the beginning to make this transition but
previously it just lacked the manpower to get done. As this PR likely shows it
wasn't a trivial integration! Some highlight changes are:

* The PR rust-lang-nursery/compiler-builtins#166 contains a number of fixes
  across platforms and also some refactorings to make the intrinsics easier to
  read. The additional testing added there also fixed a number of integration
  issues when pulling the repository into this tree.

* LTO with the compiler-builtins crate was fixed to link in the entire crate
  after the LTO process as these intrinsics are excluded from LTO.

* Treatment of hidden symbols was updated as previously the
  `#![compiler_builtins]` crate would mark all symbol *imports* as hidden
  whereas it was only intended to mark *exports* as hidden.

7 years agoAuto merge of #42727 - alexcrichton:allocators-new, r=eddyb
bors [Thu, 6 Jul 2017 00:16:16 +0000 (00:16 +0000)]
Auto merge of #42727 - alexcrichton:allocators-new, r=eddyb

rustc: Implement the #[global_allocator] attribute

This PR is an implementation of [RFC 1974] which specifies a new method of
defining a global allocator for a program. This obsoletes the old
`#![allocator]` attribute and also removes support for it.

[RFC 1974]: https://github.com/rust-lang/rfcs/pull/1974

The new `#[global_allocator]` attribute solves many issues encountered with the
`#![allocator]` attribute such as composition and restrictions on the crate
graph itself. The compiler now has much more control over the ABI of the
allocator and how it's implemented, allowing much more freedom in terms of how
this feature is implemented.

cc #27389

7 years agorustc: Implement the #[global_allocator] attribute
Alex Crichton [Sat, 3 Jun 2017 21:54:08 +0000 (14:54 -0700)]
rustc: Implement the #[global_allocator] attribute

This PR is an implementation of [RFC 1974] which specifies a new method of
defining a global allocator for a program. This obsoletes the old
`#![allocator]` attribute and also removes support for it.

[RFC 1974]: https://github.com/rust-lang/rfcs/pull/197

The new `#[global_allocator]` attribute solves many issues encountered with the
`#![allocator]` attribute such as composition and restrictions on the crate
graph itself. The compiler now has much more control over the ABI of the
allocator and how it's implemented, allowing much more freedom in terms of how
this feature is implemented.

cc #27389

7 years agoAuto merge of #40939 - jseyfried:proc_macro_api, r=nrc
bors [Wed, 5 Jul 2017 21:16:34 +0000 (21:16 +0000)]
Auto merge of #40939 - jseyfried:proc_macro_api, r=nrc

proc_macro: implement `TokenTree`, `TokenKind`, hygienic `quote!`, and other API

All new API is gated behind `#![feature(proc_macro)]` and may be used with `#[proc_macro]`, `#[proc_macro_attribute]`, and `#[proc_macro_derive]` procedural macros.

More specifically, this PR adds the following in `proc_macro`:
```rust
// `TokenStream` constructors:
impl TokenStream { fn empty() -> TokenStream { ... } }
impl From<TokenTree> for TokenStream { ... }
impl From<TokenKind> for TokenStream { ... }
impl<T: Into<TokenStream>> FromIterator<T> for TokenStream { ... }
macro quote($($t:tt)*) { ... } // A hygienic `TokenStream` quoter

// `TokenStream` destructuring:
impl TokenStream { fn is_empty(&self) -> bool { ... } }
impl IntoIterator for TokenStream { type Item = TokenTree; ... }

struct TokenTree { span: Span, kind: TokenKind }
impl From<TokenKind> for TokenTree { ... }
impl Display for TokenTree { ... }

struct Span { ... } // a region of source code along with expansion/hygiene information
impl Default for Span { ... } // a span from the current procedural macro definition
impl Span { fn call_site() -> Span { ... } } // the call site of the current expansion
fn quote_span(span: Span) -> TokenStream;

enum TokenKind {
    Group(Delimiter, TokenStream), // A delimited sequence, e.g. `( ... )`
    Term(Term), // a unicode identifier, lifetime ('a), or underscore
    Op(char, Spacing), // a punctuation character (`+`, `,`, `$`, etc.).
    Literal(Literal), // a literal character (`'a'`), string (`"hello"`), or number (`2.3`)
}

enum Delimiter {
    Parenthesis, // `( ... )`
    Brace, // `[ ... ]`
    Bracket, // `{ ... }`
    None, // an implicit delimiter, e.g. `$var`, where $var is  `...`.
}

struct Term { ... } // An interned string
impl Term {
    fn intern(string: &str) -> Symbol { ... }
    fn as_str(&self) -> &str { ... }
}

enum Spacing {
    Alone, // not immediately followed by another `Op`, e.g. `+` in `+ =`.
    Joint, // immediately followed by another `Op`, e.g. `+` in `+=`
}

struct Literal { ... }
impl Display for Literal { ... }
impl Literal {
    fn integer(n: i128) -> Literal { .. } // unsuffixed integer literal
    fn float(n: f64) -> Literal { .. } // unsuffixed floating point literal
    fn u8(n: u8) -> Literal { ... } // similarly: i8, u16, i16, u32, i32, u64, i64, f32, f64
    fn string(string: &str) -> Literal { ... }
    fn character(ch: char) -> Literal { ... }
    fn byte_string(bytes: &[u8]) -> Literal { ... }
}
```
For details on `quote!` hygiene, see [this example](https://github.com/rust-lang/rust/pull/40939/commits/20a90485c040df87a667e9b6ee38e4d8a7d7fc5d) and [declarative macros 2.0](https://github.com/rust-lang/rust/pull/40847).

r? @nrc

7 years agorustbuild: Only -Zsave-analysis for libstd
Alex Crichton [Wed, 5 Jul 2017 20:51:34 +0000 (13:51 -0700)]
rustbuild: Only -Zsave-analysis for libstd

Don't pass the flag when we're compiling the compiler or other related tools

7 years agoMerge remote-tracking branch 'origin/master' into proc_macro_api
Alex Crichton [Wed, 5 Jul 2017 15:42:13 +0000 (08:42 -0700)]
Merge remote-tracking branch 'origin/master' into proc_macro_api

7 years agoSwitch to rust-lang-nursery/compiler-builtins
Alex Crichton [Thu, 22 Jun 2017 20:14:00 +0000 (13:14 -0700)]
Switch to rust-lang-nursery/compiler-builtins

This commit migrates the in-tree `libcompiler_builtins` to the upstream version
at https://github.com/rust-lang-nursery/compiler-builtins. The upstream version
has a number of intrinsics written in Rust and serves as an in-progress rewrite
of compiler-rt into Rust. Additionally it also contains all the existing
intrinsics defined in `libcompiler_builtins` for 128-bit integers.

It's been the intention since the beginning to make this transition but
previously it just lacked the manpower to get done. As this PR likely shows it
wasn't a trivial integration! Some highlight changes are:

* The PR rust-lang-nursery/compiler-builtins#166 contains a number of fixes
  across platforms and also some refactorings to make the intrinsics easier to
  read. The additional testing added there also fixed a number of integration
  issues when pulling the repository into this tree.

* LTO with the compiler-builtins crate was fixed to link in the entire crate
  after the LTO process as these intrinsics are excluded from LTO.

* Treatment of hidden symbols was updated as previously the
  `#![compiler_builtins]` crate would mark all symbol *imports* as hidden
  whereas it was only intended to mark *exports* as hidden.

7 years agoAuto merge of #42972 - GuillaumeGomez:fix-toggles-rustdoc, r=QuietMisdreavus
bors [Wed, 5 Jul 2017 13:56:32 +0000 (13:56 +0000)]
Auto merge of #42972 - GuillaumeGomez:fix-toggles-rustdoc, r=QuietMisdreavus

Toggle wrappers are now generated correctly

Fixes #42674.

7 years agoAuto merge of #43050 - stjepang:doc-vec-fix-parens, r=frewsxcv
bors [Wed, 5 Jul 2017 02:04:07 +0000 (02:04 +0000)]
Auto merge of #43050 - stjepang:doc-vec-fix-parens, r=frewsxcv

Minor fix in docs for Vec

Added missing parentheses after `mem::size_of::<T>`.

7 years agoAuto merge of #42732 - cengizIO:master, r=Mark-Simulacrum
bors [Tue, 4 Jul 2017 23:50:11 +0000 (23:50 +0000)]
Auto merge of #42732 - cengizIO:master, r=Mark-Simulacrum

Add pager support for `rustc --explain EXXXX`

Hello!

Fixes #32665.

Thanks!

**EDIT:** _I've limited access to a Windows machine so this is taking longer than I've anticipated_. 🐢

cc @alexcrichton @nikomatsakis @Mark-Simulacrum @retep998 @ollie27 @afiune

7 years agoAuto merge of #43051 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
bors [Tue, 4 Jul 2017 15:58:24 +0000 (15:58 +0000)]
Auto merge of #43051 - Mark-Simulacrum:rollup, r=Mark-Simulacrum

Rollup of 8 pull requests

- Successful merges: #42227, #42836, #42975, #42994, #43041, #43042, #43043, #43045
- Failed merges:

7 years agoRollup merge of #43045 - PlasmaPower:patch-1, r=Mark-Simulacrum
Mark Simulacrum [Tue, 4 Jul 2017 13:41:45 +0000 (07:41 -0600)]
Rollup merge of #43045 - PlasmaPower:patch-1, r=Mark-Simulacrum

README: note how to enable debugging for rustc

I got stuck on this for a bit, looking for a debug option in `./x.py build --help`.

Diff without newline changes:

Before:

> Various other options are also supported, and are documented in the config file.

After:

> Various other options, such as enabling debug information, are also supported, and are documented in the config file.

7 years agoRollup merge of #43043 - sfackler:reverse-stability, r=Mark-Simulacrum
Mark Simulacrum [Tue, 4 Jul 2017 13:41:44 +0000 (07:41 -0600)]
Rollup merge of #43043 - sfackler:reverse-stability, r=Mark-Simulacrum

Add a stability marker for core::cmp::Reverse.0

Closes #43027

7 years agoRollup merge of #43042 - Mark-Simulacrum:rustbuild-cleanup, r=alexcrichton
Mark Simulacrum [Tue, 4 Jul 2017 13:41:43 +0000 (07:41 -0600)]
Rollup merge of #43042 - Mark-Simulacrum:rustbuild-cleanup, r=alexcrichton

Various minor cleanups to rustbuild

This is work I did before the migration to the new rustbuild. I'd prefer to land this first, before my other PR, to make the diff a little clearer.

r? @alexcrichton

7 years agoRollup merge of #43041 - andersk:dedup_by, r=alexcrichton
Mark Simulacrum [Tue, 4 Jul 2017 13:41:42 +0000 (07:41 -0600)]
Rollup merge of #43041 - andersk:dedup_by, r=alexcrichton

Document unintuitive argument order for Vec::dedup_by relation

When trying to use `dedup_by` to merge some auxiliary information from removed elements into kept elements, I was surprised to observe that `vec.dedup_by(same_bucket)` calls `same_bucket(a, b)` where `b` appears before `a` in the vector, and discards `a` when true is returned.  This argument order is probably a bug, but since it has already been stabilized, I guess we should document it as a feature and move on.

(`Vec::dedup` also uses `==` with this unexpected argument order, but I figure that’s not important since `==` is expected to be symmetric with no side effects.)

7 years agoRollup merge of #42994 - stepancheg:ignore-iml, r=aturon
Mark Simulacrum [Tue, 4 Jul 2017 13:41:41 +0000 (07:41 -0600)]
Rollup merge of #42994 - stepancheg:ignore-iml, r=aturon

Ignore *.iml files

... which are IntelliJ IDEA module files. (`.idea` is IDEA project files.)

7 years agoRollup merge of #42975 - ids1024:symlink2, r=aturon
Mark Simulacrum [Tue, 4 Jul 2017 13:41:40 +0000 (07:41 -0600)]
Rollup merge of #42975 - ids1024:symlink2, r=aturon

redox: symlink and readlink

7 years agoRollup merge of #42836 - rthomas:29355-debug, r=GuillaumeGomez
Mark Simulacrum [Tue, 4 Jul 2017 13:41:39 +0000 (07:41 -0600)]
Rollup merge of #42836 - rthomas:29355-debug, r=GuillaumeGomez

Update docs for Debug* structs. #29355

This adds docs for the Debug* structs as well as examples from the
Formatter::debug_* methods, so that a user knows how to construct them.

I added these examples as the builders module is not public and hence
the debug_*_new() functions are not available to a user.

r? @steveklabnik

7 years agoRollup merge of #42227 - ollie27:into_to_from, r=aturon
Mark Simulacrum [Tue, 4 Jul 2017 13:41:33 +0000 (07:41 -0600)]
Rollup merge of #42227 - ollie27:into_to_from, r=aturon

Convert Intos to Froms.

This is a resubmission of #42129 without `impl<T> From<Vec<T>> for Box<[T]>`.

7 years agoUse build.build instead of build.config.build
Mark Simulacrum [Tue, 27 Jun 2017 21:59:43 +0000 (15:59 -0600)]
Use build.build instead of build.config.build

7 years agoMove targets, hosts, and build triple into Build.
Mark Simulacrum [Tue, 27 Jun 2017 21:52:46 +0000 (15:52 -0600)]
Move targets, hosts, and build triple into Build.

7 years agoStore verbosity on Build
Mark Simulacrum [Tue, 27 Jun 2017 19:49:21 +0000 (13:49 -0600)]
Store verbosity on Build

Prevents accidental mistakes in not using the right verbosity by going
to only config or flags.

7 years agoStore positive instead of negative fail_fast.
Mark Simulacrum [Tue, 27 Jun 2017 19:37:24 +0000 (13:37 -0600)]
Store positive instead of negative fail_fast.

This makes later negation much easier to interpret.

7 years agoRemove src_is_git, instead call method on rust_info directly.
Mark Simulacrum [Tue, 27 Jun 2017 19:34:26 +0000 (13:34 -0600)]
Remove src_is_git, instead call method on rust_info directly.

7 years agoClarify meaning of Build.cargo, Build.rustc.
Mark Simulacrum [Tue, 27 Jun 2017 19:32:04 +0000 (13:32 -0600)]
Clarify meaning of Build.cargo, Build.rustc.

Rename Build.{cargo, rustc} to {initial_cargo, initial_rustc}.

7 years agoUpdate a few comments.
Mark Simulacrum [Tue, 27 Jun 2017 19:24:37 +0000 (13:24 -0600)]
Update a few comments.

7 years agoClippy lints
Mark Simulacrum [Tue, 27 Jun 2017 15:51:26 +0000 (09:51 -0600)]
Clippy lints

7 years agoCleanup dist
Mark Simulacrum [Tue, 27 Jun 2017 15:05:47 +0000 (09:05 -0600)]
Cleanup dist

7 years agoCleanup utils
Mark Simulacrum [Tue, 27 Jun 2017 15:05:40 +0000 (09:05 -0600)]
Cleanup utils

7 years agoCleanup compile.rs.
Mark Simulacrum [Tue, 27 Jun 2017 00:13:10 +0000 (18:13 -0600)]
Cleanup compile.rs.

7 years agoCleanups to check code.
Mark Simulacrum [Mon, 26 Jun 2017 16:23:50 +0000 (10:23 -0600)]
Cleanups to check code.

7 years agoRemove 'static lifetimes from channels.
Mark Simulacrum [Sat, 24 Jun 2017 11:42:38 +0000 (05:42 -0600)]
Remove 'static lifetimes from channels.

7 years agoClean up and restructure sanity checking.
Mark Simulacrum [Wed, 21 Jun 2017 23:03:14 +0000 (17:03 -0600)]
Clean up and restructure sanity checking.

7 years agoDon't allocate args in order to run find.
Mark Simulacrum [Wed, 21 Jun 2017 17:15:49 +0000 (11:15 -0600)]
Don't allocate args in order to run find.

7 years agoAuto merge of #43025 - est31:nan_cross_platform, r=BurntSushi
bors [Tue, 4 Jul 2017 13:21:20 +0000 (13:21 +0000)]
Auto merge of #43025 - est31:nan_cross_platform, r=BurntSushi

Make sNaN removal code tolerate different sNaN encodings

IEEE 754-1985 specifies the encoding of NaN floating point numbers,
but while it mentions that NaNs can be subdivided into signaling
and quiet ones, it doesn't fix the encoding of signaling NaNs in binary
formats. This led to different implementations (CPUs) having different
encodings. IEEE 754-2008 finally specified the encoding of signaling NaNs
but some architectures are compatible with it, while others aren't.
Certain MIPS and PA-RISC CPUs have different encodings for signaling
NaNs.

In order to have the float <-> binary cast feature of the std library be
portable to them, we don't mask any quiet NaNs like we did before (only
being compliant to IEEE 754-2008 and nothing else), but instead we
simply pass a known good NaN instead.

Note that in the code removed there was a bug; the 64 bit mask for quiet
NaNs should have been `0x0008000000000000` instead of the specified
`0x0001000000000000`.

7 years agoMinor fix in docs for Vec
Stjepan Glavina [Tue, 4 Jul 2017 13:14:08 +0000 (15:14 +0200)]
Minor fix in docs for Vec

7 years agoAuto merge of #43012 - scottmcm:delete-range-step-by, r=alexcrichton
bors [Tue, 4 Jul 2017 04:49:59 +0000 (04:49 +0000)]
Auto merge of #43012 - scottmcm:delete-range-step-by, r=alexcrichton

Delete deprecated & unstable range-specific `step_by`

Using the new one is annoying while this one exists, since the inherent method hides the one on iterator.

Tracking issue: #27741
Replacement: #41439
Deprecation: #42310 for 1.19
Fixes #41477

7 years agoREADME: note how to enable debugging for rustc
Lee Bousfield [Tue, 4 Jul 2017 02:04:57 +0000 (22:04 -0400)]
README: note how to enable debugging for rustc

7 years agoAuto merge of #42993 - stepancheg:editorconfig, r=brson
bors [Tue, 4 Jul 2017 01:08:15 +0000 (01:08 +0000)]
Auto merge of #42993 - stepancheg:editorconfig, r=brson

Add .editorconfig to src/rustllvm

... which uses 2 space indent instead of common 4 spaces.

7 years agoAdd a stability marker for core::cmp::Reverse.0
Steven Fackler [Mon, 3 Jul 2017 23:46:37 +0000 (13:46 -1000)]
Add a stability marker for core::cmp::Reverse.0

Closes #43027

7 years agoDocument unintuitive argument order for Vec::dedup_by relation
Anders Kaseorg [Mon, 3 Jul 2017 21:18:01 +0000 (17:18 -0400)]
Document unintuitive argument order for Vec::dedup_by relation

When trying to use dedup_by to merge some auxiliary information from
removed elements into kept elements, I was surprised to observe that
vec.dedup_by(same_bucket) calls same_bucket(a, b) where b appears
before a in the vector, and discards a when true is returned.  This
argument order is probably a bug, but since it has already been
stabilized, I guess we should document it as a feature and move on.

(Vec::dedup also uses == with this unexpected argument order, but I
figure that’s not important since == is expected to be symmetric with
no side effects.)

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
7 years agoMake sNaN removal code tolerate different sNaN encodings
est31 [Mon, 3 Jul 2017 14:16:45 +0000 (16:16 +0200)]
Make sNaN removal code tolerate different sNaN encodings

IEEE 754-1985 specifies the encoding of NaN floating point numbers,
but while it mentions that NaNs can be subdivided into signaling
and quiet ones, it doesn't fix the encoding of signaling NaNs in binary
formats. This led to different implementations (CPUs) having different
encodings. IEEE 754-2008 finally specified the encoding of signaling NaNs
but some architectures are compatible with it, while others aren't.
Certain MIPS and PA-RISC CPUs have different encodings for signaling
NaNs.

In order to have the float <-> binary cast feature of the std library be
portable to them, we don't mask any quiet NaNs like we did before (only
being compliant to IEEE 754-2008 and nothing else), but instead we
simply pass a known good NaN instead.

Note that in the code removed there was a bug; the 64 bit mask for quiet
NaNs should have been `0x0008000000000000` instead of the specified
`0x0001000000000000`.

7 years agoAuto merge of #42999 - behnam:ucd10, r=alexcrichton
bors [Mon, 3 Jul 2017 17:00:17 +0000 (17:00 +0000)]
Auto merge of #42999 - behnam:ucd10, r=alexcrichton

[libstd_unicode] Upgrade to Unicode 10.0.0

Update `libstd_unicode`'s data tables to Unicode 10.0.0, as released on 2017 June 20: http://www.unicode.org/versions/Unicode10.0.0/

7 years agoAuto merge of #42976 - ids1024:redoxfix, r=sfackler
bors [Mon, 3 Jul 2017 12:20:57 +0000 (12:20 +0000)]
Auto merge of #42976 - ids1024:redoxfix, r=sfackler

Fix Redox build, apparently broken by #42687

7 years agoremove isatty dependency
Cengiz Can [Mon, 3 Jul 2017 08:46:12 +0000 (11:46 +0300)]
remove isatty dependency

7 years agouse single line comments
Cengiz Can [Mon, 3 Jul 2017 08:45:31 +0000 (11:45 +0300)]
use single line comments

7 years agouse embedded implementation instead of istty crate
Cengiz Can [Sun, 2 Jul 2017 22:34:25 +0000 (01:34 +0300)]
use embedded implementation instead of istty crate

7 years agodo not spawn pager if not tty
Cengiz Can [Sun, 2 Jul 2017 20:27:10 +0000 (23:27 +0300)]
do not spawn pager if not tty