]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoAdd `repr(no_niche)` to `UnsafeCell`. Fix #68303.
Felix S. Klock II [Thu, 23 Jan 2020 19:33:55 +0000 (14:33 -0500)]
Add `repr(no_niche)` to `UnsafeCell`. Fix #68303.

4 years agotests for `#[repr(no_niche)]`.
Felix S. Klock II [Wed, 22 Jan 2020 23:50:38 +0000 (18:50 -0500)]
tests for `#[repr(no_niche)]`.

4 years agoAdd `#[repr(no_niche)]`.
Felix S. Klock II [Wed, 22 Jan 2020 23:54:04 +0000 (18:54 -0500)]
Add `#[repr(no_niche)]`.

This repr-hint makes a struct/enum hide any niche within from its
surrounding type-construction context.

It is meant (at least initially) as an implementation detail for
resolving issue 68303. We will not stabilize the repr-hint unless
someone finds motivation for doing so.

(So, declaration of `no_niche` feature lives in section of file
where other internal implementation details are grouped, and
deliberately leaves out the tracking issue number.)

incorporated review feedback, and fixed post-rebase.

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 agoadd main function to issue-69017 test
Chris Simpkins [Mon, 10 Feb 2020 18:47:52 +0000 (13:47 -0500)]
add main function to issue-69017 test

4 years agoAdd missing `_zeroed` varants to `AllocRef`
Tim Diekmann [Mon, 10 Feb 2020 16:00:59 +0000 (17:00 +0100)]
Add missing `_zeroed` varants to `AllocRef`

4 years agoRemove common usage pattern from `AllocRef`
Tim Diekmann [Mon, 10 Feb 2020 15:42:00 +0000 (16:42 +0100)]
Remove common usage pattern from `AllocRef`

4 years agoparser: Remove `Parser::prev_token_kind`
Vadim Petrochenkov [Mon, 10 Feb 2020 17:20:01 +0000 (20:20 +0300)]
parser: Remove `Parser::prev_token_kind`

4 years agoadd issue 69017 test
Chris Simpkins [Mon, 10 Feb 2020 17:03:49 +0000 (12:03 -0500)]
add issue 69017 test

4 years agouse `dyn Trait` more in tests
Mazdak Farrokhzad [Mon, 10 Feb 2020 16:39:10 +0000 (17:39 +0100)]
use `dyn Trait` more in tests

4 years agohandle TerminatorKind::Yield by returning Err(Unpromotable)
Chris Simpkins [Mon, 10 Feb 2020 16:31:55 +0000 (11:31 -0500)]
handle TerminatorKind::Yield by returning Err(Unpromotable)

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 agosome more tests for i128 oveflow behavior
Ralf Jung [Mon, 10 Feb 2020 10:37:02 +0000 (11:37 +0100)]
some more tests for i128 oveflow behavior

4 years agodiv/rem overflow tests: also test i128
Ralf Jung [Mon, 10 Feb 2020 10:23:04 +0000 (11:23 +0100)]
div/rem overflow tests: also test i128

4 years agoadd test that checks overflows on arithmetic operators
Ralf Jung [Mon, 10 Feb 2020 08:56:17 +0000 (09:56 +0100)]
add test that checks overflows on arithmetic operators

4 years agoSpeed up `SipHasher128`.
Nicholas Nethercote [Thu, 6 Feb 2020 02:04:51 +0000 (13:04 +1100)]
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.

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 agoconst-prop: use overflowing_unary_op for overflowing checking of unary ops
Ralf Jung [Sun, 9 Feb 2020 14:48:18 +0000 (15:48 +0100)]
const-prop: use overflowing_unary_op for overflowing checking of unary ops

4 years agomiri: equip unary_op with overflow detection
Ralf Jung [Sat, 8 Feb 2020 22:27:29 +0000 (23:27 +0100)]
miri: equip unary_op with overflow detection

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 agobring back extra check for int_min%-1
Ralf Jung [Sun, 9 Feb 2020 14:41:40 +0000 (15:41 +0100)]
bring back extra check for int_min%-1

4 years agomiri: simplify singed operator overflow detection
Ralf Jung [Sun, 9 Feb 2020 14:23:34 +0000 (15:23 +0100)]
miri: simplify singed operator overflow detection

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 agoAccount for type params on method without parens
Esteban Küber [Sun, 9 Feb 2020 04:02:54 +0000 (20:02 -0800)]
Account for type params on method without parens

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