Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
192 commits
Select commit Hold shift + click to select a range
979704d
Fix not applicable on statement for convert_to_guarded_return
A4-Tacks Oct 26, 2025
c0ecf1a
Implement Span::line() and Span::column() for proc-macro server
tilladam Jan 2, 2026
fd1457d
Merge pull request #21405 from tilladam/master
Veykril Jan 5, 2026
4fbc520
perf: Re-use scratch allocations for `try_evaluate_obligations`
Veykril Jan 5, 2026
978d75e
Merge pull request #21407 from Veykril/push-wlvmrkvowrlr
Veykril Jan 5, 2026
4699fdc
Fix loses exists guard for move_guard
A4-Tacks Jan 6, 2026
a978fdc
fix: use crates where ADT was defined in deref_chain of trait_applica…
sshcrack Jan 6, 2026
6cc9e5c
Document `Query`
Veykril Jan 7, 2026
1af7813
Document `WithFixture`
Veykril Jan 7, 2026
ad02093
feat: Allow rust paths in symbol search
Veykril Jan 7, 2026
dc64aef
fix: Properly lower `SelfOnly` predicates
ShoyuVanilla Jan 4, 2026
74c3f3a
Merge pull request #21414 from sshcrack/master
ShoyuVanilla Jan 7, 2026
e2b5072
Add ProjectJsonTargetSpec.project_root
cormacrelf Dec 2, 2025
ff94498
project-model: Helpers for traversing dep graph in ProjectJson
cormacrelf Dec 2, 2025
3083bde
project-model: Don't do O(n) clones as well as O(n) search
cormacrelf Dec 2, 2025
ac64177
project-model: Return crate by reference
cormacrelf Sep 4, 2024
3b97d38
Fix misuse of ?
cormacrelf Dec 2, 2025
327ea18
flycheck: Make the flycheckable unit a flycheck::PackageSpecifier enum
cormacrelf Sep 4, 2024
95a07db
project-model: Introduce RunnableKind::Flycheck
cormacrelf Sep 4, 2024
2a899bb
flycheck: Use RunnableKind::Flycheck from ProjectJson to flycheck
cormacrelf Sep 4, 2024
7f608da
flycheck: Support {label} in check_overrideCommand as well as $saved_…
cormacrelf Sep 4, 2024
4e61c60
flycheck: Always flycheck single crate if there is a build label from…
cormacrelf Sep 4, 2024
778de45
flycheck: Add display_command to pretty-print flycheck command being …
cormacrelf Sep 4, 2024
53a371c
flycheck: notifications show full command when configured in a rust-p…
cormacrelf Sep 4, 2024
3fdb78c
flycheck: Rename FlycheckConfig::CargoCommand to Automatic
cormacrelf Dec 3, 2025
2d58177
Fix RunnableKind::Run label interpolation
cormacrelf Dec 3, 2025
71e2ded
doc: Update docs for runnables to include run/flycheck
cormacrelf Dec 3, 2025
422597f
doc: make example for workspace.discoverConfig actually work
cormacrelf Dec 3, 2025
f06a6b9
doc: overhaul non-cargo build system docs
cormacrelf Dec 3, 2025
b02e975
Fix hir-ty clippy issue
cormacrelf Jan 7, 2026
be1e357
Merge pull request #21399 from ShoyuVanilla/self-only-preds
ChayimFriedman2 Jan 7, 2026
6a9de22
Prepare for merging from rust-lang/rust
invalid-email-address Jan 8, 2026
09c878a
Merge ref '548e586795f6' from rust-lang/rust
invalid-email-address Jan 8, 2026
e22a450
Merge pull request #21419 from rust-lang/rustc-pull
lnicola Jan 8, 2026
d68a73a
Merge pull request #18043 from cormacrelf/feature/rust-project-discovery
Veykril Jan 8, 2026
5d8a7da
Fixes for builtin derive expansions
ChayimFriedman2 Jan 8, 2026
d87c468
Merge pull request #21421 from ChayimFriedman2/no-derive-register
ChayimFriedman2 Jan 8, 2026
459d77e
Publish smol_str v0.3.5
ChayimFriedman2 Jan 8, 2026
3e1dd59
Merge pull request #21422 from ChayimFriedman2/new-smol-str
ChayimFriedman2 Jan 8, 2026
26be33a
Fix not disable string escape highlights
A4-Tacks Jan 8, 2026
491c320
Merge pull request #21420 from A4-Tacks/disable-string-hl
ChayimFriedman2 Jan 9, 2026
e80fbd4
Fix lifetimes len diagnostics for fn pointers
ChayimFriedman2 Jan 9, 2026
e52695c
internal: Include private definitions in generated rustdoc
Wilfred Jan 9, 2026
66ba447
Merge pull request #21433 from Wilfred/rustdoc_private_items
ChayimFriedman2 Jan 9, 2026
998a5ac
Remove code made redundant by method resolution rewrite
ChayimFriedman2 Jan 9, 2026
bcf059c
Fix issue with ignore attribute for tests where the attribute has a v…
cry-inc Jan 9, 2026
4f7e395
Merge pull request #21432 from ChayimFriedman2/fn-ptr-lifetime-diag
ShoyuVanilla Jan 10, 2026
c825a50
Cleanup
Veykril Jan 10, 2026
2c356a3
Merge pull request #21415 from Veykril/push-qusurvyqwmxt
Veykril Jan 10, 2026
25c0131
Merge pull request #21434 from ChayimFriedman2/traits-mix
ShoyuVanilla Jan 10, 2026
4e18f1d
Abstract proc-macro-srv input and output away
Veykril Jan 10, 2026
366b80e
Merge pull request #21438 from Veykril/push-prppzzzllqso
Veykril Jan 10, 2026
27fef0c
internal: Landing integration test infra for proc-macro-srv-cli
Veykril Jan 10, 2026
83c635a
Merge pull request #21436 from cry-inc/bugfix/fix-ignore-attribute-wi…
ChayimFriedman2 Jan 10, 2026
e40bd1c
Add inherit attributes for extract_function assist
A4-Tacks Jan 11, 2026
8150413
add byte range subrequest/response
Shourya742 Jan 7, 2026
e909b4b
update proc-macro-srv to include byte-range
Shourya742 Jan 7, 2026
e68a654
add byte range to main loop and direct the request via callback and d…
Shourya742 Jan 7, 2026
78d243c
add comment on incrementality of subrequest
Shourya742 Jan 8, 2026
d30f7c9
add write read imports
Shourya742 Jan 11, 2026
581444f
Merge pull request #21416 from Shourya742/2026-01-07-add-byte-range
Veykril Jan 11, 2026
33f0f80
add make corresponding constructor methods in SyntaxFactory
Shourya742 Jan 11, 2026
16d74e7
migrate generate_mut_trait_impl to new SyntaxEditor
Shourya742 Jan 11, 2026
594ca4b
Prepare for merging from rust-lang/rust
invalid-email-address Jan 12, 2026
0f0951f
Merge ref '44a5b55557c2' from rust-lang/rust
invalid-email-address Jan 12, 2026
80acef1
Format code
invalid-email-address Jan 12, 2026
b4d49de
Merge pull request #21439 from Veykril/push-okkmmxmnwyxm
Veykril Jan 12, 2026
294a0af
Disable `unused_variables` and `unused_mut` warnings
ChayimFriedman2 Jan 12, 2026
19aae35
Create a new `SymbolKind::CrateRoot`
Veykril Jan 12, 2026
5f6d385
Fix crate root search in world symbols duplicating root entries
Veykril Jan 12, 2026
8cbceb4
Merge pull request #21446 from Veykril/veykril/push-wnuyntxqruqm
Veykril Jan 12, 2026
febc131
Merge pull request #21444 from rust-lang/rustc-pull
lnicola Jan 12, 2026
55f6901
Fix lowering with supertrait predicates
Wilfred Dec 29, 2025
e6e5e5d
Merge pull request #21364 from Wilfred/fix_cycle_projections
ChayimFriedman2 Jan 12, 2026
01ebc28
smol_str: update changelog 0.3.5
alexheretic Jan 12, 2026
c20e6a1
Fix not complete `mut` and `raw` in `&x.foo()`
A4-Tacks Jan 12, 2026
21790ef
Merge pull request #21445 from ChayimFriedman2/disable-mir-warnings
Veykril Jan 12, 2026
62e777c
Fix overlapping cfg attributes for wasm32-unknown-emscripten target
robertoaloi Jan 12, 2026
bc7f853
Merge pull request #21448 from alexheretic/smol-str-changelog-0.3.5
ChayimFriedman2 Jan 12, 2026
dc029f0
Merge pull request #21450 from robertoaloi/wasm32-overlapping-cfg
lnicola Jan 12, 2026
3950a27
Merge pull request #21443 from Shourya742/2026-01-11-migrate-get_mut_…
ShoyuVanilla Jan 13, 2026
1a2200a
Merge pull request #21451 from A4-Tacks/comp-ref-mut-before-method-call
ShoyuVanilla Jan 13, 2026
38fb3a7
Merge pull request #21412 from A4-Tacks/move-guard-exist
ShoyuVanilla Jan 13, 2026
58b85be
Merge pull request #20946 from A4-Tacks/to-guarded-in-stmt
ShoyuVanilla Jan 13, 2026
467b4e4
Merge pull request #21442 from A4-Tacks/extract-func-attrs
ShoyuVanilla Jan 13, 2026
2c32c0e
Make `naked_asm!()` always return `!`
ChayimFriedman2 Jan 13, 2026
a215480
Migrate `unwrap_block` assist to use SyntaxEditor
A4-Tacks Jan 13, 2026
8d983e9
Merge pull request #21456 from ChayimFriedman2/naked-asm
Veykril Jan 13, 2026
8fb704c
fix: Hide renamed imports from macros in symbol index
Veykril Jan 13, 2026
c3dfd5d
Merge pull request #21459 from Veykril/push-oqtvruwxtsyn
Veykril Jan 13, 2026
6948a66
fix: Sync cast checks to rustc again
ShoyuVanilla Jan 13, 2026
332287d
Merge pull request #21462 from ShoyuVanilla/cast-fix
ChayimFriedman2 Jan 13, 2026
6b21796
Merge pull request #21458 from A4-Tacks/migrate-unwrap-block
ShoyuVanilla Jan 14, 2026
05939a8
Fix false positive precedence in `(2 as i32) < 3`
A4-Tacks Jan 14, 2026
4b5b42c
remove postcard from legacy
Shourya742 Jan 14, 2026
31817f6
remove flatten from ExpandMacro message in bidirectional messages
Shourya742 Jan 14, 2026
3f9de55
Merge pull request #21466 from Shourya742/2026-01-14-remove-postcard-…
Veykril Jan 14, 2026
98e1f71
Bump camino to 1.2.2
robertoaloi Jan 14, 2026
0d8aa89
fix: Fix path symbol search not respecting re-exports
Veykril Jan 14, 2026
1790ab0
Merge pull request #21464 from Veykril/push-myvkmuxpzkvp
Veykril Jan 14, 2026
6ecee2a
internal: Improve docs for discoverConfig
Wilfred Jan 14, 2026
77f372f
Merge pull request #21467 from robertoaloi/ra-upgrade
lnicola Jan 14, 2026
c31add0
Prepare for merging from rust-lang/rust
invalid-email-address Jan 15, 2026
52159b6
Merge ref 'b6fdaf2a1573' from rust-lang/rust
invalid-email-address Jan 15, 2026
5c1acd6
Merge pull request #21471 from rust-lang/rustc-pull
lnicola Jan 15, 2026
70f4111
Merge pull request #21465 from A4-Tacks/prec-cast-before-angle
ShoyuVanilla Jan 15, 2026
d859656
fix: lookup flycheck by ID instead of vector index
lukasoyen Jan 15, 2026
c6ec8ea
Merge pull request #21475 from lukasoyen/fix-flycheck-indexing
ShoyuVanilla Jan 16, 2026
4870a5f
add worker abstraction
Shourya742 Jan 1, 2026
98d4496
add termination flag to procmacroserverprocess
Shourya742 Jan 1, 2026
9fb5d34
add pool of processes
Shourya742 Jan 1, 2026
c685aa9
direct client calls via pool
Shourya742 Jan 2, 2026
82e758a
add better process picker and improve loading dylib
Shourya742 Jan 2, 2026
922bc7e
rename process to pool in ProcMacro struct
Shourya742 Jan 2, 2026
c4c336a
keep it clean and tidy
Shourya742 Jan 2, 2026
c8a3551
change callback from FnMut to Fn as we only transform messages and no…
Shourya742 Jan 3, 2026
66bca6a
propagate error from load dylibs
Shourya742 Jan 3, 2026
09c91b7
pick workers which have not exited
Shourya742 Jan 3, 2026
0936597
add version to pool
Shourya742 Jan 3, 2026
263015a
remove expand from pool
Shourya742 Jan 4, 2026
e3e7c29
remove default pool size from pool
Shourya742 Jan 5, 2026
96ecd17
add num process in config
Shourya742 Jan 5, 2026
9d5e600
add proc_macro_processes in load config
Shourya742 Jan 5, 2026
721361f
update all cli workflows
Shourya742 Jan 5, 2026
0587cbd
optimize pick_process to short circuit and return as early as possibl…
Shourya742 Jan 5, 2026
b49417e
fix test and update some autogen files
Shourya742 Jan 5, 2026
a81da31
rename from proc_macro_processes to procMacro_processes
Shourya742 Jan 5, 2026
8da5de0
rebased changes
Shourya742 Jan 11, 2026
c31698b
Improve move_guard redundanted block
A4-Tacks Jan 17, 2026
060c6f1
Merge pull request #21468 from Wilfred/improve_discover_docs
lnicola Jan 18, 2026
cbad6dd
fix: Do not show sysroot dependencies in symbol search
Veykril Jan 16, 2026
bfbee86
feat: Trigger flycheck if non-workspace files get modified
Veykril Jan 16, 2026
8f12958
Merge pull request #21483 from Veykril/push-vswqqvzqyvnv
Veykril Jan 18, 2026
7bbe902
Merge pull request #21484 from Veykril/push-uoxwkwottnqn
Veykril Jan 18, 2026
ebcbff2
Do not mix the order of builtin/regular derives in "Expand macro recu…
ChayimFriedman2 Jan 19, 2026
4dad9b9
Insert type vars and normalize for the type of a used `static`
ChayimFriedman2 Jan 19, 2026
1285b1b
Ensure correct capturing of async fn params even when they use weird …
ChayimFriedman2 Jan 19, 2026
ad7d5ea
Merge pull request #21385 from Shourya742/2026-01-01-parallelize-proc…
lnicola Jan 19, 2026
740eb6b
remove non-describing field annotation from bidirectional message def…
Shourya742 Jan 15, 2026
ffa2dad
remove serialize from Expn Globals
Shourya742 Jan 18, 2026
8fd5569
add bidirectional flow
Shourya742 Jan 18, 2026
ee35fd6
add bidirectional test
Shourya742 Jan 18, 2026
a151d7d
adapt json test
Shourya742 Jan 18, 2026
095b013
rename send and drive to request and receive and remove auto*
Shourya742 Jan 18, 2026
29aad04
Cache `Clauses::empty()`
ChayimFriedman2 Jan 19, 2026
a894e85
Merge pull request #21493 from ChayimFriedman2/perf-fixup
ChayimFriedman2 Jan 19, 2026
ab0853b
Merge pull request #21491 from ChayimFriedman2/static-insert-var
ShoyuVanilla Jan 19, 2026
dbee105
Merge pull request #21492 from ChayimFriedman2/async-fn
ShoyuVanilla Jan 20, 2026
92903fa
Merge pull request #21485 from A4-Tacks/move-guard-clean-block
ShoyuVanilla Jan 20, 2026
e07da1f
feat(hir-ty): add method references_only_ty_error to detect type errors
ileixe Jan 20, 2026
61b9b33
Fix demorgan applicable on pattern conditional
A4-Tacks Jan 20, 2026
c177a39
Merge pull request #21497 from ileixe/issue-21315
ShoyuVanilla Jan 20, 2026
8e937d4
Bump notify from 8.0.0. to 8.2.0
robertoaloi Jan 21, 2026
fd80a3e
Merge pull request #21490 from ChayimFriedman2/expand-derive-builtin
Veykril Jan 21, 2026
c8edb52
Merge pull request #21499 from A4-Tacks/not-demorgan-pattern
lnicola Jan 21, 2026
6753155
Prepare for merging from rust-lang/rust
invalid-email-address Jan 22, 2026
ee0fabd
Merge ref '004d710faff5' from rust-lang/rust
invalid-email-address Jan 22, 2026
42d9942
Merge pull request #21506 from rust-lang/rustc-pull
lnicola Jan 22, 2026
4e9e37e
internal: Add tests for rust-lang/rust#146972
Veykril Jan 23, 2026
b5bb005
Merge pull request #21509 from Veykril/push-zwownxpqxrnw
Veykril Jan 23, 2026
bd91c88
Improve extract_function name
A4-Tacks Jan 24, 2026
3f39593
fix: Fix incorrect continue for convert_range_for_to_while
A4-Tacks Jan 24, 2026
af21cbe
Merge pull request #21479 from Shourya742/2026-01-15-add-bidirectiona…
Veykril Jan 24, 2026
a443498
Merge pull request #21501 from robertoaloi/ra-bump-notify
Veykril Jan 24, 2026
cb603ad
internal: Use parser expect where possible
pksunkara Jan 25, 2026
45ef766
Merge pull request #21518 from pksunkara/pavan/jj/uwxtukzt
Veykril Jan 25, 2026
2a3614b
correct ungrammar path in patch
Shourya742 Jan 26, 2026
4fae402
Merge pull request #21523 from Shourya742/2026-01-26-correct-ungramma…
ChayimFriedman2 Jan 26, 2026
803b7cc
Merge pull request #21514 from A4-Tacks/range-for-to-while-handle-con…
ChayimFriedman2 Jan 26, 2026
9fd291e
Fix not complete 'else' before tuple
A4-Tacks Jan 19, 2026
acfb441
Merge pull request #21495 from A4-Tacks/comp-else-before-tuple
ChayimFriedman2 Jan 26, 2026
2f49df3
Improve filter predicate to length cond
A4-Tacks Jan 26, 2026
38bb09e
Fix rust-src installation command in FAQ
edwin0cheng Jan 26, 2026
d7136ca
Merge pull request #21524 from edwin0cheng/patch-1
lnicola Jan 26, 2026
b75c58d
Implement default field values `..` syntax
kouhe3 Jan 5, 2026
e0ebb92
Merge pull request #21513 from A4-Tacks/extract-fun-name
ChayimFriedman2 Jan 26, 2026
6531c75
Merge pull request #21408 from kouhe3/default_field_values
ChayimFriedman2 Jan 26, 2026
2c2602b
Fix macro matching of `meta` then `=>` or `==`
ChayimFriedman2 Jan 26, 2026
cd8fe54
Fix semicolon for toggle_macro_delimiter
A4-Tacks Jan 25, 2026
0828abf
Merge pull request #21522 from A4-Tacks/tog-macro-delim-semicolon
ChayimFriedman2 Jan 26, 2026
6664fc6
minor: Downgrade noisy log
Veykril Jan 27, 2026
cce824a
Merge pull request #21531 from Veykril/push-usuormvursms
Veykril Jan 27, 2026
4430fd8
Merge pull request #21527 from ChayimFriedman2/builtin-macro-name
ShoyuVanilla Jan 27, 2026
c420ed5
fix: Do not panic if rust-analyzer fails to spawn the discover command
Veykril Jan 27, 2026
b28e6f0
Merge pull request #21534 from Veykril/push-polxrwlzrzrx
Veykril Jan 27, 2026
bf12b8b
Fix linking of proc-macro-srv-cli
lnicola Jan 27, 2026
f1d10bb
Merge pull request #21535 from lnicola/proc-macro-srv-cli-link
ChayimFriedman2 Jan 27, 2026
3491099
Prepare for merging from rust-lang/rust
lnicola Jan 27, 2026
83e479c
Merge ref '94a0cd15f597' from rust-lang/rust
lnicola Jan 27, 2026
c5faba7
Fix sysroot-abi build
lnicola Jan 27, 2026
2c0a0bb
Merge pull request #21537 from lnicola/sync-from-rust
lnicola Jan 27, 2026
d400dca
Fix postcard test too
lnicola Jan 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/.github/workflows/rustdoc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: rustup update --no-self-update stable

- name: Build Documentation
run: cargo doc --all --no-deps
run: cargo doc --all --no-deps --document-private-items

- name: Deploy Docs
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
Expand Down
13 changes: 10 additions & 3 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"

[[package]]
name = "camino"
version = "1.2.0"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1de8bc0aa9e9385ceb3bf0c152e3a9b9544f6c4a912c8ae504e80c1f0368603"
checksum = "e629a66d692cb9ff1a1c664e41771b3dcaf961985a9774c0eb0bd1b51cf60a48"
dependencies = [
"serde_core",
]
Expand Down Expand Up @@ -1864,6 +1864,7 @@ dependencies = [
"intern",
"libc",
"libloading",
"line-index 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap2",
"object",
"paths",
Expand All @@ -1878,9 +1879,15 @@ name = "proc-macro-srv-cli"
version = "0.0.0"
dependencies = [
"clap",
"expect-test",
"intern",
"paths",
"postcard",
"proc-macro-api",
"proc-macro-srv",
"proc-macro-test",
"span",
"tt",
]

[[package]]
Expand Down Expand Up @@ -2628,7 +2635,7 @@ dependencies = [

[[package]]
name = "smol_str"
version = "0.3.4"
version = "0.3.5"
dependencies = [
"arbitrary",
"borsh",
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ debug = 2
# lsp-server = { path = "lib/lsp-server" }


# ungrammar = { path = "lin/ungrammar" }
# ungrammar = { path = "lib/ungrammar" }

# salsa = { path = "../salsa" }
# salsa-macros = { path = "../salsa/components/salsa-macros" }
Expand Down Expand Up @@ -107,7 +107,7 @@ anyhow = "1.0.98"
arrayvec = "0.7.6"
bitflags = "2.9.1"
cargo_metadata = "0.23.0"
camino = "1.1.10"
camino = "1.2.2"
crossbeam-channel = "0.5.15"
dissimilar = "1.0.10"
dot = "0.1.4"
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ pub enum LangCrateOrigin {
ProcMacro,
Std,
Test,
Dependency,
Other,
}

Expand All @@ -245,7 +246,7 @@ impl fmt::Display for LangCrateOrigin {
LangCrateOrigin::ProcMacro => "proc_macro",
LangCrateOrigin::Std => "std",
LangCrateOrigin::Test => "test",
LangCrateOrigin::Other => "other",
LangCrateOrigin::Other | LangCrateOrigin::Dependency => "other",
};
f.write_str(text)
}
Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/hir-def/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ fn match_attr_flags(attr_flags: &mut AttrFlags, attr: Meta) -> ControlFlow<Infal
match attr {
Meta::NamedKeyValue { name: Some(name), value, .. } => match name.text() {
"deprecated" => attr_flags.insert(AttrFlags::IS_DEPRECATED),
"ignore" => attr_flags.insert(AttrFlags::IS_IGNORE),
"lang" => attr_flags.insert(AttrFlags::LANG_ITEM),
"path" => attr_flags.insert(AttrFlags::HAS_PATH),
"unstable" => attr_flags.insert(AttrFlags::IS_UNSTABLE),
Expand Down
22 changes: 21 additions & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/builtin_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use intern::{Symbol, sym};
use tt::TextRange;

use crate::{
AdtId, BuiltinDeriveImplId, BuiltinDeriveImplLoc, FunctionId, HasModule, db::DefDatabase,
AdtId, BuiltinDeriveImplId, BuiltinDeriveImplLoc, FunctionId, HasModule, MacroId,
db::DefDatabase, lang_item::LangItems,
};

macro_rules! declare_enum {
Expand Down Expand Up @@ -86,6 +87,25 @@ declare_enum!(
DispatchFromDyn => [],
);

impl BuiltinDeriveImplTrait {
pub fn derive_macro(self, lang_items: &LangItems) -> Option<MacroId> {
match self {
BuiltinDeriveImplTrait::Copy => lang_items.CopyDerive,
BuiltinDeriveImplTrait::Clone => lang_items.CloneDerive,
BuiltinDeriveImplTrait::Default => lang_items.DefaultDerive,
BuiltinDeriveImplTrait::Debug => lang_items.DebugDerive,
BuiltinDeriveImplTrait::Hash => lang_items.HashDerive,
BuiltinDeriveImplTrait::Ord => lang_items.OrdDerive,
BuiltinDeriveImplTrait::PartialOrd => lang_items.PartialOrdDerive,
BuiltinDeriveImplTrait::Eq => lang_items.EqDerive,
BuiltinDeriveImplTrait::PartialEq => lang_items.PartialEqDerive,
BuiltinDeriveImplTrait::CoerceUnsized | BuiltinDeriveImplTrait::DispatchFromDyn => {
lang_items.CoercePointeeDerive
}
}
}
}

impl BuiltinDeriveImplMethod {
pub fn trait_method(
self,
Expand Down
10 changes: 6 additions & 4 deletions src/tools/rust-analyzer/crates/hir-def/src/dyn_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
pub mod keys {
use std::marker::PhantomData;

use either::Either;
use hir_expand::{MacroCallId, attrs::AttrId};
use rustc_hash::FxHashMap;
use syntax::{AstNode, AstPtr, ast};

use crate::{
BlockId, ConstId, EnumId, EnumVariantId, ExternBlockId, ExternCrateId, FieldId, FunctionId,
ImplId, LifetimeParamId, Macro2Id, MacroRulesId, ProcMacroId, StaticId, StructId, TraitId,
TypeAliasId, TypeOrConstParamId, UnionId, UseId,
BlockId, BuiltinDeriveImplId, ConstId, EnumId, EnumVariantId, ExternBlockId, ExternCrateId,
FieldId, FunctionId, ImplId, LifetimeParamId, Macro2Id, MacroRulesId, ProcMacroId,
StaticId, StructId, TraitId, TypeAliasId, TypeOrConstParamId, UnionId, UseId,
dyn_map::{DynMap, Policy},
};

Expand Down Expand Up @@ -71,7 +72,8 @@ pub mod keys {
(
AttrId,
/* derive() */ MacroCallId,
/* actual derive macros */ Box<[Option<MacroCallId>]>,
/* actual derive macros */
Box<[Option<Either<MacroCallId, BuiltinDeriveImplId>>]>,
),
> = Key::new();

Expand Down
10 changes: 5 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/expr_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::{
expr_store::path::Path,
hir::{
Array, AsmOperand, Binding, BindingId, Expr, ExprId, ExprOrPatId, Label, LabelId, Pat,
PatId, RecordFieldPat, Statement,
PatId, RecordFieldPat, RecordSpread, Statement,
},
nameres::{DefMap, block_def_map},
type_ref::{LifetimeRef, LifetimeRefId, PathId, TypeRef, TypeRefId},
Expand Down Expand Up @@ -575,8 +575,8 @@ impl ExpressionStore {
for field in fields.iter() {
f(field.expr);
}
if let &Some(expr) = spread {
f(expr);
if let RecordSpread::Expr(expr) = spread {
f(*expr);
}
}
Expr::Closure { body, .. } => {
Expand Down Expand Up @@ -706,8 +706,8 @@ impl ExpressionStore {
for field in fields.iter() {
f(field.expr);
}
if let &Some(expr) = spread {
f(expr);
if let RecordSpread::Expr(expr) = spread {
f(*expr);
}
}
Expr::Closure { body, .. } => {
Expand Down
80 changes: 60 additions & 20 deletions src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use crate::{
hir::{
Array, Binding, BindingAnnotation, BindingId, BindingProblems, CaptureBy, ClosureKind,
Expr, ExprId, Item, Label, LabelId, Literal, MatchArm, Movability, OffsetOf, Pat, PatId,
RecordFieldPat, RecordLitField, Statement, generics::GenericParams,
RecordFieldPat, RecordLitField, RecordSpread, Statement, generics::GenericParams,
},
item_scope::BuiltinShadowMode,
item_tree::FieldsShape,
Expand Down Expand Up @@ -150,6 +150,7 @@ pub(super) fn lower_body(
};

let body_expr = collector.collect(
&mut params,
body,
if is_async_fn {
Awaitable::Yes
Expand Down Expand Up @@ -903,24 +904,57 @@ impl<'db> ExprCollector<'db> {
})
}

fn collect(&mut self, expr: Option<ast::Expr>, awaitable: Awaitable) -> ExprId {
/// An `async fn` needs to capture all parameters in the generated `async` block, even if they have
/// non-captured patterns such as wildcards (to ensure consistent drop order).
fn lower_async_fn(&mut self, params: &mut Vec<PatId>, body: ExprId) -> ExprId {
let mut statements = Vec::new();
for param in params {
let name = match self.store.pats[*param] {
Pat::Bind { id, .. }
if matches!(
self.store.bindings[id].mode,
BindingAnnotation::Unannotated | BindingAnnotation::Mutable
) =>
{
// If this is a direct binding, we can leave it as-is, as it'll always be captured anyway.
continue;
}
Pat::Bind { id, .. } => {
// If this is a `ref` binding, we can't leave it as is but we can at least reuse the name, for better display.
self.store.bindings[id].name.clone()
}
_ => self.generate_new_name(),
};
let binding_id =
self.alloc_binding(name.clone(), BindingAnnotation::Mutable, HygieneId::ROOT);
let pat_id = self.alloc_pat_desugared(Pat::Bind { id: binding_id, subpat: None });
let expr = self.alloc_expr_desugared(Expr::Path(name.into()));
statements.push(Statement::Let {
pat: *param,
type_ref: None,
initializer: Some(expr),
else_branch: None,
});
*param = pat_id;
}

self.alloc_expr_desugared(Expr::Async {
id: None,
statements: statements.into_boxed_slice(),
tail: Some(body),
})
}

fn collect(
&mut self,
params: &mut Vec<PatId>,
expr: Option<ast::Expr>,
awaitable: Awaitable,
) -> ExprId {
self.awaitable_context.replace(awaitable);
self.with_label_rib(RibKind::Closure, |this| {
if awaitable == Awaitable::Yes {
match expr {
Some(e) => {
let syntax_ptr = AstPtr::new(&e);
let expr = this.collect_expr(e);
this.alloc_expr_desugared_with_ptr(
Expr::Async { id: None, statements: Box::new([]), tail: Some(expr) },
syntax_ptr,
)
}
None => this.missing_expr(),
}
} else {
this.collect_expr_opt(expr)
}
let body = this.collect_expr_opt(expr);
if awaitable == Awaitable::Yes { this.lower_async_fn(params, body) } else { body }
})
}

Expand Down Expand Up @@ -1232,10 +1266,16 @@ impl<'db> ExprCollector<'db> {
Some(RecordLitField { name, expr })
})
.collect();
let spread = nfl.spread().map(|s| self.collect_expr(s));
let spread_expr = nfl.spread().map(|s| self.collect_expr(s));
let has_spread_syntax = nfl.dotdot_token().is_some();
let spread = match (spread_expr, has_spread_syntax) {
(None, false) => RecordSpread::None,
(None, true) => RecordSpread::FieldDefaults,
(Some(expr), _) => RecordSpread::Expr(expr),
};
Expr::RecordLit { path, fields, spread }
} else {
Expr::RecordLit { path, fields: Box::default(), spread: None }
Expr::RecordLit { path, fields: Box::default(), spread: RecordSpread::None }
};

self.alloc_expr(record_lit, syntax_ptr)
Expand Down Expand Up @@ -1961,7 +2001,7 @@ impl<'db> ExprCollector<'db> {
}
}

fn collect_expr_opt(&mut self, expr: Option<ast::Expr>) -> ExprId {
pub fn collect_expr_opt(&mut self, expr: Option<ast::Expr>) -> ExprId {
match expr {
Some(expr) => self.collect_expr(expr),
None => self.missing_expr(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use crate::{
builtin_type::BuiltinUint,
expr_store::{HygieneId, lower::ExprCollector, path::Path},
hir::{
Array, BindingAnnotation, Expr, ExprId, Literal, Pat, RecordLitField, Statement,
Array, BindingAnnotation, Expr, ExprId, Literal, Pat, RecordLitField, RecordSpread,
Statement,
format_args::{
self, FormatAlignment, FormatArgs, FormatArgsPiece, FormatArgument, FormatArgumentKind,
FormatArgumentsCollector, FormatCount, FormatDebugHex, FormatOptions,
Expand Down Expand Up @@ -869,7 +870,7 @@ impl<'db> ExprCollector<'db> {
self.alloc_expr_desugared(Expr::RecordLit {
path: self.lang_path(lang_items.FormatPlaceholder).map(Box::new),
fields: Box::new([position, flags, precision, width]),
spread: None,
spread: RecordSpread::None,
})
} else {
let format_placeholder_new =
Expand Down
20 changes: 14 additions & 6 deletions src/tools/rust-analyzer/crates/hir-def/src/expr_store/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use crate::{
attrs::AttrFlags,
expr_store::path::{GenericArg, GenericArgs},
hir::{
Array, BindingAnnotation, CaptureBy, ClosureKind, Literal, Movability, Statement,
Array, BindingAnnotation, CaptureBy, ClosureKind, Literal, Movability, RecordSpread,
Statement,
generics::{GenericParams, WherePredicate},
},
lang_item::LangItemTarget,
Expand Down Expand Up @@ -139,7 +140,7 @@ pub fn print_variant_body_hir(db: &dyn DefDatabase, owner: VariantId, edition: E
}

for (_, data) in fields.fields().iter() {
let FieldData { name, type_ref, visibility, is_unsafe } = data;
let FieldData { name, type_ref, visibility, is_unsafe, default_value: _ } = data;
match visibility {
crate::item_tree::RawVisibility::Module(interned, _visibility_explicitness) => {
w!(p, "pub(in {})", interned.display(db, p.edition))
Expand Down Expand Up @@ -679,10 +680,17 @@ impl Printer<'_> {
p.print_expr(field.expr);
wln!(p, ",");
}
if let Some(spread) = spread {
w!(p, "..");
p.print_expr(*spread);
wln!(p);
match spread {
RecordSpread::None => {}
RecordSpread::FieldDefaults => {
w!(p, "..");
wln!(p);
}
RecordSpread::Expr(spread_expr) => {
w!(p, "..");
p.print_expr(*spread_expr);
wln!(p);
}
}
});
w!(self, "}}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,3 +659,21 @@ fn main() {
}"#]]
.assert_eq(&body.pretty_print(&db, def, Edition::CURRENT))
}

#[test]
fn async_fn_weird_param_patterns() {
let (db, body, def) = lower(
r#"
async fn main(&self, param1: i32, ref mut param2: i32, _: i32, param4 @ _: i32, 123: i32) {}
"#,
);

expect![[r#"
fn main(self, param1, mut param2, mut <ra@gennew>0, param4 @ _, mut <ra@gennew>1) async {
let ref mut param2 = param2;
let _ = <ra@gennew>0;
let 123 = <ra@gennew>1;
{}
}"#]]
.assert_eq(&body.pretty_print(&db, def, Edition::CURRENT))
}
Loading
Loading