Commit graph

65497 commits

Author SHA1 Message Date
Alex Crichton
b8b4f5698d Update compiler_builtins submodule for probestack fix
Closes #43102
2017-07-07 21:11:35 -07:00
bors
703341051d 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.
2017-07-07 12:54:46 +00:00
bors
70412af285 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
2017-07-07 10:37:38 +00:00
Vadim Petrochenkov
4323877e92 syntax: Apply recovery for casts to type ascription
Fix spans, add some comments
2017-07-07 11:53:12 +03:00
Vadim Petrochenkov
5fa1c1b5f3 Fix spans for binary operator expression with interpolated identifiers 2017-07-07 11:21:57 +03:00
bors
33e353ea51 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
2017-07-07 08:13:20 +00:00
bors
24fc541e7c 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
2017-07-07 06:01:30 +00:00
bors
54e3fe7af0 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
2017-07-07 03:43:14 +00:00
Steven Fackler
8c92da3c51 Implement TcpStream::connect_timeout
This breaks the "single syscall rule", but it's really annoying to hand
write and is pretty foundational.
2017-07-06 19:35:49 -07:00
bors
b80b659d67 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
2017-07-07 01:32:13 +00:00
petrochenkov
a27f8cf8a3 Address review comments
Fix regressions after rebase
2017-07-07 01:22:48 +03:00
bors
d2ebb12a1d 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.
2017-07-06 22:22:21 +00:00
Aidan Hobson Sayers
4bd27fc21b Privileged in docker run isn't necessary 2017-07-06 23:16:12 +01:00
Esteban Küber
697c85a4f1 Only underline suggestion if it is not the only code being shown 2017-07-06 14:36:49 -07:00
Esteban Küber
eb478e2381 Add extra whitespace for suggestions 2017-07-06 14:36:48 -07:00
Esteban Küber
7c84914635 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.
2017-07-06 14:36:48 -07:00
Vadim Petrochenkov
08a1d45818 Check adjustments and node substs
Cleanup checking of inherent static methods and fix checking of inherent associated constants
Add more tests
2017-07-06 23:50:02 +03:00
Vadim Petrochenkov
85fb9e0d91 Check types for privacy 2017-07-06 23:50:02 +03:00
bors
696412de7e 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
2017-07-06 19:56:55 +00:00
Ryan Thomas
c7fc6db68a Add annotations to the resize fn #39791
This adds the `inline(never)` and `cold` annotations to the
HashMap::resize function.
2017-07-06 20:32:47 +01:00
Aidan Hobson Sayers
7c8523e87b Retry downloading llvm commit tarball 2017-07-06 18:55:07 +01:00
bors
cd72f2e269 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.
2017-07-06 17:15:14 +00:00
Alex Crichton
5dbd97de3d 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.
2017-07-06 08:58:19 -07:00
Oliver Middleton
1966a6798d rustdoc: Don't run Markdown tests twice
This matches the behaviour for finding tests in Rust files.
2017-07-06 16:47:58 +01:00
bors
54fc9e4ea5 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.
2017-07-06 14:46:13 +00:00
bors
ccf401f8f7 Auto merge of #43078 - kennytm:fix-42755-vis-can-be-empty, r=petrochenkov
Disallow `$($v:vis)*`. Fix #42755.

#42755
2017-07-06 11:28:32 +00:00
Kornel
1297b2d952 Suggest rustup toolchain link 2017-07-06 12:26:34 +01:00
kennytm
06e1fc06d7
Disallow $($v:vis)*. Fix #42755. 2017-07-06 18:24:36 +08:00
bors
afb853a3d7 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,`)
2017-07-06 07:49:44 +00:00
Zack M. Davis
f668999153 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.
2017-07-05 22:37:10 -07:00
bors
7f1c4beb68 Auto merge of #43001 - estebank:try-on-unimplemented, r=aturon
Add `rustc_on_unimplemented` message to `std::ops::Try`

#42694, #35946.
2017-07-06 05:29:09 +00:00
Esteban Küber
d71caadee2 Add rustc_on_unimplemented message to std::ops::Try 2017-07-05 22:28:35 -07:00
bors
8cab2c73d4 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.
2017-07-06 02:34:29 +00:00
bors
1685c92986 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
2017-07-06 00:16:16 +00:00
Alex Crichton
695dee063b 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
2017-07-05 14:37:01 -07:00
bors
4d526e0d14 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](20a90485c0) and [declarative macros 2.0](https://github.com/rust-lang/rust/pull/40847).

r? @nrc
2017-07-05 21:16:34 +00:00
Alex Crichton
78fdbfc400 rustbuild: Only -Zsave-analysis for libstd
Don't pass the flag when we're compiling the compiler or other related tools
2017-07-05 13:51:34 -07:00
Alex Crichton
fd95db25b3 Merge remote-tracking branch 'origin/master' into proc_macro_api 2017-07-05 08:42:13 -07:00
Alex Crichton
7e6c9f3635 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.
2017-07-05 07:08:36 -07:00
bors
3610a70ce4 Auto merge of #42972 - GuillaumeGomez:fix-toggles-rustdoc, r=QuietMisdreavus
Toggle wrappers are now generated correctly

Fixes #42674.
2017-07-05 13:56:32 +00:00
bors
692b572236 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>`.
2017-07-05 02:04:07 +00:00
bors
1421bedd51 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
2017-07-04 23:50:11 +00:00
bors
2fbba5bdba 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:
2017-07-04 15:58:24 +00:00
Mark Simulacrum
9cca462ca5 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.
2017-07-04 07:41:45 -06:00
Mark Simulacrum
f80e58af89 Rollup merge of #43043 - sfackler:reverse-stability, r=Mark-Simulacrum
Add a stability marker for core::cmp::Reverse.0

Closes #43027
2017-07-04 07:41:44 -06:00
Mark Simulacrum
edbfbbfdd8 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
2017-07-04 07:41:43 -06:00
Mark Simulacrum
5f732eba7a 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.)
2017-07-04 07:41:42 -06:00
Mark Simulacrum
2fdb9c978d Rollup merge of #42994 - stepancheg:ignore-iml, r=aturon
Ignore *.iml files

... which are IntelliJ IDEA module files. (`.idea` is IDEA project files.)
2017-07-04 07:41:41 -06:00
Mark Simulacrum
8abc58e6b9 Rollup merge of #42975 - ids1024:symlink2, r=aturon
redox: symlink and readlink
2017-07-04 07:41:40 -06:00
Mark Simulacrum
93e46a95a4 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
2017-07-04 07:41:39 -06:00