]> git.lizzy.rs Git - rust.git/log
rust.git
20 months agoRollup merge of #104720 - notriddle:notriddle/popover-before-display-inline, r=Guilla...
Yuki Okushi [Tue, 22 Nov 2022 21:40:23 +0000 (06:40 +0900)]
Rollup merge of #104720 - notriddle:notriddle/popover-before-display-inline, r=GuillaumeGomez

rustdoc: remove no-op CSS `.popover::before / a.test-arrow { display: inline-block }`

Since this box is absolutely positioned, its display type is [blockified] anyway. We just need to make sure it isn't `display: none`.

[blockified]: https://www.w3.org/TR/css-display-3/#transformations

20 months agoRollup merge of #104717 - GuillaumeGomez:test-projection-used-as-const-generic, r...
Yuki Okushi [Tue, 22 Nov 2022 21:40:22 +0000 (06:40 +0900)]
Rollup merge of #104717 - GuillaumeGomez:test-projection-used-as-const-generic, r=oli-obk

Add failing test for projections used as const generic

Based on the experiment done in https://github.com/rust-lang/rust/pull/104443, we realized it's currently not possible to support projections in const generics. More information about it in https://github.com/rust-lang/rust/pull/104443#discussion_r1029375633.

This PR adds the UI test in any case so we can gather data in order to work towards adding `TyAlias` into the ABI in the future.

r? ``@oli-obk``

20 months agoRollup merge of #102293 - ecnelises:aix.initial, r=davidtwco
Yuki Okushi [Tue, 22 Nov 2022 21:40:22 +0000 (06:40 +0900)]
Rollup merge of #102293 - ecnelises:aix.initial, r=davidtwco

Add powerpc64-ibm-aix as Tier-3 target

This is part of the effort mentioned in https://github.com/rust-lang/compiler-team/issues/553.

A reference to these options are definitions from [clang](https://github.com/llvm/llvm-project/blob/ad6fe32032a6229e0c40510e9bed419a01c695b3/clang/lib/Basic/Targets/PPC.h#L414-L448) and [llvm](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp).

AIX has a system `ld` but [its options and behaviors](https://www.ibm.com/docs/en/aix/7.3?topic=l-ld-command) are different from GNU ld. Thanks to ``@bzEq`` for contributing the linking args.

20 months agoRollup merge of #101368 - thomcc:wintls-noinline, r=ChrisDenton
Yuki Okushi [Tue, 22 Nov 2022 21:40:21 +0000 (06:40 +0900)]
Rollup merge of #101368 - thomcc:wintls-noinline, r=ChrisDenton

Forbid inlining `thread_local!`'s `__getit` function on Windows

Sadly, this will make things slower to avoid UB in an edge case, but it seems hard to avoid... and really whenever I look at this code I can't help but think we're asking for trouble.

It's pretty dodgy for us to leave this as a normal function rather than `#[inline(never)]`, given that if it *does* get inlined into a dynamically linked component, it's extremely unsafe (you get some other thread local, or if you're lucky, crash). Given that it's pretty rare for people to use dylibs on Windows, the fact that we haven't gotten bug reports about it isn't really that convincing. Ideally we'd come up with some kind of compiler solution (that avoids paying for this cost when static linking, or *at least* for use within the same crate...), but it's not clear what that looks like.

Oh, and because all this is only needed when we're implementing `thread_local!` with `#[thread_local]`, this patch adjusts the `cfg_attr` to be `all(windows, target_thread_local)` as well.

r? ``@ChrisDenton``

See also #84933, which is about improving the situation.

20 months agoAuto merge of #104688 - flip1995:clippyup, r=Manishearth,flip1995
bors [Tue, 22 Nov 2022 17:09:06 +0000 (17:09 +0000)]
Auto merge of #104688 - flip1995:clippyup, r=Manishearth,flip1995

Update Clippy

r? `@Manishearth`

Sorry for taking so long. There were so many blockers and so little time. This situation should be mitigated with #104007 in the future.

20 months agorustdoc: remove no-op CSS `a.test-arrow { display: inline-block }`
Michael Howell [Tue, 22 Nov 2022 16:06:24 +0000 (09:06 -0700)]
rustdoc: remove no-op CSS `a.test-arrow { display: inline-block }`

Since this box is absolutely positioned, its display type is [blockified]
anyway. We just need to make sure it isn't `display: none`.

[blockified]: https://www.w3.org/TR/css-display-3/#transformations

20 months agorustdoc: remove no-op CSS `.popover::before { display: inline-block }`
Michael Howell [Tue, 22 Nov 2022 15:21:10 +0000 (08:21 -0700)]
rustdoc: remove no-op CSS `.popover::before { display: inline-block }`

Since this box is absolutely positioned, its display type is [blockified]
anyway. We just need to make sure it isn't `display: none`.

[blockified]: https://www.w3.org/TR/css-display-3/#transformations

20 months agoAdd failing test for projections used as const generic
Guillaume Gomez [Tue, 22 Nov 2022 15:02:37 +0000 (16:02 +0100)]
Add failing test for projections used as const generic

20 months agoClippy: Workaround for let_chains issue
Philipp Krones [Tue, 22 Nov 2022 13:30:29 +0000 (14:30 +0100)]
Clippy: Workaround for let_chains issue

20 months agoAuto merge of #104711 - Dylan-DPC:rollup-gkw1qr8, r=Dylan-DPC
bors [Tue, 22 Nov 2022 13:18:45 +0000 (13:18 +0000)]
Auto merge of #104711 - Dylan-DPC:rollup-gkw1qr8, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #104295 (Check generics parity before collecting return-position `impl Trait`s in trait)
 - #104464 (Reduce exceptions overallocation on non Windows x86_64)
 - #104615 (Create def_id for async fns during lowering)
 - #104669 (Only declare bindings for if-let guards once per arm)
 - #104701 (Remove a lifetime resolution hack from `compare_predicate_entailment`)
 - #104710 (disable strict-provenance-violating doctests in Miri)

Failed merges:

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

20 months agoRollup merge of #104710 - RalfJung:doc-strict-provenance, r=thomcc
Dylan DPC [Tue, 22 Nov 2022 11:06:39 +0000 (16:36 +0530)]
Rollup merge of #104710 - RalfJung:doc-strict-provenance, r=thomcc

disable strict-provenance-violating doctests in Miri

Most of these are on deprecated unstable functions anyway. This lets us run the remaining doctests with `-Zmiri-strict-provenance`, which I think is a win.

r? `@thomcc`

20 months agoRollup merge of #104701 - compiler-errors:rpitit-remove-reempty-hack, r=TaKO8Ki
Dylan DPC [Tue, 22 Nov 2022 11:06:38 +0000 (16:36 +0530)]
Rollup merge of #104701 - compiler-errors:rpitit-remove-reempty-hack, r=TaKO8Ki

Remove a lifetime resolution hack from `compare_predicate_entailment`

This is not needed anymore, probably due to #102334 equating the function signatures fully in `collect_trait_impl_trait_tys`. Also, the assertion in in #102903 makes sure that this is actually fixed, so I'm pretty confident this isn't needed.

20 months agoRollup merge of #104669 - LeSeulArtichaut:88015-if-let-guard-bindings, r=cjgillot
Dylan DPC [Tue, 22 Nov 2022 11:06:38 +0000 (16:36 +0530)]
Rollup merge of #104669 - LeSeulArtichaut:88015-if-let-guard-bindings, r=cjgillot

Only declare bindings for if-let guards once per arm

Currently, each candidate for a match arm uses separate locals for the bindings in the if-let guard, causing problems (#88015) when those branches converge in the arm body.

Fixes #88015 (🤞)

20 months agoRollup merge of #104615 - spastorino:create-async-def-id-in-lowering, r=compiler...
Dylan DPC [Tue, 22 Nov 2022 11:06:37 +0000 (16:36 +0530)]
Rollup merge of #104615 - spastorino:create-async-def-id-in-lowering, r=compiler-errors

Create def_id for async fns during lowering

r? `@compiler-errors`

20 months agoRollup merge of #104464 - mati865:reduce-eh-overallocation-amd64, r=thomcc
Dylan DPC [Tue, 22 Nov 2022 11:06:37 +0000 (16:36 +0530)]
Rollup merge of #104464 - mati865:reduce-eh-overallocation-amd64, r=thomcc

Reduce exceptions overallocation on non Windows x86_64

Addressing https://github.com/rust-lang/rust/pull/103894#discussion_r1020950196

20 months agoRollup merge of #104295 - compiler-errors:rpitit-generics-parity, r=eholk
Dylan DPC [Tue, 22 Nov 2022 11:06:36 +0000 (16:36 +0530)]
Rollup merge of #104295 - compiler-errors:rpitit-generics-parity, r=eholk

Check generics parity before collecting return-position `impl Trait`s in trait

The only thing is that this duplicates the error message for number of generics mismatch, but we already deduplicate that error message in Cargo. I could add a flag to delay the error if the reviewer cares.

Fixes #104281

Also drive-by adds a few comments to the `collect_trait_impl_trait_tys` method, and removes an unused argument from `compare_number_of_generics`.

20 months agodisable strict-provenance-violating doctests in Miri
Ralf Jung [Tue, 22 Nov 2022 10:28:35 +0000 (11:28 +0100)]
disable strict-provenance-violating doctests in Miri

20 months agoAuto merge of #103578 - petrochenkov:nofict, r=nagisa
bors [Tue, 22 Nov 2022 10:17:09 +0000 (10:17 +0000)]
Auto merge of #103578 - petrochenkov:nofict, r=nagisa

Unreserve braced enum variants in value namespace

With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed.

Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.

20 months agoForbid inlining `thread_local!`'s `__getit` function on Windows
Thom Chiovoloni [Sat, 3 Sep 2022 07:28:03 +0000 (00:28 -0700)]
Forbid inlining `thread_local!`'s `__getit` function on Windows

20 months agoAuto merge of #104702 - Manishearth:rollup-75hagzd, r=Manishearth
bors [Tue, 22 Nov 2022 07:15:48 +0000 (07:15 +0000)]
Auto merge of #104702 - Manishearth:rollup-75hagzd, r=Manishearth

Rollup of 7 pull requests

Successful merges:

 - #83608 (Add slice methods for indexing via an array of indices.)
 - #95583 (Deprecate the unstable `ptr_to_from_bits` feature)
 - #101655 (Make the Box one-liner more descriptive)
 - #102207 (Constify remaining `Layout` methods)
 - #103193 (mark sys_common::once::generic::Once::new const-stable)
 - #104622 (Use clang for the UEFI targets)
 - #104638 (Move macro_rules diagnostics to diagnostics module)

Failed merges:

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

20 months agoRollup merge of #104638 - Nilstrieb:macro-diagnostics, r=compiler-errors
Manish Goregaokar [Tue, 22 Nov 2022 06:26:08 +0000 (01:26 -0500)]
Rollup merge of #104638 - Nilstrieb:macro-diagnostics, r=compiler-errors

Move macro_rules diagnostics to diagnostics module

This will make it easier to add more diagnostics in the future in a centralized place.

20 months agoRollup merge of #104622 - nicholasbishop:bishop-uefi-clang, r=Mark-Simulacrum
Manish Goregaokar [Tue, 22 Nov 2022 06:26:08 +0000 (01:26 -0500)]
Rollup merge of #104622 - nicholasbishop:bishop-uefi-clang, r=Mark-Simulacrum

Use clang for the UEFI targets

This fixes an issue where the C and asm sources built by compiler_builtins were being compiled as ELF objects instead of PE objects. This wasn't noticed before because it doesn't cause compiler_builtins or rustc to fail to build. You only see a failure when a program is built that references one of the symbols in an ELF object.

Compiling with clang fixes this because the cc crate converts the UEFI targets into Windows targets that clang understands, causing it to produce PE objects.

Also update compiler_builtins to 0.1.84 to pull in some necessary fixes for compiling the UEFI targets with clang.

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

20 months agoRollup merge of #103193 - krasimirgg:sysonce, r=Amanieu
Manish Goregaokar [Tue, 22 Nov 2022 06:26:07 +0000 (01:26 -0500)]
Rollup merge of #103193 - krasimirgg:sysonce, r=Amanieu

mark sys_common::once::generic::Once::new const-stable

Attempt to address https://github.com/rust-lang/rust/issues/103191 by marking the impl const-stable.
Picked the declaration from the callsite:
https://github.com/rust-lang/rust/blob/21b246587c2687935bd6004ffa5dcc4f4dd6600d/library/std/src/sync/once.rs#L67

This is similar to https://github.com/rust-lang/rust/pull/98457.

With this in, `python3 x.py build library/std --target x86_64-unknown-none` succeeds.

20 months agoRollup merge of #102207 - CraftSpider:const-layout, r=scottmcm
Manish Goregaokar [Tue, 22 Nov 2022 06:26:07 +0000 (01:26 -0500)]
Rollup merge of #102207 - CraftSpider:const-layout, r=scottmcm

Constify remaining `Layout` methods

Makes the methods on `Layout` that aren't yet unstably const, under the same feature and issue, #67521. Most of them required no changes, only non-trivial change is probably constifying `ValidAlignment` which may affect #102072

20 months agoRollup merge of #101655 - dns2utf8:box_docs, r=dtolnay
Manish Goregaokar [Tue, 22 Nov 2022 06:26:06 +0000 (01:26 -0500)]
Rollup merge of #101655 - dns2utf8:box_docs, r=dtolnay

Make the Box one-liner more descriptive

I would like to avoid a definition that relies on itself.

r? `@GuillaumeGomez`

20 months agoRollup merge of #95583 - scottmcm:deprecate-ptr-to-from-bits, r=dtolnay
Manish Goregaokar [Tue, 22 Nov 2022 06:26:05 +0000 (01:26 -0500)]
Rollup merge of #95583 - scottmcm:deprecate-ptr-to-from-bits, r=dtolnay

Deprecate the unstable `ptr_to_from_bits` feature

I propose that we deprecate the (unstable!) `to_bits` and `from_bits` methods on raw pointers.  (With the intent to ~~remove them once `addr` has been around long enough to make the transition easy on people -- maybe another 6 weeks~~ remove them fairly soon after, as the strict and expose versions have been around for a while already.)

The APIs that came from the strict provenance explorations (#95228) are a more holistic version of these, and things like `.expose_addr()` work for the "that cast looks sketchy" case even if the full strict provenance stuff never happens.  (As a bonus, `addr` is even shorter than `to_bits`, though it is only applicable if people can use full strict provenance! `addr` is *not* a direct replacement for `to_bits`.)  So I think it's fine to move away from the `{to|from}_bits` methods, and encourage the others instead.

That also resolves the worry that was brought up (I forget where) that `q.to_bits()` and `(*q).to_bits()` both work if `q` is a pointer-to-floating-point, as they also have a `to_bits` method.

Tracking issue #91126
Code search: https://github.com/search?l=Rust&p=1&q=ptr_to_from_bits&type=Code

For potential pushback, some users in case they want to chime in
- `@RSSchermer` https://github.com/RSSchermer/ARWA/blob/365bb68541447453fc44f6fbcc5d394bb94c14e9/arwa/src/html/custom_element.rs#L105
- `@strax` https://github.com/strax/pbr/blob/99616d1dbf42f93ec8dd668d05b3180649558180/openexr/src/core/alloc.rs#L36
- `@MiSawa` https://github.com/MiSawa/pomelo/blob/577c6223588d539295a71ff125d8f249e59f4146/crates/kernel/src/timer.rs#L50

20 months agoRollup merge of #83608 - Kimundi:index_many, r=Mark-Simulacrum
Manish Goregaokar [Tue, 22 Nov 2022 06:26:05 +0000 (01:26 -0500)]
Rollup merge of #83608 - Kimundi:index_many, r=Mark-Simulacrum

Add slice methods for indexing via an array of indices.

Disclaimer: It's been a while since I contributed to the main Rust repo, apologies in advance if this is large enough already that it should've been an RFC.

---

# Update:

- Based on feedback, removed the `&[T]` variant of this API, and removed the requirements for the indices to be sorted.

# Description

This adds the following slice methods to `core`:

```rust
impl<T> [T] {
    pub unsafe fn get_many_unchecked_mut<const N: usize>(&mut self, indices: [usize; N]) -> [&mut T; N];
    pub fn get_many_mut<const N: usize>(&mut self, indices: [usize; N]) -> Option<[&mut T; N]>;
}
```

This allows creating multiple mutable references to disjunct positions in a slice, which previously required writing some awkward code with `split_at_mut()` or `iter_mut()`. For the bound-checked variant, the indices are checked against each other and against the bounds of the slice, which requires `N * (N + 1) / 2` comparison operations.

This has a proof-of-concept standalone implementation here: https://crates.io/crates/index_many

Care has been taken that the implementation passes miri borrow checks, and generates straight-forward assembly (though this was only checked on x86_64).

# Example

```rust
let v = &mut [1, 2, 3, 4];
let [a, b] = v.get_many_mut([0, 2]).unwrap();
std::mem::swap(a, b);
*v += 100;
assert_eq!(v, &[3, 2, 101, 4]);
```

# Codegen Examples

<details>
  <summary>Click to expand!</summary>

Disclaimer: Taken from local tests with the standalone implementation.

## Unchecked Indexing:

```rust
pub unsafe fn example_unchecked(slice: &mut [usize], indices: [usize; 3]) -> [&mut usize; 3] {
    slice.get_many_unchecked_mut(indices)
}
```

```nasm
example_unchecked:
 mov     rcx, qword, ptr, [r9]
 mov     r8, qword, ptr, [r9, +, 8]
 mov     r9, qword, ptr, [r9, +, 16]
 lea     rcx, [rdx, +, 8*rcx]
 lea     r8, [rdx, +, 8*r8]
 lea     rdx, [rdx, +, 8*r9]
 mov     qword, ptr, [rax], rcx
 mov     qword, ptr, [rax, +, 8], r8
 mov     qword, ptr, [rax, +, 16], rdx
 ret
```

## Checked Indexing (Option):

```rust
pub unsafe fn example_option(slice: &mut [usize], indices: [usize; 3]) -> Option<[&mut usize; 3]> {
    slice.get_many_mut(indices)
}
```

```nasm
 mov     r10, qword, ptr, [r9, +, 8]
 mov     rcx, qword, ptr, [r9, +, 16]
 cmp     rcx, r10
 je      .LBB0_7
 mov     r9, qword, ptr, [r9]
 cmp     rcx, r9
 je      .LBB0_7
 cmp     rcx, r8
 jae     .LBB0_7
 cmp     r10, r9
 je      .LBB0_7
 cmp     r9, r8
 jae     .LBB0_7
 cmp     r10, r8
 jae     .LBB0_7
 lea     r8, [rdx, +, 8*r9]
 lea     r9, [rdx, +, 8*r10]
 lea     rcx, [rdx, +, 8*rcx]
 mov     qword, ptr, [rax], r8
 mov     qword, ptr, [rax, +, 8], r9
 mov     qword, ptr, [rax, +, 16], rcx
 ret
.LBB0_7:
 mov     qword, ptr, [rax], 0
 ret
```

## Checked Indexing (Panic):

```rust
pub fn example_panic(slice: &mut [usize], indices: [usize; 3]) -> [&mut usize; 3] {
    let len = slice.len();
    match slice.get_many_mut(indices) {
        Some(s) => s,
        None => {
            let tmp = indices;
            index_many::sorted_bound_check_failed(&tmp, len)
        }
    }
}
```

```nasm
example_panic:
 sub     rsp, 56
 mov     rax, qword, ptr, [r9]
 mov     r10, qword, ptr, [r9, +, 8]
 mov     r9, qword, ptr, [r9, +, 16]
 cmp     r9, r10
 je      .LBB0_6
 cmp     r9, rax
 je      .LBB0_6
 cmp     r9, r8
 jae     .LBB0_6
 cmp     r10, rax
 je      .LBB0_6
 cmp     rax, r8
 jae     .LBB0_6
 cmp     r10, r8
 jae     .LBB0_6
 lea     rax, [rdx, +, 8*rax]
 lea     r8, [rdx, +, 8*r10]
 lea     rdx, [rdx, +, 8*r9]
 mov     qword, ptr, [rcx], rax
 mov     qword, ptr, [rcx, +, 8], r8
 mov     qword, ptr, [rcx, +, 16], rdx
 mov     rax, rcx
 add     rsp, 56
 ret
.LBB0_6:
 mov     qword, ptr, [rsp, +, 32], rax
 mov     qword, ptr, [rsp, +, 40], r10
 mov     qword, ptr, [rsp, +, 48], r9
 lea     rcx, [rsp, +, 32]
 mov     edx, 3
 call    index_many::bound_check_failed
 ud2
```
</details>

# Extensions

There are multiple optional extensions to this.

## Indexing With Ranges

This could easily be expanded to allow indexing with `[I; N]` where `I: SliceIndex<Self>`.  I wanted to keep the initial implementation simple, so I didn't include it yet.

## Panicking Variant

We could also add this method:

```rust
impl<T> [T] {
    fn index_many_mut<const N: usize>(&mut self, indices: [usize; N]) -> [&mut T; N];
}
```

This would work similar to the regular index operator and panic with out-of-bound indices. The advantage would be that we could more easily ensure good codegen with a useful panic message, which is non-trivial with the `Option` variant.

This is implemented in the standalone implementation, and used as basis for the codegen examples here and there.

20 months agoRemove a hack from compare_predicate_entailment
Michael Goulet [Tue, 22 Nov 2022 02:22:33 +0000 (02:22 +0000)]
Remove a hack from compare_predicate_entailment

20 months agoDelay bug to deduplicate diagnostics
Michael Goulet [Tue, 22 Nov 2022 01:36:35 +0000 (01:36 +0000)]
Delay bug to deduplicate diagnostics

20 months agodrive-by: style nits
Michael Goulet [Tue, 15 Nov 2022 04:06:40 +0000 (04:06 +0000)]
drive-by: style nits

20 months agoCheck generics parity between impl and trait before collecting RPITITs
Michael Goulet [Fri, 11 Nov 2022 17:36:16 +0000 (17:36 +0000)]
Check generics parity between impl and trait before collecting RPITITs

20 months agoAuto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgr
bors [Tue, 22 Nov 2022 01:35:57 +0000 (01:35 +0000)]
Auto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgr

Rollup of 11 pull requests

Successful merges:

 - #103396 (Pin::new_unchecked: discuss pinning closure captures)
 - #104416 (Fix using `include_bytes` in pattern position)
 - #104557 (Add a test case for async dyn* traits)
 - #104559 (Split `MacArgs` in two.)
 - #104597 (Probe + better error messsage for `need_migrate_deref_output_trait_object`)
 - #104656 (Move tests)
 - #104657 (Do not check transmute if has non region infer)
 - #104663 (rustdoc: factor out common button CSS)
 - #104666 (Migrate alias search result to CSS variables)
 - #104674 (Make negative_impl and negative_impl_exists take the right types)
 - #104692 (Update test's cfg-if dependency to 1.0)

Failed merges:

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

20 months agoTouch up Box<T> one-liner
David Tolnay [Mon, 21 Nov 2022 23:28:41 +0000 (15:28 -0800)]
Touch up Box<T> one-liner

20 months agoRustc_deprecated attribute superseded by deprecated
David Tolnay [Mon, 21 Nov 2022 23:18:36 +0000 (15:18 -0800)]
Rustc_deprecated attribute superseded by deprecated

20 months agoBump ptr_to_from_bits deprecation to Rust 1.67
David Tolnay [Mon, 21 Nov 2022 23:10:59 +0000 (15:10 -0800)]
Bump ptr_to_from_bits deprecation to Rust 1.67

20 months agoRollup merge of #104692 - chbaker0:libtest-cfg-if, r=thomcc
Matthias Krüger [Mon, 21 Nov 2022 23:01:12 +0000 (00:01 +0100)]
Rollup merge of #104692 - chbaker0:libtest-cfg-if, r=thomcc

Update test's cfg-if dependency to 1.0

This change was mistakenly left out of #103367

Finishes #103365

20 months agoRollup merge of #104674 - spastorino:negative-impl-tcx, r=lcnr
Matthias Krüger [Mon, 21 Nov 2022 23:01:12 +0000 (00:01 +0100)]
Rollup merge of #104674 - spastorino:negative-impl-tcx, r=lcnr

Make negative_impl and negative_impl_exists take the right types

r? `@lcnr`

20 months agoRollup merge of #104666 - GuillaumeGomez:migrate-alias-search-result, r=notriddle
Matthias Krüger [Mon, 21 Nov 2022 23:01:11 +0000 (00:01 +0100)]
Rollup merge of #104666 - GuillaumeGomez:migrate-alias-search-result, r=notriddle

Migrate alias search result to CSS variables

r? `@notriddle`

20 months agoRollup merge of #104663 - notriddle:notriddle/button-cursor, r=GuillaumeGomez
Matthias Krüger [Mon, 21 Nov 2022 23:01:11 +0000 (00:01 +0100)]
Rollup merge of #104663 - notriddle:notriddle/button-cursor, r=GuillaumeGomez

rustdoc: factor out common button CSS

20 months agoRollup merge of #104657 - hi-rustin:rustin-patch-check-transmute, r=compiler-errors
Matthias Krüger [Mon, 21 Nov 2022 23:01:10 +0000 (00:01 +0100)]
Rollup merge of #104657 - hi-rustin:rustin-patch-check-transmute, r=compiler-errors

Do not check transmute if has non region infer

close https://github.com/rust-lang/rust/issues/104609

See: https://github.com/rust-lang/rust/issues/104609#issuecomment-1320956351

r? `@compiler-errors`

20 months agoRollup merge of #104656 - c410-f3r:moar-errors, r=petrochenkov
Matthias Krüger [Mon, 21 Nov 2022 23:01:10 +0000 (00:01 +0100)]
Rollup merge of #104656 - c410-f3r:moar-errors, r=petrochenkov

Move tests

r? `@petrochenkov`

20 months agoRollup merge of #104597 - compiler-errors:need_migrate_deref_output_trait_object...
Matthias Krüger [Mon, 21 Nov 2022 23:01:09 +0000 (00:01 +0100)]
Rollup merge of #104597 - compiler-errors:need_migrate_deref_output_trait_object-msg, r=eholk

Probe + better error messsage for `need_migrate_deref_output_trait_object`

1. Use `InferCtxt::probe` in `need_migrate_deref_output_trait_object` -- that normalization *could* technically do type inference as a side-effect, and this is a lint, so it should have no side-effects.
2. Return the trait-ref so we format the error message correctly. See the UI test change -- `(dyn A + 'static)` is not a trait.

20 months agoRollup merge of #104559 - nnethercote:split-MacArgs, r=petrochenkov
Matthias Krüger [Mon, 21 Nov 2022 23:01:09 +0000 (00:01 +0100)]
Rollup merge of #104559 - nnethercote:split-MacArgs, r=petrochenkov

Split `MacArgs` in two.

`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways:
- For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used.
- For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used.

In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`).

This commit splits `MacArgs` in two:
- `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`.
- `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`.

Various other related things are renamed as well.

These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.

r? `@petrochenkov`

20 months agoRollup merge of #104557 - eholk:dyn-star-in-traits, r=compiler-errors
Matthias Krüger [Mon, 21 Nov 2022 23:01:08 +0000 (00:01 +0100)]
Rollup merge of #104557 - eholk:dyn-star-in-traits, r=compiler-errors

Add a test case for async dyn* traits

This adds a test case that approximates async functions in dyn traits using `dyn*`. The purpose is to have an example of where we are with `dyn*` and the goal of using it for dyn traits.

Issue #102425

r? `@compiler-errors`

20 months agoRollup merge of #104416 - clubby789:fix-104414, r=eholk
Matthias Krüger [Mon, 21 Nov 2022 23:01:07 +0000 (00:01 +0100)]
Rollup merge of #104416 - clubby789:fix-104414, r=eholk

Fix using `include_bytes` in pattern position

Fix #104414

20 months agoRollup merge of #103396 - RalfJung:pinning-closure-captures, r=dtolnay
Matthias Krüger [Mon, 21 Nov 2022 23:01:06 +0000 (00:01 +0100)]
Rollup merge of #103396 - RalfJung:pinning-closure-captures, r=dtolnay

Pin::new_unchecked: discuss pinning closure captures

Regardless of how the discussion in https://github.com/rust-lang/rust/pull/102737 turns out, pinning closure captures is super subtle business and probably worth discussing separately.

20 months agoSplit `MacArgs` in two.
Nicholas Nethercote [Fri, 18 Nov 2022 00:24:21 +0000 (11:24 +1100)]
Split `MacArgs` in two.

`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's
used in two ways:
- For representing attribute macro arguments (e.g. in `AttrItem`), where all
  three variants are used.
- For representing function-like macros (e.g. in `MacCall` and `MacroDef`),
  where only the `Delimited` variant is used.

In other words, `MacArgs` is used in two quite different places due to them
having partial overlap. I find this makes the code hard to read. It also leads
to various unreachable code paths, and allows invalid values (such as
accidentally using `MacArgs::Empty` in a `MacCall`).

This commit splits `MacArgs` in two:
- `DelimArgs` is a new struct just for the "delimited arguments" case. It is
  now used in `MacCall` and `MacroDef`.
- `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro
  case. Its `Delimited` variant now contains a `DelimArgs`.

Various other related things are renamed as well.

These changes make the code clearer, avoids several unreachable paths, and
disallows the invalid values.

20 months agoAuto merge of #104533 - oli-obk:method_callee, r=lcnr
bors [Mon, 21 Nov 2022 21:51:00 +0000 (21:51 +0000)]
Auto merge of #104533 - oli-obk:method_callee, r=lcnr

Clean up and harden various methods around trait substs

r? `@lcnr`

20 months agoUpdate test's cfg-if dependency to 1.0
Collin Baker [Mon, 21 Nov 2022 21:43:34 +0000 (16:43 -0500)]
Update test's cfg-if dependency to 1.0

This change was mistakenly left out of #103367

20 months agomerge self type and substs in `trait_method`
Oli Scherer [Mon, 21 Nov 2022 15:59:15 +0000 (15:59 +0000)]
merge self type and substs in `trait_method`

20 months agoSimplify one more `TraitRef::new` site
Oli Scherer [Mon, 21 Nov 2022 15:55:37 +0000 (15:55 +0000)]
Simplify one more `TraitRef::new` site

20 months agoSimplify test
Oli Scherer [Mon, 21 Nov 2022 15:52:18 +0000 (16:52 +0100)]
Simplify test

Co-authored-by: lcnr <rust@lcnr.de>
20 months agoUse `as_closure` helper method
Oli Scherer [Mon, 21 Nov 2022 15:52:01 +0000 (16:52 +0100)]
Use `as_closure` helper method

Co-authored-by: lcnr <rust@lcnr.de>
20 months agoStop passing the self-type as a separate argument.
Oli Scherer [Mon, 21 Nov 2022 12:24:53 +0000 (12:24 +0000)]
Stop passing the self-type as a separate argument.

20 months agoFix clippy's missing substs
Oli Scherer [Fri, 18 Nov 2022 19:58:07 +0000 (19:58 +0000)]
Fix clippy's missing substs

20 months agoRemove some unnecessary slicing
Oli Scherer [Thu, 17 Nov 2022 16:05:41 +0000 (16:05 +0000)]
Remove some unnecessary slicing

20 months agoRemove a redundant assert
Oli Scherer [Thu, 17 Nov 2022 15:39:11 +0000 (15:39 +0000)]
Remove a redundant assert

20 months agoFix an ICE that I just made worse
Oli Scherer [Thu, 17 Nov 2022 15:30:42 +0000 (15:30 +0000)]
Fix an ICE that I just made worse

20 months agoFor lcnr
Oli Scherer [Thu, 17 Nov 2022 15:23:07 +0000 (15:23 +0000)]
For lcnr

20 months agoAdd helper to create the trait ref for a lang item
Oli Scherer [Thu, 17 Nov 2022 14:39:19 +0000 (14:39 +0000)]
Add helper to create the trait ref for a lang item

20 months agoSome cleanup around trait_method lookup
Oli Scherer [Thu, 17 Nov 2022 13:28:32 +0000 (13:28 +0000)]
Some cleanup around trait_method lookup

20 months agoUse iterators instead of slices at more sites
Oli Scherer [Thu, 17 Nov 2022 13:06:37 +0000 (13:06 +0000)]
Use iterators instead of slices at more sites

20 months agoAllow iterators instead of requiring slices that will get turned into iterators
Oli Scherer [Thu, 17 Nov 2022 13:00:35 +0000 (13:00 +0000)]
Allow iterators instead of requiring slices that will get turned into iterators

20 months agoRemove an unnecessary query + subst round
Oli Scherer [Thu, 17 Nov 2022 12:07:31 +0000 (12:07 +0000)]
Remove an unnecessary query + subst round

20 months agoAdd a helper for replacing the self type in trait refs
Oli Scherer [Thu, 17 Nov 2022 11:55:27 +0000 (11:55 +0000)]
Add a helper for replacing the self type in trait refs

20 months agoAssert that various types have the right amount of generic args and fix the sites...
Oli Scherer [Thu, 17 Nov 2022 11:21:39 +0000 (11:21 +0000)]
Assert that various types have the right amount of generic args and fix the sites that used the wrong amount

20 months agoSplit out the actual predicate solving code into a separate function
Oli Scherer [Thu, 17 Nov 2022 10:36:18 +0000 (10:36 +0000)]
Split out the actual predicate solving code into a separate function

20 months agoUse ty::List instead of InternalSubsts
Oli Scherer [Thu, 17 Nov 2022 10:24:55 +0000 (10:24 +0000)]
Use ty::List instead of InternalSubsts

20 months agoCheck that type_implements_trait actually is passed the right amount of generic params
Oli Scherer [Thu, 17 Nov 2022 10:22:44 +0000 (10:22 +0000)]
Check that type_implements_trait actually is passed the right amount of generic params

20 months agoReduce the amount of passed-around arguments that will get merged into one later...
Oli Scherer [Thu, 17 Nov 2022 09:03:27 +0000 (09:03 +0000)]
Reduce the amount of passed-around arguments that will get merged into one later anyway

20 months agoClippy: Don't import GenericParamDefKind
Philipp Krones [Mon, 21 Nov 2022 20:04:59 +0000 (21:04 +0100)]
Clippy: Don't import GenericParamDefKind

20 months agoFix declare_clippy_lint crate
Philipp Krones [Mon, 21 Nov 2022 19:52:12 +0000 (20:52 +0100)]
Fix declare_clippy_lint crate

20 months agoUpdate Cargo.lock
Philipp Krones [Mon, 21 Nov 2022 19:52:06 +0000 (20:52 +0100)]
Update Cargo.lock

20 months agoMerge commit 'f4850f7292efa33759b4f7f9b7621268979e9914' into clippyup
Philipp Krones [Mon, 21 Nov 2022 19:34:47 +0000 (20:34 +0100)]
Merge commit 'f4850f7292efa33759b4f7f9b7621268979e9914' into clippyup

20 months agoUnreserve braced enum variants in value namespace
Vadim Petrochenkov [Tue, 25 Oct 2022 16:15:15 +0000 (20:15 +0400)]
Unreserve braced enum variants in value namespace

20 months agoAuto merge of #9881 - flip1995:rustup, r=flip1995
bors [Mon, 21 Nov 2022 19:16:14 +0000 (19:16 +0000)]
Auto merge of #9881 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

It took >4 weeks, but I finally got to do the sync 🎉

changelog: none

20 months agoFix custom ICE message test on windows
Philipp Krones [Mon, 21 Nov 2022 19:15:50 +0000 (20:15 +0100)]
Fix custom ICE message test on windows

20 months agopass clippy sysroot env if given r=ozkanonur
ozkanonur [Sat, 19 Nov 2022 23:40:31 +0000 (02:40 +0300)]
pass clippy sysroot env if given r=ozkanonur

Signed-off-by: ozkanonur <work@onurozkan.dev>
20 months agoBump nightly version -> 2022-11-21
Philipp Krones [Mon, 21 Nov 2022 19:02:14 +0000 (20:02 +0100)]
Bump nightly version -> 2022-11-21

20 months agoBump Clippy version -> 0.1.67
Philipp Krones [Mon, 21 Nov 2022 19:02:06 +0000 (20:02 +0100)]
Bump Clippy version -> 0.1.67

20 months agoMerge remote-tracking branch 'upstream/master' into rustup
Philipp Krones [Mon, 21 Nov 2022 18:59:07 +0000 (19:59 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

20 months agoAuto merge of #104120 - mejrs:diag, r=davidtwco
bors [Mon, 21 Nov 2022 18:36:26 +0000 (18:36 +0000)]
Auto merge of #104120 - mejrs:diag, r=davidtwco

Match and enforce crate and slug names

Some of these were in the wrong place or had a name that didn't match.

20 months agoCoercions work now
Eric Holk [Mon, 21 Nov 2022 18:20:12 +0000 (10:20 -0800)]
Coercions work now

20 months agoAdd a test case for async dyn* traits
Eric Holk [Fri, 18 Nov 2022 00:03:55 +0000 (16:03 -0800)]
Add a test case for async dyn* traits

20 months agorustdoc: add test case for pointer cursor
Michael Howell [Mon, 21 Nov 2022 16:16:54 +0000 (09:16 -0700)]
rustdoc: add test case for pointer cursor

20 months agoAuto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr
bors [Mon, 21 Nov 2022 15:22:54 +0000 (15:22 +0000)]
Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #104420 (Fix doc example for `wrapping_abs`)
 - #104499 (rustdoc JSON: Use `Function` everywhere and remove `Method`)
 - #104500 (`rustc_ast`: remove `ref` patterns)
 - #104511 (Mark functions created for `raw-dylib` on x86 with DllImport storage class)
 - #104595 (Add `PolyExistentialPredicate` type alias)
 - #104605 (deduplicate constant evaluation in cranelift backend)
 - #104628 (Revert "Update CI to use Android NDK r25b")
 - #104662 (Streamline deriving on packed structs.)
 - #104667 (Revert formatting changes of a test)

Failed merges:

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

20 months agonegative_impl_exists should take an InferCtxt
Santiago Pastorino [Mon, 21 Nov 2022 14:26:23 +0000 (11:26 -0300)]
negative_impl_exists should take an InferCtxt

20 months agoFix make test
mejrs [Sun, 13 Nov 2022 14:51:05 +0000 (15:51 +0100)]
Fix make test

20 months agoImprove slug name error
mejrs [Sun, 13 Nov 2022 12:10:36 +0000 (13:10 +0100)]
Improve slug name error

20 months agoFix tests
mejrs [Mon, 7 Nov 2022 23:42:00 +0000 (00:42 +0100)]
Fix tests

20 months agoMatch crate and slug names
mejrs [Mon, 7 Nov 2022 18:47:32 +0000 (19:47 +0100)]
Match crate and slug names

20 months agonegative_impl should take a TyCtxt
Santiago Pastorino [Mon, 21 Nov 2022 14:04:55 +0000 (11:04 -0300)]
negative_impl should take a TyCtxt

20 months agoRollup merge of #104667 - WaffleLapkin:unfmttest, r=Dylan-DPC
Matthias Krüger [Mon, 21 Nov 2022 13:11:13 +0000 (14:11 +0100)]
Rollup merge of #104667 - WaffleLapkin:unfmttest, r=Dylan-DPC

Revert formatting changes of a test

See https://github.com/rust-lang/rust/pull/99935/files#r1027259119
cc ``@CAD97``

20 months agoRollup merge of #104662 - nnethercote:tweak-deriving-for-packed-non-copy, r=jackh726
Matthias Krüger [Mon, 21 Nov 2022 13:11:13 +0000 (14:11 +0100)]
Rollup merge of #104662 - nnethercote:tweak-deriving-for-packed-non-copy, r=jackh726

Streamline deriving on packed structs.

The current approach to field accesses in derived code:
- Normal case: `&self.0`
- In a packed struct that derives `Copy`: `&{self.0}`
- In a packed struct that doesn't derive `Copy`: `let Self(ref x) = *self`

The `let` pattern used in the third case is equivalent to the simpler field access in the first case. This commit changes the third case to use a field access.

The commit also combines two boolean arguments (`is_packed` and `always_copy`) into a single field (`copy_fields`) earlier, to save passing both around.

r? ``@jackh726``

20 months agoRollup merge of #104628 - alex-pinkus:revert-android-ndk-upgrade, r=pietroalbini
Matthias Krüger [Mon, 21 Nov 2022 13:11:12 +0000 (14:11 +0100)]
Rollup merge of #104628 - alex-pinkus:revert-android-ndk-upgrade, r=pietroalbini

Revert "Update CI to use Android NDK r25b"

This reverts commit bf7f1ca316a249cf99d722d79a0db12fef687142 (pull request #102332).

The relevant discussion can be found in #103673, where it was agreed that more time is needed to warn the community of the upcoming breakage.

This PR is for the `master` branch, where a conflict was recently introduced due to 6d8160261ff3aee3b6eaacc37ac96cafff530980. The conflict is in `cc_detect.rs`, where the code that corrects the target triple was moved to a new function called `ndk_compiler()`. This puts the old logic in the `ndk_compiler` function, and assumes that it works properly in the other location where that code is being called. I would appreciate review from ``@pietroalbini`` to understand how we can test that the reverted logic is also suitable for the additional use case (seems to be related to setting `cc` and `cxx`). I've confirmed already that with these changes I can compile for `armv7-linux-androideabi`, `aarch64-linux-android`, `i686-linux-android`, and `x86_64-linux-android` using `x.py`.

A separate revert for the `beta` branch will be required, since the original change has already made it to beta. The beta revert is available at https://github.com/alex-pinkus/rust/commit/3fa0d94674fbe37090ebe44ac1f06e2233f3121e, but I'm not sure of the process for staging that PR.

20 months agoRollup merge of #104605 - RalfJung:clf_consts, r=bjorn3
Matthias Krüger [Mon, 21 Nov 2022 13:11:12 +0000 (14:11 +0100)]
Rollup merge of #104605 - RalfJung:clf_consts, r=bjorn3

deduplicate constant evaluation in cranelift backend

The cranelift backend had two matches on `ConstantKind`, which can be avoided, and used this `eval_for_mir` that nothing else uses... this makes things more consistent with the (better-tested) LLVM backend.

I noticed this because cranelift was the only user of `eval_for_mir`. However `try_eval_for_mir` still has one other user in `eval`... the odd thing is that the interpreter has its own `eval_mir_constant` which seems to duplicate the same functionality and does not use `try_eval_for_mir`. No idea what is happening here.

r? ``@bjorn3``
Cc ``@lcnr``

20 months agoRollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnr
Matthias Krüger [Mon, 21 Nov 2022 13:11:11 +0000 (14:11 +0100)]
Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnr

Add `PolyExistentialPredicate` type alias

Wrapping `ExistentialPredicate`s in a binder is very common, and this alias already exists for the `PolyExistential{TraitRef,Projection}` types.

20 months agoRollup merge of #104511 - dpaoliello:privateglobalworkaround, r=michaelwoerister
Matthias Krüger [Mon, 21 Nov 2022 13:11:10 +0000 (14:11 +0100)]
Rollup merge of #104511 - dpaoliello:privateglobalworkaround, r=michaelwoerister

Mark functions created for `raw-dylib` on x86 with DllImport storage class

Fix for #104453

## Issue Details
On x86 Windows, LLVM uses 'L' as the prefix for any private global symbols (`PrivateGlobalPrefix`), so when the `raw-dylib` feature creates an undecorated function symbol that begins with an 'L' LLVM misinterprets that as a private global symbol that it created and so fails the compilation at a later stage since such a symbol must have a definition.

## Fix Details
Mark the function we are creating for `raw-dylib` with `DllImport` storage class (this was already being done for MSVC at a later point for `callee::get_fn` but not for GNU (due to "backwards compatibility")): this will cause LLVM to prefix the name with `__imp_` and so it won't mistake it for a private global symbol.

20 months agoRollup merge of #104500 - WaffleLapkin:deref-the-compiler, r=wesleywiser
Matthias Krüger [Mon, 21 Nov 2022 13:11:10 +0000 (14:11 +0100)]
Rollup merge of #104500 - WaffleLapkin:deref-the-compiler, r=wesleywiser

`rustc_ast`: remove `ref` patterns

Or in other words use match ergonomics in `rustc_ast`. I do plan to do the same with other crates, but to keep the diff sane, let's do them one at a time.

20 months agoRollup merge of #104499 - Enselic:no-method-in-rustdoc-json, r=GuillaumeGomez
Matthias Krüger [Mon, 21 Nov 2022 13:11:09 +0000 (14:11 +0100)]
Rollup merge of #104499 - Enselic:no-method-in-rustdoc-json, r=GuillaumeGomez

rustdoc JSON: Use `Function` everywhere and remove `Method`

Closes #100259