3187 Commits

Author SHA1 Message Date
Lukas Wirth
1c67944f99 internal: Move library and local root inputs to base-db 2025-12-27 11:16:17 +01:00
Lukas Wirth
8c5a68e214
Merge pull request #21200 from ChayimFriedman2/fake-impls
perf: Do not really expand builtin derives, instead treat them specifically
2025-12-26 13:31:48 +00:00
Chayim Refael Friedman
bd934c08cf Allow IDE layer to "see" fake builtin derive impls
It sees them as regular impls; the details are abstracted. It's beautiful for the IDE layer, and less beautiful for `hir`, so this is a big change.

Some small differences still exist:

 - We show builtin derives impl (to the IDE layer) as if they have had no generic parameters. It is possible to show the parameters, but that means also having to handle fake impls in `TypeParam` etc., and the benefit is questionable.
 - Getting the fn *def* type of a method of a builtin derive impl is not supported, as there is no real `FunctionId`, therefore no `CallableDefId`. The trait method is returned instead. Note: getting the fn *ptr* type of the method is supported well.
 - Builtin derive impls and their methods do not fully support `HasSource`, because, well, they have no source (at least, not in the form of `ast::Impl` and `ast::Fn`). To support them, we use the derive's `TextRange` where possible, and the trait method's source when not.

 It's important to note that the def map still records the `MacroCallId`. I have doubts over this, as this means it's very easy to create the queries we don't want to create, but it does make things more convenient. In particular, a nicety of this setup is that even "Expand macro recursively" works (it creates the macro input/output query, but given that they will only be created when the user invokes the command, that does not seem to be a problem).
2025-12-26 15:00:08 +02:00
Lukas Wirth
97ac158aaa
Merge pull request #20193 from ChayimFriedman2/setting-rename-conflict
feat: Provide a setting to disable showing rename conflicts
2025-12-26 09:08:49 +00:00
A4-Tacks
ac01f880d7
Add BreakExpr completion suggest
- Move `ide::goto_definition::find_loops`
  into `ide_db::syntax_helpers::node_ext::find_loops`
2025-12-22 20:13:56 +08:00
Chayim Refael Friedman
961fd33e8e
Merge pull request #21310 from ChayimFriedman2/remove-attach-db
minor: Remove some redundant `attach_db()`s
2025-12-21 05:53:58 +00:00
Chayim Refael Friedman
65c14db957 Remove some redundant attach_db()s 2025-12-21 07:10:19 +02:00
jackh726
0dd3fe029a Add lsp extension to get failed trait obligations for a given function 2025-12-20 22:43:58 +00:00
Chayim Refael Friedman
776c818882 Lay the basics for non-Copy solver types with GC
That means stop using Salsa for interning solver types.
2025-12-18 10:12:03 +02:00
Jesung Yang
7f6858fd09 feat: introduce crate_attrs field in rust-project.json
Since the commit 50384460c68f
("Rewrite method resolution to follow rustc more closely"), the method
resolution logic has changed: rust-analyzer only looks up inherent
methods for primitive types in sysroot crates.

Unfortunately, this change broke at least one project that relies on
`rust-project.json`: Rust-for-Linux. Its auto-generated
`rust-project.json` directly embeds `core`, `alloc`, and `std` in the
`crates` list without defining `sysroot_src`. Consequently,
rust-analyzer fails to identify them as sysroot crates, breaking IDE
support for primitive methods (e.g., `0_i32.rotate_left(0)`).

However, specifying `sysroot_src` creates a new issue: it implicitly
adds `std` as a dependency to all kernel module crates, which are
actually compiled with `-Zcrate-attr=no_std`. Since rust-analyzer cannot
see compiler flags passed outside of the project definition, we need a
method to explicitly specify `#![no_std]` or, more generally,
crate-level attributes through the project configuration.

To resolve this, extend the `rust-project.json` format with a new
`crate_attrs` field. This allows users to specify crate-level attributes
such as `#![no_std]` directly into the configuration, enabling
rust-analyzer to respect them when analyzing crates.

References:
- The original Zulip discussion:
  https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/Primitive.20type.20inherent.20method.20lookup.20fails/with/562983853
2025-12-18 01:27:43 +00:00
Chayim Refael Friedman
b272c3568b
Merge pull request #21240 from benodiwal/feat/inlay-hint-missing-argument
feat: show parameter hint for missing arguments
2025-12-15 23:28:07 +00:00
dfireBird
e53d348f35
fix: use cmark_with_options to write shortcuts links to the output 2025-12-15 22:33:06 +05:30
Catherine Gasnier
8b4e438fd5 Fix "Invariant violation: file emitted multiple times" when doing scip .
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
2025-12-15 06:21:39 -08:00
Lukas Wirth
0da7839f48 internal: Give FileSymbol it's 'db lifetime 2025-12-14 10:54:13 +01:00
Chayim Refael Friedman
cc0e07901a
Merge pull request #21187 from nicolas-guichard/push-orysqtulnxww
Include operator overload occurrences in SCIP index
2025-12-11 01:04:46 +00:00
benodiwal
87f13bb21b
feat: show parameter hint for missing arguments 2025-12-10 17:37:26 +05:30
benodiwal
98a2d2cc71
fix: fixed Impl display to show trait generic args 2025-12-08 04:41:05 +05:30
Lukas Wirth
30550d917b Make ModuleId a tracked struct
optimize some stuff

Optimize `pub(crate)` visibility resolution

Optimize private visibility resolution
2025-12-07 09:31:19 +01:00
A4-Tacks
e8ee597340
Add config hide placeholders type hints
In the inferred type hints, expand the line too long. add config to disable it.

Example
---
```json
{"rust-analyzer.inlayHints.typeHints.hideInferredTypes": true}
```

```rust
use std::collections::HashMap;
fn foo(iter: Vec<Result<HashMap<String, String>, std::io::Error>>) {
    let output = iter.into_iter().collect::<Result<Vec<_>, _>>().unwrap();
}
```

**Before this PR**

```rust
let output: Vec<HashMap<String, String>> = iter.into_iter().collect::<Result<Vec<_ = HashMap<String, String>>, _ = Error>>().unwrap();
```

**After this PR**

```rust
let output: Vec<HashMap<String, String>> = iter.into_iter().collect::<Result<Vec<_>, _>>().unwrap();
```
2025-12-05 02:09:59 +08:00
Nicolas Guichard
96340cb6f6 Include operator overload occurrences in SCIP index
Operators were explicitly filtered out, both when filtering tokens to
search definitions for and when searching for actual definitions.
2025-12-01 12:43:46 +01:00
Chayim Refael Friedman
b92767700a Make Semantics::attach_first_edition() not return Option
And instead call `EditionedFileId::current_edition_guess_origin`, as most callers do it anyway.
2025-11-29 18:52:18 +02:00
Chayim Refael Friedman
f0e372c3b6 Rewrite attribute handling
Basically, we switch to expanding cfg_attr in AST form, filter irrelevant attributes from the item tree, and move hir-def attributes (non-item-tree) to be flag-based.

The main motivation is memory usage, although this also simplifies the code, and fixes some bugs around handling of `cfg_attr`s.
2025-11-29 18:52:18 +02:00
Chayim Refael Friedman
e326797e60
Merge pull request #21149 from ChayimFriedman2/lang-items
perf: Use one query per crate for lang items, not one per lang item
2025-11-29 16:19:38 +00:00
Asuka Minato
03cf272f00 fix Display scope inlay hints after closing brace for more types of blocks 2025-11-28 19:44:24 +09:00
Chayim Refael Friedman
d9bee82688 Use one query per crate for lang items, not one per lang item
Lang items rarely change, so putting a query for each doesn't give us anything. On the other hand, putting them behind only one query not only saves memory, it also has a giant benefit: we can store the struct with all lang items in the interner, making access to them very cheap. That basically means that anything in the hot path can avoid a *very common* query, and exchange it for a simple field access.
2025-11-28 03:28:44 +02:00
Wilfred Hughes
dacc74f336 feature: Set enclosing_range field on SCIP output
Previously we didn't set the enclosing position on definitions, so
SCIP consumers didn't know the position of the entire definition that
provides the symbol.
2025-11-26 17:11:21 +00:00
Nicolas Guichard
9500624e09 Show inlay hints for type placeholders
With the extra InferenceResult that maps type placeholders to their
inferred type, we can now easily display inlay hints for them.
2025-11-24 11:52:58 +01:00
xdBronch
c03bc5b0c4 add deprecated semantic token for extern crate shorthand 2025-11-23 14:24:24 -05:00
Chayim Refael Friedman
762b21c458
Merge pull request #21100 from xdBronch/deprecated-tokens
add semantic tokens for deprecated items
2025-11-23 15:24:13 +00:00
xdBronch
800c06e0ba add semantic tokens for deprecated items 2025-11-23 09:59:05 -05:00
Lukas Wirth
e3751819fa Move transitive_rev_deps from db trait away 2025-11-23 13:56:59 +01:00
Lukas Wirth
66b6a1e474 Turn transitive dependencies into a query 2025-11-22 22:26:43 +01:00
Aditya-PS-05
ba5ecc09ac feat: make dyn inlay hints configurable 2025-11-20 00:37:01 +05:30
Chayim Refael Friedman
e8e02d5515
Merge pull request #20974 from ChayimFriedman2/ns4
fix: Rewrite method resolution to follow rustc more closely
2025-11-18 23:20:04 +00:00
Chayim Refael Friedman
f4a9af3a24 Merge pull request #21007 from joe-p/feat/more_param_names
Add "msg" and "op" to hidden inlay parameter names
2025-11-15 09:17:33 +02:00
Lukas Wirth
827be28900 Merge pull request #20995 from Veykril/push-kysxxnruzslp
internal: Move `SymbolsDatabase` over to new salsa style
2025-11-15 09:17:33 +02:00
Lukas Wirth
c1c6682e8b Merge pull request #20994 from Veykril/push-npvyklkuxnlr
perf: Reduce memory usage of symbol index
2025-11-15 09:17:33 +02:00
Chayim Refael Friedman
50384460c6 Rewrite method resolution to follow rustc more closely
It cannot be exactly the same, because we have needs rustc doesn't have (namely, accurate enumeration of all methods, not just with a specific name, for completions etc., while rustc also needs a best-effort implementation for diagnostics) but it is closer than the previous impl.

In addition we rewrite the closely related handling of operator inference and impl collection.

This in turn necessitate changing some other parts of inference in order to retain behavior. As a result, the behavior more closely matches rustc and is also more correct.

This fixes 2 type mismatches on self (1 remains) and 4 diagnostics (1 remains), plus some unknown types.
2025-11-05 18:43:36 +02:00
Shoyu Vanilla
a0217d8311 fix: Expand literals with wrong suffixes into LitKind::Err 2025-11-04 02:08:33 +09:00
Jacob Pratt
ea9a188f1e
Fix typos, backtick errors/omissions 2025-10-31 00:41:27 -04:00
Kirill Bulatov
7f2bac82c6 Show proper async function signatures in the signature help
Co-authored-by: Lukas Wirth <lukas@zed.dev>
2025-10-28 21:46:55 +02:00
Shoyu Vanilla (Flint)
5d905576d4
Merge pull request #20930 from ChayimFriedman2/builtin-res-block
fix: Fix handling of blocks modules that are not the root module
2025-10-28 14:16:33 +00:00
Chayim Refael Friedman
44227800c6 Fix handling of blocks modules that are not the root module 2025-10-28 12:57:26 +02:00
Shoyu Vanilla (Flint)
6155980340
Merge pull request #20906 from ChayimFriedman2/opaques-ns
fix: Properly support opaques
2025-10-28 08:03:59 +00:00
Chayim Refael Friedman
4fddcc6d57 Provide an option to not show derives near the ADT for "Goto Implementations" or "Implementations" codelens
I don't do it by default, for three reasons: (1) it's more expensive, (2) I actually quite like seeing the derives, and they may expand to no impl/more than one impl, (3) if #19130 will ever be merged this will become even more useful.

Even a config might be too much, but it was fun and easy to code so I did that.
2025-10-28 08:34:16 +02:00
Chayim Refael Friedman
dc91c0a9f3 Provide a setting to disable showing rename conflicts 2025-10-27 18:04:33 +02:00
Chayim Refael Friedman
f7a13f0a41
Merge pull request #20369 from ChayimFriedman2/rename-self2
feat: When renaming `self` to other name, change callers method method call syntax to assoc fn syntax
2025-10-27 15:38:33 +00:00
Chayim Refael Friedman
9d038a94c2 When renaming self to other name, change callers method method call syntax to assoc fn syntax 2025-10-27 17:27:18 +02:00
Chayim Refael Friedman
537b31b55a Properly support opaques
By letting the solver take control of them (reveal them when needed and define them when needed), by providing them in the `TypingMode` plus few helpers.
2025-10-27 17:17:57 +02:00
Shoyu Vanilla
c6e605388f Add regression tests for some fixed A-ty issues 2025-10-27 02:18:52 +09:00