]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoProvide raw &str access from Decoder
Mark Rousskov [Tue, 22 Feb 2022 23:05:51 +0000 (18:05 -0500)]
Provide raw &str access from Decoder

2 years agoAuto merge of #94254 - matthiaskrgr:rollup-7llbjhd, r=matthiaskrgr
bors [Tue, 22 Feb 2022 14:41:26 +0000 (14:41 +0000)]
Auto merge of #94254 - matthiaskrgr:rollup-7llbjhd, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #94169 (Fix several asm! related issues)
 - #94178 (tidy: fire less "ignoring file length unneccessarily" warnings)
 - #94179 (solarish current_exe using libc call directly)
 - #94196 (compiletest: Print process output info with less whitespace)
 - #94208 (Add the let else tests found missing in the stabilization report)
 - #94237 (Do not suggest wrapping an item if it has ambiguous un-imported methods)
 - #94246 (ScalarMaybeUninit is explicitly hexadecimal in its formatting)

Failed merges:

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

2 years agoRollup merge of #94246 - RalfJung:hex, r=oli-obk
Matthias Krüger [Tue, 22 Feb 2022 11:16:34 +0000 (12:16 +0100)]
Rollup merge of #94246 - RalfJung:hex, r=oli-obk

ScalarMaybeUninit is explicitly hexadecimal in its formatting

This makes `ScalarMaybeUninit` consistent with `Scalar` after the changes in https://github.com/rust-lang/rust/pull/94189.

r? ``@oli-obk``

2 years agoRollup merge of #94237 - compiler-errors:dont-wrap-ambiguous-receivers, r=lcnr
Matthias Krüger [Tue, 22 Feb 2022 11:16:33 +0000 (12:16 +0100)]
Rollup merge of #94237 - compiler-errors:dont-wrap-ambiguous-receivers, r=lcnr

Do not suggest wrapping an item if it has ambiguous un-imported methods

If the method is defined for the receiver we have, but is ambiguous during probe, then it probably comes from one of several traits that just weren't `use`d. Don't suggest wrapping the receiver in `Box`/etc., even if that makes the method probe unambiguous.

Fixes #94218

2 years agoRollup merge of #94208 - est31:let_else, r=Mark-Simulacrum
Matthias Krüger [Tue, 22 Feb 2022 11:16:32 +0000 (12:16 +0100)]
Rollup merge of #94208 - est31:let_else, r=Mark-Simulacrum

Add the let else tests found missing in the stabilization report

In the stabilization report of `let else`, in #93628, I found various cases which weren't tested. This PR adds them.

2 years agoRollup merge of #94196 - aDotInTheVoid:terse-procres-info, r=Mark-Simulacrum
Matthias Krüger [Tue, 22 Feb 2022 11:16:31 +0000 (12:16 +0100)]
Rollup merge of #94196 - aDotInTheVoid:terse-procres-info, r=Mark-Simulacrum

compiletest: Print process output info with less whitespace

Before:

```
error: jsondocck failed!
status: exit status: 1
command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--template" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
Invalid command: Tried to use the previous path in the first command on line 10
Error: "Jsondocck failed for /data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs"

------------------------------------------

Rustdoc Output:
status: exit status: 0
command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait/auxiliary" "-o" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--deny" "warnings" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs" "--output-format" "json" "-Zunstable-options"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------

------------------------------------------

```

After:

```

error: jsondocck failed!
status: exit status: 1
command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--template" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs"
stdout: none
--- stderr -------------------------------
Invalid command: Tried to use the previous path in the first command on line 10
Error: "Jsondocck failed for /data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs"
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait/auxiliary" "-o" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--deny" "warnings" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none

```

2 years agoRollup merge of #94179 - devnexen:getexecname_directcall, r=kennytm
Matthias Krüger [Tue, 22 Feb 2022 11:16:30 +0000 (12:16 +0100)]
Rollup merge of #94179 - devnexen:getexecname_directcall, r=kennytm

solarish current_exe using libc call directly

2 years agoRollup merge of #94178 - est31:tolerant_lines_check, r=Mark-Simulacrum
Matthias Krüger [Tue, 22 Feb 2022 11:16:29 +0000 (12:16 +0100)]
Rollup merge of #94178 - est31:tolerant_lines_check, r=Mark-Simulacrum

tidy: fire less "ignoring file length unneccessarily" warnings

This avoids a situation where a file is at the border of the limit,
and alternates between hitting the limit and not hitting it, causing
a back and forth of addition of the ignore-tidy-linelength directive.

As an example, consider the ignore-tidy-filelength of compiler/rustc_typeck/src/collect.rs.

It was added in 2ca4964db5d263a8f9222846bd70a7f26cf414cf, removed in
37354ebc9794b0eb14b08c02177e3094c8fe91cd (a revert of the earlier commit), added again in 448d07683a6defd567996114793a09c9a8aef5df,
removed in 3171bd5bf54fb91f7f7df7c40df5adc7d8bd5dea, added in 438826fd1a9a119d00992ede948cdd479431ecbb,
and removed in bb0a2f985cb6e980cc026ea952733d53bb868f87.

To avoid this back and forth, we exempt files from the unneccessary
ignoring warning that have length of at least 70% of the limit.

2 years agoRollup merge of #94169 - Amanieu:asm_stuff, r=nagisa
Matthias Krüger [Tue, 22 Feb 2022 11:16:28 +0000 (12:16 +0100)]
Rollup merge of #94169 - Amanieu:asm_stuff, r=nagisa

Fix several asm! related issues

This is a combination of several fixes, each split into a separate commit. Splitting these into PRs is not practical since they conflict with each other.

Fixes #92378
Fixes #85247

r? ``@nagisa``

2 years agoAuto merge of #94209 - lcnr:print-mir-consts, r=oli-obk
bors [Tue, 22 Feb 2022 11:10:26 +0000 (11:10 +0000)]
Auto merge of #94209 - lcnr:print-mir-consts, r=oli-obk

change `mir::Constant` in mir dumps

this removes duplicate information and avoids printing the `stable_crate_id` in mir dumps which broke CI in #94059

r? `@oli-obk` cc `@b-naber`

2 years agochange `mir::Constant` in mir dumps
lcnr [Mon, 21 Feb 2022 07:10:07 +0000 (08:10 +0100)]
change `mir::Constant` in mir dumps

2 years agoAuto merge of #93839 - Mark-Simulacrum:delete-json-rust-deserialization, r=nnethercote
bors [Tue, 22 Feb 2022 07:54:22 +0000 (07:54 +0000)]
Auto merge of #93839 - Mark-Simulacrum:delete-json-rust-deserialization, r=nnethercote

Simplify rustc_serialize by dropping support for decoding into JSON

This PR currently bundles two (somewhat separate) tasks.

First, it removes the JSON Decoder trait impl, which permitted going from JSON to Rust structs. For now, we keep supporting JSON deserialization, but only to `Json` (an equivalent of serde_json::Value). The primary hard to remove user there is for custom targets -- which need some form of JSON deserialization -- but they already have a custom ad-hoc pass for moving from Json to a Rust struct.

A [comment](https://github.com/rust-lang/rust/blob/e7aca895980f25f6d2d3c48e10fd04656764d1e4/compiler/rustc_target/src/spec/mod.rs#L1653) there suggests that it would be impractical to move them to a Decodable-based impl, at least without backwards compatibility concerns. I suspect that if we were widely breaking compat there, it would make sense to use serde_json at this point which would produce better error messages; the types in rustc_target are relatively isolated so we would not particularly suffer from using serde_derive.

The second part of the PR (all but the first commit) is to simplify the Decoder API by removing the non-primitive `read_*` functions. These primarily add indirection (through a closure), which doesn't directly cause a performance issue (the unique closure types essentially guarantee monomorphization), but does increase the amount of work rustc and LLVM need to do. This could be split out to a separate PR, but is included here in part to help motivate the first part.

Future work might consist of:

* Specializing enum discriminant encoding to avoid leb128 for small enums (since we know the variant count, we can directly use read/write u8 in almost all cases)
* Adding new methods to support faster deserialization (e.g., access to the underlying byte stream)
   * Currently these are somewhat ad-hoc supported by specializations for e.g. `Vec<u8>`, but other types which could benefit don't today.
* Removing the Decoder trait entirely in favor of a concrete type -- today, we only really have one impl of it modulo wrappers used for specialization-based dispatch.

Highly recommend review with whitespace changes off, as the removal of closures frequently causes things to be de-indented.

2 years agoScalarMaybeUninit is explicitly hexadecimal in its formatting
Ralf Jung [Tue, 22 Feb 2022 02:46:51 +0000 (21:46 -0500)]
ScalarMaybeUninit is explicitly hexadecimal in its formatting

2 years agoDo not suggest wrapping an item if it has ambiguous un-imported methods
Michael Goulet [Tue, 22 Feb 2022 00:25:59 +0000 (16:25 -0800)]
Do not suggest wrapping an item if it has ambiguous un-imported methods

2 years agoAuto merge of #94225 - matthiaskrgr:rollup-0728x8n, r=matthiaskrgr
bors [Mon, 21 Feb 2022 22:53:45 +0000 (22:53 +0000)]
Auto merge of #94225 - matthiaskrgr:rollup-0728x8n, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #91192 (Some improvements to the async docs)
 - #94143 (rustc_const_eval: adopt let else in more places)
 - #94156 (Gracefully handle non-UTF-8 string slices when pretty printing)
 - #94186 (Update pin_static_ref stabilization version.)
 - #94189 (Implement LowerHex on Scalar to clean up their display in rustdoc)
 - #94190 (Use Metadata::modified instead of FileTime::from_last_modification_ti…)
 - #94203 (CTFE engine: Scalar: expose size-generic to_(u)int methods)
 - #94211 (Better error if the user tries to do assignment ... else)
 - #94215 (trait system: comments and small nonfunctional changes)
 - #94220 (Correctly handle miniz_oxide extern crate declaration)

Failed merges:

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

2 years agoAdd ignore-tidy-filelength
Amanieu d'Antras [Mon, 21 Feb 2022 19:18:00 +0000 (19:18 +0000)]
Add ignore-tidy-filelength

2 years agoRollup merge of #94220 - GuillaumeGomez:miniz-oxide-decl, r=Amanieu
Matthias Krüger [Mon, 21 Feb 2022 18:36:55 +0000 (19:36 +0100)]
Rollup merge of #94220 - GuillaumeGomez:miniz-oxide-decl, r=Amanieu

Correctly handle miniz_oxide extern crate declaration

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

Follow-up of https://github.com/rust-lang/rust/pull/94122.

The `miniz_oxide` dependency is optional and therefore should allow be "imported" when it makes sense.

r? `@ivmarkov`

2 years agoRollup merge of #94215 - lcnr:leak-check, r=jackh726
Matthias Krüger [Mon, 21 Feb 2022 18:36:54 +0000 (19:36 +0100)]
Rollup merge of #94215 - lcnr:leak-check, r=jackh726

trait system: comments and small nonfunctional changes

r? `@nikomatsakis` because of the leak-check check removal

2 years agoRollup merge of #94211 - est31:let_else_destructuring_error, r=matthewjasper
Matthias Krüger [Mon, 21 Feb 2022 18:36:53 +0000 (19:36 +0100)]
Rollup merge of #94211 - est31:let_else_destructuring_error, r=matthewjasper

Better error if the user tries to do assignment ... else

If the user tries to do assignment ... else, we now issue a more comprehensible error in the parser.

closes #93995

2 years agoRollup merge of #94203 - RalfJung:to_sized_int, r=oli-obk
Matthias Krüger [Mon, 21 Feb 2022 18:36:52 +0000 (19:36 +0100)]
Rollup merge of #94203 - RalfJung:to_sized_int, r=oli-obk

CTFE engine: Scalar: expose size-generic to_(u)int methods

This matches the size-generic constructors `Scalar::from_(u)int`, and it would have helped in https://github.com/rust-lang/miri/pull/1978.

r? `@oli-obk`

2 years agoRollup merge of #94190 - bjorn3:less_filetime, r=Mark-Simulacrum
Matthias Krüger [Mon, 21 Feb 2022 18:36:51 +0000 (19:36 +0100)]
Rollup merge of #94190 - bjorn3:less_filetime, r=Mark-Simulacrum

Use Metadata::modified instead of FileTime::from_last_modification_ti…

…me in run_cargo

Metadata::modified works in all platforms supported by the filetime
crate. This changes brings rustbuild a tiny bit closer towards dropping
the filetime dependency.

2 years agoRollup merge of #94189 - GuillaumeGomez:scalar-lower-hex, r=RalfJung
Matthias Krüger [Mon, 21 Feb 2022 18:36:50 +0000 (19:36 +0100)]
Rollup merge of #94189 - GuillaumeGomez:scalar-lower-hex, r=RalfJung

Implement LowerHex on Scalar to clean up their display in rustdoc

Follow-up of https://github.com/rust-lang/rust/pull/94091.

r? ````@RalfJung````

2 years agoRollup merge of #94186 - ehuss:pin-stable-1.61, r=m-ou-se
Matthias Krüger [Mon, 21 Feb 2022 18:36:49 +0000 (19:36 +0100)]
Rollup merge of #94186 - ehuss:pin-stable-1.61, r=m-ou-se

Update pin_static_ref stabilization version.

#93580 slipped into 1.61

cc `@m-ou-se`

2 years agoRollup merge of #94156 - tmiasko:pp-str, r=petrochenkov
Matthias Krüger [Mon, 21 Feb 2022 18:36:48 +0000 (19:36 +0100)]
Rollup merge of #94156 - tmiasko:pp-str, r=petrochenkov

Gracefully handle non-UTF-8 string slices when pretty printing

Fixes #78520.

2 years agoRollup merge of #94143 - est31:let_else_const_eval, r=lcnr
Matthias Krüger [Mon, 21 Feb 2022 18:36:48 +0000 (19:36 +0100)]
Rollup merge of #94143 - est31:let_else_const_eval, r=lcnr

rustc_const_eval: adopt let else in more places

Continuation of #89933, #91018, #91481, #93046, #93590, #94011.

I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This PR handles rustc_const_eval.

2 years agoRollup merge of #91192 - r00ster91:futuredocs, r=GuillaumeGomez
Matthias Krüger [Mon, 21 Feb 2022 18:36:46 +0000 (19:36 +0100)]
Rollup merge of #91192 - r00ster91:futuredocs, r=GuillaumeGomez

Some improvements to the async docs

The goal here is to make the docs overall a little bit more comprehensive and add more links between the things.

One thing that's not working yet is the links to the keywords. Somehow I couldn't get them to work.

r? ````@GuillaumeGomez```` do you know how I could get the keyword links to work?

2 years agoAdd tests
Amanieu d'Antras [Sat, 19 Feb 2022 21:46:49 +0000 (21:46 +0000)]
Add tests

2 years agoTake CodegenFnAttrs into account when validating asm! register operands
Amanieu d'Antras [Thu, 17 Feb 2022 18:16:04 +0000 (18:16 +0000)]
Take CodegenFnAttrs into account when validating asm! register operands

Checking of asm! register operands now properly takes function
attributes such as #[target_feature] and #[instruction_set] into
account.

2 years agoOn ARM, use relocation_model to detect whether r9 should be reserved
Amanieu d'Antras [Thu, 17 Feb 2022 14:16:52 +0000 (14:16 +0000)]
On ARM, use relocation_model to detect whether r9 should be reserved

The previous approach of checking for the reserve-r9 target feature
didn't actually work because LLVM only sets this feature very late when
initializing the per-function subtarget.

2 years agoSimplify gating of BPF w registers behind the alu32 target feature
Amanieu d'Antras [Thu, 17 Feb 2022 12:46:47 +0000 (12:46 +0000)]
Simplify gating of BPF w registers behind the alu32 target feature

This is already handled by supported_types().

2 years agoCorrectly handle miniz_oxide extern crate declaration
Guillaume Gomez [Mon, 21 Feb 2022 16:27:55 +0000 (17:27 +0100)]
Correctly handle miniz_oxide extern crate declaration

2 years agoAuto merge of #93505 - lcnr:substsref-vs-ty-list, r=michaelwoerister
bors [Mon, 21 Feb 2022 16:03:38 +0000 (16:03 +0000)]
Auto merge of #93505 - lcnr:substsref-vs-ty-list, r=michaelwoerister

safely `transmute<&List<Ty<'tcx>>, &List<GenericArg<'tcx>>>`

This PR has 3 relevant steps which are is split in distinct commits.

The first commit now interns `List<Ty<'tcx>>` and `List<GenericArg<'tcx>>` together, potentially reusing memory while allowing free conversions between these two using `List<Ty<'tcx>>::as_substs()` and `SubstsRef<'tcx>::try_as_type_list()`.

Using this, we then use `&'tcx List<Ty<'tcx>>` instead of a `SubstsRef<'tcx>` for tuple fields, simplifying a bunch of code.

Finally, as tuple fields and other generic arguments now use a different `TypeFoldable<'tcx>` impl, we optimize the impl for `List<Ty<'tcx>>` improving perf by slightly less than 1% in tuple heavy benchmarks.

2 years agoAuto merge of #94205 - Mark-Simulacrum:revert-93800, r=oli-obk
bors [Mon, 21 Feb 2022 13:13:04 +0000 (13:13 +0000)]
Auto merge of #94205 - Mark-Simulacrum:revert-93800, r=oli-obk

Revert #93800, fixing CI time regression

This reverts commit a240ccd81c74c105b6f5fe84c46f8d36edb7e306 (merge commit of #93800), reversing
changes made to 393fdc10483da930cdbb00eabc3635030d2e776f.

This PR was likely responsible for a relatively large regression in
dist-x86_64-msvc-alt builder times, from approximately 1.7 to 2.8 hours,
bringing that builder into the pool of the slowest builders we currently have.

This seems to be limited to the alt builder due to needing parallel-compiler
enabled, likely leading to slow LLVM compilation for some reason. See some
investigation in [this Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/msvc.28.3F.29.20builders.20running.20much.20slower).

cc `@lcnr` `@oli-obk` `@b-naber` (per original PRs review/author)

We can re-apply this PR once the regression is fixed, but it is sufficiently large that I don't think keeping this on master is viable in the meantime unless there's a very strong case to be made for it. Alternatively, we can disable that builder (it's not critical since it's an alt build), but that obviously carries its own costs.

2 years agoobligation forest docs
lcnr [Mon, 21 Feb 2022 10:56:36 +0000 (11:56 +0100)]
obligation forest docs

2 years agodon't check for the leak_check twice
lcnr [Mon, 21 Feb 2022 09:40:41 +0000 (10:40 +0100)]
don't check for the leak_check twice

2 years agoAuto merge of #94108 - compiler-errors:just-confirmation-normalization, r=jackh726
bors [Mon, 21 Feb 2022 10:06:24 +0000 (10:06 +0000)]
Auto merge of #94108 - compiler-errors:just-confirmation-normalization, r=jackh726

Normalize obligation and expected trait_refs in confirm_poly_trait_refs

Consolidate normalization the obligation and expected trait refs in `confirm_poly_trait_refs`. Also, _always_ normalize these trait refs -- we were already normalizing the obligation trait ref when confirming closure and generator candidates, but this does it for fn pointer confirmation as well.

This presumably does more work in the case that the obligation's trait ref is already normalized, but we can see from the perf runs in #94070, it actually (paradoxically, perhaps) improves performance when paired with logic that normalizes projections in fulfillment loop.

2 years agorename function
lcnr [Mon, 21 Feb 2022 09:26:25 +0000 (10:26 +0100)]
rename function

2 years agoadd comment
lcnr [Mon, 21 Feb 2022 09:23:36 +0000 (10:23 +0100)]
add comment

2 years agoBetter error if the user tries to do assignment ... else
est31 [Mon, 21 Feb 2022 07:27:24 +0000 (08:27 +0100)]
Better error if the user tries to do assignment ... else

2 years agoFix typo
est31 [Mon, 21 Feb 2022 07:28:20 +0000 (08:28 +0100)]
Fix typo

Co-authored-by: lcnr <rust@lcnr.de>
2 years agoreview
lcnr [Fri, 18 Feb 2022 11:31:12 +0000 (12:31 +0100)]
review

2 years agoadd comment to `Lift` impls
lcnr [Fri, 11 Feb 2022 12:20:38 +0000 (13:20 +0100)]
add comment to `Lift` impls

2 years agooptimize `TypeFoldable` for 2 element tuples
lcnr [Mon, 7 Feb 2022 15:08:04 +0000 (16:08 +0100)]
optimize `TypeFoldable` for 2 element tuples

2 years agoupdate rustdoc
lcnr [Mon, 7 Feb 2022 15:07:12 +0000 (16:07 +0100)]
update rustdoc

2 years agoupdate clippy
lcnr [Mon, 7 Feb 2022 15:06:55 +0000 (16:06 +0100)]
update clippy

2 years agouse `List<Ty<'tcx>>` for tuples
lcnr [Mon, 7 Feb 2022 15:06:31 +0000 (16:06 +0100)]
use `List<Ty<'tcx>>` for tuples

2 years agosafely `transmute<&List<Ty<'tcx>>, &List<GenericArg<'tcx>>>`
lcnr [Mon, 7 Feb 2022 15:05:17 +0000 (16:05 +0100)]
safely `transmute<&List<Ty<'tcx>>, &List<GenericArg<'tcx>>>`

2 years agoAdd regression test for #92069
est31 [Mon, 21 Feb 2022 03:45:40 +0000 (04:45 +0100)]
Add regression test for #92069

2 years agoExpand let-else allow tests
est31 [Mon, 21 Feb 2022 03:38:39 +0000 (04:38 +0100)]
Expand let-else allow tests

The #[allow(...)] directive was tested for the body and the pattern,
but non-presence of it wasn't tested. Furthermore, it wasn't tested
for the expression. We add expression tests as well as ones checking
the non-presence of the directive.

2 years agoAuto merge of #94066 - Mark-Simulacrum:factor-out-simple-def-kind, r=davidtwco
bors [Mon, 21 Feb 2022 03:36:55 +0000 (03:36 +0000)]
Auto merge of #94066 - Mark-Simulacrum:factor-out-simple-def-kind, r=davidtwco

Remove SimpleDefKind

Now that rustc_query_system depends on rustc_hir, we can just directly make use of the regular DefKind.

2 years agoRevert "Auto merge of #93800 - b-naber:static-initializers-mir-val, r=oli-obk"
Mark Rousskov [Mon, 21 Feb 2022 02:56:20 +0000 (21:56 -0500)]
Revert "Auto merge of #93800 - b-naber:static-initializers-mir-val, r=oli-obk"

This reverts commit a240ccd81c74c105b6f5fe84c46f8d36edb7e306, reversing
changes made to 393fdc10483da930cdbb00eabc3635030d2e776f.

This PR was likely responsible for a relatively large regression in
dist-x86_64-msvc-alt builder times, from approximately 1.7 to 2.8 hours,
bringing that builder into the pool of the slowest builders we currently have.

This seems to be limited to the alt builder due to needing parallel-compiler
enabled, likely leading to slow LLVM compilation for some reason.

2 years agoCTFE engine: Scalar: expose size-generic to_(u)int methods
Ralf Jung [Mon, 21 Feb 2022 02:31:02 +0000 (21:31 -0500)]
CTFE engine: Scalar: expose size-generic to_(u)int methods

2 years agoDelete Decoder::read_map
Mark Rousskov [Wed, 9 Feb 2022 23:19:18 +0000 (18:19 -0500)]
Delete Decoder::read_map

2 years agoDelete Decoder::read_seq
Mark Rousskov [Wed, 9 Feb 2022 23:17:14 +0000 (18:17 -0500)]
Delete Decoder::read_seq

2 years agoDelete Decoder::read_enum_variant
Mark Rousskov [Wed, 9 Feb 2022 22:48:06 +0000 (17:48 -0500)]
Delete Decoder::read_enum_variant

2 years agoDelete Decoder::read_map_elt_val
Mark Rousskov [Wed, 9 Feb 2022 22:44:54 +0000 (17:44 -0500)]
Delete Decoder::read_map_elt_val

2 years agoDelete Decoder::read_map_elt_key
Mark Rousskov [Wed, 9 Feb 2022 22:44:09 +0000 (17:44 -0500)]
Delete Decoder::read_map_elt_key

2 years agoDelete Decoder::read_option
Mark Rousskov [Wed, 9 Feb 2022 22:42:38 +0000 (17:42 -0500)]
Delete Decoder::read_option

2 years agoDelete Decoder::read_seq_elt
Mark Rousskov [Wed, 9 Feb 2022 22:39:50 +0000 (17:39 -0500)]
Delete Decoder::read_seq_elt

2 years agoDelete Decoder::read_tuple_arg
Mark Rousskov [Wed, 9 Feb 2022 22:37:17 +0000 (17:37 -0500)]
Delete Decoder::read_tuple_arg

2 years agoDelete Decoder::read_tuple
Mark Rousskov [Wed, 9 Feb 2022 22:35:11 +0000 (17:35 -0500)]
Delete Decoder::read_tuple

2 years agoUse count! macro in tuple length computation
Mark Rousskov [Wed, 9 Feb 2022 22:32:01 +0000 (17:32 -0500)]
Use count! macro in tuple length computation

2 years agoDelete Decoder::read_struct_field
Mark Rousskov [Wed, 9 Feb 2022 22:26:17 +0000 (17:26 -0500)]
Delete Decoder::read_struct_field

2 years agoDelete Decoder::read_struct
Mark Rousskov [Wed, 9 Feb 2022 22:20:43 +0000 (17:20 -0500)]
Delete Decoder::read_struct

2 years agoDelete read_enum_variant_arg
Mark Rousskov [Wed, 9 Feb 2022 22:17:04 +0000 (17:17 -0500)]
Delete read_enum_variant_arg

2 years agoDelete read_enum_variant names
Mark Rousskov [Wed, 9 Feb 2022 22:12:20 +0000 (17:12 -0500)]
Delete read_enum_variant names

2 years agoDelete Decoder::read_enum
Mark Rousskov [Wed, 9 Feb 2022 22:10:45 +0000 (17:10 -0500)]
Delete Decoder::read_enum

2 years agoRemove support for JSON deserialization to Rust
Mark Rousskov [Wed, 9 Feb 2022 22:05:44 +0000 (17:05 -0500)]
Remove support for JSON deserialization to Rust

This is no longer used by the compiler itself, and removing this support opens
the door to massively simplifying the Decodable/Decoder API by dropping the
self-describing deserialization support (necessary for JSON).

2 years agocompiletest: Print process output info with less whitespace
Nixon Enraght-Moony [Sun, 20 Feb 2022 22:44:04 +0000 (22:44 +0000)]
compiletest: Print process output info with less whitespace

Before:

```
error: jsondocck failed!
status: exit status: 1
command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--template" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
Invalid command: Tried to use the previous path in the first command on line 10
Error: "Jsondocck failed for /data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs"

------------------------------------------

Rustdoc Output:
status: exit status: 0
command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait/auxiliary" "-o" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--deny" "warnings" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs" "--output-format" "json" "-Zunstable-options"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------

------------------------------------------

```

After:

```

error: jsondocck failed!
status: exit status: 1
command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--template" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs"
stdout: none
--- stderr -------------------------------
Invalid command: Tried to use the previous path in the first command on line 10
Error: "Jsondocck failed for /data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs"
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait/auxiliary" "-o" "/data/ne321/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/traits/supertrait" "--deny" "warnings" "/data/ne321/rust/src/test/rustdoc-json/traits/supertrait.rs" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none

```

2 years agoAuto merge of #93678 - steffahn:better_unsafe_diagnostics, r=nagisa
bors [Sun, 20 Feb 2022 21:15:11 +0000 (21:15 +0000)]
Auto merge of #93678 - steffahn:better_unsafe_diagnostics, r=nagisa

Improve `unused_unsafe` lint

I’m going to add some motivation and explanation below, particularly pointing the changes in behavior from this PR.

_Edit:_ Looking for existing issues, looks like this PR fixes #88260.

_Edit2:_ Now also contains code that closes #90776.

2 years agoImprove `unused_unsafe` lint
Frank Steffahn [Thu, 3 Feb 2022 21:16:06 +0000 (22:16 +0100)]
Improve `unused_unsafe` lint

Main motivation: Fixes some issues with the current behavior. This PR is
more-or-less completely re-implementing the unused_unsafe lint; it’s also only
done in the MIR-version of the lint, the set of tests for the `-Zthir-unsafeck`
version no longer succeeds (and is thus disabled, see `lint-unused-unsafe.rs`).

On current nightly,
```rs
unsafe fn unsf() {}

fn inner_ignored() {
    unsafe {
        #[allow(unused_unsafe)]
        unsafe {
            unsf()
        }
    }
}
```

doesn’t create any warnings. This situation is not unrealistic to come by, the
inner `unsafe` block could e.g. come from a macro. Actually, this PR even
includes removal of one unused `unsafe` in the standard library that was missed
in a similar situation. (The inner `unsafe` coming from an external macro hides
    the warning, too.)

The reason behind this problem is how the check currently works:
* While generating MIR, it already skips nested unsafe blocks (i.e. unsafe
  nested in other unsafe) so that the inner one is always the one considered
  unused
* To differentiate the cases of no unsafe operations inside the `unsafe` vs.
  a surrounding `unsafe` block, there’s some ad-hoc magic walking up the HIR to
  look for surrounding used `unsafe` blocks.

There’s a lot of problems with this approach besides the one presented above.
E.g. the MIR-building uses checks for `unsafe_op_in_unsafe_fn` lint to decide
early whether or not `unsafe` blocks in an `unsafe fn` are redundant and ought
to be removed.
```rs
unsafe fn granular_disallow_op_in_unsafe_fn() {
    unsafe {
        #[deny(unsafe_op_in_unsafe_fn)]
        {
            unsf();
        }
    }
}
```
```
error: call to unsafe function is unsafe and requires unsafe block (error E0133)
  --> src/main.rs:13:13
   |
13 |             unsf();
   |             ^^^^^^ call to unsafe function
   |
note: the lint level is defined here
  --> src/main.rs:11:16
   |
11 |         #[deny(unsafe_op_in_unsafe_fn)]
   |                ^^^^^^^^^^^^^^^^^^^^^^
   = note: consult the function's documentation for information on how to avoid undefined behavior

warning: unnecessary `unsafe` block
  --> src/main.rs:10:5
   |
9  | unsafe fn granular_disallow_op_in_unsafe_fn() {
   | --------------------------------------------- because it's nested under this `unsafe` fn
10 |     unsafe {
   |     ^^^^^^ unnecessary `unsafe` block
   |
   = note: `#[warn(unused_unsafe)]` on by default

```
Here, the intermediate `unsafe` was ignored, even though it contains a unsafe
operation that is not allowed to happen in an `unsafe fn` without an additional `unsafe` block.

Also closures were problematic and the workaround/algorithms used on current
nightly didn’t work properly. (I skipped trying to fully understand what it was
supposed to do, because this PR uses a completely different approach.)
```rs
fn nested() {
    unsafe {
        unsafe { unsf() }
    }
}
```
```
warning: unnecessary `unsafe` block
  --> src/main.rs:10:9
   |
9  |     unsafe {
   |     ------ because it's nested under this `unsafe` block
10 |         unsafe { unsf() }
   |         ^^^^^^ unnecessary `unsafe` block
   |
   = note: `#[warn(unused_unsafe)]` on by default
```

vs

```rs
fn nested() {
    let _ = || unsafe {
        let _ = || unsafe { unsf() };
    };
}
```
```
warning: unnecessary `unsafe` block
 --> src/main.rs:9:16
  |
9 |     let _ = || unsafe {
  |                ^^^^^^ unnecessary `unsafe` block
  |
  = note: `#[warn(unused_unsafe)]` on by default

warning: unnecessary `unsafe` block
  --> src/main.rs:10:20
   |
10 |         let _ = || unsafe { unsf() };
   |                    ^^^^^^ unnecessary `unsafe` block
```

*note that this warning kind-of suggests that **both** unsafe blocks are redundant*

--------------------------------------------------------------------------------

I also dislike the fact that it always suggests keeping the outermost `unsafe`.
E.g. for
```rs
fn granularity() {
    unsafe {
        unsafe { unsf() }
        unsafe { unsf() }
        unsafe { unsf() }
    }
}
```
I prefer if `rustc` suggests removing the more-course outer-level `unsafe`
instead of the fine-grained inner `unsafe` blocks, which it currently does on nightly:
```
warning: unnecessary `unsafe` block
  --> src/main.rs:10:9
   |
9  |     unsafe {
   |     ------ because it's nested under this `unsafe` block
10 |         unsafe { unsf() }
   |         ^^^^^^ unnecessary `unsafe` block
   |
   = note: `#[warn(unused_unsafe)]` on by default

warning: unnecessary `unsafe` block
  --> src/main.rs:11:9
   |
9  |     unsafe {
   |     ------ because it's nested under this `unsafe` block
10 |         unsafe { unsf() }
11 |         unsafe { unsf() }
   |         ^^^^^^ unnecessary `unsafe` block

warning: unnecessary `unsafe` block
  --> src/main.rs:12:9
   |
9  |     unsafe {
   |     ------ because it's nested under this `unsafe` block
...
12 |         unsafe { unsf() }
   |         ^^^^^^ unnecessary `unsafe` block
```

--------------------------------------------------------------------------------

Needless to say, this PR addresses all these points. For context, as far as my
understanding goes, the main advantage of skipping inner unsafe blocks was that
a test case like
```rs
fn top_level_used() {
    unsafe {
        unsf();
        unsafe { unsf() }
        unsafe { unsf() }
        unsafe { unsf() }
    }
}
```
should generate some warning because there’s redundant nested `unsafe`, however
every single `unsafe` block _does_ contain some statement that uses it. Of course
this PR doesn’t aim change the warnings on this kind of code example, because
the current behavior, warning on all the inner `unsafe` blocks, makes sense in this case.

As mentioned, during MIR building all the unsafe blocks *are* kept now, and usage
is attributed to them. The way to still generate a warning like
```
warning: unnecessary `unsafe` block
  --> src/main.rs:11:9
   |
9  |     unsafe {
   |     ------ because it's nested under this `unsafe` block
10 |         unsf();
11 |         unsafe { unsf() }
   |         ^^^^^^ unnecessary `unsafe` block
   |
   = note: `#[warn(unused_unsafe)]` on by default

warning: unnecessary `unsafe` block
  --> src/main.rs:12:9
   |
9  |     unsafe {
   |     ------ because it's nested under this `unsafe` block
...
12 |         unsafe { unsf() }
   |         ^^^^^^ unnecessary `unsafe` block

warning: unnecessary `unsafe` block
  --> src/main.rs:13:9
   |
9  |     unsafe {
   |     ------ because it's nested under this `unsafe` block
...
13 |         unsafe { unsf() }
   |         ^^^^^^ unnecessary `unsafe` block
```

in this case is by emitting a `unused_unsafe` warning for all of the `unsafe`
blocks that are _within a **used** unsafe block_.

The previous code had a little HIR traversal already anyways to collect a set of
all the unsafe blocks (in order to afterwards determine which ones are unused
afterwards). This PR uses such a traversal to do additional things including logic
like _always_ warn for an `unsafe` block that’s inside of another **used**
unsafe block. The traversal is expanded to include nested closures in the same go,
this simplifies a lot of things.

The whole logic around `unsafe_op_in_unsafe_fn` is a little complicated, there’s
some test cases of corner-cases in this PR. (The implementation involves
differentiating between whether a used unsafe block was used exclusively by
operations where `allow(unsafe_op_in_unsafe_fn)` was active.) The main goal was
to make sure that code should compile successfully if all the `unused_unsafe`-warnings
are addressed _simultaneously_ (by removing the respective `unsafe` blocks)
no matter how complicated the patterns of `unsafe_op_in_unsafe_fn` being
disallowed and allowed throughout the function are.

--------------------------------------------------------------------------------

One noteworthy design decision I took here: An `unsafe` block
with `allow(unused_unsafe)` **is considered used** for the purposes of
linting about redundant contained unsafe blocks. So while
```rs

fn granularity() {
    unsafe { //~ ERROR: unnecessary `unsafe` block
        unsafe { unsf() }
        unsafe { unsf() }
        unsafe { unsf() }
    }
}
```
warns for the outer `unsafe` block,
```rs

fn top_level_ignored() {
    #[allow(unused_unsafe)]
    unsafe {
        #[deny(unused_unsafe)]
        {
            unsafe { unsf() } //~ ERROR: unnecessary `unsafe` block
            unsafe { unsf() } //~ ERROR: unnecessary `unsafe` block
            unsafe { unsf() } //~ ERROR: unnecessary `unsafe` block
        }
    }
}
```
warns on the inner ones.

2 years agoAuto merge of #94062 - Mark-Simulacrum:drop-print-cfg, r=oli-obk
bors [Sun, 20 Feb 2022 18:12:59 +0000 (18:12 +0000)]
Auto merge of #94062 - Mark-Simulacrum:drop-print-cfg, r=oli-obk

Move ty::print methods to Drop-based scope guards

Primary goal is reducing codegen of the TLS access for each closure, which shaves ~3 seconds of bootstrap time over rustc as a whole.

2 years agoUse Metadata::modified instead of FileTime::from_last_modification_time in run_cargo
bjorn3 [Sun, 20 Feb 2022 15:59:20 +0000 (16:59 +0100)]
Use Metadata::modified instead of FileTime::from_last_modification_time in run_cargo

Metadata::modified works in all platforms supported by the filetime
crate. This changes brings rustbuild a tiny bit closer towards dropping
the filetime dependency.

2 years agoImplement LowerHex on Scalar to clean up their display in rustdoc
Guillaume Gomez [Sun, 20 Feb 2022 15:43:21 +0000 (16:43 +0100)]
Implement LowerHex on Scalar to clean up their display in rustdoc

2 years agoAuto merge of #93934 - rusticstuff:inline_ensure_sufficient_stack, r=estebank
bors [Sun, 20 Feb 2022 15:10:19 +0000 (15:10 +0000)]
Auto merge of #93934 - rusticstuff:inline_ensure_sufficient_stack, r=estebank

Allow inlining of `ensure_sufficient_stack()`

This functions is monomorphized a lot and allowing the compiler to inline it improves instructions count and max RSS significantly in my local tests.

2 years agoUpdate pin_static_ref stabilization version.
Eric Huss [Sun, 20 Feb 2022 14:42:20 +0000 (06:42 -0800)]
Update pin_static_ref stabilization version.

2 years agoAuto merge of #93816 - bjorn3:rlib_metadata_first, r=nagisa
bors [Sun, 20 Feb 2022 11:32:40 +0000 (11:32 +0000)]
Auto merge of #93816 - bjorn3:rlib_metadata_first, r=nagisa

Put crate metadata first in the rlib

This should make metadata lookup faster

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

2 years agosolarish current_exe using libc call directly
David Carlier [Sun, 20 Feb 2022 08:53:18 +0000 (08:53 +0000)]
solarish current_exe using libc call directly

2 years agoAuto merge of #93605 - notriddle:notriddle/rustdoc-html-tags-resolve, r=GuillaumeGomez
bors [Sun, 20 Feb 2022 08:38:28 +0000 (08:38 +0000)]
Auto merge of #93605 - notriddle:notriddle/rustdoc-html-tags-resolve, r=GuillaumeGomez

rustdoc: resolve intra-doc links when checking HTML

Similar to #86451

CC #67799

Given this test case:

```rust
#![warn(rustdoc::invalid_html_tags)]
#![warn(rustdoc::broken_intra_doc_links)]

pub struct ExistentStruct<T>(T);

/// This [test][ExistentStruct<i32>] thing!
pub struct NoError;
```

This pull request silences the following, spurious warning:

```text
warning: unclosed HTML tag `i32`
 --> test.rs:6:31
  |
6 | /// This [test][ExistentStruct<i32>] thing!
  |                               ^^^^^
  |
note: the lint level is defined here
 --> test.rs:1:9
  |
1 | #![warn(rustdoc::invalid_html_tags)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try marking as source code
  |
6 | /// This [test][`ExistentStruct<i32>`] thing!
  |                 +                   +

warning: 1 warning emitted
```

2 years agoGracefully handle non-UTF-8 string slices when pretty printing
Tomasz Miąsko [Sat, 19 Feb 2022 00:00:00 +0000 (00:00 +0000)]
Gracefully handle non-UTF-8 string slices when pretty printing

2 years agoAuto merge of #93387 - JakobDegen:improve_partialeq, r=tmiasko
bors [Sun, 20 Feb 2022 05:24:52 +0000 (05:24 +0000)]
Auto merge of #93387 - JakobDegen:improve_partialeq, r=tmiasko

Extend uninhabited enum variant branch elimination to also affect fallthrough

The `uninhabited_enum_branching` mir opt eliminates branches on variants where the data is uninhabited. This change extends this pass to also ensure that the `otherwise` case points to a trivially unreachable bb if all inhabited variants are present in the non-otherwise branches.

I believe it was `@scottmcm` who said that LLVM eliminates some of this information in its SimplifyCFG pass. This is unfortunate, but this change should still be at least a small improvement in principle (I don't think it will show up on any benchmarks)

2 years agotidy: fire less "ignoring file length unneccessarily" warnings
est31 [Sun, 20 Feb 2022 02:17:44 +0000 (03:17 +0100)]
tidy: fire less "ignoring file length unneccessarily" warnings

This avoids a situation where a file is at the border of the limit,
and alternates between hitting the limit and not hitting it, causing
a back and forth of addition of the ignore-tidy-linelength directive.

As an example, consider the ignore-tidy-filelength of compiler/rustc_typeck/src/collect.rs.

It was added in 2ca4964db5d263a8f9222846bd70a7f26cf414cf, removed in
37354ebc9794b0eb14b08c02177e3094c8fe91cd, added again in 448d07683a6defd567996114793a09c9a8aef5df,
removed in 3171bd5bf54fb91f7f7df7c40df5adc7d8bd5dea, added in 438826fd1a9a119d00992ede948cdd479431ecbb,
and #94142 is going to remove it again.

To avoid this back and forth, we exempt files from the unneccessary
ignoring warning that have length of at least 70% of the limit.

2 years agoAuto merge of #94174 - matthiaskrgr:rollup-snyrlhy, r=matthiaskrgr
bors [Sun, 20 Feb 2022 02:19:41 +0000 (02:19 +0000)]
Auto merge of #94174 - matthiaskrgr:rollup-snyrlhy, r=matthiaskrgr

Rollup of 14 pull requests

Successful merges:

 - #93580 (Stabilize pin_static_ref.)
 - #93639 (Release notes for 1.59)
 - #93686 (core: Implement ASCII trim functions on byte slices)
 - #94002 (rustdoc: Avoid duplicating macros in sidebar)
 - #94019 (removing architecture requirements for RustyHermit)
 - #94023 (adapt static-nobundle test to use llvm-nm)
 - #94091 (Fix rustdoc const computed value)
 - #94093 (Fix pretty printing of enums without variants)
 - #94097 (Add module-level docs for `rustc_middle::query`)
 - #94112 (Optimize char_try_from_u32)
 - #94113 (document rustc_middle::mir::Field)
 - #94122 (Fix miniz_oxide types showing up in std docs)
 - #94142 (rustc_typeck: adopt let else in more places)
 - #94146 (Adopt let else in more places)

Failed merges:

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

2 years agoRollup merge of #94146 - est31:let_else, r=cjgillot
Matthias Krüger [Sat, 19 Feb 2022 23:37:34 +0000 (00:37 +0100)]
Rollup merge of #94146 - est31:let_else, r=cjgillot

Adopt let else in more places

Continuation of #89933, #91018, #91481, #93046, #93590, #94011.

I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This is the biggest of these PRs and handles the changes outside of rustdoc, rustc_typeck, rustc_const_eval, rustc_trait_selection, which were handled in PRs #94139, #94142, #94143, #94144.

2 years agoRollup merge of #94142 - est31:let_else_typeck, r=oli-obk
Matthias Krüger [Sat, 19 Feb 2022 23:37:33 +0000 (00:37 +0100)]
Rollup merge of #94142 - est31:let_else_typeck, r=oli-obk

rustc_typeck: adopt let else in more places

Continuation of https://github.com/rust-lang/rust/pull/89933, https://github.com/rust-lang/rust/pull/91018, https://github.com/rust-lang/rust/pull/91481, https://github.com/rust-lang/rust/pull/93046, https://github.com/rust-lang/rust/pull/93590, https://github.com/rust-lang/rust/pull/94011.

I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This PR handles rustc_typeck.

2 years agoRollup merge of #94122 - GuillaumeGomez:miniz-oxide-std, r=notriddle
Matthias Krüger [Sat, 19 Feb 2022 23:37:32 +0000 (00:37 +0100)]
Rollup merge of #94122 - GuillaumeGomez:miniz-oxide-std, r=notriddle

Fix miniz_oxide types showing up in std docs

Fixes #90526.

Thanks to ```````@camelid,``````` I rediscovered `doc(masked)`, allowing us to prevent `miniz_oxide` type to show up in std docs.

r? ```````@notriddle```````

2 years agoRollup merge of #94113 - Mizobrook-kan:issue-94025, r=estebank
Matthias Krüger [Sat, 19 Feb 2022 23:37:31 +0000 (00:37 +0100)]
Rollup merge of #94113 - Mizobrook-kan:issue-94025, r=estebank

document rustc_middle::mir::Field

cc #94025

2 years agoRollup merge of #94112 - digama0:patch-3, r=scottmcm
Matthias Krüger [Sat, 19 Feb 2022 23:37:30 +0000 (00:37 +0100)]
Rollup merge of #94112 - digama0:patch-3, r=scottmcm

Optimize char_try_from_u32

The optimization was proposed by ```````@falk-hueffner``````` in https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Micro-optimizing.20char.3A.3Afrom_u32/near/272146171,  and I simplified it a bit and added an explanation of why the optimization is correct. The generated code is 2 instructions shorter and uses 2 registers instead of 4 on x86.

2 years agoRollup merge of #94097 - pierwill:doc-rustc-middle-query, r=cjgillot
Matthias Krüger [Sat, 19 Feb 2022 23:37:29 +0000 (00:37 +0100)]
Rollup merge of #94097 - pierwill:doc-rustc-middle-query, r=cjgillot

Add module-level docs for `rustc_middle::query`

2 years agoRollup merge of #94093 - tmiasko:pp-no-variants, r=oli-obk
Matthias Krüger [Sat, 19 Feb 2022 23:37:28 +0000 (00:37 +0100)]
Rollup merge of #94093 - tmiasko:pp-no-variants, r=oli-obk

Fix pretty printing of enums without variants

92d20c4aaddea9507f8ad37fe37c551219153bbf removed no-variants special case from `try_destructure_const` with expectation that this case would be handled gracefully when `read_discriminant` returns an error.

Alas in that case `read_discriminant` succeeds while returning a non-existing variant, so the special case is still necessary.

Fixes #94073.

r? ````@oli-obk````

2 years agoRollup merge of #94091 - GuillaumeGomez:rustdoc-const-computed-value, r=oli-obk
Matthias Krüger [Sat, 19 Feb 2022 23:37:27 +0000 (00:37 +0100)]
Rollup merge of #94091 - GuillaumeGomez:rustdoc-const-computed-value, r=oli-obk

Fix rustdoc const computed value

Fixes #85088.

It looks like this now (instead of hexadecimal):

![Screenshot from 2022-02-17 17-55-39](https://user-images.githubusercontent.com/3050060/154532115-0f9861a0-406f-4c9c-957f-32bedd8aca7d.png)

r? ````@oli-obk````

2 years agoRollup merge of #94023 - krasimirgg:head-llvm-use-llvm-nm, r=Mark-Simulacrum
Matthias Krüger [Sat, 19 Feb 2022 23:37:26 +0000 (00:37 +0100)]
Rollup merge of #94023 - krasimirgg:head-llvm-use-llvm-nm, r=Mark-Simulacrum

adapt static-nobundle test to use llvm-nm

No functional changes intended.

This updates the test case to use llvm-nm instead of the system nm.
This fixes an instance over at the experimental build of rustc with HEAD LLVM:
https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/8380#ef6f41b5-8595-49a6-be37-0eff80e0ccb5
It is related to https://github.com/rust-lang/rust/pull/94001.

The issue is that this test uses the system nm, which may not be recent
enough to understand the update to uwtable. This replaces the test to
use the llvm-nm that should be recent enough (consistent with the LLVM
sources we use to build rustc).

2 years agoRollup merge of #94019 - hermitcore:target, r=Mark-Simulacrum
Matthias Krüger [Sat, 19 Feb 2022 23:37:25 +0000 (00:37 +0100)]
Rollup merge of #94019 - hermitcore:target, r=Mark-Simulacrum

removing architecture requirements for RustyHermit

RustHermit and HermitCore is able to run on aarch64 and x86_64. In the future these operating systems will also support RISC-V. Consequently, the dependency to a specific target should be removed.

The build process of `hermit-abi` fails if the architecture isn't supported.

2 years agoRollup merge of #94002 - GuillaumeGomez:duplicated-sidebar-macro, r=notriddle
Matthias Krüger [Sat, 19 Feb 2022 23:37:24 +0000 (00:37 +0100)]
Rollup merge of #94002 - GuillaumeGomez:duplicated-sidebar-macro, r=notriddle

rustdoc: Avoid duplicating macros in sidebar

Fixes #93912.

cc ``````@jsha`````` (for the GUI test)
r? ``````@camelid``````

2 years agoRollup merge of #93686 - dbrgn:trim-on-byte-slices, r=joshtriplett
Matthias Krüger [Sat, 19 Feb 2022 23:37:23 +0000 (00:37 +0100)]
Rollup merge of #93686 - dbrgn:trim-on-byte-slices, r=joshtriplett

core: Implement ASCII trim functions on byte slices

Hi ````````@rust-lang/libs!```````` This is a feature that I wished for when implementing serial protocols with microcontrollers. Often these protocols may contain leading or trailing whitespace, which needs to be removed. Because oftentimes drivers will operate on the byte level, decoding to unicode and checking for unicode whitespace is unnecessary overhead.

This PR adds three new methods to byte slices:

- `trim_ascii_start`
- `trim_ascii_end`
- `trim_ascii`

I did not find any pre-existing discussions about this, which surprises me a bit. Maybe I'm missing something, and this functionality is already possible through other means? There's https://github.com/rust-lang/rfcs/issues/2547 ("Trim methods on slices"), but that has a different purpose.

As per the [std dev guide](https://std-dev-guide.rust-lang.org/feature-lifecycle/new-unstable-features.html), this is a proposed implementation without any issue / RFC. If this is the wrong process, please let me know. However, I thought discussing code is easier than discussing a mere idea, and hacking on the stdlib was fun.

Tracking issue: https://github.com/rust-lang/rust/issues/94035

2 years agoRollup merge of #93639 - Mark-Simulacrum:relnotes, r=Mark-Simulacrum
Matthias Krüger [Sat, 19 Feb 2022 23:37:22 +0000 (00:37 +0100)]
Rollup merge of #93639 - Mark-Simulacrum:relnotes, r=Mark-Simulacrum

Release notes for 1.59

cc `@rust-lang/release`
r? `@cuviper`

2 years agoRollup merge of #93580 - m-ou-se:stabilize-pin-static-ref, r=scottmcm
Matthias Krüger [Sat, 19 Feb 2022 23:37:21 +0000 (00:37 +0100)]
Rollup merge of #93580 - m-ou-se:stabilize-pin-static-ref, r=scottmcm

Stabilize pin_static_ref.

FCP finished here: https://github.com/rust-lang/rust/issues/78186#issuecomment-1024987221

Closes #78186

2 years agoAuto merge of #92911 - nbdd0121:unwind, r=Amanieu
bors [Sat, 19 Feb 2022 23:25:06 +0000 (23:25 +0000)]
Auto merge of #92911 - nbdd0121:unwind, r=Amanieu

Guard against unwinding in cleanup code

Currently the only safe guard we have against double unwind is the panic count (which is local to Rust). When double unwinds indeed happen (e.g. C++ exception + Rust panic, or two C++ exceptions), then the second unwind actually goes through and the first unwind is leaked. This can cause UB. cc rust-lang/project-ffi-unwind#6

E.g. given the following C++ code:
```c++
extern "C" void foo() {
    throw "A";
}

extern "C" void execute(void (*fn)()) {
    try {
        fn();
    } catch(...) {
    }
}
```

This program is well-defined to terminate:
```c++
struct dtor {
    ~dtor() noexcept(false) {
        foo();
    }
};

void a() {
    dtor a;
    dtor b;
}

int main() {
    execute(a);
    return 0;
}
```

But this Rust code doesn't catch the double unwind:
```rust
extern "C-unwind" {
    fn foo();
    fn execute(f: unsafe extern "C-unwind" fn());
}

struct Dtor;

impl Drop for Dtor {
    fn drop(&mut self) {
        unsafe { foo(); }
    }
}

extern "C-unwind" fn a() {
    let _a = Dtor;
    let _b = Dtor;
}

fn main() {
    unsafe { execute(a) };
}
```

To address this issue, this PR adds an unwind edge to an abort block, so that the Rust example aborts. This is similar to how clang guards against double unwind (except clang calls terminate per C++ spec and we abort).

The cost should be very small; it's an additional trap instruction (well, two for now, since we use TrapUnreachable, but that's a different issue) for each function with landing pads; if LLVM gains support to encode "abort/terminate" info directly in LSDA like GCC does, then it'll be free. It's an additional basic block though so compile time may be worse, so I'd like a perf run.

r? `@ghost`
`@rustbot` label: F-c_unwind

2 years agoAuto merge of #94165 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum
bors [Sat, 19 Feb 2022 19:49:23 +0000 (19:49 +0000)]
Auto merge of #94165 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum

Bump version to 1.61

r? `@Mark-Simulacrum`

2 years agoBless up
Michael Goulet [Fri, 18 Feb 2022 01:21:48 +0000 (17:21 -0800)]
Bless up