Commit graph

27702 commits

Author SHA1 Message Date
bors
03b3cb6be9 Auto merge of #16652 - davidbarsky:david/deadlock-fix-for-16643, r=Veykril
internal: fix deadlock introduced by #16643

This fixes a deadlock introduced by #16643 ([backtrace](https://gist.github.com/davidbarsky/00f17598f5496a9c41aff31fec1c42d6)). `maybe_changed_after` calls back into other queries, so the cloning here is unfortunately inevitable.

(Zulip conversation: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Fixing.20proc-macro.20dirtying.20with.20unindexed.20projects)
2024-02-23 20:39:13 +00:00
David Barsky
64779737db internal: fix deadlock introduced by #16643 2024-02-23 15:34:23 -05:00
bors
12144045fe Auto merge of #16650 - Veykril:metrics-rustc, r=Veykril
Fix: Fix metrics CI failing
2024-02-23 19:23:45 +00:00
Lukas Wirth
0c3a524acb Fix: Fix metrics CI failing 2024-02-23 20:22:01 +01:00
bors
838523dcc2 Auto merge of #16621 - txase:no-build-with-bootstrap, r=Veykril
fix: Recompiles due to RUSTC_BOOTSTRAP

Some packages (e.g. thiserror) force a recompile if the value of the `RUSTC_BOOTSTRAP` env var changes. RA sets the variable to 1 in order to enable rustc / cargo unstable options. This causes flapping recompiles when building outside of RA.

Fixes #15057
2024-02-23 18:46:33 +00:00
bors
c45b3550c3 Auto merge of #16649 - Veykril:metrics-rustc, r=Veykril
internal: Disable rustc test metrics

The CI job for them frequently gets stuck and I am unsure why
2024-02-23 18:33:46 +00:00
Lukas Wirth
d9a08624aa internal: Disable rustc test metrics 2024-02-23 19:31:53 +01:00
bors
84c5481349 Auto merge of #16648 - Veykril:metrics-rustc, r=Veykril
internal: Pin commit of rust-lang/rust for rustc-test metrics
2024-02-23 16:27:56 +00:00
Lukas Wirth
c6a6e63a45 internal: Pin commit of rust-lang/rust for rustc-test metrics 2024-02-23 17:24:29 +01:00
bors
cbc579e51f Auto merge of #16643 - Veykril:salsa-opt, r=Veykril
internal: Optimize salsa memory usage

Reduces memory on self by ~20mb for me, there is a few more mb to save here if we made LRU caching opt-in, as currently every entry in a memoized query will store an `AtomicUsize` for the LRU.
2024-02-23 15:18:58 +00:00
Lukas Wirth
cc4d0e1bd1 Optimize salsa some more 2024-02-23 16:17:39 +01:00
bors
deddea0d90 Auto merge of #16646 - cuishuang:master, r=lnicola
remove repetitive words
2024-02-23 12:54:06 +00:00
cui fliter
6dca7948f7 remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-02-23 18:45:03 +08:00
bors
6648f19c56 Auto merge of #16645 - Veykril:deadlock, r=Veykril
fix: Fix deadlock in `recreate_crate_graph` <-> `file_line_index`

Fixes https://github.com/rust-lang/rust-analyzer/issues/16614
2024-02-23 09:13:31 +00:00
Lukas Wirth
9b7284dca7 fix: Fix deadlock in recreate_crate_graph <-> file_line_index 2024-02-23 10:10:48 +01:00
bors
1f54f714ca Auto merge of #16637 - Veykril:fix-proc-macro-srv-literals, r=Veykril
fix: Fix proc-macro server not accounting for string delimiters correctly

Fixes https://github.com/rust-lang/rust-analyzer/issues/16622

Note that this is a bug a in the proc-macro server, so this won't be fixed until the next subtree sync
2024-02-22 21:35:48 +00:00
Lukas Wirth
efa6948b57 Fix rust-analyzer not enabling rust-analyzer spans on the proc-macro server 2024-02-22 22:34:03 +01:00
Lukas Wirth
cdfb73ab9c fix: Fix proc-macro server not accounting for string delimiters correctly 2024-02-22 22:34:03 +01:00
Lukas Wirth
f89d17b426 Remove ops_salsa_runtime_mut, replace it with direct synthetic_write API 2024-02-22 10:42:30 +01:00
Chase Douglas
2826eb51aa Don't build dependencies when retrieving target data layout
`cargo rustc -- <args>` first builds dependencies then calls `rustc <args>` for the current package. Here, we don't want to build dependencies, we just want to call `rustc --print`. An unstable `cargo rustc` `--print` command bypasses building dependencies first. This speeds up execution of this code path and ensures RA doesn't recompile dependencies with the `RUSTC_BOOTSRAP=1` env var flag set.

Note that we must pass `-Z unstable-options` twice, first to enable the `cargo` unstable `--print` flag, then later to enable the unstable `rustc` `target-spec-json` print request.
2024-02-20 19:16:55 -08:00
Chase Douglas
344a79c17d Drop RUSTC_BOOTSTRAP env var when building build scripts
Some packages (e.g. thiserror) force a recompile if the value of the `RUSTC_BOOTSTRAP` env var changes. RA sets the variable to 1 in order to enable rustc / cargo unstable options it uses. This causes flapping recompiles when building outside of RA.

As of Cargo 1.75 the `--keep-going` flag is stable. This change uses the flag without `RUSTC_BOOTSTRAP` if the Cargo version is >= 1.75, and drops `--keep-going` otherwise. This fixes build script recompilation.
2024-02-20 16:42:20 -08:00
bors
543d7e98db Auto merge of #16618 - DropDemBits:structured-snippet-fix-escape-left-curly, r=Veykril
fix: Don't add `\` before `{`

Fixes #16607 for `{`. The `}` case is already fixed by #16475.

The [LSP snippet grammar](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax) only specifies that `$`, `}`, and `\` can be escaped with backslashes, but not `{`.
2024-02-20 20:11:03 +00:00
DropDemBits
07421c13d4
fix: Don't add \ before {
The LSP snippet grammar only specifies that `$`, `}`, and `\` can be escaped with
backslashes, but not `{`.
2024-02-20 14:35:59 -05:00
bors
4760d856bc Auto merge of #16617 - Veykril:rustc-tests-timeout, r=Veykril
internal: Attempt to add a timeout to rustc-tests

Looks like some new test is stuck, this might help with figuring that out, though it unfortunately won't if its a chalk hang (which is the most likely)
2024-02-20 17:06:17 +00:00
Lukas Wirth
16b15a203e internal: Attempt to add a timeout to rustc-tests 2024-02-20 18:04:53 +01:00
bors
9f0495761a Auto merge of #16616 - Veykril:build-script-fix, r=Veykril
fix: server hanging up on build script task

This should fix https://github.com/rust-lang/rust-analyzer/issues/16614, can't say for certain since it might be not 100% reproducible... We really need to replace the current workspace fetching logic, it is completely unreadable and incredibly difficult to follow. I don't really understand how the server even got to hang here honestly (I would expect it to loop re-fetching build scripts, but not hang).
2024-02-20 14:58:03 +00:00
Lukas Wirth
9dee352da0 fix: server hanging up on build script task 2024-02-20 15:55:17 +01:00
bors
c8887241f9 Auto merge of #16606 - Veykril:hover-extern, r=Veykril
internal: Render assoc item owner in hover for items other than functions

Closes https://github.com/rust-lang/rust-analyzer/issues/16603
2024-02-20 13:51:47 +00:00
Lukas Wirth
85203d9721 Render assoc item owner in hover for items other than functions 2024-02-20 13:16:12 +01:00
bors
26a16c4d9b Auto merge of #16612 - Veykril:detached-files, r=Veykril
internal: Fetch toolchain and datalayout for DetachedFiles

My changes broke the rustc test runs since we use detached files for that, this should fix that. Also addresses some new nightly warnings wrt to unnecessary imports
2024-02-20 09:48:33 +00:00
Lukas Wirth
d93096ecc0 internal: Fetch toolchain and datalayout for DetachedFiles 2024-02-20 10:40:39 +01:00
Lukas Wirth
a822291a02 Infallible definition hovers 2024-02-19 18:16:02 +01:00
bors
2223b4fa71 Auto merge of #13112 - lowr:patch/auto-trait-bounds, r=Veykril
Setup infra for handling auto trait bounds disabled due to perf problems

This patch updates some of the partially-implemented functions of `ChalkContext as RustIrDatabase`, namely `adt_datum()` and `impl_provided_for()`. With those, we can now correctly work with auto trait bounds and distinguish methods based on them.

Resolves #7856 (the second code; the first one is resolved by #13074)

**IMPORTANT**: I don't think we want to merge this until #7637 is resolved. Currently this patch introduces A LOT of unknown types and type mismtaches as shown below. This is because we cannot resolve items like `hashbrown::HashMap` in `std` modules, leading to auto trait bounds on them and their dependents unprovable.

|crate (from `rustc-perf@c52ee6` except for r-a)|e3dc5a588f07d6f1d3a0f33051d4af26190abe9e|HEAD of this branch|
|---|---|---|
|rust-analyzer @ e3dc5a588f |exprs: 417528, ??ty: 907 (0%), ?ty: 114 (0%), !ty: 1|exprs: 417528, ??ty: 1704 (0%), ?ty: 403 (0%), !ty: 20|
|ripgrep|exprs: 62120, ??ty: 2 (0%), ?ty: 0 (0%), !ty: 0|exprs: 62120, ??ty: 132 (0%), ?ty: 58 (0%), !ty: 11|
|webrender/webrender|exprs: 94355, ??ty: 49 (0%), ?ty: 16 (0%), !ty: 2|exprs: 94355, ??ty: 429 (0%), ?ty: 130 (0%), !ty: 7|
|diesel|exprs: 132591, ??ty: 401 (0%), ?ty: 5129 (3%), !ty: 31|exprs: 132591, ??ty: 401 (0%), ?ty: 5129 (3%), !ty: 31|
2024-02-19 16:45:59 +00:00
Lukas Wirth
d2b27d09ea Don't populate rust_ir::AdtVariantDatum::fields for now due to perf 2024-02-19 17:38:03 +01:00
bors
bbb781ec1e Auto merge of #16589 - rosefromthedead:unresolved-ident, r=Veykril
feat: add unresolved-ident diagnostic

This should cover missing local variables and missing unit structs and the like. It's conservatively marked experimental
2024-02-19 15:27:41 +00:00
Lukas Wirth
1e448f84c3 Clippy 2024-02-19 16:26:22 +01:00
Rose Hudson
a492d9d164 feat: add unresolved-ident diagnostic 2024-02-19 14:12:18 +01:00
Rose Hudson
d818b531c9 internal: make check_diagnostics_with_disabled more ergonomic 2024-02-19 14:12:18 +01:00
bors
e6b96dba56 Auto merge of #16590 - davidsemakula:unnecessary-else-diagnostic-fix, r=Veykril
fix: Fix false positives for "unnecessary else" diagnostic

Completes https://github.com/rust-lang/rust-analyzer/pull/16567 by `@ShoyuVanilla` (see https://github.com/rust-lang/rust-analyzer/pull/16567#discussion_r1492700667)
Fixes #16556
2024-02-19 12:49:08 +00:00
davidsemakula
f2218e7278 refactor: remove body parameter for "unnecessary else" diagnostic 2024-02-19 15:35:47 +03:00
davidsemakula
7dfeb2cdcc refactor "unnecessary else" diagnostic test 2024-02-19 15:24:45 +03:00
davidsemakula
ff70310086 fix: only emit "unnecessary else" diagnostic for expr stmts 2024-02-19 15:24:45 +03:00
Shoyu Vanilla
1205853c36 Apply indent fix in #16575 2024-02-19 15:24:45 +03:00
Shoyu Vanilla
8f6e2127c3 Fix the remove unnecessary else action to preserve block tail expr 2024-02-19 15:24:45 +03:00
Shoyu Vanilla
21f4ff0351 Check for let expr ancestors instead of tail expr 2024-02-19 15:24:45 +03:00
Shoyu Vanilla
d14b22863b Handle cases for else if 2024-02-19 15:19:27 +03:00
Shoyu Vanilla
e9c80a9c25 fix: False positive diagnostic for necessary else 2024-02-19 15:19:27 +03:00
bors
ac1029fac3 Auto merge of #16489 - UserIsntAvailable:feat/use-import-alias, r=Veykril
feat!: create alias when renaming an import.

![gif](https://github.com/rust-lang/rust-analyzer/assets/57047985/c593d9a8-b8a0-4e13-9e50-a69c7d0d8749)

Closes #15858

Implemented:
- [x] - Prevent using `reserved` keywords (e.g self) and `_`.
- [x] - Rename other modules that might be referencing the import.
- [x] - Fix "broken" tests.
- [ ] - Rename **only** "direct" references.
- [ ] - Test more cases.

Future possibilities:
1. Also support `extern crate <name>` syntax.
2. Allow aliasing `self` when it is inside an `UseTreeList`.
~3. If import path already has an alias, "rename" the alias.~
~[4. Create alias even if path is not the last path segment.](https://github.com/rust-lang/rust-analyzer/pull/16489#issuecomment-1930541697)~
2024-02-19 12:03:31 +00:00
bors
ff8fe522e8 Auto merge of #16303 - rosefromthedead:non-exhaustive-let, r=Veykril
feat: add non-exhaustive-let diagnostic

I want this to have a quickfix to add an else branch but I couldn't figure out how to do that, so here's the diagnostic on its own. It pretends a `let` is a match with one arm, and asks the match checking whether that match would be exhaustive.

Previously the pattern was checked based on its own type, but that was causing a panic in `match_check` (while processing e.g. `crates/hir/src/lib.rs`) so I changed it to use the initialiser's type instead, to align with the checking of actual match expressions. I think the panic can still happen, but I hear that `match_check` is going to be updated to a new version from rustc, so I'm posting this now in the hopes that the panic will magically go away when that happens.
2024-02-19 11:51:06 +00:00
bors
d8c8ccc380 Auto merge of #16358 - krobelus:fix-redundant-references-with-macros, r=Veykril
Deduplicate references when some of them are in macro expansions

EDIT: I wonder if this is a regression, I'll try to investigate.

Commit 6a06f6f72 (Deduplicate reference search results, 2022-11-07)
deduplicates references within each definition.

Apparently our descend_into_macros() stanza returns
one definition for each time a name is used in a macro.
Each of those definitions has the same set of references.
We return them all, leading to many redundant references.

Work around this by deduplicating definitions as well.  Perhaps there
is a better fix to not produce duplicate definitions in the first
place.

I discovered this working with the "bitflags" macro from the crate
of the same name.

Fixes #16357
2024-02-19 11:38:14 +00:00