Commit Graph

245993 Commits

Author SHA1 Message Date
bors
0878cdef2a Auto merge of #16524 - evertedsphere:swann/trait-bound-dyn, r=Veykril
minor: test that flip_trait_bound works with trait objects

Closes https://github.com/rust-lang/rust-analyzer/issues/16522.
2024-02-10 10:59:46 +00:00
bors
1ef7a2329b Auto merge of #16525 - Veykril:item-loc, r=Veykril
Abstract more over ItemTreeLoc-like structs

Allows reducing some code duplication by using functions generic over said structs. The diff isn't negative due to me adding some additional impls for completeness.
2024-02-10 10:47:37 +00:00
Lukas Wirth
00303c3b67 Abstract over ItemTreeLoc 2024-02-10 11:37:59 +01:00
Gurinder Singh
0815067796 Take empty where into account when suggesting predicates 2024-02-10 16:05:39 +05:30
Soham Chowdhury
dcdfc35fce test that flip_trait_bound works with trait objects 2024-02-10 11:06:07 +01:00
bors
232919c33a Auto merge of #120771 - oli-obk:useless_non_ensure_query_call, r=davidtwco
Use `ensure` when the result of the query is not needed beyond its `Result`ness

while I would like to just remove the `tcx` methods for ensure-only queries, that is hard to do without another query annotation or by turning the `define_callbacks` macro into a proc macro to get more control

should fix perf regression of https://github.com/rust-lang/rust/pull/120558
2024-02-10 09:27:14 +00:00
Vadim Petrochenkov
b07283815b hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
Vadim Petrochenkov
e46e3e7107 hir: Introduce TyCtxt::parent_hir_{id,node}
Remove the FIXME and keep `CRATE_HIR_ID` being its own parent.
This scheme turned out to be more practical than having an `Option` on closer inspection.

Also make `hir_owner_parent` more readable.
2024-02-10 12:23:11 +03:00
Ralf Jung
3bc490d814 various docs tweaks 2024-02-10 10:19:57 +01:00
Ralf Jung
aa64c73f14 simd_scatter: mention left-to-right order 2024-02-10 10:13:15 +01:00
Ralf Jung
5219af6ae0 add more missing simd intrinsics 2024-02-10 10:13:14 +01:00
Ralf Jung
d96f0c382f simd intrinsics: add simd_shuffle_generic 2024-02-10 10:13:14 +01:00
bors
aa97edb214 Auto merge of #16497 - evertedsphere:swann/fix-inline-for-macro-generated-method, r=Veykril
Fix incorrect inlining of functions that come from MBE macros

Partial fix for https://github.com/rust-lang/rust-analyzer/issues/16471.

As a reminder, there are two issues there:
1. missing whitespace in parameter types (the first test)
2. the `self` parameter not being replaced by `this` in the function body (the second test)

The first part is fixed in this PR. See [this comment](https://github.com/rust-lang/rust-analyzer/pull/16497#issuecomment-1934243409) for the second.
2024-02-10 08:59:51 +00:00
bors
7e9265506d Auto merge of #16521 - tetsuharuohzeki:experiment-enable-str_to_string, r=lnicola
internal: Enable str_to_string Clippy rule

This fix [the FIXME comment](bb0de88f24/Cargo.toml (L183-L184))
2024-02-10 08:15:39 +00:00
bors
757b8efed4 Auto merge of #120712 - compiler-errors:async-closures-harmonize, r=oli-obk
Harmonize `AsyncFn` implementations, make async closures conditionally impl `Fn*` traits

This PR implements several changes to the built-in and libcore-provided implementations of `Fn*` and `AsyncFn*` to address two problems:
1. async closures do not implement the `Fn*` family traits, leading to breakage: https://crater-reports.s3.amazonaws.com/pr-120361/index.html
2. *references* to async closures do not implement `AsyncFn*`, as a consequence of the existing blanket impls of the shape `AsyncFn for F where F: Fn, F::Output: Future`.

In order to fix (1.), we implement `Fn` traits appropriately for async closures. It turns out that async closures can:
* always implement `FnOnce`, meaning that they're drop-in compatible with `FnOnce`-bound combinators like `Option::map`.
* conditionally implement `Fn`/`FnMut` if they have no captures, which means that existing usages of async closures should *probably* work without breakage (crater checking this: https://github.com/rust-lang/rust/pull/120712#issuecomment-1930587805).

In order to fix (2.), we make all of the built-in callables implement `AsyncFn*` via built-in impls, and instead adjust the blanket impls for `AsyncFn*` provided by libcore to match the blanket impls for `Fn*`.
2024-02-10 07:15:15 +00:00
Zalathar
a2479a4ae7 Remove unnecessary min_specialization after bootstrap
These crates all needed specialization for `newtype_index!`, which will no
longer be necessary when the current nightly eventually becomes the next
bootstrap compiler.
2024-02-10 18:15:11 +11:00
Zalathar
7b73e4fd44 Allow restricted trait impls in macros with min_specialization
Implementing traits marked with `#[rustc_specialization_trait]` normally
requires (min-)specialization to be enabled for the enclosing crate.

With this change, that permission can also be granted by an
`allow_internal_unstable` attribute on the macro that generates the impl.
2024-02-10 18:14:02 +11:00
bors
68125c72d3 Auto merge of #120721 - onur-ozkan:incorrect-llvm-path-on-cross-target, r=albertlarsan68
fix `llvm_out` to use the correct LLVM root

When `download-ci-llvm` is enabled, `llvm_out` ends up with the
error below due to an incorrect path on cross-compilations. This change fixes that.

```sh
failed to execute command: "/rust/build/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-config" "--version"
ERROR: No such file or directory (os error 2)
```
2024-02-10 04:12:51 +00:00
Michael Goulet
e6f5af9671 Remove unused fn 2024-02-10 03:52:13 +00:00
Michael Goulet
fde695a2d1 Add a helpful suggestion 2024-02-10 03:31:34 +00:00
Venus Xeon-Blonde
d7263d7aad
Change wording 2024-02-09 22:24:57 -05:00
Michael Goulet
973bbfbd23 No more associated type bounds in dyn trait 2024-02-10 03:23:51 +00:00
Weihang Lo
9b3c0e6334
Update cargo 2024-02-09 20:50:39 -05:00
Zalathar
cf1096eb72 Remove unnecessary #![feature(min_specialization)] 2024-02-10 12:26:14 +11:00
Ben Kimock
3d4a9f5047 Turn the "no saved object file in work product" ICE into a translatable fatal error 2024-02-09 20:22:15 -05:00
Lukas Wirth
2ebf0c87c2 Deduplicate some code 2024-02-10 01:51:22 +01:00
bors
b5c46dc542 Auto merge of #120862 - matthiaskrgr:rollup-jzfab58, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #120584 (For a rigid projection, recursively look at the self type's item bounds to fix the `associated_type_bounds` feature)
 - #120596 ([rustdoc] Correctly generate path for non-local items in source code pages)
 - #120629 (Move some test files)
 - #120846 (Update jobserver-rs to 0.1.28)
 - #120850 (ast_lowering: Fix regression in `use ::{}` imports.)
 - #120853 (Avoid a collection and iteration on empty passes)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-10 00:03:43 +00:00
Matthias Krüger
8e1eaddd27
Rollup merge of #120853 - blyxyas:no-collect, r=cjgillot
Avoid a collection and iteration on empty passes

Just some mini optimization I saw in the wild. This way, we avoid a `collect` and `map` on an empty `passes`. Honestly, I don't even think this is big enough of a change to make a benchmark, but I'd still like to see results.

Based on [this book](https://nnethercote.github.io/perf-book/iterators.html#collect-and-extend)
2024-02-10 00:58:40 +01:00
Matthias Krüger
8177c0fead
Rollup merge of #120850 - petrochenkov:empimpres, r=cjgillot
ast_lowering: Fix regression in `use ::{}` imports.

Fixes https://github.com/rust-lang/rust/issues/120789
2024-02-10 00:58:39 +01:00
Matthias Krüger
317c372284
Rollup merge of #120846 - petrochenkov:jobs, r=oli-obk
Update jobserver-rs to 0.1.28

Fixes the issues found in https://github.com/rust-lang/rust/issues/120515 besides the diagnostic wording.
2024-02-10 00:58:38 +01:00
Matthias Krüger
34489b7769
Rollup merge of #120629 - c410-f3r:testsssssss, r=petrochenkov
Move some test files

r? ``@petrochenkov``
2024-02-10 00:58:38 +01:00
Matthias Krüger
c06199f863
Rollup merge of #120596 - GuillaumeGomez:jump-to-def-non-local-link, r=notriddle,fmease
[rustdoc] Correctly generate path for non-local items in source code pages

While browsing some crates using the "jump to def" feature, I realized that a lot of items didn't have a link generated. The reason is because we only cache foreign items if they appear in the documented API. This means that for the others, we need to infer them.

r? ``@notriddle``
2024-02-10 00:58:37 +01:00
Matthias Krüger
9ec287dec2
Rollup merge of #120584 - compiler-errors:u, r=lcnr
For a rigid projection, recursively look at the self type's item bounds to fix the `associated_type_bounds` feature

Given a deeply nested rigid projection like `<<<T as Trait1>::Assoc1 as Trait2>::Assoc2 as Trait3>::Assoc3`, this PR adjusts both trait solvers to look at the item bounds for all of `Assoc3`, `Assoc2`, and `Assoc1` in order to satisfy a goal. We do this because the item bounds for projections may contain relevant bounds for *other* nested projections when the `associated_type_bounds` (ATB) feature is enabled. For example:

```rust
#![feature(associated_type_bounds)]

trait Trait1 {
    type Assoc1: Trait2<Assoc2: Foo>;
    // Item bounds for `Assoc1` are:
    // `<Self as Trait1>::Assoc1: Trait2`
    // `<<Self as Trait1>::Assoc1 as Trait2>::Assoc2: Foo`
}

trait Trait2 {
    type Assoc2;
}

trait Foo {}

fn hello<T: Trait1>(x: <<T as Trait1>::Assoc1 as Trait2>::Assoc2) {
    fn is_foo(_: impl Foo) {}
    is_foo(x);
    // Currently fails with:
    // ERROR the trait bound `<<Self as Trait1>::Assoc1 as Trait2>::Assoc2: Foo` is not satisfied
}
```

This has been a long-standing place of brokenness for ATBs, and is also part of the reason why ATBs currently desugar so differently in various positions (i.e. sometimes desugaring to param-env bounds, sometimes desugaring to RPITs, etc). For example, in RPIT and TAIT position, `impl Foo<Bar: Baz>` currently desugars to `impl Foo<Bar = impl Baz>` because we do not currently take advantage of these nested item bounds if we desugared them into a single set of item bounds on the opaque. This is obviously both strange and unnecessary if we just take advantage of these bounds as we should.

## Approach

This PR repeatedly peels off each projection of a given goal's self type and tries to match its item bounds against a goal, repeating with the self type of the projection. This is pretty straightforward to implement in the new solver, only requiring us to loop on the self type of a rigid projection to discover inner rigid projections, and we also need to introduce an extra probe so we can normalize them.

In the old solver, we can do essentially the same thing, however we rely on the fact that projections *should* be normalized already. This is obviously not always the case -- however, in the case that they are not fully normalized, such as a projection which has both infer vars and, we bail out with ambiguity if we hit an infer var for the self type.

## Caveats

⚠️ In the old solver, this has the side-effect of actually stalling some higher-ranked trait goals of the form `for<'a> <?0 as Tr<'a>>: Tr2`. Because we stall them, they no longer are eagerly treated as error -- this cause some existing `known-bug` tests to go from fail -> pass.

I'm pretty unconvinced that this is a problem since we make code that we expect to pass in the *new* solver also pass in the *old* solver, though this obviously doesn't solve the *full* problem.

## And then also...

We also adjust the desugaring of ATB to always desugar to a regular associated bound, rather than sometimes to an impl Trait **except** for when the ATB is present in a `dyn Trait`. We need to lower `dyn Trait<Assoc: Bar>` to `dyn Trait<Assoc = impl Bar>` because object types need all of their associated types specified.

I would also be in favor of splitting out the ATB feature and/or removing support for object types in order to stabilize just the set of positions for which the ATB feature is consistent (i.e. always elaborates to a bound).
2024-02-10 00:58:36 +01:00
Nicholas Nethercote
bb60ded24b Loosen an assertion to account for stashed errors.
The meaning of this assertion changed in #120828 when the meaning of
`has_errors` changed to exclude stashed errors. Evidently the new
meaning is too restrictive.

Fixes #120856.
2024-02-10 09:14:59 +11:00
Camille GILLOT
014b29eecf Remove ConstGoto and SeparateConstSwitch. 2024-02-09 21:13:53 +00:00
Camille GILLOT
e132cac3c4 Enable by default. 2024-02-09 21:13:51 +00:00
Camille GILLOT
7a6b00e786 Remove untested arithmetic ops. 2024-02-09 21:06:25 +00:00
Camille GILLOT
a2a9125d6a Add test for ptr ops with same provenance. 2024-02-09 21:06:24 +00:00
Camille GILLOT
d50f26e409 Const-prop pointers. 2024-02-09 21:06:23 +00:00
bors
d44e3b95cb Auto merge of #120852 - matthiaskrgr:rollup-01pr8gj, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #120351 (Implement SystemTime for UEFI)
 - #120354 (improve normalization of `Pointee::Metadata`)
 - #120776 (Move path implementations into `sys`)
 - #120790 (better error message on download CI LLVM failure)
 - #120806 (Clippy subtree update)
 - #120815 (Improve `Option::inspect` docs)
 - #120822 (Emit more specific diagnostics when enums fail to cast with `as`)
 - #120827 (Print image input file and checksum in CI only)
 - #120836 (hide impls if trait bound is proven from env)
 - #120844 (Build DebugInfo for async closures)
 - #120851 (Remove duplicate release note)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-09 21:06:12 +00:00
Soham Chowdhury
18be556b37 inline_call: remove macro self->this test
To be added back later once we have a fix.

See #16471 and https://github.com/rust-lang/rust-analyzer/pull/16497#issuecomment-1934243409.
2024-02-09 22:02:51 +01:00
Camille GILLOT
5a6f14c4f4 Split gvn wide ptr tests. 2024-02-09 21:01:57 +00:00
Camille GILLOT
28df0a62f6 Compute binary ops between pointers in GVN. 2024-02-09 21:01:57 +00:00
Camille GILLOT
304b4ad8b9 Compute unsizing casts in GVN. 2024-02-09 21:01:57 +00:00
Camille GILLOT
1f544ca0cc Fold consecutive PtrToPtr casts. 2024-02-09 21:01:56 +00:00
Oli Scherer
614ff0fae9 Don't reinvoke impl_trait_ref query after it was already invoked 2024-02-09 20:33:23 +00:00
Oli Scherer
97b4b7f72b use impl Trait argument instead of generic param for simplicity 2024-02-09 20:25:18 +00:00
Oli Scherer
7f871ab9aa No need for FnMut when FnOnce works now 2024-02-09 20:23:40 +00:00
Oli Scherer
23277a502e Simplify conditional erroring 2024-02-09 20:23:18 +00:00
Oli Scherer
4661c83530 Avoid accessing the HIR in the happy path of coherent_trait 2024-02-09 20:12:02 +00:00