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

Summer cleaning #1507

Merged
merged 6 commits into from
Jul 8, 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
10 changes: 0 additions & 10 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::env;
use std::path::Path;

Expand Down
1 change: 1 addition & 0 deletions rls-analysis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "rls-analysis"
version = "0.17.0"
edition = "2018"
authors = ["Nick Cameron <[email protected]>"]
description = "Library for processing rustc's save-analysis data for the RLS"
license = "Apache-2.0/MIT"
Expand Down
8 changes: 0 additions & 8 deletions rls-analysis/benches/std_api_crate.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// Copyright 2017 The RLS Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(test)]

extern crate rls_analysis;
Expand Down
12 changes: 2 additions & 10 deletions rls-analysis/src/analysis.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
// Copyright 2017 The RLS Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use fst;
use std::collections::{HashMap, HashSet};
use std::iter;
use std::path::{Path, PathBuf};
use std::time::SystemTime;

use raw::{CrateId, DefKind};
use {Id, Span, SymbolQuery};
use crate::raw::{CrateId, DefKind};
use crate::{Id, Span, SymbolQuery};

/// This is the main database that contains all the collected symbol information,
/// such as definitions, their mapping between spans, hierarchy and so on,
Expand Down
24 changes: 7 additions & 17 deletions rls-analysis/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
// Copyright 2016 The RLS Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(rust_2018_idioms)]

#[macro_use]
extern crate derive_new;
#[macro_use]
extern crate log;
extern crate fst;
extern crate itertools;
extern crate json;

extern crate rls_data as data;
extern crate rls_span as span;
extern crate serde;
extern crate serde_json;

mod analysis;
mod listings;
Expand Down Expand Up @@ -136,7 +126,7 @@ impl<L: AnalysisLoader> AnalysisHost<L> {
analysis: Vec<data::Analysis>,
path_prefix: &Path,
base_dir: &Path,
blacklist: Blacklist,
blacklist: Blacklist<'_>,
) -> AResult<()> {
self.reload_with_blacklist(path_prefix, base_dir, blacklist)?;

Expand All @@ -160,7 +150,7 @@ impl<L: AnalysisLoader> AnalysisHost<L> {
&self,
path_prefix: &Path,
base_dir: &Path,
blacklist: Blacklist,
blacklist: Blacklist<'_>,
) -> AResult<()> {
trace!("reload_with_blacklist {:?} {:?} {:?}", path_prefix, base_dir, blacklist);
let empty = self.analysis.lock()?.is_none();
Expand Down Expand Up @@ -190,7 +180,7 @@ impl<L: AnalysisLoader> AnalysisHost<L> {
&self,
path_prefix: &Path,
base_dir: &Path,
blacklist: Blacklist,
blacklist: Blacklist<'_>,
) -> AResult<()> {
trace!("hard_reload {:?} {:?}", path_prefix, base_dir);
// We're going to create a dummy AnalysisHost that we will fill with data,
Expand Down Expand Up @@ -551,7 +541,7 @@ impl<L: AnalysisLoader> AnalysisHost<L> {
}

impl ::std::fmt::Display for Id {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
Expand All @@ -566,7 +556,7 @@ impl ::std::error::Error for AError {
}

impl ::std::fmt::Display for AError {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "{}", ::std::error::Error::description(self))
}
}
Expand Down
8 changes: 0 additions & 8 deletions rls-analysis/src/listings/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// Copyright 2016 The RLS Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::io;
use std::path::Path;
use std::time::SystemTime;
Expand Down
12 changes: 2 additions & 10 deletions rls-analysis/src/loader.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// Copyright 2017 The RLS Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Defines an `AnalysisLoader` trait, which allows to specify directories
//! from which save-analysis JSON files can be read. Also supplies a
//! default implementation `CargoAnalysisLoader` for Cargo-emitted save-analysis
Expand All @@ -17,7 +9,7 @@ use std::fmt;
use std::path::{Path, PathBuf};
use std::process::Command;

use AnalysisHost;
use crate::AnalysisHost;

#[derive(Debug)]
pub struct CargoAnalysisLoader {
Expand Down Expand Up @@ -150,7 +142,7 @@ pub enum Target {
}

impl fmt::Display for Target {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Target::Release => write!(f, "release"),
Target::Debug => write!(f, "debug"),
Expand Down
18 changes: 5 additions & 13 deletions rls-analysis/src/lowering.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
// Copyright 2016 The RLS Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! For processing the raw save-analysis data from rustc into the rls
//! in-memory representation.

use analysis::{Def, Glob, PerCrateAnalysis, Ref};
use crate::analysis::{Def, Glob, PerCrateAnalysis, Ref};
use data;
use loader::AnalysisLoader;
use raw::{self, CrateId, DefKind, RelationKind};
use util;
use {AResult, AnalysisHost, Id, Span, NULL};
use crate::loader::AnalysisLoader;
use crate::raw::{self, CrateId, DefKind, RelationKind};
use crate::util;
use crate::{AResult, AnalysisHost, Id, Span, NULL};

use span;

Expand Down
16 changes: 4 additions & 12 deletions rls-analysis/src/raw.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
// Copyright 2016 The RLS Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use data::config::Config;
use data::Analysis;
pub use data::{
CratePreludeData, Def, DefKind, GlobalCrateId as CrateId, Import, Ref, Relation, RelationKind,
SigElement, Signature, SpanData,
};
use listings::{DirectoryListing, ListingKind};
use {AnalysisLoader, Blacklist};
use crate::listings::{DirectoryListing, ListingKind};
use crate::{AnalysisLoader, Blacklist};

use std::collections::HashMap;
use std::fs::File;
Expand Down Expand Up @@ -52,7 +44,7 @@ impl Crate {
pub fn read_analysis_from_files<L: AnalysisLoader>(
loader: &L,
crate_timestamps: HashMap<PathBuf, SystemTime>,
crate_blacklist: Blacklist,
crate_blacklist: Blacklist<'_>,
) -> Vec<Crate> {
let mut result = vec![];

Expand Down Expand Up @@ -99,7 +91,7 @@ pub fn read_analysis_from_files<L: AnalysisLoader>(
result
}

fn ignore_data(file_name: &str, crate_blacklist: Blacklist) -> bool {
fn ignore_data(file_name: &str, crate_blacklist: Blacklist<'_>) -> bool {
crate_blacklist.iter().any(|name| file_name.starts_with(&format!("lib{}-", name)))
}

Expand Down
2 changes: 1 addition & 1 deletion rls-analysis/src/symbol_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl SymbolQuery {
stream.union()
}

pub(crate) fn search_stream<F, T>(&self, mut stream: fst::map::Union, f: F) -> Vec<T>
pub(crate) fn search_stream<F, T>(&self, mut stream: fst::map::Union<'_>, f: F) -> Vec<T>
where
F: Fn(&mut Vec<T>, &fst::map::IndexedValue),
{
Expand Down
17 changes: 3 additions & 14 deletions rls-analysis/src/test/mod.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
// Copyright 2016 The RLS Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use loader::SearchDirectory;
use raw::DefKind;
use {AnalysisHost, AnalysisLoader};
use crate::loader::SearchDirectory;
use crate::raw::DefKind;
use crate::{AnalysisHost, AnalysisLoader};

use std::collections::HashSet;
use std::path::{Path, PathBuf};

#[cfg(test)]
extern crate env_logger;

#[derive(Clone, new)]
struct TestAnalysisLoader {
path: PathBuf,
Expand Down
8 changes: 0 additions & 8 deletions rls-analysis/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// Copyright 2016 The RLS Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[cfg(unix)]
pub fn get_resident() -> Option<usize> {
use std::fs::File;
Expand Down
1 change: 1 addition & 0 deletions rls-blacklist/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "rls-blacklist"
version = "0.1.3"
edition = "2018"
authors = ["Nick Cameron <[email protected]>"]
description = "Blacklist of crates for the RLS to skip"
license = "Apache-2.0/MIT"
Expand Down
1 change: 1 addition & 0 deletions rls-rustc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "rls-rustc"
version = "0.6.0"
edition = "2018"
authors = ["Nick Cameron <[email protected]>"]
description = "A simple shim around rustc to allow using save-analysis with a stable toolchain"
license = "Apache-2.0/MIT"
Expand Down
2 changes: 0 additions & 2 deletions rls-rustc/src/bin/rustc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate rls_rustc;

fn main() {
rls_rustc::run();
}
1 change: 1 addition & 0 deletions rls-vfs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "rls-vfs"
version = "0.8.0"
edition = "2018"
authors = ["Nick Cameron <[email protected]>"]
description = "Virtual File System for the RLS"
license = "Apache-2.0/MIT"
Expand Down
4 changes: 3 additions & 1 deletion rls-vfs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![warn(rust_2018_idioms)]

extern crate rls_span as span;
#[macro_use]
extern crate log;
Expand Down Expand Up @@ -150,7 +152,7 @@ impl Into<String> for Error {
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Error::OutOfSync(ref path_buf) => {
write!(f, "file {} out of sync with filesystem", path_buf.display())
Expand Down