Skip to content

Commit 138849a

Browse files
Merge #9751
9751: Make `LoadCargoConfig`, `fn load_workspace_at` & `fn load_workspace` public again r=matklad a=regexident This [commit](b24f816) which restricted the visibility of `LoadCargoConfig`, `fn load_workspace_at` & `fn load_workspace` unfortunately effectively rendered every crate/tool that uses rust-analyzer as a library dead in the water. On of such tools is [cargo-modules](https://github.com/regexident/cargo-modules), a tool for generating tree/graph visualizations of one's Rust project and is powered by rust-analyzer as a library. For more context see the PRs that introduced those types/functions and made them `pub`: - #7595 - #7690 If kept as is rust-analyzer would effectively no longer be usable as a library. cc `@SomeoneToIgnore` Co-authored-by: Vincent Esche <regexident@gmail.com>
2 parents 49e9e21 + fee3507 commit 138849a

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

crates/rust-analyzer/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Various batch processing tasks, intended primarily for debugging.
22
3-
pub(crate) mod load_cargo;
3+
pub mod load_cargo;
44
mod analysis_stats;
55
mod diagnostics;
66
mod progress_report;

crates/rust-analyzer/src/cli/load_cargo.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ use vfs::{loader::Handle, AbsPath, AbsPathBuf};
1414

1515
use crate::reload::{ProjectFolders, SourceRootConfig};
1616

17-
pub(crate) struct LoadCargoConfig {
18-
pub(crate) load_out_dirs_from_check: bool,
19-
pub(crate) with_proc_macro: bool,
20-
pub(crate) prefill_caches: bool,
17+
// Note: Since this type is used by external tools that use rust-analyzer as a library
18+
// what otherwise would be `pub(crate)` has to be `pub` here instead.
19+
pub struct LoadCargoConfig {
20+
pub load_out_dirs_from_check: bool,
21+
pub with_proc_macro: bool,
22+
pub prefill_caches: bool,
2123
}
2224

23-
pub(crate) fn load_workspace_at(
25+
// Note: Since this function is used by external tools that use rust-analyzer as a library
26+
// what otherwise would be `pub(crate)` has to be `pub` here instead.
27+
pub fn load_workspace_at(
2428
root: &Path,
2529
cargo_config: &CargoConfig,
2630
load_config: &LoadCargoConfig,
@@ -33,7 +37,12 @@ pub(crate) fn load_workspace_at(
3337
load_workspace(workspace, cargo_config, load_config, progress)
3438
}
3539

36-
fn load_workspace(
40+
// Note: Since this function is used by external tools that use rust-analyzer as a library
41+
// what otherwise would be `pub(crate)` has to be `pub` here instead.
42+
//
43+
// The reason both, `load_workspace_at` and `load_workspace` are `pub` is that some of
44+
// these tools need access to `ProjectWorkspace`, too, which `load_workspace_at` hides.
45+
pub fn load_workspace(
3746
mut ws: ProjectWorkspace,
3847
cargo_config: &CargoConfig,
3948
load_config: &LoadCargoConfig,

0 commit comments

Comments
 (0)