Commit Graph

27139 Commits

Author SHA1 Message Date
Johann Hemmann
dea149d733 Switch to BTreeMap for stable ordering 2024-01-04 14:01:03 +01:00
Johann Hemmann
05a3c2ff20 Make filtering a function 2024-01-04 14:01:03 +01:00
Johann Hemmann
d1f4171bb6 Refactor to iterators 2024-01-04 14:01:03 +01:00
Johann Hemmann
084acc287a Extract relevant information into hashmaps 2024-01-04 14:01:02 +01:00
bors
c3a00b5468 Auto merge of #16251 - lnicola:span-description, r=lnicola
Add description to span crate manifest

CC https://github.com/rust-lang/rust-analyzer/actions/runs/7408827766/job/20157836624
2024-01-04 11:28:11 +00:00
Laurențiu Nicola
688911757e Add description to span crate manifest 2024-01-04 13:27:32 +02:00
bors
95e047e4ac Auto merge of #16248 - Veykril:proc-macro-test, r=lnicola
internal: Add proc-macro-test crate back to the main workspace

Should fix https://github.com/rust-lang/rust-analyzer/issues/16194
2024-01-04 11:00:33 +00:00
bors
8356bc9008 Auto merge of #16249 - lnicola:sync-from-rust, r=lnicola
internal: Sync from rust
2024-01-04 10:47:48 +00:00
Laurențiu Nicola
a66777cc71 Merge branch 'master' into sync-from-rust 2024-01-04 12:44:34 +02:00
Laurențiu Nicola
adf052c2ba Merge commit '426d2842c1f0e5cc5e34bb37c7ac3ee0945f9746' into sync-from-rust 2024-01-04 12:44:20 +02:00
Lukas Wirth
751d9d11e0 Add proc-macro-test crate back to the main workspace 2024-01-04 11:09:45 +01:00
Lukas Wirth
8390d2aca3 Set sysroot-abi flag for proc-macro-cli when in-rust-tree is set 2024-01-04 11:02:23 +01:00
Lukas Wirth
d480525ce8 Add extern crate rustc_driver to proc-macro-srv-cli 2024-01-04 11:02:23 +01:00
Lukas Wirth
ab2286935d Imply sysroot-abi feature when in-rust-tree is set 2024-01-04 11:02:23 +01:00
Lukas Wirth
b83f487d10 Set the in-rust-tree` feature for all rust-analyzer{-proc-macro-srv} steps 2024-01-04 11:02:20 +01:00
Nilstrieb
f0f74486bf Give a userful error when rustc cannot be found in explicit sysroot
Somehow r-a believed that my sysroot was something weird with no rustc.
Probably a me issue, but it was impossible to diagnose since r-a just
gave me a plain "No such file or directory". Adding this error makes it
clear what happened and allows diagnosing the problem.
2024-01-03 21:01:06 +01:00
bors
9279c6566b Auto merge of #16237 - Veykril:expand-arc-alloc, r=Veykril
internal: Remove unnecessary `Arc` allocations in `macro_expand`
2024-01-03 14:40:10 +00:00
bors
c3c07c66d3 Auto merge of #15933 - 71:inherent-items-in-docs, r=Veykril
feat: resolve inherent and implemented associated items in docs

This partially fixes #9694.

Supported:
- Trait methods and constants.
  * Due to resolution differences pointed out during the review of the PR, trait associated types are _not_ supported.
- Inherent methods, constants and associated types.
  * Inherent associated types are a [nightly feature](https://github.com/rust-lang/rust/issues/8995), and are supported with no additional work in this PR.

Screenshot of VS Code running with the change:

<img width="513" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/7189784/c37ed8b7-b572-4684-8e81-2a817b0027c4">

You can see that the items are resolved (excl. trait associated types) since they are semantically highlighted in the doc comment.
2024-01-03 14:28:38 +00:00
Lukas Wirth
3fc043ce9b internal: Remove unnecessary Arc allocations in macro_expand 2024-01-03 15:21:18 +01:00
bors
3fe6ff74cf Auto merge of #16085 - Austaras:master, r=Veykril
fix: try obligation of `IndexMut` when infer

Closes #15842.

This issue arises because `K` is ambiguous if only inferred from `Index` trait, but is unique if inferred from `IndexMut`, but r-a doesn't use this info.
2024-01-03 14:18:13 +00:00
bors
4f94ebb45a Auto merge of #16238 - lnicola:gentoo-docs, r=lnicola
Tweak Gentoo instructions

CC https://github.com/rust-lang/rust-analyzer/pull/15922#discussion_r1398224723
2024-01-03 14:06:47 +00:00
Young-Flash
c5c1360f7b fix: make diagnostic range accommodate for macros 2024-01-03 22:05:30 +08:00
Laurențiu Nicola
570ee51d50 Tweak Gentoo instructions 2024-01-03 16:05:00 +02:00
Grégoire Geis
fe6f931ac2 hir: resolve associated items in docs (excl. type aliases) 2024-01-03 23:04:24 +09:00
bors
91ffbd7788 Auto merge of #15922 - paul-jewell:master, r=Veykril
Updated instructions for installing rust-analyzer under Gentoo.

No need to install the guru overlay to install rust-analyzer. This is now installed based on use flag settings for dev-lang/rust and dev-lang/rust-bin. This pull request changes the instructions in the user manual.

Note: rust-analyzer is not available in the guru repository, so the old instructions no longer work.
2024-01-03 13:38:37 +00:00
bors
078183231b Auto merge of #16179 - nicolas-guichard:scip/new_fields, r=Veykril
SCIP: populate new SymbolInformation fields

Fixes #15919
2024-01-03 12:56:47 +00:00
bors
d987137b4e Auto merge of #16234 - Veykril:token-upmap, r=Veykril
fix: Fix focus range being discarded in attributes/derives when upmapping

Fixes https://github.com/rust-lang/rust-analyzer/issues/16229
2024-01-03 12:33:28 +00:00
Young-Flash
1a9b1b8ccc test: add test case for TupleField 2024-01-03 20:07:53 +08:00
Young-Flash
099c3204a2 fix: use PathTransform to resolve GenericArg 2024-01-03 20:07:29 +08:00
Nicolas Guichard
73d9c77f2a scip: Populate SymbolInformation::kind
SymbolInformation::kind is finer-grained than the SCIP symbol suffix.
This also fixes a bug where all type aliases where treated like type
parameters.

```
trait SomeTrait {
  type AssociatedType; // ← this is SomeTrait#[AssociatedType]
}

type MyTypeAlias = u8; // ← this used to be [MyTypeAlias]
                       //   and now is MyTypeAlias#
```
2024-01-03 13:05:36 +01:00
Lukas Wirth
cf22f02dc5 fix: Fix focus range being discarded in attributes/derives when upmapping 2024-01-03 12:15:28 +01:00
Nicolas Guichard
566bb77f91 scip: Populate SymbolInformation::signature_documentation 2024-01-03 10:56:12 +01:00
Nicolas Guichard
b24914970f Refactor label & docs from ide::hover::render to ide-db::defs::Definition
To build the SymbolInformation::signature_documentation we need access
to the “label” when building the TokenStaticData, preferably without
any markdown markup.
Therefore this refactors ide::hover::render::definition and its helper
functions to give easier access to the label alone.
2024-01-03 10:54:57 +01:00
Nicolas Guichard
495a55689b scip: Populate SymbolInformation::enclosing_symbol
For local variables, this gets the moniker from the enclosing
definition and stores it into the TokenStaticData.
Then it builds the scip symbol for that moniker when building the
SymbolInformation.
2024-01-03 10:54:57 +01:00
Nicolas Guichard
62663e6d4b scip: Refactor token_to_symbol to moniker_to_symbol
This is meant to implement SymbolInformation::enclosing_symbol, so we
can build the enclosing symbol from the enclosing moniker without
having the full enclosing token's TokenStaticData.
2024-01-03 10:54:57 +01:00
Nicolas Guichard
375f1cca4f scip: Populate SymbolInformation::display_name 2024-01-03 10:54:57 +01:00
Laurențiu Nicola
d3d7c4b722 Allow unexpected_cfgs in proc-macro-test imp 2024-01-03 11:36:05 +02:00
Laurențiu Nicola
932d85b529 Merge commit '426d2842c1f0e5cc5e34bb37c7ac3ee0945f9746' into sync-from-ra2 2024-01-03 11:35:07 +02:00
l1nxy
161d3055d1 use tail_expr(). 2024-01-03 09:48:49 +08:00
bors
426d2842c1 Auto merge of #16222 - rosefromthedead:unresolved-assoc-item, r=Veykril
add unresolved-assoc-item assist

I tried to copy from private-assoc-item for this
2024-01-02 15:06:13 +00:00
bors
86e559bf3f Auto merge of #16211 - tetsuharuohzeki:update-lint, r=Veykril
Use Cargo's [workspace.lints.*] to config clippy

This change begin to use [`[workspace.lints.*]`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-lints-table) that is stabilized since [Rust 1.74](https://blog.rust-lang.org/2023/11/16/Rust-1.74.0.html).

By this change, we make the configure more readable and simplify `xargo lint` more.
2024-01-02 14:53:22 +00:00
bors
1a0b772a43 Auto merge of #16153 - Veykril:err-msg, r=Veykril
fix: Notify user that linkedProjects is set when failing to discover projects

Fixes https://github.com/rust-lang/rust-analyzer/issues/15171
2024-01-02 14:42:03 +00:00
Lukas Wirth
8136e739f5 fix: Notify user that linkedProjects is set when failing to discover projects 2024-01-02 15:24:21 +01:00
bors
df94a87ea8 Auto merge of #16139 - jimmyhmiller:master, r=Veykril
Make functions in impl have a container name

fixes #16015
2024-01-02 14:08:37 +00:00
bors
7040cef07d Auto merge of #16068 - roife:fix-introduce-named-generic-name-conflicts, r=Veykril
fix: pick up new names when the name conflicts in 'introduce_named_generic'

Improve generation of names for generic parameters in `introduce_named_generics`.

fix #15731.

### Changes

- Modified `for_generic_parameter` function in `suggest_name.rs` to handle conflicts with existing generic parameters and generate unique names accordingly.
- Update `introduce_named_generic` function and pass existing params to `for_generic_parameter`, enabling the detection and handling of name collisions.
2024-01-02 13:58:06 +00:00
bors
f7a29e4e88 Auto merge of #16100 - Young-Flash:assoc_func_quickfix, r=Veykril
feat: add assoc func quickfix for `unresolved_method` diagnostic

![demo](https://github.com/rust-lang/rust-analyzer/assets/71162630/1ea1d8b8-3436-4251-a512-e0f9de01a13c)

close https://github.com/rust-lang/rust-analyzer/issues/13247

EDIT: I think add a demo gif would be helpful to `@lnicola` when he make a release change log :)
2024-01-02 13:46:35 +00:00
bors
76591096fb Auto merge of #16136 - saiintbrisson:fix/completion/a-tad-smarter-with-fns, r=Veykril
fix(completion): make the expected type a tad smarter with `Fn`s

This commit changes how the expected type is calculated when
working with Fn pointers, making the parenthesis stop vanishing
when completing the function name.

I've been bugged by the behavior of parenthesis completion for
a long while now. R-a assumes that the `LetStmt` type is the same
as the function type I've just written. Worse is that all parenthesis
vanish, even from functions that have completely different signatures.
It will now verify if the signature is the same.

While working on this, I noticed that record fields behave the same,
so I also made it prioritize the field type instead of the current
expression when possible, but I'm unsure if this is OK, so input is
appreciated.

ImplTraits as return types will still behave weirdly because lowering
is disallowed at the time it resolves the function types.

![image](https://github.com/rust-lang/rust-analyzer/assets/29989290/c06d6c93-5cac-4ebe-a93b-923017a6ae8c)
![image](https://github.com/rust-lang/rust-analyzer/assets/29989290/31594d82-fa4d-446c-a77e-47e9de1a9a67)
![image](https://github.com/rust-lang/rust-analyzer/assets/29989290/cf33856e-a485-411b-91af-11090d78a44e)
2024-01-02 13:35:42 +00:00
roife
919ecc6c32 Use HashSet to enhance performance in for_unique_generic_name in suggest_name 2024-01-02 21:33:06 +08:00
roife
bc1a5774fd fix: handle with type bounds in existing_params 2024-01-02 21:30:57 +08:00
roife
186553dab8 refactor: extracted the fn handling conflicts in generics and add docs
* Extracted the function `for_unique_generic_name` that handling generics with identical names for reusability.
* Renamed `for_generic_params` to `for_impl_trait_as_generic` for clarity
* Added documentations for `for_impl_trait_as_generic` and `for_unique_generic_name`
2024-01-02 21:30:57 +08:00