Commit Graph

19444 Commits

Author SHA1 Message Date
Ali Bektas
a15cc86c64 Implement parent-child relation for SourceRoots
This commit adds the said relation by keeping a map of type `FxHashMap<SourceRootId,Option<SourceRootId>>`
inside the `GlobalState`. Its primary use case is reading the rust-analyzer.toml files that can be
placed under every local source root. As a config will be found by traversing this "tree" we need the parent information
for every local source root. This commit omits defining this relation for library source roots entirely.
2024-03-06 19:55:04 +01:00
bors
ce15e73a8e Auto merge of #16773 - Veykril:text-explorer, r=Veykril
fix: Add config and capability for test explorer
2024-03-06 18:26:40 +00:00
Lukas Wirth
1c6d1b4f2a fix: Add config and capability for test explorer 2024-03-06 19:20:58 +01:00
bors
e5889c9b43 Auto merge of #16770 - roife:fix-issue-16278, r=Veykril
fix: panic when using float numbers without dots in chain calls

Fix #16278.

This PR fixes the panic caused by using floating-point numbers without a dot (such as `1e2`) in chain calls.

-------------

Although this syntax is very odd 🤣, r-a should not panic.
2024-03-06 15:38:35 +00:00
roife
91d181feff minor: fmt and clippy 2024-03-06 23:32:40 +08:00
roife
e2daee61bc test: add test for float_split_scientific_notation 2024-03-06 22:51:22 +08:00
roife
03420c330e fix: panic when split float numbers in scientific notation 2024-03-06 22:50:50 +08:00
bors
b85d38f7d6 Auto merge of #16755 - Veykril:rustup-bins, r=Veykril
For toolchain binaries use the full path found in $PATH

Fixes https://github.com/rust-lang/rust-analyzer/issues/16754
2024-03-06 14:47:32 +00:00
Shoyu Vanilla
a8f56112ea fix: Function argument type inference with associated type impl trait 2024-03-06 21:16:41 +09:00
bors
52d8ae791d Auto merge of #16766 - roife:fix-issue-15198, r=Veykril
fix: keep attributes in assist 'generate_delegate_trait'

fix #15198.

This PR address the issue that `impl` generated by `generate_delegate_trait` doesn't keep attributes.
2024-03-06 09:27:49 +00:00
roife
5c9ce7b11f test: add tests for keeping attrs in assist 'generate_delegate_trait' 2024-03-06 15:32:49 +08:00
roife
faea7fca01 fix: keep attrs for assist 'generate_delegate_trait' 2024-03-06 15:32:26 +08:00
hkalbasi
44be2432f5 Add test explorer 2024-03-06 00:05:29 +03:30
Vincent Esche
bf141310f8 Add fn index() accessor for hir::Param 2024-03-05 16:02:22 +01:00
Vincent Esche
1afeea85ff Add fn parent_fn() accessors for hir::Param & hir::SelfParam 2024-03-05 16:01:01 +01:00
roife
9cc3a9cfc2 fix: formatting 2024-03-05 19:55:31 +08:00
roife
16995ceda9 test: add tests for constants inside range pattern 2024-03-05 19:31:20 +08:00
roife
96a7c6ae3c fix: mir for range pattern 2024-03-05 19:31:20 +08:00
roife
ece18fecfa fix: resolve sub-patterns inside range pattern 2024-03-05 19:31:20 +08:00
bors
2898c4217d Auto merge of #16758 - Veykril:cargo-lock, r=Veykril
Update Cargo.lock
2024-03-05 11:17:42 +00:00
Lukas Wirth
00a6cc0664 Update Cargo.lock 2024-03-05 12:16:19 +01:00
bors
676455f911 Auto merge of #16757 - Veykril:style-lints, r=Veykril
fix: Put style lints behind disabled-by-default config

Fixes https://github.com/rust-lang/rust-analyzer/issues/16542
Fixes https://github.com/rust-lang/rust-analyzer/issues/16725
cc https://github.com/rust-lang/rust-analyzer/issues/16628

Our diagnostic infra is not yet setup for those kinds of diagnostics
2024-03-05 10:45:05 +00:00
Lukas Wirth
8844640c6f fix: Put style lints behind disabled-by-default config 2024-03-05 11:43:23 +01:00
Lukas Wirth
b20e467373 internal: Adjust a few things for trait assoc item hovers 2024-03-05 11:06:36 +01:00
Lukas Wirth
6b48133e9a Prefer cargo proxies when setting RUSTUP_TOOLCHAIN 2024-03-05 10:44:17 +01:00
Lukas Wirth
c310aee8d6 For toolchain binaries ue the full path found in $PATH 2024-03-05 10:17:09 +01:00
Lukas Wirth
fe0daa7be3 Revert "prioritise rustup sysroots over system ones"
This reverts commit 9f1d4aa4b9.
2024-03-05 09:37:25 +01:00
bors
ce3216e0ae Auto merge of #15938 - Young-Flash:display_trait_item_when_hover, r=Veykril
feat: add hover display for trait assoc items

This PR enable preview assoc items when hover on `trait`

![image](https://github.com/rust-lang/rust-analyzer/assets/71162630/d9c3949c-33cf-4a32-aa97-3af46b28033a)

inspired by https://github.com/rust-lang/rust-analyzer/pull/15847
2024-03-05 08:26:53 +00:00
Niklas Lindorfer
2a4ba4295b
fix: hide destructure_struct_binding assist if no public fields 2024-03-04 21:50:01 +00:00
Lukas Wirth
b9dbb8afd9 Regenerate lints table 2024-03-04 17:42:18 +01:00
Lukas Wirth
76463eee48 Move lint definition generation into xtask/codegen 2024-03-04 17:14:14 +01:00
Lukas Wirth
0964374274 Move diagnostics docs generation into xtask/codegen 2024-03-04 17:14:14 +01:00
bors
4e8cbf36a8 Auto merge of #16708 - Veykril:codegen, r=Veykril
internal: Move ide-assists codegen tests into an xtask codegen command
2024-03-04 15:50:39 +00:00
Lukas Wirth
6e802a0b56 minor: Mark remove_unnecessary_else as experimental 2024-03-04 16:35:33 +01:00
bors
a7e9f12bf7 Auto merge of #16748 - Veykril:on-demand-validation-err, r=Veykril
internal: Compute syntax validation errors on demand

The LRU cache causes us to re-parse trees quite often, yet we don't use the validation errors at all. With this we push calculating them off to the caller who is interested in them.
2024-03-04 11:19:16 +00:00
Lukas Wirth
c3c9f5ffe1 internal: Compute syntax validation errors on demand 2024-03-04 12:06:15 +01:00
bors
99a1b8f7a8 Auto merge of #16747 - Veykril:cleanup, r=Veykril
internal: Clean some stuff up

Just a bunch of small refactorings, mainly from browsing through `hir-def`
2024-03-04 10:30:17 +00:00
Lukas Wirth
4303e741de Cleanup 2024-03-04 11:10:06 +01:00
bors
2074cc28de Auto merge of #16722 - mo8it:allocations, r=Veykril
Avoid some allocations

I went on a small `.clone()` hunting tour :D
2024-03-04 09:17:23 +00:00
bors
d8feb908be Auto merge of #16703 - regexident:sema-ast-to-hir, r=Veykril
Add more methods for resolving definitions from AST to their corresponding HIR types

In order to be able to add these methods with consistent naming I had to also rename two existing methods that would otherwise be conflicting/confusing:

`Semantics::to_module_def(&self, file: FileId) -> Option<Module>` (before)
`Semantics::file_to_module_def(&self, file: FileId) -> Option<Module>` (after)

`Semantics::to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module>` (before)
`Semantics::file_to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module>` (after)

(the PR is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to walk a `hir::Function`'s AST, resolving its exprs/stmts/items to their HIR equivalents)
2024-03-04 09:02:32 +00:00
bors
0b7d4cc6ff Auto merge of #16690 - roife:fix-issue-16471, r=Veykril
fix: use 4 spaces for indentation in macro expansion

Partial fix for #16471.

In the previous code, the indentation produced by macro expansion was set to 2 spaces. This PR modifies it to 4 spaces for the sake of consistency.
2024-03-04 08:49:51 +00:00
bors
518cfe8cb7 Auto merge of #16723 - norskeld:constants-autocomplete, r=Veykril
fix: autocomplete constants inside format strings

Hi! This PR adds autocompletion for constants (including statics) inside format strings and closes #16608.

I'm not sure about adding the `constants` field to the `CompletionContext`. It kinda makes sense, since it's in line with the `locals` field, and this way everything looks a bit cleaner, but at the same time does it really need to be there?

Anyway, let me know if anything should/can be changed. :)
2024-03-04 08:36:39 +00:00
bors
4ef6a49b44 Auto merge of #16702 - Veykril:intra-doc-links-generic, r=Veykril
fix: Ignore generic arguments in intra doc link path resolution

Fixes https://github.com/rust-lang/rust-analyzer/issues/16699
2024-03-02 09:51:16 +00:00
bors
5c4c126832 Auto merge of #16704 - Veykril:stuff, r=Veykril
internal: Simplify
2024-03-02 09:37:26 +00:00
Laurențiu Nicola
dd21914e9d Remove outdated comment about static SmolStrs 2024-03-02 10:56:03 +02:00
Young-Flash
dba67b46a1 update for review 2024-03-02 10:01:04 +08:00
bors
79e0fee6a3 Auto merge of #16727 - Veykril:assoc-related, r=Veykril
fix: Don't highlight related assoc items of super traits
2024-03-01 18:34:48 +00:00
Lukas Wirth
efd76ecff1 Move AstIdMap infra to the span crate 2024-03-01 15:39:44 +01:00
Lukas Wirth
549aae7c07 Add a few more doc lines to the span crate 2024-03-01 15:20:30 +01:00
Lukas Wirth
8a5bb9d5ac Only the ROOT syntax context has None outer_expn 2024-03-01 15:14:17 +01:00