Lukas Wirth
7beac14cba
Internal: Cleanup proc-macro error handling
2024-07-26 14:38:19 +02:00
Lukas Wirth
d32e60467f
Remove unused trace module
2024-07-25 14:08:48 +02:00
bors
0ba6f4eda0
Auto merge of #17676 - winstxnhdw:precise-capturing, r=Veykril
...
feat: add preliminary support for `+ use<..>` `precise_capturing` syntax
## Summary
This PR adds basic support for the following syntax.
```rs
fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T> {}
// ~~~~~~~~~~~~~~~~~~~~~~~
// This opaque type does not capture `'a`.
fn outlives<'o, T: 'o>(_: T) {}
fn caller<'o, 'a, 'b: 'o, T: 'o>() {
// ~~
// ^ Note that we don't need `'a: 'o`.
outlives::<'o>(captures::<'a, 'b, T>());
}
```
Related to #17598
2024-07-25 11:10:56 +00:00
Winston H.
9f74787d5d
fix: handle new TypeBoundKind
variant
2024-07-25 10:58:25 +00:00
Lukas Wirth
0e93e6fee7
Make legacy_const_generics_indices thin by double boxing as its seldom used
2024-07-25 11:51:15 +02:00
Lukas Wirth
7f884487d7
Reduce size of TypeRef by 8 bytes
2024-07-25 11:14:55 +02:00
Lukas Wirth
f2fa456a8c
Fix incorrect handling of cfg'd varargs
2024-07-25 11:02:19 +02:00
Lukas Wirth
9cbafa2d49
Remove Params and Fields from AstIdMap
2024-07-25 10:22:05 +02:00
Lukas Wirth
7c374a10bd
internal: Shrink size of Binding
2024-07-22 17:14:17 +02:00
bors
36f58f5fff
Auto merge of #17670 - Veykril:mem, r=Veykril
...
LRU `body_with_source_map` query
This query is being invalidated all the time anyways (we have an extra query on top of it for the body incrementality that is not source dependent), so there is little reason to keep these around all the time when only some IDE features are interested in them.
2024-07-22 14:48:05 +00:00
Lukas Wirth
bd359b32b0
LRU body_with_source_map
query
2024-07-22 16:34:59 +02:00
bors
6f3030f316
Auto merge of #17586 - ShoyuVanilla:tuple-arg-macro-rest, r=Veykril
...
Allow macro expansions into `RestPat` in tuple args work as ellipsis like plain `RestPat`
Fixes #17292
Currently, Rust Analyzer lowers `ast::Pat::RestPat` into `Pat::Missing` in general cases on the following lines;
ffbc5ad993/crates/hir-def/src/body/lower.rs (L1359-L1367)
And in some proper positions such as `TupleStruct(..)`, it is specially handed on the following lines;
ffbc5ad993/crates/hir-def/src/body/lower.rs (L1429-L1437)
This behavior is reasonable because rustc does similar things in
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L108-L111)
and
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L123-L142)
But this sometimes works differently because Rust Analyzer expands macros while ast lowering;
ffbc5ad993/crates/hir-def/src/body/lower.rs (L1386-L1398)
ffbc5ad993/crates/hir-def/src/body/lower.rs (L941-L963)
but rustc uses expanded ast in the corresponding tuple-handling process, so it does not have macro patterns there.
62c068feea/compiler/rustc_ast_lowering/src/pat.rs (L114)
So, if a macro expansion in a tuple arg results in `..`, rustc permits it like plain `..` pattern, but Rust Analyzer rejects it.
This is the root cause of #17292 and this PR allows macros expanded into `..` in a tuple arg position work as ellipsis like that.
2024-07-22 09:08:12 +00:00
Sydney Acksman
cdd7b18149
Fix more path resolution for included submodules
...
Now with much more comprehensive testing! This
adds tests for includes within modules.
2024-07-21 19:04:19 -05:00
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