]> git.lizzy.rs Git - rust.git/log
rust.git
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 agoTweak `write_fmt` doc.
kraktus [Sun, 5 Sep 2021 15:23:58 +0000 (17:23 +0200)]
Tweak `write_fmt` doc.

Previous version wrongly used `but` while the two parts of the sentence are not contradicting but completing with each other.

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

2 years agoAuto merge of #7627 - xFrednet:0000-updating-issue-templates-again, r=llogiq
bors [Sun, 5 Sep 2021 14:53:33 +0000 (14:53 +0000)]
Auto merge of #7627 - xFrednet:0000-updating-issue-templates-again, r=llogiq

Updating issue templates again for rustbot

It turns out that our current issue template can sometimes trigger a rustbot error message, as can be seen in [#7626](https://github.com/rust-lang/rust-clippy/issues/7626). I originally tested this in #7599, but it's apparently a bit inconsistent. This PR adds backticks to the commands, as correctly suggested by `@mikerite` in the comments. (Thank you!)

``@rustbot` label +S-blocked`

---

Now I also pushed a tiny link fix as well. :upside_down_face:

---

changelog: none

2 years agoAuto merge of #7629 - mikerite:fix-7623-2, r=xFrednet
bors [Sun, 5 Sep 2021 13:17:02 +0000 (13:17 +0000)]
Auto merge of #7629 - mikerite:fix-7623-2, r=xFrednet

Make `approx_const` MSRV aware

changelog: [`approx_const`]: Add MRSV checks for LOG10_2 and LOG2_10.

Fixes #7623

2 years agoAuto merge of #88604 - camelid:rustdoc-lifetime-bounds, r=GuillaumeGomez
bors [Sun, 5 Sep 2021 12:52:34 +0000 (12:52 +0000)]
Auto merge of #88604 - camelid:rustdoc-lifetime-bounds, r=GuillaumeGomez

rustdoc: Clean up handling of lifetime bounds

Previously, rustdoc recorded lifetime bounds by rendering them into the
name of the lifetime parameter. Now, it leaves the name as the actual
name and instead records lifetime bounds in an `outlives` list, similar
to how type parameter bounds are recorded.

Also, higher-ranked lifetimes cannot currently have bounds, so I simplified
the code to reflect that.

r? `@GuillaumeGomez`

2 years agoAvoid slice indexing in Clippy (down with the ICEs)
xFrednet [Sat, 4 Sep 2021 16:21:49 +0000 (18:21 +0200)]
Avoid slice indexing in Clippy (down with the ICEs)

2 years agoAuto merge of #88662 - m-ou-se:rollup-h6lgp7k, r=m-ou-se
bors [Sun, 5 Sep 2021 10:11:37 +0000 (10:11 +0000)]
Auto merge of #88662 - m-ou-se:rollup-h6lgp7k, r=m-ou-se

Rollup of 4 pull requests

Successful merges:

 - #88257 (Provide more context on incorrect inner attribute)
 - #88432 (Fix a typo in raw_vec)
 - #88511 (x.py clippy: don't run with --all-targets by default)
 - #88657 (Fix 2021 `dyn` suggestion that used code as label)

Failed merges:

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

2 years agoAdd tests
Giacomo Stevanato [Sat, 4 Sep 2021 12:00:10 +0000 (14:00 +0200)]
Add tests

2 years agoRollup merge of #88657 - camelid:fix-dyn-sugg, r=m-ou-se
Mara Bos [Sun, 5 Sep 2021 08:32:24 +0000 (10:32 +0200)]
Rollup merge of #88657 - camelid:fix-dyn-sugg, r=m-ou-se

Fix 2021 `dyn` suggestion that used code as label

The arguments to `span_suggestion` were in the wrong order, so the error
looked like this:

    error[E0783]: trait objects without an explicit `dyn` are deprecated
      --> src/test/ui/editions/dyn-trait-sugg-2021.rs:10:5
       |
    10 |     Foo::hi(123);
       |     ^^^ help: <dyn Foo>: `use `dyn``

Now the error looks like this, as expected:

    error[E0783]: trait objects without an explicit `dyn` are deprecated
      --> src/test/ui/editions/dyn-trait-sugg-2021.rs:10:5
       |
    10 |     Foo::hi(123);
       |     ^^^ help: use `dyn`: `<dyn Foo>`

This issue was only present in the 2021 error; the 2018 lint was
correct.

r? `@m-ou-se`

2 years agoRollup merge of #88511 - matthiaskrgr:xpyclippydefaulttarget, r=jyn514
Mara Bos [Sun, 5 Sep 2021 08:32:23 +0000 (10:32 +0200)]
Rollup merge of #88511 - matthiaskrgr:xpyclippydefaulttarget, r=jyn514

x.py clippy: don't run with --all-targets by default

this caused a lot of noise because benchmarks and tests were also checked

before:
`./x.py clippy |& wc -l`
`74026`

with change:
`./x.py clippy |& wc -l`
`43269`

Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/x.2Epy.20check.20default.20targets

r?  `@jyn514` or `@Mark-Simulacrum`

2 years agoRollup merge of #88432 - terrarier2111:patch-1, r=joshtriplett
Mara Bos [Sun, 5 Sep 2021 08:32:21 +0000 (10:32 +0200)]
Rollup merge of #88432 - terrarier2111:patch-1, r=joshtriplett

Fix a typo in raw_vec

2 years agoRollup merge of #88257 - estebank:invalid-attr-error, r=oli-obk
Mara Bos [Sun, 5 Sep 2021 08:32:20 +0000 (10:32 +0200)]
Rollup merge of #88257 - estebank:invalid-attr-error, r=oli-obk

Provide more context on incorrect inner attribute

Suggest changing an inner attribute into an outer attribute if followed by an item.

2 years agoAuto merge of #88603 - nikic:llvm-update, r=cuviper
bors [Sun, 5 Sep 2021 07:04:27 +0000 (07:04 +0000)]
Auto merge of #88603 - nikic:llvm-update, r=cuviper

Update LLVM submodule

This merges upstream `release/13.x` changes to our fork. In particular, this fixes #85580.

2 years agoImprove `approx_constant` output
Michael Wright [Sun, 5 Sep 2021 06:42:00 +0000 (08:42 +0200)]
Improve `approx_constant` output

2 years agoAdd MSRV to `approx_constant` documentation
Michael Wright [Sun, 5 Sep 2021 06:19:30 +0000 (08:19 +0200)]
Add MSRV to `approx_constant` documentation

2 years agoCorrect typo
est31 [Sun, 5 Sep 2021 06:04:20 +0000 (08:04 +0200)]
Correct typo

2 years agoAuto merge of #88559 - bjorn3:archive_logic_dedup, r=cjgillot
bors [Sun, 5 Sep 2021 04:37:12 +0000 (04:37 +0000)]
Auto merge of #88559 - bjorn3:archive_logic_dedup, r=cjgillot

Move add_rlib and add_native_library to cg_ssa

This deduplicates logic between codegen backends.

cc `@antoyo` and `@khyperia` for cg_gcc and rust-gpu.

2 years agoRemove SmallVector mention
est31 [Sun, 5 Sep 2021 04:08:34 +0000 (06:08 +0200)]
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 agoFix formatting
Theodore Luo Wang [Sun, 5 Sep 2021 02:38:39 +0000 (22:38 -0400)]
Fix formatting

2 years agoUse verbose suggestions and only match if the + is seen before a numeric literal
Theodore Luo Wang [Sun, 5 Sep 2021 02:35:59 +0000 (22:35 -0400)]
Use verbose suggestions and only match if the + is seen before a numeric literal

2 years agoAuto merge of #88469 - patrick-gu:master, r=dtolnay
bors [Sun, 5 Sep 2021 01:56:25 +0000 (01:56 +0000)]
Auto merge of #88469 - patrick-gu:master, r=dtolnay

Add links in docs for some primitive types

This pull request adds additional links in existing documentation of some of the primitive types.

Where items are linked only once, I have used the `[link](destination)` format. For items in `std`, I have linked directly to the HTML, since although the primitives are in `core`, they are not displayed on `core` documentation. I was unsure of what length I should keep lines of documentation to, so I tried to keep them within reason.

Additionally, I have avoided excessively linking to keywords like `self` when they are not relevant to the documentation. I can add these links if it would be an improvement.

I hope this can improve Rust. Please let me know if there's anything I did wrong!

2 years agoFix 2021 `dyn` suggestion that used code as label
Noah Lev [Sun, 5 Sep 2021 01:29:03 +0000 (18:29 -0700)]
Fix 2021 `dyn` suggestion that used code as label

The arguments to `span_suggestion` were in the wrong order, so the error
looked like this:

    error[E0783]: trait objects without an explicit `dyn` are deprecated
      --> src/test/ui/editions/dyn-trait-sugg-2021.rs:10:5
       |
    10 |     Foo::hi(123);
       |     ^^^ help: <dyn Foo>: `use `dyn``

Now the error looks like this, as expected:

    error[E0783]: trait objects without an explicit `dyn` are deprecated
      --> src/test/ui/editions/dyn-trait-sugg-2021.rs:10:5
       |
    10 |     Foo::hi(123);
       |     ^^^ help: use `dyn`: `<dyn Foo>`

This issue was only present in the 2021 error; the 2018 lint was
correct.

2 years agoUpdate clippy_lints/src/needless_option_as_deref.rs
lyj [Sun, 5 Sep 2021 00:33:04 +0000 (08:33 +0800)]
Update clippy_lints/src/needless_option_as_deref.rs

Co-authored-by: llogiq <bogusandre@gmail.com>
2 years agoAuto merge of #88626 - cjgillot:lfitb, r=petrochenkov
bors [Sat, 4 Sep 2021 23:11:07 +0000 (23:11 +0000)]
Auto merge of #88626 - cjgillot:lfitb, r=petrochenkov

Simplify lifetimes_from_impl_trait_bounds

Part of https://github.com/rust-lang/rust/pull/87234

r? `@petrochenkov`

2 years agoAuto merge of #7570 - HKalbasi:derivable-impls, r=camsteffen
bors [Sat, 4 Sep 2021 21:40:04 +0000 (21:40 +0000)]
Auto merge of #7570 - HKalbasi:derivable-impls, r=camsteffen

Add the `derivable_impls` lint

Fix #7550

changelog: Add new derivable_impls lint. mem_replace_with_default now covers non constructor cases.

2 years agoAuto merge of #7584 - shepmaster:unnecessary_expect, r=camsteffen
bors [Sat, 4 Sep 2021 21:25:55 +0000 (21:25 +0000)]
Auto merge of #7584 - shepmaster:unnecessary_expect, r=camsteffen

Extend unnecessary_unwrap to look for expect in addition to unwrap

changelog: Extend ``[`unnecessary_unwrap`]`` to also check for `Option::expect` and `Result::expect`. Also give code suggestions in some cases.

Fixes #7581

2 years agoadd derivable impls lint
hamidreza kalbasi [Mon, 16 Aug 2021 15:04:41 +0000 (19:34 +0430)]
add derivable impls lint

2 years agoAuto merge of #88364 - pietroalbini:llvm-install-filecheck, r=Mark-Simulacrum
bors [Sat, 4 Sep 2021 20:44:41 +0000 (20:44 +0000)]
Auto merge of #88364 - pietroalbini:llvm-install-filecheck, r=Mark-Simulacrum

Make sure FileCheck is copied in the LLVM output directory

The tool, which is needed by parts of our test suite, is built as part of LLVM but is *not* copied to the directory containing the output LLVM binaries. This adds a flag to ensure the binary is copied. This shouldn't add any extra built time, as the flag just installs extra binaries that were already compiled.

This is not strictly needed for the test suite to work (as it also checks `build/$target/llvm/build/bin` for the binary), but it allows deleting the `build/$TARGET/llvm/build` directory (which also contains the intermediary build artifacts) without affecting the test suite, saving disk space.

2 years agoClarify what “a container” is in `FromIterator<Option<A>> for Option<V>` doc.
Kevin Reid [Sat, 4 Sep 2021 18:19:59 +0000 (11:19 -0700)]
Clarify what “a container” is in `FromIterator<Option<A>> for Option<V>` doc.

2 years agoAdd sentence punctuation and links in `Option` docs.
Kevin Reid [Sat, 4 Sep 2021 18:17:34 +0000 (11:17 -0700)]
Add sentence punctuation and links in `Option` docs.

2 years ago“Moves” instead of “copies” in `<Option<T> as From<T>>::from` doc.
Kevin Reid [Sat, 4 Sep 2021 18:05:36 +0000 (11:05 -0700)]
“Moves” instead of “copies” in `<Option<T> as From<T>>::from` doc.

This implementation 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.

Also linkify `Some` while we're touching the line anyway.

2 years agoDocument when to use Windows' `symlink_dir` vs. `symlink_file`
Chris Denton [Sat, 4 Sep 2021 18:22:34 +0000 (19:22 +0100)]
Document when to use Windows' `symlink_dir` vs. `symlink_file`

It was previously unclear which should be used when.

2 years agoAuto merge of #88574 - camelid:box-genericarg-const, r=GuillaumeGomez
bors [Sat, 4 Sep 2021 18:18:00 +0000 (18:18 +0000)]
Auto merge of #88574 - camelid:box-genericarg-const, r=GuillaumeGomez

rustdoc: Box `GenericArg::Const` to reduce enum size

This should reduce the amount of memory allocated in the common cases
where the `GenericArg` is a lifetime or type.

2 years agoneedless_option_as_deref
lengyijun [Tue, 24 Aug 2021 14:06:46 +0000 (22:06 +0800)]
needless_option_as_deref

2 years agoAuto merge of #88550 - dpaoliello:dpaoliello/allocdebuginfo, r=estebank
bors [Sat, 4 Sep 2021 12:27:45 +0000 (12:27 +0000)]
Auto merge of #88550 - dpaoliello:dpaoliello/allocdebuginfo, r=estebank

Include debug info for the allocator shim

Issue Details:
In some cases it is necessary to generate an "allocator shim" to forward various Rust allocation functions (e.g., `__rust_alloc`) to an underlying function (e.g., `malloc`). However, since this allocator shim is a manually created LLVM module it is not processed via the normal module processing code and so no debug info is generated for it (if debugging info is enabled).

Fix Details:
* Modify the `debuginfo` code to allow creating debug info for a module without a `CodegenCx` (since it is difficult, and expensive, to create one just to emit some debug info).
* After creating the allocator shim add in basic debug info.

2 years agoFix documentation of eval_order_dependence
chansuke [Sat, 4 Sep 2021 12:07:25 +0000 (21:07 +0900)]
Fix documentation of eval_order_dependence

2 years agoFix #88256, remove duplicated diagnostic
yukang [Sat, 4 Sep 2021 11:26:25 +0000 (19:26 +0800)]
Fix #88256, remove duplicated diagnostic

2 years agoFix #88256, remove duplicated diagnostic
yukang [Sat, 4 Sep 2021 11:26:25 +0000 (19:26 +0800)]
Fix #88256, remove duplicated diagnostic

2 years agoAuto merge of #88547 - notriddle:notriddle/is-expr-delims-necessary, r=davidtwco
bors [Sat, 4 Sep 2021 09:46:58 +0000 (09:46 +0000)]
Auto merge of #88547 - notriddle:notriddle/is-expr-delims-necessary, r=davidtwco

fix(rustc_lint): better detect when parens are necessary

Fixes #88519

2 years agoAuto merge of #88538 - bjorn3:no_session_in_crate_loader, r=petrochenkov
bors [Sat, 4 Sep 2021 07:17:12 +0000 (07:17 +0000)]
Auto merge of #88538 - bjorn3:no_session_in_crate_loader, r=petrochenkov

CrateLocator refactorings

This makes the `CrateLocator` a lot cleaner IMHO and much more self-contained. The last commit removes `extra_filename` from the crate metadata. This is an **insta-stable** change as it allows a crate like `libfoo-abc.rlib` to be used as dependency and then be renamed as `libfoo-bcd.rlib` while still being found as indirect dependency. This may reduce performance when there are a lot of versions of the same crate available as the extra filename won't be used to do an early rejection of crates before trying to load metadata, but it makes the logic to find the right filename a lot cleaner.

2 years agoAuto merge of #88633 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum
bors [Sat, 4 Sep 2021 04:32:59 +0000 (04:32 +0000)]
Auto merge of #88633 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum

Bump version to 1.57

r? `@Mark-Simulacrum`

2 years agoBump version to 1.57
Mark Rousskov [Sat, 4 Sep 2021 01:54:48 +0000 (21:54 -0400)]
Bump version to 1.57

2 years agoAuto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiser
bors [Sat, 4 Sep 2021 01:40:36 +0000 (01:40 +0000)]
Auto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiser

Detect bare blocks with type ascription that were meant to be a `struct` literal

Address part of #34255.

Potential improvement: silence the other knock down errors in `issue-34255-1.rs`.

2 years agoEnable all main body Markdown options for summaries
Noah Lev [Sat, 4 Sep 2021 00:17:24 +0000 (17:17 -0700)]
Enable all main body Markdown options for summaries

This fixes odd renderings when these features are used in the first
paragraph of documentation for an item. This is an extension of #87270.

2 years agoFix accidentally deleted part
patrick-gu [Sat, 4 Sep 2021 00:13:42 +0000 (17:13 -0700)]
Fix accidentally deleted part

2 years agoAdd a missing backtick
patrick-gu [Sat, 4 Sep 2021 00:11:57 +0000 (17:11 -0700)]
Add a missing backtick

2 years agoUse `summary_opts()` for Markdown summaries
Noah Lev [Sat, 4 Sep 2021 00:10:52 +0000 (17:10 -0700)]
Use `summary_opts()` for Markdown summaries

It was accidentally changed to use `opts()` in #86451.

I also renamed `opts()` to `main_body_opts()` to make this kind of
accidental change less likely.

2 years agoRemove excessive linking
patrick-gu [Sat, 4 Sep 2021 00:09:37 +0000 (17:09 -0700)]
Remove excessive linking

2 years agoAuto merge of #88482 - athei:add-import-test, r=the8472
bors [Fri, 3 Sep 2021 23:12:35 +0000 (23:12 +0000)]
Auto merge of #88482 - athei:add-import-test, r=the8472

Add regression test for a spurious import

This PR adds a test that verifies that the bug described in the linked issue does not creep back into the code. In essence it checks that compiling some specific code (that uses 128 bit multiplication) with a specific set of compiler options does not lead to a spurious import of a panic function.

I noticed that other wasm tests use `# only-wasm32-bare` in their `Makefile`. This will skip the test for me. I did not find out how to run this test locally. Maybe someone can help.

closes #78744
r? `@jyn514`

2 years agoReplace Vec by Option.
Camille GILLOT [Thu, 1 Apr 2021 17:42:27 +0000 (19:42 +0200)]
Replace Vec by Option.

2 years agoSimplify lifetimes_from_impl_trait_bounds.
Camille GILLOT [Thu, 15 Jul 2021 21:00:42 +0000 (23:00 +0200)]
Simplify lifetimes_from_impl_trait_bounds.

2 years agorustdoc: Box `GenericArg::Const` to reduce enum size
Noah Lev [Wed, 1 Sep 2021 22:26:07 +0000 (15:26 -0700)]
rustdoc: Box `GenericArg::Const` to reduce enum size

2 years agoAuto merge of #88572 - matthewjasper:if-let-scoping-fix, r=oli-obk
bors [Fri, 3 Sep 2021 20:31:43 +0000 (20:31 +0000)]
Auto merge of #88572 - matthewjasper:if-let-scoping-fix, r=oli-obk

Fix drop handling for `if let` expressions

MIR lowering for `if let` expressions is now more complicated now that
`if let` exists in HIR. This PR adds a scope for the variables bound in
an `if let` expression and then uses an approach similar to how we
handle loops to ensure that we reliably drop the correct variables.

Closes #88307
cc `@flip1995` `@richkadel` `@c410-f3r`

2 years agoUpdate coverage tests
Matthew Jasper [Fri, 3 Sep 2021 18:51:27 +0000 (19:51 +0100)]
Update coverage tests

2 years agoAuto merge of #88454 - devnexen:sunos_asan, r=wesleywiser
bors [Fri, 3 Sep 2021 17:50:51 +0000 (17:50 +0000)]
Auto merge of #88454 - devnexen:sunos_asan, r=wesleywiser

sunos systems add sanitizer supported.

2 years agoAuto merge of #88597 - cjgillot:lower-global, r=petrochenkov
bors [Fri, 3 Sep 2021 14:47:13 +0000 (14:47 +0000)]
Auto merge of #88597 - cjgillot:lower-global, r=petrochenkov

Move global analyses from lowering to resolution

Split off https://github.com/rust-lang/rust/pull/87234

r? `@petrochenkov`

2 years agoDetect bare blocks with type ascription that were meant to be a `struct` literal
Esteban Kuber [Thu, 2 Sep 2021 18:34:03 +0000 (18:34 +0000)]
Detect bare blocks with type ascription that were meant to be a `struct` literal

Address part of #34255.

Potential improvement: silence the other knock down errors in
`issue-34255-1.rs`.

2 years agoCorrect link in documentation for the file `clippy_lints::utils::conf`
Fridtjof Stoldt [Fri, 3 Sep 2021 13:31:53 +0000 (15:31 +0200)]
Correct link in documentation for the file `clippy_lints::utils::conf`

2 years agoUpdating issue templates again for rustbot
xFrednet [Fri, 3 Sep 2021 10:12:16 +0000 (12:12 +0200)]
Updating issue templates again for rustbot

2 years agoAuto merge of #88618 - m-ou-se:rollup-6tss5z6, r=m-ou-se
bors [Fri, 3 Sep 2021 11:37:52 +0000 (11:37 +0000)]
Auto merge of #88618 - m-ou-se:rollup-6tss5z6, r=m-ou-se

Rollup of 7 pull requests

Successful merges:

 - #88202 (Add an example for deriving PartialOrd on enums)
 - #88483 (Fix LLVM libunwind build for non-musl targets)
 - #88507 (Add test case for using `slice::fill` with MaybeUninit)
 - #88557 (small const generics cleanup)
 - #88579 (remove redundant / misplaced sentence from docs)
 - #88610 (Update outdated docs of array::IntoIter::new.)
 - #88613 (Update primitive docs for rust 2021.)

Failed merges:

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

2 years agoRollup merge of #88613 - m-ou-se:array-docs-2021, r=Amanieu
Mara Bos [Fri, 3 Sep 2021 11:30:51 +0000 (13:30 +0200)]
Rollup merge of #88613 - m-ou-se:array-docs-2021, r=Amanieu

Update primitive docs for rust 2021.

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

2 years agoRollup merge of #88610 - m-ou-se:array-into-iter-docs, r=Amanieu
Mara Bos [Fri, 3 Sep 2021 11:30:50 +0000 (13:30 +0200)]
Rollup merge of #88610 - m-ou-se:array-into-iter-docs, r=Amanieu

Update outdated docs of array::IntoIter::new.

2 years agoRollup merge of #88579 - ast-ral:master, r=m-ou-se
Mara Bos [Fri, 3 Sep 2021 11:30:49 +0000 (13:30 +0200)]
Rollup merge of #88579 - ast-ral:master, r=m-ou-se

remove redundant / misplaced sentence from docs

Removes sentence that seems to have drifted down into the examples section. Luckily, someone already added an explanation of what happens with packed structs back into the initial section of the doc entry and this wayward sentence can likely just be deleted.

2 years agoRollup merge of #88557 - lcnr:const-generics-cleanup, r=BoxyUwU
Mara Bos [Fri, 3 Sep 2021 11:30:48 +0000 (13:30 +0200)]
Rollup merge of #88557 - lcnr:const-generics-cleanup, r=BoxyUwU

small const generics cleanup

2 years agoRollup merge of #88507 - atsuzaki:slice-fill-maybeuninit-test, r=RalfJung
Mara Bos [Fri, 3 Sep 2021 11:30:47 +0000 (13:30 +0200)]
Rollup merge of #88507 - atsuzaki:slice-fill-maybeuninit-test, r=RalfJung

Add test case for using `slice::fill` with MaybeUninit

Adds test for #87891

Looks alright? `@RalfJung`
Fixes #87891