Commit graph

1090 commits

Author SHA1 Message Date
bors
e88946ace8 Auto merge of #17655 - Veykril:std-find-path, r=Veykril
More `find_path` improvements
2024-07-21 11:21:25 +00:00
Lukas Wirth
733cb1e645 Optimize find_path for sysroot library search some more 2024-07-21 13:20:12 +02:00
Lukas Wirth
4b2a123280 Fix visited module tracking not clearing itself on backtracking 2024-07-21 12:17:50 +02:00
Lukas Wirth
2a32976e90 Use out parameter instead of return value for find_path choice 2024-07-21 11:32:48 +02:00
Lukas Wirth
9fd6d26e97 Fix using wrong length for max_len arg 2024-07-21 11:16:23 +02:00
Lukas Wirth
2564b69e1d Specialize find_path local search 2024-07-21 11:10:15 +02:00
Lukas Wirth
a6e4ac705c Optimize find_path choice selection 2024-07-21 10:53:33 +02:00
bors
88258b7fd2 Auto merge of #17653 - Veykril:std-find-path, r=Veykril
Prefer standard library paths over shorter extern deps re-exports

This should generally speed up path finding for std items as we no longer bother looking through all external dependencies. It also makes more sense to prefer importing std items from the std dependencies directly.

Fixes https://github.com/rust-lang/rust-analyzer/issues/17540
2024-07-21 07:24:38 +00:00
Lukas Wirth
40bbc684ad Prefer standard library paths over shorter extern deps re-exports 2024-07-21 09:14:17 +02:00
bors
5f26438b5d Auto merge of #17650 - ObsidianMinor:fix/17645, r=Veykril
Fix path resolution for child mods of those expanded by `include!`

Child modules wouldn't use the correct candidate paths due to a branch that doesn't seem to be doing what it's intended to do. Removing the branch fixes the problem and all existing test cases pass.

Having no knowledge of how any of this works, I believe this fixes #17645. Using another test that writes the included mod directly into `lib.rs` instead, I found the difference can be traced to the candidate files we use to look up mods. A separate branch for if the file comes from an `include!` macro doesn't take into account the original mod we're contained within:

```rust
None if file_id.macro_file().map_or(false, |it| it.is_include_macro(db.upcast())) => {
    candidate_files.push(format!("{}.rs", name.display(db.upcast())));
    candidate_files.push(format!("{}/mod.rs", name.display(db.upcast())));
}
```

I'm not sure why this branch exists. Tracing the branch back takes us to 3bb9efb but it doesn't say *why* the branch was added. The test case that was added in this commit passes with the branch removed, so I think it's just superfluous at this point.
2024-07-21 06:17:14 +00:00
Sydney Acksman
b9469f52a3 Fix path resolution for child mods of those expanded by include!
Child modules wouldn't use the correct candidate paths due to a branch that doesn't seem to be doing what it's intended to do. Removing the branch fixes the problem and all existing test cases pass.
2024-07-20 14:32:28 -05:00
Laurențiu Nicola
1075978bed Fix some typos 2024-07-20 08:30:22 +03:00
Lukas Wirth
546eb6b530 Test macros doing edition dependent parsing 2024-07-19 16:43:58 +02:00
Lukas Wirth
5264f86242 Encode edition within FileId in the hir layer 2024-07-18 08:49:10 +02:00
Lukas Wirth
92268627a8 Support rustc_skip_during_method_dispatch 2024-07-17 11:46:36 +02:00
Lukas Wirth
7011094685 Add always disabled gen parse support 2024-07-17 10:49:12 +02:00
Lukas Wirth
2346a80ab4 Remove Name::to_smol_str 2024-07-16 12:43:58 +02:00
Lukas Wirth
df5f1777b8 More symbol usage 2024-07-16 12:05:16 +02:00
Lukas Wirth
93024ad411 Switch token trees to use Symbols 2024-07-16 10:11:59 +02:00
Lukas Wirth
dcfda55c82 Escape fetched env vars in env! expansion 2024-07-15 13:08:29 +02:00
Lukas Wirth
e846c04fbe Encode ident rawness and literal kind separately in tt::Leaf 2024-07-15 12:24:40 +02:00
Lukas Wirth
cde0f69cae Fix stable iteration ordering for Map<Name, ...> usages 2024-07-15 11:25:46 +02:00
Lukas Wirth
f2d51073d2 Use statics + clone instead of const until const can access statics 2024-07-14 17:52:59 +02:00
Shoyu Vanilla
b238855892 Allow macro expansions into RestPat in tuple args work as ellipsis like plain RestPat 2024-07-13 07:09:17 +09:00
Lukas Wirth
3fe815b0f3 Use Symbol in Name 2024-07-12 16:06:44 +02:00
beetrees
d5db933f9d
Add f16 and f128 support 2024-07-10 10:43:14 +01:00
beetrees
320022622c
fix: Fix double rounding of f32 literals 2024-07-08 16:31:32 +01:00
bors
a5b21ea0aa Auto merge of #17555 - Veykril:grammar-inline, r=Veykril
internal: Inline generated syntax methods
2024-07-07 09:21:04 +00:00
Lukas Wirth
c08d419fba HasGenericArgs syntax trait 2024-07-07 11:18:28 +02:00
bors
a494aaba87 Auto merge of #17523 - wada314:master, r=Veykril
Add an option to use "::" for the external crate prefix.

Fixes #11823 .
Hi I'm very new to rust-analyzer and not sure how the review process are. Can somebody take a look at this PR? thanks!
2024-07-07 08:32:46 +00:00
Lukas Wirth
90682c393d Drop unused profile things 2024-07-07 08:24:10 +02:00
Shoyu Vanilla
4bb623decb Disallow nested impl traits 2024-07-04 23:31:55 +09:00
Lukas Wirth
baa959fa99 Move lifetimes in front of type and const params but after self 2024-07-02 14:17:34 +02:00
Lukas Wirth
966798b7ba Make GenericParams::lifetimes private 2024-07-02 13:45:53 +02:00
Lukas Wirth
be1ea4028b Make GenericParams::where_predicates private 2024-07-02 13:45:50 +02:00
Lukas Wirth
372e2d22e6 Make GenericParams::type_or_consts private 2024-07-02 13:45:48 +02:00
Shohei Wada
3725ab3146 squash. 2024-07-02 01:52:34 +09:00
Lukas Wirth
21a3d01875 Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
Lukas Wirth
882ae7105d Simplify unresolved proc-macro handling 2024-06-30 13:26:13 +02:00
Lukas Wirth
8df034d453 Shrink mbe's Op 2024-06-24 10:07:32 +02:00
Lukas Wirth
e052b3e9a6 Intern ModPath within RawVisibility 2024-06-24 10:07:32 +02:00
Lukas Wirth
5548aecdca Save a bit on empty item trees by deduplicating them 2024-06-24 10:07:32 +02:00
Lukas Wirth
3168ab5b99 Enum variants are not generic def ids 2024-06-24 10:07:31 +02:00
Lukas Wirth
c01f4cf902 Simplify 2024-06-21 18:27:05 +02:00
Lukas Wirth
480bfd5a7d There can only be one self param 2024-06-21 17:55:16 +02:00
Lukas Wirth
f9bb5476c3 fix: Fix pat fragment parsers choking on <eoi> 2024-06-17 19:42:56 +02:00
bors
6b8b8ff4c5 Auto merge of #17417 - Wilfred:intern_macros_salsa, r=Veykril
refactor: Prefer plain trait definitions over macros for impl_intern_value_trivial

`impl_intern_value_trivial` can be defined with a trait directly, so prefer that over a macro definition.
2024-06-14 06:20:26 +00:00
Wilfred Hughes
3874681cb6 Prefer plain trait definitions over macros for salsa 2024-06-13 17:32:06 -07:00
Wilfred Hughes
d68e549205 internal: Fix rustdoc warnings
`cargo doc` generates a bunch of warnings on rust-analyzer. Fix all the
bare URL and empty code block warnings.
2024-06-13 17:29:10 -07:00
bors
fa486e694e Auto merge of #17406 - Veykril:modpath-clone, r=Veykril
internal: Don't unnecessarily clone ModPaths out of interning wrappers
2024-06-12 09:49:41 +00:00
Lukas Wirth
ba543f7d76 internal: Don't unnecessarily clone ModPaths out of interning wrappers 2024-06-12 11:43:36 +02:00
bors
22648b2655 Auto merge of #17405 - Veykril:modpath-clone, r=Veykril
internal: Don't unnecessarily clone ModPaths in early name res
2024-06-12 09:27:49 +00:00
Lukas Wirth
855282fa53 internal: Don't unnecessarily clone ModPaths in early name res 2024-06-12 11:25:19 +02:00
bors
b5e0d7c349 Auto merge of #17398 - Veykril:bogus-file, r=Veykril
internal: Remove FileId::BOGUS
2024-06-12 07:19:31 +00:00
Lukas Wirth
8ebabce475 internal: Remove FileId::BOGUS 2024-06-12 08:16:07 +02:00
Young-Flash
6403bdb930 minor: use push_str instead 2024-06-09 22:31:55 +08:00
Young-Flash
e8941dae46 internal: tweak test case 2024-06-09 20:55:40 +08:00
Young-Flash
dcbc76b967 internal: better print style for hir 2024-06-09 12:00:43 +08:00
Wilfred Hughes
27182bb96b chore: Prefer tracing span shorthand macros 2024-06-06 16:52:25 -07:00
bors
af488c971f Auto merge of #17352 - roife:fix-issue-17338, r=Veykril
fix: do not resolve prelude within block modules

fix #17338 (continuing from #17251).

In #17251, we injected preludes into non-top-level modules, which leading to r-a to directly resolve names in preludes in block modules. This PR fix it by checking whether the module is a pseudo-module introduced by blocks. (similar to what we do for extern preludes)
2024-06-06 09:40:39 +00:00
roife
c330c62aa2 fix: do not resolve prelude within block modules 2024-06-06 16:55:09 +08:00
Lukas Wirth
97b58f2846 Try caching macro calls more aggressively 2024-06-04 15:23:00 +02:00
Lukas Wirth
6f0207d594 Cleanup some inert attribute stuff 2024-06-04 12:38:20 +02:00
Lukas Wirth
f1dbb958c8 Add fuel to find_path 2024-06-03 20:07:00 +02:00
Lukas Wirth
f94d34bd72 Remove an allocation in find_path::find_local_import_locations 2024-06-03 19:57:49 +02:00
Lukas Wirth
48822e0941 Simplify 2024-06-03 19:46:40 +02:00
Lukas Wirth
426d01eab0 Deduplicate 2024-06-03 19:26:11 +02:00
Lukas Wirth
db80216dac Fix find_path search not reducing scope appropriately for foreign items 2024-06-03 19:21:19 +02:00
Lukas Wirth
60fa981df1 Simplify 2024-06-03 19:06:58 +02:00
Nilstrieb
0e1353bebd Don't mark #[rustc_deprecated_safe_2024] functions as unsafe
`std::env::set_var` will be unsafe in edition 2024, but not before it.
I couldn't quite figure out how to check for the span properly, so for now
we just turn the false positives into false negatives, which are less bad.
2024-06-02 15:04:26 +02:00
bors
d4da3f925c Auto merge of #17251 - roife:fix-issue-17057, r=Veykril
fix: resolve extern prelude for local mods in block modules

fix https://github.com/rust-lang/rust-analyzer/issues/17057, https://github.com/rust-lang/rust-analyzer/issues/17032.

We should use `ModuleOrigin` to check if the current module is a pseudo-module introduced by blocks (where names might be shadowed), rather than checking `block_def_map`.
2024-05-22 20:11:24 +00:00
Lukas Wirth
3a7dcf91c4 Simplify 2024-05-22 21:57:44 +02:00
David Barsky
b75301cec8 internal: refactor prefer_no_std/prefer_prelude bools into a struct 2024-05-22 20:46:30 +02:00
roife
d9cc159b26 fix: check pseudo-block by local_id instead of ModuleOrigin 2024-05-23 02:39:53 +08:00
bors
6a16749eb0 Auto merge of #17277 - Veykril:find-path-fixes, r=Veykril
fix: Various find path fixes

Fixes https://github.com/rust-lang/rust-analyzer/issues/17271
2024-05-22 18:22:32 +00:00
bors
42a8500ebf Auto merge of #17279 - Veykril:format_args-escape, r=Veykril
fix: Fix format_args lowering passing incorrect parameters to `rustc_parse_format`
2024-05-22 14:12:22 +00:00
Lukas Wirth
4f17d07e69 fix: Fix format_args lowering passing incorrect parameters to rustc_parse_format 2024-05-22 16:11:06 +02:00
bors
daf66ad8eb Auto merge of #17268 - Veykril:signatures, r=Veykril
feat: More callable info

With this PR we retain more info about callables other than functions, allowing for closure parameter type inlay hints to be linkable as well as better signature help around closures and `Fn*` implementors.
2024-05-22 12:48:17 +00:00
Lukas Wirth
ca06b090d7 expectify find_path tests 2024-05-22 14:05:24 +02:00
Lukas Wirth
c88b421853 fix: Fix general find-path inconsistencies 2024-05-22 14:05:24 +02:00
roife
48dc20f80d test: add tests for extern preludes resolving in local mods 2024-05-21 20:35:55 +08:00
Laurențiu Nicola
49cae17fa2 Merge from rust-lang/rust 2024-05-19 11:20:26 +03:00
Lukas Wirth
cd9e90cc71 Update builtin tool list 2024-05-18 10:52:05 +02:00
roife
55db9530eb fix: resolve extern prelude for local mods in block modules 2024-05-17 23:29:00 +08:00
bors
77c7886283 Auto merge of #17227 - Veykril:build-deps-changed-hashes, r=Veykril
fix: Hash file contents to verify whether file actually changed

Fixes https://github.com/rust-lang/rust-analyzer/issues/16580
2024-05-14 10:48:18 +00:00
Lukas Wirth
1ca97ba896 Hash file contents to verify whether file actually changed 2024-05-14 11:55:12 +02:00
bors
d28111dce8 Auto merge of #17224 - Veykril:lock-bump, r=Veykril
Bump Cargo.lock
2024-05-14 08:59:34 +00:00
Lukas Wirth
2a4be8d1f7 Bump Cargo.lock 2024-05-14 10:57:02 +02:00
bors
b98690ba74 Auto merge of #17221 - Veykril:lazier-validation, r=Veykril
internal: Lazier macro parse tree validation
2024-05-13 15:16:46 +00:00
Lukas Wirth
56552f4839 Push macro-parsing error calculation out of fundamental queries 2024-05-13 16:56:26 +02:00
Lukas Wirth
a39c0493a1 Render literal escaping errors in hovers 2024-05-13 12:51:57 +02:00
Martin Nordholts
938e1a0e2c Change SIGPIPE ui from #[unix_sigpipe = "..."] to -Zon-broken-pipe=...
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern
was raised related to using a language attribute for the feature: Long
term, we want `fn lang_start()` to be definable by any crate, not just
libstd. Having a special language attribute in that case becomes
awkward.

So as a first step towards towards the next stabilization attempt, this
PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag
`-Zon-broken-pipe=...` to remove that concern, since now the language
is not "contaminated" by this feature.

Another point was also raised, namely that the ui should not leak
**how** it does things, but rather what the **end effect** is. The new
flag uses the proposed naming. This is of course something that can be
iterated on further before stabilization.
2024-05-02 19:48:29 +02:00
bors
ecba59d69c Auto merge of #17175 - Veykril:fix-implicit-ty-args, r=Veykril
fix: Fix implicit ty args being lowered where they shouldn't

Fixes https://github.com/rust-lang/rust-analyzer/issues/17173
2024-05-02 10:04:13 +00:00
Lukas Wirth
8241d8a0b8 fix: Fix implicit ty args being lowered where they shouldn't 2024-05-02 11:53:53 +02:00
Lukas Wirth
a268eaf053 fix: Correctly handle no_core/no_std for preludes 2024-05-02 10:50:28 +02:00
Lukas Wirth
da0fb75d10
Use RefCell::take 2024-04-30 14:19:56 +02:00
dfireBird
40a677ddf0
implement creating generics for impl traits in associated types 2024-04-29 23:55:02 +05:30
Lukas Wirth
36c1c77cf9 fix: Fix doc comment desugaring for proc-macros 2024-04-27 13:30:51 +02:00
Lukas Wirth
bfe59bbdc8 fix: Fix attributes on generic parameters colliding in item tree 2024-04-27 13:15:36 +02:00
Lukas Wirth
ac389ce2ef fix: Fix expression scopes not being calculated for inline consts 2024-04-25 09:49:19 +02:00
bors
4c08e2d32f Auto merge of #16938 - Nilstrieb:dont-panic-tests, r=Veykril
Implement `BeginPanic` handling in const eval

for #16935, needs some figuring out of how to write these tests correctly
2024-04-21 16:22:02 +00:00
roife
a543516ea4 fix: handle escaped chars in doc comments 2024-04-19 14:57:37 +08:00
Lukas Wirth
a9140e197c Fix #[rustc_const_panic_str] functions not actually being hooked 2024-04-18 15:49:08 +02:00
Lukas Wirth
5df690e13f Fixup some issues with minicore 2024-04-18 12:20:54 +02:00
Lukas Wirth
531a270d91 Generally optimize diagnostics performance 2024-04-15 22:15:41 +02:00
Lukas Wirth
94e38261b3 Optimize exhaustiveness checking perf a bit 2024-04-15 19:35:48 +02:00
Lukas Wirth
a483d3bc37 internal: Thread edition through to parsing/tt-to-syntax-tree routines for macros 2024-04-14 16:02:38 +02:00
Lukas Wirth
83370fe5d7 Use Edition::CURRENT 2024-04-14 15:30:29 +02:00
Johann Hemmann
2cf5d8811a Raise edition one more level 2024-04-14 15:11:33 +02:00
Lukas Wirth
a82e028e30 Cleanup util::Generics method names 2024-04-06 14:29:40 +02:00
Lukas Wirth
f3567bb604 Arc CrateData::cfg_options 2024-04-06 13:55:10 +02:00
Lukas Wirth
13890697eb Simplify 2024-04-06 13:12:07 +02:00
Lukas Wirth
5957835cdf Consider exported_name="main" functions in test modules as tests 2024-04-04 14:51:10 +02:00
Lukas Wirth
2b62d4b2ba Fix some cfg censoring bugs 2024-04-03 16:43:08 +02:00
Lukas Wirth
707be6b99c Adjust display impls to respect lifetime bounds 2024-04-02 14:51:08 +02:00
Lukas Wirth
0927f86247 Replace static_lifetime usages with error_lifetime, lower outlives goals 2024-04-02 14:51:06 +02:00
dfireBird
69c4ac6304
implement len and is_empty method in generic_params 2024-03-29 18:26:46 +05:30
bors
0583aaa555 Auto merge of #16805 - dfireBird:lifetime_lowering, r=Veykril
feat: Implement resolving and lowering of Lifetimes (no inference yet)
2024-03-26 07:58:43 +00:00
dfireBird
0e54e2b55a
use references in Generics iter methods 2024-03-26 13:04:54 +05:30
Lukas Wirth
8e324e98a1 Rename ProcMacroKind::FuncLike to Bang 2024-03-22 11:20:56 +01:00
bors
16c8deeb86 Auto merge of #16835 - wyatt-herkamp:use_one_tt_for_a_derive, r=Veykril
Have Derive Attribute share a token tree with it's proc macros.

The goal of this PR is to stop creating a token tree for each derive proc macro.

This is done by giving the derive proc macros an id to its parent derive element.

From running the analysis stat on the rust analyzer project I did see a small memory decrease.

```
Inference:           42.80s, 362ginstr, 591mb
MIR lowering:        8.67s, 67ginstr, 291mb
Mir failed bodies: 18 (0%)
Data layouts:        85.81ms, 609minstr, 8mb
Failed data layouts: 135 (6%)
Const evaluation:    440.57ms, 5235minstr, 13mb
Failed const evals: 1 (0%)
Total:               64.16s, 552ginstr, 1731mb
```
After Change
```
Inference:           40.32s, 340ginstr, 593mb
MIR lowering:        7.95s, 62ginstr, 292mb
Mir failed bodies: 18 (0%)
Data layouts:        87.97ms, 591minstr, 8mb
Failed data layouts: 135 (6%)
Const evaluation:    433.38ms, 5226minstr, 14mb
Failed const evals: 1 (0%)
Total:               60.49s, 523ginstr, 1680mb
```

Currently this breaks the expansion for the actual derive attribute.

## TODO
- [x] Pick a better name for the function `smart_macro_arg`
2024-03-21 18:04:38 +00:00
Wyatt Herkamp
c381d0fc64 Review Updates 2024-03-21 13:41:46 -04:00
Wyatt Herkamp
262e06f1ef Remove MacroCallKind::DeriveAttr 2024-03-21 12:50:58 -04:00
Wyatt Herkamp
c376addfcc Cleanup 2024-03-21 08:12:26 -04:00
Wyatt Herkamp
2c2bbe07fd Treat Derive Macro specially. 2024-03-21 08:07:54 -04:00
Wyatt Herkamp
4bd2f948bb Formatting 2024-03-21 08:07:54 -04:00
Wyatt Herkamp
15d183be79 Initial Attempt limiting number of token tree in macro expansion. 2024-03-21 08:06:43 -04:00
Lukas Wirth
928d847cc2 Keep the span for Attr::Literal 2024-03-21 10:28:25 +01:00
Lukas Wirth
6d1071962f Resolve whether $pat is $pat_param or not via 🌟hygiene🌟 2024-03-21 10:22:45 +01:00
Lukas Wirth
255a8aef92 Move Edition into span crate 2024-03-21 10:21:44 +01:00
dfireBird
13301e7a1a
replace static_lifetime with new_lifetime_var where necessary
implemented suggested fixes and changes and fix merge conflicts
2024-03-18 17:53:09 +05:30
dfireBird
a6c8cbfd91
update Generics iter methods to return GenericParamId 2024-03-18 17:18:08 +05:30
dfireBird
f95b3d4cd2
implement resolving and lowering of Lifetimes 2024-03-18 17:18:06 +05:30
Lukas Wirth
b59c8c76db Repalce Span with SyntaxContextId in MacroCallLoc 2024-03-15 12:47:05 +01:00
Lukas Wirth
3b1ad2379d internal: Make def site span for proc-macro more invalidation resistant 2024-03-15 10:14:00 +01:00
Lukas Wirth
d085ade631 Remove dead test code 2024-03-14 16:24:51 +01:00
Lukas Wirth
d2f8eae2ec feat: Support macro calls in eager macros for IDE features 2024-03-14 15:40:35 +01:00
Lukas Wirth
9767156a29 Simplify 2024-03-13 20:02:21 +01:00
Lukas Wirth
abe3177445 Shrink MacroCallLoc 2024-03-13 18:05:27 +01:00
bors
a2e274142f Auto merge of #16819 - Veykril:span-upmapping, r=Veykril
internal: Improve rooted upmapping

cc https://github.com/rust-lang/rust-analyzer/issues/16235
2024-03-12 12:58:52 +00:00
Lukas Wirth
9ba4493918 internal: Improve rooted upmapping 2024-03-12 13:46:58 +01:00
bors
d3e6fea315 Auto merge of #16789 - wyatt-herkamp:cfg_attr, r=Veykril
cfg Attribute Stripping for Proc Macro Expansion

This will attempt to process cfg attributes and cfg_attr attributes for proc macro expansion.
![image](https://github.com/rust-lang/rust-analyzer/assets/11785959/b85ef203-14a5-44c9-9b67-59a65a5f2d96)

Closes #8434 , #11657, and #13904
2024-03-12 10:19:19 +00:00
Wyatt Herkamp
447de3d788 Review Updates and added tests. 2024-03-11 11:05:59 -04:00
bors
8f8bcfc131 Auto merge of #16335 - lnicola:salsa-lz4-file-text, r=Veykril
internal: Compress file text using LZ4

I haven't tested properly, but this roughly looks like:

```
1246 MB
    59mb   4899 FileTextQuery

1008 MB
    20mb   4899 CompressedFileTextQuery
   555kb   1790 FileTextQuery
```

We might want to test on something more interesting, like `bevy`.
2024-03-11 13:43:33 +00:00
bors
2320e12541 Auto merge of #16771 - Veykril:self-param-split, r=Veykril
internal: Don't desugar self param into a pattern

Small experiment to see if this simplifies things
2024-03-11 12:45:46 +00:00
Lukas Wirth
458f4a2960 internal: Treat the self param as different from patterns when lowering 2024-03-11 09:46:28 +01:00
Lukas Wirth
558feeab61 internal: Remove synstructure const hack support 2024-03-11 09:44:40 +01:00
Laurențiu Nicola
0f43b55e83 Stop using an Arc when setting the file text 2024-03-08 20:30:12 +02:00
Laurențiu Nicola
02b6c181dd Compress file text using lz4 in salsa 2024-03-08 20:22:08 +02:00
Lukas Wirth
09b9a921a8 fix: Don't invalid body query results when generating desugared names 2024-03-07 15:03:16 +01:00
Lukas Wirth
c04c0dd5ba fix: Don't force draw a dependency edge to the real_span_map query 2024-03-07 14:14:59 +01:00
Lukas Wirth
a3b6e891ea Add tracing spans to macro generated database 2024-03-06 20:19:36 +01:00
roife
ece18fecfa fix: resolve sub-patterns inside range pattern 2024-03-05 19:31:20 +08:00
Lukas Wirth
c3c9f5ffe1 internal: Compute syntax validation errors on demand 2024-03-04 12:06:15 +01:00
Lukas Wirth
4303e741de Cleanup 2024-03-04 11:10:06 +01:00
Lukas Wirth
efd76ecff1 Move AstIdMap infra to the span crate 2024-03-01 15:39:44 +01:00
Lukas Wirth
91554e0ae7 fix: Fix modules in blocks not resolving in ide layer 2024-02-26 14:54:47 +01:00
Lukas Wirth
d93096ecc0 internal: Fetch toolchain and datalayout for DetachedFiles 2024-02-20 10:40:39 +01:00
bors
2223b4fa71 Auto merge of #13112 - lowr:patch/auto-trait-bounds, r=Veykril
Setup infra for handling auto trait bounds disabled due to perf problems

This patch updates some of the partially-implemented functions of `ChalkContext as RustIrDatabase`, namely `adt_datum()` and `impl_provided_for()`. With those, we can now correctly work with auto trait bounds and distinguish methods based on them.

Resolves #7856 (the second code; the first one is resolved by #13074)

**IMPORTANT**: I don't think we want to merge this until #7637 is resolved. Currently this patch introduces A LOT of unknown types and type mismtaches as shown below. This is because we cannot resolve items like `hashbrown::HashMap` in `std` modules, leading to auto trait bounds on them and their dependents unprovable.

|crate (from `rustc-perf@c52ee6` except for r-a)|e3dc5a588f07d6f1d3a0f33051d4af26190abe9e|HEAD of this branch|
|---|---|---|
|rust-analyzer @ e3dc5a588f |exprs: 417528, ??ty: 907 (0%), ?ty: 114 (0%), !ty: 1|exprs: 417528, ??ty: 1704 (0%), ?ty: 403 (0%), !ty: 20|
|ripgrep|exprs: 62120, ??ty: 2 (0%), ?ty: 0 (0%), !ty: 0|exprs: 62120, ??ty: 132 (0%), ?ty: 58 (0%), !ty: 11|
|webrender/webrender|exprs: 94355, ??ty: 49 (0%), ?ty: 16 (0%), !ty: 2|exprs: 94355, ??ty: 429 (0%), ?ty: 130 (0%), !ty: 7|
|diesel|exprs: 132591, ??ty: 401 (0%), ?ty: 5129 (3%), !ty: 31|exprs: 132591, ??ty: 401 (0%), ?ty: 5129 (3%), !ty: 31|
2024-02-19 16:45:59 +00:00
Laurențiu Nicola
6b17dba68c Merge commit 'ac998a74b3c8ff4b81c3eeb9a18811d4cc76226d' into sync-from-ra 2024-02-18 09:41:20 +02:00
Lukas Wirth
9d18e197bc Filter out {unknown} types in adt_datum_quqery 2024-02-14 14:10:54 +01:00
bors
cf8733353d Auto merge of #16540 - Veykril:macro-arg, r=Veykril
internal: macro_arg query always returns a TokenTree
2024-02-12 16:32:40 +00:00
Lukas Wirth
2fa57d90bc internal: macro_arg query always returns a TokenTree 2024-02-12 17:19:41 +01:00
bors
818c30c311 Auto merge of #16092 - kilpkonn:term_search_1, r=Veykril
feat: Introduce term search to rust-analyzer

# Introduce term search to `rust-analyzer`
_I've marked this as draft as there might be some shortcomings, please point them out so I can fix them. Otherwise I think it is kind of ready as I think I'll rather introduce extra functionality in follow up PRs._

Term search (or I guess expression search for rust) is a technique to generate code by basically making the types match.
Consider the following program
```rust
fn wrap(arg: i32) -> Option<i32> {
    todo!();
}
```
From the types of values in scope and constructors of `Option`, we can produce the expected result of wrapping the argument in `Option`

Dependently typed languages such as `Idris2` and `Agda` have similar tools to help with proofs, but this can be also used in everyday development as a "auto-complete".

# Demo videos

https://github.com/rust-lang/rust-analyzer/assets/19900308/7b68a1b7-7dba-4e31-9221-6c7485e77d88

https://github.com/rust-lang/rust-analyzer/assets/19900308/0fae530a-aabb-4b28-af71-e19f8d3d64b2

# What does it currently do
- It works well with locals, free functions, type constructors and non-static impl methods that take items by value.
- Works with functions/methods that take shared references, but not with unique references (very conservative).
- Can handle projections to struct fields (eg. `foo.bar.baz`) but this might me more conservative than it has to be to avoid conflicting with borrow checker
- Should create only valid programs (no type / borrow checking errors). Tested with `rust-analyzer analysis-stats /path/to/ripgrep/Cargo.toml --run-term-search --validate-term-search` (basically running `cargo check` on all of the generated programs and only error seems to be due to type inference which is more of issue of testing method.

# Performace / fitness
```txt
ripgrep (latest)
Tail Expr syntactic hits: 130/1692 (7%)
Tail Exprs found: 523/1692 (30%)
Term search avg time: 9ms
Term search:         15.64s, 97ginstr, 8mb

rust-analyzer (on this branch)
Tail Expr syntactic hits: 804/13860 (5%)
Tail Exprs found: 6757/13860 (48%)
Term search avg time: 78ms
Term search:         1088.23s, 6765ginstr, 98mb
```
Highly generic code seems to blow up the search space so currently the amount of generics allowed is functions/methods is limited down to 0 (1 didn't give much improvement and 2 is already like 0.5+s search time)

# Plans for the future (not in this PR)
- ``~~Add impl methods that do not take `self` type (should be quite straight forward)~~ Done
- Be smarter (aka less restrictive) about borrow checking - this seems quite hard but since the current approach is rather naive I think some easy improvement is available.
- ``~~See if it works as a autocomplete while typing~~ Done

_Feel free to ask questions / point of shortcoming either here or on Zulip, I'll be happy to address them. I'm doing this as part of my MSc thesis so I'll be working on it till summer anyway 😄_
2024-02-12 14:47:12 +00:00
bors
47b4dd7273 Auto merge of #15923 - tamasfe:feat/better-ignored-macros2, r=Veykril
feat: ignored and disabled macro expansion

Supersedes #15117, I was having some conflicts after a rebase and since I didn't remember much of it I started clean instead.

The end result is pretty much the same as the linked PR, but instead of proc macro lookups, I marked the expanders that explicitly cannot be expanded and we shouldn't even attempt to do so.

## Unresolved questions

- [ ] I introduced a `DISABLED_ID` next to `DUMMY_ID` in `hir-expand`'s `ProcMacroExpander`, that is effectively exactly the same thing with slightly different semantics, dummy macros are not (yet) expanded probably due to errors, while not expanding disabled macros is part of the usual flow. I'm not sure if it's the right way to handle this, I also thought of just adding a flag instead of replacing the macro ID, so that the disabled macro can still be expanded for any reason if needed.
2024-02-12 12:42:45 +00:00
Lukas Wirth
e2a985e93f Encode disabled proc-macros via boolean flag, not special Expander 2024-02-12 13:39:38 +01:00
tamasfe
ab50ec9863 fix(macros): no diagnostics for disabled macro 2024-02-12 12:50:44 +01:00
tamasfe
6d45afd8d8 feat: ignored and disabled macro expansion 2024-02-12 12:50:40 +01:00
Nicholas Nethercote
4a13722518 Tweak delayed bug mentions.
Now that we have both `delayed_bug` and `span_delayed_bug`, it makes
sense to use the generic term "delayed bug" more.
2024-02-12 18:39:20 +11:00
Tavo Annus
125791386d Cleanup term search related changes 2024-02-11 14:35:54 +02:00
Tavo Annus
627255dd5a Add static method tactic 2024-02-11 13:33:29 +02:00
Lukas Wirth
c990587593 fix: Fix macro transcriber emitting incorrect lifetime tokens 2024-02-11 12:10:38 +01:00
Laurențiu Nicola
e41ab350d6 Merge commit 'ddf105b646c6749a2de2451c9a499a354eec79c2' into sync-from-ra 2024-02-11 08:40:19 +02:00
Lukas Wirth
5136705fad internal: Remove SELF_REF hack for self referential SyntaxContexts 2024-02-10 16:20:02 +01:00
Lukas Wirth
36fb1409ed Cleanup visibility.rs 2024-02-10 13:50:45 +01:00
Lukas Wirth
dc69255b83 Re-organize hir-def/lib.rs 2024-02-10 12:40:23 +01:00
Lukas Wirth
74eb3ecbc1 Move ChildbySource and HasSource impls to their corresponding modules 2024-02-10 12:09:12 +01:00
bors
1ef7a2329b Auto merge of #16525 - Veykril:item-loc, r=Veykril
Abstract more over ItemTreeLoc-like structs

Allows reducing some code duplication by using functions generic over said structs. The diff isn't negative due to me adding some additional impls for completeness.
2024-02-10 10:47:37 +00:00
Lukas Wirth
00303c3b67 Abstract over ItemTreeLoc 2024-02-10 11:37:59 +01:00
Lukas Wirth
2ebf0c87c2 Deduplicate some code 2024-02-10 01:51:22 +01:00
Tetsuharu Ohzeki
99f5d7ca4c hir-def: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
Tetsuharu Ohzeki
c6637f39c0 clippy: Enable borrowed_box rule 2024-02-10 00:14:17 +09:00
Tetsuharu Ohzeki
d45cabd029 clippy: Enable derived_hash_with_manual_eq rule 2024-02-10 00:14:17 +09:00
Tetsuharu Ohzeki
2601d19bac clippy: Enable non_canonical_clone_impl rule 2024-02-09 22:37:42 +09:00
Tetsuharu Ohzeki
7669619f9a clippy: Enable self_named_constructors rule 2024-02-09 22:31:21 +09:00
austaras
dad0fdb13f fix: preserve where clause when builtin derive 2024-02-08 22:44:39 +08:00
clubby789
79e4111442 Remove ffi_returns_twice references 2024-02-07 19:42:07 +00:00
bors
66cec4d11a Auto merge of #16470 - Veykril:clippy-disallow, r=lnicola
internal: Lint debug prints and disallowed types with clippy
2024-02-05 17:20:43 +00:00
bors
7fb639ffc1 Auto merge of #16482 - GnomedDev:boxed-subtree, r=lnicola
Swap Subtree::token_trees from Vec to boxed slice

Performs one of the optimizations suggested in #16325, but a little bit more. Boxed slices guarantee `shrink_to_fit` aswell as saving a pointer width as no capacity has to be stored.

Most of the diff is:
- Changing `vec![]` to `Box::new([])`
- Changing initialize -> fill into fill -> into_boxed_slice
- Working around the lack of an owned iterator or automatic iteration over a `Box<[T]>`

I would like to use my own crate, [small-fixed-array](https://lib.rs/small-fixed-array), although I understand if it isn't mature enough for this. If I'm given the go ahead, I can rework this PR to use it instead.
2024-02-05 09:14:06 +00:00
bors
3e47532dd4 Auto merge of #16474 - davidbarsky:david/import-on-the-fly-improvements, r=lnicola
internal: even more `tracing`

As part of profiling completions, I added some additional spans and moved `TyBuilder::subst_for_def` closer to its usage site (the latter had a small impact on completion performance. Thanks for the tip, Lukas!)
2024-02-05 09:01:58 +00:00
Laurențiu Nicola
b8a3180a60 Merge commit '0113bc9388b480fa42c632f57f4f0f7af5813ec1' into sync-from-ra 2024-02-04 10:37:58 +02:00
GnomedDev
8011b56827
Swap Subtree::token_trees from Vec to boxed slice 2024-02-04 00:28:22 +00:00
bors
8f6a72871e Auto merge of #16469 - Young-Flash:ci_typos, r=lnicola
internal: add typos check CI (part 2)

follow up https://github.com/rust-lang/rust-analyzer/pull/16448
2024-02-02 12:02:48 +00:00
Young-Flash
ba2910a3a7 minor: correct some typos 2024-02-02 18:22:54 +08:00
David Barsky
f9bef39d48 internal: add some more tracing spans inside of hir-ty 2024-02-01 16:10:32 -05:00
Lukas Wirth
9e8a0fae0c Lint debug prints and disallowed types with clippy 2024-02-01 17:57:27 +01:00
Johann Hemmann
771c6c9271 format_collect 2024-01-31 19:06:36 +01:00
Johann Hemmann
d37f4e0d21 new_without_default 2024-01-31 19:06:36 +01:00
Johann Hemmann
dd9f27b8d3 borrow_deref_ref 2024-01-31 19:06:18 +01:00
Johann Hemmann
c4688343de derivable_impls 2024-01-31 19:06:18 +01:00