Commit Graph

106427 Commits

Author SHA1 Message Date
Tim Vermeulen 8cf33b0d9d Add tests 2020-03-17 00:03:43 +01:00
Tim Vermeulen cff1182bcd Fix FlattenCompat::{next, next_back} 2020-03-17 00:03:43 +01:00
Tim Vermeulen 16a23e72d0 Fuse FlattenCompat's inner iterator 2020-02-10 13:32:21 +01:00
Tim Vermeulen 14bcf0aaa5 Fix Peekable::next_back 2020-02-10 13:32:21 +01:00
bors a19edd6b16 Auto merge of #68802 - eddyb:debuginfo-there-can-only-be-one-arg, r=nagisa
rustc_codegen_ssa: don't treat inlined variables as debuginfo arguments.

Fixes #67586 by limiting `ArgumentVariable` special-casing to `VarDebugInfo` entries that are in `OUTERMOST_SOURCE_SCOPE`, i.e. the function's own argument scope.
That excludes `VarDebugInfo` from inlined callees, which can also point to the caller's argument locals.

This is a snippet from the optimized MIR (including inlining) of the testcase:
```rust
fn  foo(_1: usize) -> usize {
    debug bar => _1;                     // in scope 0 at ./example.rs:2:12: 2:15
    let mut _0: usize;                   // return place in scope 0 at ./example.rs:2:27: 2:32
    scope 1 {
        debug x => _1;                   // in scope 1 at /rustc/9ed29b6ff6aa2e048b09c27af8f62ee3040bdb37/src/libcore/convert/mod.rs:106:26: 106:27
    }
```
`scope 1` is from inlining the `identity` call, and `debug x => _1;` comes from the body of `core::convert::identity`, so they are now ignored for the purposes of determining the `ArgumentVariable` debuginfo associated to `_1`.
2020-02-08 21:28:05 +00:00
bors 07a34df18b Auto merge of #68452 - msizanoen1:riscv-abi, r=nagisa,eddyb
Implement proper C ABI lowering for RISC-V

This is necessary for full RISC-V psABI compliance when passing argument across C FFI boundary.

cc @lenary
2020-02-08 18:10:48 +00:00
bors 85ffd44d3d Auto merge of #68443 - eddyb:abi-compat-enum, r=nagisa
rustc_target: treat enum variants like union members, in call ABIs.

Fixes #68190, by handling non-C-like `enum`s as-if they were an `union` of `struct`s, in call ABIs.
Tests were provided by @sw17ch, from theirs and @bitwalker's original examples.

cc @nagisa @rkruppe
2020-02-08 13:02:21 +00:00
Eduard-Mihai Burtescu d20e4aa8e3 test: use `all: $(call NATIVE_STATICLIB,test)` to build a C lib. 2020-02-08 13:40:50 +02:00
Eduard-Mihai Burtescu d69b3b16e5 test: address comments and pacify the merciless tidy. 2020-02-08 06:52:09 +02:00
Eduard-Mihai Burtescu da33935c26 rustc_target: treat enum variants like union members, in call ABIs. 2020-02-08 06:50:59 +02:00
Eduard-Mihai Burtescu 8f81593d6c rustc_target: switch homogeneous_aggregate to returning Result. 2020-02-08 06:50:59 +02:00
John VanEnk 1d28952631 Add non-C-like enumeration tests on Rust->C calls to the abi-sysv64-arg-passing test. 2020-02-08 06:50:59 +02:00
John VanEnk 3b23b9864c Two test cases where Rust calls C using enums by value
One calls into C functions passing non-c-like enumerations by
value. The other calls into C expecting non-C-like enumerations as
returns.

These test cases are based on the tests provided by @bitwalker on
issue #68190. The original tests were provided at:
2688d5c672
2020-02-08 06:50:59 +02:00
John VanEnk 26bb0f15e7 Add similar examples that work to each test. 2020-02-08 06:17:03 +02:00
John VanEnk f1b52b34f2 Add a test that demonstrates an incorrect return value when calling into rust with non-c-like-enums. 2020-02-08 06:17:03 +02:00
John VanEnk cd5ad993d0 Add a test that demonstrates a segfault when calling into rust with non-c-like-enum. 2020-02-08 06:17:02 +02:00
bors 6cad7542da Auto merge of #68358 - matthewjasper:spec-fix, r=nikomatsakis
Remove some unsound specializations

This removes the unsound and exploitable specializations in the standard library

* The `PartialEq` and `Hash` implementations for  `RangeInclusive` are changed to avoid specialization.
* The `PartialOrd` specialization for slices now specializes on a limited set of concrete types.
* Added some tests for the soundness problems.
2020-02-08 03:46:56 +00:00
bors 8498c5f5b0 Auto merge of #65232 - nikomatsakis:lazy-norm-anon-const-push-2, r=matthewjasper
replace the leak check with universes, take 2

This PR is an attempt to revive the "universe-based region check", which is an important step towards lazy normalization. Unlike before, we also modify the definition of `'empty` so that it is indexed by a universe. This sidesteps some of the surprising effects we saw before -- at the core, we no longer think that `exists<'a> { forall<'b> { 'b: 'a } }` is solveable. The new region lattice looks like this:

```
static ----------+-----...------+       (greatest)
|                |              |
early-bound and  |              |
free regions     |              |
|                |              |
scope regions    |              |
|                |              |
empty(root)   placeholder(U1)   |
|            /                  |
|           /         placeholder(Un)
empty(U1) --         /
|                   /
...                /
|                 /
empty(Un) --------                      (smallest)
```
This PR has three effects:

* It changes a fair number of error messages, I think for the better.
* It fixes a number of bugs. The old algorithm was too conservative and caused us to reject legal subtypings.
* It also causes two regressions (things that used to compile, but now do not).
    * `coherence-subtyping.rs` gets an additional error. This is expected.
    * `issue-57639.rs` regresses as before, for the reasons covered in #57639.

Both of the regressions stem from the same underlying property: without the leak check, the instantaneous "subtype" check is not able to tell whether higher-ranked subtyping will succeed or not. In both cases, we might be able to fix the problem by doing a 'leak-check like change' at some later point (e.g., as part of coherence).

This is a draft PR because:

* I didn't finish ripping out the leak-check completely.
* We might want to consider a crater run before landing this.
* We might want some kind of design meeting to cover the overall strategy.
* I just remembered I never finished 100% integrating this into the canonicalization code.
* I should also review what happens in NLL region checking -- it probably still has a notion of bottom (empty set).

r? @matthewjasper
2020-02-07 23:08:52 +00:00
bors a29424a226 Auto merge of #68933 - Dylan-DPC:rollup-akz13kj, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #68164 (Selectively disable sanitizer instrumentation)
 - #68413 (Add GitHub issue templates)
 - #68889 (Move the `hir().krate()` method to a query and remove the `Krate` dep node)
 - #68909 (Respect --nocapture in panic=abort test mode)
 - #68910 (Add myself to .mailmap)
 - #68919 (Remove HashStable impl for ast::Lifetime)
 - #68928 (clean up E0276 explanation)

Failed merges:

r? @ghost
2020-02-07 17:47:11 +00:00
Dylan DPC 9681544f38
Rollup merge of #68928 - GuillaumeGomez:cleanup-e0276, r=Dylan-DPC
clean up E0276 explanation

r? @Dylan-DPC
2020-02-07 17:00:27 +01:00
Dylan DPC 88573a7f61
Rollup merge of #68919 - Zoxc:ast-lifetime, r=nikomatsakis
Remove HashStable impl for ast::Lifetime
2020-02-07 17:00:25 +01:00
Dylan DPC 9047c57e9f
Rollup merge of #68910 - hanna-kruppe:master, r=Mark-Simulacrum
Add myself to .mailmap
2020-02-07 17:00:23 +01:00
Dylan DPC f734e47516
Rollup merge of #68909 - tmandry:panic-abort-nocapture, r=alexcrichton
Respect --nocapture in panic=abort test mode

r? @alexcrichton
2020-02-07 17:00:21 +01:00
Dylan DPC 90f6267dea
Rollup merge of #68889 - Zoxc:hir-krate, r=eddyb
Move the `hir().krate()` method to a query and remove the `Krate` dep node

r? @eddyb cc @michaelwoerister
2020-02-07 17:00:19 +01:00
Dylan DPC f9ebad33a2
Rollup merge of #68413 - XAMPPRocky:master, r=Mark-Simulacrum
Add GitHub issue templates

This PR adds GitHub's issue templates to the repository. Adding templates for two of the most common issues we create on the repository. We could add more specific templates (e.g. ICEs) depending on the response to initial templates. I've included a screenshot of what it looks like, and people can also try out the UI and specific templates, by going to [`XAMPPRocky/rust`](https://github.com/XAMPPRocky/rust/issues/new/choose).

<img width="1115" alt="Screenshot 2020-01-21 at 13 57 46" src="https://user-images.githubusercontent.com/4464295/72807027-c51baa00-3c56-11ea-8a4c-98238489b345.png">
2020-02-07 17:00:18 +01:00
Dylan DPC 2f1eaeea77
Rollup merge of #68164 - tmiasko:no-sanitize, r=nikomatsakis
Selectively disable sanitizer instrumentation

Add `no_sanitize` attribute that allows to opt out from sanitizer
instrumentation in an annotated function.
2020-02-07 17:00:16 +01:00
bors fb29dfcc9a Auto merge of #68930 - RalfJung:miri, r=RalfJung
update miri

Cc @oli-obk r? @ghost

Fixes https://github.com/rust-lang/rust/issues/68878
2020-02-07 14:41:17 +00:00
Ralf Jung 4eeaa92366 update miri 2020-02-07 15:04:44 +01:00
Guillaume Gomez 26020f5063 clean up E0276 explanation 2020-02-07 13:23:33 +01:00
John Kåre Alsaker 44edbc0e90 Remove HashStable impl for ast::Lifetime 2020-02-07 08:07:06 +01:00
bors b5e21dbb5c Auto merge of #68499 - ssomers:btree_search_tidying, r=Mark-Simulacrum
BtreeMap range_search spruced up

#39457 created a lower level entry point for `range_search` to operate on, but it's really not hard to move it up a level of abstraction, making it somewhat shorter and reusing existing unsafe code (`new_edge` is unsafe although it is currently not tagged as such).

Benchmark added. Comparison says there's no real difference:
```
>cargo benchcmp old3.txt new3.txt --threshold 5
 name                                           old3.txt ns/iter  new3.txt ns/iter  diff ns/iter   diff %  speedup
 btree::map::find_seq_100                       19                21                           2   10.53%   x 0.90
 btree::map::range_excluded_unbounded           3,117             2,838                     -279   -8.95%   x 1.10
 btree::map::range_included_unbounded           1,768             1,871                      103    5.83%   x 0.94
 btree::set::intersection_10k_neg_vs_10k_pos    35                37                           2    5.71%   x 0.95
 btree::set::intersection_staggered_100_vs_10k  2,488             2,314                     -174   -6.99%   x 1.08
 btree::set::is_subset_10k_vs_100               3                 2                           -1  -33.33%   x 1.50
```

r? @Mark-Simulacrum
2020-02-07 06:24:55 +00:00
Stein Somers ae03e16d08 Lift range_search up one level of abstraction 2020-02-07 02:41:28 +01:00
bors f8fd462447 Auto merge of #68907 - Dylan-DPC:rollup-osm5e8o, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #67359 (Rename -Zexternal-macro-backtrace to -Zmacro-backtrace and clean up implementation.)
 - #68524 (Generator Resume Arguments)
 - #68791 (implement proper linkchecker hardening)
 - #68886 (Mark fn map_or() as eagerly evaluated.)
 - #68888 (error code examples: replace some more ignore with compile_fail)
 - #68894 (Update E0565 examples)

Failed merges:

r? @ghost
2020-02-07 00:06:35 +00:00
Stein Somers be051adb57 Create benchmarks for BTreeMap::range 2020-02-07 00:57:54 +01:00
Hanna Kruppe c39f2092f7 Add myself to .mailmap 2020-02-06 23:45:20 +01:00
Tyler Mandry 861b328f7d Respect --nocapture in panic=abort test mode 2020-02-06 14:43:53 -08:00
Dylan DPC 7ef5b8951f
Rollup merge of #68894 - JohnTitor:update-e0565, r=Dylan-DPC
Update E0565 examples

Fixes #68892

r? @GuillaumeGomez
2020-02-06 22:38:39 +01:00
Dylan DPC 0e294cf395
Rollup merge of #68888 - tspiteri:ignore-to-compile_fail, r=petrochenkov
error code examples: replace some more ignore with compile_fail

Now that #68664 has been merged and `compile_fail` attempts a full build rather than `--emit=metadata`, these errors should be caught by `compile_fail` and do not need to be ignored.
2020-02-06 22:38:37 +01:00
Dylan DPC cc3a0e458c
Rollup merge of #68886 - tom-a-wagner:master, r=Mark-Simulacrum
Mark fn map_or() as eagerly evaluated.

In the docs for option.rs and result.rs, it is noted for all *_or()
functions that they are eagerly evaluated, except for the map_or()
function.
This commit adds this missing documentation to the two files.

Closes #68866
2020-02-06 22:38:36 +01:00
Dylan DPC 4ce157d008
Rollup merge of #68791 - mark-i-m:proper-linkcheck, r=ehuss,JohnTitor
implement proper linkchecker hardening

r? @JohnTitor

This implements proper linkcheck filtering... we might need to fiddle with a bit to adjust what is or isn't filtered, but this seems to work reasonable locally.
2020-02-06 22:38:34 +01:00
Dylan DPC 2d8f6389d0
Rollup merge of #68524 - jonas-schievink:generator-resume-arguments, r=Zoxc
Generator Resume Arguments

cc https://github.com/rust-lang/rust/issues/43122 and https://github.com/rust-lang/rust/issues/56974

Blockers:
* [x] Fix miscompilation when resume argument is live across a yield point (https://github.com/rust-lang/rust/pull/68524#issuecomment-578459069)
* [x] Fix 10% compile time regression in `await-call-tree` benchmarks (https://github.com/rust-lang/rust/pull/68524#issuecomment-578487162)
  * [x] Fix remaining 1-3% regression (https://github.com/rust-lang/rust/pull/68524#issuecomment-579566255) - resolved (https://github.com/rust-lang/rust/pull/68524#issuecomment-581144901)
* [x] Make dropck rules account for resume arguments (https://github.com/rust-lang/rust/pull/68524#issuecomment-578541137)

Follow-up work:
* Change async/await desugaring to make use of this feature
* Rewrite [`box_region.rs`](3d8778d767/src/librustc_data_structures/box_region.rs) to use resume arguments (this shows up in profiles too)
2020-02-06 22:38:33 +01:00
Dylan DPC 26c86a6a28
Rollup merge of #67359 - eddyb:macro-backtrace-all-the-same, r=petrochenkov
Rename -Zexternal-macro-backtrace to -Zmacro-backtrace and clean up implementation.

This is my attempt at dealing with https://github.com/rust-lang/rust/pull/66364#issuecomment-565517232, although I'm not sure it's the least disruptive one.

The behavior of `-Zexternal-macro-backtrace` was already to enable full macro backtraces for *all* macros, the only part of it that was specific to cross-crate macros was showing this when *not used*:
```
note: this error originates in a macro outside of the current crate
  (in Nightly builds, run with -Z external-macro-backtrace for more info)
```

After this PR:
* the flag is renamed to `-Zmacro-backtrace`
  * do we need to have a deprecation period? cc @rust-lang/compiler
* the message informing you about the flag is always shown when an expansion of a bang macro/attribute/derive is involved, not just cross-crate ones
  * this accounts for most of the changes in tests
  * we could perhaps only show it for the bang macro case? feels odd for derives
* `fix_multispans_in_std_macros` is split into `fix_multispans_in_extern_macros` and `render_multispans_macro_backtrace`
  * this roughly reverts the non-behavioral parts of #46605, which combined the two functionalities
  * not sure where the old `std_macros` name came from, perhaps the `<std macros>` synthetic "file"? even then, odd that `std` specifically was mentioned
* `render_multispan_macro_backtrace`, by default (i.e. without `-Zmacro-backtrace`), hides the `in this macro invocation` label specifically to avoid redundancy in the diagnostic
  * that is, showing the macro use site is only useful when the diagnostic is inside the macro definition and the user can't otherwise tell which use site it applies to, not when the diagnostic is at/inside the use site already (which would make the label redundant)
  * before, it was only checking for the situation in which a cross-crate macro *definition* span would be replaced with the invocation span, which both made the connection to redundancy unobvious, and didn't help with other redundancy (e.g. when the diagnostic was pointing to an argument inside the macro invocation)
  * this accounts for the remaining test changes, which I've first noticed in https://github.com/rust-lang/rust/pull/66364#discussion_r356135967 but only later understood as part of this PR (hence the "redundancy" descriptions)

This PR is not needed for #66364, but it would help, as after this PR there's only one `.span_to_filename(...).is_macros()` check (i.e. for `<... macros>` synthetic "files") left in `rustc_errors`, and it's much more self-contained.

r? @petrochenkov
2020-02-06 22:38:31 +01:00
Niko Matsakis 4b3c66d2c3 make lint warn by default 2020-02-06 16:29:32 -05:00
Niko Matsakis 363fabaf1f lint impls that will become incoherent when leak-check is removed 2020-02-06 15:58:01 -05:00
Niko Matsakis e9c78947dc add the ability to skip leak check within a snapshot
The intention is that coherence code will skip the leak check and
determine whether two impls *would have* overlapped, and then issue a
warning.
2020-02-06 15:58:01 -05:00
Niko Matsakis 5e0197f13a apply various formatting nits 2020-02-06 15:58:01 -05:00
Niko Matsakis 6bc79c9cf3 use derive(Debug) for TypeTrace 2020-02-06 15:58:01 -05:00
Niko Matsakis 534f044425 index ReEmpty by universe
We now make `'empty` indexed by a universe index, resulting
in a region lattice like this:

```
static ----------+-----...------+       (greatest)
|                |              |
early-bound and  |              |
free regions     |              |
|                |              |
scope regions    |              |
|                |              |
empty(root)   placeholder(U1)   |
|            /                  |
|           /         placeholder(Un)
empty(U1) --         /
|                   /
...                /
|                 /
empty(Un) --------                      (smallest)
```

Therefore, `exists<A> { forall<B> { B: A } }` is now unprovable,
because A must be at least Empty(U1) and B is placeholder(U2), and hence
the two regions are unrelated.
2020-02-06 15:58:00 -05:00
Niko Matsakis b52414fede integrate the `sub_free_regions` code so we have only one copy of it 2020-02-06 15:57:58 -05:00
Niko Matsakis 03b2fff40e don't mention specific region numbers in the ~ERROR message 2020-02-06 15:51:02 -05:00