Commit Graph

74895 Commits

Author SHA1 Message Date
bors
3eeb5a665e Auto merge of #46785 - leodasvacas:type-check-defaults-at-declaration, r=nikomatsakis
[Underspecified semantics] Type check defaults at declaration.

Fixes  #46669. See the test for code that compiles on stable but will no longer compile. This falls under a "Underspecified language semantics" fix. **Needs crater**.

On type and trait declarations, we currently allow anything that name checks as a type parameter default. That allows the user to write a default that can never be applied, or even a default that may conditionally be applied depending on the type of another parameter. Mostly this just defers the error to use sites, but also allows clever hacks such as `Foo<T, U = <T as Iterator>::Item>` where `U` will be able to apply it's default only when `T: Iterator`. Maybe that means this bug is a feature, but it's a fiddly behaviour that seems undesirable.

This PR validates defaults at declaration sites by ensuring all predicates on the parameter are valid for the default. With the exception of `Self: Sized` which we don't want to check to allow things like `trait Add<RHS = Self>`.
2018-03-01 13:19:18 +00:00
bors
a85417f593 Auto merge of #48349 - nrc:update, r=alexcrichton
Update RLS

r? @alexcrichton
2018-03-01 02:11:35 +00:00
bors
0e3c9bba8e Auto merge of #48615 - Manishearth:rollup, r=Manishearth
Rollup of 10 pull requests

- Successful merges: #48355, #48359, #48380, #48419, #48420, #48461, #48522, #48570, #48572, #48603
- Failed merges:
2018-02-28 23:10:14 +00:00
Manish Goregaokar
b2b9707696
Rollup merge of #48603 - pthariensflame:patch-1, r=frewsxcv
Fixes #47311.
r? @nrc
2018-02-28 15:09:31 -08:00
Manish Goregaokar
f57835b7f4
Rollup merge of #48461 - Manishearth:epoch-dyn-trait, r=nmatsakis
Fixes #47311.
r? @nrc
2018-02-28 15:09:29 -08:00
Manish Goregaokar
6b5519ddac
Rollup merge of #48420 - teiesti:path_parents, r=BurntSushi
Fixes #47311.
r? @nrc
2018-02-28 15:09:27 -08:00
Manish Goregaokar
12515608cb
Rollup merge of #48380 - nikomatsakis:issue-48251-master, r=acrichto
Fixes #47311.
r? @nrc
2018-02-28 15:09:26 -08:00
Manish Goregaokar
fac7d7cfb2
Rollup merge of #48359 - jsgf:remap-path-prefix, r=sanxiyn
Fixes #47311.
r? @nrc
2018-02-28 15:09:24 -08:00
Manish Goregaokar
f59ab8e96a
Rollup merge of #48355 - mikhail-m1:subslice_pattern_array_drop2, r=nikomatsakis
Fixes #47311.
r? @nrc
2018-02-28 15:09:22 -08:00
leonardo.yvens
3e84aeda0f Update UI test 2018-02-28 12:59:30 -03:00
Niko Matsakis
c84b7815b3 add a comment 2018-02-28 12:33:16 -03:00
leonardo.yvens
a7c7c8a4d7 Check only concrete defaults for well formedness 2018-02-28 12:33:16 -03:00
leonardo.yvens
c74f85f935 Check only predicates with a single param with a concrete default.
This is the most conservative possible and should be always correct.
2018-02-28 12:33:16 -03:00
leonardo.yvens
ac17948d0f Mark non-defaulted params as TyError to avoid a custom visitor. 2018-02-28 12:33:15 -03:00
leonardo.yvens
81ab26c99a Add tests for dependent defaults. 2018-02-28 12:33:15 -03:00
leonardo.yvens
75997d85c5 Check WF of predicates with defaults only if all params have defaults 2018-02-28 12:33:15 -03:00
leonardo.yvens
addc404d32 Check WF of predicate with defaults only if all in LHS have default
Given a trait predicate, if all params appearing in the LHS have
defaults then it should be a backwards compatible predicate. We verify
that by checking the WF of predicate with all defaults substituted
simultaneously.
2018-02-28 12:33:15 -03:00
leonardo.yvens
35499aa9fc Expand comments, address nits. 2018-02-28 12:33:15 -03:00
leonardo.yvens
7c1b6848db use map_bound instead of skip_binder 2018-02-28 12:33:14 -03:00
leonardo.yvens
3b4a06272e Go back to checking only the LHS of trait predicates. 2018-02-28 12:33:14 -03:00
leonardo.yvens
d9c336afb7 default WF: Substitute defaults individually in the clauses. 2018-02-28 12:33:14 -03:00
leonardo.yvens
87c2ad048a default WF: Leverage type substitution, less workarounding
`Predicate` is `TypeFoldable`, use that. Be less clever with the
workaround.
2018-02-28 12:33:14 -03:00
leonardo.yvens
a6bb32c9cc Check WF of defaults even when there are no bounds. 2018-02-28 12:33:14 -03:00
leonardo.yvens
4d9703373d Type check defaults.
And refactor duplicated code.
2018-02-28 12:33:14 -03:00
Tobias Stolzmann
b9e9b4a146
Add std::path::Path::ancestors
Squashed commit of the following:

commit 1b5d55e26f667b1a25c83c5db0cbb072013a5122
Author: Tobias Stolzmann <tobias.stolzmann@gmail.com>
Date:   Wed Feb 28 00:06:15 2018 +0100

    Bugfix

commit 4265c2db0b0aaa66fdeace5d329665fd2d13903a
Author: Tobias Stolzmann <tobias.stolzmann@gmail.com>
Date:   Tue Feb 27 22:59:12 2018 +0100

    Rename std::path::Path::parents into std::path::Path::ancestors

commit 2548e4b14d377d20adad0f08304a0dd6f8e48e23
Author: Tobias Stolzmann <tobias.stolzmann@gmail.com>
Date:   Tue Feb 27 12:50:37 2018 +0100

    Add tracking issue

commit 3e2ce51a6eea0e39af05849f76dd2cefd5035e86
Author: Tobias Stolzmann <tobias.stolzmann@gmail.com>
Date:   Mon Feb 26 15:05:15 2018 +0100

    impl FusedIterator for Parents

commit a7e096420809740311e19d963d4aba6df77be2f9
Author: Tobias Stolzmann <tobias.stolzmann@gmail.com>
Date:   Mon Feb 26 14:38:41 2018 +0100

    Clarify that the iterator returned will yield at least one value

commit 796a36ea203cd197cc4c810eebd21c7e3433e6f1
Author: Tobias Stolzmann <tobias.stolzmann@gmail.com>
Date:   Thu Feb 22 14:01:21 2018 +0100

    Fix examples

commit e279383b21f11c97269cb355a5b2a0ecdb65bb0c
Author: Tobias Stolzmann <tobias.stolzmann@gmail.com>
Date:   Thu Feb 22 04:47:24 2018 +0100

    Add std::path::Path::parents
2018-02-28 15:29:16 +01:00
bors
0ff9872b22 Auto merge of #48608 - kennytm:rollup, r=kennytm
Rollup of 15 pull requests

- Successful merges: #48266, #48321, #48365, #48381, #48450, #48473, #48479, #48484, #48488, #48497, #48541, #48548, #48558, #48560, #48565
- Failed merges:
2018-02-28 11:24:23 +00:00
kennytm
fed0c4201c
Rollup merge of #48565 - alexcrichton:rename-bmi, r=cramertj
rustc: Rename `bmi` feature to `bmi1`

This is what [Intel calls it][bmi1] and will [remove a special case][stdsimd]
when verifying intrinsics in stdsimd.

[bmi1]: https://software.intel.com/sites/landingpage/IntrinsicsGuide/#othertechs=BMI1
[stdsimd]: bed25b2a9f/crates/stdsimd-verify/tests/x86-intel.rs (L252-L258)
2018-02-28 19:15:43 +08:00
kennytm
537f8d6f86
Rollup merge of #48560 - bdrewery:freebsd-struct-abi, r=estebank
Fix FreeBSD struct returning ABI.

FreeBSD has had a patch similar to this for a while. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223047.

This reworks 6774e7a to be more specific about what `compute_abi_info` is checking for per target.
2018-02-28 19:15:42 +08:00
kennytm
4b4cd47021
Rollup merge of #48558 - Mark-Simulacrum:error-format, r=Manishearth
Fix error-format to properly send JSON to stdout

Since we take Cargo's JSON messages as well we need to specifically send
rustc's messages out so we don't hide them.

r? @Manishearth
2018-02-28 19:15:41 +08:00
kennytm
59ab146ec3
Rollup merge of #48548 - alexcrichton:msvc-linker-utf16, r=alexcrichton
Encode linker arguments as UTF-16 on MSVC platforms

This is a forward-port of #48455 to the master branch
2018-02-28 19:15:40 +08:00
kennytm
62f4fe5132
Rollup merge of #48541 - varkor:inlined-main, r=michaelwoerister
Ensure main() always has external linkage

This ensures that the entry function is never elided due to inlining, even with `inline(always)`. Fixes #47783.

There were a couple of possible ways of addressing this issue; I simply picked the one that seemed most direct. A warning could be appropriate, but considering using inlining hints in other places it doesn't apply also throws no warnings, and it seems like an edge case anyway, I haven't added one for now.
2018-02-28 19:15:39 +08:00
kennytm
d3fee346a5
Rollup merge of #48497 - scottmcm:more-restricted-termination, r=nikomatsakis
Restrict the Termination impls to simplify stabilization

Make a minimal commitment in preparation for stabilization.  More impls, or broader ones, are likely in future, but are not necessary at this time and are more controversial.

cc https://github.com/rust-lang/rust/issues/48453#issuecomment-368155082
r? @nikomatsakis
2018-02-28 19:15:38 +08:00
kennytm
a3fecfb8e9
Rollup merge of #48488 - varkor:handle-gdb-error-compiletest, r=michaelwoerister
Handle gdb command failure gracefully in compiletest

Previously, if the gdb command was available, but threw an error, compiletest would panic.  This is obviously not good. Now, gdb is treated as missing if calling `gdb --version` does not output anything on stdout.
2018-02-28 19:15:36 +08:00
kennytm
428f00250d
Rollup merge of #48484 - glaubitz:powerpcspe-linux, r=alexcrichton
Add support for powerpc-unknown-linux-gnuspe

This PR adds support for the embedded PowerPC variant "e500". On Linux, this architecture is usually called "powerpcspe", it is a 32-bit PowerPC architecture. The main difference between normal 32-bit PowerPC and PowerPCSPE is the lack of Altivec instructions and the additional SPE instruction set.

This architecture is supported in Debian through an unofficial port.
2018-02-28 19:15:35 +08:00
kennytm
af55518bcf
Rollup merge of #48479 - mark-i-m:rustc-guide, r=nikomatsakis
Start moving to the rustc guide!

r? @nikomatsakis

cc #48478
2018-02-28 19:15:34 +08:00
kennytm
cbd0a2c6fd
Rollup merge of #48473 - GuillaumeGomez:rustdoc-auto-trait-impl-fix, r=QuietMisdreavus
Fix auto trait impl rustdoc ice

Fixes #48463.

r? @QuietMisdreavus
2018-02-28 19:15:33 +08:00
kennytm
ef44e63da6
Rollup merge of #48450 - frewsxcv:frewsxcxv-stabilize-slice-rotatee, r=alexcrichton
Stabilize [T]::rotate_{left,right}

https://github.com/rust-lang/rust/issues/41891
2018-02-28 19:15:32 +08:00
kennytm
71ce38eb9e
Rollup merge of #48381 - GuillaumeGomez:rustdoc-theme-securities, r=QuietMisdreavus
Rustdoc theme securities

Fixes #48375.
Fixes #48376.

r? @steveklabnik
cc @QuietMisdreavus
2018-02-28 19:15:31 +08:00
kennytm
c599463cd1
Rollup merge of #48365 - Centril:docs/document-refcell-panics, r=frewsxcv
RefCell: document panics in Clone, PartialEq, PartialOrd, Ord.

This fixes #47400 by adding:

```rust
    /// # Panics
    ///
    /// Panics if the value is currently mutably borrowed.
```
to said impls. They may panic since they call `.borrow()`.
2018-02-28 19:15:29 +08:00
kennytm
85d7d0bf56
Rollup merge of #48321 - milesand:no_panic_pow, r=alexcrichton
Add non-panicking variants of pow for integer types

Currently, calling pow may panic in case of overflow, and the function does not have non-panicking counterparts. Thus, it would be beneficial to add those in.

Closes #48291.
Relevant tracking issue: #48320
2018-02-28 19:15:28 +08:00
kennytm
f933dd243a
Rollup merge of #48266 - pietroalbini:report-compiler-flags-on-ice, r=michaelwoerister
Report non-standard compile flags on ICE

Some ICEs (such as the recent #48248) only happens when a non-standard compiler flag is provided to rustc, but users don't always report the used flags. This can slow down reproducing the issue, so this PR shows all the non-standard compiler flags in the ICE error message.

For example, the output of #48248 with this PR is:

```
error: internal compiler error: [...]

thread 'rustc' panicked at [...]
note: Run with `RUST_BACKTRACE=1` for a backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: [...]

note: rustc 1.25.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -C link-dead-code
```

### Open questions

* At the moment, only `-C` and `-Z` flags are shown by default, and all the ones provided by cargo in a standard build are ignored: I did this to only show the flags that probably caused the ICE, and to remove some noise from the message. This removed flags like `opt-level` and `debuginfo` though, could those be useful for reproducing ICEs?
2018-02-28 19:15:27 +08:00
bors
ddab91a5de Auto merge of #48056 - ExpHP:macro-commas, r=dtolnay
Comprehensively support trailing commas in std/core macros

I carefully organized the changes into four commits:

* Test cases
* Fixes for `macro_rules!` macros
* Fixes for builtin macros
* Docs for builtins

**I can easily scale this back to just the first two commits for now if such is desired.**

### Breaking (?) changes

* This fixes #48042, which is a breaking change that I hope people can agree is just a bugfix for an extremely dark corner case.

* To fix five of the builtins, this changes `syntax::ext::base::get_single_str_from_tts` to accept a trailing comma, and revises the documentation so that this aspect is not surprising. **I made this change under the (hopefully correct) understanding that `libsyntax` is private rustc implementation detail.** After reviewing all call sites (which were, you guessed it, *precisely those five macros*), I believe the revised semantics are closer to the intended spirit of the function.

### Changes which may require concensus

Up until now, it could be argued that some or all the following macros did not conceptually take a comma-separated list, because they only took one argument:

  * **`cfg(unix,)`** (most notable since cfg! is unique in taking a meta tag)
  * **`include{,_bytes,_str}("file.rs",)`**  (in item form this might be written as "`include!{"file.rs",}`" which is even slightly more odd)
  * **`compile_error("message",);`**
  * **`option_env!("PATH",)`**
  * **`try!(Ok(()),)`**

So I think these particular changes may require some sort of consensus.  **All of the fixes for builtins are included this list, so if we want to defer these decisions to later then I can scale this PR back to just the first two commits.**

### Other notes/general requests for comment

* Do we have a big checklist somewhere of "things to do when adding macros?" My hope is for `run-pass/macro-comma-support.rs` to remain comprehensive.
* Originally I wanted the tests to also comprehensively forbid double trailing commas.  However, this didn't work out too well: [see this gist and the giant FIXME in it](https://gist.github.com/ExpHP/6fc40e82f3d73267c4e590a9a94966f1#file-compile-fail_macro-comma-support-rs-L33-L50)
* I did not touch `select!`. It appears to me to be a complete mess, and its trailing comma mishaps are only the tip of the iceberg.
* There are [some compile-fail test cases](https://github.com/ExpHP/rust/blob/5fa97c35da2f0ee/src/test/compile-fail/macro-comma-behavior.rs#L49-L52) that didn't seem to work (rustc emits errors, but compile-fail doesn't acknowledge them), so they are disabled. Any clues? (Possibly related: These happen to be precisely the set of errors which are tagged by rustc as "this error originates in a macro outside of the current crate".)

---

Fixes #48042
Closes #46241
2018-02-28 07:10:05 +00:00
Alexander Ronald Altman
db6a5ee1aa Minor grammatical/style fix in docs. 2018-02-28 00:04:05 -06:00
bors
89e5a0796e Auto merge of #47894 - vi:rustdoc_foldable_impls, r=GuillaumeGomez,QuietMisdreavus
rustdoc: Foldable impl blocks

Addresses #40363, #45720, #24483, #23986 and so on

* Expands and refactors collapseDocs and toggleAllDocs
* Adds [-] toggle to all impls (including inherent impl)
* Makes it hiding though main css file, not though element inline style

May need to be addressed:

* "[-]" and anchor link copier are overlaid a bit
* Inherent methods are also hidden by the global [-] toggle.
* Auto-collapsing "Iterator" and so on by default is not implemented yet
* Tested only shallowly and only in Chromiuim
* No tests. Are there tests for css/js part here?
* The new implementation may be a bit slower.

What next steps are need to be done before the integration?
2018-02-28 04:24:18 +00:00
Nick Cameron
4b6f5c2aa4 Update RLS 2018-02-28 17:08:09 +13:00
Manish Goregaokar
0cb367266b
Emit parentheses in suggestion for global paths 2018-02-27 19:24:16 -08:00
bors
affe297c13 Auto merge of #48576 - ishitatsuyuki:dup-fix, r=nikomatsakis
Bring back ParamEnv deduplication

Fix #48551
2018-02-27 22:46:42 +00:00
Mazdak Farrokhzad
f8ebb3f09f fix wording on panics in binary operators on RefCells" 2018-02-27 15:48:50 +01:00
Tatsuyuki Ishi
f297f56e76 Bring back ParamEnv deduplication 2018-02-27 17:30:20 +09:00
bors
29f5c699b1 Auto merge of #48449 - petrochenkov:uidiff, r=nikomatsakis
Anonymize some line numbers in UI test output

New unstable flag `-Z ui-testing` is introduced. This flag changes diagnostic output of the compiler *in some way* making it more suitable for UI testing (this is intentionally vague).
At the moment this flag anonymizes line numbers at line starts thus solving the largest issue with UI test diffs. If diffs continue to be too noisy, some other tweaks could be applied (e.g. anonymizing lines/columns in `--> $DIR/file.rs:line:column`), but this needs some time and experience (we shouldn't diverge too much from the actual output in general).

If comment `// disable-ui-testing-normalization` is added to an UI test, then `-Z ui-testing` is not passed.

Closes https://github.com/rust-lang/rust/issues/46643
2018-02-27 00:29:50 +00:00