Commit Graph

26888 Commits

Author SHA1 Message Date
Lukas Wirth
634d588fd7 Simplify 2023-12-06 14:36:39 +01:00
bors
cc8faa697c Auto merge of #16034 - Veykril:ide-macro-improvements, r=Veykril
feat: Allow navigation targets to be duplicated when the focus range lies in the macro definition site

![Code_KI1EfbAHRZ](https://github.com/rust-lang/rust-analyzer/assets/3757771/2cc82e5c-320f-4de2-9d55-fe975d180f2a)

Basically if a name of an item originates from the macro definition we now point to that as well as the creating macro call.

Big diff because I also made `FileId`s field private due to some debugging I had to do (having a searchable constructor makes things easier).
2023-12-06 11:47:46 +00: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
Michael Goulet
76c972cb54 Rollup merge of #118123 - RalfJung:internal-lib-features, r=compiler-errors
Add support for making lib features internal

We have the notion of an "internal" lang feature: a feature that is never intended to be stabilized, and using which can cause ICEs and other issues without that being considered a bug.

This extends that idea to lib features as well. It is an alternative to https://github.com/rust-lang/rust/pull/115623: instead of using an attribute to declare lib features internal, we simply do this based on the name. Everything ending in `_internals` or `_internal` is considered internal.

Then we rename `core_intrinsics` to `core_intrinsics_internal`, which fixes https://github.com/rust-lang/rust/issues/115597.
2023-12-05 14:52:41 -05:00
bors
05df6c52ca Auto merge of #16027 - Veykril:implicit-format-args, r=Veykril
feat: Implicit format args support

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

![image](https://github.com/rust-lang/rust-analyzer/assets/3757771/14fe2caf-4ea3-40a5-8aa4-ff08ea0ccbde)
Too lazy to make a gif of this right now (would probably be good to show renaming)
2023-12-05 16:15:45 +00:00
Lukas Wirth
9b7ec5e31b Ignore strings in token trees in syntax highlighting 2023-12-05 17:07:00 +01:00
Lukas Wirth
4525787ed5 Add test for implicit format args support through nested macro call 2023-12-05 17:07:00 +01:00
Lukas Wirth
fe0a85ca29 Resolve implicit format args in syntax highlighting 2023-12-05 17:07:00 +01:00
Lukas Wirth
d2cd30007c Implicit format args support 2023-12-05 17:07:00 +01:00
Lukas Wirth
5b8e386bae Improve macro descension API 2023-12-05 17:06:57 +01:00
Young-Flash
afc4075c7c fix: make drop inlay hint more readable 2023-12-05 22:56:51 +08:00
bors
afc1ae1aa3 Auto merge of #16016 - dfireBird:regression-fix-15879, r=lnicola
fix: Insert fn call parens only if the parens inserted around field name

Fixes #16014.

Sorry I missed it in previous PR. I've added a test as level to prevent regressions again.
Give any suggestions to improve the test if anything.
2023-12-05 14:53:29 +00:00
bors
986577faaa Auto merge of #16026 - lnicola:bump-rustc-deps, r=lnicola
minor: Bump rustc deps
2023-12-05 11:42:14 +00:00
Laurențiu Nicola
73b9f885f6 Bump ra-ap-rustc_index and ra-ap-rustc_abi 2023-12-05 13:40:29 +02:00
Laurențiu Nicola
22676ce946 Revert "Temporarily revert delay_bug to delayed_bug change"
This reverts commit 6d2543b622.
2023-12-05 13:39:45 +02:00
Laurențiu Nicola
a9b037f510 Bump ra-ap-rustc_parse_format 2023-12-05 13:39:17 +02:00
Laurențiu Nicola
1834b38dbe Bump ra-ap-rustc_lexer 2023-12-05 13:38:35 +02:00
bors
a90a42b407 Auto merge of #16022 - Xanewok:no-warn-semicolon-in-expr-from-macros, r=lnicola
internal: 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.

See https://github.com/rust-lang/rust/issues/79813 for the tracking issue.
2023-12-05 11:23:25 +00:00
bors
ceb4426cd6 Auto merge of #16024 - lnicola:debug-workspace-path, r=lnicola
fix: Fix runnable cwd on Windows

Fixes #16010
2023-12-05 11:11:43 +00:00
Laurențiu Nicola
9dc38214c0 Fix runnable cwd on Windows 2023-12-05 13:09:01 +02: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
2d66f6df25 Auto merge of #16018 - lnicola:no-debug, r=Veykril
minor: Disable debuginfo again

I suspect this wasn't intentional, right?
2023-12-04 20:30:20 +00:00
Laurențiu Nicola
523ad0f634 Disable debuginfo again 2023-12-04 22:15:59 +02: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
bors
11e1ceaf75 Auto merge of #16017 - lnicola:sync-from-rust, r=lnicola
minor: sync from downstream
2023-12-04 19:43:27 +00:00
Laurențiu Nicola
6d2543b622 Temporarily revert delay_bug to delayed_bug change 2023-12-04 21:41:19 +02:00
Laurențiu Nicola
26c0963281 Merge branch 'master' into sync-from-rust 2023-12-04 21:39:22 +02:00
dfireBird
20c6f27024
Insert fn call parens only if the parens inserted around field name 2023-12-04 22:37:34 +05:30
ClSlaid
b21d68cd2a
feat: add proc-macro rebuild on save option
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
2023-12-04 21:08:29 +08:00
werifu
05e8b926e6 fix: bug in extract_function: should not import ControlFlow in some cases 2023-12-04 16:23:18 +08:00
Laurențiu Nicola
30fc9329d1 Merge commit 'e402c494b7c7d94a37c6d789a216187aaf9ccd3e' into sync-from-ra 2023-12-04 09:19:15 +02:00
Lukas Wirth
18f1a3c3c6 Some final touches 2023-12-03 20:20:59 +01:00
Lukas Wirth
81410ab500 Cleanup FileId stuff 2023-12-02 19:32:53 +01: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
Lukas Wirth
d2a31acda1 Fix macro expansion expression parenthesis wrapping 2023-12-02 13:03:46 +01:00
Nicholas Nethercote
40da288eb0 Rename LayoutCalculator::delay_bug as LayoutCalculator::delayed_bug.
To match with the previous commits.
2023-12-02 09:01:34 +11:00
Nicholas Nethercote
4375419b24 Rename HandlerInner::delay_span_bug as HandlerInner::span_delayed_bug.
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug`
follows the pattern used everywhere else: `span_err`, `span_warning`,
etc.
2023-12-02 09:01:19 +11:00
bors
e402c494b7 Auto merge of #15879 - dfireBird:fix-14656, r=Veykril
Implement completion for the callable fields.

Fixes #14656

PR is opened with basic changes. It could be improved by having a new `SymbolKind` for the callable fields and implementing a separate render function similar to the `render_method` for the new `SymbolKind`.
It could also be done without any changes to the `SymbolKind` of course, have the new function called based on the type of field.
I prefer the former method.

Please give any thoughts or changes you think is appropriate for this method. I could start working on that in this same PR.
2023-12-01 16:20:36 +00:00
Lukas Wirth
efa67294ed Fix eager macro input spans being discarded 2023-12-01 16:29:58 +01:00
Lukas Wirth
c11737cd63 Simplify include handling 2023-12-01 14:58:57 +01:00
bors
6e6a0b0a3d Auto merge of #16000 - HKalbasi:drop-inlay-hint, r=HKalbasi
Initial support for implicit drop inlay hint

cc #15785
2023-12-01 13:36:08 +00:00
dfireBird
b7effe54ee
fix close parens position to move after field access 2023-12-01 18:55:26 +05:30
Lukas Wirth
0003e568ca Pass calling span through to builtin macro expansions 2023-12-01 14:11:57 +01:00
hkalbasi
4d55cac466 Initial support for implicit drop inlay hint 2023-12-01 16:16:46 +03:30
bors
c2f133489c Auto merge of #15912 - Sarrus1:master, r=HKalbasi
chore: remove unused `PhantomData`

This PR removes an unused `PhantomData` in `FileItemTreeId`.

*Note:* I am not sure how this should be implemented, maybe as a type instead of a wrapper struct? I'd be happy to do so if needed 👍
2023-12-01 11:07:35 +00:00
bors
57e90240a5 Auto merge of #15961 - ohno418:top-level-let-stmt, r=Veykril
Improve error handling for top-level `let` statements

This commit addresses the issue of excessive and unrelated errors generated by top-level `let` statements. Now, only a single error is produced, indicating that `let` statements are invalid at the top level.

---

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

While I'm not really sure if handling a particular case in a special manner is appropriate, it would be good to suppress the excessive number of annoying and unrelated errors.
2023-12-01 10:41:16 +00:00
Yutaro Ohno
e076192dd8 Improve error handling for top-level let statements
This commit addresses the issue of excessive and unrelated errors
generated by top-level `let` statements. Now, only a single error is
produced, indicating that `let` statements are invalid at the top level.
2023-12-01 10:37:21 +09:00
bors
c9d189d137 Auto merge of #15993 - meowtec:fix/workspaces-debug-cwd, r=Veykril
Debug use cargo workspace root as `cwd`

fixes #13022
2023-11-30 19:31:15 +00:00
bors
1c51e25a5a Auto merge of #15994 - ChayimFriedman2:err-comma-after-fus, r=Veykril
fix: Err for comma after functional update syntax

Error message copied from rustc, https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=20aeedb2db504c4e4ced54b665e761d6.

Fixes #15989.
2023-11-30 15:59:31 +00:00