Commit graph

69401 commits

Author SHA1 Message Date
Ariel Ben-Yehuda
48655ea661 add a bunch of debug logging to transform::inline 2017-11-09 23:03:41 +02:00
bors
6e2977499b Auto merge of #45866 - JohnColanduoni:issue-45731, r=alexcrichton
Disable `mmap`  in `libbacktrace` on Apple platforms

Fixes #45731

libbacktrace uses mmap if available to map ranges of the files containing debug information. On macOS `mmap` will succeed even if the mapped range does not exist, and a SIGBUS (with an unusual EXC_BAD_ACCESS code 10) will occur when the program attempts to page in the memory. To combat this we force `libbacktrace` to be built with the simple `read` based fallback on Apple platforms.
2017-11-08 14:54:03 +00:00
bors
4bb96f6519 Auto merge of #45575 - michaelwoerister:tweak-inline-trans-items, r=nikomatsakis
Only instantiate inline- and const-fns if they are referenced (again).

It seems that we have regressed on not translating `#[inline]` functions unless they are actually used. This should bring back this optimization. I also added a regression test this time so it doesn't happen again accidentally.

Fixes #40392.

r? @alexcrichton

UPDATE & PSA
---------------------
This patch **makes translation very lazy** -- in general this is a good thing (we don't want the compiler to do unnecessary work) but it has two consequences:
1. Some error messages are only generated when an item is actually translated. Consequently, this patch will lead to more cases where the compiler will only start emitting errors when the erroneous function is actually used. This has always been true to some extend (e.g. when passing generic values to an intrinsic) but since this is something user-facing it's worth mentioning.
2. When writing tests, one has to make sure that the functions in question are actually generated. In other words, it must not be dead code. This can usually  be achieved by either
    1. making sure the function is exported from the resulting binary or
    2. by making sure the function is called from something that is exported (or `main()`).

Note that it depends on the crate type what functions are exported:
   1. For rlibs and dylibs everything that is reachable from the outside is exported.
   2. For executables, cdylibs, and staticlibs, items are only exported if they are additionally `#[no_mangle]` or have an `#[export_name]`.

The commits in this PR contain many examples of how tests can be updated to comply to the new requirements.
2017-11-08 12:23:34 +00:00
John Colanduoni
8581b59fb3 Disable mmap in libbacktrace on Apple platforms
Fixes #45731

libbacktrace uses mmap if available to map ranges of the files containing debug information. On macOS `mmap` will succeed even if the mapped range does not exist, and a SIGBUS (with an unusual EXC_BAD_ACCESS code 10) will occur when the program attempts to page in the memory. To combat this we force `libbacktrace` to be built with the simple `read` based fallback on Apple platforms.
2017-11-08 02:28:17 -08:00
Michael Woerister
081ef8ed75 Update fastcall-inreg codegen test so that functions actually get instantiated. 2017-11-08 11:09:48 +01:00
bors
f733f484f8 Auto merge of #45862 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 4 pull requests

- Successful merges: #45582, #45766, #45830, #45849
- Failed merges:
2017-11-08 09:43:27 +00:00
Guillaume Gomez
661c507a2e Rollup merge of #45849 - GuillaumeGomez:more-shortcut, r=QuietMisdreavus
Add "-" shortcut

Fixes #45847.

r? @Havvy
2017-11-08 10:09:18 +01:00
Guillaume Gomez
6392a164f0 Rollup merge of #45830 - pornel:dosglobs, r=dtolnay
Warn about lack of args glob expansion in Windows shell

Because all shells on Linux/macOS expand globs, and even MinGW on Windows emulates this behavior, it's easy to forget that Windows by itself doesn't support glob expansion. This PR documents this cross-platform difference.
2017-11-08 10:09:17 +01:00
Guillaume Gomez
1db95a2354 Rollup merge of #45766 - GuillaumeGomez:trait-methods-list, r=QuietMisdreavus
Add more elements in the sidebar

Fixes #45740.

r? @rust-lang/docs
2017-11-08 10:09:16 +01:00
Guillaume Gomez
0f6e0107c3 Rollup merge of #45582 - GuillaumeGomez:doc-unix-missing-links, r=frewsxcv
Add missing links and examples

r? @rust-lang/docs
2017-11-08 10:09:15 +01:00
bors
49bee9d09a Auto merge of #45735 - tirr-c:issue-45730, r=arielb1
Forbid casting to/from a pointer of unknown kind

Fixes #45730.

Before, it ICE'd when `pointer_kind` encountered `TyInfer`.
2017-11-08 07:12:15 +00:00
bors
e177df3d5c Auto merge of #45379 - cuviper:unit_from_iter, r=alexcrichton
impl FromIterator<()> for ()

This just collapses all unit items from an iterator into one.  This is
more useful when combined with higher-level abstractions, like
collecting to a `Result<(), E>` where you only care about errors:

```rust
use std::io::*;
data = vec![1, 2, 3, 4, 5];
let res: Result<()> = data.iter()
    .map(|x| writeln!(stdout(), "{}", x))
    .collect();
assert!(res.is_ok());
```
2017-11-08 01:32:12 +00:00
Guillaume Gomez
ac398a33a9 Add more elements in the sidebar 2017-11-07 23:45:06 +01:00
Guillaume Gomez
5e116985eb Add "-" shortcut 2017-11-07 22:44:18 +01:00
bors
ee2286149a Auto merge of #44932 - cuviper:unsized-ptr-is_null, r=alexcrichton
Remove `T: Sized` on pointer `as_ref()` and `as_mut()`

`NonZero::is_zero()` was already casting all pointers to thin `*mut u8` to check for null.  The same test on unsized fat pointers can also be used with `as_ref()` and `as_mut()` to get fat references.

(This PR formerly changed `is_null()` too, but checking just the data pointer is not obviously correct for trait objects, especially if `*const self` sorts of methods are ever allowed.)
2017-11-07 20:55:01 +00:00
Guillaume Gomez
cef0573734 Add missing links and examples 2017-11-07 20:42:26 +01:00
bors
7f6417e9b7 Auto merge of #45822 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests

- Successful merges: #45470, #45588, #45682, #45714, #45751, #45764, #45778, #45782, #45784
- Failed merges:
2017-11-07 18:04:33 +00:00
Kornel
53de42e333 Warn about non-portability of glob patterns 2017-11-07 17:01:56 +00:00
Michael Woerister
d141abfda7 Always treat #[rustc_std_internal_symbol]s as root TransItems. 2017-11-07 16:41:42 +01:00
kennytm
0d53ecd0c7
Rollup merge of #45784 - harpocrates:fix/print-parens-cast-lt, r=kennytm
Pretty print parens around casts on the LHS of `<`/`<<`

When pretty printing a cast expression occuring on the LHS of a `<` or `<<` expression, we should add parens around the cast. Otherwise, the `<`/`<<` gets interpreted as the beginning of the generics for the type on the RHS of the cast.

Consider:

    $ cat parens_cast.rs
    macro_rules! negative {
        ($e:expr) => { $e < 0 }
    }

    fn main() {
        negative!(1 as i32);
    }

Before this PR, the output of the following is not valid Rust:

    $ rustc -Z unstable-options --pretty=expanded parens_cast.rs
    #![feature(prelude_import)]
    #![no_std]
    #[prelude_import]
    use std::prelude::v1::*;
    #[macro_use]
    extern crate std as std;
    macro_rules! negative(( $ e : expr ) => { $ e < 0 });

    fn main() { 1 as i32 < 0; }

After this PR, the output of the following is valid Rust:

    $ rustc -Z unstable-options --pretty=expanded parens_cast.rs
    #![feature(prelude_import)]
    #![no_std]
    #[prelude_import]
    use std::prelude::v1::*;
    #[macro_use]
    extern crate std as std;
    macro_rules! negative(( $ e : expr ) => { $ e < 0 });

    fn main() { (1 as i32) < 0; }

I've gone through several README/wiki style documents but I'm still not sure where to test this though. I'm not even sure if this sort of thing is tested...
2017-11-07 22:40:20 +08:00
kennytm
1683b830a8
Rollup merge of #45782 - frewsxcv:frewsxcv-shorthands-helpers, r=manishearth
Display all emission types in error msg if user inputs invalid option.

before:

```
> rustc --emit foo
error: unknown emission type: `foo`
```

after:

```
> rustc --emit foo
error: unknown emission type: `foo` - expected one of: `llvm-bc`, `asm`, `llvm-ir`, `mir`, `obj`, `metadata`, `link`, `dep-info`
```
2017-11-07 22:40:19 +08:00
kennytm
6c8a2f659e
Rollup merge of #45778 - Havvy:patch-1, r=steveklabnik
Update reference link in doc's 404

It's currently linking to a page that says it's on the page I'm changing the link too.
2017-11-07 22:40:17 +08:00
kennytm
4b2a5da8c9
Rollup merge of #45764 - QuietMisdreavus:rustdoc-doctest-lints, r=GuillaumeGomez
rustdoc: add #[allow(unused)] to every doctest

More information in #45750 - this is behavior that was documented but not actually implemented.

I also reordered how outer attributes are applied to doctests. Previously, attributes from `#![doc(test(attr(...)))]` would be applied *after* attributes from within the test itself, meaning if a doctest tried to override lints that would be set crate-wide, it wouldn't work at all. This gives a better scope of how lints can be applied.

Closes #45750
2017-11-07 22:40:16 +08:00
kennytm
d8238e4314
Rollup merge of #45751 - estebank:issue-44684, r=nikomatsakis
Handle anon lifetime arg being returned with named lifetime return type

When there's a lifetime mismatch between an argument with an anonymous
lifetime being returned in a method with a return type that has a named
lifetime, show specialized lifetime error pointing at argument with a
hint to give it an explicit lifetime matching the return type.

```
error[E0621]: explicit lifetime required in the type of `other`
  --> file2.rs:21:21
   |
17 |     fn bar(&self, other: Foo) -> Foo<'a> {
   |                   ----- consider changing the type of `other` to `Foo<'a>`
...
21 |                     other
   |                     ^^^^^ lifetime `'a` required
```

Follow up to #44124 and #42669. Fix #44684.
2017-11-07 22:40:15 +08:00
kennytm
264bfc418c
Rollup merge of #45714 - sdroege:thread-panic-docs, r=dtolnay
Update the std::thread docs and clarify that panics can nowadays be caught
2017-11-07 22:40:13 +08:00
kennytm
eae36714df
Rollup merge of #45682 - RalfJung:rwlock-guards, r=alexcrichton
RwLock guards are Sync if T is

Currently, the compiler requires `T` to also be `Send`.  There is no reason for
that.  `&Rw{Read,Write}LockGuard` only provides a shared referenced to `T`, sending
that across threads is safe if `T` is `Sync`.

Cc @oconnor663
2017-11-07 22:40:12 +08:00
kennytm
843dc4bd76
Rollup merge of #45588 - Keruspe:master, r=alexcrichton
rustbuild: don't try to install rls if ToolState is not Testing

We already do that for the Dist Step so we would end up trying to install something that we didn't dist.
2017-11-07 22:40:11 +08:00
kennytm
8074361f46
Rollup merge of #45470 - GuillaumeGomez:unix-metadata-ext, r=QuietMisdreavus
add missing docs for MetadataExt

r? @rust-lang/docs
2017-11-07 22:40:09 +08:00
bors
7ade24f672 Auto merge of #45666 - Amanieu:tls-model, r=alexcrichton
Allow overriding the TLS model

This PR adds the ability to override the default "global-dynamic" TLS model with a more specific one through a target json option or a command-line option. This allows for better code generation in certain situations.

This is similar to the `-ftls-model=` option in GCC and Clang.
2017-11-07 14:24:15 +00:00
Michael Woerister
8fcf3e33e4 Fix some rebasing fallout. 2017-11-07 08:54:38 +01:00
Michael Woerister
e546fea0a1 Don't duplicate logic of when an Instance requests to be inlined. 2017-11-07 08:54:38 +01:00
Michael Woerister
48a8d23b97 Update run-make tests. 2017-11-07 08:54:38 +01:00
Michael Woerister
7d774c4214 Update mir-opt tests. 2017-11-07 08:54:38 +01:00
Michael Woerister
55c3b8ec66 Update compile-fail tests. 2017-11-07 08:54:38 +01:00
Michael Woerister
9fd4be9c2e Update codegen tests. 2017-11-07 08:54:38 +01:00
Michael Woerister
cedae73c8c Fix incremental tests after change to instantiation strategy. 2017-11-07 08:54:38 +01:00
Michael Woerister
6a3659427e incr.comp.: Improve error message for unknown fingerprint. 2017-11-07 08:54:38 +01:00
Michael Woerister
6c1529b34f Update invalid inline arg test. 2017-11-07 08:54:38 +01:00
Michael Woerister
6ae60ea94e Add regression tests for non-instantiation of inline and const fns. 2017-11-07 08:54:38 +01:00
Michael Woerister
7bb9353dd5 Update codegen-unit tests. 2017-11-07 08:54:38 +01:00
Michael Woerister
b61ee5180c Fix translation item collection for inline and const fns. 2017-11-07 08:54:38 +01:00
bors
3e7f501991 Auto merge of #45620 - ollie27:rustdoc_impl_generic_dupe, r=QuietMisdreavus
rustdoc: Fix duplicated impls with generics

The same type can appear multiple times in impls so we need to use a set
to avoid adding it multiple times.

Fixes: #45584
2017-11-07 07:24:13 +00:00
Alec Theriault
aa38a1ee50 Update comments in cast-lt.pp 2017-11-06 22:18:14 -08:00
Esteban Küber
805333b2b5 review comments 2017-11-06 21:02:31 -08:00
bors
a17e72462f Auto merge of #45571 - zackmdavis:regenerate_char_private, r=alexcrichton
regenerate libcore/char_private.rs

(filed separately from the work in #45569, because of this matter of the updated Unicode data; see also #45567)

char_private.rs is generated programmatically by char_private.py, using data retrieved from the Unicode Consortium's website.

The motivation here was to make `is_printable` crate-visible (with `pub(crate)`), but it would seem that the Unicode data has changed slightly since char_private.rs was last generated.
2017-11-07 02:07:34 +00:00
Corey Farwell
c3ea358121 Display all emission types in error msg if user inputs invalid option.
before:

```
> rustc --emit foo
error: unknown emission type: `foo`
```

after:

```
> rustc --emit foo
error: unknown emission type: `foo` - expected one of: `llvm-bc`, `asm`, `llvm-ir`, `mir`, `obj`, `metadata`, `link`, `dep-info`
```
2017-11-06 20:36:48 -05:00
bors
785643a5eb Auto merge of #45668 - nikomatsakis:nll-free-region, r=arielb1
extend NLL with preliminary support for free regions on functions

This PR extends https://github.com/rust-lang/rust/pull/45538 with support for free regions. This is pretty preliminary and will no doubt want to change in various ways, particularly as we add support for closures, but it's enough to get the basic idea in place:

- We now create specific regions to represent each named lifetime declared on the function.
- Region values can contain references to these regions (represented for now as a `BTreeSet<RegionIndex>`).
- If we wind up trying to infer that `'a: 'b` must hold, but no such relationship was declared, we report an error.

It also does a number of drive-by refactorings.

r? @arielb1

cc @spastorino
2017-11-06 23:30:57 +00:00
Amanieu d'Antras
fdf7ba2ce9 Move tls-model to a -Z option since it is unstable 2017-11-06 21:10:49 +00:00
bors
bd0e45a323 Auto merge of #45811 - DSpeckhals:update-rustfmt-rls, r=nikomatsakis
tools: Fix rustfmt and the RLS

These tools have been corrected in their upstream repo's, and the submodules have been updated here to reflect that. I also had to update Cargo to match what the RLS is expecting.

The tool states for `rustfmt` and `rls` where both changed from "Broken" to "Testing" in this commit, thus enabling testing and distribution again.
2017-11-06 20:43:46 +00:00
bors
dbe8055f5a Auto merge of #45322 - infinity0:master, r=alexcrichton
When cross-compiling, also build target-arch tarballs for libstd. (Closes: #42320)

Half of the logic is actually in there already in install.rs:install_std but it fails with an error like:

sh: 0: Can't open /<<BUILDDIR>>/rustc-1.21.0+dfsg1/build/tmp/dist/rust-std-1.21.0-powerpc64le-unknown-linux-gnu/install.sh

because the target-arch dist tarball wasn't built as well. This commit fixes that so the overall install works.

There is one minor bug in the existing code which this commit doesn't fix - the install.log from multiple runs of the installer gets clobbered, which seems like it might interfere with the uninstall process (I didn't look very deeply into this, because it doesn't affect what I need to do.) The actual installed files under DESTDIR seem fine though - either they are installed under an arch-specific path, or the multiple runs will clobber the same path with the same arch-independent file.
2017-11-06 18:04:13 +00:00