Skip to content

Subtree update of rust-analyzer #126865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 190 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
ada256c
Feat: hide double underscored symbols from symbol search
jkelleyrtp May 22, 2024
69e9d75
Allow searching with prefix
jkelleyrtp May 22, 2024
2feca17
Fix: clippy
jkelleyrtp May 22, 2024
c07530c
Add preference modifier for workspace-local crates when using auto im…
mathew-horner May 29, 2024
88f125e
Add `Function::fn_ptr_type(…)` for obtaining name-erased function type
regexident May 29, 2024
e3d0939
style: simplify string interpolation
hamirmahal May 30, 2024
58cc964
fix: formatting in `handlers/unresolved_method.rs`
hamirmahal May 30, 2024
ee26bcb
Don't mark `#[rustc_deprecated_safe_2024]` functions as unsafe
Noratrieb Jun 2, 2024
5fc5f63
Add `tt_from_syntax`
DropDemBits Mar 5, 2024
becd71f
minor: tidy up `Parse` a little bit
DropDemBits Mar 9, 2024
b9c19c1
Add `ast::Expr::parse`
DropDemBits Mar 9, 2024
9e31705
Make `extract_expressions_from_format_string` only use snippets when …
DropDemBits Mar 5, 2024
0c7d5c6
fix typos & formatting
DropDemBits Jun 2, 2024
a10d710
Add path info to `AbsPathBuf::assert`'s assert
Veykril Jun 2, 2024
1bed783
Auto merge of #17337 - Veykril:assert-info, r=Veykril
bors Jun 2, 2024
fcde6c9
Auto merge of #17333 - DropDemBits:extract-format-args-snippet-cap, r…
bors Jun 3, 2024
fa41f19
Auto merge of #17312 - regexident:function-fn-ptr-type, r=Veykril
bors Jun 3, 2024
af65ff5
Auto merge of #17315 - hamirmahal:style/simplify-string-interpolation…
bors Jun 3, 2024
bdd2bd1
Auto merge of #17329 - Nilstrieb:rustc_deprecated_safe_2024, r=Veykril
bors Jun 3, 2024
b26a06f
Simplify
Veykril Jun 3, 2024
cd265ca
Fix find_path search not reducing scope appropriately for foreign items
Veykril Jun 3, 2024
45a1662
Deduplicate
Veykril Jun 3, 2024
1244fc5
Simplify
Veykril Jun 3, 2024
1eecc18
Remove an allocation in `find_path::find_local_import_locations`
Veykril Jun 3, 2024
59cef9c
Add fuel to `find_path`
Veykril Jun 3, 2024
845754a
Auto merge of #17340 - Veykril:find-path2, r=Veykril
bors Jun 3, 2024
93b87e9
Recognize `__` prefixes for symbol search query
Veykril Jun 4, 2024
33a9021
Auto merge of #17282 - jkelleyrtp:jk/filter-by-underscorte, r=Veykril
bors Jun 4, 2024
211af03
Cleanup some inert attribute stuff
Veykril Jun 4, 2024
59c3a3a
Auto merge of #17341 - Veykril:inert-attr, r=Veykril
bors Jun 4, 2024
9876913
Try caching macro calls more aggressively
Veykril Apr 3, 2024
c5a5c93
Cache `file_to_def` in `SourceToDefCtx`
Veykril Jun 4, 2024
8d5e14d
Cache parse trees in `Semantics`
Veykril Jun 4, 2024
6eab89f
Use dyn cache for Semantics macro resolution
Veykril Jun 4, 2024
4c007c8
Auto merge of #17004 - Veykril:ide-macro-caching, r=Veykril
bors Jun 4, 2024
b885cea
Update package.json
ChosenName Jun 5, 2024
dc10748
Update config.rs
ChosenName Jun 5, 2024
48f1b49
Fix typos
ChosenName Jun 5, 2024
e592d88
fmt
ChosenName Jun 5, 2024
adb7de2
Update config.rs
ChosenName Jun 5, 2024
d47848e
Update dist.rs
ChosenName Jun 5, 2024
728001e
fmt
ChosenName Jun 5, 2024
ca07bf2
fmt
ChosenName Jun 5, 2024
9559894
Add debug info to invalid offset error
Veykril Jun 5, 2024
02c178b
Auto merge of #17347 - Veykril:inv-offset-err, r=Veykril
bors Jun 5, 2024
53b5038
Apply suggested changes
alibektas Apr 18, 2024
ff6e912
Apply requested changes round 2
alibektas Apr 27, 2024
292bb94
Apply requested changes round 3
alibektas Apr 29, 2024
0e207fe
Shuffle around some of the configs between the levels
Veykril May 3, 2024
cf89e9c
Fix local configs allowing to contain global changes
Veykril May 3, 2024
bd5f276
Resolve #17344 by using `.get(…)` instead of `[…]` in `TypeOrConstPar…
regexident Jun 5, 2024
6e7eecc
Auto merge of #17348 - regexident:fix-type-or-const-param-source, r=V…
bors Jun 5, 2024
dfae2a5
Diagnose most incorrect ra-toml config errors
Veykril Jun 5, 2024
003106c
Keep config diagnostics across changes
Veykril Jun 5, 2024
9e31bce
chore: Update Cargo.lock to avoid yanked version
Wilfred Jun 6, 2024
901c01c
fix: Highlight unlinked files consistently with inactive files
Wilfred Jun 6, 2024
3a99bb0
Auto merge of #17349 - Wilfred:update_libc, r=lnicola
bors Jun 6, 2024
b8e94dd
Auto merge of #17350 - Wilfred:mark_missing_file_unused, r=Veykril
bors Jun 6, 2024
56a298b
Auto merge of #17346 - ChosenName:master, r=Veykril
bors Jun 6, 2024
d726854
Fix file loading of r-a toml files
Veykril Jun 6, 2024
6561b71
fix: do not resolve prelude within block modules
roife Jun 6, 2024
07fde07
test: add regression test for prelude shadowing in block modules
roife Jun 6, 2024
49dd2d3
Auto merge of #17352 - roife:fix-issue-17338, r=Veykril
bors Jun 6, 2024
8573eb2
fix: incorrect formatting of hover actions
roife Jun 6, 2024
4739660
Auto merge of #17353 - roife:fix-issue-12728, r=Veykril
bors Jun 6, 2024
22ee477
chore: Prefer tracing span shorthand macros
Wilfred Jun 6, 2024
07034ff
Auto merge of #17356 - Wilfred:span_shorthand, r=lnicola
bors Jun 7, 2024
59002b3
Fix processing of ratoml files
Veykril Jun 7, 2024
1eda1ae
Auto merge of #17308 - mathew-horner:prefer-workspace, r=Veykril
bors Jun 7, 2024
a9f0e20
Auto merge of #17058 - alibektas:13529/ratoml, r=Veykril
bors Jun 7, 2024
ab0917e
fix: Fix renaming imports of foreign items touching foreign sources
Veykril Jun 7, 2024
f711c68
Auto merge of #17360 - Veykril:rename-alias-foreign, r=Veykril
bors Jun 7, 2024
fc92e5c
Add version info to status bar item
Veykril Jun 7, 2024
c501753
Auto merge of #17359 - Veykril:status-bar, r=Veykril
bors Jun 7, 2024
4f67f71
internal: Expose snippet capability to diagnostic quickfixes
DropDemBits Jun 8, 2024
b4891c3
fix: Fix generated markers not being patchable in package.json
Veykril Jun 8, 2024
4f180b6
Auto merge of #17368 - Veykril:dist-fix, r=Veykril
bors Jun 8, 2024
994a9b8
Auto merge of #17365 - DropDemBits:diagnostic-snippet-cap, r=Veykril
bors Jun 8, 2024
f4153f4
internal: better print style for hir
Young-Flash Jun 9, 2024
3243ea0
feat: Compute native diagnostics in parallel
Veykril Jun 9, 2024
02dd227
Allow choosing logical cores for num threads config
Veykril Jun 9, 2024
7053aed
Register virtual workspace Cargo.toml files in the VFS
Veykril Jun 9, 2024
a800a1d
Fix divide by zero
Veykril Jun 9, 2024
6e08590
internal: tweak test case
Young-Flash Jun 9, 2024
b45cf63
minor: use push_str instead
Young-Flash Jun 9, 2024
a65c912
Don't intern attribute inputs as their spans make them unique
Veykril Jun 9, 2024
5a1df7f
Auto merge of #17375 - Veykril:attr-input-no-intern, r=Veykril
bors Jun 9, 2024
0ef2213
Auto merge of #17372 - Veykril:parallel-diagnostics, r=Veykril
bors Jun 10, 2024
0a57742
Thread more HasSource::source calls through Semantics for caching
Veykril Jun 10, 2024
ac9cdbb
Remove extra parse cache from Semantics again
Veykril Jun 10, 2024
8fd1b50
Auto merge of #17380 - Veykril:sema-source, r=Veykril
bors Jun 10, 2024
5aa6137
fix: ensure that the parent of a SourceRoot cannot be itself
roife Jun 10, 2024
c995190
Auto merge of #17381 - roife:fix-issue-17378, r=Veykril
bors Jun 10, 2024
704b56b
Auto merge of #17377 - Young-Flash:hir_print, r=Veykril
bors Jun 11, 2024
34d273b
Simplify some config serialization stuff
Veykril Jun 9, 2024
d181bfd
Auto merge of #17374 - Veykril:configs, r=Veykril
bors Jun 11, 2024
5e3bf0a
Chore(deps-dev): Bump braces from 3.0.2 to 3.0.3 in /editors/code
dependabot[bot] Jun 11, 2024
4cf0490
Auto merge of #17389 - rust-lang:dependabot/npm_and_yarn/editors/code…
bors Jun 11, 2024
25004a1
edit: change 'Length' to 'Len'
randomicon00 Jun 11, 2024
80a2ac5
internal: simplify and refactor write_where_clause
roife Jun 7, 2024
e5f8598
feat: show type bounds from containers for functions
roife Jun 7, 2024
445e886
feat: add hover config for showing container bounds
roife Jun 11, 2024
687889c
internal: simplify and rename display_xxx to write_xxx for consistency
roife Jun 7, 2024
6c122f6
fix: skip container header if no generics params
roife Jun 8, 2024
668327a
refactor: move the logic that displays container type bounds to funct…
roife Jun 11, 2024
ca7e04f
edit: Length to Len in benchmark
randomicon00 Jun 11, 2024
a3ec3b9
Auto merge of #17392 - randomicon00:17242, r=Veykril
bors Jun 11, 2024
21e9022
Auto merge of #17364 - roife:fix-issue-12917, r=Veykril
bors Jun 11, 2024
36caa43
fix: Fix `HirDisplay` stackoverflow for parameter Self defaults
Veykril Jun 11, 2024
5e1ab70
Auto merge of #17394 - Veykril:recurse-fix, r=Veykril
bors Jun 11, 2024
1e9e86c
feature: add build system info; runnables to `rust-project.json`
Wilfred Jun 11, 2024
a97aef8
Auto merge of #16840 - Wilfred:shell_runnable, r=Veykril
bors Jun 11, 2024
c86f3d3
internal: Remove FileId::BOGUS
Veykril Jun 12, 2024
031d37f
Auto merge of #17398 - Veykril:bogus-file, r=Veykril
bors Jun 12, 2024
1a26a1f
internal: Don't unnecessarily clone ModPaths in early name res
Veykril Jun 12, 2024
68fa2a9
Auto merge of #17405 - Veykril:modpath-clone, r=Veykril
bors Jun 12, 2024
4e21a5a
internal: Don't unnecessarily clone ModPaths out of interning wrappers
Veykril Jun 12, 2024
51ea7e8
Auto merge of #17406 - Veykril:modpath-clone, r=Veykril
bors Jun 12, 2024
e728026
hir/semantics: Only allow expansion of specific built in macros
ishanjain28 Jun 12, 2024
a29d99d
fix: add a breaker to avoid infinite loops from source root cycles
davidhewitt Jun 13, 2024
66ec977
Auto merge of #17412 - davidhewitt:source-loop-cycle-bail, r=Veykril
bors Jun 13, 2024
c2843be
fix: avoid doubling cargo args in runnables
davidbarsky Jun 13, 2024
85e87fb
Auto merge of #17407 - davidbarsky:david/fix-17402, r=Veykril
bors Jun 13, 2024
e11ea3c
fix: Only show unlinked-file diagnostic on first line during startup
Wilfred Jun 13, 2024
501cef9
internal: Fix rustdoc warnings
Wilfred Jun 14, 2024
767da82
Prefer plain trait definitions over macros for salsa
Wilfred Jun 13, 2024
8ab0fc3
added tests
ishanjain28 Jun 14, 2024
4d58fc1
fixed tests
ishanjain28 Jun 14, 2024
1623f15
allow format_args! expansion
ishanjain28 Jun 14, 2024
5ca4b3d
Auto merge of #17418 - Wilfred:rustdoc_warnings, r=Veykril
bors Jun 14, 2024
e0c1b2b
Auto merge of #17417 - Wilfred:intern_macros_salsa, r=Veykril
bors Jun 14, 2024
9b61903
Created expand_allowed_builtins, updated expand_macro to call this fu…
ishanjain28 Jun 15, 2024
9ce8a96
fix: handle character boundaries for wide chars in extend_selection
roife Jun 15, 2024
a8ca5d0
feat: add space after specific keywords in completion
roife Jun 16, 2024
5385429
docs: document omission heuristics for parameter inlay hints
Lunaphied Jun 16, 2024
0257394
docs: fix manual generation instructions
Lunaphied Jun 16, 2024
5934eed
feat: add `toggleLSPLogs` command
jjoeldaniel Jun 17, 2024
2fe9b7e
Properly prime all crate def maps in `parallel_prime_caches`
Veykril Jun 17, 2024
ffb00fd
Add some more syntax fixup rules
Veykril Jun 17, 2024
ebb32f5
Fix and cleanup VSCode task building
Veykril Jun 17, 2024
13a4f23
Auto merge of #17440 - Veykril:runnables, r=Veykril
bors Jun 17, 2024
45b1e13
Auto merge of #17439 - Veykril:paralleler-prime-caches, r=Veykril
bors Jun 17, 2024
e06b8aa
Auto merge of #17434 - Lunaphied:fix/document-inlay-parameters, r=Vey…
bors Jun 17, 2024
5d5c298
Auto merge of #17435 - Lunaphied:fix/manual-generation, r=Veykril
bors Jun 17, 2024
d2f975a
fix: Fix pat fragment parsers choking on <eoi>
Veykril Jun 17, 2024
6891225
Auto merge of #17442 - Veykril:pat-eof, r=Veykril
bors Jun 17, 2024
b8a5fc7
Update lib.rs
abdullathedruid Jun 17, 2024
1ad33f9
Auto merge of #17444 - abdullathedruid:patch-1, r=lnicola
bors Jun 18, 2024
d3d840b
Add tactic for associated item constants
kilpkonn May 25, 2024
74c1675
Tidy up vscode extension a bit
Veykril Jun 19, 2024
2ad3132
Auto merge of #17455 - Veykril:vscode-ext, r=Veykril
bors Jun 19, 2024
cf50b29
Auto merge of #17415 - Wilfred:unlinked_diagnostic_span, r=Veykril
bors Jun 19, 2024
cbbdf1e
Auto merge of #17426 - roife:fix-issue-17420, r=Veykril
bors Jun 19, 2024
50ba0c0
Auto merge of #17431 - roife:fix-issue-17428, r=Veykril
bors Jun 19, 2024
17f2596
Auto merge of #17438 - jjoeldaniel:toggle_lsp_logs, r=Veykril
bors Jun 19, 2024
c1fed6a
Auto merge of #17449 - kilpkonn:assoc_const, r=Veykril
bors Jun 19, 2024
33d4ab6
updated tests
ishanjain28 Jun 19, 2024
a2d4e29
removed format_args from allowed expansions
ishanjain28 Jun 19, 2024
79b4dec
remove panicbit.cargo extension warning
panicbit Jun 19, 2024
b4952b2
fix(completion): complete async keyword
MariaSolOs Jun 19, 2024
e95043c
Auto merge of #17459 - MariaSolOs:async-compl, r=Veykril
bors Jun 19, 2024
35d0bcd
Preparing for merge from rust-lang/rust
lnicola Jun 20, 2024
9d2bb7f
Merge from rust-lang/rust
lnicola Jun 20, 2024
185971c
fix: ensure there are no cycles in the source_root_parent_map
roife Jun 19, 2024
f18fe6c
Auto merge of #17460 - lnicola:sync-from-rust, r=lnicola
bors Jun 20, 2024
153a2ba
Auto merge of #17457 - roife:remove-circle, r=Veykril
bors Jun 20, 2024
2f4e555
fix: Fix flycheck panicking when cancelled
Veykril Jun 20, 2024
a17efb9
Auto merge of #17456 - panicbit:remove-cargo-extension-warning, r=Vey…
bors Jun 20, 2024
e5d5c7b
Invert matching on builtin macros in expand_allowed_builtins
Veykril Jun 20, 2024
e871775
Auto merge of #17419 - ishanjain28:filter_builtin_macro_expansion, r=…
bors Jun 20, 2024
1d0d439
Auto merge of #17461 - Veykril:drop-flycheck-recv, r=Veykril
bors Jun 20, 2024
16a28ca
fix: Fix IDE features breaking in some attr macros
Veykril Jun 20, 2024
48b6f28
Auto merge of #17462 - Veykril:sema-attr-macro-res, r=Veykril
bors Jun 20, 2024
edd66a7
Check that Expr is none before adding fixup
wyatt-herkamp Jun 20, 2024
9b8b6f9
Auto merge of #17464 - wyatt-herkamp:fix-actix-macro, r=lnicola
bors Jun 20, 2024
7b50a5f
Extract generics module
Veykril Jun 21, 2024
51b138c
fix: use ItemInNs::Macros to convert ModuleItem to ItemInNs
roife Jun 21, 2024
c133c64
Light docs and privacy
Veykril Jun 21, 2024
3a66230
There can only be one self param
Veykril Jun 21, 2024
3b97b75
Simplify
Veykril Jun 21, 2024
873dcf4
Lazy generics
Veykril Jun 21, 2024
5cbaa3f
Save allocations for empty generic_predicates query results
Veykril Jun 21, 2024
2893153
Don't attempt to compute implict sized clauses for empty generics
Veykril Jun 21, 2024
36c3731
Auto merge of #17473 - Veykril:generics, r=Veykril
bors Jun 21, 2024
54f3f56
Save allocations for empty generic_defaults query results
Veykril Jun 21, 2024
6195749
Prevent re-allocation in `CallableSig::from_params_and_return`
Veykril Jun 21, 2024
398e3a3
Auto merge of #17474 - Veykril:ty-perf-stuff, r=Veykril
bors Jun 21, 2024
9b33872
Auto merge of #17469 - roife:fix-issue-17425, r=Veykril
bors Jun 21, 2024
0744b36
Remove Changelog: XXX title from Github release notes
lnicola Jun 22, 2024
70e9582
Auto merge of #17475 - lnicola:changelog-title, r=lnicola
bors Jun 22, 2024
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
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tq = "test -- -q"
qt = "tq"
lint = "clippy --all-targets -- --cap-lints warn"
codegen = "run --package xtask --bin xtask -- codegen"
dist = "run --package xtask --bin xtask -- dist"

[target.x86_64-pc-windows-msvc]
linker = "rust-lld"
Expand Down
15 changes: 13 additions & 2 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,15 @@ dependencies = [
"dirs-sys",
]

[[package]]
name = "dirs"
version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
dependencies = [
"dirs-sys",
]

[[package]]
name = "dirs-sys"
version = "0.4.1"
Expand Down Expand Up @@ -503,6 +512,7 @@ dependencies = [
"hir-def",
"hir-expand",
"hir-ty",
"intern",
"itertools",
"once_cell",
"rustc-hash",
Expand Down Expand Up @@ -891,9 +901,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"

[[package]]
name = "libc"
version = "0.2.154"
version = "0.2.155"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"

[[package]]
name = "libloading"
Expand Down Expand Up @@ -1665,6 +1675,7 @@ dependencies = [
"anyhow",
"cfg",
"crossbeam-channel",
"dirs",
"dissimilar",
"expect-test",
"flycheck",
Expand Down
6 changes: 5 additions & 1 deletion src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ xshell = "0.2.5"
dashmap = { version = "=5.5.3", features = ["raw-api"] }

[workspace.lints.rust]
rust_2018_idioms = "warn"
bare_trait_objects = "warn"
elided_lifetimes_in_paths = "warn"
ellipsis_inclusive_range_patterns = "warn"
explicit_outlives_requirements = "warn"
unused_extern_crates = "warn"
unused_lifetimes = "warn"
unreachable_pub = "warn"
semicolon_in_expressions_from_macros = "warn"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/base-db/src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl FileChange {
}

pub fn apply(self, db: &mut dyn SourceDatabaseExt) {
let _p = tracing::span!(tracing::Level::INFO, "FileChange::apply").entered();
let _p = tracing::info_span!("FileChange::apply").entered();
if let Some(roots) = self.roots {
for (idx, root) in roots.into_iter().enumerate() {
let root_id = SourceRootId(idx as u32);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl CrateGraph {
from: CrateId,
dep: Dependency,
) -> Result<(), CyclicDependenciesError> {
let _p = tracing::span!(tracing::Level::INFO, "add_dep").entered();
let _p = tracing::info_span!("add_dep").entered();

self.check_cycle_after_dependency(from, dep.crate_id)?;

Expand Down
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn toolchain_channel(db: &dyn SourceDatabase, krate: CrateId) -> Option<ReleaseC
}

fn parse(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
let _p = tracing::span!(tracing::Level::INFO, "parse", ?file_id).entered();
let _p = tracing::info_span!("parse", ?file_id).entered();
let text = db.file_text(file_id);
// FIXME: Edition based parsing
SourceFile::parse(&text, span::Edition::CURRENT)
Expand Down Expand Up @@ -187,7 +187,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
}

fn relevant_crates(&self, file_id: FileId) -> Arc<[CrateId]> {
let _p = tracing::span!(tracing::Level::INFO, "relevant_crates").entered();
let _p = tracing::info_span!("relevant_crates").entered();
let source_root = self.0.file_source_root(file_id);
self.0.source_root_crates(source_root)
}
Expand Down
8 changes: 4 additions & 4 deletions src/tools/rust-analyzer/crates/flycheck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl FlycheckActor {
Some(c) => c,
None => continue,
};
let formatted_command = format!("{:?}", command);
let formatted_command = format!("{command:?}");

tracing::debug!(?command, "will restart flycheck");
let (sender, receiver) = unbounded();
Expand All @@ -318,8 +318,7 @@ impl FlycheckActor {
}
Err(error) => {
self.report_progress(Progress::DidFailToRestart(format!(
"Failed to run the following command: {} error={}",
formatted_command, error
"Failed to run the following command: {formatted_command} error={error}"
)));
self.status = FlycheckStatus::Finished;
}
Expand All @@ -331,7 +330,7 @@ impl FlycheckActor {
// Watcher finished
let command_handle = self.command_handle.take().unwrap();
self.command_receiver.take();
let formatted_handle = format!("{:?}", command_handle);
let formatted_handle = format!("{command_handle:?}");

let res = command_handle.join();
if let Err(error) = &res {
Expand Down Expand Up @@ -387,6 +386,7 @@ impl FlycheckActor {
"did cancel flycheck"
);
command_handle.cancel();
self.command_receiver.take();
self.report_progress(Progress::DidCancel);
self.status = FlycheckStatus::Finished;
}
Expand Down
61 changes: 54 additions & 7 deletions src/tools/rust-analyzer/crates/hir-def/src/attr.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
//! A higher level attributes based on TokenTree, with also some shortcuts.

pub mod builtin;

#[cfg(test)]
mod tests;

use std::{borrow::Cow, hash::Hash, ops, slice::Iter as SliceIter};

use base_db::CrateId;
Expand Down Expand Up @@ -75,7 +70,7 @@ impl Attrs {
db: &dyn DefDatabase,
v: VariantId,
) -> Arc<ArenaMap<LocalFieldId, Attrs>> {
let _p = tracing::span!(tracing::Level::INFO, "fields_attrs_query").entered();
let _p = tracing::info_span!("fields_attrs_query").entered();
// FIXME: There should be some proper form of mapping between item tree field ids and hir field ids
let mut res = ArenaMap::default();

Expand Down Expand Up @@ -326,7 +321,7 @@ impl AttrsWithOwner {
}

pub(crate) fn attrs_query(db: &dyn DefDatabase, def: AttrDefId) -> Attrs {
let _p = tracing::span!(tracing::Level::INFO, "attrs_query").entered();
let _p = tracing::info_span!("attrs_query").entered();
// FIXME: this should use `Trace` to avoid duplication in `source_map` below
let raw_attrs = match def {
AttrDefId::ModuleId(module) => {
Expand Down Expand Up @@ -646,3 +641,55 @@ pub(crate) fn fields_attrs_source_map(

Arc::new(res)
}

#[cfg(test)]
mod tests {
//! This module contains tests for doc-expression parsing.
//! Currently, it tests `#[doc(hidden)]` and `#[doc(alias)]`.

use triomphe::Arc;

use base_db::FileId;
use hir_expand::span_map::{RealSpanMap, SpanMap};
use mbe::{syntax_node_to_token_tree, DocCommentDesugarMode};
use syntax::{ast, AstNode, TextRange};

use crate::attr::{DocAtom, DocExpr};

fn assert_parse_result(input: &str, expected: DocExpr) {
let source_file = ast::SourceFile::parse(input, span::Edition::CURRENT).ok().unwrap();
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
let map = SpanMap::RealSpanMap(Arc::new(RealSpanMap::absolute(FileId::from_raw(0))));
let tt = syntax_node_to_token_tree(
tt.syntax(),
map.as_ref(),
map.span_for_range(TextRange::empty(0.into())),
DocCommentDesugarMode::ProcMacro,
);
let cfg = DocExpr::parse(&tt);
assert_eq!(cfg, expected);
}

#[test]
fn test_doc_expr_parser() {
assert_parse_result("#![doc(hidden)]", DocAtom::Flag("hidden".into()).into());

assert_parse_result(
r#"#![doc(alias = "foo")]"#,
DocAtom::KeyValue { key: "alias".into(), value: "foo".into() }.into(),
);

assert_parse_result(r#"#![doc(alias("foo"))]"#, DocExpr::Alias(["foo".into()].into()));
assert_parse_result(
r#"#![doc(alias("foo", "bar", "baz"))]"#,
DocExpr::Alias(["foo".into(), "bar".into(), "baz".into()].into()),
);

assert_parse_result(
r#"
#[doc(alias("Bar", "Qux"))]
struct Foo;"#,
DocExpr::Alias(["Bar".into(), "Qux".into()].into()),
);
}
}
48 changes: 0 additions & 48 deletions src/tools/rust-analyzer/crates/hir-def/src/attr/tests.rs

This file was deleted.

8 changes: 7 additions & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Body {
db: &dyn DefDatabase,
def: DefWithBodyId,
) -> (Arc<Body>, Arc<BodySourceMap>) {
let _p = tracing::span!(tracing::Level::INFO, "body_with_source_map_query").entered();
let _p = tracing::info_span!("body_with_source_map_query").entered();
let mut params = None;

let mut is_async_fn = false;
Expand Down Expand Up @@ -395,6 +395,12 @@ impl BodySourceMap {
self.expr_map.get(&src).copied()
}

pub fn expansions(
&self,
) -> impl Iterator<Item = (&InFile<AstPtr<ast::MacroCall>>, &MacroFileId)> {
self.expansions.iter()
}

pub fn implicit_format_args(
&self,
node: InFile<&ast::FormatArgsExpr>,
Expand Down
12 changes: 7 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use intern::Interned;
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use span::AstIdMap;
use stdx::never;
use syntax::{
ast::{
self, ArrayExprKind, AstChildren, BlockExpr, HasArgList, HasAttrs, HasLoopBody, HasName,
Expand Down Expand Up @@ -480,7 +481,8 @@ impl ExprCollector<'_> {
} else if e.const_token().is_some() {
Mutability::Shared
} else {
unreachable!("parser only remaps to raw_token() if matching mutability token follows")
never!("parser only remaps to raw_token() if matching mutability token follows");
Mutability::Shared
}
} else {
Mutability::from_mutable(e.mut_token().is_some())
Expand Down Expand Up @@ -963,7 +965,7 @@ impl ExprCollector<'_> {
.resolve_path(
self.db,
module,
&path,
path,
crate::item_scope::BuiltinShadowMode::Other,
Some(MacroSubNs::Bang),
)
Expand Down Expand Up @@ -1006,9 +1008,9 @@ impl ExprCollector<'_> {
Some((mark, expansion)) => {
// Keep collecting even with expansion errors so we can provide completions and
// other services in incomplete macro expressions.
self.source_map
.expansions
.insert(macro_call_ptr, self.expander.current_file_id().macro_file().unwrap());
if let Some(macro_file) = self.expander.current_file_id().macro_file() {
self.source_map.expansions.insert(macro_call_ptr, macro_file);
}
let prev_ast_id_map = mem::replace(
&mut self.ast_id_map,
self.db.ast_id_map(self.expander.current_file_id()),
Expand Down
17 changes: 13 additions & 4 deletions src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,30 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo
let mut p = Printer { db, body, buf: header, indent_level: 0, needs_indent: false };
if let DefWithBodyId::FunctionId(it) = owner {
p.buf.push('(');
let params = &db.function_data(it).params;
let mut params = params.iter();
let function_data = &db.function_data(it);
let (mut params, ret_type) = (function_data.params.iter(), &function_data.ret_type);
if let Some(self_param) = body.self_param {
p.print_binding(self_param);
p.buf.push(':');
p.buf.push_str(": ");
if let Some(ty) = params.next() {
p.print_type_ref(ty);
p.buf.push_str(", ");
}
}
body.params.iter().zip(params).for_each(|(&param, ty)| {
p.print_pat(param);
p.buf.push(':');
p.buf.push_str(": ");
p.print_type_ref(ty);
p.buf.push_str(", ");
});
// remove the last ", " in param list
if body.params.len() > 0 {
p.buf.truncate(p.buf.len() - 2);
}
p.buf.push(')');
// return type
p.buf.push_str(" -> ");
p.print_type_ref(ret_type);
p.buf.push(' ');
}
p.print_expr(body.body_expr);
Expand Down
Loading
Loading