]> git.lizzy.rs Git - rust.git/log
rust.git
23 months agoAuto merge of #98463 - mystor:expand_expr_bool, r=eddyb
bors [Sun, 10 Jul 2022 14:02:45 +0000 (14:02 +0000)]
Auto merge of #98463 - mystor:expand_expr_bool, r=eddyb

proc_macro: Fix expand_expr expansion of bool literals

Previously, the expand_expr method would expand bool literals as a
`Literal` token containing a `LitKind::Bool`, rather than as an `Ident`.
This is not a valid token, and the `LitKind::Bool` case needs to be
handled seperately.

Tests were added to more deeply compare the streams in the expand-expr
test suite to catch mistakes like this in the future.

23 months agoAuto merge of #99112 - matthiaskrgr:rollup-uv2zk4d, r=matthiaskrgr
bors [Sun, 10 Jul 2022 11:35:12 +0000 (11:35 +0000)]
Auto merge of #99112 - matthiaskrgr:rollup-uv2zk4d, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #99045 (improve print styles)
 - #99086 (Fix display of search result crate filter dropdown)
 - #99100 (Fix binary name in help message for test binaries)
 - #99103 (Avoid some `&str` to `String` conversions)
 - #99109 (fill new tracking issue for `feature(strict_provenance_atomic_ptr)`)

Failed merges:

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

23 months agoRollup merge of #99109 - WaffleLapkin:atomic_ti, r=Dylan-DPC
Matthias Krüger [Sun, 10 Jul 2022 09:52:18 +0000 (11:52 +0200)]
Rollup merge of #99109 - WaffleLapkin:atomic_ti, r=Dylan-DPC

fill new tracking issue for `feature(strict_provenance_atomic_ptr)`

New tracking issue: #99108.

The generic strict provenance issue has a lot of discussions on its own, so I think it's meaningful to have a separate issue for atomic ptr methods.

23 months agoRollup merge of #99103 - TaKO8Ki:avoid-&str-to-string-conversions, r=oli-obk
Matthias Krüger [Sun, 10 Jul 2022 09:52:17 +0000 (11:52 +0200)]
Rollup merge of #99103 - TaKO8Ki:avoid-&str-to-string-conversions, r=oli-obk

Avoid some `&str` to `String` conversions

This patch removes some `&str` to `String` conversions.

23 months agoRollup merge of #99100 - Smittyvb:test-cli-binary-name, r=thomcc
Matthias Krüger [Sun, 10 Jul 2022 09:52:16 +0000 (11:52 +0200)]
Rollup merge of #99100 - Smittyvb:test-cli-binary-name, r=thomcc

Fix binary name in help message for test binaries

Currently the help output for a test binary uses the first argument instead of the binary name in the help output:

```
$ cargo test -- --help
...
Usage: --help [OPTIONS] [FILTERS...]
...
```

This fixes it to use the name of the binary (or `...` if there is no binary name passed on argv):

```
$ cargo test -- --help
...
Usage: /tmp/x/target/debug/deps/x-80c11a15ad4e1bf3 [OPTIONS] [FILTERS...]
...
```

23 months agoRollup merge of #99086 - GuillaumeGomez:search-result-crate-filter-dropdown, r=notriddle
Matthias Krüger [Sun, 10 Jul 2022 09:52:15 +0000 (11:52 +0200)]
Rollup merge of #99086 - GuillaumeGomez:search-result-crate-filter-dropdown, r=notriddle

Fix display of search result crate filter dropdown

In case a crate name is too long, the `<select>` completely overflows its parent. Another problem is that there is left margin on the `select` which break the alignment. You can see both issues here:

![Screenshot from 2022-07-09 15-31-12](https://user-images.githubusercontent.com/3050060/178108959-0eb5af19-ec60-4d34-a2fd-c27147683c78.png)

And with the fix:

![Screenshot from 2022-07-09 15-33-37](https://user-images.githubusercontent.com/3050060/178108980-71030a92-84ee-4ee5-98e3-f97d03a6fbaf.png)

cc `@jsha`
r? `@notriddle`

23 months agoRollup merge of #99045 - 1011X:patch-1, r=GuillaumeGomez
Matthias Krüger [Sun, 10 Jul 2022 09:52:14 +0000 (11:52 +0200)]
Rollup merge of #99045 - 1011X:patch-1, r=GuillaumeGomez

improve print styles

this change removes some interactive elements in ``@media` print` form.

more specifically, it removes the sidebar, source links, the expand/collapse toggle buttons, and the `#copy-path` button.
it also adjusts some spacing and removes the `.top-doc` description completely if it's currently collapsed.

23 months agofill new tracking issue for `feature(strict_provenance_atomic_ptr)`
Maybe Waffle [Sun, 10 Jul 2022 09:17:33 +0000 (13:17 +0400)]
fill new tracking issue for `feature(strict_provenance_atomic_ptr)`

23 months agoAuto merge of #95295 - CAD97:layout-isize, r=scottmcm
bors [Sun, 10 Jul 2022 08:54:32 +0000 (08:54 +0000)]
Auto merge of #95295 - CAD97:layout-isize, r=scottmcm

Enforce that layout size fits in isize in Layout

As it turns out, enforcing this _in APIs that already enforce `usize` overflow_ is fairly trivial. `Layout::from_size_align_unchecked` continues to "allow" sizes which (when rounded up) would overflow `isize`, but these are now declared as library UB for `Layout`, meaning that consumers of `Layout` no longer have to check this before making an allocation.

(Note that this is "immediate library UB;" IOW it is valid for a future release to make this immediate "language UB," and there is an extant patch to do so, to allow Miri to catch this misuse.)

See also #95252, [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Layout.20Isn't.20Enforcing.20The.20isize.3A.3AMAX.20Rule).
Fixes https://github.com/rust-lang/rust/issues/95334

Some relevant quotes:

`@eddyb,` https://github.com/rust-lang/rust/pull/95252#issuecomment-1078513769

> [B]ecause of the non-trivial presence of both of these among code published on e.g. crates.io:
>
>   1. **`Layout` "producers" / `GlobalAlloc` "users"**: smart pointers (including `alloc::rc` copies with small tweaks), collections, etc.
>   2. **`Layout` "consumers" / `GlobalAlloc` "providers"**: perhaps fewer of these, but anything built on top of OS APIs like `mmap` will expose `> isize::MAX` allocations (on 32-bit hosts) if they lack extra checks
>
> IMO the only responsible option is to enforce the `isize::MAX` limit in `Layout`, which:
>
>   * makes `Layout` _sound_ in terms of only ever allowing allocations where `(alloc_base_ptr: *mut u8).offset(size)` is never UB
>   * frees both "producers" and "consumers" of `Layout` from manually reimplementing the checks
>     * manual checks can be risky, e.g. if the final size passed to the allocator isn't the one being checked
>     * this applies retroactively, fixing the overall soundness of existing code with zero transition period or _any_ changes required from users (as long as going through `Layout` is mandatory, making a "choke point")
>
>
> Feel free to quote this comment onto any relevant issue, I might not be able to keep track of developments.

`@Gankra,` https://github.com/rust-lang/rust/pull/95252#issuecomment-1078556371

> As someone who spent way too much time optimizing libcollections checks for this stuff and tried to splatter docs about it everywhere on the belief that it was a reasonable thing for people to manually take care of: I concede the point, it is not reasonable. I am wholy spiritually defeated by the fact that _liballoc_ of all places is getting this stuff wrong. This isn't throwing shade at the folks who implemented these Rc features, but rather a statement of how impractical it is to expect anyone out in the wider ecosystem to enforce them if _some of the most audited rust code in the library that defines the very notion of allocating memory_ can't even reliably do it.
>
> We need the nuclear option of Layout enforcing this rule. Code that breaks this rule is _deeply_ broken and any "regressions" from changing Layout's contract is a _correctness_ fix. Anyone who disagrees and is sufficiently motivated can go around our backs but the standard library should 100% refuse to enable them.

cc also `@RalfJung` `@rust-lang/wg-allocators.` Even though this technically supersedes #95252, those potential failure points should almost certainly still get nicer panics than just "unwrap failed" (which they would get by this PR).

It might additionally be worth recommending to users of the `Layout` API that they should ideally use `.and_then`/`?` to complete the entire layout calculation, and then `panic!` from a single location at the end of `Layout` manipulation, to reduce the overhead of the checks and optimizations preserving the exact location of each `panic` which are conceptually just one failure: allocation too big.

Probably deserves a T-lang and/or T-libs-api FCP (this technically solidifies the [objects must be no larger than `isize::MAX`](https://rust-lang.github.io/unsafe-code-guidelines/layout/scalars.html#isize-and-usize) rule further, and the UCG document says this hasn't been RFCd) and a crater run. Ideally, no code exists that will start failing with this addition; if it does, it was _likely_ (but not certainly) causing UB.

Changes the raw_vec allocation path, thus deserves a perf run as well.

I suggest hiding whitespace-only changes in the diff view.

23 months agoAuto merge of #97522 - xfix:stabilize-slice-from-raw-parts, r=dtolnay
bors [Sun, 10 Jul 2022 06:26:03 +0000 (06:26 +0000)]
Auto merge of #97522 - xfix:stabilize-slice-from-raw-parts, r=dtolnay

Partially stabilize const_slice_from_raw_parts

This doesn't stabilize methods working on mutable pointers.

This pull request continues from #94946.

Pinging `@rust-lang/wg-const-eval` this because I use `rustc_allow_const_fn_unstable`. I believe this is justifiable as it's already possible to use `slice::from_raw_parts` in stable by abusing `transmute`. The stable alternative to this would be to provide a stable const implementation of `std::ptr::from_raw_parts` (as it can already be implemented in stable).

```rust
use std::mem;

#[repr(C)]
struct Slice<T> {
    data: *const T,
    len: usize,
}

fn main() {
    let data: *const i32 = [1, 2, 3, 4].as_ptr();
    let len = 4;
    println!("{:?}", unsafe {
        mem::transmute::<Slice<i32>, &[i32]>(Slice { data, len })
    });
}
```

`@rustbot` modify labels: +T-libs-api

23 months agoAuto merge of #98213 - notriddle:notriddle/clap-3, r=Mark-Simulacrum
bors [Sun, 10 Jul 2022 03:45:08 +0000 (03:45 +0000)]
Auto merge of #98213 - notriddle:notriddle/clap-3, r=Mark-Simulacrum

Bump to clap 3

This PR, along with several others, will entirely remove the Clap 2 dependency from the rust source tree.

* https://github.com/rust-lang/rust-installer/pull/114
* https://github.com/rust-lang/rls/pull/1779

This PR includes a submodule bump for rust-installer, which includes the following PRs:

* https://github.com/rust-lang/rust-installer/pull/114
* https://github.com/rust-lang/rust-installer/pull/113
* https://github.com/rust-lang/rust-installer/pull/115

23 months agoFix binary name in help message for test binaries
Smitty [Sat, 9 Jul 2022 22:52:37 +0000 (18:52 -0400)]
Fix binary name in help message for test binaries

23 months agoAuto merge of #98950 - ChrisDenton:getoverlapped-io, r=thomcc
bors [Sat, 9 Jul 2022 22:37:56 +0000 (22:37 +0000)]
Auto merge of #98950 - ChrisDenton:getoverlapped-io, r=thomcc

Windows: Fallback for overlapped I/O

Fixes #98947

23 months agoPartially stabilize const_slice_from_raw_parts
Konrad Borowski [Sun, 29 May 2022 16:01:26 +0000 (18:01 +0200)]
Partially stabilize const_slice_from_raw_parts

This doesn't stabilize methods working on mutable pointers.

23 months agoAuto merge of #99056 - lcnr:higher_ranked_sub, r=oli-obk
bors [Sat, 9 Jul 2022 19:57:13 +0000 (19:57 +0000)]
Auto merge of #99056 - lcnr:higher_ranked_sub, r=oli-obk

don't use `commit_if_ok` during `higher_ranked_sub`

This snapshot doesn't really do anything useful for us, especially once we deal with placeholder outlive bounds during trait solving.

I guess that currently the idea is that `higher_ranked_sub` could cause a later `leak_check` to fail even if the combine operation isn't actually relevant. But really, using combine outside of snapshot and ignoring its result is wrong anyways, as it can constrain inference variables.

r? rust-lang/types

23 months agoavoid some `&str` to `String` conversions
Takayuki Maeda [Sat, 9 Jul 2022 18:18:56 +0000 (03:18 +0900)]
avoid some `&str` to `String` conversions

23 months agoAuto merge of #98957 - RalfJung:zst-are-different, r=lcnr,oli-obk
bors [Sat, 9 Jul 2022 17:16:00 +0000 (17:16 +0000)]
Auto merge of #98957 - RalfJung:zst-are-different, r=lcnr,oli-obk

 don't allow ZST in ScalarInt

There are several indications that we should not ZST as a ScalarInt:
- We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it.
  `ValTree::zst()` used the former, but the latter could possibly arise as well.
- Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`.
- LLVM codegen already had to special-case ZST ScalarInt.

So I propose we stop using ScalarInt to represent ZST (which are clearly not integers). Instead, we can add new ZST variants to those types that did not have other variants which could be used for this purpose.

Based on https://github.com/rust-lang/rust/pull/98831. Only the commits starting from "don't allow ZST in ScalarInt" are new.

r? `@oli-obk`

23 months agoUpdate Cargo.lock
Michael Howell [Mon, 20 Jun 2022 18:41:56 +0000 (11:41 -0700)]
Update Cargo.lock

23 months agoFix epage's nits
Michael Howell [Mon, 20 Jun 2022 18:04:34 +0000 (11:04 -0700)]
Fix epage's nits

* Use real newlines in command descriptions
* Make `--dest-dir` optional
* Show help message when no subcommand is supplied

23 months agoUpdate submodule rust-installer
Michael Howell [Sat, 18 Jun 2022 15:54:00 +0000 (08:54 -0700)]
Update submodule rust-installer

This includes the following pull requests:

* https://github.com/rust-lang/rust-installer/pull/114
* https://github.com/rust-lang/rust-installer/pull/113

23 months agoBump to clap 3
Michael Howell [Fri, 17 Jun 2022 21:53:03 +0000 (14:53 -0700)]
Bump to clap 3

23 months agoAuto merge of #99082 - matthiaskrgr:rollup-nouwsh7, r=matthiaskrgr
bors [Sat, 9 Jul 2022 14:46:29 +0000 (14:46 +0000)]
Auto merge of #99082 - matthiaskrgr:rollup-nouwsh7, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #99022 (MIR dataflow: Rename function to `always_storage_live_locals`)
 - #99050 (Clarify MIR semantics of storage statements)
 - #99067 (Intra-doc-link-ify reference to Clone::clone_from)

Failed merges:

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

23 months agoAdd GUI test for search result crate filter dropdown
Guillaume Gomez [Sat, 9 Jul 2022 13:54:36 +0000 (15:54 +0200)]
Add GUI test for search result crate filter dropdown

23 months agoFix display of search result crate filter dropdown
Guillaume Gomez [Sat, 9 Jul 2022 13:54:14 +0000 (15:54 +0200)]
Fix display of search result crate filter dropdown

23 months agotweak names and output and bless
Ralf Jung [Wed, 6 Jul 2022 14:14:46 +0000 (10:14 -0400)]
tweak names and output and bless

23 months agoreview feedback
Ralf Jung [Tue, 5 Jul 2022 21:38:46 +0000 (17:38 -0400)]
review feedback

23 months agofix cranelift and gcc backends
Ralf Jung [Tue, 5 Jul 2022 20:53:48 +0000 (16:53 -0400)]
fix cranelift and gcc backends

23 months agodon't allow ZST in ScalarInt
Ralf Jung [Sun, 3 Jul 2022 15:17:23 +0000 (11:17 -0400)]
don't allow ZST in ScalarInt

There are several indications that we should not ZST as a ScalarInt:
- We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it.
  `ValTree::zst()` used the former, but the latter could possibly arise as well.
- Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`.
- LLVM codegen already had to special-case ZST ScalarInt.

So instead add new ZST variants to those types that did not have other variants
which could be used for this purpose.

23 months agoRollup merge of #99067 - est31:to_owned_link, r=Dylan-DPC
Matthias Krüger [Sat, 9 Jul 2022 10:52:52 +0000 (12:52 +0200)]
Rollup merge of #99067 - est31:to_owned_link, r=Dylan-DPC

Intra-doc-link-ify reference to Clone::clone_from

23 months agoRollup merge of #99050 - JakobDegen:storage-docs, r=tmiasko
Matthias Krüger [Sat, 9 Jul 2022 10:52:51 +0000 (12:52 +0200)]
Rollup merge of #99050 - JakobDegen:storage-docs, r=tmiasko

Clarify MIR semantics of storage statements

Seems worthwhile to start closing out some of the less controversial open questions about MIR semantics. Hopefully this is fairly non-controversial - it's what we implement already, and I see no reason to do anything more restrictive. cc ``@tmiasko`` who commented on this when it was discussed in the original PR that added these docs.

23 months agoRollup merge of #99022 - pierwill:always-storage-live-locals, r=pierwill
Matthias Krüger [Sat, 9 Jul 2022 10:52:50 +0000 (12:52 +0200)]
Rollup merge of #99022 - pierwill:always-storage-live-locals, r=pierwill

MIR dataflow: Rename function to `always_storage_live_locals`

Related to #99021.

r?  ```@JakobDegen``` (as discussed on Zulip)

23 months agoAuto merge of #98328 - topjohnwu:fix_cross, r=jyn514
bors [Sat, 9 Jul 2022 10:45:30 +0000 (10:45 +0000)]
Auto merge of #98328 - topjohnwu:fix_cross, r=jyn514

Fix several issues during cross compiling

- When cross compiling LLVM on an arm64 macOS machine to x86_64, CMake will produce universal binaries by default, causing link errors. Explicitly set `CMAKE_OSX_ARCHITECTURES` to the one single target architecture so that the executables and libraries will be single architecture.
- When cross compiling rustc with `llvm.clang = true`, `CLANG_TABLEGEN` has to be set to the host `clang-tblgen` executable to build clang.

23 months agoAuto merge of #99078 - Dylan-DPC:rollup-gnw6cli, r=Dylan-DPC
bors [Sat, 9 Jul 2022 07:15:34 +0000 (07:15 +0000)]
Auto merge of #99078 - Dylan-DPC:rollup-gnw6cli, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #98350 (Implement support for DWARF version 5.)
 - #98915 (Clarify deriving code)
 - #98980 (fix ICE in ConstProp)
 - #99008 (Adding suggestion for E0530)
 - #99043 (Collapse some weirdly-wrapping derives)
 - #99048 (Remove a string comparison about types)
 - #99070 (Update integer_atomics tracking issue)

Failed merges:

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

23 months agoRollup merge of #99070 - tamird:update-tracking-issue, r=RalfJung
Dylan DPC [Sat, 9 Jul 2022 05:58:09 +0000 (11:28 +0530)]
Rollup merge of #99070 - tamird:update-tracking-issue, r=RalfJung

Update integer_atomics tracking issue

Updates #32976.
Updates #99069.

r? ``@RalfJung``

23 months agoRollup merge of #99048 - TaKO8Ki:remove-type-string-comparison, r=compiler-errors
Dylan DPC [Sat, 9 Jul 2022 05:58:08 +0000 (11:28 +0530)]
Rollup merge of #99048 - TaKO8Ki:remove-type-string-comparison, r=compiler-errors

Remove a string comparison about types

23 months agoRollup merge of #99043 - compiler-errors:derive-nit, r=cjgillot
Dylan DPC [Sat, 9 Jul 2022 05:58:07 +0000 (11:28 +0530)]
Rollup merge of #99043 - compiler-errors:derive-nit, r=cjgillot

Collapse some weirdly-wrapping derives

self-explanatory

23 months agoRollup merge of #99008 - obeis:issue-98974, r=compiler-errors
Dylan DPC [Sat, 9 Jul 2022 05:58:06 +0000 (11:28 +0530)]
Rollup merge of #99008 - obeis:issue-98974, r=compiler-errors

Adding suggestion for E0530

Closes #98974

23 months agoRollup merge of #98980 - RalfJung:const-prop-ice, r=oli-obk
Dylan DPC [Sat, 9 Jul 2022 05:58:05 +0000 (11:28 +0530)]
Rollup merge of #98980 - RalfJung:const-prop-ice, r=oli-obk

fix ICE in ConstProp

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

23 months agoRollup merge of #98915 - nnethercote:clarify-deriving-code, r=Mark-Simulacrum
Dylan DPC [Sat, 9 Jul 2022 05:58:04 +0000 (11:28 +0530)]
Rollup merge of #98915 - nnethercote:clarify-deriving-code, r=Mark-Simulacrum

Clarify deriving code

A number of clarifications to the deriving code.

r? ``@Mark-Simulacrum``

23 months agoRollup merge of #98350 - pcwalton:dwarf5, r=michaelwoerister
Dylan DPC [Sat, 9 Jul 2022 05:58:03 +0000 (11:28 +0530)]
Rollup merge of #98350 - pcwalton:dwarf5, r=michaelwoerister

Implement support for DWARF version 5.

DWARF version 5 brings a number of improvements over version 4. Quoting from
the announcement [1]:

> Version 5 incorporates improvements in many areas: better data compression,
> separation of debugging data from executable files, improved description of
> macros and source files, faster searching for symbols, improved debugging
> optimized code, as well as numerous improvements in functionality and
> performance.

On platforms where DWARF version 5 is supported (Linux, primarily), this commit
adds support for it behind a new `-Z dwarf-version=5` flag.

[1]: https://dwarfstd.org/Public_Review.php

r? ``@michaelwoerister``

23 months agoAuto merge of #99028 - tmiasko:inline, r=estebank
bors [Sat, 9 Jul 2022 04:34:51 +0000 (04:34 +0000)]
Auto merge of #99028 - tmiasko:inline, r=estebank

Miscellaneous inlining improvements

Add `#[inline]` to a few trivial non-generic methods from a perf report
that otherwise wouldn't be candidates for inlining.

23 months agoAuto merge of #98961 - zeevm:issue-98958-fix, r=oli-obk
bors [Sat, 9 Jul 2022 02:04:17 +0000 (02:04 +0000)]
Auto merge of #98961 - zeevm:issue-98958-fix, r=oli-obk

Only enable ConstProp on opt level >= 1

r? `@JakobDegen`

23 months agoMinor updates based on review comments.
Nicholas Nethercote [Thu, 7 Jul 2022 21:57:34 +0000 (07:57 +1000)]
Minor updates based on review comments.

23 months agoClarify MIR semantics of storage statements
Jakob Degen [Fri, 8 Jul 2022 07:58:48 +0000 (00:58 -0700)]
Clarify MIR semantics of storage statements

23 months agoAuto merge of #98816 - estebank:implicit-sized, r=oli-obk
bors [Fri, 8 Jul 2022 23:17:34 +0000 (23:17 +0000)]
Auto merge of #98816 - estebank:implicit-sized, r=oli-obk

Track implicit `Sized` obligations in type params

When we evaluate `ty::GenericPredicates` we introduce the implicit
`Sized` predicate of type params, but we do so with only the `Predicate`
its `Span` as context, we don't have an `Obligation` or
`ObligationCauseCode` we could influence. To try and carry this
information through, we add a new field to `ty::GenericPredicates` that
tracks both which predicates come from a type param and whether that
param has any bounds already (to use in suggestions).

We also suggest adding a `?Sized` bound if appropriate on E0599.

Address part of #98539.

23 months agoSimplify `cs_fold`.
Nicholas Nethercote [Tue, 5 Jul 2022 01:23:55 +0000 (11:23 +1000)]
Simplify `cs_fold`.

`cs_fold` has four distinct cases, covered by three different function
arguments:

- first field
- combine current field with previous results
- no fields
- non-matching enum variants

This commit clarifies things by replacing the three function arguments
with one that takes a new `CsFold` type with four slightly different)
cases

- single field
- combine result for current field with results for previous fields
- no fields
- non-matching enum variants

This makes the code shorter and clearer.

23 months agoFix some inconsistencies.
Nicholas Nethercote [Tue, 5 Jul 2022 00:21:37 +0000 (10:21 +1000)]
Fix some inconsistencies.

This makes `cs_cmp`, `cs_partial_cmp`, and `cs_op` (for `PartialEq`)
more similar. It also fixes some out of date comments.

23 months agoCut down large comment about zero-variant enums.
Nicholas Nethercote [Mon, 4 Jul 2022 23:50:36 +0000 (09:50 +1000)]
Cut down large comment about zero-variant enums.

When deriving functions for zero-variant enums, we just generated a
function body that calls `std::instrincs::unreachable`. There is a large
comment with some not-very-useful historical discussion about
alternatives, including some discussion of feature-gating zero-variant
enums, which is clearly irrelevant today.

This commit cuts the comment down greatly.

23 months agoAvoid transposes in deriving code.
Nicholas Nethercote [Mon, 4 Jul 2022 23:04:41 +0000 (09:04 +1000)]
Avoid transposes in deriving code.

The deriving code has some complex parts involving iterations over
selflike args and also fields within structs and enum variants.

The return types for a few functions demonstrate this:

- `TraitDef::create_{struct_pattern,enum_variant_pattern}` returns a
  `(P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>)>)`
- `TraitDef::create_struct_field_accesses` returns a `Vec<(Span,
  Option<Ident>, P<Expr>)>`.

This results in per-field data stored within per-selflike-arg data, with
lots of repetition within the per-field data elements. This then has to
be "transposed" in two places (`expand_struct_method_body` and
`expand_enum_method_body`) into per-self-like-arg data stored within
per-field data. It's all quite clumsy and confusing.

This commit rearranges things greatly. Data is obtained in the needed
form up-front, avoiding the need for transposition. Also, various
functions are split, removed, and added, to make things clearer and
avoid tuple return values.

The diff is hard to read, which reflects the messiness of the original
code -- there wasn't an easy way to break these changes into small
pieces. (Sorry!) It's a net reduction of 35 lines and a readability
improvement. The generated code is unchanged.

23 months agoRemove `FieldInfo::attrs`.
Nicholas Nethercote [Mon, 4 Jul 2022 22:59:17 +0000 (08:59 +1000)]
Remove `FieldInfo::attrs`.

It's unused. This also removes the need for the lifetime on `FieldInfo`,
which is nice.

23 months agoRename `FieldInfo` fields.
Nicholas Nethercote [Mon, 4 Jul 2022 22:47:04 +0000 (08:47 +1000)]
Rename `FieldInfo` fields.

Use `self_exprs` and `other_selflike_exprs` in a manner similar to the
previous commit.

23 months agoClarify args terminology.
Nicholas Nethercote [Mon, 4 Jul 2022 22:25:47 +0000 (08:25 +1000)]
Clarify args terminology.

The deriving code has inconsistent terminology to describe args.

In some places it distinguishes between:
- the `&self` arg (if present), versus
- all other args.

In other places it distinguishes between:
- the `&self` arg (if present) and any other arguments with the same
  type (in practice there is at most one, e.g. in `PartialEq::eq`),
  versus
- all other args.

The terms "self_args" and "nonself_args" are sometimes used for the
former distinction, and sometimes for the latter. "args" is also
sometimes used for "all other args".

This commit makes the code consistently uses "self_args"/"nonself_args"
for the former and "selflike_args"/"nonselflike_args" for the latter.
This change makes the code easier to read.

The commit also adds a panic on an impossible path (the `Self_` case) in
`extract_arg_details`.

23 months agoUpdate integer_atomics tracking issue
Tamir Duberstein [Fri, 8 Jul 2022 21:52:04 +0000 (17:52 -0400)]
Update integer_atomics tracking issue

Updates #32976.
Updates #99069.

23 months agoIntra-doc-link-ify reference to Clone::clone_from
est31 [Fri, 8 Jul 2022 20:41:41 +0000 (22:41 +0200)]
Intra-doc-link-ify reference to Clone::clone_from

23 months agoAuto merge of #99034 - RalfJung:miri, r=Mark-Simulacrum
bors [Fri, 8 Jul 2022 20:36:33 +0000 (20:36 +0000)]
Auto merge of #99034 - RalfJung:miri, r=Mark-Simulacrum

update Miri

Fixes https://github.com/rust-lang/rust/issues/98922
r? `@ghost`

23 months agoImplement support for DWARF version 5.
Patrick Walton [Mon, 20 Jun 2022 23:26:51 +0000 (16:26 -0700)]
Implement support for DWARF version 5.

DWARF version 5 brings a number of improvements over version 4. Quoting from
the announcement [1]:

> Version 5 incorporates improvements in many areas: better data compression,
> separation of debugging data from executable files, improved description of
> macros and source files, faster searching for symbols, improved debugging
> optimized code, as well as numerous improvements in functionality and
> performance.

On platforms where DWARF version 5 is supported (Linux, primarily), this commit
adds support for it behind a new `-Z dwarf-version=5` flag.

[1]: https://dwarfstd.org/Public_Review.php

23 months agoAuto merge of #98614 - oli-obk:take_unsound_opaque_types, r=wesleywiser
bors [Fri, 8 Jul 2022 17:55:26 +0000 (17:55 +0000)]
Auto merge of #98614 - oli-obk:take_unsound_opaque_types, r=wesleywiser

don't succeed `evaluate_obligation` query if new opaque types were registered

fixes #98608
fixes #98604

The root cause of all this is that in type flag computation we entirely ignore nongeneric things like struct fields and the signature of function items. So if a flag had to be set for a struct if it is set for a field, that will only happen if the field is generic, as only the generic parameters are checked.

I now believe we cannot use type flags to handle opaque types. They seem like the wrong tool for this.

Instead, this PR replaces the previous logic by adding a new variant of `EvaluatedToOk`: `EvaluatedToOkModuloOpaqueTypes`, which says that there were some opaque types that got hidden types bound, but that binding may not have been legal (because we don't know if the opaque type was in its defining scope or not).

23 months agoset all padding for main element in print
Infra [Fri, 8 Jul 2022 16:44:16 +0000 (12:44 -0400)]
set all padding for main element in print

23 months agoAuto merge of #99054 - Dylan-DPC:rollup-0zuhhds, r=Dylan-DPC
bors [Fri, 8 Jul 2022 15:24:57 +0000 (15:24 +0000)]
Auto merge of #99054 - Dylan-DPC:rollup-0zuhhds, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #98533 (Add a `-Zdump-drop-tracking-cfg` debugging flag)
 - #98654 (An optimization for `pest-2.1.3`)
 - #98657 (Migrate some diagnostics from `rustc_const_eval` to `SessionDiagnostic`)
 - #98794 (Highlight conflicting param-env candidates)

Failed merges:

 - #98957 ( don't allow ZST in ScalarInt )

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

23 months agoremove a string comparison about types
Takayuki Maeda [Fri, 8 Jul 2022 15:07:52 +0000 (00:07 +0900)]
remove a string comparison about types

23 months agodon't use `commit_if_ok` during `higher_ranked_sub`
lcnr [Fri, 8 Jul 2022 14:33:59 +0000 (16:33 +0200)]
don't use `commit_if_ok` during `higher_ranked_sub`

23 months agoOnly register hidden types for opaque types from the current crate, nothing else...
Oli Scherer [Fri, 8 Jul 2022 13:59:44 +0000 (13:59 +0000)]
Only register hidden types for opaque types from the current crate, nothing else would work anyway.

23 months agoRollup merge of #98794 - compiler-errors:conflicting-param-env, r=michaelwoerister
Dylan DPC [Fri, 8 Jul 2022 12:55:51 +0000 (18:25 +0530)]
Rollup merge of #98794 - compiler-errors:conflicting-param-env, r=michaelwoerister

Highlight conflicting param-env candidates

This could probably be further improved by noting _why_ equivalent param-env candidates (modulo regions) leads to ambiguity.

Fixes #98786

23 months agoRollup merge of #98657 - compiler-errors:rustc-const-eval-session-diagnostic-1, r...
Dylan DPC [Fri, 8 Jul 2022 12:55:50 +0000 (18:25 +0530)]
Rollup merge of #98657 - compiler-errors:rustc-const-eval-session-diagnostic-1, r=davidtwco

Migrate some diagnostics from `rustc_const_eval` to `SessionDiagnostic`

I'm still trying to get the hang of this, so it doesn't migrate _all_ of `rustc_const_eval`. Working on that later.

r? `@davidtwco`

23 months agoRollup merge of #98654 - nnethercote:pest-2.1.3-opt, r=pnkfelix
Dylan DPC [Fri, 8 Jul 2022 12:55:49 +0000 (18:25 +0530)]
Rollup merge of #98654 - nnethercote:pest-2.1.3-opt, r=pnkfelix

An optimization for `pest-2.1.3`

An easy win I found while looking at a profile of `pest-2.1.3`. It's also a small code cleanup.

r? `@pnkfelix`

23 months agoRollup merge of #98533 - jyn514:drop-tracking-debugging, r=eholk
Dylan DPC [Fri, 8 Jul 2022 12:55:48 +0000 (18:25 +0530)]
Rollup merge of #98533 - jyn514:drop-tracking-debugging, r=eholk

Add a `-Zdump-drop-tracking-cfg` debugging flag

This is useful for debugging drop-tracking; previously, you had to recompile
rustc from source and manually add a call to `write_graph_to_file`. This
makes the option more discoverable and configurable at runtime.

I also took the liberty of making the labels for the CFG nodes much easier to read:
previously, they looked like `id(2), local_id: 48`, now they look like
```
expr from_config (hir_id=HirId { owner: DefId(0:10 ~ default_struct_update[79f9]::foo), local_id: 2})
```

r? ``@eholk``

23 months agoAuto merge of #98758 - nnethercote:more-derive-output-improvements, r=Mark-Simulacrum
bors [Fri, 8 Jul 2022 12:44:14 +0000 (12:44 +0000)]
Auto merge of #98758 - nnethercote:more-derive-output-improvements, r=Mark-Simulacrum

More derive output improvements

This PR includes:
- Some test improvements.
- Some cosmetic changes to derive output that make the code look more like what a human would write.
- Some more fundamental improvements to `cmp` and `partial_cmp` generation.

r? `@Mark-Simulacrum`

23 months agoUpdate ui test for the new E0530 suggestion
Obei Sideg [Fri, 8 Jul 2022 11:54:11 +0000 (14:54 +0300)]
Update ui test for the new E0530 suggestion

23 months agointerpret: only to track_caller in debug builds due to perf
Ralf Jung [Fri, 8 Jul 2022 11:33:19 +0000 (07:33 -0400)]
interpret: only to track_caller in debug builds due to perf

23 months agoCheck if E0530 is `rustc_resolve::late::PatternSource::Match` to emit suggestion
Obei Sideg [Fri, 8 Jul 2022 11:01:30 +0000 (14:01 +0300)]
Check if E0530 is `rustc_resolve::late::PatternSource::Match` to emit suggestion

23 months agoCheck if E0530 is `tuple variant` or `tuple struct` to emit suggestion
Obei Sideg [Fri, 8 Jul 2022 10:20:05 +0000 (13:20 +0300)]
Check if E0530 is `tuple variant` or `tuple struct` to emit suggestion

23 months agoAuto merge of #98638 - bjorn3:less_string_interning, r=tmiasko
bors [Fri, 8 Jul 2022 10:03:27 +0000 (10:03 +0000)]
Auto merge of #98638 - bjorn3:less_string_interning, r=tmiasko

Use less string interning

This removes string interning in a couple of places where doing so won't result in perf improvements. I also switched one place to use pre-interned symbols.

23 months agoAuto merge of #99047 - matthiaskrgr:rollup-01vn70s, r=matthiaskrgr
bors [Fri, 8 Jul 2022 07:22:33 +0000 (07:22 +0000)]
Auto merge of #99047 - matthiaskrgr:rollup-01vn70s, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #95635 (sess: stabilize `--terminal-width` as `--diagnostic-width`)
 - #98718 (Stabilize `into_future`)
 - #98795 (A few cleanups)
 - #98798 (Fix caching bug in `download-rustc = true`)
 - #99019 (Add doc comments in `rustc_middle::mir`)
 - #99026 (Add test for and fix rust-lang/rust-clippy#9131)

Failed merges:

 - #98957 ( don't allow ZST in ScalarInt )

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

23 months agoRollup merge of #99026 - anall:buffix/clippy-9131, r=xFrednet
Matthias Krüger [Fri, 8 Jul 2022 06:00:41 +0000 (08:00 +0200)]
Rollup merge of #99026 - anall:buffix/clippy-9131, r=xFrednet

Add test for and fix rust-lang/rust-clippy#9131

This lint seems to have been broken by #98446 -- but of course, there was no clippy test for this case at the time.

`expr.span.ctxt().outer_expn_data()` now has `MacroKind::Derive` instead of `MacroKind::Attr` for something like:

```
#[derive(Clone, Debug)]
pub struct UnderscoreInStruct {
    _foo: u32,
}
```

---

changelog: none

closes: https://github.com/rust-lang/rust-clippy/issues/9131

23 months agoRollup merge of #99019 - pierwill:doc-mir-statement, r=cjgillot
Matthias Krüger [Fri, 8 Jul 2022 06:00:40 +0000 (08:00 +0200)]
Rollup merge of #99019 - pierwill:doc-mir-statement, r=cjgillot

Add doc comments in `rustc_middle::mir`

23 months agoRollup merge of #98798 - jyn514:download-rustc-cached, r=Mark-Simulacrum
Matthias Krüger [Fri, 8 Jul 2022 06:00:39 +0000 (08:00 +0200)]
Rollup merge of #98798 - jyn514:download-rustc-cached, r=Mark-Simulacrum

Fix caching bug in `download-rustc = true`

When moving this to rustbuild, I introduced a bug: if you had the file already downloaded, but
deleted the sysroot for whatever reason, rustbuil would fail to unpack the cached tarball.

This only affects people if they have a cached tarball, which is probably why we haven't seen an issue yet -
wiping `build/cache` would work around the issue, or just not deleting `build/$TARGET/stage2`.

Fixes the following error:
```
thread 'main' panicked at 'fs::read_dir(&lib_dir) failed with No such file or directory (os error 2) ("/home/jnelson/rust-lang/rust2/build/x86_64-unknown-linux-gnu/ci-rustc/lib")', config.rs:1563:20
```

r? ``@Mark-Simulacrum``

23 months agoRollup merge of #98795 - jackh726:lexical_region_resolve_cleanup, r=compiler-errors
Matthias Krüger [Fri, 8 Jul 2022 06:00:38 +0000 (08:00 +0200)]
Rollup merge of #98795 - jackh726:lexical_region_resolve_cleanup, r=compiler-errors

A few cleanups

Each commit is (mostly) self-explanatory. These changes have come as I try to remove `ReEmpty` (#98559).

23 months agoRollup merge of #98718 - yoshuawuyts:stabilize-into-future, r=yaahc
Matthias Krüger [Fri, 8 Jul 2022 06:00:37 +0000 (08:00 +0200)]
Rollup merge of #98718 - yoshuawuyts:stabilize-into-future, r=yaahc

Stabilize `into_future`

https://github.com/rust-lang/rust/issues/67644 has been labeled with [S-tracking-ready-to-stabilize](https://github.com/rust-lang/rust/labels/S-tracking-ready-to-stabilize) - which mentions someone needs to file a stabilization PR. So hence this PR! :sparkles: Thanks!

Closes https://github.com/rust-lang/rust/issues/67644

r? ``@joshtriplett``

23 months agoRollup merge of #95635 - davidtwco:terminal-width-stabilization, r=oli-obk
Matthias Krüger [Fri, 8 Jul 2022 06:00:36 +0000 (08:00 +0200)]
Rollup merge of #95635 - davidtwco:terminal-width-stabilization, r=oli-obk

sess: stabilize `--terminal-width` as `--diagnostic-width`

Formerly `-Zterminal-width`, `--terminal-width` allows the user or build
tool to inform rustc of the width of the terminal so that diagnostics
can be truncated.

Pending agreement to stabilize, see tracking issue at #84673.

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

23 months agotry to fix tidy issues
Infra [Fri, 8 Jul 2022 05:54:55 +0000 (01:54 -0400)]
try to fix tidy issues

23 months agoimprove print styles
Infra [Fri, 8 Jul 2022 05:29:35 +0000 (01:29 -0400)]
improve print styles

this change removes some interactive elements in `@media print` form.

more specifically, it removes the source links, the expand/collapse toggle buttons, and the `#copy-path` button.
it also adjusts some spacing and removes the `.top-doc` description completely if it's currently collapsed.

23 months agoCollapse some weirdly-wrapping derives
Michael Goulet [Fri, 8 Jul 2022 04:36:30 +0000 (04:36 +0000)]
Collapse some weirdly-wrapping derives

23 months agoadd regex to rustc-workspace-hack
Ralf Jung [Fri, 8 Jul 2022 04:23:01 +0000 (00:23 -0400)]
add regex to rustc-workspace-hack

23 months agoHighlight conflicting param-env candidates
Michael Goulet [Sat, 2 Jul 2022 01:30:07 +0000 (01:30 +0000)]
Highlight conflicting param-env candidates

23 months agosimplify plurals in fluent messages using hir::ConstContext
Michael Goulet [Fri, 8 Jul 2022 03:46:18 +0000 (03:46 +0000)]
simplify plurals in fluent messages using hir::ConstContext

23 months agoMigrate MutDeref, TransientMutBorrow diagnostics
Michael Goulet [Wed, 29 Jun 2022 06:22:15 +0000 (23:22 -0700)]
Migrate MutDeref, TransientMutBorrow diagnostics

23 months agoMigrate PanicNonStr, RawPtrComparison, RawPtrToInt diagnostics
Michael Goulet [Wed, 29 Jun 2022 05:46:25 +0000 (22:46 -0700)]
Migrate PanicNonStr, RawPtrComparison, RawPtrToInt diagnostics

23 months agoMigrate StaticAccess diagnostic
Michael Goulet [Wed, 29 Jun 2022 05:32:32 +0000 (22:32 -0700)]
Migrate StaticAccess diagnostic

23 months agoImplement IntoDiagnosticArg for hir::ConstContext
Michael Goulet [Wed, 29 Jun 2022 05:09:59 +0000 (22:09 -0700)]
Implement IntoDiagnosticArg for hir::ConstContext

23 months agoMigrate NonConstOp diagnostic
Michael Goulet [Wed, 29 Jun 2022 04:46:01 +0000 (21:46 -0700)]
Migrate NonConstOp diagnostic

23 months agoMigrate unstable-in-stable diagnostic
Michael Goulet [Wed, 29 Jun 2022 04:26:05 +0000 (21:26 -0700)]
Migrate unstable-in-stable diagnostic

23 months agoUse dashes instead of underscores in fluent names
Michael Goulet [Wed, 29 Jun 2022 04:03:14 +0000 (21:03 -0700)]
Use dashes instead of underscores in fluent names

23 months agoAuto merge of #98482 - cjgillot:short-struct-span-closure, r=estebank
bors [Fri, 8 Jul 2022 03:05:15 +0000 (03:05 +0000)]
Auto merge of #98482 - cjgillot:short-struct-span-closure, r=estebank

Shorten def_span of closures to just their header

Continuation of https://github.com/rust-lang/rust/pull/93967.

23 months agoMove code from rustc_trait_selection/opaque_types to better places
Jack Huey [Fri, 1 Jul 2022 01:27:13 +0000 (21:27 -0400)]
Move code from rustc_trait_selection/opaque_types to better places

23 months agoupdate Miri
Ralf Jung [Fri, 8 Jul 2022 00:51:58 +0000 (20:51 -0400)]
update Miri

23 months agoMove is_free and is_free_or_static to Region, change resolve_var to resolve_region...
Jack Huey [Tue, 28 Jun 2022 04:08:35 +0000 (00:08 -0400)]
Move is_free and is_free_or_static to Region, change resolve_var to resolve_region, and remove RootEmptyRegion

23 months agoAuto merge of #98360 - estebank:uninit-binding, r=oli-obk
bors [Thu, 7 Jul 2022 23:36:21 +0000 (23:36 +0000)]
Auto merge of #98360 - estebank:uninit-binding, r=oli-obk

 On partial uninit error point at where we need init

When a binding is declared without a value, borrowck verifies that all
codepaths have *one* assignment to them to initialize them fully. If
there are any cases where a condition can be met that leaves the binding
uninitialized or we attempt to initialize a field of an uninitialized
binding, we emit E0381.

We now look at all the statements that initialize the binding, and use
them to explore branching code paths that *don't* and point at them. If
we find *no* potential places where an assignment to the binding might
be missing, we display the spans of all the existing initializers to
provide some context.

Fix https://github.com/rust-lang/rust/issues/97956.

23 months agoAuto merge of #99024 - matthiaskrgr:rollup-8ygpcpg, r=matthiaskrgr
bors [Thu, 7 Jul 2022 20:55:34 +0000 (20:55 +0000)]
Auto merge of #99024 - matthiaskrgr:rollup-8ygpcpg, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #97917 (Implement ExitCodeExt for Windows)
 - #98844 (Reword comments and rename HIR visiting methods.)
 - #98979 (interpret: use AllocRange in UninitByteAccess)
 - #98986 (Fix missing word in comment)
 - #98994 (replace process exit with more detailed exit in src/bootstrap/*.rs)
 - #98995 (Add a test for #80471)
 - #99002 (suggest adding a derive for #[default] applied to variants)
 - #99004 (Add a test for #70408)
 - #99017 (Replace boolean argument for print_where_clause with an enum to make code more clear)

Failed merges:

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

23 months agofix arm test
Esteban Küber [Thu, 7 Jul 2022 20:16:33 +0000 (13:16 -0700)]
fix arm test

23 months agoMiscellaneous inlining improvements
Tomasz Miąsko [Thu, 7 Jul 2022 00:00:00 +0000 (00:00 +0000)]
Miscellaneous inlining improvements

Add `#[inline]` to a few trivial non-generic methods from a perf report
that otherwise wouldn't be candidates for inlining.