Commit Graph

163255 Commits

Author SHA1 Message Date
Eduard-Mihai Burtescu
d4fc5ae25c rustc_errors: handle force_warn only through DiagnosticId::Lint. 2022-02-23 05:38:24 +00:00
Eduard-Mihai Burtescu
02ff9e0aef Replace &mut DiagnosticBuilder, in signatures, with &mut Diagnostic. 2022-02-23 05:38:19 +00:00
Eduard-Mihai Burtescu
f24ff1815f rustc_errors: add downgrade_to_delayed_bug to Diagnostic itself. 2022-02-23 03:46:51 +00:00
bors
5bd1ec3283 Auto merge of #83706 - a1phyr:fix_vec_layout_calculation, r=JohnTitor
Fix a layout possible miscalculation in `alloc::RawVec`

A layout miscalculation could happen in `RawVec` when used with a type whose size isn't a multiple of its alignment. I don't know if such type can exist in Rust, but the Layout API provides ways to manipulate such types. Anyway, it is better to calculate memory size in a consistent way.
2022-02-22 20:50:38 +00:00
bors
68369a041c 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
2022-02-22 14:41:26 +00:00
Matthias Krüger
e3814629c4
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``
2022-02-22 12:16:34 +01:00
Matthias Krüger
396910a664
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
2022-02-22 12:16:33 +01:00
Matthias Krüger
b322382893
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.
2022-02-22 12:16:32 +01:00
Matthias Krüger
1177b30ac9
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

```
2022-02-22 12:16:31 +01:00
Matthias Krüger
21fb81405e
Rollup merge of #94179 - devnexen:getexecname_directcall, r=kennytm
solarish current_exe using libc call directly
2022-02-22 12:16:30 +01:00
Matthias Krüger
a53b604fea
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 2ca4964db5, removed in
37354ebc97 (a revert of the earlier commit), added again in 448d07683a,
removed in 3171bd5bf5, added in 438826fd1a,
and removed in bb0a2f985c.

To avoid this back and forth, we exempt files from the unneccessary
ignoring warning that have length of at least 70% of the limit.
2022-02-22 12:16:29 +01:00
Matthias Krüger
1cf2e6993e
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``
2022-02-22 12:16:28 +01:00
bors
9ecd75b831 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`
2022-02-22 11:10:26 +00:00
lcnr
ee0b56483f change mir::Constant in mir dumps 2022-02-22 09:38:07 +01:00
bors
58a721af9f 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](e7aca89598/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.
2022-02-22 07:54:22 +00:00
Ralf Jung
fb1ee8764f ScalarMaybeUninit is explicitly hexadecimal in its formatting 2022-02-21 21:46:51 -05:00
Michael Goulet
0626919f21 Do not suggest wrapping an item if it has ambiguous un-imported methods 2022-02-21 16:45:35 -08:00
bors
b8967b0d52 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
2022-02-21 22:53:45 +00:00
Amanieu d'Antras
a60b79137c Add ignore-tidy-filelength 2022-02-21 19:18:00 +00:00
Matthias Krüger
ed3530925e
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`
2022-02-21 19:36:55 +01:00
Matthias Krüger
9157775152
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
2022-02-21 19:36:54 +01:00
Matthias Krüger
d3649f8d52
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
2022-02-21 19:36:53 +01:00
Matthias Krüger
f3a1a8cd4f
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`
2022-02-21 19:36:52 +01:00
Matthias Krüger
3095743600
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.
2022-02-21 19:36:51 +01:00
Matthias Krüger
f639ba634b
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````
2022-02-21 19:36:50 +01:00
Matthias Krüger
74cb6b77a0
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`
2022-02-21 19:36:49 +01:00
Matthias Krüger
da25e1e59c
Rollup merge of #94156 - tmiasko:pp-str, r=petrochenkov
Gracefully handle non-UTF-8 string slices when pretty printing

Fixes #78520.
2022-02-21 19:36:48 +01:00
Matthias Krüger
ea7f7f7c4c
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.
2022-02-21 19:36:48 +01:00
Matthias Krüger
12705b4700
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?
2022-02-21 19:36:46 +01:00
Amanieu d'Antras
fb5539b475 Add tests 2022-02-21 18:28:22 +00:00
Amanieu d'Antras
fc41d4bf35 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.
2022-02-21 18:28:22 +00:00
Amanieu d'Antras
1ceb104851 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.
2022-02-21 18:28:22 +00:00
Amanieu d'Antras
2e8a7663b4 Simplify gating of BPF w registers behind the alu32 target feature
This is already handled by supported_types().
2022-02-21 18:28:22 +00:00
Guillaume Gomez
910d46fd60 Correctly handle miniz_oxide extern crate declaration 2022-02-21 17:27:55 +01:00
bors
03a8cc7df1 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.
2022-02-21 16:03:38 +00:00
bors
1103d2e914 Auto merge of #94205 - Mark-Simulacrum:revert-93800, r=oli-obk
Revert #93800, fixing CI time regression

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

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.
2022-02-21 13:13:04 +00:00
lcnr
6a1f5eab83 obligation forest docs 2022-02-21 12:00:26 +01:00
lcnr
ec0a0ca3f4 don't check for the leak_check twice 2022-02-21 12:00:26 +01:00
bors
a924ef73bc 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.
2022-02-21 10:06:24 +00:00
lcnr
15e95c0b7f rename function 2022-02-21 11:02:52 +01:00
lcnr
239f33ea5b add comment 2022-02-21 11:02:52 +01:00
est31
76ea566677 Better error if the user tries to do assignment ... else 2022-02-21 08:59:39 +01:00
est31
413f3f787c
Fix typo
Co-authored-by: lcnr <rust@lcnr.de>
2022-02-21 08:28:20 +01:00
lcnr
80f56cdc2a review 2022-02-21 07:09:11 +01:00
lcnr
c909b6dc22 add comment to Lift impls 2022-02-21 07:09:11 +01:00
lcnr
758f4e7158 optimize TypeFoldable for 2 element tuples 2022-02-21 07:09:11 +01:00
lcnr
7d5d6c055b update rustdoc 2022-02-21 07:09:11 +01:00
lcnr
880343c61f update clippy 2022-02-21 07:09:11 +01:00
lcnr
1245131a11 use List<Ty<'tcx>> for tuples 2022-02-21 07:09:11 +01:00
lcnr
a9c1ab82f5 safely transmute<&List<Ty<'tcx>>, &List<GenericArg<'tcx>>> 2022-02-21 07:06:55 +01:00