]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agobetter test
Deadbeef [Wed, 1 Sep 2021 13:07:49 +0000 (13:07 +0000)]
better test

2 years agofmt
Deadbeef [Wed, 1 Sep 2021 12:53:51 +0000 (12:53 +0000)]
fmt

2 years agoAdd a simple test case
Deadbeef [Wed, 1 Sep 2021 11:55:16 +0000 (11:55 +0000)]
Add a simple test case

2 years agoDo not lint for ~const Drop bounds
Deadbeef [Wed, 1 Sep 2021 11:55:03 +0000 (11:55 +0000)]
Do not lint for ~const Drop bounds

2 years agoConst dropping
Deadbeef [Wed, 1 Sep 2021 11:06:15 +0000 (11:06 +0000)]
Const dropping

2 years agoRemove unused query
Deadbeef [Wed, 1 Sep 2021 08:19:58 +0000 (08:19 +0000)]
Remove unused query

2 years agocleanup hir hack
Deadbeef [Wed, 1 Sep 2021 08:08:40 +0000 (08:08 +0000)]
cleanup hir hack

2 years agoAuto merge of #88615 - flip1995:clippyup, r=Manishearth
bors [Wed, 8 Sep 2021 23:52:31 +0000 (23:52 +0000)]
Auto merge of #88615 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

2 years agoAuto merge of #80522 - cjgillot:borrowcrate, r=oli-obk
bors [Wed, 8 Sep 2021 20:42:42 +0000 (20:42 +0000)]
Auto merge of #80522 - cjgillot:borrowcrate, r=oli-obk

Split rustc_mir

The `rustc_mir` crate is the second largest in the compiler.
This PR splits it up into 5 crates:
- rustc_borrowck;
- rustc_const_eval;
- rustc_mir_dataflow;
- rustc_mir_transform;
- rustc_monomorphize.

2 years agoRebase fallout.
Camille GILLOT [Wed, 1 Sep 2021 19:05:35 +0000 (21:05 +0200)]
Rebase fallout.

2 years agoUpdate run-make-fulldeps.
Camille GILLOT [Thu, 2 Sep 2021 17:02:55 +0000 (19:02 +0200)]
Update run-make-fulldeps.

2 years agoAuto merge of #88750 - jackh726:rollup-w57i9fp, r=jackh726
bors [Wed, 8 Sep 2021 17:26:17 +0000 (17:26 +0000)]
Auto merge of #88750 - jackh726:rollup-w57i9fp, r=jackh726

Rollup of 9 pull requests

Successful merges:

 - #86263 (Rustdoc: Report Layout of enum variants)
 - #88541 (Add regression test for #74400)
 - #88553 (Improve diagnostics for unary plus operators (#88276))
 - #88594 (More symbolic doc aliases)
 - #88648 (Correct “copies” to “moves” in `<Option<T> as From<T>>::from` doc, and other copyediting)
 - #88691 (Add a regression test for #88649)
 - #88694 (Drop 1.56 stabilizations from 1.55 release notes)
 - #88712 (Fix docs for `uX::checked_next_multiple_of`)
 - #88726 (Fix typo in `const_generics` replaced with `adt_const_params` note)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #88726 - MingweiSamuel:patch-1, r=wesleywiser
Jack Huey [Wed, 8 Sep 2021 16:24:22 +0000 (12:24 -0400)]
Rollup merge of #88726 - MingweiSamuel:patch-1, r=wesleywiser

Fix typo in `const_generics` replaced with `adt_const_params` note

2 years agoRollup merge of #88712 - jhpratt:fix-int_rounding-docs, r=joshtriplett
Jack Huey [Wed, 8 Sep 2021 16:24:21 +0000 (12:24 -0400)]
Rollup merge of #88712 - jhpratt:fix-int_rounding-docs, r=joshtriplett

Fix docs for `uX::checked_next_multiple_of`

Thanks to `@photino` for noticing this [here](https://github.com/rust-lang/rust/issues/88581#issuecomment-913982246).

r? `@joshtriplett`

`@rustbot` label: +A-docs +A-waiting-on-review

2 years agoRollup merge of #88694 - Mark-Simulacrum:relnotes, r=Mark-Simulacrum
Jack Huey [Wed, 8 Sep 2021 16:24:20 +0000 (12:24 -0400)]
Rollup merge of #88694 - Mark-Simulacrum:relnotes, r=Mark-Simulacrum

Drop 1.56 stabilizations from 1.55 release notes

r? `@Mark-Simulacrum`

2 years agoRollup merge of #88691 - hyd-dev:88649, r=Mark-Simulacrum
Jack Huey [Wed, 8 Sep 2021 16:24:19 +0000 (12:24 -0400)]
Rollup merge of #88691 - hyd-dev:88649, r=Mark-Simulacrum

Add a regression test for #88649

I noticed that #88649 does not have a regression test, so I add one in this PR.

The test fails with this without #88678:
```
error[E0080]: evaluation of constant value failed
  --> /checkout/src/test/ui/consts/issue-88649.rs:13:52
   |
LL |             Foo::Variant1(x) | Foo::Variant2(x) if x => {}
   |                                                    ^ StorageLive on a local that was already live

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
```

2 years agoRollup merge of #88648 - kpreid:option, r=Mark-Simulacrum
Jack Huey [Wed, 8 Sep 2021 16:24:18 +0000 (12:24 -0400)]
Rollup merge of #88648 - kpreid:option, r=Mark-Simulacrum

Correct “copies” to “moves” in `<Option<T> as From<T>>::from` doc, and other copyediting

The `impl<T> From<T> for Option<T>` has no `Copy` or `Clone` bound, so its operation is guaranteed to be a move. The call site might copy, but the function itself cannot.

Since that would have been a rather small PR, I also reviewed the other documentation in the file and made other improvements (in separate commits): adding periods and commas, linking `Deref::Target`, and clarifying what "a container" is in `FromIterator`.

2 years agoRollup merge of #88594 - steffahn:more_symbolic_doc_aliases, r=joshtriplett
Jack Huey [Wed, 8 Sep 2021 16:24:17 +0000 (12:24 -0400)]
Rollup merge of #88594 - steffahn:more_symbolic_doc_aliases, r=joshtriplett

More symbolic doc aliases

A bunch of small changes, mostly adding `#[doc(alias = "…")]` entries for symbolic `"…"`.

Also a small change in documentation of `const` keywords.

2 years agoRollup merge of #88553 - theo-lw:issue-88276, r=estebank
Jack Huey [Wed, 8 Sep 2021 16:24:16 +0000 (12:24 -0400)]
Rollup merge of #88553 - theo-lw:issue-88276, r=estebank

Improve diagnostics for unary plus operators (#88276)

This pull request improves the diagnostics emitted on parsing a unary plus operator. See #88276.

Before:

```
error: expected expression, found `+`
 --> src/main.rs:2:13
  |
2 |     let x = +1;
  |             ^ expected expression
```

After:

```
error: leading `+` is not supported
 --> main.rs:2:13
  |
2 |     let x = +1;
  |             ^
  |             |
  |             unexpected `+`
  |             help: try removing the `+`
```

2 years agoRollup merge of #88541 - vandenheuvel:regression_test_74400, r=Mark-Simulacrum
Jack Huey [Wed, 8 Sep 2021 16:24:15 +0000 (12:24 -0400)]
Rollup merge of #88541 - vandenheuvel:regression_test_74400, r=Mark-Simulacrum

Add regression test for #74400

Closes #74400 by adding a regression test.

2 years agoRollup merge of #86263 - fee1-dead:rustdoc-layout-variants, r=camelid
Jack Huey [Wed, 8 Sep 2021 16:24:14 +0000 (12:24 -0400)]
Rollup merge of #86263 - fee1-dead:rustdoc-layout-variants, r=camelid

Rustdoc: Report Layout of enum variants

Followup of #83501, Fixes #86253.

cc `@camelid`

`@rustbot` label A-rustdoc

2 years agoUpdate Cargo.lock
flip1995 [Wed, 8 Sep 2021 14:32:16 +0000 (16:32 +0200)]
Update Cargo.lock

2 years agoMerge commit '27afd6ade4bb1123a8bf82001629b69d23d62aff' into clippyup
flip1995 [Wed, 8 Sep 2021 14:31:47 +0000 (16:31 +0200)]
Merge commit '27afd6ade4bb1123a8bf82001629b69d23d62aff' into clippyup

2 years agoDrop 1.56 stabilizations from 1.55 release notes
Mark Rousskov [Mon, 6 Sep 2021 16:55:11 +0000 (12:55 -0400)]
Drop 1.56 stabilizations from 1.55 release notes

2 years agoAuto merge of #7631 - camsteffen:depinfo, r=flip1995
bors [Wed, 8 Sep 2021 13:30:11 +0000 (13:30 +0000)]
Auto merge of #7631 - camsteffen:depinfo, r=flip1995

Use binary-dep-depinfo to resolve UI test dependencies

Closes #7343
Closes #6809
Closes #3643

changelog: none

r? `@flip1995`
cc `@Jarcho`

2 years agoDeny warnings in test modules
Cameron Steffen [Wed, 8 Sep 2021 13:19:14 +0000 (08:19 -0500)]
Deny warnings in test modules

2 years agoAuto merge of #87489 - bdalrhm:rustdoc-line-num, r=CraftSpider
bors [Wed, 8 Sep 2021 12:55:15 +0000 (12:55 +0000)]
Auto merge of #87489 - bdalrhm:rustdoc-line-num, r=CraftSpider

`rustdoc`: compute correct line number for indented rust code blocks.

This PR fixes a bug in `rustdoc` where it computes the wrong line number for indented rust code blocks (and subsequent blocks) it finds in markdown strings. To fix this issue, we decrement the line number if we find characters between the code block and the preceding line ending. I noticed this issue as I was trying to use `rustdoc` to extract examples from The Rust Reference and run them through the [Rust Model Checker](https://github.com/model-checking/rmc).

2 years agoUse binary-dep-depinfo to resolve UI dependencies
Cameron Steffen [Fri, 3 Sep 2021 20:24:29 +0000 (15:24 -0500)]
Use binary-dep-depinfo to resolve UI dependencies

2 years agoRemove unused dependencies
Cameron Steffen [Fri, 3 Sep 2021 20:55:14 +0000 (15:55 -0500)]
Remove unused dependencies

2 years agoAuto merge of #7644 - flip1995:rustup, r=flip1995
bors [Wed, 8 Sep 2021 09:00:54 +0000 (09:00 +0000)]
Auto merge of #7644 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump Clippy Version -> 0.1.57
flip1995 [Wed, 8 Sep 2021 08:59:04 +0000 (10:59 +0200)]
Bump Clippy Version -> 0.1.57

2 years agoBump nightly version -> 2021-09-08
flip1995 [Wed, 8 Sep 2021 08:58:51 +0000 (10:58 +0200)]
Bump nightly version -> 2021-09-08

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Wed, 8 Sep 2021 08:50:04 +0000 (10:50 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #7607 - dswij:mut-range-bound-break, r=flip1995
bors [Wed, 8 Sep 2021 08:14:17 +0000 (08:14 +0000)]
Auto merge of #7607 - dswij:mut-range-bound-break, r=flip1995

`mut_range_bound` check for immediate break after mutation

closes #7532

`mut_range_bound` ignores mutation on range bounds that is placed immediately before break. Still warns if the break is not always reachable.

changelog: [`mut_range_bound`] ignore range bound mutations before immediate break

2 years agoAuto merge of #86943 - ptrojahn:suggest_derive, r=estebank
bors [Wed, 8 Sep 2021 07:27:41 +0000 (07:27 +0000)]
Auto merge of #86943 - ptrojahn:suggest_derive, r=estebank

Suggest deriving traits if possible

This only applies to builtin derives as I don't think there is a
clean way to get the available derives in typeck.

Closes #85851

2 years agoAuto merge of #88061 - jackh726:genericbound-cleanup, r=estebank
bors [Wed, 8 Sep 2021 04:00:58 +0000 (04:00 +0000)]
Auto merge of #88061 - jackh726:genericbound-cleanup, r=estebank

Remove `hir::GenericBound::Unsized`

Rather than "moving" the `?Sized` bounds to the param bounds, just also check where clauses in `astconv`. I also did some related cleanup here, but that's not strictly neccesary. Also going to do a perf run here.

r? `@estebank`

2 years agoAdd known problems to `mut_range_bound` docs
dswij [Mon, 6 Sep 2021 22:07:50 +0000 (06:07 +0800)]
Add known problems to `mut_range_bound` docs

2 years agoUpdate test output for `mut_range_bound`
dswij [Fri, 3 Sep 2021 04:27:05 +0000 (12:27 +0800)]
Update test output for `mut_range_bound`

2 years ago`mut_range_bound` to check for immediate break from loop
dswij [Thu, 2 Sep 2021 08:04:46 +0000 (16:04 +0800)]
`mut_range_bound` to check for immediate break from loop

2 years agoAdd additional test for broken loop in `mut_range_bound`
dswij [Thu, 26 Aug 2021 10:20:13 +0000 (18:20 +0800)]
Add additional test for broken loop in `mut_range_bound`

2 years agoAuto merge of #88477 - sexxi-goose:issue-88476, r=nikomatsakis
bors [Wed, 8 Sep 2021 00:58:33 +0000 (00:58 +0000)]
Auto merge of #88477 - sexxi-goose:issue-88476, r=nikomatsakis

2229: Don't move out of drop type

Fixes #88476

r? `@nikomatsakis`

2 years agoA bit of cleanup to astconv
jackh726 [Sun, 15 Aug 2021 08:17:36 +0000 (04:17 -0400)]
A bit of cleanup to astconv

2 years agoChange is_unsized to add_implicitly_sized
jackh726 [Sun, 15 Aug 2021 07:09:47 +0000 (03:09 -0400)]
Change is_unsized to add_implicitly_sized

2 years agoDon't move ?Trait bounds to param bounds if they're in where clauses
jackh726 [Sun, 15 Aug 2021 04:53:40 +0000 (00:53 -0400)]
Don't move ?Trait bounds to param bounds if they're in where clauses

2 years agoStatic assert size of GenericBoun to ensure size doesn't change
jackh726 [Sun, 15 Aug 2021 00:25:38 +0000 (20:25 -0400)]
Static assert size of GenericBoun to ensure size doesn't change

2 years agoRename rustc_mir to rustc_const_eval.
Camille GILLOT [Tue, 5 Jan 2021 19:08:11 +0000 (20:08 +0100)]
Rename rustc_mir to rustc_const_eval.

2 years agoAuto merge of #88724 - Mark-Simulacrum:bump-rls, r=Mark-Simulacrum
bors [Tue, 7 Sep 2021 18:31:03 +0000 (18:31 +0000)]
Auto merge of #88724 - Mark-Simulacrum:bump-rls, r=Mark-Simulacrum

Bump RLS submodule

r? `@Mark-Simulacrum`

2 years agoMove the dataflow framework to its own crate.
Camille GILLOT [Tue, 5 Jan 2021 18:53:07 +0000 (19:53 +0100)]
Move the dataflow framework to its own crate.

2 years agoMove monomorphize code to its own crate.
Camille GILLOT [Sat, 2 Jan 2021 13:42:15 +0000 (14:42 +0100)]
Move monomorphize code to its own crate.

2 years agoFix typo in `const_generics` replaced with `adt_const_params` note
Mingwei Samuel [Tue, 7 Sep 2021 16:27:30 +0000 (09:27 -0700)]
Fix typo in `const_generics` replaced with `adt_const_params` note

2 years agoAuto merge of #88710 - Mark-Simulacrum:tyvid-idx, r=jackh726
bors [Tue, 7 Sep 2021 15:28:34 +0000 (15:28 +0000)]
Auto merge of #88710 - Mark-Simulacrum:tyvid-idx, r=jackh726

Use index newtyping for TyVid

This is useful for using TyVid in types like VecGraph, and just otherwise seems like a small win.

2 years agoBump RLS submodule
Mark Rousskov [Tue, 7 Sep 2021 14:12:12 +0000 (10:12 -0400)]
Bump RLS submodule

2 years agoAuto merge of #88161 - michaelwoerister:fix-whole-archive-no-bundle, r=petrochenkov
bors [Tue, 7 Sep 2021 12:31:11 +0000 (12:31 +0000)]
Auto merge of #88161 - michaelwoerister:fix-whole-archive-no-bundle, r=petrochenkov

Fix handling of +whole-archive native link modifier.

This PR fixes a bug in `add_upstream_native_libraries` that led to the `+whole-archive` modifier being ignored when linking in native libs.

~~Note that the PR does not address the situation when `+whole-archive` is combined with `+bundle`.~~
`@wesleywiser's` commit adds validation code that turns combining `+whole-archive` with `+bundle` into an error.

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

r? `@petrochenkov`
cc `@wesleywiser` `@gcoakes`

2 years agoAdd test case for no-bundle/whole-archive native libs linking.
Michael Woerister [Mon, 30 Aug 2021 09:54:12 +0000 (11:54 +0200)]
Add test case for no-bundle/whole-archive native libs linking.

2 years agoAuto merge of #7642 - mikerite:fix-7641, r=flip1995
bors [Tue, 7 Sep 2021 08:16:36 +0000 (08:16 +0000)]
Auto merge of #7642 - mikerite:fix-7641, r=flip1995

Add `TAU` to `approx_constant`

changelog: [`approx_constant`]: Add `TAU`

2 years agoFix docs for `uX::checked_next_multiple_of`
Jacob Pratt [Tue, 7 Sep 2021 06:14:04 +0000 (02:14 -0400)]
Fix docs for `uX::checked_next_multiple_of`

2 years agoAuto merge of #88689 - Aaron1011:confused-std-resolver, r=cjgillot
bors [Tue, 7 Sep 2021 05:28:53 +0000 (05:28 +0000)]
Auto merge of #88689 - Aaron1011:confused-std-resolver, r=cjgillot

Move `confused_type_with_std_module` to `ResolverOutputs`

This eliminates untracked global state from `Session`.

2 years agoAdd `TAU` to `approx_constant`
Michael Wright [Tue, 7 Sep 2021 03:50:04 +0000 (05:50 +0200)]
Add `TAU` to `approx_constant`

2 years agoUse index newtyping for TyVid
Mark Rousskov [Mon, 30 Aug 2021 21:45:16 +0000 (17:45 -0400)]
Use index newtyping for TyVid

2 years agoAuto merge of #88448 - xu-cheng:btree-blk-build, r=Mark-Simulacrum
bors [Tue, 7 Sep 2021 02:24:11 +0000 (02:24 +0000)]
Auto merge of #88448 - xu-cheng:btree-blk-build, r=Mark-Simulacrum

BTreeMap/BTreeSet::from_iter: use bulk building to improve the performance

Bulk building is a common technique to increase the performance of building a fresh btree map. Instead of inserting items one-by-one, we sort all the items beforehand then create the BtreeMap in bulk.

Benchmark
```
./x.py bench library/alloc --test-args btree::map::from_iter
```

* Before
```
test btree::map::from_iter_rand_100                      ... bench:       3,694 ns/iter (+/- 840)
test btree::map::from_iter_rand_10_000                   ... bench:   1,033,446 ns/iter (+/- 192,950)
test btree::map::from_iter_seq_100                       ... bench:       5,689 ns/iter (+/- 1,259)
test btree::map::from_iter_seq_10_000                    ... bench:     861,033 ns/iter (+/- 118,815)
```

* After
```
test btree::map::from_iter_rand_100                      ... bench:       3,033 ns/iter (+/- 707)
test btree::map::from_iter_rand_10_000                   ... bench:     775,958 ns/iter (+/- 105,152)
test btree::map::from_iter_seq_100                       ... bench:       2,969 ns/iter (+/- 336)
test btree::map::from_iter_seq_10_000                    ... bench:     258,292 ns/iter (+/- 29,364)
```

2 years agoAuto merge of #83214 - cjgillot:dep-map, r=michaelwoerister
bors [Mon, 6 Sep 2021 23:58:16 +0000 (23:58 +0000)]
Auto merge of #83214 - cjgillot:dep-map, r=michaelwoerister

Mmap the incremental data instead of reading it.

Instead of reading the full incremental state using `fs::read_file`, we memmap it using a private read-only file-backed map.
This allows the system to reclaim any memory we are not using, while ensuring we are not polluted by
outside modifications to the file.

Suggested in https://github.com/rust-lang/rust/pull/83036#issuecomment-800458082 by `@bjorn3`

2 years agoMove rustc_mir::transform to rustc_mir_transform.
Camille GILLOT [Fri, 1 Jan 2021 00:53:25 +0000 (01:53 +0100)]
Move rustc_mir::transform to rustc_mir_transform.

2 years agoMove rustc_mir::borrow_check to new crate rustc_borrowck.
Camille GILLOT [Wed, 30 Dec 2020 17:48:40 +0000 (18:48 +0100)]
Move rustc_mir::borrow_check to new crate rustc_borrowck.

2 years agoAuto merge of #88692 - hyd-dev:miri, r=RalfJung
bors [Mon, 6 Sep 2021 21:06:22 +0000 (21:06 +0000)]
Auto merge of #88692 - hyd-dev:miri, r=RalfJung

Update Miri

Fixes #88671.

r? `@RalfJung`

2 years agoUpdate `Cargo.lock`
hyd-dev [Mon, 6 Sep 2021 16:43:27 +0000 (00:43 +0800)]
Update `Cargo.lock`

2 years agoUpdate Miri
hyd-dev [Mon, 6 Sep 2021 16:33:37 +0000 (00:33 +0800)]
Update Miri

2 years agoMove `confused_type_with_std_module` to `ResolverOutputs`
Aaron Hill [Mon, 6 Sep 2021 16:20:59 +0000 (11:20 -0500)]
Move `confused_type_with_std_module` to `ResolverOutputs`

This eliminates untracked global state from `Session`.

2 years agoAuto merge of #88362 - pietroalbini:bump-stage0, r=Mark-Simulacrum
bors [Mon, 6 Sep 2021 16:01:17 +0000 (16:01 +0000)]
Auto merge of #88362 - pietroalbini:bump-stage0, r=Mark-Simulacrum

Pin bootstrap checksums and add a tool to update it automatically

:warning: :warning: This is just a proactive hardening we're performing on the build system, and it's not prompted by any known compromise. If you're aware of security issues being exploited please [check out our responsible disclosure page](https://www.rust-lang.org/policies/security). :warning: :warning:

---

This PR aims to improve Rust's supply chain security by pinning the checksums of the bootstrap compiler downloaded by `x.py`, preventing a compromised `static.rust-lang.org` from affecting building the compiler. The checksums are stored in `src/stage0.json`, which replaces `src/stage0.txt`. This PR also adds a tool to automatically update the bootstrap compiler.

The changes in this PR were originally discussed in [Zulip](https://zulip-archive.rust-lang.org/stream/241545-t-release/topic/pinning.20stage0.20hashes.html).

## Potential attack

Before this PR, an attacker who wanted to compromise the bootstrap compiler would "just" need to:

1. Gain write access to `static.rust-lang.org`, either by compromising DNS or the underlying storage.
2. Upload compromised binaries and corresponding `.sha256` files to `static.rust-lang.org`.

There is no signature verification in `x.py` as we don't want the build system to depend on GPG. Also, since the checksums were not pinned inside the repository, they were downloaded from `static.rust-lang.org` too: this only protected from accidental changes in `static.rust-lang.org` that didn't change the `*.sha256` files. The attack would allow the attacker to compromise past and future invocations of `x.py`.

## Mitigations introduced in this PR

This PR adds pinned checksums for all the bootstrap components in `src/stage0.json` instead of downloading the checksums from `static.rust-lang.org`. This changes the attack scenario to:

1. Gain write access to `static.rust-lang.org`, either by compromising DNS or the underlying storage.
2. Upload compromised binaries to `static.rust-lang.org`.
3. Land a (reviewed) change in the `rust-lang/rust` repository changing the pinned hashes.

Even with a successful attack, existing clones of the Rust repository won't be affected, and once the attack is detected reverting the pinned hashes changes should be enough to be protected from the attack. This also enables further mitigations to be implemented in following PRs, such as verifying signatures when pinning new checksums (removing the trust on first use aspect of this PR) and adding a check in CI making sure a PR updating the checksum has not been tampered with (see the future improvements section).

## Additional changes

There are additional changes implemented in this PR to enable the mitigation:

* The `src/stage0.txt` file has been replaced with `src/stage0.json`. The reasoning for the change is that there is existing tooling to read and manipulate JSON files compared to the custom format we were using before, and the slight challenge of manually editing JSON files (no comments, no trailing commas) are not a problem thanks to the new `bump-stage0`.

* A new tool has been added to the repository, `bump-stage0`. When invoked, the tool automatically calculates which release should be used as the bootstrap compiler given the current version and channel, gathers all the relevant checksums and updates `src/stage0.json`. The tool can be invoked by running:

  ```
  ./x.py run src/tools/bump-stage0
  ```

* Support for downloading releases from `https://dev-static.rust-lang.org` has been removed, as it's not possible to verify checksums there (it's customary to replace existing artifacts there if a rebuild is warranted). This will require a change to the release process to avoid bumping the bootstrap compiler on beta before the stable release.

## Future improvements

* Add signature verification as part of `bump-stage0`, which would require the attacker to also obtain the release signing keys in order to successfully compromise the bootstrap compiler. This would be fine to add now, as the burden of installing the tool to verify signatures would only be placed on whoever updates the bootstrap compiler, instead of everyone compiling Rust.

* Add a check on CI that ensures the checksums in `src/stage0.json` are the expected ones. If a PR changes the stage0 file CI should also run the `bump-stage0` tool and fail if the output in CI doesn't match the committed file. This prevents the PR author from tweaking the output of the tool manually, which would otherwise be close to impossible for a human to detect.

* Automate creating the PRs bumping the bootstrap compiler, by setting up a scheduled job in GitHub Actions that runs the tool and opens a PR.

* Investigate whether a similar mitigation can be done for "download from CI" components like the prebuilt LLVM.

r? `@Mark-Simulacrum`

2 years agoAdd a regression test for https://github.com/rust-lang/rust/issues/88649
hyd-dev [Mon, 6 Sep 2021 15:58:10 +0000 (23:58 +0800)]
Add a regression test for https://github.com/rust-lang/rust/issues/88649

2 years agoAuto merge of #88686 - rylev:rollup-m1tf9ir, r=m-ou-se
bors [Mon, 6 Sep 2021 13:20:16 +0000 (13:20 +0000)]
Auto merge of #88686 - rylev:rollup-m1tf9ir, r=m-ou-se

Rollup of 6 pull requests

Successful merges:

 - #88602 (Add tests for some const generics issues)
 - #88647 (Document when to use Windows' `symlink_dir` vs. `symlink_file`)
 - #88659 (Remove SmallVector mention)
 - #88661 (Correct typo)
 - #88673 (Fix typo: needede -> needed)
 - #88685 (:arrow_up: rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoSuggest deriving traits if possible
Paul Trojahn [Mon, 26 Jul 2021 18:26:23 +0000 (20:26 +0200)]
Suggest deriving traits if possible

This only applies to builtin derives as I don't think there is a
clean way to get the available derives in typeck.

Closes #85851

2 years agoAuto merge of #88678 - matthewjasper:if-boolean-scoping, r=oli-obk
bors [Mon, 6 Sep 2021 10:39:21 +0000 (10:39 +0000)]
Auto merge of #88678 - matthewjasper:if-boolean-scoping, r=oli-obk

Change scope of temporaries in match guards

Each pattern in a match arm has its own copy of the match guard in MIR, with its own temporary, so it has to be dropped before the the guards are joined to the single copy of the arm. This PR changes `then_else_break` to allow it to put the temporary in the innermost scope possible. This change isn't done for `if` expressions because that affects a large number of mir-opt tests and could more significantly affect performance.

closes #88649

r? `@oli-obk`

2 years agoRollup merge of #88685 - lnicola:rust-analyzer-2021-09-06, r=lnicola
Ryan Levick [Mon, 6 Sep 2021 10:38:58 +0000 (12:38 +0200)]
Rollup merge of #88685 - lnicola:rust-analyzer-2021-09-06, r=lnicola

:arrow_up: rust-analyzer

2 years agoRollup merge of #88673 - Qwaz:node-typo, r=jyn514
Ryan Levick [Mon, 6 Sep 2021 10:38:57 +0000 (12:38 +0200)]
Rollup merge of #88673 - Qwaz:node-typo, r=jyn514

Fix typo: needede -> needed

Fix a typo in library/alloc/src/collections/btree/node.rs

2 years agoRollup merge of #88661 - est31:typo_fix_in_test, r=joshtriplett
Ryan Levick [Mon, 6 Sep 2021 10:38:56 +0000 (12:38 +0200)]
Rollup merge of #88661 - est31:typo_fix_in_test, r=joshtriplett

Correct typo

found while addressing reviewer remarks for #88316

2 years agoRollup merge of #88659 - est31:update_smallvec_name, r=matthewjasper
Ryan Levick [Mon, 6 Sep 2021 10:38:55 +0000 (12:38 +0200)]
Rollup merge of #88659 - est31:update_smallvec_name, r=matthewjasper

Remove SmallVector mention

SmallVector is long gone, as it's been first replaced
by OneVector in commit e5e6375352636360add297c1f5a1f37ce71506e9,
which then has been removed entirely in favour of SmallVec in
commit 130a32fa7259d348dc3a684b38e688da398c30bb.

2 years agoRollup merge of #88647 - ChrisDenton:win-symlink-docs, r=joshtriplett
Ryan Levick [Mon, 6 Sep 2021 10:38:54 +0000 (12:38 +0200)]
Rollup merge of #88647 - ChrisDenton:win-symlink-docs, r=joshtriplett

Document when to use Windows' `symlink_dir` vs. `symlink_file`

It was previously unclear why there are two functions and when they should be used.

Fixes: #88635
2 years agoRollup merge of #88602 - BoxyUwU:tests-uwu-nya, r=lcnr
Ryan Levick [Mon, 6 Sep 2021 10:38:53 +0000 (12:38 +0200)]
Rollup merge of #88602 - BoxyUwU:tests-uwu-nya, r=lcnr

Add tests for some const generics issues

closes #82956
closes #84659
closes #86530
closes #86535

there is also a random test in here about array repeat expressions that I already had on this branch but it seems to fit the theme of this PR so kept it...

r? `@lcnr`

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Mon, 6 Sep 2021 08:05:05 +0000 (11:05 +0300)]
:arrow_up: rust-analyzer

2 years agoAuto merge of #88631 - camelid:sugg-span, r=davidtwco
bors [Mon, 6 Sep 2021 07:58:24 +0000 (07:58 +0000)]
Auto merge of #88631 - camelid:sugg-span, r=davidtwco

Improve structured tuple struct suggestion

Previously, the span was just for the constructor name, which meant it
would result in syntactically-invalid code when applied. Now, the span
is for the entire expression.

I also changed it to use `span_suggestion_verbose`, for two reasons:

1. Now that the suggestion span has been corrected, the output is a bit
   cluttered and hard to read. Putting the suggestion its own window
   creates more space.

2. It's easier to see what's being suggested, since now the version
   after the suggestion is applied is shown.

r? `@davidtwco`

2 years agoAuto merge of #7634 - chansuke:update-eval-order-depends-docs, r=Manishearth
bors [Mon, 6 Sep 2021 07:51:55 +0000 (07:51 +0000)]
Auto merge of #7634 - chansuke:update-eval-order-depends-docs, r=Manishearth

Fix documentation of eval_order_dependence

Fixes #7624.

changelog: fix documentation of eval_order_dependence

2 years agoCorrectly handle niche of enum
Deadbeef [Mon, 6 Sep 2021 07:09:32 +0000 (07:09 +0000)]
Correctly handle niche of enum

2 years agoAuto merge of #88665 - falk-hueffner:int-log-return-value-u32, r=scottmcm
bors [Mon, 6 Sep 2021 05:28:32 +0000 (05:28 +0000)]
Auto merge of #88665 - falk-hueffner:int-log-return-value-u32, r=scottmcm

Change return type for T::{log,log2,log10} to u32.

The value is at most 128, and this is consistent with using u32 for small values elsewhere (e.g. BITS, count_ones, leading_zeros).

2 years agoAuto merge of #88640 - SkiFire13:tests-for-85499, r=jackh726
bors [Mon, 6 Sep 2021 03:00:48 +0000 (03:00 +0000)]
Auto merge of #88640 - SkiFire13:tests-for-85499, r=jackh726

Add tests for issues fixed by #85499

Closes #80706
Closes #80956
Closes #81809
Closes #85455

2 years agoAuto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
bors [Mon, 6 Sep 2021 00:14:41 +0000 (00:14 +0000)]
Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank

Fix #88256 remove duplicated diagnostics

Fix #88256

2 years agoAuto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
bors [Mon, 6 Sep 2021 00:14:41 +0000 (00:14 +0000)]
Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank

Fix #88256 remove duplicated diagnostics

Fix #88256

2 years agoAdd regression test for #74400
Bram van den Heuvel [Tue, 31 Aug 2021 09:03:49 +0000 (11:03 +0200)]
Add regression test for #74400

2 years agoAuto merge of #88435 - cjgillot:no-walk-crate, r=Aaron1011
bors [Sun, 5 Sep 2021 21:40:34 +0000 (21:40 +0000)]
Auto merge of #88435 - cjgillot:no-walk-crate, r=Aaron1011

Avoid invoking the hir_crate query to traverse the HIR

Walking the HIR tree is done using the `hir_crate` query. However, this is unnecessary, since `hir_owner(CRATE_DEF_ID)` provides the same information. Since depending on `hir_crate` forces dependents to always be executed, this leads to unnecessary work.

By splitting HIR and attributes visits, we can avoid an edge to `hir_crate` when trying to visit the HIR tree.

2 years agoFix typo: needede -> needed
Yechan Bae [Sun, 5 Sep 2021 20:04:19 +0000 (16:04 -0400)]
Fix typo: needede -> needed

2 years agoAuto merge of #88552 - nbdd0121:vtable, r=nagisa
bors [Sun, 5 Sep 2021 18:55:32 +0000 (18:55 +0000)]
Auto merge of #88552 - nbdd0121:vtable, r=nagisa

Stop allocating vtable entries for non-object-safe methods

Current a vtable entry is allocated for all associated fns, even if the method is not object-safe: https://godbolt.org/z/h7vx6f35T

As a result, each vtable for `Iterator`' currently consumes 74 `usize`s. This PR stops allocating vtable entries for those methods, reducing vtable size of each `Iterator` vtable to 7 `usize`s.

Note that this PR introduces will cause more invocations of `is_vtable_safe_method`. So a perf run might be needed. If result isn't favorable then we might need to query-ify `is_vtable_safe_method`.

2 years agoAuto merge of #7596 - lengyijun:option_needless_deref, r=llogiq
bors [Sun, 5 Sep 2021 18:11:56 +0000 (18:11 +0000)]
Auto merge of #7596 - lengyijun:option_needless_deref, r=llogiq

New lint: option_needless_deref

changelog: [`option_needless_deref`]
fix #7571

2 years agoChange scope of temporaries in match guards
Matthew Jasper [Sun, 5 Sep 2021 17:50:55 +0000 (18:50 +0100)]
Change scope of temporaries in match guards

Each pattern in a match arm has its own copy of the match guard in MIR,
with its own temporary, so it has to be dropped before the the guards
are joined to the single copy of the arm.

2 years agoMention usage of `const` in raw pointer types at the top of the keyword's documentati...
Frank Steffahn [Thu, 2 Sep 2021 15:47:28 +0000 (17:47 +0200)]
Mention usage of `const` in raw pointer types at the top of the keyword's documentation page.

2 years agoAdditional aliases for pointers
Frank Steffahn [Thu, 2 Sep 2021 15:37:53 +0000 (17:37 +0200)]
Additional aliases for pointers

2 years agoAdd query `own_existential_vtable_entries`
Gary Guo [Wed, 1 Sep 2021 22:04:28 +0000 (23:04 +0100)]
Add query `own_existential_vtable_entries`

2 years agoStop allocating vtable entries for non-object-safe methods
Gary Guo [Tue, 31 Aug 2021 23:49:14 +0000 (00:49 +0100)]
Stop allocating vtable entries for non-object-safe methods

2 years agoAuto merge of #7638 - xFrednet:7569-avoid-indexing-in-clippy, r=Manishearth
bors [Sun, 5 Sep 2021 17:01:50 +0000 (17:01 +0000)]
Auto merge of #7638 - xFrednet:7569-avoid-indexing-in-clippy, r=Manishearth

Avoid slice indexing in Clippy (down with the ICEs)

While working on #7569 I got about 23 lint reports where we can avoid slice indexing by destructing the slice early. This is a preparation PR to avoid fixing them in the lint PR. (The implementation already takes about 300 lines without tests :sweat_smile:). Either way, this should hopefully be easy to review :upside_down_face:

---

changelog: none

2 years agoAuto merge of #88499 - eddyb:layout-off, r=nagisa
bors [Sun, 5 Sep 2021 16:14:41 +0000 (16:14 +0000)]
Auto merge of #88499 - eddyb:layout-off, r=nagisa

Provide `layout_of` automatically (given tcx + param_env + error handling).

After #88337, there's no longer any uses of `LayoutOf` within `rustc_target` itself, so I realized I could move the trait to `rustc_middle::ty::layout` and redesign it a bit.

This is similar to #88338 (and supersedes it), but at no ergonomic loss, since there's no funky `C: LayoutOf<Ty = Ty>` -> `Ty: TyAbiInterface<C>` generic `impl` chain, and each `LayoutOf` still corresponds to one `impl` (of `LayoutOfHelpers`) for the specific context.

After this PR, this is what's needed to get `trait LayoutOf` (with the `layout_of` method) implemented on some context type:
* `TyCtxt`, via `HasTyCtxt`
* `ParamEnv`, via `HasParamEnv`
* a way to transform `LayoutError`s into the desired error type
  * an error type of `!` can be paired with having `cx.layout_of(...)` return `TyAndLayout` *without* `Result<...>` around it, such as used by codegen
  * this is done through a new `LayoutOfHelpers` trait (and so is specifying the type of `cx.layout_of(...)`)

When going through this path (and not bypassing it with a manual `impl` of `LayoutOf`), the end result is that only the error case can be customized, the query itself and the success paths are guaranteed to be uniform.

(**EDIT**: just noticed that because of the supertrait relationship, you cannot actually implement `LayoutOf` yourself, the blanket `impl` fully covers all possible context types that could ever implement it)

Part of the motivation for this shape of API is that I've been working on querifying `FnAbi::of_*`, and what I want/need to introduce for that looks a lot like the setup in this PR - in particular, it's harder to express the `FnAbi` methods in `rustc_target`, since they're much more tied to `rustc` concepts.

r? `@nagisa` cc `@oli-obk` `@bjorn3`

2 years agoAuto merge of #88499 - eddyb:layout-off, r=nagisa
bors [Sun, 5 Sep 2021 16:14:41 +0000 (16:14 +0000)]
Auto merge of #88499 - eddyb:layout-off, r=nagisa

Provide `layout_of` automatically (given tcx + param_env + error handling).

After #88337, there's no longer any uses of `LayoutOf` within `rustc_target` itself, so I realized I could move the trait to `rustc_middle::ty::layout` and redesign it a bit.

This is similar to #88338 (and supersedes it), but at no ergonomic loss, since there's no funky `C: LayoutOf<Ty = Ty>` -> `Ty: TyAbiInterface<C>` generic `impl` chain, and each `LayoutOf` still corresponds to one `impl` (of `LayoutOfHelpers`) for the specific context.

After this PR, this is what's needed to get `trait LayoutOf` (with the `layout_of` method) implemented on some context type:
* `TyCtxt`, via `HasTyCtxt`
* `ParamEnv`, via `HasParamEnv`
* a way to transform `LayoutError`s into the desired error type
  * an error type of `!` can be paired with having `cx.layout_of(...)` return `TyAndLayout` *without* `Result<...>` around it, such as used by codegen
  * this is done through a new `LayoutOfHelpers` trait (and so is specifying the type of `cx.layout_of(...)`)

When going through this path (and not bypassing it with a manual `impl` of `LayoutOf`), the end result is that only the error case can be customized, the query itself and the success paths are guaranteed to be uniform.

(**EDIT**: just noticed that because of the supertrait relationship, you cannot actually implement `LayoutOf` yourself, the blanket `impl` fully covers all possible context types that could ever implement it)

Part of the motivation for this shape of API is that I've been working on querifying `FnAbi::of_*`, and what I want/need to introduce for that looks a lot like the setup in this PR - in particular, it's harder to express the `FnAbi` methods in `rustc_target`, since they're much more tied to `rustc` concepts.

r? `@nagisa` cc `@oli-obk` `@bjorn3`

2 years agoChange return type for T::{log,log2,log10} to u32. The value is at
Falk Hüffner [Sun, 5 Sep 2021 15:09:21 +0000 (17:09 +0200)]
Change return type for T::{log,log2,log10} to u32. The value is at
most 128, and this is consistent with using u32 for small values
elsewhere (e.g. BITS, count_ones, leading_zeros).