]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoRollup merge of #69022 - ljedrz:traits_tweak_vecs, r=petrochenkov
Dylan DPC [Tue, 11 Feb 2020 15:36:59 +0000 (16:36 +0100)]
Rollup merge of #69022 - ljedrz:traits_tweak_vecs, r=petrochenkov

traits: preallocate 2 Vecs of known initial size

The 2 preallocations are pretty obvious; both vectors will be as big as or larger than the collections they are created from.

In `WfPredicates::normalize` the change from a functional style improves readability and should be perf-friendly, too.

4 years agoRollup merge of #68824 - ajpaverd:cfguard-rustbuild, r=Mark-Simulacrum
Dylan DPC [Tue, 11 Feb 2020 15:36:57 +0000 (16:36 +0100)]
Rollup merge of #68824 - ajpaverd:cfguard-rustbuild, r=Mark-Simulacrum

Enable Control Flow Guard in rustbuild

Now that Rust supports Control Flow Guard (#68180), add a config.toml option to build the standard library with CFG enabled.

r? @nagisa

4 years agoRollup merge of #68816 - estebank:fn-mut-closure, r=varkor
Dylan DPC [Tue, 11 Feb 2020 15:36:55 +0000 (16:36 +0100)]
Rollup merge of #68816 - estebank:fn-mut-closure, r=varkor

Tweak borrow error on `FnMut` when `Fn` is expected

Fix #31701, fix #66097.

4 years agoRollup merge of #66498 - bjorn3:less_feature_flags, r=Dylan-DPC
Dylan DPC [Tue, 11 Feb 2020 15:36:54 +0000 (16:36 +0100)]
Rollup merge of #66498 - bjorn3:less_feature_flags, r=Dylan-DPC

Remove unused feature gates

I think many of the remaining unstable things can be easily be replaced with stable things. I have kept the `#![feature(nll)]` even though it is only necessary in `libstd`, to make regressions of it harder.

4 years agoAuto merge of #68961 - eddyb:dbg-stack-dunk, r=nagisa
bors [Tue, 11 Feb 2020 07:36:59 +0000 (07:36 +0000)]
Auto merge of #68961 - eddyb:dbg-stack-dunk, r=nagisa

rustc_codegen_ssa: only "spill" SSA-like values to the stack for debuginfo.

This is an implementation of the idea described in https://github.com/rust-lang/rust/issues/68817#issuecomment-583719182.

In short, instead of debuginfo forcing otherwise-SSA-like MIR locals into `alloca`s, and requiring a `load` for each use (or two, for scalar pairs), the `alloca` is now *only* used for attaching debuginfo with `llvm.dbg.declare`: the `OperandRef` is stored to the `alloca`, but *never loaded* from it.

Outside of `debug_introduce_local`, nothing cares about the debuginfo-only `alloca`, and instead works with `OperandRef` the same as MIR locals without debuginfo before this PR.

This should have some of the benefits of `llvm.dbg.value`, while working today.

cc @nagisa @nikomatsakis

4 years agoAuto merge of #68929 - matprec:consistent-issue-references, r=Dylan-DPC
bors [Tue, 11 Feb 2020 02:00:27 +0000 (02:00 +0000)]
Auto merge of #68929 - matprec:consistent-issue-references, r=Dylan-DPC

Make issue references consistent

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

cc https://github.com/rust-lang/rust/pull/63008

r? @varkor because you reviewed the original pr

4 years agoAuto merge of #69030 - Dylan-DPC:rollup-t9uk7vc, r=Dylan-DPC
bors [Mon, 10 Feb 2020 22:46:29 +0000 (22:46 +0000)]
Auto merge of #69030 - Dylan-DPC:rollup-t9uk7vc, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #68897 (clean up E0275 explanation)
 - #68908 (Add long error code explanation message for E0637 )
 - #68932 (self-profile: Support arguments for generic_activities.)
 - #68986 (Make ASCII ctype functions unstably const )
 - #69007 (Clean up E0283 explanation)
 - #69014 (change an instance of span_bug() to struct_span_err() to avoid ICE)

Failed merges:

r? @ghost

4 years agoEnable Control Flow Guard in rustbuild
Andrew Paverd [Tue, 28 Jan 2020 14:29:44 +0000 (14:29 +0000)]
Enable Control Flow Guard in rustbuild

4 years agoRollup merge of #69014 - dwrensha:fix-68890, r=Centril
Dylan DPC [Mon, 10 Feb 2020 16:29:03 +0000 (17:29 +0100)]
Rollup merge of #69014 - dwrensha:fix-68890, r=Centril

change an instance of span_bug() to struct_span_err() to avoid ICE

After #67148, the `span_bug()` in `parse_ty_tuple_or_parens()` is reachable because `parse_paren_comma_seq()` can return an `Ok()` even in cases where it encounters an error.
This pull request prevents an ICE in such cases by replacing the `span_bug()` with `struct_span_error()`.

Fixes #68890.

4 years agoRollup merge of #69007 - GuillaumeGomez:clean-up-e0283, r=Dylan-DPC
Dylan DPC [Mon, 10 Feb 2020 16:29:01 +0000 (17:29 +0100)]
Rollup merge of #69007 - GuillaumeGomez:clean-up-e0283, r=Dylan-DPC

Clean up E0283 explanation

r? @Dylan-DPC

4 years agoRollup merge of #68986 - ecstatic-morse:const-ascii-ctype, r=Centril
Dylan DPC [Mon, 10 Feb 2020 16:28:59 +0000 (17:28 +0100)]
Rollup merge of #68986 - ecstatic-morse:const-ascii-ctype, r=Centril

Make ASCII ctype functions unstably const

Makes the following inherent methods on `u8` and `char` unstable `const fn`:

 * `is_ascii_alphabetic`
 * `is_ascii_uppercase`
 * `is_ascii_lowercase`
 * `is_ascii_alphanumeric`
 * `is_ascii_digit`
 * `is_ascii_hexdigit`
 * `is_ascii_punctuation`
 * `is_ascii_graphic`
 * `is_ascii_whitespace`
 * `is_ascii_control`

cc #68983

4 years agoRollup merge of #68932 - michaelwoerister:self-profile-generic-activity-args, r=wesle...
Dylan DPC [Mon, 10 Feb 2020 16:28:57 +0000 (17:28 +0100)]
Rollup merge of #68932 - michaelwoerister:self-profile-generic-activity-args, r=wesleywiser

self-profile: Support arguments for generic_activities.

This PR adds support for recording arguments of "generic activities". The most notable use case is LLVM module names, which should be very interesting for `crox` profiles. In the future it might be interesting to add more fine-grained events for pre-query passes like macro expansion.

I tried to judiciously de-duplicate existing self-profile events with `extra_verbose_generic_activity`, now that the latter also generates self-profile events.

r? @wesleywiser

4 years agoRollup merge of #68908 - jwhite927:E0637, r=Dylan-DPC
Dylan DPC [Mon, 10 Feb 2020 16:28:56 +0000 (17:28 +0100)]
Rollup merge of #68908 - jwhite927:E0637, r=Dylan-DPC

Add long error code explanation message for E0637

Reference issue [#61137](https://github.com/rust-lang/rust/issues/61137)
To incorporate a long error description for E0637, I have made the necessary modification to error_codes.rs and added error_codes/E0637.md, and blessed the relevant .stderror files. ~~, however when I build rustc stage 1, I am unable to make `$ rustc --explain E0637` work even though rustc appears to be able to call up the long error explanations for other errors. I wanted to guarantee this would work before moving on the blessing the various ui tests that have been affected. @GuillaumeGomez Do you know the most likely reason(s) why this would be the case?~~
Update: `$ rustc --explain E0637` works now.

4 years agoRollup merge of #68897 - GuillaumeGomez:clean-up-e0275, r=Dylan-DPC
Dylan DPC [Mon, 10 Feb 2020 16:28:54 +0000 (17:28 +0100)]
Rollup merge of #68897 - GuillaumeGomez:clean-up-e0275, r=Dylan-DPC

clean up E0275 explanation

r? @Dylan-DPC

4 years agoAuto merge of #68835 - CAD97:sound-range-inclusive, r=Mark-Simulacrum
bors [Mon, 10 Feb 2020 15:24:59 +0000 (15:24 +0000)]
Auto merge of #68835 - CAD97:sound-range-inclusive, r=Mark-Simulacrum

Remove problematic specialization from RangeInclusive

Fixes #67194 using the approach [outlined by Mark-Simulacrum](https://github.com/rust-lang/rust/issues/67194#issuecomment-581669549).

> I believe the property we want is that if `PartialEq(&self, &other) == true`, then `self.next() == other.next()`. It is true that this is satisfied by removing the specialization and always doing `is_empty.unwrap_or_default()`; the "wrong" behavior there arises from calling `next()` having an effect on initially empty ranges, as we should be in `is_empty = true` but are not (yet) there. It might be possible to detect that the current state is always empty (i.e., `start > end`) and then not fill in the empty slot. I think this might solve the problem without regressing tests; however, this could have performance implications.

> That approach essentially states that we only use the `is_empty` slot for cases where `start <= end`. That means that `Idx: !Step` and `start > end` would both behave the same, and correctly -- we do not need the boolean if we're not ever going to emit any values from the iterator.

This is implemented here by replacing the `is_empty: Option<bool>` slot with an `exhausted: bool` slot. This flag is

- `false` upon construction,
- `false` when iteration has not yielded an element -- importantly, this means it is always `false` for an iterator empty by construction,
- `false` when iteration has yielded an element and the iterator is not exhausted, and
- only `true` when iteration has been used to exhaust the iterator.

For completeness, this also adds a note to the `Debug` representation to note when the range is exhausted.

4 years agoself-profile: Support arguments for generic_activities.
Michael Woerister [Fri, 7 Feb 2020 14:01:23 +0000 (15:01 +0100)]
self-profile: Support arguments for generic_activities.

4 years agopreallocate 2 Vecs in traits; tweak WfPredicates::normalize
ljedrz [Mon, 10 Feb 2020 13:28:56 +0000 (14:28 +0100)]
preallocate 2 Vecs in traits; tweak WfPredicates::normalize

4 years agoclean up E0275 explanation
Guillaume Gomez [Thu, 6 Feb 2020 16:53:03 +0000 (17:53 +0100)]
clean up E0275 explanation

4 years agoClean up E0283 explanation
Guillaume Gomez [Sun, 9 Feb 2020 22:11:54 +0000 (23:11 +0100)]
Clean up E0283 explanation

4 years agoAuto merge of #69012 - Dylan-DPC:rollup-13qn0fq, r=Dylan-DPC
bors [Mon, 10 Feb 2020 10:47:39 +0000 (10:47 +0000)]
Auto merge of #69012 - Dylan-DPC:rollup-13qn0fq, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #68694 (Reduce the number of `RefCell`s in `InferCtxt`.)
 - #68966 (Improve performance of coherence checks)
 - #68976 (Make `num::NonZeroX::new` an unstable `const fn`)
 - #68992 (Correctly parse `mut a @ b`)
 - #69005 (Small graphviz improvements for the new dataflow framework)
 - #69006 (parser: Keep current and previous tokens precisely)

Failed merges:

r? @ghost

4 years ago[parser] change an instance of span_bug() to struct_span_err() to avoid ICE
David Renshaw [Mon, 10 Feb 2020 04:01:23 +0000 (23:01 -0500)]
[parser] change an instance of span_bug() to struct_span_err() to avoid ICE

4 years agoRollup merge of #69006 - petrochenkov:prevspan2, r=Centril
Dylan DPC [Mon, 10 Feb 2020 00:54:23 +0000 (01:54 +0100)]
Rollup merge of #69006 - petrochenkov:prevspan2, r=Centril

parser: Keep current and previous tokens precisely

...including their unnormalized forms.
Add more documentation for them.

Hopefully, this will help to eliminate footguns like https://github.com/rust-lang/rust/pull/68728#discussion_r373787486.

I'll try to address the FIXMEs in separate PRs during the next week.

r? @Centril

4 years agoRollup merge of #69005 - ecstatic-morse:unified-dataflow-graphviz, r=wesleywiser
Dylan DPC [Mon, 10 Feb 2020 00:54:21 +0000 (01:54 +0100)]
Rollup merge of #69005 - ecstatic-morse:unified-dataflow-graphviz, r=wesleywiser

Small graphviz improvements for the new dataflow framework

Split out from #68241. This prints the correct effect diff for each line (the before-effect and the after-effect) and makes marginal improvements to the graphviz output for the new dataflow framework including using monospaced font and better line breaking. This will only be useful when #68241 is merged and the graphviz output changes from this:

![image](https://user-images.githubusercontent.com/29463364/74107776-5e3c3300-4b28-11ea-9d33-4862228b5e87.png)

to this:

![image](https://user-images.githubusercontent.com/29463364/74107751-20d7a580-4b28-11ea-99ca-24f749386601.png)

r? @wesleywiser

4 years agoRollup merge of #68992 - matthewjasper:imm-binding-after-at, r=Centril
Dylan DPC [Mon, 10 Feb 2020 00:54:20 +0000 (01:54 +0100)]
Rollup merge of #68992 - matthewjasper:imm-binding-after-at, r=Centril

Correctly parse `mut a @ b`

r? @Centril

Closes #67861
Closes #67926

4 years agoRollup merge of #68976 - ecstatic-morse:const-non-zero, r=dtolnay
Dylan DPC [Mon, 10 Feb 2020 00:54:18 +0000 (01:54 +0100)]
Rollup merge of #68976 - ecstatic-morse:const-non-zero, r=dtolnay

Make `num::NonZeroX::new` an unstable `const fn`

cc #53718

These require `#[feature(const_if_match)]`, meaning they must remain unstable for the time being.

4 years agoRollup merge of #68966 - jonas-schievink:coherence-perf, r=varkor
Dylan DPC [Mon, 10 Feb 2020 00:54:17 +0000 (01:54 +0100)]
Rollup merge of #68966 - jonas-schievink:coherence-perf, r=varkor

Improve performance of coherence checks

The biggest perf improvement in here is expected to come from the removal of the remaining #43355 warning code since that effectively runs the expensive parts of coherence *twice*, which can even be visualized by obtaining a flamegraph:

![image](https://user-images.githubusercontent.com/5047365/74091959-e1f41200-4a8b-11ea-969d-2849d3f86c63.png)

4 years agoRollup merge of #68694 - nnethercote:reduce-RefCells-in-InferCtxt, r=varkor
Dylan DPC [Mon, 10 Feb 2020 00:54:15 +0000 (01:54 +0100)]
Rollup merge of #68694 - nnethercote:reduce-RefCells-in-InferCtxt, r=varkor

Reduce the number of `RefCell`s in `InferCtxt`.

`InferCtxt` contains six structures within `RefCell`s. Every time we
create and dispose of (commit or rollback) a snapshot we have to
`borrow_mut` each one of them.

This commit moves the six structures under a single `RefCell`, which
gives significant speed-ups by reducing the number of `borrow_mut`
calls. To avoid runtime errors I had to reduce the lifetimes of dynamic
borrows in a couple of places.

r? @varkor

4 years agoRemove vestigial #43355-compat code
Jonas Schievink [Sat, 8 Feb 2020 18:14:50 +0000 (19:14 +0100)]
Remove vestigial #43355-compat code

This was previously a future-compat warning that has since been turned into
hard error, but without actually removing all the code.

Avoids a call to `traits::overlapping_impls`, which is expensive.

4 years agoDefer error span calculation until needed
Jonas Schievink [Fri, 7 Feb 2020 23:45:03 +0000 (00:45 +0100)]
Defer error span calculation until needed

This was showing up in profiles. Also deduplicates the code to get just
the impl header span.

4 years agoAdd desc to `specialization_graph_of` query
Jonas Schievink [Fri, 7 Feb 2020 23:27:24 +0000 (00:27 +0100)]
Add desc to `specialization_graph_of` query

4 years agoReduce queries/map lookups done by coherence
Jonas Schievink [Fri, 7 Feb 2020 23:27:07 +0000 (00:27 +0100)]
Reduce queries/map lookups done by coherence

This has negligible perf impact, but it does improve the code a bit.

* Only query the specialization graph of any trait once instead of once per
  impl
* Loop over impls only once, precomputing impl DefId and TraitRef

4 years agoAuto merge of #67665 - Patryk27:master, r=zackmdavis
bors [Sun, 9 Feb 2020 22:13:05 +0000 (22:13 +0000)]
Auto merge of #67665 - Patryk27:master, r=zackmdavis

Improve reporting errors and suggestions for trait bounds

Fix #66802

- When printing errors for unsized function parameter, properly point at the parameter instead of function's body.
- Improve `consider further restricting this bound` (and related) messages by separating human-oriented hints from the machine-oriented ones.

4 years agoReduce the number of `RefCell`s in `InferCtxt`.
Nicholas Nethercote [Thu, 30 Jan 2020 21:45:57 +0000 (08:45 +1100)]
Reduce the number of `RefCell`s in `InferCtxt`.

`InferCtxt` contains six structures within `RefCell`s. Every time we
create and dispose of (commit or rollback) a snapshot we have to
`borrow_mut` each one of them.

This commit moves the six structures under a single `RefCell`, which
gives significant speed-ups by reducing the number of `borrow_mut`
calls. To avoid runtime errors I had to reduce the lifetimes of dynamic
borrows in a couple of places.

4 years agoparser: Keep current and previous tokens precisely
Vadim Petrochenkov [Sun, 9 Feb 2020 14:54:38 +0000 (17:54 +0300)]
parser: Keep current and previous tokens precisely

including their unnormalized forms.
Add more documentation for them.

4 years ago--bless --compare-mode=nll
Matthias Prechtl [Fri, 7 Feb 2020 12:07:02 +0000 (13:07 +0100)]
--bless --compare-mode=nll

4 years agoMake issue references consistent
Matthias Prechtl [Fri, 7 Feb 2020 12:06:35 +0000 (13:06 +0100)]
Make issue references consistent

4 years agoUpdate for #68718
bjorn3 [Sun, 9 Feb 2020 18:52:42 +0000 (19:52 +0100)]
Update for #68718

4 years agoAuto merge of #69004 - jonas-schievink:rollup-z2ymler, r=jonas-schievink
bors [Sun, 9 Feb 2020 18:44:39 +0000 (18:44 +0000)]
Auto merge of #69004 - jonas-schievink:rollup-z2ymler, r=jonas-schievink

Rollup of 5 pull requests

Successful merges:

 - #68738 (Derive Clone + Eq for std::string::FromUtf8Error)
 - #68742 (implement AsMut<str> for String)
 - #68881 (rustc_codegen_llvm: always set AlwaysPreserve on all debuginfo variables)
 - #68911 (Speed up the inherent impl overlap check)
 - #68913 (Pretty-print generic params and where clauses on associated types)

Failed merges:

r? @ghost

4 years agoUse nicer alignment when printing state vectors
Dylan MacKenzie [Tue, 21 Jan 2020 21:37:59 +0000 (13:37 -0800)]
Use nicer alignment when printing state vectors

4 years agoDon't break first line
Dylan MacKenzie [Tue, 21 Jan 2020 21:37:02 +0000 (13:37 -0800)]
Don't break first line

4 years agoRemove unnecessary allows
Dylan MacKenzie [Tue, 21 Jan 2020 21:36:34 +0000 (13:36 -0800)]
Remove unnecessary allows

4 years agoAdd option to `dot::render` for monospace font
Dylan MacKenzie [Tue, 21 Jan 2020 21:35:17 +0000 (13:35 -0800)]
Add option to `dot::render` for monospace font

4 years agoPrint `after` effect in default graphviz formatter
Dylan MacKenzie [Tue, 21 Jan 2020 02:36:54 +0000 (18:36 -0800)]
Print `after` effect in default graphviz formatter

Now the line for each statement will show the diff resulting from the
combination of `before_statement_effect` and `statement_effect`. It's
still possible to observe each in isolation via
`borrowck_graphviz_format = "two_phase"`.

4 years agoRollup merge of #68913 - Areredify:gat_pretty, r=cramertj
Jonas Schievink [Sun, 9 Feb 2020 17:23:34 +0000 (18:23 +0100)]
Rollup merge of #68913 - Areredify:gat_pretty, r=cramertj

Pretty-print generic params and where clauses on associated types

closes #67509

4 years agoRollup merge of #68911 - jonas-schievink:inherent-overlap, r=petrochenkov
Jonas Schievink [Sun, 9 Feb 2020 17:23:33 +0000 (18:23 +0100)]
Rollup merge of #68911 - jonas-schievink:inherent-overlap, r=petrochenkov

Speed up the inherent impl overlap check

This gives a ~7% improvement in compile times for the stm32f0(x2) crate.

Also addresses @eddyb's comment in https://github.com/rust-lang/rust/pull/68837#discussion_r375701767.

4 years agoRollup merge of #68881 - eddyb:always-preserve-dbg-vars, r=nagisa
Jonas Schievink [Sun, 9 Feb 2020 17:23:31 +0000 (18:23 +0100)]
Rollup merge of #68881 - eddyb:always-preserve-dbg-vars, r=nagisa

rustc_codegen_llvm: always set AlwaysPreserve on all debuginfo variables

Making this depend on the optimization level appears to have been a copy-paste mistake (other LLVM functions called in this module also take a `bool` argument, but there it means something unrelated).
Also see https://github.com/rust-lang/rust/pull/8855#discussion_r374392128.

I don't believe we have any reason to let LLVM omit user variables from DWARF, and we were already setting this to `true` when LLVM *could* optimize them away, so this PR should have no effect anyway.

r? @michaelwoerister or @nagisa cc @hanna-kruppe @nikomatsakis

4 years agoRollup merge of #68742 - tspiteri:string-as-mut, r=sfackler
Jonas Schievink [Sun, 9 Feb 2020 17:23:30 +0000 (18:23 +0100)]
Rollup merge of #68742 - tspiteri:string-as-mut, r=sfackler

implement AsMut<str> for String

Closes #68741.

4 years agoRollup merge of #68738 - kennytm:derive-clone-eq-for-fromutf8error, r=sfackler
Jonas Schievink [Sun, 9 Feb 2020 17:23:28 +0000 (18:23 +0100)]
Rollup merge of #68738 - kennytm:derive-clone-eq-for-fromutf8error, r=sfackler

Derive Clone + Eq for std::string::FromUtf8Error

Implement `Clone` and `Eq` for `std::string::FromUtf8Error`.

Both the inner `Vec<u8>` and `std::str::Utf8Error` are also `Clone + Eq`, so I don't see why we shouldn't derive them on `FromUtf8Error` as well.

(impl are insta-stable, requiring FCP from T-libs.)

4 years agoAuto merge of #68623 - Zoxc:lld, r=Mark-Simulacrum
bors [Sun, 9 Feb 2020 15:24:50 +0000 (15:24 +0000)]
Auto merge of #68623 - Zoxc:lld, r=Mark-Simulacrum

Add an option to use LLD to link the compiler on Windows platforms

Based on https://github.com/rust-lang/rust/pull/68609.

Using LLD is good way to improve compile times on Windows since `link.exe` is quite slow. The time for `x.py build --stage 1 src/libtest` goes from 0:12:00 to 0:08:29. Compile time for `rustc_driver` goes from 226.34s to 18.5s. `rustc_macros` goes from 28.69s to 7.7s. The size of `rustc_driver` is also reduced from 83.3 MB to 78.7 MB.

r? @Mark-Simulacrum

4 years agorustc_codegen_ssa: only "spill" SSA-like values to the stack for debuginfo.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 17:24:31 +0000 (19:24 +0200)]
rustc_codegen_ssa: only "spill" SSA-like values to the stack for debuginfo.

4 years agorustc_codegen_ssa: use `debug_introduce_local` on Operand call results.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 17:20:45 +0000 (19:20 +0200)]
rustc_codegen_ssa: use `debug_introduce_local` on Operand call results.

4 years agoMore comments
John Kåre Alsaker [Sun, 9 Feb 2020 13:35:50 +0000 (14:35 +0100)]
More comments

4 years agoAdd some comments
John Kåre Alsaker [Sun, 9 Feb 2020 13:26:13 +0000 (14:26 +0100)]
Add some comments

4 years agoDon't parse `mut a @ b` as `mut a @ mut b`
Matthew Jasper [Sun, 9 Feb 2020 13:19:06 +0000 (13:19 +0000)]
Don't parse `mut a @ b` as `mut a @ mut b`

4 years agoAuto merge of #68975 - Dylan-DPC:rollup-jzab8oh, r=Dylan-DPC
bors [Sun, 9 Feb 2020 10:20:46 +0000 (10:20 +0000)]
Auto merge of #68975 - Dylan-DPC:rollup-jzab8oh, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #68718 (Move `rustc_hir::def_id` to `rustc_span::def_id`)
 - #68834 (Fix and test implementation of BTreeMap's first/last_entry, pop_first/last)
 - #68857 (perf: Reduce Vec allocations in normalization by passing &mut Vec)
 - #68918 (Don't use the word "unwrap" to describe "unwrap" methods)
 - #68946 (Mark several functions and methods in core::cmp as #[must_use])
 - #68958 (Clean up E0277 and E0282 explanations)
 - #68960 (codegen: misc cleanups around debuginfo scopes and locations.)

Failed merges:

r? @ghost

4 years agoImprove reporting errors and suggestions for trait bounds
Patryk Wychowaniec [Thu, 26 Dec 2019 12:43:33 +0000 (13:43 +0100)]
Improve reporting errors and suggestions for trait bounds

4 years agoAuto merge of #68689 - estebank:where-clause-sugg-missing-fn, r=varkor
bors [Sun, 9 Feb 2020 07:11:56 +0000 (07:11 +0000)]
Auto merge of #68689 - estebank:where-clause-sugg-missing-fn, r=varkor

When suggesting associated fn with type parameters, include in the structured suggestion

Address #50734.

```
error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `baz`
  --> file.rs:14:1
   |
14 | impl TraitA<()> for S {
   | ^^^^^^^^^^^^^^^^^^^^^ missing `foo`, `bar`, `baz` in implementation
   |
   = help: implement the missing item: `fn foo<T>(_: T) -> Self where T: TraitB, TraitB::Item = A { unimplemented!() }`
   = help: implement the missing item: `fn bar<T>(_: T) -> Self { unimplemented!() }`
   = help: implement the missing item: `fn baz<T>(_: T) -> Self where T: TraitB, <T as TraitB>::Item: std::marker::Copy { unimplemented!() }`
```

It doesn't work well for associated types with `ty::Predicate::Projection`s as we need to resugar `T: Trait, Trait::Assoc = K` → `T: Trait<Assoc = K>`.

4 years agoTest ASCII ctype methods in a const context
Dylan MacKenzie [Sun, 9 Feb 2020 06:16:13 +0000 (22:16 -0800)]
Test ASCII ctype methods in a const context

4 years agoMake the ASCII ctype inherent methods const
Dylan MacKenzie [Sun, 9 Feb 2020 05:29:16 +0000 (21:29 -0800)]
Make the ASCII ctype inherent methods const

4 years agoreview comment
Esteban Küber [Fri, 31 Jan 2020 19:35:37 +0000 (11:35 -0800)]
review comment

4 years agoreview comments
Esteban Küber [Sun, 9 Feb 2020 05:05:43 +0000 (21:05 -0800)]
review comments

4 years agoAuto merge of #68376 - Centril:move-ref-patterns, r=matthewjasper
bors [Sun, 9 Feb 2020 04:01:28 +0000 (04:01 +0000)]
Auto merge of #68376 - Centril:move-ref-patterns, r=matthewjasper

Initial implementation of `#![feature(move_ref_pattern)]`

Following up on #45600, under the gate `#![feature(move_ref_pattern)]`, `(ref x, mut y)` is allowed subject to restrictions necessary for soundness. The match checking implementation and tests for `#![feature(bindings_after_at)]` is also adjusted as necessary.

Closes #45600.
Tracking issue: #68354.

r? @matthewjasper

4 years agoTest `NonZeroU8::new` in a const context
Dylan MacKenzie [Sun, 9 Feb 2020 00:02:37 +0000 (16:02 -0800)]
Test `NonZeroU8::new` in a const context

4 years agoMake `num::NonZeroX::new` an unstable `const fn`
Dylan MacKenzie [Sun, 9 Feb 2020 00:02:20 +0000 (16:02 -0800)]
Make `num::NonZeroX::new` an unstable `const fn`

4 years agoRollup merge of #68960 - eddyb:llvm-dbg-cleanup, r=nagisa
Dylan DPC [Sat, 8 Feb 2020 23:54:00 +0000 (00:54 +0100)]
Rollup merge of #68960 - eddyb:llvm-dbg-cleanup, r=nagisa

codegen: misc cleanups around debuginfo scopes and locations.

See each commit message. Most of these seem to be leftovers from the transition to MIR codegen.

r? @nagisa cc @bjorn3

4 years agoRollup merge of #68958 - GuillaumeGomez:clean-up-e0277-e0282, r=Dylan-DPC
Dylan DPC [Sat, 8 Feb 2020 23:53:58 +0000 (00:53 +0100)]
Rollup merge of #68958 - GuillaumeGomez:clean-up-e0277-e0282, r=Dylan-DPC

Clean up E0277 and E0282 explanations

r? @Dylan-DPC

4 years agoRollup merge of #68946 - mjbshaw:must_use, r=mjbshaw
Dylan DPC [Sat, 8 Feb 2020 23:53:56 +0000 (00:53 +0100)]
Rollup merge of #68946 - mjbshaw:must_use, r=mjbshaw

Mark several functions and methods in core::cmp as #[must_use]

These functions and methods aren't mutating functions and ignoring the result of them is likely a bug in the user's code.

4 years agoRollup merge of #68918 - brson:unwrapdoc, r=Dylan-DPC
Dylan DPC [Sat, 8 Feb 2020 23:53:55 +0000 (00:53 +0100)]
Rollup merge of #68918 - brson:unwrapdoc, r=Dylan-DPC

Don't use the word "unwrap" to describe "unwrap" methods

It's tautological, and "unwrap" is essentially Rust-specific jargon.

I was teaching a newbie some Rust, and doing the usual hand-waving about error handling using unwrap. They asked what 'unwrap' means. I said look it up in the docs. The docs read (paraphrased) "unwrap unwraps". I was embarrassed.

This changes all the Option/Result functions with unwrapping behavior to use a variation on a single description:

> "Returns the contained `Some/Ok` value [or ...]."

It also renames the closure of `Result::unwrap_or_else` to `default` for consistency with `Option`, and perhaps makes a few other small tweaks.

Previous: https://github.com/rust-lang/rust/pull/68849

4 years agoRollup merge of #68857 - Marwes:allocations, r=matthewjasper
Dylan DPC [Sat, 8 Feb 2020 23:53:53 +0000 (00:53 +0100)]
Rollup merge of #68857 - Marwes:allocations, r=matthewjasper

perf: Reduce Vec allocations in normalization by passing &mut Vec

Complicates the code a bit but allocation/freeing were a few percent of the overall runtime in trait heavy code.

4 years agoRollup merge of #68834 - ssomers:btree_first_last_fix68829, r=KodrAus
Dylan DPC [Sat, 8 Feb 2020 23:53:52 +0000 (00:53 +0100)]
Rollup merge of #68834 - ssomers:btree_first_last_fix68829, r=KodrAus

Fix and test implementation of BTreeMap's first/last_entry, pop_first/last

Properly implement and test `first_entry` & `last_entry` to fix problem report #68829

4 years agoRollup merge of #68718 - Aaron1011:move-def-hir-span, r=petrochenkov
Dylan DPC [Sat, 8 Feb 2020 23:53:50 +0000 (00:53 +0100)]
Rollup merge of #68718 - Aaron1011:move-def-hir-span, r=petrochenkov

Move `rustc_hir::def_id` to `rustc_span::def_id`

This will allow `HygieneData` to refer to `DefId` and `DefIndex`, which
will enable proper serialization of Span hygiene information.

This also reduces the number of things imported from `rustc_hir`, which
might make it easier to remove dependencies on it.

4 years agoDisable failing codegen test
CAD97 [Wed, 5 Feb 2020 20:51:27 +0000 (15:51 -0500)]
Disable failing codegen test

4 years agoRemove problematic specialization from RangeInclusive
CAD97 [Tue, 4 Feb 2020 22:54:16 +0000 (17:54 -0500)]
Remove problematic specialization from RangeInclusive

4 years agoMove librustc_hir/def_id.rs to librustc_span/def_id.rs
Aaron Hill [Sat, 8 Feb 2020 20:06:31 +0000 (15:06 -0500)]
Move librustc_hir/def_id.rs to librustc_span/def_id.rs

For noww, librustc_hir re-exports the `def_id` module from
librustc_span, so the rest of rustc can continue to reference
rustc_hir::def_id

4 years agoMerge branch 'master' of https://github.com/jwhite927/rust into E0637
Josh White [Sat, 8 Feb 2020 21:30:40 +0000 (16:30 -0500)]
Merge branch 'master' of https://github.com/jwhite927/rust into E0637

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 agoTidied up E0637.md
Josh White [Sat, 8 Feb 2020 21:26:09 +0000 (16:26 -0500)]
Tidied up E0637.md

4 years agoReduce Vec allocations in normalization by passing &mut Vec
Markus Westerlind [Wed, 8 Jan 2020 21:06:25 +0000 (22:06 +0100)]
Reduce Vec allocations in normalization by passing &mut Vec

4 years agoCorrected E0637.md based on test failures
Josh White [Sat, 8 Feb 2020 19:24:35 +0000 (14:24 -0500)]
Corrected E0637.md based on test failures

4 years agoMark several functions and methods in core::cmp as #[must_use]
Michael Bradshaw [Sat, 8 Feb 2020 06:13:36 +0000 (22:13 -0800)]
Mark several functions and methods in core::cmp as #[must_use]

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 agorustc_codegen_ssa: remove unnecessary source_locations_enabled.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 16:27:49 +0000 (18:27 +0200)]
rustc_codegen_ssa: remove unnecessary source_locations_enabled.

4 years agorustc_codegen_llvm: remove InternalDebugLocation and simplify dbg_var_addr.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 16:07:44 +0000 (18:07 +0200)]
rustc_codegen_llvm: remove InternalDebugLocation and simplify dbg_var_addr.

4 years agorustc_codegen_llvm: remove unnecessary special-casing of root scopes' children.
Eduard-Mihai Burtescu [Sat, 8 Feb 2020 15:58:00 +0000 (17:58 +0200)]
rustc_codegen_llvm: remove unnecessary special-casing of root scopes' children.

4 years agoClean up E0277 and E0282 explanations
Guillaume Gomez [Sat, 8 Feb 2020 14:47:29 +0000 (15:47 +0100)]
Clean up E0277 and E0282 explanations

4 years agoAdd missing import
Jonas Schievink [Sat, 8 Feb 2020 13:44:32 +0000 (14:44 +0100)]
Add missing import

4 years agoMake `provided_trait_methods` use `impl Iterator`
Jonas Schievink [Fri, 7 Feb 2020 20:33:23 +0000 (21:33 +0100)]
Make `provided_trait_methods` use `impl Iterator`

4 years agoAdd a fast path to inherent impl overlap check
Jonas Schievink [Thu, 6 Feb 2020 23:52:35 +0000 (00:52 +0100)]
Add a fast path to inherent impl overlap check

Quickly skip impls that do not define any items with the same name

4 years agoUse `associated_items` query in impl overlap check
Jonas Schievink [Thu, 6 Feb 2020 22:50:08 +0000 (23:50 +0100)]
Use `associated_items` query in impl overlap check

This reduces the number of `associated_item` queries done here.

4 years agoMake `associated_items` query return a slice
Jonas Schievink [Thu, 6 Feb 2020 22:21:44 +0000 (23:21 +0100)]
Make `associated_items` query return a slice

4 years agoCorrected E0637.md based on test failure
Josh White [Sat, 8 Feb 2020 13:14:28 +0000 (08:14 -0500)]
Corrected E0637.md based on test failure

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 agoAdded compiler flags to example code, removed unexpected curly
Josh White [Sat, 8 Feb 2020 11:18:42 +0000 (06:18 -0500)]
Added compiler flags to example code, removed unexpected curly

4 years agoRemoved trailing white spaces
Josh White [Sat, 8 Feb 2020 05:22:15 +0000 (00:22 -0500)]
Removed trailing white spaces

4 years agoMerge branch 'master' of https://github.com/jwhite927/rust into E0637
Josh White [Sat, 8 Feb 2020 04:56:44 +0000 (23:56 -0500)]
Merge branch 'master' of https://github.com/jwhite927/rust into E0637

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.