Commit graph

156250 commits

Author SHA1 Message Date
Oli Scherer
07b8bbb1f6 Equality of regions is not just on identity, but if both regions outlive each other 2021-10-15 17:50:33 +00:00
Oli Scherer
6f71cab3b0 Normalize regions before comparing them for member constraints 2021-10-15 17:50:33 +00:00
Oli Scherer
5115069ccd Add some more instrumentation 2021-10-15 17:50:33 +00:00
Oli Scherer
16868d9096 Remove a now-unused struct 2021-10-15 17:50:33 +00:00
Niko Matsakis
094a9c743e simplify constrain_opaque_types 2021-10-15 17:50:33 +00:00
bors
af9b508e1d Auto merge of #88717 - tabokie:vecdeque-fast-append, r=m-ou-se
Optimize VecDeque::append

Optimize `VecDeque::append` to do unsafe copy rather than iterating through each element.

On my `Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz`, the benchmark shows 37% improvements:
```
Master:
custom-bench vec_deque_append 583164 ns/iter
custom-bench vec_deque_append 550040 ns/iter

Patched:
custom-bench vec_deque_append 349204 ns/iter
custom-bench vec_deque_append 368164 ns/iter
```

Additional notes on the context: this is the third attempt to implement a non-trivial version of `VecDeque::append`, the last two are reverted due to unsoundness or regression, see:
- https://github.com/rust-lang/rust/pull/52553, reverted in https://github.com/rust-lang/rust/pull/53571
- https://github.com/rust-lang/rust/pull/53564, reverted in https://github.com/rust-lang/rust/pull/54851

Both cases are covered by existing tests.

Signed-off-by: tabokie <xy.tao@outlook.com>
2021-10-15 12:51:31 +00:00
bors
1dafe6d1c3 Auto merge of #88540 - ibraheemdev:swap-unchecked, r=kennytm
add `slice::swap_unchecked`

An unsafe version of `slice::swap` that does not do bounds checking.
2021-10-15 09:35:45 +00:00
bors
72d66064e7 Auto merge of #89903 - matthiaskrgr:rollup-s0c69xl, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #86011 (move implicit `Sized` predicate to end of list)
 - #89821 (Add a strange test for `unsafe_code` lint.)
 - #89859 (add dedicated error variant for writing the discriminant of an uninhabited enum variant)
 - #89870 (Suggest Box::pin when Pin::new is used instead)
 - #89880 (Use non-checking TLS relocation in aarch64 asm! sym test.)
 - #89885 (add long explanation for E0183)
 - #89894 (Remove unused dependencies from rustc_const_eval)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-15 05:59:49 +00:00
Matthias Krüger
e45c222793
Rollup merge of #89894 - camsteffen:unused-deps, r=Mark-Simulacrum
Remove unused dependencies from rustc_const_eval
2021-10-15 07:44:50 +02:00
Matthias Krüger
e3099e7d8c
Rollup merge of #89885 - cameron1024:long-explanation-E0183, r=GuillaumeGomez
add long explanation for E0183

Addresses #61137
2021-10-15 07:44:49 +02:00
Matthias Krüger
f0555cefae
Rollup merge of #89880 - adamgemmell:dev/nc-relocation, r=Amanieu
Use non-checking TLS relocation in aarch64 asm! sym test.

The checking variant ensures that the offset required is not larger than 12 bits - hence we wouldn't ever need the upper 12 bits.

It's unlikely to ever fail in this small test but this is technically correct.

This was noticed incidentally when we found that LLD doesn't support the `tprel_lo12` relocation, even though LLVM can apparently generate it when using `-mtls-size=12`.
2021-10-15 07:44:48 +02:00
Matthias Krüger
e2c28ad1e7
Rollup merge of #89870 - tmandry:box-pin, r=estebank
Suggest Box::pin when Pin::new is used instead

This fixes an incorrect diagnostic.

**Based on #89390**; only the last commit is specific to this PR. "Ignore whitespace changes" also helps here.
2021-10-15 07:44:47 +02:00
Matthias Krüger
345d483e95
Rollup merge of #89859 - RalfJung:write-discriminant, r=oli-obk
add dedicated error variant for writing the discriminant of an uninhabited enum variant

This is conceptually different from hitting an `Unreachable` terminator. Also add some sanity check making sure we don't write discriminants of things that do not have discriminants.

r? ``@oli-obk``
2021-10-15 07:44:47 +02:00
Matthias Krüger
b74ae0487b
Rollup merge of #89821 - crlf0710:unsafe_code_lint_test, r=Mark-Simulacrum
Add a strange test for `unsafe_code` lint.

The current behavior is a little surprising to me. I'm not sure whether people would change it, but at least let me document the current behavior with a test.

I learnt about this from the [totally-speedy-transmute](https://docs.rs/totally-speedy-transmute) crate.

cc #10599 the original implementation pr.
2021-10-15 07:44:45 +02:00
Matthias Krüger
36a1076d24
Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank
move implicit `Sized` predicate to end of list

In `Bounds::predicates()`, move the implicit `Sized` predicate to the
end of the generated list. This means that if there is an explicit
`Sized` bound, it will be checked first, and any resulting
diagnostics will have a more useful span.

Fixes #85998, at least partially. ~~Based on #85979, but only the last 2 commits are new for this pull request.~~ (edit: rebased) A full fix would need to deal with where-clauses, and that seems difficult. Basically, predicates are being collected in multiple stages, and there are two places where implicit `Sized` predicates can be inserted: once for generic parameters, and once for where-clauses. I think this insertion is happening too early, and we should actually do it only at points where we collect all of the relevant trait bounds for a type parameter.

I could use some help interpreting the changes to the stderr output. It looks like reordering the predicates changed some diagnostics that don't obviously have anything to do with `Sized` bounds. Possibly some error reporting code is making assumptions about ordering of predicates? The diagnostics for src/test/ui/derives/derives-span-Hash-*.rs seem to have improved, no longer pointing at the type parameter identifier, but src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs became less verbose for some reason.

I also ran into an instance of #84970 while working on this, but I kind of expected that could happen, because I'm reordering predicates. I can open a separate issue on that if it would be helpful.

``@estebank`` this seems likely to conflict (slightly?) with your work on #85947; how would you like to resolve that?
2021-10-15 07:44:44 +02:00
bors
313e71a253 Auto merge of #89884 - Mark-Simulacrum:revert-enum-discr, r=wesleywiser
Revert enum discriminants

Reverts stabilization of arbitrary enum discriminants per https://github.com/rust-lang/rust/issues/88621#issuecomment-929482371.

Reopens #60553.
2021-10-15 02:55:58 +00:00
Cameron Steffen
64d18d4c51 Remove unused dependencies from rustc_const_eval 2021-10-14 15:42:42 -05:00
Charles Lew
c76c620e4e Add a test for unsafe_code lint. 2021-10-15 01:21:05 +08:00
cameron1024
cca39148f3 add long explanation for E0183 2021-10-14 17:44:04 +01:00
bors
e1e9319d93 Auto merge of #89882 - matthiaskrgr:rollup-1dh7pz8, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89390 (Fix incorrect Box::pin suggestion)
 - #89433 (Fix ctrl-c causing reads of stdin to return empty on Windows.)
 - #89823 (Switch order of terms to prevent overflow)
 - #89865 (Allow static linking LLVM with ThinLTO)
 - #89873 (Add missing word to `FromStr` trait documentation)
 - #89878 (Fix missing remaining compiler specific cfg information)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-14 16:23:10 +00:00
Mark Rousskov
2284082ae8 Drop reverted stabilizations from release notes 2021-10-14 10:58:16 -04:00
Mark Rousskov
8485e6fdec Revert "Stabilize arbitrary_enum_discriminant"
This reverts commit 7a62f29f31.
2021-10-14 10:57:56 -04:00
Matthias Krüger
d6eff5ac4c
Rollup merge of #89878 - GuillaumeGomez:add-missing-cfg-hide, r=notriddle
Fix missing remaining compiler specific cfg information

Follow-up of #89596. We forgot a few of them:

![Screenshot from 2021-10-14 11-36-44](https://user-images.githubusercontent.com/3050060/137292700-64ebc59f-d9d2-41f2-be3a-fa5bf211523c.png)
![Screenshot from 2021-10-14 11-36-56](https://user-images.githubusercontent.com/3050060/137292703-f63fa4e5-2c56-446b-9f86-3652f03dfe59.png)

r? `@notriddle`
2021-10-14 16:06:47 +02:00
Matthias Krüger
686857f5bf
Rollup merge of #89873 - askoufis:patch-1, r=Mark-Simulacrum
Add missing word to `FromStr` trait documentation

The doc comment is getting a bit wide, let me know if I should restructure it/add a new line.
2021-10-14 16:06:46 +02:00
Matthias Krüger
0888c6dc78
Rollup merge of #89865 - tmandry:llvm-static, r=Mark-Simulacrum
Allow static linking LLVM with ThinLTO

There's no reason not to allow this if the user wants it. It works, at least in a local build on linux host.

For our use case, we're happy to spend more time building the compiler if it creates a speedup every time we run it, and we've observed speedups like this with clang.
2021-10-14 16:06:46 +02:00
Matthias Krüger
29081f95e9
Rollup merge of #89823 - jackh726:project-overflow, r=oli-obk
Switch order of terms to prevent overflow

Fixes #89639

r? ``@pnkfelix``
2021-10-14 16:06:45 +02:00
Matthias Krüger
d177791791
Rollup merge of #89433 - arlosi:stdin-fix, r=joshtriplett
Fix ctrl-c causing reads of stdin to return empty on Windows.

Pressing ctrl+c (or ctrl+break) on Windows caused a blocking read of stdin to unblock and return empty, unlike other platforms which continue to block.

On ctrl-c, `ReadConsoleW` will return success, but also set `LastError` to `ERROR_OPERATION_ABORTED`.

This change detects this case, and re-tries the call to `ReadConsoleW`.

Fixes #89177. See issue for further details.

Tested on Windows 7 and Windows 10 with both MSVC and GNU toolchains
2021-10-14 16:06:44 +02:00
Matthias Krüger
f9c9774aea
Rollup merge of #89390 - tmandry:issue-72117, r=estebank
Fix incorrect Box::pin suggestion

The suggestion checked if `Pin<Box<T>>` could be coeerced to the expected
type, but did not check predicates created by the coercion. We now
look for predicates that definitely cannot be satisfied before giving
the suggestion.

The suggestion is still marked MaybeIncorrect because we allow predicates that
are still ambiguous and can't be proven.

Fixes #72117.
2021-10-14 16:06:43 +02:00
Ralf Jung
c5a68cf0a6 add dedicated error variant for writing the discriminant of an uninhabited enum variant 2021-10-14 10:03:20 -04:00
Ibraheem Ahmed
cf12732a38
don't duplicate slice panic_bounds_check 2021-10-14 09:31:34 -04:00
bors
0a56eb11fa Auto merge of #88698 - Noble-Mushtak:master, r=nikomatsakis,oli-obk
Add check that live_region is live in sanitize_promoted

This pull request fixes #88434 by adding a check in `sanitize_promoted` to ensure that only regions which are actually live are added to the `liveness_constraints` of the `BorrowCheckContext`.

To implement this change, I needed to add a method to `LivenessValues` which gets the elements contained by a region:

    /// Returns an iterator of all the elements contained by the region `r`
    crate fn get_elements(&self, row: N) -> impl Iterator<Item = Location> + '_

Then, inside `sanitize_promoted`, we check whether the iterator returned by this method is non-empty to ensure that the region is actually live at at least one location before adding that region to the `liveness_constraints` of the `BorrowCheckContext`.

This is my first pull request to the Rust repo, so any feedback on how I can improve this pull request or if there is a better way to fix this issue would be very appreciated.
2021-10-14 13:21:46 +00:00
Adam Gemmell
af5b146324 Use non-checking TLS relocation in aarch64 asm! sym test.
The checking variant ensures that the offset required is not larger than
12 bits - hence we wouldn't ever need the upper 12 bits.
2021-10-14 12:27:19 +01:00
bors
c34ac8747c Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obk
Add `const_eval_select` intrinsic

Adds an intrinsic that calls a given function when evaluated at compiler time, but generates a call to another function when called at runtime.

See https://github.com/rust-lang/const-eval/issues/7 for previous discussion.

r? `@oli-obk.`
2021-10-14 10:06:30 +00:00
Guillaume Gomez
30a20f8c83 Fix missing remaining compiler specific cfg information 2021-10-14 11:39:30 +02:00
Deadbeef
11fac09ead
fix codegen test 2021-10-14 07:35:35 +00:00
Deadbeef
26b78ccd31
Fix const stability 2021-10-14 07:07:34 +00:00
Deadbeef
6770dbd4b5
Avoid tupling at the callee 2021-10-14 06:18:53 +00:00
Adam Skoufis
4b59b35b76
Add missing word to FromStr trait docs 2021-10-14 13:47:54 +11:00
bors
7807a694c2 Auto merge of #89815 - GuillaumeGomez:associated-consts-sidebar, r=notriddle
Associated consts sidebar

Fixes #89354.

A screenshot with `f32`:

![Screenshot from 2021-10-12 15-07-57](https://user-images.githubusercontent.com/3050060/136962078-5faf7b87-7ea5-4d7a-99a4-b2afd77b78e2.png)
2021-10-14 02:24:52 +00:00
Tyler Mandry
d18502d6b3 Suggest Box::pin when Pin::new is used instead 2021-10-14 01:06:25 +00:00
bors
8c852bc15a Auto merge of #89858 - matthiaskrgr:rollup-evsnr2e, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89347 (suggestion for typoed crate or module)
 - #89670 (Improve `std:🧵:available_parallelism` docs)
 - #89757 (Use shallow clones for submodules)
 - #89759 (Assemble the compiler when running `x.py build`)
 - #89846 (Add `riscv32imc-esp-espidf` to 1.56 changelog)
 - #89853 (Update the 1.56.0 release header for consistency)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-13 23:27:57 +00:00
Tyler Mandry
a8558e9efa Exit early if expected type is not an adt 2021-10-13 23:26:01 +00:00
Tyler Mandry
156c9222f5 Move misplaced comment 2021-10-13 23:26:00 +00:00
Tyler Mandry
485ae9f2c0 Always check predicates in can_coerce
This only changed two tests and I consider both changes an improvement.
2021-10-13 23:26:00 +00:00
Tyler Mandry
5c14433c00 Fix incorrect Box::pin suggestion
The suggestion checked if Pin<Box<T>> could be coeerced to the expected
type, but did not check predicates created by the coercion. We now
look for predicates that definitely cannot be satisfied before giving
the suggestion.

The suggestion is marked MaybeIncorrect because we allow predicates that
are still ambiguous and can't be proven.
2021-10-13 23:26:00 +00:00
Tyler Mandry
2c31c31bb8 Fix line length 2021-10-13 23:26:00 +00:00
Tyler Mandry
c9af192690 Allow static linking LLVM with ThinLTO 2021-10-13 22:58:03 +00:00
Matthias Krüger
a624eef249
Rollup merge of #89853 - cuviper:release-1.56, r=Mark-Simulacrum
Update the 1.56.0 release header for consistency
2021-10-13 22:51:05 +02:00
Matthias Krüger
03638f1c24
Rollup merge of #89846 - esp-rs:riscv-esp-idf-changelog, r=Mark-Simulacrum
Add `riscv32imc-esp-espidf` to 1.56 changelog
2021-10-13 22:51:04 +02:00
Matthias Krüger
204bd6e215
Rollup merge of #89759 - jyn514:x-build-assemble, r=Mark-Simulacrum
Assemble the compiler when running `x.py build`

Previously, there was no way to actually get binaries in
`build/$TARGET/stage1/bin` without building the standard library. This
makes it possible to build just the compiler. This can be useful when
the standard library isn't actually necessary for trying out your tests
(e.g. a bug that can be reproduced with only a `no_core` crate).

Closes https://github.com/rust-lang/rust/issues/73519.
2021-10-13 22:51:03 +02:00