Commit graph

154354 commits

Author SHA1 Message Date
jackh726
22ef04e22f A bit of cleanup to astconv 2021-09-07 18:25:57 -04:00
jackh726
216906fb75 Change is_unsized to add_implicitly_sized 2021-09-07 18:08:46 -04:00
jackh726
f1f1d56d93 Don't move ?Trait bounds to param bounds if they're in where clauses 2021-09-07 18:08:46 -04:00
jackh726
2eaf9fe364 Static assert size of GenericBoun to ensure size doesn't change 2021-09-07 17:53:43 -04:00
Camille GILLOT
c5fc2609f0 Rename rustc_mir to rustc_const_eval. 2021-09-07 20:46:26 +02:00
bors
fdf65053e9 Auto merge of #88724 - Mark-Simulacrum:bump-rls, r=Mark-Simulacrum
Bump RLS submodule

r? `@Mark-Simulacrum`
2021-09-07 18:31:03 +00:00
Camille GILLOT
fd9c04fe32 Move the dataflow framework to its own crate. 2021-09-07 19:57:07 +02:00
Camille GILLOT
81a600b6b7 Move monomorphize code to its own crate. 2021-09-07 19:53:04 +02:00
Mingwei Samuel
f8cbb1935c
Fix typo in const_generics replaced with adt_const_params note 2021-09-07 09:27:30 -07:00
bors
69c4aa2901 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.
2021-09-07 15:28:34 +00:00
Mark Rousskov
c13808fb77 Bump RLS submodule 2021-09-07 11:16:31 -04:00
bors
73641cd23b 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`
2021-09-07 12:31:11 +00:00
Michael Woerister
70c7317d71 Add test case for no-bundle/whole-archive native libs linking. 2021-09-07 14:14:08 +02:00
bors
b7c25e1679 Auto merge of #7642 - mikerite:fix-7641, r=flip1995
Add `TAU` to `approx_constant`

changelog: [`approx_constant`]: Add `TAU`
2021-09-07 08:16:36 +00:00
Michael Howell
d6ff916c2f test: add case for mutating iterator
Note that this incorrectly suggests a shared borrow,
but at least we know it's happening.
2021-09-07 00:51:27 -07:00
Jacob Pratt
56bb6f5a25
Fix docs for uX::checked_next_multiple_of 2021-09-07 02:14:04 -04:00
bors
385f8e2078 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`.
2021-09-07 05:28:53 +00:00
Michael Wright
a7a5a5d9b0 Add TAU to approx_constant 2021-09-07 05:50:04 +02:00
Mark Rousskov
2eac09d258 Use index newtyping for TyVid 2021-09-06 22:38:06 -04:00
bors
ffaf857045 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)
```
2021-09-07 02:24:11 +00:00
bors
11bbb52313 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`
2021-09-06 23:58:16 +00:00
Camille GILLOT
bba4be681d Move rustc_mir::transform to rustc_mir_transform. 2021-09-07 00:43:14 +02:00
Camille GILLOT
31a61ccc38 Move rustc_mir::borrow_check to new crate rustc_borrowck. 2021-09-07 00:29:22 +02:00
bors
1698e3cac5 Auto merge of #88692 - hyd-dev:miri, r=RalfJung
Update Miri

Fixes #88671.

r? `@RalfJung`
2021-09-06 21:06:22 +00:00
hyd-dev
e671c356bf
Update Cargo.lock 2021-09-07 00:43:27 +08:00
hyd-dev
6eec72ede8
Update Miri 2021-09-07 00:33:37 +08:00
Aaron Hill
404402430d
Move confused_type_with_std_module to ResolverOutputs
This eliminates untracked global state from `Session`.
2021-09-06 11:20:59 -05:00
bors
8ceea01bb4 Auto merge of #88362 - pietroalbini:bump-stage0, r=Mark-Simulacrum
Pin bootstrap checksums and add a tool to update it automatically

⚠️ ⚠️ 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). ⚠️ ⚠️

---

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`
2021-09-06 16:01:17 +00:00
hyd-dev
214eef0435
Add a regression test for https://github.com/rust-lang/rust/issues/88649 2021-09-06 23:58:10 +08:00
bors
13db8440bb 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 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-09-06 13:20:16 +00:00
Paul Trojahn
50e5f90c92 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
2021-09-06 13:18:05 +02:00
bors
1c858ba5bf 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`
2021-09-06 10:39:21 +00:00
Ryan Levick
3c4b461583
Rollup merge of #88685 - lnicola:rust-analyzer-2021-09-06, r=lnicola
⬆️ rust-analyzer
2021-09-06 12:38:58 +02:00
Ryan Levick
0d4a51d741
Rollup merge of #88673 - Qwaz:node-typo, r=jyn514
Fix typo: needede -> needed

Fix a typo in library/alloc/src/collections/btree/node.rs
2021-09-06 12:38:57 +02:00
Ryan Levick
797f9ce01a
Rollup merge of #88661 - est31:typo_fix_in_test, r=joshtriplett
Correct typo

found while addressing reviewer remarks for #88316
2021-09-06 12:38:56 +02:00
Ryan Levick
5f09e93318
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 e5e6375352,
which then has been removed entirely in favour of SmallVec in
commit 130a32fa72.
2021-09-06 12:38:55 +02:00
Ryan Levick
29a018def4
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
2021-09-06 12:38:54 +02:00
Ryan Levick
dcd0e1d835
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`
2021-09-06 12:38:53 +02:00
Laurențiu Nicola
a48ddcd93e ⬆️ rust-analyzer 2021-09-06 11:05:05 +03:00
bors
d19d864e79 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`
2021-09-06 07:58:24 +00:00
bors
17294b8161 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
2021-09-06 07:51:55 +00:00
Deadbeef
c0451f73b2
Correctly handle niche of enum 2021-09-06 07:10:48 +00:00
bors
b2d9bcda7e 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).
2021-09-06 05:28:32 +00:00
bors
0e0ce8364c 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
2021-09-06 03:00:48 +00:00
bors
f7aaa2a200 Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
Fix #88256 remove duplicated diagnostics

Fix #88256
2021-09-06 00:14:41 +00:00
bors
8f3aa5e8b9 Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
Fix #88256 remove duplicated diagnostics

Fix #88256
2021-09-06 00:14:41 +00:00
Bram van den Heuvel
fe7bcd6e40 Add regression test for #74400 2021-09-06 01:00:47 +02:00
bors
7849e3e9dd 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.
2021-09-05 21:40:34 +00:00
Yechan Bae
3a105cfcea Fix typo: needede -> needed 2021-09-05 16:04:19 -04:00
bors
e30b68353f 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`.
2021-09-05 18:55:32 +00:00