]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoBox::leak - relaxed constraints wrt. lifetimes
Mazdak [Thu, 9 Nov 2017 22:25:32 +0000 (23:25 +0100)]
Box::leak - relaxed constraints wrt. lifetimes

6 years agoBox::leak - fixed bug in documentation
Mazdak [Wed, 8 Nov 2017 23:15:07 +0000 (00:15 +0100)]
Box::leak - fixed bug in documentation

6 years agoBox::leak - improve documentation
Mazdak [Wed, 8 Nov 2017 22:59:35 +0000 (23:59 +0100)]
Box::leak - improve documentation

6 years agoadded associated function Box::leak
Mazdak [Wed, 8 Nov 2017 22:10:33 +0000 (23:10 +0100)]
added associated function Box::leak

6 years agoAuto merge of #45205 - rkruppe:saturating-casts, r=eddyb
bors [Wed, 8 Nov 2017 17:27:56 +0000 (17:27 +0000)]
Auto merge of #45205 - rkruppe:saturating-casts, r=eddyb

Saturating casts between integers and floats

Introduces a new flag, `-Z saturating-float-casts`, which makes code generation for int->float and float->int casts safe (`undef`-free), implementing [the saturating semantics laid out by](https://github.com/rust-lang/rust/issues/10184#issuecomment-299229143) @jorendorff for float->int casts and overflowing to infinity for `u128::MAX` -> `f32`.
Constant evaluation in trans was changed to behave like HIR const eval already did, i.e., saturate for u128->f32 and report an error for problematic float->int casts.

Many thanks to @eddyb, whose APFloat port simplified many parts of this patch, and made HIR constant evaluation recognize dangerous float casts as mentioned above.
Also thanks to @ActuallyaDeviloper whose branchless implementation served as inspiration for this implementation.

cc #10184 #41799
fixes #45134

6 years agoAuto merge of #45866 - JohnColanduoni:issue-45731, r=alexcrichton
bors [Wed, 8 Nov 2017 14:54:03 +0000 (14:54 +0000)]
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.

6 years agoDisable u128 <-> float tests on emscripten
Robin Kruppe [Wed, 8 Nov 2017 13:54:03 +0000 (14:54 +0100)]
Disable u128 <-> float tests on emscripten

6 years agoAuto merge of #45575 - michaelwoerister:tweak-inline-trans-items, r=nikomatsakis
bors [Wed, 8 Nov 2017 12:23:34 +0000 (12:23 +0000)]
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.

6 years agoDisable `mmap` in `libbacktrace` on Apple platforms
John Colanduoni [Wed, 8 Nov 2017 10:28:17 +0000 (02:28 -0800)]
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.

6 years agoUpdate fastcall-inreg codegen test so that functions actually get instantiated.
Michael Woerister [Wed, 8 Nov 2017 10:09:48 +0000 (11:09 +0100)]
Update fastcall-inreg codegen test so that functions actually get instantiated.

6 years agoAuto merge of #45862 - GuillaumeGomez:rollup, r=GuillaumeGomez
bors [Wed, 8 Nov 2017 09:43:27 +0000 (09:43 +0000)]
Auto merge of #45862 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 4 pull requests

- Successful merges: #45582, #45766, #45830, #45849
- Failed merges:

6 years agoRollup merge of #45849 - GuillaumeGomez:more-shortcut, r=QuietMisdreavus
Guillaume Gomez [Wed, 8 Nov 2017 09:09:18 +0000 (10:09 +0100)]
Rollup merge of #45849 - GuillaumeGomez:more-shortcut, r=QuietMisdreavus

Add "-" shortcut

Fixes #45847.

r? @Havvy

6 years agoRollup merge of #45830 - pornel:dosglobs, r=dtolnay
Guillaume Gomez [Wed, 8 Nov 2017 09:09:17 +0000 (10:09 +0100)]
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.

6 years agoRollup merge of #45766 - GuillaumeGomez:trait-methods-list, r=QuietMisdreavus
Guillaume Gomez [Wed, 8 Nov 2017 09:09:16 +0000 (10:09 +0100)]
Rollup merge of #45766 - GuillaumeGomez:trait-methods-list, r=QuietMisdreavus

Add more elements in the sidebar

Fixes #45740.

r? @rust-lang/docs

6 years agoRollup merge of #45582 - GuillaumeGomez:doc-unix-missing-links, r=frewsxcv
Guillaume Gomez [Wed, 8 Nov 2017 09:09:15 +0000 (10:09 +0100)]
Rollup merge of #45582 - GuillaumeGomez:doc-unix-missing-links, r=frewsxcv

Add missing links and examples

r? @rust-lang/docs

6 years agoAuto merge of #45735 - tirr-c:issue-45730, r=arielb1
bors [Wed, 8 Nov 2017 07:12:15 +0000 (07:12 +0000)]
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`.

6 years agoAuto merge of #45379 - cuviper:unit_from_iter, r=alexcrichton
bors [Wed, 8 Nov 2017 01:32:12 +0000 (01:32 +0000)]
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());
```

6 years agoAdd more elements in the sidebar
Guillaume Gomez [Sat, 4 Nov 2017 19:45:12 +0000 (20:45 +0100)]
Add more elements in the sidebar

6 years agoAdd "-" shortcut
Guillaume Gomez [Tue, 7 Nov 2017 21:44:18 +0000 (22:44 +0100)]
Add "-" shortcut

6 years agoAuto merge of #44932 - cuviper:unsized-ptr-is_null, r=alexcrichton
bors [Tue, 7 Nov 2017 20:55:01 +0000 (20:55 +0000)]
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.)

6 years agoAdd missing links and examples
Guillaume Gomez [Fri, 27 Oct 2017 20:01:50 +0000 (22:01 +0200)]
Add missing links and examples

6 years agoClean up
Robin Kruppe [Sat, 28 Oct 2017 14:43:08 +0000 (16:43 +0200)]
Clean up

6 years agoImplement more efficient saturation
Robin Kruppe [Tue, 17 Oct 2017 14:42:10 +0000 (16:42 +0200)]
Implement more efficient saturation

6 years agoMake trans const eval error on overflow and NaN, matching HIR const eval.
Robin Kruppe [Sun, 15 Oct 2017 20:28:49 +0000 (22:28 +0200)]
Make trans const eval error on overflow and NaN, matching  HIR const eval.

6 years agoExtract (f32::MAX + 0.5 ULP) constant
Robin Kruppe [Sun, 15 Oct 2017 19:37:09 +0000 (21:37 +0200)]
Extract (f32::MAX + 0.5 ULP) constant

6 years agoFix bug in rustc_apfloat
Robin Kruppe [Sun, 15 Oct 2017 18:10:42 +0000 (20:10 +0200)]
Fix bug in rustc_apfloat

6 years agoSaturating casts between integers and floats (both directions).
Robin Kruppe [Mon, 9 Oct 2017 00:14:00 +0000 (02:14 +0200)]
Saturating casts between integers and floats (both directions).

This affects regular code generation as well as constant evaluation in trans,
but not the HIR constant evaluator because that one returns an error for
overflowing casts and NaN-to-int casts. That error is conservatively
correct and we should be careful to not accept more code in constant
expressions.
The changes to code generation are guarded by a new -Z flag, to be able
to evaluate the performance impact. The trans constant evaluation changes
are unconditional because they have no run time impact and don't affect
type checking either.

6 years agoAuto merge of #45822 - kennytm:rollup, r=kennytm
bors [Tue, 7 Nov 2017 18:04:33 +0000 (18:04 +0000)]
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:

6 years agoWarn about non-portability of glob patterns
Kornel [Tue, 7 Nov 2017 12:17:04 +0000 (12:17 +0000)]
Warn about non-portability of glob patterns

6 years agoAlways treat #[rustc_std_internal_symbol]s as root TransItems.
Michael Woerister [Tue, 7 Nov 2017 15:41:42 +0000 (16:41 +0100)]
Always treat #[rustc_std_internal_symbol]s as root TransItems.

6 years agoRollup merge of #45784 - harpocrates:fix/print-parens-cast-lt, r=kennytm
kennytm [Tue, 7 Nov 2017 07:52:15 +0000 (15:52 +0800)]
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...

6 years agoRollup merge of #45782 - frewsxcv:frewsxcv-shorthands-helpers, r=manishearth
kennytm [Tue, 7 Nov 2017 07:52:14 +0000 (15:52 +0800)]
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`
```

6 years agoRollup merge of #45778 - Havvy:patch-1, r=steveklabnik
kennytm [Tue, 7 Nov 2017 07:52:13 +0000 (15:52 +0800)]
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.

6 years agoRollup merge of #45764 - QuietMisdreavus:rustdoc-doctest-lints, r=GuillaumeGomez
kennytm [Tue, 7 Nov 2017 07:52:12 +0000 (15:52 +0800)]
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

6 years agoRollup merge of #45751 - estebank:issue-44684, r=nikomatsakis
kennytm [Tue, 7 Nov 2017 07:52:11 +0000 (15:52 +0800)]
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.

6 years agoRollup merge of #45714 - sdroege:thread-panic-docs, r=dtolnay
kennytm [Tue, 7 Nov 2017 07:52:11 +0000 (15:52 +0800)]
Rollup merge of #45714 - sdroege:thread-panic-docs, r=dtolnay

Update the std::thread docs and clarify that panics can nowadays be caught

6 years agoRollup merge of #45682 - RalfJung:rwlock-guards, r=alexcrichton
kennytm [Tue, 7 Nov 2017 07:52:10 +0000 (15:52 +0800)]
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

6 years agoRollup merge of #45588 - Keruspe:master, r=alexcrichton
kennytm [Tue, 7 Nov 2017 07:52:09 +0000 (15:52 +0800)]
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.

6 years agoRollup merge of #45470 - GuillaumeGomez:unix-metadata-ext, r=QuietMisdreavus
kennytm [Tue, 7 Nov 2017 07:52:08 +0000 (15:52 +0800)]
Rollup merge of #45470 - GuillaumeGomez:unix-metadata-ext, r=QuietMisdreavus

add missing docs for MetadataExt

r? @rust-lang/docs

6 years agoAuto merge of #45666 - Amanieu:tls-model, r=alexcrichton
bors [Tue, 7 Nov 2017 14:24:15 +0000 (14:24 +0000)]
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.

6 years agoFix some rebasing fallout.
Michael Woerister [Mon, 6 Nov 2017 09:35:52 +0000 (10:35 +0100)]
Fix some rebasing fallout.

6 years agoDon't duplicate logic of when an Instance requests to be inlined.
Michael Woerister [Mon, 30 Oct 2017 17:49:56 +0000 (18:49 +0100)]
Don't duplicate logic of when an Instance requests to be inlined.

6 years agoUpdate run-make tests.
Michael Woerister [Mon, 30 Oct 2017 17:21:06 +0000 (18:21 +0100)]
Update run-make tests.

6 years agoUpdate mir-opt tests.
Michael Woerister [Mon, 30 Oct 2017 17:20:07 +0000 (18:20 +0100)]
Update mir-opt tests.

6 years agoUpdate compile-fail tests.
Michael Woerister [Mon, 30 Oct 2017 17:19:31 +0000 (18:19 +0100)]
Update compile-fail tests.

6 years agoUpdate codegen tests.
Michael Woerister [Mon, 30 Oct 2017 17:18:00 +0000 (18:18 +0100)]
Update codegen tests.

6 years agoFix incremental tests after change to instantiation strategy.
Michael Woerister [Fri, 27 Oct 2017 16:57:15 +0000 (18:57 +0200)]
Fix incremental tests after change to instantiation strategy.

6 years agoincr.comp.: Improve error message for unknown fingerprint.
Michael Woerister [Fri, 27 Oct 2017 16:56:29 +0000 (18:56 +0200)]
incr.comp.: Improve error message for unknown fingerprint.

6 years agoUpdate invalid inline arg test.
Michael Woerister [Fri, 27 Oct 2017 14:15:23 +0000 (16:15 +0200)]
Update invalid inline arg test.

6 years agoAdd regression tests for non-instantiation of inline and const fns.
Michael Woerister [Fri, 27 Oct 2017 12:32:26 +0000 (14:32 +0200)]
Add regression tests for non-instantiation of inline and const fns.

6 years agoUpdate codegen-unit tests.
Michael Woerister [Fri, 27 Oct 2017 12:31:18 +0000 (14:31 +0200)]
Update codegen-unit tests.

6 years agoFix translation item collection for inline and const fns.
Michael Woerister [Fri, 27 Oct 2017 12:30:34 +0000 (14:30 +0200)]
Fix translation item collection for inline and const fns.

6 years agoAuto merge of #45620 - ollie27:rustdoc_impl_generic_dupe, r=QuietMisdreavus
bors [Tue, 7 Nov 2017 07:24:13 +0000 (07:24 +0000)]
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
6 years agoUpdate comments in cast-lt.pp
Alec Theriault [Tue, 7 Nov 2017 06:18:14 +0000 (22:18 -0800)]
Update comments in cast-lt.pp

6 years agoreview comments
Esteban Küber [Tue, 7 Nov 2017 05:02:31 +0000 (21:02 -0800)]
review comments

6 years agoAuto merge of #45571 - zackmdavis:regenerate_char_private, r=alexcrichton
bors [Tue, 7 Nov 2017 02:07:34 +0000 (02:07 +0000)]
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.

6 years agoDisplay all emission types in error msg if user inputs invalid option.
Corey Farwell [Sun, 5 Nov 2017 14:20:59 +0000 (09:20 -0500)]
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`
```

6 years agoAuto merge of #45668 - nikomatsakis:nll-free-region, r=arielb1
bors [Mon, 6 Nov 2017 23:30:57 +0000 (23:30 +0000)]
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

6 years agoMove tls-model to a -Z option since it is unstable
Amanieu d'Antras [Mon, 6 Nov 2017 21:10:49 +0000 (21:10 +0000)]
Move tls-model to a -Z option since it is unstable

6 years agoAuto merge of #45811 - DSpeckhals:update-rustfmt-rls, r=nikomatsakis
bors [Mon, 6 Nov 2017 20:43:46 +0000 (20:43 +0000)]
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.

6 years agoAuto merge of #45322 - infinity0:master, r=alexcrichton
bors [Mon, 6 Nov 2017 18:04:13 +0000 (18:04 +0000)]
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.

6 years agotools: Fix rustfmt and the RLS
Dustin Speckhals [Mon, 6 Nov 2017 17:59:33 +0000 (12:59 -0500)]
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.

6 years agoForbid casting to/from a pointer of unknown kind
Wonwoo Choi [Fri, 3 Nov 2017 07:58:01 +0000 (16:58 +0900)]
Forbid casting to/from a pointer of unknown kind

6 years agoAuto merge of #45369 - fintelia:patch-1, r=BurntSushi
bors [Mon, 6 Nov 2017 15:19:48 +0000 (15:19 +0000)]
Auto merge of #45369 - fintelia:patch-1, r=BurntSushi

Implement is_empty() for BufReader

Simple implementation of `is_empty` method for BufReader so it is possible to tell whether there is any data in its buffer.

I didn't know correct stability annotation to place on the function. Presumably there is no reason to place this feature behind a feature flag, but I wasn't sure how to tag it as an unstable feature without that.

CC: #45323
6 years agoAuto merge of #45737 - oli-obk:json, r=petrochenkov
bors [Mon, 6 Nov 2017 12:18:12 +0000 (12:18 +0000)]
Auto merge of #45737 - oli-obk:json, r=petrochenkov

Pretty print json in ui tests

I found the json output in one line to not be useful for reviewing

r? @petrochenkov

6 years agoEnsure dist::Std for every libstd target. (Closes: #42320)
Ximin Luo [Mon, 6 Nov 2017 10:34:18 +0000 (11:34 +0100)]
Ensure dist::Std for every libstd target. (Closes: #42320)

This fixes cross-compile installation. 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.

6 years agoAdjust json errors to byte changes
Oliver Schneider [Mon, 6 Nov 2017 09:34:23 +0000 (10:34 +0100)]
Adjust json errors to byte changes

6 years agoAuto merge of #45798 - nrc:rls-bugs-3, r=eddyb
bors [Mon, 6 Nov 2017 08:48:11 +0000 (08:48 +0000)]
Auto merge of #45798 - nrc:rls-bugs-3, r=eddyb

A couple more save-analysis fixes

r? @eddyb

6 years agoAuto merge of #45758 - nzig:explain-span-ctxt, r=petrochenkov
bors [Mon, 6 Nov 2017 05:16:15 +0000 (05:16 +0000)]
Auto merge of #45758 - nzig:explain-span-ctxt, r=petrochenkov

Add comment explaining the ctxt field in Span

As discussed in #45747.

r? @petrochenkov

6 years agoFix comments
Alec Theriault [Mon, 6 Nov 2017 04:53:46 +0000 (20:53 -0800)]
Fix comments

6 years agosave-analysis: fix bugs in method chains
Nick Cameron [Mon, 6 Nov 2017 02:52:42 +0000 (15:52 +1300)]
save-analysis: fix bugs in method chains

Use the span we save in the PathSegment for a method call, rather than searching for it in the text.

Fixes https://github.com/nrc/rls-analysis/issues/111

6 years agoAuto merge of #45756 - topecongiro:fix-typos/librustc_typeck, r=kennytm
bors [Mon, 6 Nov 2017 02:02:11 +0000 (02:02 +0000)]
Auto merge of #45756 - topecongiro:fix-typos/librustc_typeck, r=kennytm

Fix typos in README.md

This nitpicky PR fixes few typos I found while reading `README.md`s.

6 years agosave-analysis: give better info for Unions
Nick Cameron [Mon, 6 Nov 2017 01:56:43 +0000 (14:56 +1300)]
save-analysis: give better info for Unions

6 years agoAuto merge of #45770 - spastorino:newtype_index, r=nikomatsakis
bors [Sun, 5 Nov 2017 22:06:15 +0000 (22:06 +0000)]
Auto merge of #45770 - spastorino:newtype_index, r=nikomatsakis

Make last structs indexes definitions use newtype_index macro

This PR makes the last two index structs not using newtype_index macro to use it and also fixes this https://github.com/rust-lang/rust/issues/45763 issue.

6 years agoAdded tests
Alec Theriault [Sun, 5 Nov 2017 20:27:46 +0000 (12:27 -0800)]
Added tests

6 years agoAuto merge of #45723 - sinkuu:ice_45493, r=arielb1
bors [Sun, 5 Nov 2017 19:19:59 +0000 (19:19 +0000)]
Auto merge of #45723 - sinkuu:ice_45493, r=arielb1

Fix MIR inlining panic in generic function

MIR inlining calls `Instance::resolve` with a substs containing param, and `trans_apply_param_substs` panics. ~~This PR fixes it by making `Instance::resolve` return `None` if `substs.has_param_types()`, though I'm not sure if this is a right fix.~~

Fixes #45493.

6 years agoHandle anon lifetime arg being returned with named lifetime return type
Esteban Küber [Sat, 4 Nov 2017 00:30:14 +0000 (17:30 -0700)]
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.

6 years agoPretty print parens around casts on the LHS of '<'
Alec Theriault [Sun, 5 Nov 2017 17:28:00 +0000 (09:28 -0800)]
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.

6 years agoAuto merge of #45072 - nikomatsakis:issue-38714, r=arielb1
bors [Sun, 5 Nov 2017 16:49:08 +0000 (16:49 +0000)]
Auto merge of #45072 - nikomatsakis:issue-38714, r=arielb1

new rules for merging expected and supplied types in closure signatures

As uncovered in #38714, we currently have some pretty bogus code for combining the "expected signature" of a closure with the "supplied signature". To set the scene, consider a case like this:

```rust
fn foo<F>(f: F)
where
  F: for<'a> FnOnce(&'a u32) -> &'a u32
  // ^ *expected* signature comes from this where-clause
{
    ...
}

fn main() {
    foo(|x: &u32| -> &u32 { .. }
     // ^^^^^^^^^^^^^^^^^ supplied signature
     // comes from here
}
```

In this case, the supplied signature (a) includes all the parts and (b) is the same as the expected signature, modulo the names used for the regions. But often people supply only *some* parts of the signature. For example, one might write `foo(|x| ..)`, leaving *everything* to be inferred, or perhaps `foo(|x: &u32| ...)`, which leaves the return type to be inferred.

In the current code, we use the expected type to supply the types that are not given, but otherwise use the type the user gave, except for one case: if the user writes `fn foo(|x: _| ..)` (i.e., an underscore at the outermost level), then we will take the expected type (rather than instantiating a fresh type variable). This can result in nonsensical situations, particularly with bound regions that link the types of parameters to one another or to the return type. Consider `foo(|x: &u32| ...)` -- if we *literally* splice the expected return type of `&'a u32` together with what the user gave, we wind up with a signature like `for<'a> fn(&u32) -> &'a u32`. This is not even permitted as a type, because bound regions like `'a` must appear also in the arguments somewhere, which is why #38714 leads to an ICE.

This PR institutes some new rules. These are not meant to be the *final* set of rules, but they are a kind of "lower bar" for what kind of code we accept (i.e., we can extend these rules in the future to be smarter in some cases, but -- as we will see -- these rules do accept some things that we then would not be able to back off from).

These rules are derived from a few premises:

- First and foremost, anonymous regions in closure annotation are mostly requests for the code to "figure out the right lifetime" and shouldn't be read too closely. So for example when people write a closure signature like `|x: &u32|`, they are really intended for us to "figure out" the right region for `x`.
    - In contrast, the current code treats this supplied type as being more definitive. In particular, writing `|x: &u32|` would always result in the region of `x` being bound in the closure type. In other words, the signature would be something like `for<'a> fn(&'a u32)` -- this is derived from the fact that `fn(&u32)` expands to a type where the region is bound in the fn type.
    - This PR takes a different approach. The "binding level" for reference types appearing in closure signatures can be informed in some cases by the expected signature. So, for example, if the expected signature is something like `(&'f u32)`, where the region of the first argument appears free, then for `|x: &u32|`, the new code would infer `x` to also have the free region `'f`.
        - This inference has some limits. We don't do this for bindings that appear within the selected types themselves. So e.g. `|x: fn(&u32)|`, when combined with an expected type of `fn(fn(&'f u32))`, would still result in a closure that expects `for<'a> fn(&'a u32)`. Such an annotation will ultimately result in an error, as it happens, since `foo` is supplying a `fn(&'f u32)` to the closure, but the closure signature demands a `for<'a> fn(&'a u32)`. But still we choose to trust it and have the user change it.
        - I wanted to preserve the rough intuition that one can copy-and-paste a type out of the fn signature and into the fn body without dramatically changing its meaning. Interestingly, if one has `|x: &u32|`, then regardless of whether the region of `x` is bound or free in the closure signature, it is also free in the region body, and that is also true when one writes `let x: &u32`, so that intuition holds here. But the same would not be true for `fn(&u32)`, hence the different behavior.
- Second, we must take either **all** the references to bound regions from the expected type or **none**. The current code, as we saw, will happily take a bound region in the return type but drop the other place where it is used, in the parameters. Since bound regions are all about linking multiple things together, I think it's important not to do that. (That said, we could conceivably be a bit less strict here, since the subtyping rules will get our back, but we definitely don't want any bound regions that appear only in the return type.)
- Finally, we cannot take the bound region names from the supplied types and "intermix" them with the names from the expected types.
    - We *could* potentially do some alpha renaming, but I didn't do that.
- Ultimately, if the types the user supplied do not match expectations in some way that we cannot recover from, we fallback to deriving the closure signature solely from those expected types.
    - For example, if the expected type is `u32` but the user wrote `i32`.
    - Or, more subtle, if the user wrote e.g. `&'x u32` for some named lifetime `'x`, but the expected type includes a bound lifetime (`for<'a> (&'a u32)`). In that case, preferring the type that the user explicitly wrote would hide an appearance of a bound name from the expected type, and we try to never do that.

The detailed rules that I came up with are found in the code, but for ease of reading I've also [excerpted them into a gist](https://gist.github.com/nikomatsakis/e69252a2b57e6d97d044c2f254c177f1). I am not convinced they are correct and would welcome feedback for alternative approaches.

(As an aside, the way I think I would ultimately *prefer* to think about this is that the conversion from HIR types to internal types could be parameterized by an "expected type" that it uses to guide itself. However, since that would be a pain, I opted *in the code* to first instantiate the supplied types as `Ty<'tcx>` and then "merge" those types with the `Ty<'tcx>` from the expected signature.)

I think we should probably FCP this before landing.

cc @rust-lang/lang
r? @arielb1

6 years agoadd #![allow(unused)] to the playground link rustdoc tests
QuietMisdreavus [Sun, 5 Nov 2017 16:24:05 +0000 (10:24 -0600)]
add #![allow(unused)] to the playground link rustdoc tests

6 years agorustdoc: add #[allow(unused)] to every doctest
QuietMisdreavus [Sat, 4 Nov 2017 19:13:44 +0000 (14:13 -0500)]
rustdoc: add #[allow(unused)] to every doctest

also modify the order crate attributes are applied, to have a better
order of how things can override lints, either per-crate or per-test

6 years agoAuto merge of #45759 - alexcrichton:update-openssl, r=sfackler
bors [Sun, 5 Nov 2017 14:18:21 +0000 (14:18 +0000)]
Auto merge of #45759 - alexcrichton:update-openssl, r=sfackler

rustbuild: Update the OpenSSL version to link

This updates the OpenSSL tarball download to reflect OpenSSL's newest release.

6 years agoFix MIR inlining panic in generic function
sinkuu [Sun, 5 Nov 2017 13:57:53 +0000 (22:57 +0900)]
Fix MIR inlining panic in generic function

6 years agoAuto merge of #44042 - LukasKalbertodt:ascii-methods-on-instrinsics, r=alexcrichton
bors [Sun, 5 Nov 2017 11:42:59 +0000 (11:42 +0000)]
Auto merge of #44042 - LukasKalbertodt:ascii-methods-on-instrinsics, r=alexcrichton

Copy all `AsciiExt` methods to the primitive types directly in order to deprecate it later

**EDIT:** [this PR is ready now](https://github.com/rust-lang/rust/pull/44042#issuecomment-333883548). I edited this post to reflect the current status of discussion, which is (apart from code review) pretty much settled.

---

This is my current progress in order to prepare stabilization of #39658. As discussed there (and in #39659), the idea is to deprecated `AsciiExt` and copy all methods to the type directly. Apparently there isn't really a reason to have those methods in an extension trait¹.

~~This is **work in progress**: copy&pasting code while slightly modifying the documentation isn't the most exciting thing to do. Therefore I wanted to already open this WIP PR after doing basically 1/4 of the job (copying methods to `&[u8]`, `char` and `&str` is still missing) to get some feedback before I continue. Some questions possibly worth discussing:~~

1. ~~Does everyone agree that deprecating `AsciiExt` is a good idea? Does everyone agree with the goal of this PR?~~ => apparently yes
2. ~~Are my changes OK so far? Did I do something wrong?~~
3. ~~The issue of the unstable-attribute is currently set to 0. I would wait until you say "Ok" to the whole thing, then create a tracking issue and then insert the correct issue id. Is that ok?~~
4. ~~I tweaked `eq_ignore_ascii_case()`: it now takes the argument `other: u8` instead of `other: &u8`. The latter was enforced by the trait. Since we're not bound to a trait anymore, we can drop the reference, ok?~~ => I reverted this, because the interface has to match the `AsciiExt` interface exactly.

¹ ~~Could it be that we can't write `impl [u8] {}`? This might be the reason for `AsciiExt`. If that is the case: is there a good reason we can't write such an impl block? What can we do instead?~~ => we couldn't at the time this PR was opened, but Simon made it possible.

/cc @SimonSapin @zackw

6 years agoRelax #[deny(warnings)] in some crate for cargotest
Lukas Kalbertodt [Sun, 5 Nov 2017 09:40:06 +0000 (10:40 +0100)]
Relax #[deny(warnings)] in some crate for cargotest

Otherwise changes to the compiler are unable to introduce new
warnings: some crates tested by cargotest deny all warnings and
thus, the CI build fails.

Thanks SimonSapin for the patch!

6 years agoAuto merge of #45754 - scottmcm:checked-npot, r=dtolnay
bors [Sun, 5 Nov 2017 09:11:45 +0000 (09:11 +0000)]
Auto merge of #45754 - scottmcm:checked-npot, r=dtolnay

Fix #18604: next_power_of_two should panic on overflow

Fixes https://github.com/rust-lang/rust/issues/18604

Is it possible to write a test for this?  My experiments showed `x.py test` running in release mode, so my attempt at a `#[should_panic]` didn't work.

6 years agoAuto merge of #45748 - petrochenkov:short, r=alexcrichton
bors [Sun, 5 Nov 2017 06:42:17 +0000 (06:42 +0000)]
Auto merge of #45748 - petrochenkov:short, r=alexcrichton

Shorten paths to auxiliary files created by tests

I'm hitting issues with long file paths to object files created by the test suite, similar to https://github.com/rust-lang/rust/issues/45103#issuecomment-335622075.

If we look at the object file path in https://github.com/rust-lang/rust/issues/45103 we can see that the patch contains of few components:
```
specialization-cross-crate-defaults.stage2-x86_64-pc-windows-gnu.run-pass.libaux\specialization_cross_crate_defaults.specialization_cross_crate_defaults0.rust-cgu.o
```
=>

1. specialization-cross-crate-defaults // test name, required
2. stage2 // stage disambiguator, required
3. x86_64-pc-windows-gnu // target disambiguator, required
4. run-pass // mode disambiguator, rarely required
5. libaux // suffix, can be shortened
6. specialization_cross_crate_defaults // required, there may be several libraries in the directory
7. specialization_cross_crate_defaults0 // codegen unit name, can be shortened?
8. rust-cgu // suffix, can be shortened?
9. o // object file extension

This patch addresses items `4`, `5` and `8`.
`libaux` is shortened to `aux`, `rust-cgu` is shortened to `rcgu`, mode disambiguator is omitted unless it's necessary (for pretty-printing and debuginfo tests, see https://github.com/rust-lang/rust/pull/24537/commits/38d26d811a44ba93637c84ce77a58af88c47f0ac)

I haven't touched names of codegen units though (`specialization_cross_crate_defaults0`).
Is it useful for them to have descriptive names including the crate name, as opposed to just `0` or `cgu0` or something?

6 years agoAuto merge of #45710 - alexcrichton:std-symbols, r=michaelwoerister
bors [Sun, 5 Nov 2017 04:02:07 +0000 (04:02 +0000)]
Auto merge of #45710 - alexcrichton:std-symbols, r=michaelwoerister

rustc: Handle some libstd symbole exports better

Right now symbol exports, particularly in a cdylib, are handled by
assuming that `pub extern` combined with `#[no_mangle]` means "export
this". This isn't actually what we want for some symbols that the
standard library uses to implement itself, for example symbols related
to allocation. Additionally other special symbols like
`rust_eh_personallity` have no need to be exported from cdylib crate
types (only needed in dylib crate types).

This commit updates how rustc handles these special symbols by adding to
the hardcoded logic of symbols like `rust_eh_personallity` but also
adding a new attribute, `#[rustc_std_internal_symbol]`, which forces the
export level to be considered the same as all other Rust functions
instead of looking like a C function.

The eventual goal here is to prevent functions like `__rdl_alloc` from
showing up as part of a Rust cdylib as it's just an internal
implementation detail. This then further allows such symbols to get gc'd
by the linker when creating a cdylib.

6 years agoUpdate reference link in doc's 404
Ryan Scheel [Sun, 5 Nov 2017 03:53:27 +0000 (20:53 -0700)]
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.

6 years agorustc: Handle some libstd symbole exports better
Alex Crichton [Wed, 1 Nov 2017 20:16:36 +0000 (13:16 -0700)]
rustc: Handle some libstd symbole exports better

Right now symbol exports, particularly in a cdylib, are handled by
assuming that `pub extern` combined with `#[no_mangle]` means "export
this". This isn't actually what we want for some symbols that the
standard library uses to implement itself, for example symbols related
to allocation. Additionally other special symbols like
`rust_eh_personallity` have no need to be exported from cdylib crate
types (only needed in dylib crate types).

This commit updates how rustc handles these special symbols by adding to
the hardcoded logic of symbols like `rust_eh_personallity` but also
adding a new attribute, `#[rustc_std_internal_symbol]`, which forces the
export level to be considered the same as all other Rust functions
instead of looking like a C function.

The eventual goal here is to prevent functions like `__rdl_alloc` from
showing up as part of a Rust cdylib as it's just an internal
implementation detail. This then further allows such symbols to get gc'd
by the linker when creating a cdylib.

6 years agoUse Add::add for overflow checks instead of [rustc_inherit_overflow_checks]
Scott McMurray [Sun, 5 Nov 2017 00:10:51 +0000 (17:10 -0700)]
Use Add::add for overflow checks instead of [rustc_inherit_overflow_checks]

6 years agoFix comment formatting
Nadav Zingerman [Sat, 4 Nov 2017 23:24:20 +0000 (01:24 +0200)]
Fix comment formatting

6 years agoAuto merge of #45711 - tirr-c:unicode-span, r=estebank
bors [Sat, 4 Nov 2017 23:09:19 +0000 (23:09 +0000)]
Auto merge of #45711 - tirr-c:unicode-span, r=estebank

Display spans correctly when there are zero-width or wide characters

Hopefully...
* fixes #45211
* fixes #8706

---

Before:
```
error: invalid width `7` for integer literal
  --> unicode_2.rs:12:25
   |
12 |     let _ = ("a̐éö̲", 0u7);
   |                         ^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: invalid width `42` for integer literal
  --> unicode_2.rs:13:20
   |
13 |     let _ = ("아あ", 1i42);
   |                    ^^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: aborting due to 2 previous errors
```

After:
```
error: invalid width `7` for integer literal
  --> unicode_2.rs:12:25
   |
12 |     let _ = ("a̐éö̲", 0u7);
   |                     ^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: invalid width `42` for integer literal
  --> unicode_2.rs:13:20
   |
13 |     let _ = ("아あ", 1i42);
   |                      ^^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: aborting due to 2 previous errors
```

Spans might display incorrectly on the browser.

r? @estebank

6 years agoMake DefIndex use newtype_index macro
Santiago Pastorino [Sat, 4 Nov 2017 20:48:05 +0000 (17:48 -0300)]
Make DefIndex use newtype_index macro

6 years agoMake DEBUG_FORMAT = custom work
Santiago Pastorino [Sat, 4 Nov 2017 22:09:47 +0000 (19:09 -0300)]
Make DEBUG_FORMAT = custom work

Fixes #45763, ht by @durka

6 years agoRemove import of now unused AsciiExt
Lukas Kalbertodt [Fri, 3 Nov 2017 20:24:20 +0000 (21:24 +0100)]
Remove import of now unused AsciiExt

I also replaced a wildcard import with a specific one, while I was
at it.

6 years agoAuto merge of #45394 - davidtwco:rfc-2008, r=petrochenkov
bors [Sat, 4 Nov 2017 18:07:07 +0000 (18:07 +0000)]
Auto merge of #45394 - davidtwco:rfc-2008, r=petrochenkov

RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute

This work-in-progress pull request contains my changes to implement [RFC 2008](https://github.com/rust-lang/rfcs/pull/2008). The related tracking issue is #44109.

As of writing, enum-related functionality is not included and there are some issues related to tuple/unit structs. Enum related tests are currently ignored.

WIP PR requested by @nikomatsakis [in Gitter](https://gitter.im/rust-impl-period/WG-compiler-middle?at=59e90e6297cedeb0482ade3e).

6 years agoIgnoring pretty print for test due to #37199
David Wood [Sat, 4 Nov 2017 18:01:35 +0000 (18:01 +0000)]
Ignoring pretty print for test due to #37199

6 years agoMake DepNodeIndex use newtype_index macro
Santiago Pastorino [Sat, 4 Nov 2017 16:41:53 +0000 (13:41 -0300)]
Make DepNodeIndex use newtype_index macro

6 years agoAuto merge of #45709 - nrc:rls-bugs-2, r=eddyb
bors [Sat, 4 Nov 2017 15:30:20 +0000 (15:30 +0000)]
Auto merge of #45709 - nrc:rls-bugs-2, r=eddyb

Fix a bunch of minor save-analysis bugs

r? @eddyb