Commit Graph

24713 Commits

Author SHA1 Message Date
Caleb Cartwright
00c3f7552e refactor: add chunks method to TokenStream to obviate rustdoc clones 2023-05-13 16:59:28 -05:00
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
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
yukang
83789b8b06 fmt 2023-05-13 19:40:17 +08: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
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
y21
7fe83345ef improve error for impl<..> impl Trait for Type 2023-05-13 10:51:21 +02: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
Michael Goulet
ff54c801f0 Encode VariantIdx so we can decode variants in the right order 2023-05-13 00:26:35 +00:00
Lukas Markeffsky
9c418e5170 allow mutating function args through &raw const 2023-05-13 00:00:51 +02: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
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
Oli Scherer
e2daccc4ac Add a convenience function 2023-05-12 10:25:34 +00:00
Oli Scherer
84a43f0e3a Rewrite nested if conditions into a single match 2023-05-12 10:25:06 +00:00
Oli Scherer
31ae7c46bd Invert IgnoreRegions to CheckRegions 2023-05-12 10:24:17 +00:00
Oli Scherer
f08b517597 Require impl Trait in associated types to appear in method signatures 2023-05-12 10:24:03 +00:00
WANG Rui
d58863fe43 asm: loongarch64: Drop efiapi 2023-05-12 17:22:47 +08:00
bors
0b795044c6 Auto merge of #111493 - matthiaskrgr:rollup-iw1z59b, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #111179 (Fix instrument-coverage tests by using Python to sort instantiation groups)
 - #111393 (bump windows crate 0.46 -> 0.48)
 - #111441 (Verify copies of mutable pointers in 2 stages in ReferencePropagation)
 - #111456 (Update cargo)
 - #111490 (Don't ICE in layout computation for placeholder types)
 - #111492 (use by ref TokenTree iterator to avoid a few clones)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-12 07:31:18 +00:00
Matthias Krüger
9039de61f3
Rollup merge of #111492 - calebcartwright:by-ref-tokentree-1, r=compiler-errors
use by ref TokenTree iterator to avoid a few clones

Just a handful of swaps from the by-value cursor to by-ref cursor so as to avoid some unnecessary clones.

I've been doing some analysis on internal cleanup opportunities within rustfmt and as part of that yak-shave I found myself perusing broader token stream and tree usage (which we use within rustfmt). As reflected in some inline comments on the cursor structs (not part of this diff), there's probably many other such cases throughout the code, but figured I'd start small with these while I had the time. May take a look at the other sites in the future
2023-05-12 07:11:14 +02:00
Matthias Krüger
4c12f5d252
Rollup merge of #111490 - compiler-errors:layout-placeholder, r=aliemjay
Don't ICE in layout computation for placeholder types

We use `layout_of` for the built-in `PointerLike` trait to check if a type can be coerced to a `dyn*`.

Since the new solver canonicalizes parameter types to placeholders, that code needs to be able to treat placeholders like params, and for the most part it does, **except** for a call to `is_trivially_sized`. This PR fixes that.
2023-05-12 07:11:14 +02:00
Matthias Krüger
ab18da61f4
Rollup merge of #111441 - cjgillot:issue-111422, r=JakobDegen
Verify copies of mutable pointers in 2 stages in ReferencePropagation

Fixes #111422

In the first stage, we mark the copies as reborrows, to be checked later.
In the second stage, we walk the reborrow chains to verify that all stages are fully replacable.

The replacement itself mirrors the check, and iterates through the reborrow chain.

r? ``````@RalfJung``````
cc ``````@JakobDegen``````
2023-05-12 07:11:13 +02:00
Matthias Krüger
d075b6c16d
Rollup merge of #111393 - klensy:win-0.48, r=oli-obk
bump windows crate 0.46 -> 0.48

This drops duped version of crate(0.46), reduces `rustc_driver.dll` ~800kb and reduces exported functions number from 26k to 22k.

Also while here, added `tidy-alphabetical` sorting to lists in tidy allowed lists.
2023-05-12 07:11:12 +02:00
Caleb Cartwright
05c5df5682 refactor: use by-ref TokenTree iterator to avoid a few clones 2023-05-11 21:59:38 -05:00
Michael Goulet
3009cb3f6b Don't ICE in layout computation for placeholder types 2023-05-12 00:58:06 +00:00
Michael Goulet
6641b49cdd
Rollup merge of #111460 - clubby789:lowercase-box-self, r=compiler-errors
Improve suggestion for `self: Box<self>`

Fixes #110642
2023-05-11 17:43:09 -07:00
Michael Goulet
7c31df9d6c
Rollup merge of #111444 - cjgillot:issue-111400, r=oli-obk
Only warn single-use lifetime when the binders match.

Fixes https://github.com/rust-lang/rust/issues/111400
2023-05-11 17:43:08 -07:00
Michael Goulet
691a5f3883
Rollup merge of #111375 - rcvalle:rust-cfi-fix-106547, r=bjorn3
CFI: Fix SIGILL reached via trait objects

Fix #106547 by transforming the concrete self into a reference to a trait object before emitting type metadata identifiers for trait methods.
2023-05-11 17:43:07 -07:00
Michael Goulet
41ab8e6b87
Rollup merge of #111366 - obeis:ascribe-user-type-variance, r=lcnr
Make `NonUseContext::AscribeUserTy` carry `ty::Variance`

Close #108267
2023-05-11 17:43:07 -07:00
Michael Goulet
341d6dfba5
Rollup merge of #106038 - aliemjay:opaque-implied, r=lcnr
use implied bounds when checking opaque types

During opaque type inference, we check for the well-formedness of the hidden type in the opaque type's own environment, not the one of the defining site, which are different in the case of TAIT.

However in the case of associated-type-impl-trait, we don't use implied bounds from the impl header. This caused us to reject the following:
```rust
trait Service<Req> {
    type Output;
    fn call(req: Req) -> Self::Output;
}

impl<'a, Req> Service<&'a Req> for u8 {
    type Output= impl Sized; // we can't prove WF of hidden type  `WF(&'a Req)` although it's implied by the impl
    //~^ ERROR type parameter Req doesn't live long enough
    fn call(req: &'a Req) -> Self::Output {
        req
    }
}
```

although adding an explicit bound would make it pass:
```diff
- impl<'a, Req> Service<&'a Req> for u8 {
+ impl<'a, Req> Service<&'a Req> for u8  where Req: 'a, {
```

I believe it should pass as we already allow the concrete type to be used:
```diff
impl<'a, Req> Service<&'a Req> for u8 {
-    type Output= impl Sized;
+    type Output= &'a Req;
```

Fixes #95922

Builds on #105982

cc ``@lcnr`` (because implied bounds)

r? ``@oli-obk``
2023-05-11 17:43:06 -07:00
Michael Goulet
14bf909e71 Note base types of coercion 2023-05-12 00:10:52 +00:00
Evgeniy A. Dushistov
6b58ff5cdf Usage of atomic counters for llvm code coverage 2023-05-12 01:40:04 +03:00
clubby789
2555f3bbcf Better diagnostics for env! where variable contains escape 2023-05-11 21:41:07 +01:00
AngelicosPhosphoros
7c263adb2a 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.
Tracking issue: #111466.
2023-05-11 18:06:31 +04:00
clubby789
3851a4bb91 Improve error for self: Box<self> 2023-05-11 13:21:10 +01:00
Bryanskiy
670f5b134e Populate effective visibilities in rustc_privacy 2023-05-11 14:51:01 +03:00
bors
f8d8ffa2eb Auto merge of #111029 - Nilstrieb:when-the-errs-are-too-big, r=petrochenkov
Shrink `SelectionError` a lot

`SelectionError` used to be 80 bytes (on 64 bit). That's quite big. Especially because the selection cache contained `Result<_, SelectionError>. The Ok type is only 32 bytes, so the 80 bytes significantly inflate the size of the cache.

Most variants of the `SelectionError` seem to be hard errors, only `Unimplemented` shows up in practice (for cranelift-codegen, it occupies 23.4% of all cache entries). We can just box away the biggest variant, `OutputTypeParameterMismatch`, to get the size down to 16 bytes, well within the size of the Ok type inside the cache.
2023-05-11 08:43:38 +00:00
Matthias Krüger
968911dbc0
Rollup merge of #111432 - cjgillot:issue-111426, r=oli-obk
Use visit_assign to detect SSA locals.

I screwed up the logic in 3c43b61b87.

Fixes https://github.com/rust-lang/rust/issues/111426
2023-05-11 07:05:29 +02:00
Matthias Krüger
39761b0cf9
Rollup merge of #111382 - Zalathar:ffi, r=cuviper
Isolate coverage FFI type layouts from their underlying LLVM C++ types

I noticed that several of the types used to send coverage information through FFI are not properly isolated from the layout of their corresponding C++ types in the LLVM API.

This PR adds more explicitly-defined FFI struct/enum types in `CoverageMappingWrapper.cpp`, so that Rust source files in `rustc_codegen_ssa` and `rustc_codegen_llvm` aren't directly exposed to LLVM C++ types.
2023-05-11 07:05:27 +02:00
Matthias Krüger
aa9adf457b
Rollup merge of #111292 - Urgau:check-cfg-issue-111291, r=petrochenkov
Fix mishandled `--check-cfg` arguments order

This PR fixes a bug in `--check-cfg` where the order of `--check-cfg=names(a)` and `--check-cfg=values(a,…)` would trip the compiler.

Fixes https://github.com/rust-lang/rust/issues/111291
cc `@taiki-e` `@petrochenkov`
2023-05-11 07:05:27 +02:00
Matthias Krüger
40d933a19a
Rollup merge of #108705 - clubby789:refutable-let-closure-borrow, r=cjgillot
Prevent ICE with broken borrow in closure

r? `@Nilstrieb`
Fixes #108683

This solution isn't ideal, I'm hoping to find a way to continue compilation without ICEing.
2023-05-11 07:05:26 +02:00
bors
9a767b6b9e Auto merge of #110820 - cjgillot:faster-dcp, r=oli-obk
Optimize dataflow-const-prop place-tracking infra

Optimization opportunities found while investigating https://github.com/rust-lang/rust/pull/110719

Computing places breadth-first ensures that we create short projections before deep projections, since the former are more likely to be propagated.

The most relevant is the pre-computation of flooded places. Callgrind showed `flood_*` methods and especially `preorder_preinvoke` were especially hot. This PR attempts to pre-compute the set of `ValueIndex` that `preorder_invoke` would visit.

Using this information, we make some `PlaceIndex` inaccessible when they contain no `ValueIndex`, allowing to skip computations for those places.

cc `@jachris` as original author
2023-05-10 20:54:31 +00:00
Camille GILLOT
a2fe9935ea Only warn single-use lifetime when the binders match. 2023-05-10 19:49:02 +00:00
Camille GILLOT
9fb1c73a73 Avoid shadowing. 2023-05-10 19:23:01 +00:00
Camille GILLOT
aeac555578 Do not see through copies of mutable pointers. 2023-05-10 19:22:57 +00:00
Camille GILLOT
d0d4e0237f Iteratively replace pointers. 2023-05-10 19:22:54 +00:00
Urgau
e280df556d Add note to suggest using let _ = x to ignore the value 2023-05-10 19:36:02 +02:00
Urgau
d23f8957ae Improve warning message by saying that it "does nothing" 2023-05-10 19:36:02 +02:00
Urgau
457fa953a2 Use label instead of note to be more consistent with other lints 2023-05-10 19:36:02 +02:00
Urgau
971b9b23b5 Uplift clippy::forget_copy to rustc 2023-05-10 19:36:01 +02:00
Urgau
1ef9c163aa Uplift clippy::forget_ref to rustc 2023-05-10 19:36:01 +02:00
Urgau
156f5563c7 Uplift clippy::drop_copy to rustc 2023-05-10 19:36:01 +02:00
Urgau
28cdbc2a64 Uplift clippy::drop_ref to rustc 2023-05-10 19:36:01 +02:00
Urgau
7dab6094bb Remove useless drop of copy type 2023-05-10 19:36:01 +02:00
Urgau
d36e390d81 Remove and fix useless drop of reference 2023-05-10 19:36:01 +02:00
b-naber
e7a2f52ba1 don't inline polymorphic adt instances whose fields contain projections
in DropGlue.
2023-05-10 16:03:52 +00:00
Camille GILLOT
6ad0497cc0 Use visit_assign to detect SSA locals. 2023-05-10 15:26:51 +00:00
bohan
7c1bc0353b refactor(resolve): clean up the early error return caused by non-call 2023-05-10 22:35:01 +08:00
Obei Sideg
2198faeee2 Make NonUseContext::AscribeUserTy carry ty::Variance 2023-05-10 09:54:56 +03:00
bors
25444e5a2e Auto merge of #111414 - matthiaskrgr:rollup-q0qoc47, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110673 (Make alias bounds sound in the new solver (take 2))
 - #110747 (Encode types in SMIR)
 - #111095 (Correctly handle associated items of a trait inside a `#[doc(hidden)]` item)
 - #111381 (Keep encoding attributes for closures)
 - #111408 (Fix incorrect implication of transmuting slices)
 - #111410 (Switch to `EarlyBinder` for `thir_abstract_const` query)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-10 06:53:47 +00:00
Matthias Krüger
70d5bf7fae
Rollup merge of #111410 - kylematsuda:earlybinder-abstract-const, r=BoxyUwU
Switch to `EarlyBinder` for `thir_abstract_const` query

Part of the work to finish https://github.com/rust-lang/rust/issues/105779.

This PR adds `EarlyBinder` to the return type of the `thir_abstract_const` query and removes `bound_abstract_const`.

r? `@compiler-errors`
2023-05-10 06:12:15 +02:00
Matthias Krüger
3d4d6703a9
Rollup merge of #111381 - oli-obk:closure_attr, r=petrochenkov
Keep encoding attributes for closures

see https://github.com/model-checking/kani/pull/2406#issuecomment-1539630332 for some context.

We stopped encoding attributes for closures, but some tools need them
2023-05-10 06:12:14 +02:00
Matthias Krüger
f1922275b7
Rollup merge of #110747 - oli-obk:smirty, r=spastorino
Encode types in SMIR

The first commit makes sure we can actually store a Ty<'tcx> (with the lifetime) in the thread local and get it back out. The second commit then introduces types.

r? `@spastorino`
2023-05-10 06:12:13 +02:00
Matthias Krüger
c14d912cd2
Rollup merge of #110673 - compiler-errors:alias-bounds-2, r=lcnr
Make alias bounds sound in the new solver (take 2)

Make alias bounds sound in the new solver (in a way that does not require coinduction) by only considering them for projection types whose corresponding trait refs come from a param-env candidate.

That is, given `<T as Trait>::Assoc: Bound`, we only *really* need to consider the alias bound if `T: Trait` is satisfied via a param-env candidate. If it's instead satisfied, e.g., via an user provided impl candidate or a , then that impl should have a concrete type to which we could otherwise normalize `<T as Trait>::Assoc`, and that concrete type is then responsible to prove the `Bound` on it.

Similar consideration is given to opaque types, since we only need to consider alias bounds if we're *not* in reveal-all mode, since similarly we'd be able to reveal the opaque types and prove any bounds that way.

This does not remove that hacky "eager projection replacement" logic from object bounds, which are somewhat like alias bounds. But removing this eager normalization behavior (added in #108333) would require full coinduction to be enabled. Compare to #110628, which does remove this object-bound custom logic but requires coinduction to be sound.

r? `@lcnr`
2023-05-10 06:12:13 +02:00
bors
63fc57b98e Auto merge of #106560 - bjorn3:support_staticlib_dylib_linking, r=pnkfelix
Support linking to rust dylib with --crate-type staticlib

This allows for example dynamically linking libstd, while statically linking the user crate into an executable or C dynamic library. For this two unstable flags (`-Z staticlib-allow-rdylib-deps` and `-Z staticlib-prefer-dynamic`) are introduced. Without the former you get an error. The latter is the equivalent to `-C prefer-dynamic` for the staticlib crate type to indicate that dynamically linking is preferred when both options are available, like for libstd. Care must be taken to ensure that no crate ends up being merged into two distinct staticlibs that are linked together. Doing so will cause a linker error at best and undefined behavior at worst. In addition two distinct staticlibs compiled by different rustc may not be combined under any circumstances due to some rustc private symbols not being mangled.

To successfully link a staticlib, `--print native-static-libs` can be used while compiling to ask rustc for the linker flags necessary when linking the staticlib. This is an existing flag which previously only listed native libraries. It has been extended to list rust dylibs too. Trying to locate libstd yourself to link against it is not supported and may break if for example the libstd of multiple rustc versions are put in the same directory.

For an example on how to use this see the `src/test/run-make-fulldeps/staticlib-dylib-linkage/` test.
2023-05-10 03:40:40 +00:00
Kyle Matsuda
26dc139b37 add EarlyBinder to thir_abstract_const; remove tcx.bound_abstract_const 2023-05-09 16:22:50 -06:00
bors
50dff955a9 Auto merge of #106285 - cjgillot:refprop-ssa, r=JakobDegen
Implement SSA-based reference propagation

Rust has a tendency to create a lot of short-lived borrows, in particular for method calls. This PR aims to remove those short-lived borrows with a const-propagation dedicated to pointers to local places.

This pass aims to transform the following pattern:
```
  _1 = &raw? mut? PLACE;
  _3 = *_1;
  _4 = &raw? mut? *_1;
```

Into
```
  _1 = &raw? mut? PLACE;
  _3 = PLACE;
  _4 = &raw? mut? PLACE;
```

where `PLACE` is a direct or an indirect place expression.

By removing indirection, this pass should help both dest-prop and const-prop to handle more cases.
This optimization is distinct from const-prop and dataflow const-prop since the borrow-reborrow patterns needs to preserve borrowck invariants, especially the uniqueness property of mutable references.

The pointed-to places are computed using a SSA analysis. We suppose that removable borrows are typically temporaries from autoref, so they are by construction assigned only once, and a SSA analysis is enough to catch them. For each local, we store both where and how it is used, in order to efficiently compute the all-or-nothing property. Thanks to `Derefer`, we only have to track locals, not places in general.

---

There are 3 properties that need to be upheld for this transformation to be legal:
- place constness: `PLACE` must refer to the same memory wherever it appears;
- pointer liveness: we must not introduce dereferences of dangling pointers;
- `&mut` borrow uniqueness.

## Constness

If `PLACE` is an indirect projection, if its of the form `(*LOCAL).PROJECTIONS` where:
- `LOCAL` is SSA;
- all projections in `PROJECTIONS` are constant (no dereference and no indexing).

If `PLACE` is a direct projection of a local, we consider it as constant if:
- the local is always live, or it has a single `StorageLive` that dominates all uses;
- all projections are constant.

# Liveness

When performing a substitution, we must take care not to introduce uses of dangling locals.

Using a dangling borrow is UB. Therefore, we assume that for any use of `*x`, where `x` is a borrow, the pointed-to memory is live.

Limitations:
- occurrences of `*x` in an `&raw mut? *x` are accepted;
- raw pointers are allowed to be dangling.

In those 2 case, we do not substitute anything, to be on the safe side.

**Open question:** we do not differentiate borrows of ZST and non-ZST. The UB rules may be
different depending on the layout. Having a different treatment would effectively prevent this
pass from running on polymorphic MIR, which defeats the purpose of MIR opts.

## Uniqueness

For `&mut` borrows, we also need to preserve the uniqueness property:
we must avoid creating a state where we interleave uses of `*_1` and `_2`.
To do it, we only perform full substitution of mutable borrows:
we replace either all or none of the occurrences of `*_1`.

Some care has to be taken when `_1` is copied in other locals.
```
   _1 = &raw? mut? _2;
   _3 = *_1;
   _4 = _1
   _5 = *_4
```
In such cases, fully substituting `_1` means fully substituting all of the copies.

For immutable borrows, we do not need to preserve such uniqueness property,
so we perform all the possible substitutions without removing the `_1 = &_2` statement.
2023-05-09 21:54:34 +00:00
Michael Goulet
3a863e534b Consolidate the 'match assumption' type methods in GoalKind 2023-05-09 20:37:50 +00:00
Michael Goulet
0dbaae4165 Make alias bounds sound in the new solver 2023-05-09 20:37:50 +00:00
Ramon de C Valle
7c7b22e62c CFI: Fix SIGILL reached via trait objects
Fix #106547 by transforming the concrete self into a reference to a
trait object before emitting type metadata identifiers for trait
methods.
2023-05-09 20:04:19 +00:00
Matthias Krüger
363d158cd8
Rollup merge of #111215 - BoxyUwU:resolve_anon_consts_differently, r=cjgillot
Various changes to name resolution of anon consts

Sorry this PR is kind of all over the place ^^'

Fixes #111012

- Rewrites anon const nameres to all go through `fn resolve_anon_const` explicitly instead of `visit_anon_const` to ensure that we do not accidentally resolve anon consts as if they are allowed to use generics when they aren't. Also means that we dont have bits of code for resolving anon consts that will get out of sync (i.e. legacy const generics and resolving path consts that were parsed as type arguments)
- Renames two of the `LifetimeRibKind`, `AnonConst -> ConcreteAnonConst` and `ConstGeneric -> ConstParamTy`
- Noticed while doing this that under `generic_const_exprs` all lifetimes currently get resolved to errors without any error being emitted which was causing a bunch of tests to pass without their bugs having been fixed, incidentally fixed that in this PR and marked those tests as `// known-bug:`. I'm fine to break those since `generic_const_exprs` is a very unstable incomplete feature and this PR _does_ make generic_const_exprs "less broken" as a whole, also I can't be assed to figure out what the underlying causes of all of them are. This PR reopens #77357 #83993
- Changed `generics_of` to stop providing generics and predicates to enum variant discriminant anon consts since those are not allowed to use generic parameters
- Updated the error for non 'static lifetime in const arguments and the error for non 'static lifetime in const param tys to use `derive(Diagnostic)`

I have a vague idea why const-arg-in-const-arg.rs, in-closure.rs and simple.rs have started failing which is unfortunate since these were deliberately made to work, I think lifetime resolution being broken just means this regressed at some point and nobody noticed because the tests were not testing anything :( I'm fine breaking these too for the same reason as the tests for #77357 #83993. I couldn't get `// known-bug` to work for these ICEs and just kept getting different stderr between CI and local `--bless` so I just removed them and will create an issue to track re-adding (and fixing) the bugs if this PR lands.

r? `@cjgillot` cc `@compiler-errors`
2023-05-09 20:49:32 +02:00
Matthias Krüger
e4c82501c2
Rollup merge of #110770 - m-ou-se:fmt-temp-lifetime, r=oli-obk
Limit lifetime of format_args!() with inlined args.

Fixes #110769
2023-05-09 20:49:31 +02:00
Camille GILLOT
c17e878fb8 Correct StorageLive comment. 2023-05-09 17:59:35 +00:00
Camille GILLOT
a67bf08ed7 Only check storage liveness for direct projections. 2023-05-09 17:59:35 +00:00
Camille GILLOT
3b4e1fe104 Do not check StorageLive dominates address-taking. 2023-05-09 17:59:35 +00:00
Camille GILLOT
3268f2e61d Only check that StorageLive dominates address-taking. 2023-05-09 17:59:35 +00:00
Camille GILLOT
0bd9bd6b8a Explicit performance concern. 2023-05-09 17:59:35 +00:00
Camille GILLOT
38612f5ec7 Explicitly skip arguments. 2023-05-09 17:59:35 +00:00
Camille GILLOT
3c43b61b87 Do not consider borrowed Freeze locals as SSA. 2023-05-09 17:59:35 +00:00
Camille GILLOT
3490375570 Implement SSA-based reference propagation. 2023-05-09 17:59:34 +00:00
Camille GILLOT
ccc1da247b Prevent stack overflow. 2023-05-09 17:27:58 +00:00
Camille GILLOT
2aa1c23fed Add a few comments. 2023-05-09 17:27:58 +00:00
Camille GILLOT
79c073746b Do not flood on copy_nonoverlapping. 2023-05-09 17:27:58 +00:00
Camille GILLOT
add5124dce Extract handle_set_discriminant. 2023-05-09 17:27:58 +00:00
Camille GILLOT
2b0bf3cf59 Trim the places that will not be used. 2023-05-09 17:27:58 +00:00
Camille GILLOT
38fa676330 Precompute values to flood. 2023-05-09 17:27:58 +00:00
Camille GILLOT
7c3d55150d Create tracked places breadth first. 2023-05-09 17:27:58 +00:00
Camille GILLOT
71138e9933 Make HasTop and HasBottom consts. 2023-05-09 17:27:58 +00:00
vlad20012
6989246645
Reduce BitSet size used in Borrows dataflow analysis 2023-05-09 18:50:13 +02:00
klensy
3c03cce341 bump windows crate 0.46 -> 0.48 in workspace 2023-05-09 18:20:13 +03:00
bors
3a37c2f052 Auto merge of #111371 - compiler-errors:revert-110907, r=petrochenkov
Revert "Populate effective visibilities in `rustc_privacy`"

This reverts commit cff85f22f5, cc #110907. It needs to be fixed, but there are too many issues being reported that I wanted to put up a revert until a proper fix can be committed.

Fixes a ton of issues where private but still reachable impls were missing during codegen:
Fixes #111320
Fixes #111321
Fixes #111334
Fixes #111357
Fixes #111368
Fixes #111373
Fixes #111377
Fixes #111386
Fixes #111387

`@bors` p=1

r? `@petrochenkov`
2023-05-09 15:16:17 +00:00
Mara Bos
d5843ddaf1 Limit lifetime of format_args!() with inlined args. 2023-05-09 16:08:40 +02:00
Zalathar
9addf0651c Correctly mark parameter RustMappingRegions as pointer-to-const
The regions don't need to be mutable because we pass a copy of them to LLVM
instead, and this matches the `*const` in the Rust-side signature.
2023-05-09 18:43:12 +10:00
Zalathar
7cab196e7c Isolate coverage FFI type layouts from their underlying LLVM C++ types 2023-05-09 18:08:32 +10:00
Oli Scherer
b7f570fff3 Keep encoding attributes for closures 2023-05-09 07:54:18 +00:00
Nilstrieb
e8ab648902 Rename expected_trait_ref to self_ty_trait_ref
This trait ref is derived from the self type and then equated to the
trait ref from the obligation.

For example, for `fn(): Fn(u32)`, `self_ty_trait_ref` is `Fn()`, which
is then equated to `Fn(u32)` (which will fail, causing the obligation to
fail).
2023-05-09 07:16:59 +00:00
Nilstrieb
41a9cbeb64 Shrink SelectionError a lot
`SelectionError` used to be 80 bytes (on 64 bit). That's quite big.
Especially because the selection cache contained `Result<_,
SelectionError>. The Ok type is only 32 bytes, so the 80 bytes
significantly inflate the size of the cache.

Most variants of the `SelectionError` seem to be hard errors, only
`Unimplemented` shows up in practice (for cranelift-codegen, it occupies
23.4% of all cache entries). We can just box away the biggest variant,
`OutputTypeParameterMismatch`, to get the size down to 16 bytes, well
within the size of the Ok type inside the cache.
2023-05-09 07:10:47 +00:00
Dylan DPC
f748bb1402
Rollup merge of #111252 - matthewjasper:min-spec-improvements, r=compiler-errors
Min specialization improvements

- Don't allow specialization impls with no items, such implementations are probably not correct and only occur as mistakes in the compiler and standard library
- Fix a missing normalization call
- Adds spans for lifetime errors from overly general specializations

Closes #79457
Closes #109815
2023-05-09 12:33:46 +05:30
Dylan DPC
8c51701b8a
Rollup merge of #111120 - chenyukang:yukang-suggest-let, r=Nilstrieb
Suggest let for possible binding with ty

Origin from https://github.com/rust-lang/rust/pull/109128#discussion_r1179866137

r? `@Nilstrieb`
2023-05-09 12:33:46 +05:30
Dylan DPC
dbd090c655
Rollup merge of #110694 - est31:builtin, r=petrochenkov
Implement builtin # syntax and use it for offset_of!(...)

Add `builtin #` syntax to the parser, as well as a generic infrastructure to support both item and expression position builtin syntaxes. The PR also uses this infrastructure for the implementation of the `offset_of!` macro, added by #106934.

cc `@petrochenkov` `@DrMeepster`

cc #110680 `builtin #` tracking issue
cc #106655 `offset_of!` tracking issue
2023-05-09 12:33:45 +05:30
Dylan DPC
ff30b8cb7b
Rollup merge of #110583 - Ezrashaw:tweak-make-mut-spans, r=estebank
tweak "make mut" spans when assigning to locals

Work towards fixing #106857

This PR just cleans up a lot of spans which is helpful before properly fixing the issues. Best reviewed commit-by-commit.

r? `@estebank`
2023-05-09 12:33:45 +05:30
Dylan DPC
2ecc72217b
Rollup merge of #110504 - compiler-errors:tweak-borrow-sugg, r=cjgillot
Tweak borrow suggestion span

Avoids a `span_to_snippet` call when we don't need to surround the expression in parentheses. The fact that the suggestion was using the whole span of the expression rather than just appending a `&` was prevented me from using `// run-rustfix` in another PR (https://github.com/rust-lang/rust/pull/110432#discussion_r1170500484).

Also some drive-by renames of functions that have been annoying me for a bit.
2023-05-09 12:33:44 +05:30
Dylan DPC
02a85bd038
Rollup merge of #110304 - cchiw:master, r=davidtwco
Add GNU Property Note

Fix #103001

Generates the missing property note:
```
Displaying notes found in: .note.gnu.property
  Owner                Data size 	Description
  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0	      Properties: x86 feature: IBT
```
2023-05-09 12:33:44 +05:30
yukang
4d219d0666 move sugg to derive session diagnostic 2023-05-09 11:51:04 +08:00
Michael Goulet
5fcf2e6edc Revert "Populate effective visibilities in rustc_privacy"
This reverts commit cff85f22f5.
2023-05-08 21:47:44 +00:00
Tomasz Miąsko
83a5a69a4c Align unsized locals
Allocate an extra space for unsized locals and manually align the
storage, since alloca doesn't support dynamic alignment.
2023-05-08 23:40:51 +02:00
bors
2f2c438dce Auto merge of #111358 - compiler-errors:rollup-yv27vrp, r=compiler-errors
Rollup of 6 pull requests

Successful merges:

 - #104070 (Prevent aborting guard from aborting the process in a forced unwind)
 - #109410 (Introduce `AliasKind::Inherent` for inherent associated types)
 - #111004 (Migrate `mir_transform` to translatable diagnostics)
 - #111118 (Suggest struct when we get colon in fileds in enum)
 - #111170 (Diagnostic args are still args if they're documented)
 - #111354 (Fix miscompilation when calling default methods on `Future`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-08 21:00:50 +00:00
bors
dfe31889e1 Auto merge of #111007 - JakobDegen:nrvo, r=tmiasko
Disable nrvo mir opt

See #111005 and #110902 . The ICE can definitely be hit on stable, the miscompilation I'm not sure about. The pass makes some pretty sketchy assumptions though, and we should not have it on while that's the case.

I'm not going to work on actually fixing this, it's probably not excessively difficult though.

r? rust-lang/mir-opt
2023-05-08 18:10:26 +00:00
Josh Stone
c836c24994 Remove the ThinLTO CU hack
This reverts #46722, commit e0ab5d5feb.

Since #111167, commit 10b69dde3f, we are
generating DWARF subprograms in a way that is meant to be more compatible
with LLVM's expectations, so hopefully we don't need this workaround
rewriting CUs anymore.
2023-05-08 10:34:15 -07:00
Michael Goulet
bbea63f627
Rollup merge of #111354 - jonas-schievink:enable-future-combinators, r=compiler-errors
Fix miscompilation when calling default methods on `Future`

In https://github.com/rust-lang/rust/issues/111264 I discovered a lingering miscompilation when calling a default method on `Future` (none currently exist). https://github.com/rust-lang/rust/pull/111279 added a debug assertion, which sadly doesn't help much since to my knowledge stage0 is not built with them enabled, and it still doesn't make default methods work like they should.

This PR fixes `resolve_instance` to resolve default methods on `Future` correctly, allowing library contributors to add `Future` combinators without running into ICEs or miscompilations. I've tested this as part of https://github.com/rust-lang/rust/pull/111347, but no test is included here (assuming that future methods include their own tests that would cover this sufficiently).

r? `@compiler-errors`
2023-05-08 09:30:23 -07:00
Michael Goulet
24ba82de4e
Rollup merge of #111170 - compiler-errors:diag-doc, r=petrochenkov
Diagnostic args are still args if they're documented

Fixes https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.60.23.5Bderive.28Diagnostic.29.5D.60.20works.20badly.20with.20docs/near/355597997

There's a lot of really strange code incongruencies between `Diagnostic` and `Subdiagnostic` derive. Perhaps those macros need some more overhaul, but I didn't really want to do it today.
2023-05-08 09:30:23 -07:00
Michael Goulet
beb49671c2
Rollup merge of #111118 - chenyukang:yukang-sugg-struct, r=compiler-errors
Suggest struct when we get colon in fileds in enum

A follow-up fix for https://github.com/rust-lang/rust/pull/109128

From: https://github.com/rust-lang/rust/pull/109128#discussion_r1179304932

r? `@estebank`
2023-05-08 09:30:22 -07:00
Michael Goulet
68594142b1
Rollup merge of #111004 - clubby789:migrate-mir-transform, r=oli-obk
Migrate `mir_transform` to translatable diagnostics

cc #100717
2023-05-08 09:30:22 -07:00
Michael Goulet
29ac429c9b
Rollup merge of #109410 - fmease:iat-alias-kind-inherent, r=compiler-errors
Introduce `AliasKind::Inherent` for inherent associated types

Allows us to check (possibly generic) inherent associated types for well-formedness.
Type inference now also works properly.

Follow-up to #105961. Supersedes #108430.
Fixes #106722.
Fixes #108957.
Fixes #109768.
Fixes #109789.
Fixes #109790.

~Not to be merged before #108860 (`AliasKind::Weak`).~

CC `@jackh726`
r? `@compiler-errors`

`@rustbot` label T-types F-inherent_associated_types
2023-05-08 09:30:21 -07:00
Michael Goulet
fcb275f85e
Rollup merge of #104070 - nbdd0121:unwind, r=Amanieu
Prevent aborting guard from aborting the process in a forced unwind

Fix #101469
2023-05-08 09:30:21 -07:00
Jonas Schievink
3bbb69eaa0 Fix miscompilation when adding default method to Future 2023-05-08 17:06:48 +02:00
Oli Scherer
5c6e2342f6 Encode types in SMIR 2023-05-08 14:23:19 +00:00
bors
a0111af531 Auto merge of #110824 - cjgillot:const-prop-index, r=JakobDegen,oli-obk
ConstProp into PlaceElem::Index.

Noticed this while looking at keccak output MIR.

This pass aims to replace `ProjectionElem::Index` with `ProjectionElem::ConstantIndex` during ConstProp.

r? `@ghost`
2023-05-08 14:23:13 +00:00
Oli Scherer
7f74ae57e8 Create a trait to abstract over the smir API 2023-05-08 14:23:04 +00:00
Jakob Degen
8e2da80fc5 Disable nrvo mir opt 2023-05-08 03:55:41 -07:00
Yuki Okushi
2a8adcc966
Rollup merge of #111332 - loongarch-rs:inline-asm, r=Amanieu
Improve inline asm for LoongArch

This PR is a sub-part of https://github.com/rust-lang/rust/pull/111235, to improve inline asm for LoongArch.

r? `@Amanieu`
2023-05-08 19:41:51 +09:00
Yuki Okushi
c122ac3e69
Rollup merge of #111331 - taiki-e:s390x-asm-cc, r=Amanieu
Mark s390x condition code register as clobbered in inline assembly

Various s390x instructions (arithmetic operations, logical operations, comparisons, etc. see also "Condition Codes" section in [z/Architecture Reference Summary](https://www.ibm.com/support/pages/zarchitecture-reference-summary)) modify condition code register `cc`, but AFAIK there is currently no way to mark it as clobbered in `asm!`.

`cc` register definition in LLVM:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/SystemZ/SystemZRegisterInfo.td#L320

This PR also updates asm_experimental_arch docs in the unstable-book to mention s390x registers.

cc `@uweigand`

r? `@Amanieu`
2023-05-08 19:41:50 +09:00
Yuki Okushi
c145d93395
Rollup merge of #111211 - compiler-errors:negative-bounds-super, r=TaKO8Ki
Don't compute trait super bounds unless they're positive

Fixes #111207

The comment is modified to explain the rationale for why we even have this recursive call to supertraits in the first place, which doesn't apply to negative bounds since they don't elaborate at all.
2023-05-08 19:41:49 +09:00
Yuki Okushi
4df84a1e4e
Rollup merge of #110638 - nikarh:vita, r=Mark-Simulacrum
STD support for PSVita

This PR adds std support for `armv7-sony-vita-newlibeabihf` target.

The work here is fairly similar to #95897, just for a different target platform.

This depends on the following pull requests:

rust-lang/backtrace-rs#523
rust-lang/libc#3209
2023-05-08 19:41:49 +09:00
Yuki Okushi
c9b4c63e01
Rollup merge of #110377 - chrisnc:armv7-atomic-64, r=cjgillot
Update max_atomic_width of armv7r and armv7_sony_vita targets to 64.

All armv7a and armv7r implementations support `ldrexd`/`strexd`, only armv7m does not.
2023-05-08 19:41:48 +09:00
Yuki Okushi
e3eb6a87bf
Rollup merge of #105354 - BlackHoleFox:apple-deployment-printer, r=oli-obk
Add deployment-target --print flag for Apple targets

This is very useful for crates that need to know what the Apple OS deployment target is for their build scripts or inside of a build environment. Right now, the defaults just get copy/pasted around the ecosystem since they've been stable for so long. But with #104385 in progress, that won't be true anymore and everything will need to move. Ideally whenever it happens again, this could be less painful as everything can ask the compiler what its default is instead.

To show examples of the copy/paste proliferation, here's some crates and/or apps that do:
- [cc](https://github.com/rust-lang/cc-rs/pull/708/files), Soon
-  [mac-notification-sys](https://github.com/h4llow3En/mac-notification-sys/pull/46/files#diff-d0d98998092552a1d3259338c2c71e118a5b8343dd4703c0c7f552ada7f9cb42R10-R12)
- [PyO3](ccb02d1aa1/src/target.rs (L755-L758))
- [Anki](613b5c1034/build/runner/src/bundle/artifacts.rs (L49-L54))
- [jsc-rs](3776726756/xtask/src/build.rs (L402-L405))
... and probably more that a simple GitHub codesearch didn't see
2023-05-08 19:41:48 +09:00
bors
c86e7fb60f Auto merge of #111342 - Dylan-DPC:rollup-b5p6wzy, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #110297 (Make `(try_)subst_and_normalize_erasing_regions` take `EarlyBinder`)
 - #110827 (Fix lifetime suggestion for type aliases with objects in them)
 - #111022 (Use smaller ints for bitflags)
 - #111056 (Fix some suggestions where a `Box<T>` is expected.)
 - #111262 (Further normalize msvc-non-utf8-ouput)
 - #111265 (Make generics_of has_self on RPITITs delegate to the opaque)
 - #111323 (Give a more helpful error when running the rustc shim directly)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-08 07:35:30 +00:00
yukang
0e8703da3e make it more accurate by parsing ty 2023-05-08 15:07:36 +08:00
yukang
6b76588222 suggest struct when we get colon in fileds in enum 2023-05-08 14:58:09 +08:00
yukang
5e94b5faf1 code refactor and fix wrong suggestion 2023-05-08 14:56:36 +08:00
Taiki Endo
e61bb8810b Mark s390x condition code register as clobbered in inline assembly 2023-05-08 15:42:56 +09:00
Dylan DPC
940567068c
Rollup merge of #111265 - spastorino:has_self-opaque_ty, r=compiler-errors
Make generics_of has_self on RPITITs delegate to the opaque

r? `@compiler-errors`

I couldn't come up with a test case and none of the ones in the `tests` folder is impacted by this change, but I still think is the right thing to do.

Michael, let me know if you have ideas on how to add a test that's affected by this change.
2023-05-08 11:39:22 +05:30
Dylan DPC
aceb5d951b
Rollup merge of #111056 - JohnBobbo96:fix_box_suggestions, r=compiler-errors
Fix some suggestions where a `Box<T>` is expected.

This fixes #111011, and also adds a suggestion for boxing a unit type when a `Box<T>` was expected and an empty block was found.
2023-05-08 11:39:21 +05:30
Dylan DPC
c75543d648
Rollup merge of #111022 - Nilstrieb:smaller-bitflags, r=compiler-errors
Use smaller ints for bitflags

Free shrinking!
2023-05-08 11:39:21 +05:30
Dylan DPC
e04c9019f0
Rollup merge of #110827 - compiler-errors:issue-110761-followup, r=cjgillot
Fix lifetime suggestion for type aliases with objects in them

Fixes an issue identified in https://github.com/rust-lang/rust/issues/110761#issuecomment-1520678479

This suggestion, like many other borrowck suggestions, are very fragile and there are other ways to trigger strange behavior even after this PR, so this is just a small improvement and not a total rework 💀
2023-05-08 11:39:20 +05:30
Dylan DPC
71a1ac2c9a
Rollup merge of #110297 - kylematsuda:earlybinder_tcx_subst, r=BoxyUwU
Make `(try_)subst_and_normalize_erasing_regions` take `EarlyBinder`

Changes `subst_and_normalize_erasing_regions` and `try_subst_and_normalize_erasing_regions` to take  `EarlyBinder<T>` instead of `T`.

(related to #105779)

This was suggested by `@BoxyUwU` in https://github.com/rust-lang/rust/pull/107753#discussion_r1105828139. After changing `type_of` to return `EarlyBinder`, there were several places where the binder was immediately skipped to call `tcx.subst_and_normalize_erasing_regions`, only for the binder to be reconstructed inside of that method.

r? `@BoxyUwU`
2023-05-08 11:39:20 +05:30
bors
ea0c22ea4f Auto merge of #106621 - ozkanonur:enable-elided-lifetimes-for-doctests, r=Mark-Simulacrum
enable `rust_2018_idioms` lint group for doctests

With this change, `rust_2018_idioms` lint group will be enabled for compiler/libstd doctests.

Resolves #106086
Resolves #99144

Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-05-08 04:50:28 +00:00