Commit Graph

223235 Commits

Author SHA1 Message Date
Dylan DPC
40c4ed4994
Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler-errors
uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`

Split from #109842.

r? ``@compiler-errors``
2023-05-02 11:44:52 +05:30
Dylan DPC
f47a63ca3d
Rollup merge of #110895 - Ayush1325:thread-local-fix, r=thomcc
Remove `all` in target_thread_local cfg

I think it was left there by mistake after the previous refactoring. I just came across it while rebasing to master.
2023-05-02 11:44:52 +05:30
Dylan DPC
be4f9f5bec
Rollup merge of #110512 - compiler-errors:fix-elaboration-with-associated-type-bounds, r=spastorino
Fix elaboration with associated type bounds

When computing a trait's supertrait predicates, do not add any associated type *trait* bounds to that list of supertrait predicates. This is because supertrait predicates are expected to have the same `Self` type as the trait.

For example, given:

```rust
trait Foo: Bar<Assoc: Send>
```

Before, we would compute that the supertrait predicates of `T: Foo` are `T: Bar` and `<T as Bar>::Assoc: Send`. However, the last bound is a trait predicate for a totally different type than `T`, and existing code that uses supertrait bounds such as vtable construction, closure fn signature deduction, etc. all rely on the invariant that we have a list of predicates for self type `T`.

Fixes #76593

The reason for all the extra diagnostic noise is that we're recomputing predicates with a different filter now. These diagnostics should be deduplicated for any end-user though.

---

This does bring up an interesting question -- is the predicate `<T as Bar>::Assoc: Send` an implied bound of `T: Foo`? Because currently the only bounds implied by a (non-alias) trait are its supertraits. I guess I could fix this too, but it would require even more changes, and I'm inclined to punt this question along.
2023-05-02 11:44:51 +05:30
Dylan DPC
f379a58bf2
Rollup merge of #108668 - gibbyfree:stabilizedebuggervisualizer, r=wesleywiser
Stabilize debugger_visualizer

This stabilizes the `debugger_visualizer` attribute (#95939).

* Marks the `debugger_visualizer` feature as `accepted`.
* Marks the `debugger_visualizer` attribute as `ungated`.
* Deletes feature gate test, removes feature gate from other tests.

Closes #95939
2023-05-02 11:44:51 +05:30
Dylan DPC
b727132e23
Rollup merge of #108161 - WaffleLapkin:const_param_ty, r=BoxyUwU
Add `ConstParamTy` trait

This is a bit sketch, but idk.
r? `@BoxyUwU`

Yet to be done:
- [x] ~~Figure out if it's okay to implement `StructuralEq` for primitives / possibly remove their special casing~~ (it should be okay, but maybe not in this PR...)
- [ ] Maybe refactor the code a little bit
- [x] Use a macro to make impls a bit nicer

Future work:
- [ ] Actually™ use the trait when checking if a `const` generic type is allowed
- [ ] _Really_ refactor the surrounding code
- [ ] Refactor `marker.rs` into multiple modules for each "theme" of markers
2023-05-02 11:44:50 +05:30
Dylan DPC
f916c44aec
Rollup merge of #105076 - mina86:a, r=scottmcm
Refactor core::char::EscapeDefault and co. structures

Change core::char::{EscapeUnicode, EscapeDefault and EscapeDebug}
structures from using a state machine to computing escaped sequence
upfront and during iteration just going through the characters.

This is arguably simpler since it’s easier to think about having
a buffer and start..end range to iterate over rather than thinking
about a state machine.

This also harmonises implementation of aforementioned iterators and
core::ascii::EscapeDefault struct.  This is done by introducing a new
helper EscapeIterInner struct which holds the buffer and offers simple
methods for iterating over range.

As a side effect, this probably optimises Display implementation for
those types since rather than calling write_char repeatedly, write_str
is invoked once.  On 64-bit platforms, it also reduces size of some of
the structs:

    | Struct                     | Before | After |
    |----------------------------+--------+-------+
    | core::char::EscapeUnicode  |     16 |    12 |
    | core::char::EscapeDefault  |     16 |    12 |
    | core::char::EscapeDebug    |     16 |    16 |

My ulterior motive and reason why I started looking into this is
addition of as_str method to the iterators.  With this change this
will became trivial.  It’s also going to be trivial to implement
DoubleEndedIterator if that’s ever desired.
2023-05-02 11:44:50 +05:30
bors
1cb63572d2 Auto merge of #106075 - nbdd0121:ffi-unwind, r=joshtriplett
Partial stabilisation of `c_unwind`

The stabilisation report is at https://github.com/rust-lang/rust/issues/74990#issuecomment-1363473645

cc `@rust-lang/wg-ffi-unwind`
2023-05-02 00:45:04 +00:00
Gibby Free
c9653a6b0b fix stderrs 2023-05-01 13:37:15 -07:00
Gibby Free
b00e5f37f3 remove bootstrap from tests 2023-05-01 13:37:15 -07:00
bors
d6ddee637b Auto merge of #111066 - matthiaskrgr:rollup-4k6rj23, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109540 (std docs: edit `PathBuf::set_file_name` example)
 - #110093 (Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times`)
 - #110987 (update wasi_clock_time_api ref.)
 - #111038 (Leave promoteds untainted by errors when borrowck fails)
 - #111042 (Add `#[no_coverage]` to the test harness's `fn main`)
 - #111057 (Make sure the implementation of TcpStream::as_raw_fd is fully inlined)
 - #111065 (Explicitly document how Send and Sync relate to references)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-01 20:35:53 +00:00
bors
dbba594575 Auto merge of #111067 - albertlarsan68:fix-multiprocessing-x-py, r=jyn514
Make x.py work again in most (all?) cases

Fixes #111046.

Wrap all of x.py in `if __name__ == '__main__':` to avoid problems with `multiprocessing`
Make the pool sizing better
2023-05-01 17:34:24 +00:00
Albert Larsan
30119498be
Make x.py work again in most (all?) cases
Wrap all of x.py in `if __name__ == '__main__':` to avoid problems with `multiprocessing`
Make the pool sizing better
2023-05-01 16:20:45 +00:00
Michael Goulet
bec7193072 Don't use implied trait predicates in gather_explicit_predicates_of 2023-05-01 15:45:28 +00:00
Michael Goulet
8ea71f264e Do not consider associated type bounds for super_predicates_that_define_assoc_type 2023-05-01 15:45:28 +00:00
Michael Goulet
0bcfff48a5 Simplify type_parameter_bounds_in_generics 2023-05-01 15:45:28 +00:00
Matthias Krüger
15eebac9d9
Rollup merge of #111065 - est31:send_mut_ref, r=m-ou-se
Explicitly document how Send and Sync relate to references

Some of these relations were already mentioned in the text, but that Send is implemented for &mut impl Send was not mentioned, neither did the docs list when &T is Sync. Inspired by the discussion in #110961.

[Proof](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ed77bfc3c77ba664400ebc2734f500e6) based on `@lukas-code` 's [example](https://github.com/rust-lang/rust/pull/110961#discussion_r1181220662).
2023-05-01 17:10:25 +02:00
Matthias Krüger
02134611ce
Rollup merge of #111057 - xfix:tcpstream-as-raw-fd-inline, r=m-ou-se
Make sure the implementation of TcpStream::as_raw_fd is fully inlined

Currently the following function:

```rust
use std::os::fd::{AsRawFd, RawFd};
use std::net::TcpStream;

pub fn as_raw_fd(socket: &TcpStream) -> RawFd {
    socket.as_raw_fd()
}
```

Is optimized to the following:

```asm
example::as_raw_fd:
        push    rax
        call    qword ptr [rip + <std::net::tcp::TcpStream as std::sys_common::AsInner<std::sys_common::net::TcpStream>>::as_inner@GOTPCREL]
        mov     rdi, rax
        call    qword ptr [rip + std::sys_common::net::TcpStream::socket@GOTPCREL]
        mov     rdi, rax
        pop     rax
        jmp     qword ptr [rip + _ZN73_$LT$std..sys..unix..net..Socket$u20$as$u20$std..os..fd..raw..AsRawFd$GT$9as_raw_fd17h633bcf7e481df8bbE@GOTPCREL]
```

I think it would make more sense to inline trivial functions used within `TcpStream::AsRawFd`.
2023-05-01 17:10:25 +02:00
Matthias Krüger
0a2562bf4d
Rollup merge of #111042 - Zalathar:no-coverage, r=wesleywiser
Add `#[no_coverage]` to the test harness's `fn main`

There are two main motivations for adding `#[no_coverage]` to the test harness's entry point:

- The entry point is trivial compiler-generated code that doesn't correspond to user source, and it always runs, so there's no value in instrumenting it for coverage.
- Because it has dummy spans, it causes the instrumentor implementation to emit invalid coverage mappings that confuse `llvm-cov` and result in strange coverage reports.

Fixes #110749.
2023-05-01 17:10:24 +02:00
Matthias Krüger
f835b13812
Rollup merge of #111038 - tmiasko:untainted-promoteds, r=compiler-errors
Leave promoteds untainted by errors when borrowck fails

Previously, when borrowck failed it would taint all promoteds within the MIR body. An attempt to evaluated the promoteds would subsequently fail with spurious "note: erroneous constant used". For example:

```console
...
note: erroneous constant used
 --> tests/ui/borrowck/tainted-promoteds.rs:7:9
  |
7 |     a = &0 * &1 * &2 * &3;
  |         ^^

note: erroneous constant used
 --> tests/ui/borrowck/tainted-promoteds.rs:7:14
  |
7 |     a = &0 * &1 * &2 * &3;
  |              ^^

note: erroneous constant used
 --> tests/ui/borrowck/tainted-promoteds.rs:7:19
  |
7 |     a = &0 * &1 * &2 * &3;
  |                   ^^

note: erroneous constant used
 --> tests/ui/borrowck/tainted-promoteds.rs:7:24
  |
7 |     a = &0 * &1 * &2 * &3;
  |                        ^^
```

Borrowck failure doesn't indicate that there is anything wrong with promoteds. Leave them untainted.

Fixes #110856.
2023-05-01 17:10:24 +02:00
Matthias Krüger
8a9e696f43
Rollup merge of #110987 - infdahai:wasi_clock_time, r=m-ou-se
update wasi_clock_time_api ref.

Closes #110809

>Preview0 corresponded to the import module name wasi_unstable. It was also called snapshot_0 in some places. It was short-lived, and the changes to preview1 were minor, so the focus here is on preview1.

we use the `preview1` doc according to the above quote form [WASI legacy Readme](https://github.com/WebAssembly/WASI/blob/main/legacy/README.md) .
2023-05-01 17:10:23 +02:00
Matthias Krüger
9e863aefba
Rollup merge of #110093 - beetrees:set-times-32-bit, r=joshtriplett
Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times`

Add support to `set_times` for 64-bit `time_t` on 32-bit glibc Linux platforms which have a 32-bit `time_t`. Split from #109773.

Tracking issue: #98245
2023-05-01 17:10:22 +02:00
Matthias Krüger
4da8a7a370
Rollup merge of #109540 - marcospb19:edit-Path-with_file_name-example, r=m-ou-se
std docs: edit `PathBuf::set_file_name` example

To make explicit that `set_file_name` might replace or remove the
extension, not just the file stem.

Also edit docs for `Path::with_file_name`, which calls `set_file_name`.
2023-05-01 17:10:22 +02:00
est31
09c50a0ae3 Explicitly document how Send and Sync relate to references
Some of these relations were already mentioned in the text, but that
Send is implemented for &mut impl Send was not mentioned,
neither did the docs list when &T is Sync.
2023-05-01 16:41:06 +02:00
bors
6db1e5e771 Auto merge of #111010 - scottmcm:mem-replace-simpler, r=WaffleLapkin
Make `mem::replace` simpler in codegen

Since they'd mentioned more intrinsics for simplifying stuff recently,
r? `@WaffleLapkin`

This is a continuation of me looking at foundational stuff that ends up with more instructions than it really needs.  Specifically I noticed this one because `Range::next` isn't MIR-inlining, and one of the largest parts of it is a `replace::<usize>` that's a good dozen instructions instead of the two it could be.

So this means that `ptr::write` with a `Copy` type no longer generates worse IR than manually dereferencing (well, at least in LLVM -- MIR still has bonus pointer casts), and in doing so means that we're finally down to just the two essential `memcpy`s when emitting `mem::replace` for a large type, rather than the bonus-`alloca` and three `memcpy`s we emitted before this ([or the 6 we currently emit in 1.69 stable](https://rust.godbolt.org/z/67W8on6nP)).  That said, LLVM does _usually_ manage to optimize the extra code away.  But it's still nice for it not to have to do as much, thanks to (for example) not going through an `alloca` when `replace`ing a primitive like a `usize`.

(This is a new intrinsic, but one that's immediately lowered to existing MIR constructs, so not anything that MIRI or the codegen backends or MIR semantics needs to do work to handle.)
2023-05-01 14:29:15 +00:00
Maybe Waffle
c31754651d Fix StructuralEq impls for &T, [T] and [T; N]
(`StructuralEq` is shallow for some reason...)
2023-05-01 11:45:51 +00:00
Konrad Borowski
500a8e1336 Inline AsRawFd implementations 2023-05-01 13:28:19 +02:00
Konrad Borowski
3abc30719e Inline socket function implementations 2023-05-01 13:27:02 +02:00
Konrad Borowski
174c0e86ca Inline AsInner implementations 2023-05-01 13:25:09 +02:00
bors
b7d8c88b64 Auto merge of #111036 - RalfJung:miri, r=RalfJung
update Miri

r? `@ghost`
2023-05-01 11:13:49 +00:00
bors
4b87ed9d0f Auto merge of #111026 - compiler-errors:only-typeck-root, r=cjgillot
Only cache typeck results if it's the typeck root

context: https://rust-lang.zulipchat.com/#narrow/stream/241847-t-compiler.2Fwg-incr-comp/topic/incr_comp_query_cache_promotion.20taking.20forever

Basically, typeck children just copy the typeck results of their typeck root item, so caching their results means copying the same typeck results for each child item.

r? `@ghost`
2023-05-01 06:58:49 +00:00
Scott McMurray
3456f77241 Update MIRI compiletests 2023-04-30 22:33:04 -07:00
Scott McMurray
5292d48b85 Codegen fewer instructions in mem::replace 2023-04-30 22:33:04 -07:00
bors
2034b6d23c Auto merge of #111040 - matthiaskrgr:rollup-g2sns0f, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110823 (Tweak await span to not contain dot)
 - #111015 (Remove wrong assertion in match checking.)
 - #111023 (Test precise capture with a multi-variant enum and exhaustive patterns)
 - #111032 (Migrate `builtin_macros::asm` diagnostics to translatable diagnostics)
 - #111033 (Ping Nadrieril when changing exhaustiveness checking)
 - #111037 (Close parentheses for `offset_of` in AST pretty printing)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-01 03:47:09 +00:00
Zalathar
77af67ab64 Add #[no_coverage] to the test harness's fn main 2023-05-01 11:01:12 +10:00
Matthias Krüger
9de14d894b
Rollup merge of #111037 - Nilstrieb:close-the-offsetof, r=compiler-errors
Close parentheses for `offset_of` in AST pretty printing

HIR pretty printing already handles it correctly.

This will conflict with #110694 but it seems like that PR is gonna take bit more time.
2023-05-01 01:09:50 +02:00
Matthias Krüger
7b488f4598
Rollup merge of #111033 - Nadrieril:Nadrieril-triagebot, r=compiler-errors
Ping Nadrieril when changing exhaustiveness checking

Hi!

I don't know what the procedure is but I'd quite like to be pinged when people try to change the exhaustiveness code. It's a tricky piece of code and I'm the de facto expert on it; I'd like to be available to provide feedback to contributors who wish to change it. I occasionally look through the git history and open PRs but a triagebot ping would be much more convenient.

The message says "might have" because `check_match.rs` contains a little bit of exhaustiveness logic and a lot of other match-related checks, so this ping will have false positives.
2023-05-01 01:09:49 +02:00
Matthias Krüger
124aad337f
Rollup merge of #111032 - clubby789:migrate-asm-diagnostics, r=compiler-errors
Migrate `builtin_macros::asm` diagnostics to translatable diagnostics

cc #100717

Planning on working through the remaining diagnostics in this crate
2023-05-01 01:09:49 +02:00
Matthias Krüger
bde3cbd8c3
Rollup merge of #111023 - tmiasko:multi-variant-capture, r=compiler-errors
Test precise capture with a multi-variant enum and exhaustive patterns

Add test checking that it is possible to capture fields of a multi-variant enum, when remaining variants are visibly uninhabited (under the `exhaustive_patterns` feature gate).
2023-05-01 01:09:48 +02:00
Matthias Krüger
07726e3bf2
Rollup merge of #111015 - cjgillot:chained-let-and, r=compiler-errors
Remove wrong assertion in match checking.

This assertions is completely misguided, introduced by https://github.com/rust-lang/rust/pull/108504. The responsible PR is on beta, nominating for backport.

Instead of checking that this is not a `&&`, it would make sense to check that neither arms of that `&&` is a `let`. This seems like a lot of code for unclear benefit.

r? `@saethlin`
2023-05-01 01:09:48 +02:00
Matthias Krüger
1b262b8b56
Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naber
Tweak await span to not contain dot

Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue.

Fixes #110761

This mostly touches a bunch of tests to tighten their `await` span.
2023-05-01 01:09:47 +02:00
Tomasz Miąsko
c678acd3a2 Leave promoteds untainted by errors when borrowck fails
Previously, when borrowck failed it would taint all promoteds within the MIR
body. An attempt to evaluated the promoteds would subsequently fail with
spurious "note: erroneous constant used". For example:

```console
...
note: erroneous constant used
 --> tests/ui/borrowck/tainted-promoteds.rs:7:9
  |
7 |     a = &0 * &1 * &2 * &3;
  |         ^^

note: erroneous constant used
 --> tests/ui/borrowck/tainted-promoteds.rs:7:14
  |
7 |     a = &0 * &1 * &2 * &3;
  |              ^^

note: erroneous constant used
 --> tests/ui/borrowck/tainted-promoteds.rs:7:19
  |
7 |     a = &0 * &1 * &2 * &3;
  |                   ^^

note: erroneous constant used
 --> tests/ui/borrowck/tainted-promoteds.rs:7:24
  |
7 |     a = &0 * &1 * &2 * &3;
  |                        ^^
```

Borrowck failure doesn't indicate that there is anything wrong with
promoteds. Leave them untainted.
2023-04-30 23:57:47 +02:00
Nilstrieb
0dbea7ad54 Close parentheses for offset_of in AST pretty printing
HIR pretty printing already handles it correctly.
2023-04-30 23:29:40 +02:00
Nadrieril
f93f6c5cc5 Ping Nadrieril when changing exhaustiveness checking 2023-04-30 22:54:50 +02:00
Ralf Jung
f4acc67434 update lockfile 2023-04-30 22:47:51 +02:00
clubby789
3738a18df7 Migrate builtin_macros::asm diagnostics to translatable diagnostics 2023-04-30 21:45:46 +01:00
Ralf Jung
bbe3a1542e make it more obvious when the rustc-pull failed 2023-04-30 22:39:18 +02:00
Ralf Jung
697d130844 Merge from rustc 2023-04-30 22:35:29 +02:00
bors
9ecda8de85 Auto merge of #110427 - Nilstrieb:parallel-bootstrap-startup, r=albertlarsan68
Parallelize initial Rust download in bootstrap

Parallelize the initial download of Rust in `bootstrap.py`

`time ./x.py --help` after `rm -r build`
Before: 33s
After: 27s
2023-04-30 20:02:00 +00:00
Nilstrieb
a98968ee0e Parallelize initial rust extraction
This is quite slow and embarassingly parallel, even in python.

This speeds up the initial bootstrap build by about 5-10s.
2023-04-30 19:58:47 +00:00
Michael Goulet
938e807816 Only cache typeck results if it's the typeck root 2023-04-30 19:36:59 +00:00