Commit Graph

18853 Commits

Author SHA1 Message Date
davidsemakula
4a6b16bfbe order use trees following rustfmt's algorithm for ordering imports 2024-01-11 20:04:45 +03:00
bors
9d8889cdfc Auto merge of #16348 - Veykril:nested-includes, r=Veykril
fix: Fix nested includes resolving from the wrong base file

Fixes https://github.com/rust-lang/rust-analyzer/issues/16109
2024-01-11 11:53:24 +00:00
Lukas Wirth
215ede8497 fix: Fix nested includes resolving from the wrong base file 2024-01-11 12:41:47 +01:00
Lukas Wirth
b6e6d5d3af internal: Consider all kinds of explicit private imports in find_path 2024-01-11 12:22:04 +01:00
bors
d5366b5c19 Auto merge of #16265 - Patryk27:suggest-pub-crate-imports, r=Veykril
fix: Acknowledge `pub(crate)` imports in import suggestions

rust-analyzer has logic that discounts suggesting `use`s for private imports, but that logic is unnecessarily strict - for instance given this code:

```rust
mod foo {
    pub struct Foo;
}

pub(crate) use self::foo::*;

mod bar {
    fn main() {
        Foo$0;
    }
}
```

... RA will suggest to add `use crate::foo::Foo;`, which not only makes the code overly verbose (especially in larger code bases), but also is disjoint with what rustc itself suggests.

This commit adjusts the logic, so that `pub(crate)` imports are taken into account when generating the suggestions; considering rustc's behavior, I think this change doesn't warrant any extra configuration flag.

Note that this is my first commit to RA, so I guess the approach taken here might be suboptimal - certainly feels somewhat hacky, maybe there's some better way of finding out the optimal import path 😅
2024-01-11 09:54:22 +00:00
Patryk Wychowaniec
76aaf17794
Suggest pub(crate) imports
rust-analyzer has logic that discounts suggesting `use`s for private
imports, but that logic is unnecessarily strict - for instance given
this code:

```rust
mod foo {
    pub struct Foo;
}

pub(crate) use self::foo::*;

mod bar {
    fn main() {
        Foo$0;
    }
}
```

... RA will suggest to add `use crate::foo::Foo;`, which not only makes
the code overly verbose (especially in larger code bases), but also is
disjoint with what rustc itself suggests.

This commit adjusts the logic, so that `pub(crate)` imports are taken
into account when generating the suggestions; considering rustc's
behavior, I think this change doesn't warrant any extra configuration
flag.

Note that this is my first commit to RA, so I guess the approach taken
here might be suboptimal - certainly feels somewhat hacky, maybe there's
some better way of finding out the optimal import path 😅
2024-01-10 18:21:16 +01:00
Lukas Wirth
4d3a0dc329 Replace SourceRootCrates hashset output with slice for deterministic order 2024-01-10 14:51:51 +01:00
bors
e5a1118265 Auto merge of #16330 - zheylmun:master, r=Veykril
minor: Mark unresolved associated item diagnostic as experimental

Per #16327 unresolved associated item has false positives.  Mark the diagnostic as experimental until this is more dependable.
2024-01-10 12:10:30 +00:00
Zach
1aff8157bc Set experimental field at diagnostic new instead of lib 2024-01-10 05:58:25 -06:00
bors
b201684982 Auto merge of #16274 - dfireBird:completion_score, r=Veykril
Add notable_trait predicate to `CompletionRelevance`

Given a score of 1 for now, will change as per reviews needed.
2024-01-10 11:16:52 +00:00
dfireBird
257870e09f
add tests to verify relevance of notable traits and some refactors 2024-01-10 16:30:22 +05:30
bors
1c9bb31970 Auto merge of #16209 - l1nxy:add-merge-nested-if, r=Veykril
feat: assist to merge nested if

resolve: #16095
2024-01-10 09:18:05 +00:00
Lukas Wirth
4b7b602da9 Remove sysroot-abi feature flag from proc-macro-test 2024-01-10 09:53:12 +01:00
roife
d327f3036c Add test 'comments_in_block_expr' in in 'extract_function' 2024-01-10 15:00:58 +08:00
roife
bc54775c9d Preserve comments for extracted block expr in 'extract_function' assist 2024-01-10 15:00:35 +08:00
Zach
beeaaf184e Mark unresolved associated item diagnostic as experimental 2024-01-09 17:09:50 -06:00
Lukas Wirth
f8b130a6aa unreachable pub 2024-01-09 21:35:22 +01:00
Lukas Wirth
c4b3075be0 Don't allocate inherent_impls_in_block and trait_impls_in_block if its empty 2024-01-09 21:20:03 +01:00
Lukas Wirth
4e16e0f2c1 Don't allocate DefDatabase::crate_lang_items if its empty 2024-01-09 21:06:21 +01:00
Lukas Wirth
9673915045 Make DefDatabase::lang_attr transparent 2024-01-09 20:52:10 +01:00
Lukas Wirth
06aaf20f10 Some minor perf improvements 2024-01-09 20:43:17 +01:00
bors
51ac6de6f3 Auto merge of #16277 - roife:fix-issue16276, r=Veykril
Resolve panic in `generate_delegate_methods`

Fixes #16276

This PR addresses two issues:

1. When using `PathTransform`, it searches for the node corresponding to the `path` in the `source_scope` during `make::fn_`. Therefore, we need to perform the transform before `make::fn_` (similar to the problem in issue #15804). Otherwise, even though the tokens are the same, their offsets (i.e., `span`) differ, resulting in the error "Can't find CONST_ARG@xxx."

2. As mentioned in the first point, `PathTransform` searches for the node corresponding to the `path` in the `source_scope`. Thus, when transforming paths, we should update nodes from right to left (i.e., use **reverse of preorder** (right -> left -> root) instead of **postorder** (left -> right -> root)). Reasons are as follows:

    In the red-green tree (rowan), we do not store absolute ranges but instead store the length of each node and dynamically calculate offsets (spans). Therefore, when modifying the left-side node (such as nodes are inserted or deleted), it causes all right-side nodes' spans to change. This, in turn, leads to PathTransform being unable to find nodes with the same paths (due to different spans), resulting in errors.
2024-01-09 15:52:34 +00:00
bors
da6f7e2c7b Auto merge of #16275 - davidsemakula:ast-path-segments, r=Veykril
fix: Fix `ast::Path::segments` implementation

calling `ast::Path::segments` on a qualifier currently returns all the segments of the top path instead of just the segments of the qualifier.

The issue can be summarized by the simple failing test below:
```rust
#[test]
fn path_segments() {
    //use ra_ap_syntax::ast;
    let path: ast::Path = ...; // e.g. `ast::Path` for "foo::bar::item".

    let path_segments: Vec<_> = path.segments().collect();
    let qualifier_segments: Vec<_> = path.qualifier().unwrap().segments().collect();
    assert_eq!(path_segments.len(), qualifier_segments.len() + 1); // Fails because `LHS = RHS`.
}
```

This PR:
- Fixes the implementation of `ast::Path::segments`
- Fixes `ast::Path::segments` callers that either implicitly relied on behavior of previous implementation or exhibited other "wrong" behavior directly related to the result of `ast::Path::segments` (all callers have been reviewed, only one required modification)
- Removes unnecessary (and now unused) `ast::Path::segments` alternatives
2024-01-09 15:41:48 +00:00
bors
9e34e643a1 Auto merge of #16319 - Veykril:no-double-load, r=Veykril
fix: Differentiate between vfs config load and file changed events

Kind of fixes https://github.com/rust-lang/rust-analyzer/issues/14730 in a pretty bad way. We need to rethink the vfs-notify layer entirely. For a decent fix.
2024-01-09 10:24:23 +00:00
bors
e3575a87de Auto merge of #16312 - Veykril:win-proc-macro-srv, r=Veykril
fix: Fix rust-analyzer-proc-macro-srv failing to spawn on windows
2024-01-09 10:12:57 +00:00
bors
acafce3389 Auto merge of #16309 - Veykril:proc-macro-srv-err, r=Veykril
Recognize proc macro server unexpectedly exiting and report the exit code
2024-01-09 10:01:10 +00:00
bors
c246ecfd55 Auto merge of #16310 - Veykril:range-access-parse, r=Veykril
fix: Fix incorrect parsing error on method call on range

Fixes https://github.com/rust-lang/rust-analyzer/issues/16289
2024-01-09 09:49:25 +00:00
bors
25f71469f1 Auto merge of #16311 - Veykril:rustc-deps, r=Veykril
internal: Remove `rustc_dependencies ` crate

The crate serves no purpose really
2024-01-09 09:37:48 +00:00
Lukas Wirth
21a953fe37 Recognize proc macro server unexpectedly exiting and report the exit code 2024-01-09 10:37:26 +01:00
Lukas Wirth
a8c94eaf13 fix: Fix rust-analyzer-proc-macro-srv failing to spawn on windows 2024-01-09 10:35:54 +01:00
Lukas Wirth
e1c67485bf fix: Differentiate between vfs config load and file changed events 2024-01-09 10:30:16 +01:00
Laurențiu Nicola
4413aeb9e8 Temporarily disable resolve_proc_macro test 2024-01-09 10:27:36 +02:00
Laurențiu Nicola
b0b2b1c5f1 Fix allow(dead_code) 2024-01-09 10:00:57 +02:00
Laurențiu Nicola
0ae73738ad Try to fix feature gates 2024-01-09 09:52:58 +02:00
Laurențiu Nicola
f52f2f9c3c Merge branch 'master' into sync-from-rust 2024-01-09 08:46:16 +02:00
bors
598511b4e8 Auto merge of #16308 - Veykril:builtin-macro-hygiene, r=lnicola
Builtin derives are hygienic

Closes https://github.com/rust-lang/rust-analyzer/issues/16295
2024-01-08 17:10:32 +00:00
dfireBird
df5c647982
add notable_trait predicate to CompletionRelevance
implement the predicate set on the case function from traits
2024-01-08 20:34:11 +05:30
Lukas Wirth
f972da70d4 Remove rustc_dependencies crate 2024-01-08 15:39:35 +01:00
Lukas Wirth
e25e0dd0ad Split out rustc_parse_format from rustc_dependencies 2024-01-08 15:30:26 +01:00
Lukas Wirth
b97ab00bd4 Split out rustc_lexer from rustc_dependencies 2024-01-08 15:24:46 +01:00
Lukas Wirth
72200641c1 fix: Fix incorrect parsing error on method call on range 2024-01-08 15:09:26 +01:00
Lukas Wirth
1c40ac79c8 VFS no longer stores all source files in memory 2024-01-08 12:51:16 +01:00
Lukas Wirth
7dd9f20ce3 Builtin derives are hygienic 2024-01-08 12:50:11 +01:00
Laurențiu Nicola
3afeb24198 Merge commit 'af40101841c45aa75b56f4e9ca745369da8fb4ba' into sync-from-ra 2024-01-08 11:29:25 +02:00
bors
6ce3f44597 Auto merge of #16298 - riverbl:exclusive-range-hint, r=Veykril
feat: Add inlay hint for exclusive ranges

Adds an inlay hint containing a '<' character to exclusive range expressions and patterns that specify an upper bound.

![2024-01-07-095056_257x415_scrot](https://github.com/rust-lang/rust-analyzer/assets/94326797/d6bbc0de-52a5-4af4-b53c-a034749b6cab)

Inspired by [this comment](https://github.com/rust-lang/rust/issues/37854#issuecomment-1865124907) noting that IntelliJ Rust has this feature.
2024-01-07 10:21:39 +00:00
riverbl
3c378b9c70 Add inlay hint for exclusive ranges
Adds an inlay hint containing a '<' character to exclusive range expressions and patterns that specify an upper bound.
2024-01-07 09:33:56 +00:00
Matthias Krüger
3fb2cd2002 autofix remaining perf findings 2024-01-07 01:20:20 +01:00
Matthias Krüger
196650dfaf don't to_string() format args 2024-01-07 01:11:57 +01:00
Matthias Krüger
b22bd36f6e remove more redundant clones manually 2024-01-07 00:26:49 +01:00
Matthias Krüger
476e10e961 remove redundant clones 2024-01-07 00:17:48 +01:00