Commit Graph

60885 Commits

Author SHA1 Message Date
Segev Finer
3f1d3948d6 Fix backtraces on i686-pc-windows-gnu by disabling FPO
This might have performance implications. But do note that MSVC
disables FPO by default nowadays and it's use is limited in exception
heavy languages like C++.

Closes: #28218
2017-01-29 06:46:42 +02:00
bors
f39f273826 Auto merge of #39375 - seeekr:patch-1, r=apasel422
Fix typo in liballoc/lib.rs
2017-01-28 23:14:22 +00:00
Denis Andrejew
339bdc158f Fix typo in liballoc/lib.rs 2017-01-28 22:16:16 +00:00
bors
1491e04259 Auto merge of #39234 - segevfiner:fix-backtraces-on-windows-gnu, r=petrochenkov
Make backtraces work on Windows GNU targets again.

This is done by adding a function that can return a filename
to pass to backtrace_create_state. The filename is obtained in
a safe way by first getting the filename, locking the file so it can't
be moved, and then getting the filename again and making sure it's the same.

See: https://github.com/rust-lang/rust/pull/37359#issuecomment-260123399
Issue: #33985

Note though that this isn't that pretty...

I had to implement a `WideCharToMultiByte` wrapper function to convert to the ANSI code page. This will work better than only allowing ASCII provided that the ANSI code page is set to the user's local language, which is often the case.

Also, please make sure that I didn't break the Unix build.
2017-01-28 20:32:56 +00:00
Segev Finer
ab21314c3f Disable backtrace tests on i686-pc-windows-gnu since it's broken by FPO 2017-01-28 21:52:31 +02:00
bors
c81c1d6a41 Auto merge of #39360 - osa1:typos, r=GuillaumeGomez
Fix typos in libsyntax/tokenstream.rs
2017-01-28 14:13:00 +00:00
Ömer Sinan Ağacan
15411fb0fa Fix typos in libsyntax/tokenstream.rs 2017-01-28 17:00:43 +03:00
bors
010c3e25c4 Auto merge of #39340 - GuillaumeGomez:empty_comment, r=frewsxcv
Don't generate doc if doc comments only filled with 'white' characters

Fixes #39339.

r? @steveklabnik

cc @rust-lang/docs
2017-01-28 09:41:40 +00:00
bors
0f49616a53 Auto merge of #39305 - eddyb:synelide, r=nikomatsakis
Perform lifetime elision (more) syntactically, before type-checking.

The *initial* goal of this patch was to remove the (contextual) `&RegionScope` argument passed around `rustc_typeck::astconv` and allow converting arbitrary (syntactic) `hir::Ty` to (semantic) `Ty`.
I've tried to closely match the existing behavior while moving the logic to the earlier `resolve_lifetime` pass, and [the crater report](https://gist.github.com/eddyb/4ac5b8516f87c1bfa2de528ed2b7779a) suggests none of the changes broke real code, but I will try to list everything:

There are few cases in lifetime elision that could trip users up due to "hidden knowledge":
```rust
type StaticStr = &'static str; // hides 'static
trait WithLifetime<'a> {
    type Output; // can hide 'a
}

// This worked because the type of the first argument contains
// 'static, although StaticStr doesn't even have parameters.
fn foo(x: StaticStr) -> &str { x }

// This worked because the compiler resolved the argument type
// to <T as WithLifetime<'a>>::Output which has the hidden 'a.
fn bar<'a, T: WithLifetime<'a>>(_: T::Output) -> &str { "baz" }
```

In the two examples above, elision wasn't using lifetimes that were in the source, not even *needed* by paths in the source, but rather *happened* to be part of the semantic representation of the types.
To me, this suggests they should have never worked through elision (and they don't with this PR).

Next we have an actual rule with a strange result, that is, the return type here elides to `&'x str`:
```rust
impl<'a, 'b> Trait for Foo<'a, 'b> {
    fn method<'x, 'y>(self: &'x Foo<'a, 'b>, _: Bar<'y>) -> &str {
        &self.name
    }
}
```
All 3 of `'a`, `'b` and `'y` are being ignored, because the `&self` elision rule only cares that the first argument is "`self` by reference". Due implementation considerations (elision running before typeck), I've limited it in this PR to a reference to a primitive/`struct`/`enum`/`union`, but not other types, but I am doing another crater run to assess the impact of limiting it to literally `&self` and `self: &Self` (they're identical in HIR).

It's probably ideal to keep an "implicit `Self` for `self`" type around and *only* apply the rule to `&self` itself, but that would result in more bikeshed, and #21400 suggests some people expect otherwise.
Another decent option is treating `self: X, ... -> Y` like `X -> Y` (one unique lifetime in `X` used for `Y`).

The remaining changes have to do with "object lifetime defaults" (see RFCs [599](https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md) and [1156](https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md)):
```rust
trait Trait {}
struct Ref2<'a, 'b, T: 'a+'b>(&'a T, &'b T);

// These apply specifically within a (fn) body,
// which allows type and lifetime inference:
fn main() {
    // Used to be &'a mut (Trait+'a) - where 'a is one
    // inference variable - &'a mut (Trait+'b) in this PR.
    let _: &mut Trait;

    // Used to be an ambiguity error, but in this PR it's
    // Ref2<'a, 'b, Trait+'c> (3 inference variables).
    let _: Ref2<Trait>;
}
```
What's happening here is that inference variables are created on the fly by typeck whenever a lifetime has no resolution attached to it - while it would be possible to alter the implementation to reuse inference variables based on decisions made early by `resolve_lifetime`, not doing that is more flexible and works better - it can compile all testcases from #38624 by not ending up with `&'static mut (Trait+'static)`.

The ambiguity specifically cannot be an early error, because this is only the "default" (typeck can still pick something better based on the definition of `Trait` and whether it has any lifetime bounds), and having an error at all doesn't help anyone, as we can perfectly infer an appropriate lifetime inside the `fn` body.

**TODO**: write tests for the user-visible changes.

cc @nikomatsakis @arielb1
2017-01-28 06:21:23 +00:00
bors
0f8a296475 Auto merge of #39353 - alexcrichton:rollup, r=alexcrichton
Rollup of 21 pull requests

- Successful merges: #38617, #39284, #39285, #39290, #39302, #39305, #39306, #39307, #39311, #39313, #39314, #39321, #39325, #39332, #39335, #39344, #39345, #39346, #39348, #39350, #39351
- Failed merges:
2017-01-28 02:50:51 +00:00
Eduard-Mihai Burtescu
c0e474d9a6 test: add missing lifetime in recently added test. 2017-01-28 02:56:46 +02:00
Eduard-Mihai Burtescu
9a0af1638a rustc: remove unused bounds field from RegionParameterDef. 2017-01-28 02:56:46 +02:00
Eduard-Mihai Burtescu
4eac052a33 rustc: move object default lifetimes to resolve_lifetimes. 2017-01-28 02:56:46 +02:00
Eduard-Mihai Burtescu
c5befdc630 rustc: always keep an explicit lifetime in trait objects. 2017-01-28 02:56:46 +02:00
Eduard-Mihai Burtescu
41553d6fbc rustc: lower trait type paths as TyTraitObject. 2017-01-28 02:56:46 +02:00
Eduard-Mihai Burtescu
9783947c2a rustc_typeck: move impl Trait checks out of RegionScope. 2017-01-28 02:56:46 +02:00
Eduard-Mihai Burtescu
ba1849daec rustc: move most of lifetime elision to resolve_lifetimes. 2017-01-28 02:56:46 +02:00
Eduard-Mihai Burtescu
bbc341424c rustc: simplify scope-tracking in resolve_lifetime. 2017-01-28 02:56:46 +02:00
Eduard-Mihai Burtescu
0682a75f44 rustc: clean up the style of middle::resolve_lifetime. 2017-01-28 02:56:46 +02:00
Eduard-Mihai Burtescu
7a2a669bb7 rustc: always include elidable lifetimes in HIR types. 2017-01-28 02:56:46 +02:00
Eduard-Mihai Burtescu
f79feba205 rustc_typeck: pass all lifetimes through AstConv::opt_ast_region_to_region. 2017-01-28 02:55:37 +02:00
Eduard-Mihai Burtescu
4f559f8c33 rustc_typeck: force users of RegionScope to get anon_region's one by one. 2017-01-28 02:55:21 +02:00
Alex Crichton
1767d9715c Rollup merge of #39351 - nikomatsakis:incr-comp-skip-typeck-1, r=eddyb
move `cast_kinds` into `TypeckTables` where it belongs

r? @eddyb
2017-01-27 16:42:08 -08:00
Alex Crichton
9eb00687ac Rollup merge of #39350 - nagisa:i128-test-helpers-better-def, r=alexcrichton
Use __SIZEOF_INT128__ to test __int128 presence

Previously we tested whether a handful of preprocessor variables indicating certain 64 bit
platforms, but this does not work for other 64 bit targets which have support for __int128 in C
compiler.

Use the `__SIZEOF__INT128__` preprocessor variable instead. This variable gets set to 16 by gcc and
clang for every target where __int128 is supported.
2017-01-27 16:42:08 -08:00
Alex Crichton
ebe17b0c70 Rollup merge of #39348 - steveklabnik:cyryl-mailmap, r=alexcrichton
Fix cyryl's mailmap entry
2017-01-27 16:42:08 -08:00
Alex Crichton
86af9a19ec Rollup merge of #39346 - steveklabnik:jethro-mailmap, r=brson
Fix @jethrogb's mailmap entry

cc rust-lang-nursery/thanks#51
2017-01-27 16:42:07 -08:00
Alex Crichton
854690c0d8 Rollup merge of #39345 - steveklabnik:carol-mailmap, r=alexcrichton
Fix up @carols10cents' mailmap entry

The previous ways didn't work; this does.

cc rust-lang-nursery/thanks#45
2017-01-27 16:42:07 -08:00
Alex Crichton
7c75608cfb Rollup merge of #39344 - ollie27:links, r=steveklabnik
Fix a few links in the docs

r? @steveklabnik
2017-01-27 16:42:07 -08:00
Alex Crichton
915242af7a Rollup merge of #39335 - cramertj:cramertj/can_begin_expr_fix, r=petrochenkov
Fix can_begin_expr keyword behavior

Partial fix for #28784.
2017-01-27 16:42:07 -08:00
Alex Crichton
30ae115a1d Rollup merge of #39332 - nagisa:another-bigendian-128, r=eddyb
Fix another endianness issue in i128 trans

Apparently LLVMArbitraryPrecisionInteger demands integers to be in low-endian 64-bytes, rather than host-endian 64-bytes. This is weird, and obviously, not documented. And rustc now works a teeny bit more on big endians.

r? @eddyb
2017-01-27 16:42:07 -08:00
Alex Crichton
a5ff116557 Rollup merge of #39321 - king6cong:master, r=frewsxcv
doc comment typo fix
2017-01-27 16:42:06 -08:00
Alex Crichton
4ef67babf2 Rollup merge of #39314 - stjepang:rewrite-sort-header, r=brson
Rewrite the first sentence in slice::sort

For every method, the first sentence should consisely explain what it does,
not how. This sentence usually starts with a verb.

It's really weird for `sort` to be explained in terms of another function,
namely `sort_by`. There's no need for that because it's obvious how `sort`
sorts elements: there is `T: Ord`.

If `sort_by_key` does not have to explicitly state how it's implemented,
then `sort` doesn't either.

r? @steveklabnik
2017-01-27 16:42:06 -08:00
Alex Crichton
06fcccfb7d Rollup merge of #39313 - est31:drop_in_place_is_stable, r=GuillaumeGomez
drop_in_place is stable now, don't #![feature] it in the nomicon and a test.

It was stable since Rust 1.8.

r? @GuillaumeGomez
2017-01-27 16:42:06 -08:00
Alex Crichton
e1a5c467c7 Rollup merge of #39311 - solson:fix-unpretty-mir-non-local, r=eddyb
Avoid ICE when pretty-printing non-local MIR item.

This comes up when using `-Zunstable-options --unpretty=mir`. Previously, rustc would ICE due to an unwrap later in this function (after `as_local_node_id`). Instead, we should just ignore items from other crates when pretty-printing MIR.

This was reported in #rust: [this playground code](https://is.gd/PSMBZS) causes an ICE if you click the MIR button. The problem is the mention of the non-local item `std::usize::MAX`, so you can reduce the test case [a lot](https://is.gd/SaLjaa).

r? @eddyb
2017-01-27 16:42:06 -08:00
Alex Crichton
0edc3d37bb Rollup merge of #39307 - alexcrichton:stabilize-1.16, r=brson
std: Stabilize APIs for the 1.16.0 release

This commit applies the stabilization/deprecations of the 1.16.0 release, as
tracked by the rust-lang/rust issue tracker and the final-comment-period tag.

The following APIs were stabilized:

* `VecDeque::truncate`
* `VecDeque::resize`
* `String::insert_str`
* `Duration::checked_{add,sub,div,mul}`
* `str::replacen`
* `SocketAddr::is_ipv{4,6}`
* `IpAddr::is_ipv{4,6}`
* `str::repeat`
* `Vec::dedup_by`
* `Vec::dedup_by_key`
* `Result::unwrap_or_default`
* `<*const T>::wrapping_offset`
* `<*mut T>::wrapping_offset`
* `CommandExt::creation_flags` (on Windows)
* `File::set_permissions`
* `String::split_off`

The following APIs were deprecated

* `EnumSet` - replaced with other ecosystem abstractions, long since unstable

Closes #27788
Closes #35553
Closes #35774
Closes #36436
Closes #36949
Closes #37079
Closes #37087
Closes #37516
Closes #37827
Closes #37916
Closes #37966
Closes #38080
2017-01-27 16:42:06 -08:00
Alex Crichton
13e3b36f68 Rollup merge of #39306 - GuillaumeGomez:newtype_help, r=eddyb
Add note for E0117

Fixes #39249.

I just applied the suggestion of @durka since I don't see anything else to add.
2017-01-27 16:42:05 -08:00
Alex Crichton
ac1e92328a Rollup merge of #39302 - alexcrichton:upload-all, r=brson
travis: Upload all artifacts in build/dist

Previously we only uploaded tarballs, but this modifies Travis/AppVeyor to
upload everything. We shouldn't have anything else in there to worry about and
otherwise we need to be sure to pick up pkg/msi/exe installers.
2017-01-27 16:41:50 -08:00
Alex Crichton
0e64d4954f Rollup merge of #39290 - canndrew:hide-uninhabitedness, r=nikomatsakis
Hide uninhabitedness checks behind feature gate

This reverts the fix to match exhaustiveness checking so that it can be discussed. The new code is now hidden behind the `never_type` feature gate.
2017-01-27 16:41:50 -08:00
Alex Crichton
666fc45289 Rollup merge of #39285 - nrc:save-tables, r=@eddyb
save-analysis: get tables directly, accomodating them being missing

Fixes an ICE when running with save-analysis after an error

r? @eddyb
2017-01-27 16:41:50 -08:00
Alex Crichton
f1658610be Rollup merge of #39284 - alexcrichton:manifesting, r=brson
rustbuild: Add manifest generation in-tree

This commit adds a new tool, `build-manifest`, which is used to generate a
distribution manifest of all produced artifacts. This tool is intended to
replace the `build-rust-manifest.py` script that's currently located on the
buildmaster. The intention is that we'll have a builder which periodically:

* Downloads all artifacts for a commit
* Runs `./x.py dist hash-and-sign`. This will generate `sha256` and `asc` files
  as well as TOML manifests.
* Upload all generated hashes and manifests to the directory the artifacts came
  from.
* Upload *all* artifacts (tarballs and hashes and manifests) to an archived
  location.
* If necessary, upload all artifacts to the main location.

This script is intended to just be the second step here where orchestrating
uploads and such will all happen externally from the build system itself.

cc #38531
2017-01-27 16:41:49 -08:00
Alex Crichton
a2a3074fb3 Rollup merge of #38617 - pnkfelix:double-reference, r=pnkfelix
Detect double reference when applying binary op

``` rust
let vr = v.iter().filter(|x| {
    x % 2 == 0
});
```

will now yield the following compiler output:

``` bash
ERROR binary operation `%` cannot be applied to type `&&_`
NOTE this is a reference of a reference to a type that `%` can be applied to,
you need to dereference this variable once for this operation to work
NOTE an implementation of `std::ops::Rem` might be missing for `&&_`
```

The first NOTE is new.

Fix #33877

----

Thanks to @estebank for providing the original PR #34420 (of which this is a tweaked rebase).
2017-01-27 16:41:49 -08:00
Segev Finer
1b4a6c86fa Use libc::c_char instead of i8 due to platforms with unsigned char 2017-01-28 01:01:16 +02:00
Guillaume Gomez
460a3b20aa Don't generate doc if doc comments only filled with 'white' characters 2017-01-27 23:18:07 +01:00
bors
154c202afb Auto merge of #37057 - brson:nosuggest, r=nikomatsakis
rustc: Remove all "consider using an explicit lifetime parameter" suggestions

These give so many incorrect suggestions that having them is
detrimental to the user experience. The compiler should not be
suggesting changes to the code that are wrong - it is infuriating: not
only is the compiler telling you that _you don't understand_ borrowing,
_the compiler itself_ appears to not understand borrowing. It does not
inspire confidence.

r? @nikomatsakis
2017-01-27 22:13:41 +00:00
Simonas Kazlauskas
98bc300d69 Use __SIZEOF_INT128__ to test __int128 presence
Previously we tested whether a handful of preprocessor variables indicating certain 64 bit
platforms, but this does not work for other 64 bit targets which have support for __int128 in C
compiler.

Use the __SIZEOF__INT128__ preprocessor variable instead. This variable gets set to 16 by gcc and
clang for every target where __int128 is supported.
2017-01-27 23:23:26 +02:00
Niko Matsakis
f4010d7e61 move cast_kinds into TypeckTables where it belongs 2017-01-27 16:16:43 -05:00
Steve Klabnik
810b22bdb1 Fix cyryl's mailmap entry 2017-01-27 15:28:52 -05:00
Steve Klabnik
945177de8c Fix @jethrogb's mailmap entry
cc rust-lang-nursery/thanks#51
2017-01-27 15:19:30 -05:00
Steve Klabnik
0f2a5f686f Fix up @carols10cents' mailmap entry
The previous ways didn't work; this does.

cc rust-lang-nursery/thanks#45
2017-01-27 14:29:59 -05:00
bors
62a7258677 Auto merge of #39320 - alexcrichton:less-backtraces, r=aturon
travis: Turn off core dumps on OSX

I've seen these take up quite a bit of log space and I have the sneaking
suspicion that they're just making our test suite take longer (sometimes timing
out on 32-bit OSX now). In any case the backtraces haven't proven too useful,
unfortunately.
2017-01-27 18:12:04 +00:00