Commit Graph

106686 Commits

Author SHA1 Message Date
Chris Simpkins
53b16fb5f2 add main function to issue-69017 test 2020-02-10 13:47:52 -05:00
Tim Diekmann
97d1f8d9bb Add missing _zeroed varants to AllocRef 2020-02-10 19:44:29 +01:00
Tim Diekmann
25de80ad23 Remove common usage pattern from AllocRef 2020-02-10 18:38:09 +01:00
Vadim Petrochenkov
8d799218ab parser: Remove Parser::prev_token_kind 2020-02-10 20:29:37 +03:00
Chris Simpkins
fc3ecb22b9 add issue 69017 test 2020-02-10 12:03:49 -05:00
Mazdak Farrokhzad
75afd0b0cf use dyn Trait more in tests 2020-02-10 17:42:09 +01:00
Chris Simpkins
9e78ce068b handle TerminatorKind::Yield by returning Err(Unpromotable) 2020-02-10 11:31:55 -05:00
Dylan DPC
119bc976db
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.
2020-02-10 17:29:03 +01:00
Dylan DPC
db08784964
Rollup merge of #69007 - GuillaumeGomez:clean-up-e0283, r=Dylan-DPC
Clean up E0283 explanation

r? @Dylan-DPC
2020-02-10 17:29:01 +01:00
Dylan DPC
6e1b75b7e1
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
2020-02-10 17:28:59 +01:00
Dylan DPC
24260e5bae
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
2020-02-10 17:28:57 +01:00
Dylan DPC
531f235134
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.
2020-02-10 17:28:56 +01:00
Dylan DPC
1e26a1c4d1
Rollup merge of #68897 - GuillaumeGomez:clean-up-e0275, r=Dylan-DPC
clean up E0275 explanation

r? @Dylan-DPC
2020-02-10 17:28:54 +01:00
bors
e6ec0d125e 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.
2020-02-10 15:24:59 +00:00
Michael Woerister
81dccb1a5c self-profile: Support arguments for generic_activities. 2020-02-10 15:46:41 +01:00
ljedrz
b8893df8d3 preallocate 2 Vecs in traits; tweak WfPredicates::normalize 2020-02-10 15:22:09 +01:00
Guillaume Gomez
37e7b46177 clean up E0275 explanation 2020-02-10 13:25:48 +01:00
Guillaume Gomez
ded629289a Clean up E0283 explanation 2020-02-10 13:23:52 +01:00
bors
4d1241f515 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
2020-02-10 10:47:39 +00:00
Nicholas Nethercote
f8a02864af Speed up SipHasher128.
The current code in `SipHasher128::short_write` is inefficient. It uses
`u8to64_le` (which is complex and slow) to extract just the right number of
bytes of the input into a u64 and pad the result with zeroes. It then
left-shifts that value in order to bitwise-OR it with `self.tail`.

For example, imagine we have a u32 input 0xIIHH_GGFF and only need three bytes
to fill up `self.tail`. The current code uses `u8to64_le` to construct
0x0000_0000_00HH_GGFF, which is just 0xIIHH_GGFF with the 0xII removed and
zero-extended to a u64. The code then left-shifts that value by five bytes --
discarding the 0x00 byte that replaced the 0xII byte! -- to give
0xHHGG_FF00_0000_0000. It then then ORs that value with self.tail.

There's a much simpler way to do it: zero-extend to u64 first, then left shift.
E.g. 0xIIHH_GGFF is zero-extended to 0x0000_0000_IIHH_GGFF, and then
left-shifted to 0xHHGG_FF00_0000_0000. We don't have to take time to exclude
the unneeded 0xII byte, because it just gets shifted out anyway! It also avoids
multiple occurrences of `unsafe`.

There's a similar story with the setting of `self.tail` at the method's end.
The current code uses `u8to64_le` to extract the remaining part of the input,
but the same effect can be achieved more quickly with a right shift on the
zero-extended input.

All that works on little-endian. It doesn't work for big-endian, but we
can just do a `to_le` before calling `short_write` and then it works.

This commit changes `SipHasher128` to use the simpler shift-based approach. The
code is also smaller, which means that `short_write` is now inlined where
previously it wasn't, which makes things faster again. This gives big
speed-ups for all incremental builds, especially "baseline" incremental
builds.
2020-02-10 15:54:14 +11:00
David Renshaw
371060b598 [parser] change an instance of span_bug() to struct_span_err() to avoid ICE 2020-02-09 23:02:02 -05:00
Dylan DPC
18c6d39b55
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
2020-02-10 01:54:23 +01:00
Dylan DPC
a8d4ccf907
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
2020-02-10 01:54:21 +01:00
Dylan DPC
64d2d04eb9 Rollup merge of #68992 - matthewjasper:imm-binding-after-at, r=Centril
Correctly parse `mut a @ b`

r? @Centril

Closes #67861
Closes #67926
2020-02-10 01:54:20 +01:00
Dylan DPC
e3315f6742
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.
2020-02-10 01:54:18 +01:00
Dylan DPC
b3cfb97d5c 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)
2020-02-10 01:54:17 +01:00
Dylan DPC
8007f8468b
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
2020-02-10 01:54:15 +01:00
Jonas Schievink
23095928a7 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.
2020-02-09 23:18:02 +01:00
Jonas Schievink
8f468ee114 Defer error span calculation until needed
This was showing up in profiles. Also deduplicates the code to get just
the impl header span.
2020-02-09 23:17:09 +01:00
Jonas Schievink
82d6e79cfe Add desc to specialization_graph_of query 2020-02-09 23:17:09 +01:00
Jonas Schievink
5ab1ab4959 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
2020-02-09 23:17:09 +01:00
bors
840bdc349d 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.
2020-02-09 22:13:05 +00:00
Nicholas Nethercote
7426853ba2 Reduce the number of RefCells 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.
2020-02-10 08:55:34 +11:00
Vadim Petrochenkov
cd7a428b5e parser: Keep current and previous tokens precisely
including their unnormalized forms.
Add more documentation for them.
2020-02-10 00:08:53 +03:00
Matthias Prechtl
7b555178ae --bless --compare-mode=nll 2020-02-09 20:43:49 +01:00
Matthias Prechtl
f35a7c38da Make issue references consistent 2020-02-09 20:43:49 +01:00
bjorn3
3e57a0afb5 Update for #68718 2020-02-09 19:52:42 +01:00
bors
71c7e149e4 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
2020-02-09 18:44:39 +00:00
Dylan MacKenzie
8d6208c39b Use nicer alignment when printing state vectors 2020-02-09 10:33:07 -08:00
Dylan MacKenzie
83dfb422fe Don't break first line 2020-02-09 10:33:06 -08:00
Dylan MacKenzie
fb14386de3 Remove unnecessary allows 2020-02-09 10:33:06 -08:00
Dylan MacKenzie
852afa2e88 Add option to dot::render for monospace font 2020-02-09 10:33:06 -08:00
Dylan MacKenzie
effd52078c 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"`.
2020-02-09 10:33:06 -08:00
Jonas Schievink
da005822ce
Rollup merge of #68913 - Areredify:gat_pretty, r=cramertj
Pretty-print generic params and where clauses on associated types

closes #67509
2020-02-09 18:23:34 +01:00
Jonas Schievink
f6b8281d34
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.
2020-02-09 18:23:33 +01:00
Jonas Schievink
0e23d3681e
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
2020-02-09 18:23:31 +01:00
Jonas Schievink
3516df3ecb
Rollup merge of #68742 - tspiteri:string-as-mut, r=sfackler
implement AsMut<str> for String

Closes #68741.
2020-02-09 18:23:30 +01:00
Jonas Schievink
0b50319af6
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.)
2020-02-09 18:23:28 +01:00
bors
1ad6b5e1e6 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
2020-02-09 15:24:50 +00:00
Eduard-Mihai Burtescu
1a8f5efab8 rustc_codegen_ssa: only "spill" SSA-like values to the stack for debuginfo. 2020-02-09 16:39:23 +02:00