Commit Graph

224298 Commits

Author SHA1 Message Date
bors
2c41369acc Auto merge of #111374 - tmiasko:align-unsized-locals, r=cjgillot
Align unsized locals

Allocate an extra space for unsized locals and manually align the storage, since alloca doesn't support dynamic alignment.

Fixes #71416.
Fixes #71695.
2023-05-13 19:03:33 +00:00
bors
1623978dc4 Auto merge of #111535 - RalfJung:miri, r=RalfJung
update Miri

Needed to get miri-test-libstd working again
2023-05-13 16:26:25 +00:00
clubby789
f77971e221 Handle error body when in generator layout 2023-05-13 16:45:19 +01:00
bors
dd8ec9c88d Auto merge of #107586 - SparrowLii:parallel-query, r=cjgillot
Introduce `DynSend` and `DynSync` auto trait for parallel compiler

part of parallel-rustc #101566

This PR introduces `DynSend / DynSync` trait and `FromDyn / IntoDyn` structure in rustc_data_structure::marker. `FromDyn` can dynamically check data structures for thread safety when switching to parallel environments (such as calling `par_for_each_in`). This happens only when `-Z threads > 1` so it doesn't affect single-threaded mode's compile efficiency.

r? `@cjgillot`
2023-05-13 13:47:53 +00:00
Ralf Jung
d8815efdae update lockfile 2023-05-13 15:45:54 +02:00
Alona Enraght-Moony
c271c708e2 rustdoc-json: Add tests for #![feature(inherent_associated_types)] 2023-05-13 13:07:23 +00:00
bors
7750cd93eb Auto merge of #2894 - RalfJung:simd-ptr, r=RalfJung
implement SIMD ptr casts
2023-05-13 11:52:57 +00:00
Ralf Jung
10540a2c79 implement SIMD ptr casts 2023-05-13 13:52:08 +02:00
yukang
83789b8b06 fmt 2023-05-13 19:40:17 +08:00
Camille GILLOT
8fb888dfaa Add multiple borrow test. 2023-05-13 10:32:32 +00:00
Camille GILLOT
13fb0794ac Do not ICE on deeply nested borrows. 2023-05-13 10:29:05 +00:00
Camille GILLOT
19652377c3 Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
Camille GILLOT
25ef277594 Add mir-opt test. 2023-05-13 10:14:38 +00:00
Camille GILLOT
ccef802163 Add debuginfo test. 2023-05-13 10:14:14 +00:00
Camille GILLOT
7de9aac4fb Support ConstantIndex in debuginfo. 2023-05-13 10:12:15 +00:00
Camille GILLOT
2ec0071913 Implement references VarDebugInfo. 2023-05-13 10:12:14 +00:00
bors
ebf2b375e1 Auto merge of #110699 - jyn514:simulate-remapped-already-remapped, r=cjgillot
Apply simulate-remapped-rust-src-base even if remap-debuginfo is set in config.toml

This is really a mess. Here is the situation before this change:

- UI tests depend on not having `rust-src` available. In particular, <3f374128ee/tests/ui/tuple/wrong_argument_ice.stderr (L7-L8)> is depending on the `note` being a single line and not showing the source code.
- When `download-rustc` is disabled, we pass `-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX` `-Ztranslate-remapped-path-to-local-path=no`, which changes the diagnostic to something like `  --> /rustc/FAKE_PREFIX/library/alloc/src/collections/vec_deque/mod.rs:1657:12`
- When `download-rustc` is enabled, we still pass those flags, but they no longer have an effect. Instead rustc emits diagnostic paths like this: `  --> /rustc/39c6804b92aa202369e402525cee329556bc1db0/library/alloc/src/collections/vec_deque/mod.rs:1657:12`. Notice how there's a real commit and not `FAKE_PREFIX`. This happens because we set `CFG_VIRTUAL_RUST_SOURCE_BASE_DIR` during bootstrapping for CI artifacts, and rustc previously didn't allow for `simulate-remapped` to affect paths that had already been remapped.
- Pietro noticed this and decided the right thing was to normalize `/rustc/<commit>` to `$SRC_DIR` in compiletest: 470423c3d2
- After my change to `x test core`, which rebuilds stage 2 std from source so `build/stage2-std` and `build/stage2` use the same `.rlib` metadata, the compiler suddenly notices it has sources for `std` available and prints those in the diagnostic, causing the test to fail.

This changes `simulate-remapped-rust-src-base` to support remapping paths that have already been remapped, unblocking download-rustc.

Unfortunately, although this fixes the specific problem for
download-rustc, it doesn't seem to affect all the compiler's
diagnostics. In particular, various `mir-opt` tests are failing to
respect `simulate-remapped-path-prefix` (I looked into fixing this but
it seems non-trivial). As a result, we can't remove the normalization in
compiletest that maps `/rustc/<commit>` to `$SRC_DIR`, so this change is
currently untested anywhere except locally.

You can test this locally yourself by setting `rust.remap-debuginfo = true`, running any UI test with `ERROR` annotations, then rerunning the test manually with a dev toolchain to verify it prints `/rustc/FAKE_PREFIX`, not `/rustc/1.71.0`.

Helps with https://github.com/rust-lang/rust/issues/110352.
2023-05-13 10:10:59 +00:00
yukang
ce6cfc37d0 Fix ice caused by shorthand fields in NoFieldsForFnCall 2023-05-13 18:06:16 +08:00
Camille GILLOT
1c36f50b3e Extract debug_introduce_local_as_var. 2023-05-13 10:04:17 +00:00
bors
b22bc276f8 Auto merge of #2893 - RalfJung:rustup, r=RalfJung
Rustup
2023-05-13 08:57:21 +00:00
Ralf Jung
7431970758 fmt and fix lint 2023-05-13 10:57:01 +02:00
Ralf Jung
7b1cb69efa Merge from rustc 2023-05-13 10:52:38 +02:00
Ralf Jung
b0a621e62c Preparing for merge from rustc 2023-05-13 10:52:26 +02:00
y21
7fe83345ef improve error for impl<..> impl Trait for Type 2023-05-13 10:51:21 +02:00
bors
69fef92ab2 Auto merge of #111526 - Dylan-DPC:rollup-h75agro, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #110454 (Require impl Trait in associated types to appear in method signatures)
 - #111096 (Add support for `cfg(overflow_checks)`)
 - #111451 (Note user-facing types of coercion failure)
 - #111469 (Fix data race in llvm source code coverage)
 - #111494 (Encode `VariantIdx` so we can decode ADT variants in the right order)
 - #111499 (asm: loongarch64: Drop efiapi)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-13 05:52:50 +00:00
Dylan DPC
1533eafa15
Rollup merge of #111499 - loongarch-rs:drop-efiapi, r=Amanieu
asm: loongarch64: Drop efiapi

This PR aims to drop `efiapi` which is not a valid ABI on LoongArch.

Fixes: https://github.com/rust-lang/rust/pull/111237#discussion_r1192119809
2023-05-13 11:05:35 +05:30
Dylan DPC
8c89601647
Rollup merge of #111494 - compiler-errors:variant-order, r=petrochenkov
Encode `VariantIdx` so we can decode ADT variants in the right order

As far as I can tell, we don't guarantee anything about the ordering of `DefId`s and module children...

The code that motivated this PR (#111483) looks something like:

```rust
#[derive(Protocol)]
pub enum Data {
    #[protocol(discriminator(0x00))]
    Disconnect(Disconnect),
    EncryptionRequest,
    /* more variants... */
}
```

The specific macro ([`protocol`](https://github.com/dylanmckay/protocol)) doesn't really matter, but as far as I can tell (from calls to `build_reduced_graph`), the presence of that `#[protocol(..)]` helper attribute causes the def-id of the `Disconnect` enum variant to be collected *after* its siblings, and it shows up after the other variants in `module_children`.

When we decode the variants for `Data` in a child crate (an example test, in this case), this means that the `Disconnect` variant is moved to the end of the variants list, and all of the other variants now have incorrect relative discriminant data, causing the ICE.

This PR fixes this by sorting manually by variant index after they are decoded. I guess there are alternative ways of fixing this, such as not reusing `module_children_non_reexports` to encode the order-sensitive ADT variants, or to do some sorting in `rustc_resolve`... but none of those seemed particularly satisfying either.

~I really struggled to create a reproduction here -- it required at least 3 crates, one of which is a proc macro, and then some code to actually compute discriminants in the child crate... Needless to say, I failed to repro this in a test, but I can confirm that it fixes the regression in #111483.~ Test exists now.

r? `@petrochenkov` but feel free to reassign. ~Again, sorry for no test, but I hope the explanation at least suggests why a fix like this is likely necessary.~ Feedback is welcome.
2023-05-13 11:05:34 +05:30
Dylan DPC
770fd738c7
Rollup merge of #111469 - Dushistov:fix-coverage-data-race, r=wesleywiser
Fix data race in llvm source code coverage

Fixes #91092 .

Before this patch, increment of counters for code coverage looks like this:
```
 movq    .L__profc__RNvCsd6wgJFC5r19_3lib6bugaga+8(%rip), %rax
 addq    $1, %rax
movq    %rax, .L__profc__RNvCsd6wgJFC5r19_3lib6bugaga+8(%rip)
```

after this patch:

```
lock            incq    .L__profc__RNvCs3JgIB2SjHh2_3lib6bugaga+8(%rip)
```
2023-05-13 11:05:34 +05:30
Dylan DPC
05ca3e31df
Rollup merge of #111451 - compiler-errors:note-cast-origin, r=b-naber
Note user-facing types of coercion failure

When coercing, for example, `Box<A>` into `Box<dyn B>`, make sure that any failure notes mention *those* specific types, rather than mentioning inner types, like "the cast from `A` to `dyn B`".

I expect end-users are often confused when we skip layers of types and only mention the "innermost" part of a coercion, especially when other notes point at HIR, e.g. #111406.
2023-05-13 11:05:33 +05:30
Dylan DPC
36125c43da
Rollup merge of #111096 - AngelicosPhosphoros:overflow_checks_issue_91130, r=petrochenkov
Add support for `cfg(overflow_checks)`

This PR adds support for detecting if overflow checks are enabled in similar fashion as `debug_assertions` are detected. Possible use-case of this, for example, if we want to use checked integer casts in builds with overflow checks, e.g.

```rust
pub fn cast(val: usize)->u16 {
    if cfg!(overflow_checks) {
        val.try_into().unwrap()
    }
    else{
        vas as _
    }
}
```

Resolves #91130.
2023-05-13 11:05:33 +05:30
Dylan DPC
6cb13585d0
Rollup merge of #110454 - oli-obk:limited_impl_trait_in_assoc_type, r=compiler-errors
Require impl Trait in associated types to appear in method signatures

This implements the limited version of TAIT that was proposed in https://github.com/rust-lang/rust/issues/107645#issuecomment-1477899536

Similar to `impl Trait` in return types, `impl Trait` in associated types may only be used within the impl block which it is a part of. To make everything simpler and forward compatible to getting desugared to a plain type alias impl trait in the future, we're requiring that any associated functions or constants that want to register hidden types must be using the associated type in their signature (type of the constant or argument/return type of the associated method. Where bounds mentioning the associated type are ignored).

We have preexisting tests checking that this works transitively across multiple associated types in situations like

```rust
impl Foo for Bar {
    type A = impl Trait;
    type B = impl Iterator<Item = Self::A>;
    fn foo() -> Self::B { ...... }
}
```
2023-05-13 11:05:32 +05:30
Scott McMurray
a9570a34cd Stop checking for the absense of something that doesn't exist
A couple of codegen tests are doing
```
// CHECK-NOT: slice_index_len_fail
```

However, that function no longer exists: [the only places](https://github.com/search?q=repo%3Arust-lang%2Frust+slice_index_len_fail&type=code) it occurs in the repo are in those tests.

So this PR updates the tests to check for the absense of the functions that are actually used today to panic for out-of-bounds indexing.
2023-05-12 21:59:26 -07:00
bors
16d3e18281 Auto merge of #111447 - scottmcm:remove-more-assumes, r=thomcc
Remove useless `assume`s from `slice::iter(_mut)`

You were right in https://github.com/rust-lang/rust/pull/111395#discussion_r1190312704,
r? `@the8472`

LLVM already removes these assumes while optimizing, as can be seen in <https://rust.godbolt.org/z/KTfWKbdEM>.
2023-05-13 03:09:05 +00:00
Scott McMurray
c50a2e1d17 Remove useless assumes from slice::iter(_mut) 2023-05-12 17:34:55 -07:00
Michael Goulet
ff54c801f0 Encode VariantIdx so we can decode variants in the right order 2023-05-13 00:26:35 +00:00
bors
9850584a4e Auto merge of #103413 - RalfJung:phantom-dropck, r=lcnr
PhantomData: fix documentation wrt interaction with dropck

As far as I could find out, the `PhantomData`-dropck interaction *only* affects code using `may_dangle`. The documentation in the standard library has not been updated for 8 years and thus stems from a time when Rust still used "parametric dropck", before [RFC 1238](https://rust-lang.github.io/rfcs/1238-nonparametric-dropck.html). Back then what the docs said was correct, but with `may_dangle` dropck it stopped being entirely accurate and these days, with NLL, it is actively misleading.

Fixes https://github.com/rust-lang/rust/issues/102810
Fixes https://github.com/rust-lang/rust/issues/70841
Cc `@nikomatsakis` I hope what I am saying here is right.^^
2023-05-13 00:23:51 +00:00
Lukas Markeffsky
9c418e5170 allow mutating function args through &raw const 2023-05-13 00:00:51 +02:00
bors
7d59fa3d23 Auto merge of #111506 - RalfJung:miri, r=oli-obk
update Miri

and run mir-opt-level=4 tests in rustc CI so issues like https://github.com/rust-lang/rust/issues/111422 are caught before they land.

r? `@oli-obk` due to the bootstrap changes
2023-05-12 21:49:06 +00:00
Lukas Markeffsky
97ed808322 remove no-op logic 2023-05-12 23:14:31 +02:00
bors
4a59ba4d54 Auto merge of #111396 - vlad20012:reduce-Borrows-dataflow-bitset-size, r=cjgillot
Reduce BitSet size used in `Borrows` dataflow analysis

It looks like it is not needed to multiply the number of borrows by 2. Bits greater than `self.borrow_set.len()` are never set in this bitset. This should decrease the memory usage by an epsilon.
2023-05-12 17:37:05 +00:00
bors
25c545114a Auto merge of #2890 - oli-obk:ui_test, r=RalfJung
Add `./miri run-dep` for running a file with test dependencies available

fixes #2443
2023-05-12 14:19:50 +00:00
Oli Scherer
2f187343b9 Document arguments and interesting flags 2023-05-12 14:19:34 +00:00
Ralf Jung
b93fd8355a hedge for future changes
Co-authored-by: lcnr <rust@lcnr.de>
2023-05-12 15:28:51 +02:00
Ralf Jung
18fd17d2cd run miri tests with MIR opts in rustc CI 2023-05-12 15:07:24 +02:00
bors
cd5f8b4f70 Auto merge of #2892 - RalfJung:rustup, r=RalfJung
Rustup
2023-05-12 12:19:07 +00:00
Ralf Jung
b1574380cc opt-level 4 should work again now 2023-05-12 14:18:52 +02:00
Ralf Jung
8556c4d108 bump rustc (no josh changes) 2023-05-12 14:18:46 +02:00
bors
077fc26f0a Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwco
Uplift `clippy::{drop,forget}_{ref,copy}` lints

This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints.

Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted.

## `drop_ref` and `forget_ref`

The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value.

### Example

```rust
let mut lock_guard = mutex.lock();
std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex
// still locked
operation_that_requires_mutex_to_be_unlocked();
```

### Explanation

Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended.

## `drop_copy` and `forget_copy`

The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait.

### Example

```rust
let x: i32 = 42; // i32 implements Copy
std::mem::forget(x) // A copy of x is passed to the function, leaving the
                    // original unaffected
```

### Explanation

Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation.

-----

Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
2023-05-12 12:04:32 +00:00
Oli Scherer
4e92f761fe Use the opaque_types_defined_by query to cheaply check for whether a hidden type may be registered for an opaque type 2023-05-12 10:26:50 +00:00
lcnr
6ae803eedf add query opaque_types_defined_by 2023-05-12 10:26:07 +00:00