Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 8a73540

Browse files
committed
Auto merge of #1264 - h-michael:pub-crate, r=alexheretic
Remove crate_visibility_modifier feature related with #1248
2 parents e1e6ab5 + a235a21 commit 8a73540

File tree

8 files changed

+55
-56
lines changed

8 files changed

+55
-56
lines changed

src/build/cargo_plan.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@ use crate::build::PackageArg;
4343
/// Main key type by which `Unit`s will be distinguished in the build plan.
4444
/// In Target we're mostly interested in TargetKind (Lib, Bin, ...) and name
4545
/// (e.g. we can have 2 binary targets with different names).
46-
crate type UnitKey = (PackageId, Target, CompileMode);
46+
pub(crate) type UnitKey = (PackageId, Target, CompileMode);
4747

4848
/// Holds the information how exactly the build will be performed for a given
4949
/// workspace with given, specified features.
5050
#[derive(Debug, Default)]
51-
crate struct CargoPlan {
51+
pub(crate) struct CargoPlan {
5252
/// Stores a full Cargo `Unit` data for a first processed unit with a given key.
53-
crate units: HashMap<UnitKey, OwnedUnit>,
53+
pub(crate) units: HashMap<UnitKey, OwnedUnit>,
5454
/// Main dependency graph between the simplified units.
55-
crate dep_graph: HashMap<UnitKey, HashSet<UnitKey>>,
55+
pub(crate) dep_graph: HashMap<UnitKey, HashSet<UnitKey>>,
5656
/// Reverse dependency graph that's used to construct a dirty compiler call queue.
57-
crate rev_dep_graph: HashMap<UnitKey, HashSet<UnitKey>>,
57+
pub(crate) rev_dep_graph: HashMap<UnitKey, HashSet<UnitKey>>,
5858
/// Cached compiler calls used when creating a compiler call queue.
59-
crate compiler_jobs: HashMap<UnitKey, ProcessBuilder>,
59+
pub(crate) compiler_jobs: HashMap<UnitKey, ProcessBuilder>,
6060
/// Calculated input files that unit depend on.
61-
crate input_files: HashMap<UnitKey, Vec<PathBuf>>,
62-
crate file_key_mapping: HashMap<PathBuf, HashSet<UnitKey>>,
61+
pub(crate) input_files: HashMap<UnitKey, Vec<PathBuf>>,
62+
pub(crate) file_key_mapping: HashMap<PathBuf, HashSet<UnitKey>>,
6363
// An object for finding the package which a file belongs to and this inferring
6464
// a package argument.
6565
package_map: Option<PackageMap>,
@@ -69,14 +69,14 @@ crate struct CargoPlan {
6969
}
7070

7171
impl CargoPlan {
72-
crate fn with_manifest(manifest_path: &Path) -> CargoPlan {
72+
pub(crate) fn with_manifest(manifest_path: &Path) -> CargoPlan {
7373
CargoPlan {
7474
package_map: Some(PackageMap::new(manifest_path)),
7575
..Default::default()
7676
}
7777
}
7878

79-
crate fn with_packages(manifest_path: &Path, pkgs: HashSet<String>) -> CargoPlan {
79+
pub(crate) fn with_packages(manifest_path: &Path, pkgs: HashSet<String>) -> CargoPlan {
8080
CargoPlan {
8181
built_packages: pkgs,
8282
..Self::with_manifest(manifest_path)
@@ -85,14 +85,14 @@ impl CargoPlan {
8585

8686
/// Returns whether a build plan has cached compiler invocations and dep
8787
/// graph so it's at all able to return a job queue via `prepare_work`.
88-
crate fn is_ready(&self) -> bool {
88+
pub(crate) fn is_ready(&self) -> bool {
8989
!self.compiler_jobs.is_empty()
9090
}
9191

9292
/// Cache a given compiler invocation in `ProcessBuilder` for a given
9393
/// `PackageId` and `TargetKind` in `Target`, to be used when processing
9494
/// cached build plan.
95-
crate fn cache_compiler_job(
95+
pub(crate) fn cache_compiler_job(
9696
&mut self,
9797
id: PackageId,
9898
target: &Target,
@@ -103,7 +103,7 @@ impl CargoPlan {
103103
self.compiler_jobs.insert(unit_key, cmd.clone());
104104
}
105105

106-
crate fn cache_input_files(
106+
pub(crate) fn cache_input_files(
107107
&mut self,
108108
id: PackageId,
109109
target: &Target,
@@ -140,7 +140,7 @@ impl CargoPlan {
140140
/// Emplace a given `Unit`, along with its `Unit` dependencies (recursively)
141141
/// into the dependency graph as long as the passed `Unit` isn't filtered
142142
/// out by the `filter` closure.
143-
crate fn emplace_dep_with_filter<Filter>(
143+
pub(crate) fn emplace_dep_with_filter<Filter>(
144144
&mut self,
145145
unit: &Unit<'_>,
146146
cx: &Context<'_, '_>,
@@ -349,7 +349,7 @@ impl CargoPlan {
349349
}
350350
}
351351

352-
crate fn prepare_work<T: AsRef<Path> + fmt::Debug>(
352+
pub(crate) fn prepare_work<T: AsRef<Path> + fmt::Debug>(
353353
&self,
354354
modified: &[T],
355355
) -> WorkStatus {
@@ -517,12 +517,12 @@ fn key_from_unit(unit: &Unit<'_>) -> UnitKey {
517517

518518
#[derive(Hash, PartialEq, Eq, Debug, Clone)]
519519
/// An owned version of `cargo::core::Unit`.
520-
crate struct OwnedUnit {
521-
crate id: PackageId,
522-
crate target: Target,
523-
crate profile: Profile,
524-
crate kind: Kind,
525-
crate mode: CompileMode,
520+
pub(crate) struct OwnedUnit {
521+
pub(crate) id: PackageId,
522+
pub(crate) target: Target,
523+
pub(crate) profile: Profile,
524+
pub(crate) kind: Kind,
525+
pub(crate) mode: CompileMode,
526526
}
527527

528528
impl<'a> From<Unit<'a>> for OwnedUnit {

src/build/external.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,25 +171,25 @@ fn plan_from_analysis(analysis: &[Analysis], build_dir: &Path) -> Result<Externa
171171

172172
#[derive(Debug, Deserialize)]
173173
/// Build plan as emitted by `cargo build --build-plan -Zunstable-options`
174-
crate struct RawPlan {
175-
crate invocations: Vec<RawInvocation>,
174+
pub(crate) struct RawPlan {
175+
pub(crate) invocations: Vec<RawInvocation>,
176176
}
177177

178178
#[derive(Debug, Deserialize)]
179-
crate struct RawInvocation {
180-
crate deps: Vec<usize>,
181-
crate outputs: Vec<PathBuf>,
179+
pub(crate) struct RawInvocation {
180+
pub(crate) deps: Vec<usize>,
181+
pub(crate) outputs: Vec<PathBuf>,
182182
#[serde(default)]
183-
crate links: BTreeMap<PathBuf, PathBuf>,
184-
crate program: String,
185-
crate args: Vec<String>,
186-
crate env: BTreeMap<String, String>,
183+
pub(crate) links: BTreeMap<PathBuf, PathBuf>,
184+
pub(crate) program: String,
185+
pub(crate) args: Vec<String>,
186+
pub(crate) env: BTreeMap<String, String>,
187187
#[serde(default)]
188-
crate cwd: Option<PathBuf>,
188+
pub(crate) cwd: Option<PathBuf>,
189189
}
190190

191191
#[derive(Clone, Debug)]
192-
crate struct Invocation {
192+
pub(crate) struct Invocation {
193193
deps: Vec<usize>, // FIXME: Use arena and store refs instead for ergonomics
194194
outputs: Vec<PathBuf>,
195195
links: BTreeMap<PathBuf, PathBuf>,
@@ -201,7 +201,7 @@ crate struct Invocation {
201201
/// Safe build plan type, invocation dependencies are guaranteed to be inside
202202
/// the plan.
203203
#[derive(Debug, Default)]
204-
crate struct ExternalPlan {
204+
pub(crate) struct ExternalPlan {
205205
units: HashMap<u64, Invocation>,
206206
deps: HashMap<u64, HashSet<u64>>,
207207
rev_deps: HashMap<u64, HashSet<u64>>,
@@ -248,11 +248,11 @@ impl Invocation {
248248
}
249249

250250
impl ExternalPlan {
251-
crate fn new() -> ExternalPlan {
251+
pub(crate) fn new() -> ExternalPlan {
252252
Default::default()
253253
}
254254

255-
crate fn with_units(units: Vec<Invocation>) -> ExternalPlan {
255+
pub(crate) fn with_units(units: Vec<Invocation>) -> ExternalPlan {
256256
let mut plan = ExternalPlan::new();
257257
for unit in &units {
258258
for &dep in &unit.deps {
@@ -272,7 +272,7 @@ impl ExternalPlan {
272272
self.rev_deps.entry(dep).or_insert_with(HashSet::new).insert(key);
273273
}
274274

275-
crate fn try_from_raw(build_dir: &Path, raw: RawPlan) -> Result<ExternalPlan, ()> {
275+
pub(crate) fn try_from_raw(build_dir: &Path, raw: RawPlan) -> Result<ExternalPlan, ()> {
276276
// Sanity check, each dependency (index) has to be inside the build plan
277277
if raw
278278
.invocations

src/build/plan.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ use crate::build::{BuildResult, Internals, PackageArg};
2020
use crate::build::cargo_plan::CargoPlan;
2121
use crate::build::external::ExternalPlan;
2222

23-
crate trait BuildKey {
23+
pub(crate) trait BuildKey {
2424
type Key: Eq + Hash;
2525
fn key(&self) -> Self::Key;
2626
}
2727

28-
crate trait BuildGraph {
28+
pub(crate) trait BuildGraph {
2929
type Unit: BuildKey;
3030

3131
fn units(&self) -> Vec<&Self::Unit>;
@@ -48,14 +48,14 @@ crate trait BuildGraph {
4848
}
4949

5050
#[derive(Debug)]
51-
crate enum WorkStatus {
51+
pub(crate) enum WorkStatus {
5252
NeedsCargo(PackageArg),
5353
Execute(JobQueue),
5454
}
5555

5656
#[allow(clippy::large_enum_variant)]
5757
#[derive(Debug)]
58-
crate enum BuildPlan {
58+
pub(crate) enum BuildPlan {
5959
External(ExternalPlan),
6060
Cargo(CargoPlan)
6161
}
@@ -74,7 +74,7 @@ impl BuildPlan {
7474
}
7575

7676
#[derive(Debug)]
77-
crate struct JobQueue(Vec<ProcessBuilder>);
77+
pub(crate) struct JobQueue(Vec<ProcessBuilder>);
7878

7979
/// Returns an immediately next argument to the one specified in a given
8080
/// ProcessBuilder (or `None` if the searched or the next argument could not be found).
@@ -93,11 +93,11 @@ fn proc_argument_value<T: AsRef<OsStr>>(prc: &ProcessBuilder, key: T) -> Option<
9393
}
9494

9595
impl JobQueue {
96-
crate fn with_commands(jobs: Vec<ProcessBuilder>) -> JobQueue {
96+
pub(crate) fn with_commands(jobs: Vec<ProcessBuilder>) -> JobQueue {
9797
JobQueue(jobs)
9898
}
9999

100-
crate fn dequeue(&mut self) -> Option<ProcessBuilder> {
100+
pub(crate) fn dequeue(&mut self) -> Option<ProcessBuilder> {
101101
self.0.pop()
102102
}
103103

src/build/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use std::sync::{Arc, Mutex};
5959
use std::process::Command;
6060

6161
// Runs a single instance of rustc. Runs in-process.
62-
crate fn rustc(
62+
pub(crate) fn rustc(
6363
vfs: &Vfs,
6464
args: &[String],
6565
envs: &HashMap<String, Option<OsString>>,

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//! code completion, and enables renaming and refactorings.
77
88
#![feature(rustc_private, integer_atomics, drain_filter)]
9-
#![feature(crate_visibility_modifier)] // needed for edition 2018
109
#![allow(unknown_lints)]
1110
#![warn(clippy::all, rust_2018_idioms)]
1211
#![allow(

src/server/dispatch.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_millis(3_600_000);
3737
macro_rules! define_dispatch_request_enum {
3838
($($request_type:ident),*$(,)*) => {
3939
#[allow(clippy::large_enum_variant)] // seems ok for a short lived macro-enum
40-
crate enum DispatchRequest {
40+
pub(crate) enum DispatchRequest {
4141
$(
4242
$request_type(Request<$request_type>),
4343
)*
@@ -112,13 +112,13 @@ define_dispatch_request_enum!(
112112
/// handle the requests sequentially, without blocking stdin.
113113
/// Requests dispatched this way are automatically timed out & avoid
114114
/// processing if have already timed out before starting.
115-
crate struct Dispatcher {
115+
pub(crate) struct Dispatcher {
116116
sender: mpsc::Sender<(DispatchRequest, InitActionContext, JobToken)>,
117117
}
118118

119119
impl Dispatcher {
120120
/// Creates a new `Dispatcher` starting a new thread and channel
121-
crate fn new<O: Output>(out: O) -> Self {
121+
pub(crate) fn new<O: Output>(out: O) -> Self {
122122
let (sender, receiver) = mpsc::channel::<(DispatchRequest, InitActionContext, JobToken)>();
123123

124124
thread::Builder::new()
@@ -134,7 +134,7 @@ impl Dispatcher {
134134
}
135135

136136
/// Sends a request to the dispatch-worker thread, does not block
137-
crate fn dispatch<R: Into<DispatchRequest>>(&mut self, request: R, ctx: InitActionContext) {
137+
pub(crate) fn dispatch<R: Into<DispatchRequest>>(&mut self, request: R, ctx: InitActionContext) {
138138
let (job, token) = ConcurrentJob::new();
139139
ctx.add_job(job);
140140
if let Err(err) = self.sender.send((request.into(), ctx, token)) {

src/server/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pub(super) struct StdioOutput {
195195

196196
impl StdioOutput {
197197
/// Construct a new `stdout` output.
198-
crate fn new() -> StdioOutput {
198+
pub(crate) fn new() -> StdioOutput {
199199
StdioOutput {
200200
next_id: Arc::new(AtomicU64::new(1)),
201201
}

src/server/message.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,13 @@ where
293293

294294
#[derive(Debug, PartialEq)]
295295
pub(super) struct RawMessage {
296-
crate method: String,
297-
crate id: Id,
298-
crate params: serde_json::Value,
296+
pub(crate) method: String,
297+
pub(crate) id: Id,
298+
pub(crate) params: serde_json::Value,
299299
}
300300

301301
impl RawMessage {
302-
crate fn parse_as_request<'de, R>(&'de self) -> Result<Request<R>, jsonrpc::Error>
302+
pub(crate) fn parse_as_request<'de, R>(&'de self) -> Result<Request<R>, jsonrpc::Error>
303303
where
304304
R: LSPRequest,
305305
<R as LSPRequest>::Params: serde::Deserialize<'de>,
@@ -334,7 +334,7 @@ impl RawMessage {
334334
}
335335
}
336336

337-
crate fn parse_as_notification<'de, T>(&'de self) -> Result<Notification<T>, jsonrpc::Error>
337+
pub(crate) fn parse_as_notification<'de, T>(&'de self) -> Result<Notification<T>, jsonrpc::Error>
338338
where
339339
T: LSPNotification,
340340
<T as LSPNotification>::Params: serde::Deserialize<'de>,
@@ -350,7 +350,7 @@ impl RawMessage {
350350
})
351351
}
352352

353-
crate fn try_parse(msg: &str) -> Result<Option<RawMessage>, jsonrpc::Error> {
353+
pub(crate) fn try_parse(msg: &str) -> Result<Option<RawMessage>, jsonrpc::Error> {
354354
// Parse the message.
355355
let ls_command: serde_json::Value =
356356
serde_json::from_str(msg).map_err(|_| jsonrpc::Error::parse_error())?;

0 commit comments

Comments
 (0)