Commit Graph

701 Commits

Author SHA1 Message Date
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
austaras
1b7968a2cb fix: try obligation of IndexMut when infer 2023-12-31 07:19:16 +08:00
Tetsuharu Ohzeki
efc87092b3 Use Cargo's [workspace.lints.*] to config clippy 2023-12-29 23:51:32 +09:00
Lukas Wirth
9d24764624 internal: Cleanup Expander a bit 2023-12-22 13:01:13 +01:00
bors
3ce35931db Auto merge of #16178 - Veykril:builtin-fn-callsite, r=Veykril
fix: Fix span marking for builtin fn macros
2023-12-21 15:22:23 +00:00
Lukas Wirth
5bdb479131 fix: Fix span marking for builtin fn macros 2023-12-21 16:20:27 +01:00
bors
9ee71b43ca Auto merge of #16175 - Veykril:dummy-spans, r=Veykril
fix: Correctly set and mark the proc-macro spans

This slows down analysis by 2-3s on self for me unfortunately (~2.5% slowdown)

Noisy diff due to two simple refactoring in the first 2 commits. Relevant changes are [7d762d1](7d762d18ed) and [1e1113c](1e1113cf5f) which introduce def site spans and correct marking for proc-macros respectively.
2023-12-21 10:00:13 +00:00
Lukas Wirth
1e1113cf5f Correctly set and mark the proc-macro spans 2023-12-21 10:51:54 +01:00
Lukas Wirth
7d762d18ed Record macro def site spans 2023-12-21 09:54:47 +01:00
Lukas Wirth
51a9e7831a Rename some things and turn macro to macro def into a query 2023-12-21 09:18:25 +01:00
Lukas Wirth
071fe4e4e9 Move Intern and Lookup traits to hir-expand 2023-12-20 21:24:20 +01:00
bors
337e2abb67 Auto merge of #16167 - Veykril:dummy-spans, r=Veykril
fix: Fully remove dummy spans

Fixes https://github.com/rust-lang/rust-analyzer/issues/16008

Some of these spans are certainly wrong, but since we discard invisible delimiters currently it doesn't really matter.
2023-12-20 13:33:36 +00:00
Lukas Wirth
7b804552a5 Remove Delimiter::DUMMY_INVISIBLE 2023-12-20 14:00:14 +01:00
Lukas Wirth
4ec81230db Remove usages of Span::DUMMY 2023-12-20 12:53:46 +01:00
bors
7bdf48ce37 Auto merge of #16165 - Veykril:meta-vars, r=Veykril
fix: Update metavariable expression implementation

Fixes https://github.com/rust-lang/rust-analyzer/issues/16154
This duplicates behavior of that before and after PR https://github.com/rust-lang/rust/pull/117050 based on the toolchain version. There are some 1.76 nightlies that are still broken (any before that PR basically) but fetching and storing the commit makes little sense to me (opposed to the toolchain version).
2023-12-20 10:30:58 +00:00
Lukas Wirth
8753ca5360 fix: Update metavariable expression implementation 2023-12-19 11:55:00 +01:00
bors
484525f8d7 Auto merge of #16158 - saiintbrisson:fix/mbe/desugar-comment-to-raw-string, r=Veykril
fix(mbe): desugar doc correctly for mbe

Fixes #16110.

The way rust desugars doc comments when expanding macros is rendering it as raw strings delimited with hashes. Rust-analyzer wasn't aware of this, so the desugared doc comments wouldn't match correctly when on the LHS of macro declarations.

This PR fixes this by porting the code used by rustc:
59096cdad0/compiler/rustc_ast/src/tokenstream.rs (L662-L671)
2023-12-19 07:00:35 +00:00
Luiz Carvalho
6f58e98f2c
fix(mbe): update test 2023-12-19 01:03:00 -03:00
Luiz Carvalho
117a28a065
fix(mbe): desugar doc correctly for mbe
Fixes #16110.

The way rust desugars doc comments when expanding macros
is rendering it as raw strings delimited with hashes.
Rust-analyzer wasn't aware of this, so the desugared doc
comments wouldn't match correctly when on the LHS of macro
declarations.

This PR fixes this by porting the code used by rustc: 4cfdbd328b/compiler/rustc_ast/src/tokenstream.rs (L6837)
2023-12-19 00:55:56 -03:00
bors
0ed815faca Auto merge of #16151 - lnicola:minimal-2024-edition, r=davidbarsky
internal: Add minimal support for the 2024 edition

CC #16146
2023-12-18 17:33:20 +00:00
Laurențiu Nicola
fec0e04fc2 Add minimal support for the 2024 edition 2023-12-18 17:10:20 +02:00
Lukas Wirth
f49a2fed3f internal: Move out WithFixture into dev-dep only crate 2023-12-18 15:24:08 +01:00
Lukas Wirth
66e29be1bd internal: Split out a span crate 2023-12-18 14:08:33 +01:00
Lukas Wirth
35620306a6 internal: Move proc-macro knowledge out of base-db 2023-12-18 12:37:18 +01:00
bors
a7764198b1 Auto merge of #16123 - Veykril:simplify, r=Veykril
internal: Remove `ModuleId` from `TypeOwnerId`

It only exists due to the IDE layer, but we can encode this temporary hack more cleanly
2023-12-15 13:10:17 +00:00
Lukas Wirth
9083017c9d Remove ModuleId from TypeOwnerId 2023-12-14 14:11:57 +01:00
hkalbasi
6a40400c13 Update builtin attrs from rustc 2023-12-13 21:18:24 +03:30
bors
94af6c63b7 Auto merge of #16061 - Veykril:vec-completion, r=Veykril
fix: Fix fragment parser replacing matches with dummies on incomplete parses

Notably, this caused some completions in the `vec!` macro to no longer work. Fixes https://github.com/rust-lang/rust-analyzer/issues/15016
2023-12-13 09:59:13 +00:00
Lukas Wirth
7cc6b0f2e9 Partially revert #16101 2023-12-12 22:53:40 +01:00
bors
dd42c1457d Auto merge of #16101 - Veykril:search-depedencies-fix, r=Veykril
fix: Fix `import_map::search_dependencies` getting confused by assoc and non assoc items with the same name

No test case as creating one is kind of tricky... Ideally the code should be restructured such that this collision wouldn't matter in the first place, its kind of a mess.

Fixes https://github.com/rust-lang/rust-analyzer/issues/16074
Fixes https://github.com/rust-lang/rust-analyzer/issues/16080
Fixes https://github.com/rust-lang/rust-analyzer/issues/15845
2023-12-12 14:51:25 +00:00
Lukas Wirth
ca995d765d fix: Fix import_map::search_dependencies getting confused by assoc and non assoc items with the same name 2023-12-12 15:45:42 +01:00
hkalbasi
801c0ea478 Replace doc_comments_and_attrs with collect_attrs, 2nd round 2023-12-11 22:56:50 +03:30
Lukas Wirth
5f957658c1 fix: Fix fragment parser replacing matches with dummies on incomplete parses 2023-12-08 20:39:16 +01:00
Lukas Wirth
cf083fefc4 fix: Fix completion failing in format_args! with invalid template 2023-12-08 20:35:33 +01:00
bors
86cccc76e3 Auto merge of #16048 - Veykril:concat-bytes-fix, r=Veykril
fix: Fix concat_bytes! expansion emitting an identifier

Fixes https://github.com/rust-lang/rust-analyzer/issues/16046 (note that this has always been broken)
2023-12-08 12:27:58 +00:00
bors
6bbb2ac304 Auto merge of #15705 - rmehri01:14485_fix_delegate_self_references, r=Veykril
fix: resolve Self type references in delegate method assist

This PR makes the delegate method assist resolve any `Self` type references in the parameters or return type. It also works across macros such as the `uint_impl!` macro used for `saturating_mul` in the issue example.

Closes #14485
2023-12-08 11:31:34 +00:00
Ryan Mehri
7e768cbe70 fix: prefer keeping Self if it is in the same impl def 2023-12-08 12:30:14 +01:00
Lukas Wirth
d54745aed3 fix: Fix item tree lowering pub(self) to pub() 2023-12-08 11:59:44 +01:00
petr-tik
2d879e0431 Stop offering private functions in completions
Before
Private functions have RawVisibility module, but were
missed because take_types returned None early. After resolve_visibility
returned None, Visibility::Public was set instead and private functions
ended up being offered in autocompletion.

Choosing such a function results in an immediate error diagnostic
about using a private function.

After
Pattern match of take_types that returns None and
query for Module-level visibility from the original_module

Fix #15134 - tested with a unit test and a manual end-to-end
test of building rust-analyzer from my branch and opening
the reproduction repository

REVIEW
Refactor to move scope_def_applicable and check function visibility
from a module

Please let me know what's the best way to add a unit tests to
nameres, which is where the root cause was
2023-12-08 11:38:54 +01:00
Lukas Wirth
71337f6682 fix: Fix concat_bytes! expansion 2023-12-08 11:34:03 +01:00
Lukas Wirth
5544f4fa3d Bump and unlock some dependencies 2023-12-07 11:48:58 +01:00
Lukas Wirth
634d588fd7 Simplify 2023-12-06 14:36:39 +01:00
Lukas Wirth
9cb13b6efb Allow navigation targets to be duplicated when the focus range lies in the macro definition site 2023-12-06 12:38:19 +01:00
Lukas Wirth
d2cd30007c Implicit format args support 2023-12-05 17:07:00 +01:00
Igor Matuszewski
a7224c998d Don't explicitly warn against semicolon_in_expressions_from_macros
This has been warn-by-default for two years now and has already been
added to the future-incompat lints in 1.68.
2023-12-05 11:35:09 +01:00
bors
e91fdf7860 Auto merge of #15959 - Veykril:macro-shower3, r=lnicola
TokenMap -> SpanMap rewrite

Opening early so I can have an overview over the full diff more easily, still very unfinished and lots of work to be done.

The gist of what this PR does is move away from assigning IDs to tokens in arguments and expansions and instead gives the subtrees the text ranges they are sourced from (made relative to some item for incrementality). This means we now only have a single map per expension, opposed to map for expansion and arguments.

A few of the things that are not done yet (in arbitrary order):
- [x] generally clean up the current mess
- [x] proc-macros, have been completely ignored so far
- [x] syntax fixups, has been commented out for the time being needs to be rewritten on top of some marker SyntaxContextId
- [x] macro invocation syntax contexts are not properly passed around yet, so $crate hygiene does not work in all cases (but most)
  - [x] builtin macros do not set spans properly, $crate basically does not work with them rn (which we use)
~~- [ ] remove all uses of dummy spans (or if that does not work, change the dummy entries for dummy spans so that tests will not silently pass due to havin a file id for the dummy file)~~
  - [x] de-queryfy `macro_expand`, the sole caller of it is `parse_macro_expansion`, and both of these are lru-cached with the same limit so having it be a query is pointless
- [x] docs and more docs
- [x] fix eager macro spans and other stuff
  - [x] simplify include! handling
- [x] Figure out how to undo the sudden `()` expression wrapping in expansions / alternatively prioritize getting invisible delimiters working again
- [x] Simplify InFile stuff and HirFIleId extensions
~~- [ ] span crate containing all the file ids, span stuff, ast ids. Then remove the dependency injection generics from tt and mbe~~

Fixes https://github.com/rust-lang/rust-analyzer/issues/10300
Fixes https://github.com/rust-lang/rust-analyzer/issues/15685
2023-12-04 19:59:53 +00:00
Laurențiu Nicola
26c0963281 Merge branch 'master' into sync-from-rust 2023-12-04 21:39:22 +02:00
Laurențiu Nicola
30fc9329d1 Merge commit 'e402c494b7c7d94a37c6d789a216187aaf9ccd3e' into sync-from-ra 2023-12-04 09:19:15 +02:00
Lukas Wirth
02a3a9438a Some more minor cleanups 2023-12-02 17:04:13 +01:00
Lukas Wirth
5edf7bddc6 Fix mod item in included file resolving incorrectly 2023-12-02 13:49:09 +01:00