Merge pull request #5738 from matklad/cfg

Rename ra_cfg -> cfg
This commit is contained in:
Aleksey Kladov 2020-08-13 10:52:31 +02:00 committed by GitHub
commit 882e1a95ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 118 additions and 134 deletions

149
Cargo.lock generated
View file

@ -15,15 +15,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
[[package]]
name = "aho-corasick"
version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
dependencies = [
"memchr",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
@ -121,6 +112,16 @@ version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
[[package]]
name = "cfg"
version = "0.0.0"
dependencies = [
"mbe",
"rustc-hash",
"syntax",
"tt",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
@ -289,9 +290,9 @@ checksum = "9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1"
[[package]]
name = "either"
version = "1.5.3"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
checksum = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f"
[[package]]
name = "ena"
@ -551,9 +552,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.2.1"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
@ -645,10 +646,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "memchr"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
name = "mbe"
version = "0.0.0"
dependencies = [
"log",
"parser",
"rustc-hash",
"smallvec",
"syntax",
"test_utils",
"tt",
]
[[package]]
name = "memmap"
@ -901,6 +909,23 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "proc_macro_srv"
version = "0.0.0"
dependencies = [
"cargo_metadata",
"difference",
"goblin",
"libloading",
"mbe",
"memmap",
"ra_proc_macro",
"serde_derive",
"test_utils",
"toolchain",
"tt",
]
[[package]]
name = "profile"
version = "0.0.0"
@ -940,22 +965,12 @@ dependencies = [
"text_edit",
]
[[package]]
name = "ra_cfg"
version = "0.1.0"
dependencies = [
"ra_mbe",
"rustc-hash",
"syntax",
"tt",
]
[[package]]
name = "ra_db"
version = "0.1.0"
dependencies = [
"cfg",
"profile",
"ra_cfg",
"rustc-hash",
"salsa",
"stdx",
@ -997,6 +1012,7 @@ version = "0.1.0"
dependencies = [
"anymap",
"arena",
"cfg",
"drop_bomb",
"either",
"expect",
@ -1004,12 +1020,11 @@ dependencies = [
"indexmap",
"itertools",
"log",
"mbe",
"once_cell",
"profile",
"ra_cfg",
"ra_db",
"ra_hir_expand",
"ra_mbe",
"rustc-hash",
"smallvec",
"stdx",
@ -1025,10 +1040,10 @@ dependencies = [
"arena",
"either",
"log",
"mbe",
"parser",
"profile",
"ra_db",
"ra_mbe",
"rustc-hash",
"syntax",
"test_utils",
@ -1067,6 +1082,7 @@ dependencies = [
name = "ra_ide"
version = "0.1.0"
dependencies = [
"cfg",
"either",
"expect",
"indexmap",
@ -1075,7 +1091,6 @@ dependencies = [
"oorandom",
"profile",
"ra_assists",
"ra_cfg",
"ra_db",
"ra_fmt",
"ra_hir",
@ -1107,19 +1122,6 @@ dependencies = [
"text_edit",
]
[[package]]
name = "ra_mbe"
version = "0.1.0"
dependencies = [
"log",
"parser",
"rustc-hash",
"smallvec",
"syntax",
"test_utils",
"tt",
]
[[package]]
name = "ra_proc_macro"
version = "0.1.0"
@ -1132,23 +1134,6 @@ dependencies = [
"tt",
]
[[package]]
name = "proc_macro_srv"
version = "0.0.0"
dependencies = [
"cargo_metadata",
"difference",
"goblin",
"libloading",
"memmap",
"ra_mbe",
"ra_proc_macro",
"serde_derive",
"test_utils",
"toolchain",
"tt",
]
[[package]]
name = "ra_project_model"
version = "0.1.0"
@ -1156,9 +1141,9 @@ dependencies = [
"anyhow",
"arena",
"cargo_metadata",
"cfg",
"log",
"paths",
"ra_cfg",
"ra_db",
"ra_proc_macro",
"rustc-hash",
@ -1219,10 +1204,7 @@ version = "1.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"thread_local",
]
[[package]]
@ -1258,6 +1240,7 @@ name = "rust-analyzer"
version = "0.1.0"
dependencies = [
"anyhow",
"cfg",
"crossbeam-channel",
"env_logger",
"expect",
@ -1267,20 +1250,19 @@ dependencies = [
"log",
"lsp-server",
"lsp-types",
"mbe",
"mimalloc",
"oorandom",
"parking_lot",
"pico-args",
"proc_macro_srv",
"profile",
"ra_cfg",
"ra_db",
"ra_hir",
"ra_hir_def",
"ra_hir_ty",
"ra_ide",
"ra_ide_db",
"ra_mbe",
"proc_macro_srv",
"ra_project_model",
"ra_ssr",
"rayon",
@ -1414,18 +1396,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "serde"
version = "1.0.114"
version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3"
checksum = "e54c9a88f2da7238af84b5101443f0c0d0a3bbdc455e34a5c9497b1903ed55d5"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.114"
version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e"
checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48"
dependencies = [
"proc-macro2",
"quote",
@ -1471,9 +1453,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
[[package]]
name = "smallvec"
version = "1.4.1"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f"
checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
[[package]]
name = "smol_str"
@ -1614,9 +1596,9 @@ dependencies = [
[[package]]
name = "tracing"
version = "0.1.18"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0aae59226cf195d8e74d4b34beae1859257efb4e5fed3f147d2dc2c7d372178"
checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c"
dependencies = [
"cfg-if",
"tracing-attributes",
@ -1625,9 +1607,9 @@ dependencies = [
[[package]]
name = "tracing-attributes"
version = "0.1.9"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b"
checksum = "1fe233f4227389ab7df5b32649239da7ebe0b281824b4e84b342d04d3fd8c25e"
dependencies = [
"proc-macro2",
"quote",
@ -1636,9 +1618,9 @@ dependencies = [
[[package]]
name = "tracing-core"
version = "0.1.13"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d593f98af59ebc017c0648f0117525db358745a8894a8d684e185ba3f45954f9"
checksum = "db63662723c316b43ca36d833707cc93dff82a02ba3d7e354f342682cc8b3545"
dependencies = [
"lazy_static",
]
@ -1666,9 +1648,9 @@ dependencies = [
[[package]]
name = "tracing-subscriber"
version = "0.2.10"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7b33f8b2ef2ab0c3778c12646d9c42a24f7772bee4cdafc72199644a9f58fdc"
checksum = "abd165311cc4d7a555ad11cc77a37756df836182db0d81aac908c8184c584f40"
dependencies = [
"ansi_term",
"chrono",
@ -1679,6 +1661,7 @@ dependencies = [
"serde_json",
"sharded-slab",
"smallvec",
"thread_local",
"tracing-core",
"tracing-log",
"tracing-serde",

View file

@ -1,9 +1,9 @@
[package]
edition = "2018"
name = "ra_cfg"
version = "0.1.0"
authors = ["rust-analyzer developers"]
name = "cfg"
version = "0.0.0"
license = "MIT OR Apache-2.0"
authors = ["rust-analyzer developers"]
edition = "2018"
[lib]
doctest = false
@ -11,8 +11,8 @@ doctest = false
[dependencies]
rustc-hash = "1.1.0"
syntax = { path = "../syntax" }
tt = { path = "../tt" }
[dev-dependencies]
mbe = { path = "../ra_mbe", package = "ra_mbe" }
mbe = { path = "../mbe" }
syntax = { path = "../syntax" }

View file

@ -4,7 +4,7 @@
use std::slice::Iter as SliceIter;
use syntax::SmolStr;
use tt::SmolStr;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CfgExpr {
@ -86,17 +86,15 @@ fn next_cfg_expr(it: &mut SliceIter<tt::TokenTree>) -> Option<CfgExpr> {
mod tests {
use super::*;
use mbe::{ast_to_token_tree, TokenMap};
use mbe::ast_to_token_tree;
use syntax::ast::{self, AstNode};
fn get_token_tree_generated(input: &str) -> (tt::Subtree, TokenMap) {
let source_file = ast::SourceFile::parse(input).ok().unwrap();
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
ast_to_token_tree(&tt).unwrap()
}
fn assert_parse_result(input: &str, expected: CfgExpr) {
let (tt, _) = get_token_tree_generated(input);
let (tt, _) = {
let source_file = ast::SourceFile::parse(input).ok().unwrap();
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
ast_to_token_tree(&tt).unwrap()
};
let cfg = CfgExpr::parse(&tt);
assert_eq!(cfg, expected);
}

View file

@ -1,9 +1,9 @@
//! ra_cfg defines conditional compiling options, `cfg` attibute parser and evaluator
//! cfg defines conditional compiling options, `cfg` attibute parser and evaluator
mod cfg_expr;
use rustc_hash::FxHashSet;
use syntax::SmolStr;
use tt::SmolStr;
pub use cfg_expr::CfgExpr;

View file

@ -1,20 +1,21 @@
[package]
edition = "2018"
name = "ra_mbe"
version = "0.1.0"
authors = ["rust-analyzer developers"]
name = "mbe"
version = "0.0.0"
license = "MIT OR Apache-2.0"
authors = ["rust-analyzer developers"]
edition = "2018"
[lib]
doctest = false
[dependencies]
syntax = { path = "../syntax" }
parser = { path = "../parser" }
tt = { path = "../tt" }
rustc-hash = "1.1.0"
smallvec = "1.2.0"
log = "0.4.8"
syntax = { path = "../syntax" }
parser = { path = "../parser" }
tt = { path = "../tt" }
[dev-dependencies]
test_utils = { path = "../test_utils" }

View file

@ -9,12 +9,13 @@ edition = "2018"
doctest = false
[dependencies]
tt = { path = "../tt" }
ra_mbe = { path = "../ra_mbe" }
ra_proc_macro = { path = "../ra_proc_macro" }
goblin = "0.2.1"
libloading = "0.6.0"
memmap = "0.7"
tt = { path = "../tt" }
mbe = { path = "../mbe" }
ra_proc_macro = { path = "../ra_proc_macro" }
test_utils = { path = "../test_utils" }
[dev-dependencies]
@ -22,4 +23,5 @@ cargo_metadata = "0.11.1"
difference = "2.0.0"
# used as proc macro test target
serde_derive = "1.0.106"
toolchain = { path = "../toolchain" }

View file

@ -182,7 +182,7 @@ pub mod token_stream {
fn from_str(src: &str) -> Result<TokenStream, LexError> {
let (subtree, _token_map) =
ra_mbe::parse_to_token_tree(src).ok_or("Failed to parse from mbe")?;
mbe::parse_to_token_tree(src).ok_or("Failed to parse from mbe")?;
let tt: tt::TokenTree = subtree.into();
Ok(tt.into())

View file

@ -13,7 +13,7 @@ salsa = "0.15.2"
rustc-hash = "1.1.0"
syntax = { path = "../syntax" }
ra_cfg = { path = "../ra_cfg" }
cfg = { path = "../cfg" }
profile = { path = "../profile" }
tt = { path = "../tt" }
test_utils = { path = "../test_utils" }

View file

@ -59,7 +59,7 @@
//! ```
use std::{str::FromStr, sync::Arc};
use ra_cfg::CfgOptions;
use cfg::CfgOptions;
use rustc_hash::FxHashMap;
use test_utils::{extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER};
use vfs::{file_set::FileSet, VfsPath};

View file

@ -8,7 +8,7 @@
use std::{fmt, iter::FromIterator, ops, str::FromStr, sync::Arc};
use ra_cfg::CfgOptions;
use cfg::CfgOptions;
use rustc_hash::{FxHashMap, FxHashSet};
use syntax::SmolStr;
use tt::TokenExpander;

View file

@ -28,8 +28,8 @@ syntax = { path = "../syntax" }
profile = { path = "../profile" }
hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" }
test_utils = { path = "../test_utils" }
mbe = { path = "../ra_mbe", package = "ra_mbe" }
ra_cfg = { path = "../ra_cfg" }
mbe = { path = "../mbe" }
cfg = { path = "../cfg" }
tt = { path = "../tt" }
[dev-dependencies]

View file

@ -23,7 +23,7 @@ use crate::{
EnumId, HasModule, LocalEnumVariantId, LocalFieldId, Lookup, ModuleId, StructId, UnionId,
VariantId,
};
use ra_cfg::CfgOptions;
use cfg::CfgOptions;
/// Note that we use `StructData` for unions as well!
#[derive(Debug, Clone, PartialEq, Eq)]

View file

@ -2,10 +2,10 @@
use std::{ops, sync::Arc};
use cfg::{CfgExpr, CfgOptions};
use either::Either;
use hir_expand::{hygiene::Hygiene, AstId, InFile};
use mbe::ast_to_token_tree;
use ra_cfg::{CfgExpr, CfgOptions};
use syntax::{
ast::{self, AstNode, AttrsOwner},
SmolStr,

View file

@ -6,10 +6,10 @@ pub mod scope;
use std::{mem, ops::Index, sync::Arc};
use arena::{map::ArenaMap, Arena};
use cfg::CfgOptions;
use drop_bomb::DropBomb;
use either::Either;
use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId};
use ra_cfg::CfgOptions;
use ra_db::CrateId;
use rustc_hash::FxHashMap;
use syntax::{ast, AstNode, AstPtr};

View file

@ -3,6 +3,7 @@
//! `DefCollector::collect` contains the fixed-point iteration loop which
//! resolves imports and expands macros.
use cfg::CfgOptions;
use hir_expand::{
ast_id_map::FileAstId,
builtin_derive::find_builtin_derive,
@ -11,7 +12,6 @@ use hir_expand::{
proc_macro::ProcMacroExpander,
HirFileId, MacroCallId, MacroDefId, MacroDefKind,
};
use ra_cfg::CfgOptions;
use ra_db::{CrateId, FileId, ProcMacroId};
use rustc_hash::FxHashMap;
use syntax::ast;

View file

@ -19,5 +19,5 @@ syntax = { path = "../syntax" }
parser = { path = "../parser" }
profile = { path = "../profile" }
tt = { path = "../tt" }
mbe = { path = "../ra_mbe", package = "ra_mbe" }
mbe = { path = "../mbe" }
test_utils = { path = "../test_utils"}

View file

@ -25,7 +25,7 @@ syntax = { path = "../syntax" }
text_edit = { path = "../text_edit" }
ra_db = { path = "../ra_db" }
ra_ide_db = { path = "../ra_ide_db" }
ra_cfg = { path = "../ra_cfg" }
cfg = { path = "../cfg" }
ra_fmt = { path = "../ra_fmt" }
profile = { path = "../profile" }
test_utils = { path = "../test_utils" }

View file

@ -47,7 +47,7 @@ mod typing;
use std::sync::Arc;
use ra_cfg::CfgOptions;
use cfg::CfgOptions;
use ra_db::{
salsa::{self, ParallelDatabase},
CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath,

View file

@ -1,7 +1,7 @@
//! FIXME: write short doc here
use std::sync::Arc;
use ra_cfg::CfgOptions;
use cfg::CfgOptions;
use ra_db::{CrateName, FileSet, SourceRoot, VfsPath};
use test_utils::{
extract_annotations, extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER,

View file

@ -63,7 +63,7 @@ pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> {
#[cfg(test)]
mod tests {
use ra_cfg::CfgOptions;
use cfg::CfgOptions;
use ra_db::Env;
use test_utils::mark;

View file

@ -1,8 +1,8 @@
use std::fmt;
use cfg::CfgExpr;
use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics};
use itertools::Itertools;
use ra_cfg::CfgExpr;
use ra_ide_db::RootDatabase;
use syntax::{
ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner},

View file

@ -15,7 +15,7 @@ rustc-hash = "1.1.0"
cargo_metadata = "0.11.1"
arena = { path = "../arena" }
ra_cfg = { path = "../ra_cfg" }
cfg = { path = "../cfg" }
ra_db = { path = "../ra_db" }
toolchain = { path = "../toolchain" }
ra_proc_macro = { path = "../ra_proc_macro" }

View file

@ -3,7 +3,7 @@
//! rustc main.rs --cfg foo --cfg 'feature="bar"'
use std::str::FromStr;
use ra_cfg::CfgOptions;
use cfg::CfgOptions;
use stdx::split_once;
#[derive(Clone, Eq, PartialEq, Debug)]

View file

@ -12,8 +12,8 @@ use std::{
};
use anyhow::{bail, Context, Result};
use cfg::CfgOptions;
use paths::{AbsPath, AbsPathBuf};
use ra_cfg::CfgOptions;
use ra_db::{CrateGraph, CrateId, CrateName, Edition, Env, FileId};
use rustc_hash::{FxHashMap, FxHashSet};

View file

@ -42,7 +42,7 @@ syntax = { path = "../syntax" }
text_edit = { path = "../text_edit" }
vfs = { path = "../vfs" }
vfs-notify = { path = "../vfs-notify" }
ra_cfg = { path = "../ra_cfg" }
cfg = { path = "../cfg" }
toolchain = { path = "../toolchain" }
# This should only be used in CLI
@ -60,5 +60,5 @@ winapi = "0.3.8"
[dev-dependencies]
expect = { path = "../expect" }
test_utils = { path = "../test_utils" }
mbe = { path = "../ra_mbe", package = "ra_mbe" }
mbe = { path = "../mbe" }
tt = { path = "../tt" }

View file

@ -1,6 +1,6 @@
//! See `CargoTargetSpec`
use ra_cfg::CfgExpr;
use cfg::CfgExpr;
use ra_ide::{FileId, RunnableKind, TestId};
use ra_project_model::{self, TargetKind};
use vfs::AbsPathBuf;
@ -177,8 +177,8 @@ fn required_features(cfg_expr: &CfgExpr, features: &mut Vec<String>) {
mod tests {
use super::*;
use cfg::CfgExpr;
use mbe::ast_to_token_tree;
use ra_cfg::CfgExpr;
use syntax::{
ast::{self, AstNode},
SmolStr,

View file

@ -195,7 +195,7 @@ impl TidyDocs {
"ra_hir",
"ra_hir_expand",
"ra_ide",
"ra_mbe",
"mbe",
"parser",
"profile",
"ra_project_model",