Commit graph

31465 commits

Author SHA1 Message Date
Lukas Wirth
9b7b93e031 fix: Fix panics for semantic highlighting at startup 2024-08-20 09:53:37 +02:00
bors
bfb4e6515e Auto merge of #128588 - onur-ozkan:clean-up-bootstrap-internals, r=albertlarsan68
bootstrap minor improvements and clean-ups

3rd commit fixes https://github.com/rust-lang/rust/issues/128553#issuecomment-2266119948.
2024-08-19 18:15:01 +00:00
bors
979e3b54f7 Auto merge of #17886 - Wilfred:prime_caches_quiescent, r=Veykril
internal: ServerStatusParams should consider 'prime caches' in quiescent status

Priming caches is a performance win, but it takes a lock on the salsa database and prevents rust-analyzer from responding to e.g. go-to-def requests.

This causes confusion for users, who see the spinner next to rust-analyzer in the VS Code footer stop, so they start attempting to navigate their code.

Instead, set the `quiescent` status in LSP to false during cache priming, so the VS Code spinner persists until we can respond to any LSP request.
2024-08-19 17:30:25 +00:00
Wilfred Hughes
0edb0e1e62 ServerStatusParams should consider 'prime caches' in quiescent status
Priming caches is a performance win, but it takes a lock on the salsa
database and prevents rust-analyzer from responding to e.g. go-to-def
requests.

This causes confusion for users, who see the spinner next to
rust-analyzer in the VS Code footer stop, so they start attempting to
navigate their code.

Instead, set the `quiescent` status in LSP to false during cache
priming, so the VS Code spinner persists until we can respond to any
LSP request.
2024-08-19 10:27:53 -07:00
bors
644617361d Auto merge of #17924 - ShoyuVanilla:issue-17921, r=Veykril
fix: Panic when a TAIT exists in a RPIT

Fixes  #17921

When there is a TAIT inside of a RPIT like;

```rust
trait Foo {}
type Bar = impl Foo;
fn foo<A>() -> impl Future<Output = Bar> { .. }
```

while inferencing `fn foo`, `insert_inference_vars_for_impl_trait` tries to substitute impl trait bounds of `Bar`, i.e. `Implemented(Foo)` with RPITs `placeholders`, and this causes panic

fa00326247/crates/hir-ty/src/infer.rs (L903-L905)
2024-08-19 14:17:07 +00:00
Shoyu Vanilla
722f0d3b46 fix: Panic when a TAIT exists in a RPIT 2024-08-19 23:07:13 +09:00
Lukas Wirth
90e08d3c93 Allow user config to not exist 2024-08-19 16:00:06 +02:00
Lukas Wirth
fd3fce2600 Remove the ability to configure the user config path 2024-08-19 15:12:33 +02:00
bors
c9955bf86b Auto merge of #17929 - Veykril:invocation-loc-docs, r=Veykril
minor: Improve documentation for `InvocationStrategy`

cc https://github.com/rust-lang/rust-analyzer/pull/17888
2024-08-19 12:25:38 +00:00
Lukas Wirth
3c4cdbbd1a Improve documentation for InvocationStrategy 2024-08-19 14:23:05 +02:00
bors
0c395dc5a4 Auto merge of #17928 - roife:fix-issue-17869, r=Veykril
fix: keep comments in convert_while_to_loop

Fix #17869.
2024-08-19 10:20:50 +00:00
roife
6a85595bb8 fix: keep comments in convert_while_to_loop 2024-08-19 17:27:54 +08:00
bors
c1879398af Auto merge of #17888 - Tyrubias:remove-invocation-location, r=Veykril
chore(config): remove `invocationLocation` in favor of `invocationStrategy`

These flags were added to help rust-analyzer integrate with repos requiring non-Cargo invocations. The consensus is that having two independent settings are no longer needed. This change removes `invocationLocation` in favor of `invocationStrategy` and changes the internal representation of `InvocationStrategy::Once` to hold the workspace root.

Closes #17848.
2024-08-19 08:19:38 +00:00
Victor Song
b0f20c7deb chore(config): remove invocationLocation in favor of invocationStrategy
These flags were added to help rust-analyzer integrate with repos
requiring non-Cargo invocations. The consensus is that having two
independent settings are no longer needed. This change removes
`invocationLocation` in favor of `invocationStrategy` and changes
the internal representation of `InvocationStrategy::Once` to hold
the workspace root.
2024-08-19 02:25:40 -05:00
bors
ba973db72a Auto merge of #17925 - darichey:issue-17767, r=Veykril
Include generics when lowering extern type

Fixes #17767
2024-08-19 07:20:55 +00:00
bors
3bc2724c7d Auto merge of #125854 - beetrees:zst-arg-abi, r=estebank
Move ZST ABI handling to `rustc_target`

Currently, target specific handling of ZST function call ABI (specifically passing them indirectly instead of ignoring them) is handled in `rustc_ty_utils`, whereas all other target specific function call ABI handling is located in `rustc_target`. This PR moves the ZST handling to `rustc_target` so that all the target-specific function call ABI handling is in one place. In the process of doing so, this PR fixes #125850 by ensuring that ZST arguments are always correctly ignored in the x86-64 `"sysv64"` ABI; any code which would be affected by this fix would have ICEd before this PR. Tests are also added using `#[rustc_abi(debug)]` to ensure this behaviour does not regress.

Fixes #125850
2024-08-18 22:15:41 +00:00
David Richey
e350bc2cf5 Include generics when lowering extern type 2024-08-18 15:12:01 -05:00
bors
551b4f5718 Auto merge of #126450 - madsmtm:promote-mac-catalyst, r=Mark-Simulacrum
Promote Mac Catalyst targets to Tier 2, and ship with rustup

Promote the Mac Catalyst targets `x86_64-apple-ios-macabi` and `aarch64-apple-ios-macabi` to Tier 2, as per [the MCP](https://github.com/rust-lang/compiler-team/issues/761) (see that for motivation and details).

These targets are now also distributed with rustup, although without the sanitizer runtime, as that currently has trouble building, see https://github.com/rust-lang/rust/issues/129069.
2024-08-18 15:52:58 +00:00
bors
90b62e67a2 Auto merge of #129115 - jieyouxu:reenable-dump-ice, r=estebank
Re-enable `dump-ice-to-disk` for Windows

This test was previously flakey on `i686-mingw` (reason unknown), but since some modifications (quarantining each ICE test in separate tmp dirs, adding/removing `RUSTC_ICE` env vars as suitable to prevent any kind of environmental influence), I could no longer make it fail on `i686-mingw`.

I tried running this test (without the `ignore-windows` of course) a bunch of times via `i686-mingw` try jobs and it refused to fail (see #128958). I was also never able to reproduce the failure locally.

In any case, if this turns out to be still flakey on `i686-mingw`, we can revert the removal of `ignore-windows` but this time we'll have way more context for why the test failed.

Running the `i686-mingw` alongside some Windows jobs for basic santiy check. But the try jobs succeeding is insufficient to guarantee reproducibility.

cc #129115 for backlink.

try-job: x86_64-msvc
try-job: x86_64-mingw
try-job: i686-msvc
try-job: i686-mingw
2024-08-18 02:25:33 +00:00
bors
b57dee117b Auto merge of #128771 - carbotaniuman:stabilize_unsafe_attr, r=nnethercote
Stabilize `unsafe_attributes`

# Stabilization report

## Summary

This is a tracking issue for the RFC 3325: unsafe attributes

We are stabilizing `#![feature(unsafe_attributes)]`,  which makes certain attributes considered 'unsafe', meaning that they must be surrounded by an `unsafe(...)`, as in `#[unsafe(no_mangle)]`.

RFC: rust-lang/rfcs#3325
Tracking issue: #123757

## What is stabilized

### Summary of stabilization

Certain attributes will now be designated as unsafe attributes, namely, `no_mangle`, `export_name`, and `link_section` (stable only), and these attributes will need to be called by surrounding them in `unsafe(...)` syntax. On editions prior to 2024, this is simply an edition lint, but it will become a hard error in 2024. This also works in `cfg_attr`, but `unsafe` is not allowed for any other attributes, including proc-macros ones.

```rust
#[unsafe(no_mangle)]
fn a() {}

#[cfg_attr(any(), unsafe(export_name = "c"))]
fn b() {}
```

For a table showing the attributes that were considered to be included in the list to require unsafe, and subsequent reasoning about why each such attribute was or was not included, see [this comment here](https://github.com/rust-lang/rust/pull/124214#issuecomment-2124753464)

## Tests

The relevant tests are in `tests/ui/rust-2024/unsafe-attributes` and `tests/ui/attributes/unsafe`.
2024-08-17 22:48:42 +00:00
bors
af833f0ba8 Auto merge of #128792 - compiler-errors:foreign-sig, r=spastorino
Use `FnSig` instead of raw `FnDecl` for `ForeignItemKind::Fn`, fix ICE for `Fn` trait error on safe foreign fn

Let's use `hir::FnSig` instead of `hir::FnDecl + hir::Safety` for `ForeignItemKind::Fn`. This consolidates some handling code between normal fns and foreign fns.

Separetly, fix an ICE where we weren't handling `Fn` trait errors for safe foreign fns.

If perf is bad for the first commit, I can rework the ICE fix to not rely on it. But if perf is good, I prefer we fix and clean up things all at once 👍

r? spastorino

Fixes #128764
2024-08-17 19:35:01 +00:00
bors
fa00326247 Auto merge of #17915 - Veykril:offline-no-deps, r=Veykril
feat: Make rust-analyzer work partially when offline

Helps out with https://github.com/rust-lang/rust-analyzer/issues/12499 a bit
2024-08-17 17:20:39 +00:00
Lukas Wirth
1013bf36dc Adress new clippy::large_enum_variant diagnostics 2024-08-17 19:18:56 +02:00
Lukas Wirth
07c1b83e98 feat: Make rust-analyzer work partially when missing an internet connection 2024-08-17 19:14:46 +02:00
bors
469b06214a Auto merge of #17916 - ShoyuVanilla:issue-17711, r=Veykril
fix: Wrong BoundVar index when lowering impl trait parameter of parent generics

Fixes #17711

From the following test code;

```rust
//- minicore: deref
use core::ops::Deref;

struct Struct<'a, T>(&'a T);

trait Trait {}

impl<'a, T: Deref<Target = impl Trait>> Struct<'a, T> {
    fn foo(&self) -> &Self { self }

    fn bar(&self) {
        let _ = self.foo();
    }

}
```

when we call `register_obligations_for_call` for `let _ = self.foo();`,

07659783fd/crates/hir-ty/src/infer/expr.rs (L1939-L1952)

we are querying `generic_predicates` and it has `T: Deref<Target = impl Trait>` predicate from the parent `impl Struct`;

07659783fd/crates/hir-ty/src/lower.rs (L375-L399)

but as we can see above, lowering `TypeRef = impl Trait` doesn't take into account the parent generic parameters, so the `BoundVar` index here is `0`, as `fn foo` has no generic args other than parent's,

But this `BoundVar` is pointing at `'a` in `<'a, T: Deref<Target = impl Trait>>`.
So, in the first code reference `register_obligations_for_call`'s L:1948 - `.substitute(Interner, parameters)`, we are substituting `'a` with `Ty`, not `Lifetime` and this makes panic inside the chalk.

This PR fixes this wrong `BoundVar` index in such cases
2024-08-17 17:00:52 +00:00
bors
ffb67710f7 Auto merge of #128786 - estebank:multiple-crate-versions, r=fee1-dead
Detect multiple crate versions on method not found

When a type comes indirectly from one crate version but the imported trait comes from a separate crate version, the called method won't be found. We now show additional context:

```
error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope
 --> multiple-dep-versions.rs:8:10
  |
8 |     Type.foo();
  |          ^^^ method not found in `Type`
  |
note: there are multiple different versions of crate `dependency` in the dependency graph
 --> multiple-dep-versions.rs:4:32
  |
4 | use dependency::{do_something, Trait};
  |                                ^^^^^ `dependency` imported here doesn't correspond to the right crate version
  |
 ::: ~/rust/build/x86_64-unknown-linux-gnu/test/run-make/crate-loading/rmake_out/multiple-dep-versions-1.rs:4:1
  |
4 | pub trait Trait {
  | --------------- this is the trait that was imported
  |
 ::: ~/rust/build/x86_64-unknown-linux-gnu/test/run-make/crate-loading/rmake_out/multiple-dep-versions-2.rs:4:1
  |
4 | pub trait Trait {
  | --------------- this is the trait that is needed
5 |     fn foo(&self);
  |        --- the method is available for `dep_2_reexport::Type` here
```

Fix #128569, fix #110926, fix #109161, fix #81659, fix #51458, fix #32611. Follow up to #124944.
2024-08-17 14:40:04 +00:00
Shoyu Vanilla
d7431ecdfa fix: Wrong BoundVar index when lowering impl trait parameter of parent generics 2024-08-17 22:33:27 +09:00
bors
e4edf6ca94 Auto merge of #17917 - ShoyuVanilla:pin-rowan, r=lnicola
Pin `rowan` to `0.15.15`

To prevent #17914, I think that it would be safer pinning this before we fix it correctly
2024-08-17 12:40:17 +00:00
Shoyu Vanilla
95470c250a Pin rowan to 0.15.15 2024-08-17 21:35:07 +09:00
bors
59cfcb2b60 Auto merge of #126877 - GrigorenkoPV:clone_to_uninit, r=dtolnay
CloneToUninit impls

As per #126799.

Also implements it for `Wtf8` and both versions of `os_str::Slice`.

Maybe it is worth to slap `#[inline]` on some of those impls.

r? `@dtolnay`
2024-08-17 11:39:08 +00:00
bors
12992e3000 Auto merge of #128598 - RalfJung:float-comments, r=workingjubilee
float to/from bits and classify: update for float semantics RFC

With https://github.com/rust-lang/rfcs/pull/3514 having been accepted, it is clear that hardware which e.g. flushes subnormal to zero is just non-conformant from a Rust perspective -- this is a hardware bug, or maybe an LLVM backend bug (where LLVM doesn't lower floating-point ops in a way that they have the standardized behavior). So update the comments here to make it clear that we don't have to do any of this, we're just being nice.

Also remove the subnormal/NaN checks from the (unstable) const-version of to/from-bits; they are not needed since we decided with the aforementioned RFC that it is okay to get a different result at const-time and at run-time.

r? `@workingjubilee` since I think you wrote many of the comments I am editing here.
2024-08-17 09:13:13 +00:00
bors
2d820ec893 Auto merge of #116528 - daxpedda:stabilize-ready-into-inner, r=dtolnay
Stabilize `Ready::into_inner()`

This PR stabilizes `Ready::into_inner()`.

Tracking issue: #101196.
Implementation PR: #101189.

Closes #101196.
2024-08-16 23:20:38 +00:00
bors
62cacda1eb Auto merge of #129162 - matthiaskrgr:rollup-r0oxdev, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #128990 (Re-enable more debuginfo tests on freebsd)
 - #129042 (Special-case alias ty during the delayed bug emission in `try_from_lit`)
 - #129086 (Stabilize `is_none_or`)
 - #129149 (Migrate `validate_json.py` script to rust in `run-make/rustdoc-map-file` test)
 - #129154 (Fix wrong source location for some incorrect macro definitions)
 - #129161 (Stabilize std:🧵:Builder::spawn_unchecked)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-16 20:19:00 +00:00
Matthias Krüger
5f7a34ad89
Rollup merge of #129161 - dtolnay:spawnunck, r=Noratrieb
Stabilize std:🧵:Builder::spawn_unchecked

Closes #55132.
2024-08-16 19:59:00 +02:00
Matthias Krüger
838fb52077
Rollup merge of #129154 - wafarm:fix-95463, r=estebank
Fix wrong source location for some incorrect macro definitions

Fixes #95463

Currently the code will consume the next token tree after `var` when trying to parse `$var:some_type` even when it's not a `:` (e.g. a `$` when input is `($foo $bar:tt) => {}`). Additionally it will return the wrong span when it's not a `:`.

This PR fixes these problems.
2024-08-16 19:58:59 +02:00
Matthias Krüger
63cef7bc2a
Rollup merge of #129149 - GuillaumeGomez:migrate-python-script, r=jieyouxu
Migrate `validate_json.py` script to rust in `run-make/rustdoc-map-file` test

This PR fixes the FIXME I added for future-me who become present-me. :')

Since there are multiple `run-make` tests using python scripts, I suppose more of them will migrate to Rust, hence why I added the `jzon` public reexport to the `run-make-support` crate.

cc `@jieyouxu`
r? `@Kobzol`
2024-08-16 19:58:59 +02:00
Matthias Krüger
a9a91233de
Rollup merge of #129086 - slanterns:is_none_or, r=dtolnay
Stabilize `is_none_or`

Closes: https://github.com/rust-lang/rust/issues/126383.

`@rustbot` label: +T-libs-api

r? libs-api
2024-08-16 19:58:58 +02:00
Matthias Krüger
26241b8dea
Rollup merge of #129042 - Jaic1:fix-116308, r=BoxyUwU
Special-case alias ty during the delayed bug emission in `try_from_lit`

This PR tries to fix #116308.

A delayed bug in `try_from_lit` will not be emitted so that the compiler will not ICE when it sees the pair `(ast::LitKind::Int, ty::TyKind::Alias)` in `lit_to_const` (called from `try_from_lit`).

This PR is related to an unstable feature `adt_const_params` (#95174).

r? ``@BoxyUwU``
2024-08-16 19:58:58 +02:00
bors
07659783fd Auto merge of #17909 - darichey:remove-discoverProjectRunner, r=lnicola
Remove rust-analyzer.workspace.discoverProjectRunner

The functionality for this vscode config option was removed in #17395, so it doesn't do anything anymore.
2024-08-16 14:58:43 +00:00
David Richey
ac6a3f82cd Remove rust-analyzer.workspace.discoverProjectRunner 2024-08-16 09:50:45 -05:00
bors
7f77e09fbe Auto merge of #17900 - darichey:exclude-vendored-libraries, r=davidbarsky
Add scip/lsif flag to exclude vendored libaries

#17809 changed StaticIndex to include vendored libraries. This PR adds a flag to disable that behavior.

At work, our monorepo has too many rust targets to index all at once, so we split them up into several shards. Since all of our libraries are vendored, if rust-analyzer includes them, sharding no longer has much benefit, because every shard will have to index the entire transitive dependency graphs of all of its targets. We get around the issue presented in #17809 because some other shard will index the libraries directly.
2024-08-16 14:25:36 +00:00
bors
ec837b5f84 Auto merge of #129068 - cuviper:llvm19rc2, r=compiler-errors
Re-update to LLVM 19 rc2

The update in #128677 was accidentally reverted in #128962.

Fixes #129064
r? nikic
2024-08-16 14:22:33 +00:00
bors
c9ee892263 Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykril
fix: Properly account for editions in names

This PR touches a lot of parts. But the main changes are changing `hir_expand::Name` to be raw edition-dependently and only when necessary (unrelated to how the user originally wrote the identifier), and changing `is_keyword()` and `is_raw_identifier()` to be edition-aware (this was done in #17896, but the FIXMEs were fixed here).

It is possible that I missed some cases, but most IDE parts should properly escape (or not escape) identifiers now.

The rules of thumb are:

 - If we show the identifier to the user, its rawness should be determined by the edition of the edited crate. This is nice for IDE features, but really important for changes we insert to the source code.
 - For tests, I chose `Edition::CURRENT` (so we only have to (maybe) update tests when an edition becomes stable, to avoid churn).
 - For debugging tools (helper methods and logs), I used `Edition::LATEST`.

Reviewing notes:

This is a really big PR but most of it is mechanical translation. I changed `Name` displayers to require an edition, and followed the compiler errors. Most methods just propagate the edition requirement. The interesting cases are mostly in `ide-assists`, as sometimes the correct crate to fetch the edition from requires awareness (there may be two). `ide-completions` and `ide-diagnostics` were solved pretty easily by introducing an edition field to their context. `ide` contains many features, for most of them it was propagated to the top level function and there the edition was fetched based on the file.

I also fixed all FIXMEs from #17896. Some required introducing an edition parameter (usually not for many methods after the changes to `Name`), some were changed to a new method `is_any_identifier()` because they really want any possible keyword.

Fixes #17895.
Fixes #17774.
2024-08-16 13:49:32 +00:00
Chayim Refael Friedman
9d3368f2c2 Properly account for editions in names
This PR touches a lot of parts. But the main changes are changing
`hir_expand::Name` to be raw edition-dependently and only when necessary
(unrelated to how the user originally wrote the identifier),
and changing `is_keyword()` and `is_raw_identifier()` to be edition-aware
(this was done in #17896, but the FIXMEs were fixed here).

It is possible that I missed some cases, but most IDE parts should properly
escape (or not escape) identifiers now.

The rules of thumb are:

 - If we show the identifier to the user, its rawness should be determined
   by the edition of the edited crate. This is nice for IDE features,
   but really important for changes we insert to the source code.
 - For tests, I chose `Edition::CURRENT` (so we only have to (maybe) update
   tests when an edition becomes stable, to avoid churn).
 - For debugging tools (helper methods and logs), I used `Edition::LATEST`.
2024-08-16 16:46:24 +03:00
bors
ed5c260fc6 Auto merge of #17595 - dfireBird:infer-lt, r=flodiebold
Implement lifetime inferring
2024-08-16 12:09:18 +00:00
bors
18bfa61a1e Auto merge of #129052 - onur-ozkan:better-incompatibility-check, r=Kobzol
detect incompatible CI rustc options more precisely

Previously, the logic here was simply checking whether the option was set in `config.toml`. This approach was not manageable in our CI runners as we set so many options in config.toml. In reality, those values are not incompatible since they are usually the same value used to generate the CI rustc. Now, the new logic compares the configuration values with the values used to generate the CI rustc, so we get more precise results and make the process more manageable.

r? Kobzol

Blocker for https://github.com/rust-lang/rust/pull/122709
2024-08-16 11:52:38 +00:00
dfireBird
8a4261aca8
implement basic inferring of lifetimes 2024-08-16 16:40:32 +05:30
bors
4cd8dcf287 Auto merge of #17903 - tmandry:graceful-exit, r=Veykril
Allow flycheck process to exit gracefully

Assuming it isn't cancelled. Closes #17902.

The only place CommandHandle::join() is used is when the flycheck command
finishes, so this commit changes the behavior of the method itself.

The only reason I can see for the existing behavior is if the command is somehow holding onto a build lock longer than it should, this would force it to be released. But it would be a pretty heavy-handed way to solve that issue. I'm not aware of this occurring in practice.
2024-08-16 07:35:16 +00:00
bors
28b6838a0e Auto merge of #17908 - ChayimFriedman2:usages-word-boundaries, r=Veykril
Test for word boundary in `FindUsages`

This speeds up short identifiers search significantly, while unlikely to have an effect on long identifiers (the analysis takes much longer than some character comparison).

Tested by finding all references to `eq()` (from `PartialEq`) in the rust-analyzer repo. Total time went down from 100s to 10s (a 10x reduction!).

Feel free to close this if you consider this a non-issue, as most short identifiers are local.
2024-08-16 07:20:23 +00:00
bors
fc36e0ca16 Auto merge of #17907 - ChayimFriedman2:no-once_cell, r=Veykril
internal: Replace once_cell with std's recently stabilized OnceCell/Lock and LazyCell/Lock

This doesn't get rid of the once_cell dependency, unfortunately, since we have dependencies that use it, but it's a nice to do cleanup. And when our deps will eventually get rid of once_cell we will get rid of it for free.
2024-08-16 07:05:59 +00:00