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

Remove crate_visibility_modifier feature #1264

Merged
merged 2 commits into from
Jan 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 21 additions & 21 deletions src/build/cargo_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ use crate::build::PackageArg;
/// Main key type by which `Unit`s will be distinguished in the build plan.
/// In Target we're mostly interested in TargetKind (Lib, Bin, ...) and name
/// (e.g. we can have 2 binary targets with different names).
crate type UnitKey = (PackageId, Target, CompileMode);
pub(crate) type UnitKey = (PackageId, Target, CompileMode);

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

impl CargoPlan {
crate fn with_manifest(manifest_path: &Path) -> CargoPlan {
pub(crate) fn with_manifest(manifest_path: &Path) -> CargoPlan {
CargoPlan {
package_map: Some(PackageMap::new(manifest_path)),
..Default::default()
}
}

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

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

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

crate fn cache_input_files(
pub(crate) fn cache_input_files(
&mut self,
id: PackageId,
target: &Target,
Expand Down Expand Up @@ -140,7 +140,7 @@ impl CargoPlan {
/// Emplace a given `Unit`, along with its `Unit` dependencies (recursively)
/// into the dependency graph as long as the passed `Unit` isn't filtered
/// out by the `filter` closure.
crate fn emplace_dep_with_filter<Filter>(
pub(crate) fn emplace_dep_with_filter<Filter>(
&mut self,
unit: &Unit<'_>,
cx: &Context<'_, '_>,
Expand Down Expand Up @@ -349,7 +349,7 @@ impl CargoPlan {
}
}

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

#[derive(Hash, PartialEq, Eq, Debug, Clone)]
/// An owned version of `cargo::core::Unit`.
crate struct OwnedUnit {
crate id: PackageId,
crate target: Target,
crate profile: Profile,
crate kind: Kind,
crate mode: CompileMode,
pub(crate) struct OwnedUnit {
pub(crate) id: PackageId,
pub(crate) target: Target,
pub(crate) profile: Profile,
pub(crate) kind: Kind,
pub(crate) mode: CompileMode,
}

impl<'a> From<Unit<'a>> for OwnedUnit {
Expand Down
30 changes: 15 additions & 15 deletions src/build/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,25 +171,25 @@ fn plan_from_analysis(analysis: &[Analysis], build_dir: &Path) -> Result<Externa

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

#[derive(Debug, Deserialize)]
crate struct RawInvocation {
crate deps: Vec<usize>,
crate outputs: Vec<PathBuf>,
pub(crate) struct RawInvocation {
pub(crate) deps: Vec<usize>,
pub(crate) outputs: Vec<PathBuf>,
#[serde(default)]
crate links: BTreeMap<PathBuf, PathBuf>,
crate program: String,
crate args: Vec<String>,
crate env: BTreeMap<String, String>,
pub(crate) links: BTreeMap<PathBuf, PathBuf>,
pub(crate) program: String,
pub(crate) args: Vec<String>,
pub(crate) env: BTreeMap<String, String>,
#[serde(default)]
crate cwd: Option<PathBuf>,
pub(crate) cwd: Option<PathBuf>,
}

#[derive(Clone, Debug)]
crate struct Invocation {
pub(crate) struct Invocation {
deps: Vec<usize>, // FIXME: Use arena and store refs instead for ergonomics
outputs: Vec<PathBuf>,
links: BTreeMap<PathBuf, PathBuf>,
Expand All @@ -201,7 +201,7 @@ crate struct Invocation {
/// Safe build plan type, invocation dependencies are guaranteed to be inside
/// the plan.
#[derive(Debug, Default)]
crate struct ExternalPlan {
pub(crate) struct ExternalPlan {
units: HashMap<u64, Invocation>,
deps: HashMap<u64, HashSet<u64>>,
rev_deps: HashMap<u64, HashSet<u64>>,
Expand Down Expand Up @@ -248,11 +248,11 @@ impl Invocation {
}

impl ExternalPlan {
crate fn new() -> ExternalPlan {
pub(crate) fn new() -> ExternalPlan {
Default::default()
}

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

crate fn try_from_raw(build_dir: &Path, raw: RawPlan) -> Result<ExternalPlan, ()> {
pub(crate) fn try_from_raw(build_dir: &Path, raw: RawPlan) -> Result<ExternalPlan, ()> {
// Sanity check, each dependency (index) has to be inside the build plan
if raw
.invocations
Expand Down
14 changes: 7 additions & 7 deletions src/build/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ use crate::build::{BuildResult, Internals, PackageArg};
use crate::build::cargo_plan::CargoPlan;
use crate::build::external::ExternalPlan;

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

crate trait BuildGraph {
pub(crate) trait BuildGraph {
type Unit: BuildKey;

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

#[derive(Debug)]
crate enum WorkStatus {
pub(crate) enum WorkStatus {
NeedsCargo(PackageArg),
Execute(JobQueue),
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug)]
crate enum BuildPlan {
pub(crate) enum BuildPlan {
External(ExternalPlan),
Cargo(CargoPlan)
}
Expand All @@ -74,7 +74,7 @@ impl BuildPlan {
}

#[derive(Debug)]
crate struct JobQueue(Vec<ProcessBuilder>);
pub(crate) struct JobQueue(Vec<ProcessBuilder>);

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

impl JobQueue {
crate fn with_commands(jobs: Vec<ProcessBuilder>) -> JobQueue {
pub(crate) fn with_commands(jobs: Vec<ProcessBuilder>) -> JobQueue {
JobQueue(jobs)
}

crate fn dequeue(&mut self) -> Option<ProcessBuilder> {
pub(crate) fn dequeue(&mut self) -> Option<ProcessBuilder> {
self.0.pop()
}

Expand Down
2 changes: 1 addition & 1 deletion src/build/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use std::sync::{Arc, Mutex};
use std::process::Command;

// Runs a single instance of rustc. Runs in-process.
crate fn rustc(
pub(crate) fn rustc(
vfs: &Vfs,
args: &[String],
envs: &HashMap<String, Option<OsString>>,
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//! code completion, and enables renaming and refactorings.

#![feature(rustc_private, integer_atomics, drain_filter)]
#![feature(crate_visibility_modifier)] // needed for edition 2018
#![allow(unknown_lints)]
#![warn(clippy::all, rust_2018_idioms)]
#![allow(
Expand Down
8 changes: 4 additions & 4 deletions src/server/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_millis(3_600_000);
macro_rules! define_dispatch_request_enum {
($($request_type:ident),*$(,)*) => {
#[allow(clippy::large_enum_variant)] // seems ok for a short lived macro-enum
crate enum DispatchRequest {
pub(crate) enum DispatchRequest {
$(
$request_type(Request<$request_type>),
)*
Expand Down Expand Up @@ -112,13 +112,13 @@ define_dispatch_request_enum!(
/// handle the requests sequentially, without blocking stdin.
/// Requests dispatched this way are automatically timed out & avoid
/// processing if have already timed out before starting.
crate struct Dispatcher {
pub(crate) struct Dispatcher {
sender: mpsc::Sender<(DispatchRequest, InitActionContext, JobToken)>,
}

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

thread::Builder::new()
Expand All @@ -134,7 +134,7 @@ impl Dispatcher {
}

/// Sends a request to the dispatch-worker thread, does not block
crate fn dispatch<R: Into<DispatchRequest>>(&mut self, request: R, ctx: InitActionContext) {
pub(crate) fn dispatch<R: Into<DispatchRequest>>(&mut self, request: R, ctx: InitActionContext) {
let (job, token) = ConcurrentJob::new();
ctx.add_job(job);
if let Err(err) = self.sender.send((request.into(), ctx, token)) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub(super) struct StdioOutput {

impl StdioOutput {
/// Construct a new `stdout` output.
crate fn new() -> StdioOutput {
pub(crate) fn new() -> StdioOutput {
StdioOutput {
next_id: Arc::new(AtomicU64::new(1)),
}
Expand Down
12 changes: 6 additions & 6 deletions src/server/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ where

#[derive(Debug, PartialEq)]
pub(super) struct RawMessage {
crate method: String,
crate id: Id,
crate params: serde_json::Value,
pub(crate) method: String,
pub(crate) id: Id,
pub(crate) params: serde_json::Value,
}

impl RawMessage {
crate fn parse_as_request<'de, R>(&'de self) -> Result<Request<R>, jsonrpc::Error>
pub(crate) fn parse_as_request<'de, R>(&'de self) -> Result<Request<R>, jsonrpc::Error>
where
R: LSPRequest,
<R as LSPRequest>::Params: serde::Deserialize<'de>,
Expand Down Expand Up @@ -334,7 +334,7 @@ impl RawMessage {
}
}

crate fn parse_as_notification<'de, T>(&'de self) -> Result<Notification<T>, jsonrpc::Error>
pub(crate) fn parse_as_notification<'de, T>(&'de self) -> Result<Notification<T>, jsonrpc::Error>
where
T: LSPNotification,
<T as LSPNotification>::Params: serde::Deserialize<'de>,
Expand All @@ -350,7 +350,7 @@ impl RawMessage {
})
}

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