]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoAuto merge of #68802 - eddyb:debuginfo-there-can-only-be-one-arg, r=nagisa
bors [Sat, 8 Feb 2020 21:28:05 +0000 (21:28 +0000)]
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`.

4 years agoAuto merge of #68452 - msizanoen1:riscv-abi, r=nagisa,eddyb
bors [Sat, 8 Feb 2020 18:10:48 +0000 (18:10 +0000)]
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

4 years agoAuto merge of #68443 - eddyb:abi-compat-enum, r=nagisa
bors [Sat, 8 Feb 2020 13:02:21 +0000 (13:02 +0000)]
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

4 years agotest: use `all: $(call NATIVE_STATICLIB,test)` to build a C lib.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 11:40:50 +0000 (13:40 +0200)]
test: use `all: $(call NATIVE_STATICLIB,test)` to build a C lib.

4 years agotest: address comments and pacify the merciless tidy.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 04:50:41 +0000 (06:50 +0200)]
test: address comments and pacify the merciless tidy.

4 years agorustc_target: treat enum variants like union members, in call ABIs.
Eduard-Mihai Burtescu [Wed, 22 Jan 2020 00:52:54 +0000 (02:52 +0200)]
rustc_target: treat enum variants like union members, in call ABIs.

4 years agorustc_target: switch homogeneous_aggregate to returning Result.
Eduard-Mihai Burtescu [Wed, 22 Jan 2020 00:52:14 +0000 (02:52 +0200)]
rustc_target: switch homogeneous_aggregate to returning Result.

4 years agoAdd non-C-like enumeration tests on Rust->C calls to the abi-sysv64-arg-passing test.
John VanEnk [Wed, 22 Jan 2020 21:07:03 +0000 (13:07 -0800)]
Add non-C-like enumeration tests on Rust->C calls to the abi-sysv64-arg-passing test.

4 years agoTwo test cases where Rust calls C using enums by value
John VanEnk [Wed, 22 Jan 2020 06:26:13 +0000 (22:26 -0800)]
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:
https://github.com/bitwalker/rust_non_c_like_enums_issue/tree/2688d5c672bd4e289085fcdf1c6110e99e7e8ab1

4 years agoAdd similar examples that work to each test.
John VanEnk [Sat, 11 Jan 2020 01:59:18 +0000 (17:59 -0800)]
Add similar examples that work to each test.

4 years agoAdd a test that demonstrates an incorrect return value when calling into rust with...
John VanEnk [Sat, 11 Jan 2020 01:42:30 +0000 (17:42 -0800)]
Add a test that demonstrates an incorrect return value when calling into rust with non-c-like-enums.

4 years agoAdd a test that demonstrates a segfault when calling into rust with non-c-like-enum.
John VanEnk [Sat, 11 Jan 2020 01:16:04 +0000 (17:16 -0800)]
Add a test that demonstrates a segfault when calling into rust with non-c-like-enum.

4 years agoAuto merge of #68358 - matthewjasper:spec-fix, r=nikomatsakis
bors [Sat, 8 Feb 2020 03:46:56 +0000 (03:46 +0000)]
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.

4 years agoAuto merge of #65232 - nikomatsakis:lazy-norm-anon-const-push-2, r=matthewjasper
bors [Fri, 7 Feb 2020 23:08:52 +0000 (23:08 +0000)]
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

4 years agoAuto merge of #68933 - Dylan-DPC:rollup-akz13kj, r=Dylan-DPC
bors [Fri, 7 Feb 2020 17:47:11 +0000 (17:47 +0000)]
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

4 years agoRollup merge of #68928 - GuillaumeGomez:cleanup-e0276, r=Dylan-DPC
Dylan DPC [Fri, 7 Feb 2020 16:00:27 +0000 (17:00 +0100)]
Rollup merge of #68928 - GuillaumeGomez:cleanup-e0276, r=Dylan-DPC

clean up E0276 explanation

r? @Dylan-DPC

4 years agoRollup merge of #68919 - Zoxc:ast-lifetime, r=nikomatsakis
Dylan DPC [Fri, 7 Feb 2020 16:00:25 +0000 (17:00 +0100)]
Rollup merge of #68919 - Zoxc:ast-lifetime, r=nikomatsakis

Remove HashStable impl for ast::Lifetime

4 years agoRollup merge of #68910 - hanna-kruppe:master, r=Mark-Simulacrum
Dylan DPC [Fri, 7 Feb 2020 16:00:23 +0000 (17:00 +0100)]
Rollup merge of #68910 - hanna-kruppe:master, r=Mark-Simulacrum

Add myself to .mailmap

4 years agoRollup merge of #68909 - tmandry:panic-abort-nocapture, r=alexcrichton
Dylan DPC [Fri, 7 Feb 2020 16:00:21 +0000 (17:00 +0100)]
Rollup merge of #68909 - tmandry:panic-abort-nocapture, r=alexcrichton

Respect --nocapture in panic=abort test mode

r? @alexcrichton

4 years agoRollup merge of #68889 - Zoxc:hir-krate, r=eddyb
Dylan DPC [Fri, 7 Feb 2020 16:00:19 +0000 (17:00 +0100)]
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

4 years agoRollup merge of #68413 - XAMPPRocky:master, r=Mark-Simulacrum
Dylan DPC [Fri, 7 Feb 2020 16:00:18 +0000 (17:00 +0100)]
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">

4 years agoRollup merge of #68164 - tmiasko:no-sanitize, r=nikomatsakis
Dylan DPC [Fri, 7 Feb 2020 16:00:16 +0000 (17:00 +0100)]
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.

4 years agoAuto merge of #68930 - RalfJung:miri, r=RalfJung
bors [Fri, 7 Feb 2020 14:41:17 +0000 (14:41 +0000)]
Auto merge of #68930 - RalfJung:miri, r=RalfJung

update miri

Cc @oli-obk r? @ghost

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

4 years agoupdate miri
Ralf Jung [Fri, 7 Feb 2020 14:04:44 +0000 (15:04 +0100)]
update miri

4 years agoclean up E0276 explanation
Guillaume Gomez [Fri, 7 Feb 2020 12:23:33 +0000 (13:23 +0100)]
clean up E0276 explanation

4 years agoRemove HashStable impl for ast::Lifetime
John Kåre Alsaker [Fri, 7 Feb 2020 07:07:06 +0000 (08:07 +0100)]
Remove HashStable impl for ast::Lifetime

4 years agoAuto merge of #68499 - ssomers:btree_search_tidying, r=Mark-Simulacrum
bors [Fri, 7 Feb 2020 06:24:55 +0000 (06:24 +0000)]
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

4 years agoLift range_search up one level of abstraction
Stein Somers [Thu, 23 Jan 2020 06:48:09 +0000 (07:48 +0100)]
Lift range_search up one level of abstraction

4 years agoAuto merge of #68907 - Dylan-DPC:rollup-osm5e8o, r=Dylan-DPC
bors [Fri, 7 Feb 2020 00:06:35 +0000 (00:06 +0000)]
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

4 years agoCreate benchmarks for BTreeMap::range
Stein Somers [Thu, 23 Jan 2020 20:58:55 +0000 (21:58 +0100)]
Create benchmarks for BTreeMap::range

4 years agoAdd myself to .mailmap
Hanna Kruppe [Thu, 6 Feb 2020 22:45:20 +0000 (23:45 +0100)]
Add myself to .mailmap

4 years agoRespect --nocapture in panic=abort test mode
Tyler Mandry [Thu, 6 Feb 2020 22:43:53 +0000 (14:43 -0800)]
Respect --nocapture in panic=abort test mode

4 years agoRollup merge of #68894 - JohnTitor:update-e0565, r=Dylan-DPC
Dylan DPC [Thu, 6 Feb 2020 21:38:39 +0000 (22:38 +0100)]
Rollup merge of #68894 - JohnTitor:update-e0565, r=Dylan-DPC

Update E0565 examples

Fixes #68892

r? @GuillaumeGomez

4 years agoRollup merge of #68888 - tspiteri:ignore-to-compile_fail, r=petrochenkov
Dylan DPC [Thu, 6 Feb 2020 21:38:37 +0000 (22:38 +0100)]
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.

4 years agoRollup merge of #68886 - tom-a-wagner:master, r=Mark-Simulacrum
Dylan DPC [Thu, 6 Feb 2020 21:38:36 +0000 (22:38 +0100)]
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

4 years agoRollup merge of #68791 - mark-i-m:proper-linkcheck, r=ehuss,JohnTitor
Dylan DPC [Thu, 6 Feb 2020 21:38:34 +0000 (22:38 +0100)]
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.

4 years agoRollup merge of #68524 - jonas-schievink:generator-resume-arguments, r=Zoxc
Dylan DPC [Thu, 6 Feb 2020 21:38:33 +0000 (22:38 +0100)]
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`](https://github.com/rust-lang/rust/blob/3d8778d767f0dde6fe2bc9459f21ead8e124d8cb/src/librustc_data_structures/box_region.rs) to use resume arguments (this shows up in profiles too)

4 years agoRollup merge of #67359 - eddyb:macro-backtrace-all-the-same, r=petrochenkov
Dylan DPC [Thu, 6 Feb 2020 21:38:31 +0000 (22:38 +0100)]
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

4 years agomake lint warn by default
Niko Matsakis [Thu, 6 Feb 2020 20:59:09 +0000 (15:59 -0500)]
make lint warn by default

4 years agolint impls that will become incoherent when leak-check is removed
Niko Matsakis [Fri, 24 Jan 2020 20:57:01 +0000 (15:57 -0500)]
lint impls that will become incoherent when leak-check is removed

4 years agoadd the ability to skip leak check within a snapshot
Niko Matsakis [Sat, 18 Jan 2020 12:59:16 +0000 (07:59 -0500)]
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.

4 years agoapply various formatting nits
Niko Matsakis [Sat, 18 Jan 2020 10:47:28 +0000 (05:47 -0500)]
apply various formatting nits

4 years agouse derive(Debug) for TypeTrace
Niko Matsakis [Mon, 11 Nov 2019 18:14:57 +0000 (13:14 -0500)]
use derive(Debug) for TypeTrace

4 years agoindex ReEmpty by universe
Niko Matsakis [Tue, 8 Oct 2019 23:26:57 +0000 (19:26 -0400)]
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.

4 years agointegrate the `sub_free_regions` code so we have only one copy of it
Niko Matsakis [Tue, 8 Oct 2019 14:56:03 +0000 (10:56 -0400)]
integrate the `sub_free_regions` code so we have only one copy of it

4 years agodon't mention specific region numbers in the ~ERROR message
Niko Matsakis [Tue, 8 Oct 2019 09:11:50 +0000 (05:11 -0400)]
don't mention specific region numbers in the ~ERROR message

4 years agoadd a `IsEmpty` for use in verified bounds
Niko Matsakis [Tue, 8 Oct 2019 09:06:21 +0000 (05:06 -0400)]
add a `IsEmpty` for use in verified bounds

We currently have a kind of arbitrary check for `Verify` conditions
which says that if the "test region" is `'empty`, then the check
passes. This was added to fix #42467 -- it happens to be correct for
the purposes that we use verify bounds for, but it doesn't feel
generally correct. Replace with a more principled test.

4 years agodo not limit NiceRegionError to SubSupConflict or ConcreteFailure
Niko Matsakis [Mon, 11 Nov 2019 18:14:01 +0000 (13:14 -0500)]
do not limit NiceRegionError to SubSupConflict or ConcreteFailure

4 years agotests: add a revision to macro_backtrace without -Zmacro-backtrace.
Eduard-Mihai Burtescu [Thu, 6 Feb 2020 10:16:38 +0000 (12:16 +0200)]
tests: add a revision to macro_backtrace without -Zmacro-backtrace.

4 years agorustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros.
Eduard-Mihai Burtescu [Mon, 16 Dec 2019 13:56:47 +0000 (15:56 +0200)]
rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros.

4 years agorustc_errors: hide "in this macro invocation" when redundant, more explicitly.
Eduard-Mihai Burtescu [Sun, 15 Dec 2019 15:47:51 +0000 (17:47 +0200)]
rustc_errors: hide "in this macro invocation" when redundant, more explicitly.

4 years agorustc_errors: deduplicate the -Zmacro-backtrace suggestion message.
Eduard-Mihai Burtescu [Wed, 15 Jan 2020 15:50:26 +0000 (17:50 +0200)]
rustc_errors: deduplicate the -Zmacro-backtrace suggestion message.

4 years agorustc: rename -Zexternal-macro-backtrace to -Zmacro-backtrace.
Eduard-Mihai Burtescu [Sun, 15 Dec 2019 15:12:30 +0000 (17:12 +0200)]
rustc: rename -Zexternal-macro-backtrace to -Zmacro-backtrace.

4 years agorustc_errors: split macro backtrace rendering from <*macros> hacks.
Eduard-Mihai Burtescu [Fri, 13 Dec 2019 21:21:14 +0000 (23:21 +0200)]
rustc_errors: split macro backtrace rendering from <*macros> hacks.

4 years agoMark fn map_or() as eagerly evaluated.
Tom A. Wagner [Thu, 6 Feb 2020 11:09:16 +0000 (12:09 +0100)]
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.

4 years agoMake `krate` private
John Kåre Alsaker [Thu, 6 Feb 2020 16:14:38 +0000 (17:14 +0100)]
Make `krate` private

4 years agoAuto merge of #68893 - Dylan-DPC:rollup-3f2421a, r=Dylan-DPC
bors [Thu, 6 Feb 2020 15:43:00 +0000 (15:43 +0000)]
Auto merge of #68893 - Dylan-DPC:rollup-3f2421a, r=Dylan-DPC

Rollup of 9 pull requests

Successful merges:

 - #68691 (Remove `RefCell` usage from `ObligationForest`.)
 - #68751 (Implement `unused_parens` for `const` and `static` items)
 - #68788 (Towards unified `fn` grammar)
 - #68837 (Make associated item collection a query)
 - #68842 (or_patterns: add regression test for #68785)
 - #68844 (use def_path_str for missing_debug_impls message)
 - #68845 (stop using BytePos for computing spans in librustc_parse/parser/mod.rs)
 - #68869 (clean up E0271 explanation)
 - #68880 (Forbid using `0` as issue number)

Failed merges:

r? @ghost

4 years agoUpdate E0565 examples
Yuki Okushi [Thu, 6 Feb 2020 14:55:45 +0000 (23:55 +0900)]
Update E0565 examples

4 years agoRollup merge of #68880 - JohnTitor:issue-non-zero, r=Dylan-DPC
Dylan DPC [Thu, 6 Feb 2020 14:37:51 +0000 (15:37 +0100)]
Rollup merge of #68880 - JohnTitor:issue-non-zero, r=Dylan-DPC

Forbid using `0` as issue number

Fixes #67496

r? @Centril

4 years agoRollup merge of #68869 - GuillaumeGomez:err-explanation-e0271, r=Dylan-DPC
Dylan DPC [Thu, 6 Feb 2020 14:37:49 +0000 (15:37 +0100)]
Rollup merge of #68869 - GuillaumeGomez:err-explanation-e0271, r=Dylan-DPC

clean up E0271 explanation

r? @Dylan-DPC

4 years agoRollup merge of #68845 - dwrensha:fix-68783, r=estebank
Dylan DPC [Thu, 6 Feb 2020 14:37:47 +0000 (15:37 +0100)]
Rollup merge of #68845 - dwrensha:fix-68783, r=estebank

stop using BytePos for computing spans in librustc_parse/parser/mod.rs

Computing spans using logic such as `self.token.span.lo() + BytePos(1)` can cause internal compiler errors like #68730 when non-ascii characters are given as input.

#68735 partially addressed this problem, but only for one case. Moreover, its usage of `next_point()` does not actually align with what `bump_with()` expects. For example, given the token `>>=`, we should pass the span consisting of the final two characters `>=`, but `next_point()` advances the span beyond the end of the `=`.

This pull request instead computes the start of the new span by doing `start_point(self.token.span).hi()`. This matches `self.token.span.lo() + BytePos(1)` in the common case where the characters are ascii, and it gracefully handles multibyte characters.

Fixes #68783.

4 years agoRollup merge of #68844 - euclio:debug-impl-def-path, r=petrochenkov
Dylan DPC [Thu, 6 Feb 2020 14:37:46 +0000 (15:37 +0100)]
Rollup merge of #68844 - euclio:debug-impl-def-path, r=petrochenkov

use def_path_str for missing_debug_impls message

The lint message will now use the full, correct path to the `Debug`
trait, even in `no_std`.

4 years agoRollup merge of #68842 - Centril:issue-68785, r=estebank
Dylan DPC [Thu, 6 Feb 2020 14:37:44 +0000 (15:37 +0100)]
Rollup merge of #68842 - Centril:issue-68785, r=estebank

or_patterns: add regression test for #68785

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

(Fixed by https://github.com/rust-lang/rust/pull/67668.)

cc https://github.com/rust-lang/rust/issues/54883
r? @estebank

4 years agoRollup merge of #68837 - jonas-schievink:assoc-item-lookup-2, r=estebank
Dylan DPC [Thu, 6 Feb 2020 14:37:43 +0000 (15:37 +0100)]
Rollup merge of #68837 - jonas-schievink:assoc-item-lookup-2, r=estebank

Make associated item collection a query

Before this change, every time associated items were iterated over (which rustc does *a lot* – this can probably be further optimized), there would be N+1 queries to fetch all assoc. items. Now there's just one after they've been computed once.

4 years agoRollup merge of #68788 - Centril:unified-fn-bodies, r=petrochenkov
Dylan DPC [Thu, 6 Feb 2020 14:37:41 +0000 (15:37 +0100)]
Rollup merge of #68788 - Centril:unified-fn-bodies, r=petrochenkov

Towards unified `fn` grammar

Part of https://github.com/rust-lang/rust/pull/68728.

- Syntactically, `fn` items in `extern { ... }` blocks can now have bodies (`fn foo() { ... }` as opposed to `fn foo();`). As above, we use semantic restrictions instead.

- Syntactically, `fn` items in free contexts (directly in a file or a module) can now be without bodies (`fn foo();` as opposed to `fn foo() { ... }`. As above, we use semantic restrictions instead, including for non-ident parameter patterns.

- We move towards unifying the `fn` front matter; this is fully realized in https://github.com/rust-lang/rust/pull/68728.

r? @petrochenkov

4 years agoRollup merge of #68751 - Tyg13:unused_parens_const_static, r=Centril
Dylan DPC [Thu, 6 Feb 2020 14:37:39 +0000 (15:37 +0100)]
Rollup merge of #68751 - Tyg13:unused_parens_const_static, r=Centril

Implement `unused_parens` for `const` and `static` items

Fixes #67942

4 years agoRollup merge of #68691 - nnethercote:rm-RefCell-from-ObligationForest, r=nikomatsakis
Dylan DPC [Thu, 6 Feb 2020 14:37:38 +0000 (15:37 +0100)]
Rollup merge of #68691 - nnethercote:rm-RefCell-from-ObligationForest, r=nikomatsakis

Remove `RefCell` usage from `ObligationForest`.

It's not needed.

This doesn't affect performance, it just simplifies the code a little.

r? @nikomatsakis

4 years agoerror code examples: replace some more ignore with compile_fail
Trevor Spiteri [Thu, 6 Feb 2020 14:31:21 +0000 (15:31 +0100)]
error code examples: replace some more ignore with compile_fail

Now that 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.

4 years agoIgnore panic-drops-resume.rs on wasm/emscripten
Jonas Schievink [Thu, 6 Feb 2020 13:59:51 +0000 (14:59 +0100)]
Ignore panic-drops-resume.rs on wasm/emscripten

It does not have unwinding support

4 years agoComment tweaks
John Kåre Alsaker [Thu, 6 Feb 2020 13:11:57 +0000 (14:11 +0100)]
Comment tweaks

4 years agoRemove the `Forest` type
John Kåre Alsaker [Thu, 6 Feb 2020 12:41:37 +0000 (13:41 +0100)]
Remove the `Forest` type

4 years agoMove the `krate` method to Hir and remove the Krate dep node
John Kåre Alsaker [Thu, 6 Feb 2020 11:46:26 +0000 (12:46 +0100)]
Move the `krate` method to Hir and remove the Krate dep node

4 years agoClarify comment about `_2` living across a yield
Jonas Schievink [Thu, 6 Feb 2020 11:34:31 +0000 (12:34 +0100)]
Clarify comment about `_2` living across a yield

4 years agoSimplify implicit resume argument
Jonas Schievink [Thu, 6 Feb 2020 11:27:35 +0000 (12:27 +0100)]
Simplify implicit resume argument

4 years agoAdd a `hir_krate` query
John Kåre Alsaker [Thu, 6 Feb 2020 11:16:51 +0000 (12:16 +0100)]
Add a `hir_krate` query

4 years agoAdd a Hir wrapper type
John Kåre Alsaker [Thu, 6 Feb 2020 10:59:29 +0000 (11:59 +0100)]
Add a Hir wrapper type

4 years agoAuto merge of #68664 - tspiteri:no_run-complete-build, r=nikomatsakis
bors [Thu, 6 Feb 2020 08:48:01 +0000 (08:48 +0000)]
Auto merge of #68664 - tspiteri:no_run-complete-build, r=nikomatsakis

rustdoc: attempt full build for compile_fail test

Some code fails when doing a full build but does not fail when only emitting metadata. This commit makes sure compile_fail tests for such code behave as expected, that is, the test succeeds because the compilation fails.

Fixes #67771.

4 years agoForbid using `0` as issue number
Yuki Okushi [Thu, 6 Feb 2020 07:19:39 +0000 (16:19 +0900)]
Forbid using `0` as issue number

4 years agoAuto merge of #68583 - estebank:hrlt, r=oli-obk
bors [Thu, 6 Feb 2020 05:19:52 +0000 (05:19 +0000)]
Auto merge of #68583 - estebank:hrlt, r=oli-obk

Account for HR lifetimes when suggesting introduction of named lifetime

```
error[E0106]: missing lifetime specifier
 --> src/test/ui/suggestions/fn-missing-lifetime-in-item.rs:2:32
  |
2 | struct S2<F: Fn(&i32, &i32) -> &i32>(F);
  |                 ----  ----     ^ expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2
  = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the bound lifetime-generic with a new `'a` lifetime
  |
2 | struct S2<F: for<'a> Fn(&'a i32, &'a i32) -> &'a i32>(F);
  |              ^^^^^^^    ^^^^^^^  ^^^^^^^     ^^^
help: consider introducing a named lifetime parameter
  |
2 | struct S2<'a, F: Fn(&'a i32, &'a i32) -> &'a i32>(F);=
  |           ^^^       ^^^^^^^  ^^^^^^^     ^^^
```

Follow up to #68267. Addresses the diagnostics part of #49287.

4 years agounused-parens: implement for const/static items
Tyler Lanphear [Sat, 1 Feb 2020 23:30:52 +0000 (18:30 -0500)]
unused-parens: implement for const/static items

4 years agoAuto merge of #68861 - Dylan-DPC:rollup-0m09hsg, r=Dylan-DPC
bors [Thu, 6 Feb 2020 01:46:46 +0000 (01:46 +0000)]
Auto merge of #68861 - Dylan-DPC:rollup-0m09hsg, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #68762 (Strip unnecessary subexpression)
 - #68790 (Improve `merge_from_succ`)
 - #68809 (Make more arithmetic functions unstably const)
 - #68832 (Clean up E0264, E0267 and E0268 explanations)
 - #68840 (On suggesting `#![recursion_limit = "X"]`, note current crate name)
 - #68846 (doc fix on doc attribute)
 - #68851 (Fix issue number of `capacity` method)
 - #68858 (Merge item id stable hashing functions)

Failed merges:

r? @ghost

4 years agoRemove `RefCell` usage from `ObligationForest`.
Nicholas Nethercote [Fri, 31 Jan 2020 02:39:34 +0000 (13:39 +1100)]
Remove `RefCell` usage from `ObligationForest`.

It's not needed.

4 years agoAdd CodegenFnAttrFlags::NO_SANITIZE_ANY
Tomasz Miąsko [Thu, 6 Feb 2020 00:00:00 +0000 (00:00 +0000)]
Add CodegenFnAttrFlags::NO_SANITIZE_ANY

4 years agoAuto merge of #68461 - cjgillot:split_infer_prelude, r=matthewjasper
bors [Wed, 5 Feb 2020 22:41:54 +0000 (22:41 +0000)]
Auto merge of #68461 - cjgillot:split_infer_prelude, r=matthewjasper

Move datatypes definitions in specific modules inside rustc::{traits, infer}

Prelude to #67953

Some data types inside `rustc::traits` and `rustc::infer` are used in other parts of `librustc`. These cannot go to a separate crate `librustc_infer`.

This PR moves those data types to `traits::types` and `infer::types` modules, from where everything is reexported.

Note for review: some imports feature the `crate -> rustc` substitution. This is cruft from the splitting out of #67953. This can be reverted, but are bound to be put back by #67953.

r? @Centril
cc @Zoxc

4 years agoApply LLVM sanitize attributes to generated entry wrapper
Tomasz Miąsko [Thu, 16 Jan 2020 00:00:00 +0000 (00:00 +0000)]
Apply LLVM sanitize attributes to generated entry wrapper

4 years agoSelectively disable sanitizer instrumentation
Tomasz Miąsko [Sun, 12 Jan 2020 00:00:00 +0000 (00:00 +0000)]
Selectively disable sanitizer instrumentation

Add `no_sanitize` attribute that allows to opt out from sanitizer
instrumentation in an annotated function.

4 years agoclean E0271 explanation
Guillaume Gomez [Wed, 5 Feb 2020 22:03:03 +0000 (23:03 +0100)]
clean E0271 explanation

4 years agoAuto merge of #67429 - mati865:mingw-ultimate-fix, r=alexcrichton
bors [Wed, 5 Feb 2020 19:11:04 +0000 (19:11 +0000)]
Auto merge of #67429 - mati865:mingw-ultimate-fix, r=alexcrichton

windows-gnu: prefer system crt libraries if they are available

The origin of the issue is the fact Rust ships mingw-w64 libraries but no headers and prefers own libraries over the system ones.
This leads to situation when headers aren't compatible with libraries (mingw-w64 doesn't provide any forward compatibility and AFAIK backwards compatibility is guaranteed only within major release series).

It's easier to understand how this PR works when looking at the linker invocation before and with this PR: https://www.diffchecker.com/GEuYFmzo
It adds system libraries path before Rust libraries so the linker will prefer them.
It has potential issue when system has files with the same names as Rust but that could be avoided by moving Rust shipped mingw-w64 libraries from `lib/rustlib/x86_64-pc-windows-gnu/lib` to say `lib/rustlib/x86_64-pc-windows-gnu/lib/mingw`. Then adding linker paths in this order: Rust libraries, system libraries, Rust shipped mingw-w64 libraries.

Fixes #47048
Fixes #49078
Fixes #53454
Fixes #60912

4 years agoFix test
Esteban Küber [Wed, 5 Feb 2020 18:59:14 +0000 (10:59 -0800)]
Fix test

4 years agoAccount for `impl Trait`
Esteban Küber [Thu, 30 Jan 2020 19:53:47 +0000 (11:53 -0800)]
Account for `impl Trait`

Address #49287

4 years agoMove code to `diagnostics.rs`
Esteban Küber [Tue, 28 Jan 2020 23:04:18 +0000 (15:04 -0800)]
Move code to `diagnostics.rs`

4 years agoreview comments
Esteban Küber [Tue, 28 Jan 2020 01:33:13 +0000 (17:33 -0800)]
review comments

4 years agoreview comments: wording
Esteban Küber [Tue, 28 Jan 2020 00:25:43 +0000 (16:25 -0800)]
review comments: wording

4 years agoAccount for `fn()` types in lifetime suggestions
Esteban Küber [Tue, 28 Jan 2020 00:13:45 +0000 (16:13 -0800)]
Account for `fn()` types in lifetime suggestions

4 years agoAccount for `'_` in suggestions
Esteban Küber [Mon, 27 Jan 2020 22:35:20 +0000 (14:35 -0800)]
Account for `'_` in suggestions

4 years agoreview comments
Esteban Küber [Mon, 27 Jan 2020 22:08:59 +0000 (14:08 -0800)]
review comments

4 years agoSuggest `'r` instead of `'lifetime`
Esteban Küber [Mon, 27 Jan 2020 20:49:12 +0000 (12:49 -0800)]
Suggest `'r` instead of `'lifetime`

4 years agoWhen suggesting lifetimes, propose adding the new lifetime to all arguments
Esteban Küber [Mon, 27 Jan 2020 20:41:49 +0000 (12:41 -0800)]
When suggesting lifetimes, propose adding the new lifetime to all arguments

4 years agoUse spans for input borrowed types unrelated to return type
Esteban Küber [Mon, 27 Jan 2020 19:48:52 +0000 (11:48 -0800)]
Use spans for input borrowed types unrelated to return type

4 years agoAccount for HKTB when suggesting introduction of named lifetime
Esteban Küber [Mon, 27 Jan 2020 19:26:06 +0000 (11:26 -0800)]
Account for HKTB when suggesting introduction of named lifetime