Commit Graph

720 Commits

Author SHA1 Message Date
Jonas Schievink
0642724e94 Provide signature help when editing generic args 2022-03-18 19:59:41 +01:00
bors[bot]
6ad8c022ed
Merge #11750
11750: fix: Fix runnables trying to add doc tests in the crate root from #[macro_export] macros r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11746
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-18 11:13:37 +00:00
Lukas Wirth
828196be3b fix: Fix runnables trying to add doc tests in the crate root from #[macro_export] macros 2022-03-18 12:01:59 +01:00
Florian Diebold
9ea2e0bd5b Fixes for consts 2022-03-17 17:04:32 +01:00
bors[bot]
683fea4de4
Merge #11707
11707: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-14 20:05:46 +00:00
Lukas Wirth
fbc1d2a514 Simplify 2022-03-14 20:36:35 +01:00
hkalbasi
b301b040f5 Add const generics 2022-03-14 14:38:37 +03:30
Matthias Krüger
56e4ea59d9 more clippy fixes:
clippy::match_like_matches_macro
clippy::to_string_in_format_args
clippy::single_char_add_str
clippy::filter_map_identity
clippy::clone_on_copy
clippy::useless_format
clippy::unused_unit
2022-03-12 16:50:49 +01:00
Matthias Krüger
21ffc5350d fix clippy::redundant_clone 2022-03-12 16:50:49 +01:00
Matthias Krüger
d64d711db2 fix clippy::map_flatten 2022-03-12 16:50:49 +01:00
Matthias Krüger
62ed658311 fix clippy::useless_conversion 2022-03-12 16:50:49 +01:00
Matthias Krüger
7912e33ed6 fix clippy::needless_borrow 2022-03-12 16:50:49 +01:00
Lukas Wirth
301711ee71 internal: Remove ide_completion::render::build_ext module 2022-03-12 16:13:49 +01:00
Lukas Wirth
a9dd606387 fix: Show what file paths were expected for unresolved modules 2022-03-11 17:08:30 +01:00
Lukas Wirth
6c8c02f625 Don't parse source files to generate macro completion details 2022-03-10 22:21:58 +01:00
Lukas Wirth
2abe19e46a Don't offer qualified path completions for buitlin derives 2022-03-10 21:22:13 +01:00
Lukas Wirth
a8b76b632c Expand into pseudo-derive attribute expansions in completions 2022-03-10 20:53:50 +01:00
bors[bot]
4fcaefa62a
Merge #11660
11660: Insert dummy values for const generics in subst r=flodiebold a=HKalbasi

fix #11659 

This is a band-aid until proper const generic support.

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-03-09 17:18:03 +00:00
Lukas Wirth
2537ad0d9e Simplify 2022-03-09 11:26:06 +01:00
Lukas Wirth
f9c8646d89 fix symbol index collection not collecting legacy macros 2022-03-09 01:44:20 +01:00
Lukas Wirth
4e94fb7028 Fix ProcMacroData recording wrong name for derives 2022-03-09 01:13:38 +01:00
Lukas Wirth
c37fe779c6 Add data queries for macros 2022-03-09 00:41:54 +01:00
Lukas Wirth
55ec93a337 Remove unnecessary macro_declarations from ItemScope 2022-03-09 00:19:53 +01:00
Lukas Wirth
c04b0f435b Move hir to new MacroId 2022-03-08 23:51:48 +01:00
hkalbasi
1282178783 insert dummy values for const generics in subst 2022-03-09 02:02:42 +03:30
Lukas Wirth
93b09ca067 Update tidy ignore list 2022-03-06 19:18:40 +01:00
Lukas Wirth
c1f91c93b2 minor: Simplify 2022-03-06 17:56:02 +01:00
Lukas Wirth
d460b7c9d1 Fix extern crate self having self unresolved 2022-03-06 00:17:40 +01:00
Andy Russell
49fab593ad
show variadic args in hover function signature 2022-03-04 16:44:31 -05:00
Lukas Wirth
32bf7af83e Support locals with multiple declaration sites 2022-03-04 19:49:08 +01:00
hkalbasi
660fd4ab41 Resolve only type params in type ns 2022-03-04 12:30:53 +03:30
hkalbasi
4fa8749c44 Preserve order of generic args 2022-03-04 11:46:14 +03:30
Lukas Wirth
47ce4436e4 Make hir::Local::name infallible 2022-02-26 16:36:44 +01:00
Florian Diebold
6fb5abbc03 Refactor autoderef and method resolution
- don't return the receiver type from method resolution; instead just
 return the autorefs/autoderefs that happened and repeat them. This
 ensures all the effects like trait obligations and whatever we learned
 about type variables from derefing them are actually applied. Also, it
 allows us to get rid of `decanonicalize_ty`, which was just wrong in
 principle.

 - Autoderef itself now directly works with an inference table. Sadly
 this has the effect of making it harder to use as an iterator, often
 requiring manual `while let` loops. (rustc works around this by using
 inner mutability in the inference context, so that things like unifying
 types don't require a unique reference.)

 - We now record the adjustments (autoref/deref) for method receivers
 and index expressions, which we didn't before.

 - Removed the redundant crate parameter from method resolution, since
 the trait_env contains the crate as well.

 - in the HIR API, the methods now take a scope to determine the trait env.
 `Type` carries a trait env, but I think that's probably a bad decision
 because it's easy to create it with the wrong env, e.g. by using
 `Adt::ty`. This mostly didn't matter so far because
 `iterate_method_candidates` took a crate parameter and ignored
 `self.krate`, but the trait env would still have been wrong in those
 cases, which I think would give some wrong results in some edge cases.

Fixes #10058.
2022-02-25 11:47:14 +01:00
Akshay
a5ab6a2f75 add is_slice method to hir::Type 2022-02-24 15:20:12 +05:30
Lukas Wirth
e759db361e Resolve functions as proc-macros via FileAstId 2022-02-23 11:21:46 +01:00
Lukas Wirth
8db88df758 simplify and document 2022-02-22 10:45:29 +01:00
Lukas Wirth
94e59c9c56 Simplify 2022-02-22 10:20:45 +01:00
Lukas Wirth
1bbef5af85 Fix syntax highlighting not highlighting derives anymore 2022-02-22 10:20:44 +01:00
Lukas Wirth
f13c98034b Make replace_derive_with_manual_impl work again 2022-02-22 10:20:44 +01:00
Lukas Wirth
7b89d5ede2 internal: Expand the derive attribute into a pseudo expansion 2022-02-22 10:20:40 +01:00
bors[bot]
979b5b32bc
Merge #11455
11455: Handle proc-macro functions as the proc-macro they resolve to r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11212

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-21 16:56:37 +00:00
Lukas Wirth
8cdef2ffcf fix: Don't count commas when looking for the derive attribute in diagnostics 2022-02-21 13:43:42 +01:00
Lukas Wirth
035bedc28b internal: Remove name fields from MacroCallKind 2022-02-21 00:02:10 +01:00
Lukas Wirth
cef8a17ea5 Handle proc-macro functions as the proc-macro they resolve to 2022-02-11 22:06:03 +01:00
Lukas Wirth
661d721e20 Add completion module tailored towards use trees 2022-02-03 15:51:57 +01:00
Lukas Wirth
6940cca760 Move attribute path completions into attribute completion module 2022-02-03 15:50:14 +01:00
Florian Diebold
4ed5fe1554 Fix assoc type shorthand from method bounds
In code like this:
```rust
impl<T> Option<T> {
    fn as_deref(&self) -> T::Target where T: Deref {}
}
```

when trying to resolve the associated type `T::Target`, we were only
looking at the bounds on the impl (where the type parameter is defined),
but the method can add additional bounds that can also be used to refer
to associated types. Hence, when resolving such an associated type, it's
not enough to just know the type parameter T, we also need to know
exactly where we are currently.

This fixes #11364 (beta apparently switched some bounds around).
2022-02-03 13:15:02 +01:00
Lukas Wirth
d7a544e69a fix: Complete functions and methods from block level impls 2022-02-01 23:29:40 +01:00
Lukas Wirth
45ff51ba22 Make more precise range macro upmapping 2022-01-31 15:53:44 +01:00
Lukas Wirth
6194092086 Complete local fn and closure params from surrounding locals scope 2022-01-31 11:56:42 +01:00
Lukas Wirth
ddf7b70a0f Fix cfg_attr invalidating derive identifier IDE functionality 2022-01-30 22:47:16 +01:00
Lukas Wirth
cc04cfc982 Reduce allocations in attribute collection 2022-01-30 22:18:32 +01:00
Lukas Wirth
ebd723995a fix: don't panic in semantics due to cfg_attr disrupting offsets 2022-01-23 17:42:38 +01:00
Jonas Schievink
8a7f0d920e Allow macros to expand to or-patterns 2022-01-17 16:52:53 +01:00
Lukas Wirth
82fccb971e feat: Add very simplistic ident completion for format_args! macro input 2022-01-15 12:23:26 +01:00
bors[bot]
fc331fe831
Merge #11282
11282: fix: Properly cache files in Semantics when ascending macros r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11280
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-14 10:08:27 +00:00
Lukas Wirth
f1cb5ed9b0 fix: Properly cache files in Semantics when ascending macros 2022-01-14 11:07:53 +01:00
Lukas Wirth
2f8dd64830 Replace HasSource usages with Semantics equivalent 2022-01-14 10:59:27 +01:00
Jonas Schievink
3fde9f820a Unexport MacroDefId from hir 2022-01-13 16:18:05 +01:00
Jonas Schievink
18e80e6892 Remove ModuleId from hir reexports 2022-01-12 20:21:13 +01:00
Jonas Schievink
09219e10f1 Mostly restore hir API boundary 2022-01-12 19:56:47 +01:00
Jonas Schievink
0706de94bb Report DefDiagnostics from inside item bodies 2022-01-11 14:34:25 +01:00
bors[bot]
5a711d4f3a
Merge #11210
11210: feat: Deprioritize ops methods in completion r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10593



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-11 09:39:12 +00:00
Lukas Wirth
ca0633c808 feat: Deprioritize ops methods in completion 2022-01-11 09:26:53 +01:00
Lukas Wirth
47591f0fb2 Remove InFile wrapping from DynMap keys 2022-01-08 12:16:44 +01:00
Lukas Wirth
6746ba5839 Record attribute calls on assoc items in TraitData and ImplData 2022-01-08 10:45:12 +01:00
bors[bot]
41a0e95d61
Merge #11230
11230: fix: Fix attribute stripping ignoring doc comments r=Veykril a=Veykril

Follow up to https://github.com/rust-analyzer/rust-analyzer/pull/11225#pullrequestreview-846779237


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 18:06:33 +00:00
Lukas Wirth
81163b8cd4 fix: Fix attribute stripping ignoring doc comments 2022-01-07 18:51:10 +01:00
bors[bot]
40009e07d0
Merge #11145
11145: feat: add config to use reasonable default expression instead of todo! when filling missing fields r=Veykril a=bnjjj

Use `Default::default()` in struct fields when we ask to fill it instead of putting `todo!()` for every fields

before:

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {<|>};
}
``` 

after: 

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {
        text: String::new(),
        num: 0,
        other: todo!(),
    };
}
``` 



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
2022-01-07 14:10:11 +00:00
Lukas Wirth
ca4baa6e55 Use FileAstId<ast::Adt> in nameres where appropriate instead 2022-01-07 14:20:27 +01:00
Benjamin Coenen
f4ce0d78bb add better default behavior on fill struct fields diagnostic
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-06 15:42:29 +01:00
Lukas Wirth
dc135cc076 internal: Support registered tools and attributes in ide layer 2022-01-06 14:56:50 +01:00
bors[bot]
ac3ea3e81c
Merge #11112
11112: Evaluate constants in array repeat expression r=HKalbasi a=HKalbasi

cc #8655 

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-01-04 21:51:37 +00:00
hkalbasi
75c2acae6e Evaluate constants in array repeat expression 2022-01-05 01:17:01 +03:30
Benjamin Coenen
336c899a07 add better default behavior on fill struct fields diagnostic
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-04 15:59:00 +01:00
Lukas Wirth
19f1ff5c70 give resolve_derive_ident a more robust api 2022-01-03 16:00:45 +01:00
Lukas Wirth
44b0fe8ec7 cleanup 2022-01-02 23:44:26 +01:00
Lukas Wirth
aeb5d64912 Implement ToDef for ast::Attr 2022-01-02 23:44:26 +01:00
Lukas Wirth
6b7b09d329 internal: Record unresolved derive invocations in hir 2022-01-02 23:44:23 +01:00
Lukas Wirth
762a3b3030 Fix tool module classification not working correctly 2022-01-02 23:14:18 +01:00
Lukas Wirth
44d61766b5 internal: Record unresolved derive invocations in hir 2022-01-01 20:43:25 +01:00
Aleksey Kladov
aa1788dc71 clarify semantics of doc links 2021-12-28 17:00:55 +03:00
Aleksey Kladov
177a183e85 minor: simplify 2021-12-28 16:52:15 +03:00
Aleksey Kladov
56b51852c2 minor: dedup 2021-12-28 16:52:15 +03:00
Aleksey Kladov
726da9884b avoid speculation when completing macros 2021-12-28 16:52:15 +03:00
hkalbasi
e6139cf47b show values of constants in hover 2021-12-23 17:53:46 +03:30
Lukas Wirth
276687a6ee internal: Directly use self param in completions instead of searching 2021-12-22 00:18:39 +01:00
Lukas Wirth
22b2c2fdf7 Simplify 2021-12-21 14:07:48 +01:00
Lukas Wirth
8e084132f8 internal: Do less work in hir::Semantics 2021-12-21 13:38:58 +01:00
bors[bot]
8dc3a270f6
Merge #11067
11067: internal: Store function param names in ItemTree r=Veykril a=Veykril

This prevents us reparsing source files for completions, sometimes slowing them down massively if the source file is not cached at the expense of a slightly bigger memory usage.

related info https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Completion.20performance

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-20 14:43:39 +00:00
Lukas Wirth
cd9d76e0ca internal: Store function param names in ItemTree 2021-12-20 15:24:37 +01:00
bors[bot]
f46731a230
Merge #11028
11028: Bump MSRV (1.57) r=Veykril a=iDawer

This bumps MSRV on all crates to 1.57 except `la-arena`

#10986 requires >=1.57 

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2021-12-20 13:45:35 +00:00
Lukas Wirth
a574434c3f Simplify NameClass::classify 2021-12-20 13:47:06 +01:00
Lukas Wirth
37a87708ae internal: Don't kick off inference in Semantics::descend_into_macros_impl 2021-12-20 13:19:48 +01:00
Laurențiu Nicola
32b6f103a6 Bump chalk 2021-12-19 18:58:39 +02:00
iDawer
676744be6e Bump MSRV (1.57) 2021-12-16 01:56:12 +05:00
Lukas Wirth
9915103c9e Simplify 2021-12-14 12:38:20 +01:00
Lukas Wirth
749eeef3e7 fix: insert whitespaces into assoc items for assist when macro generated 2021-12-13 16:35:32 +01:00
Lukas Wirth
328419534d Move ws insert rendering for macro expansion into ide_db 2021-12-13 15:55:13 +01:00