Skip to content
This repository was archived by the owner on Mar 1, 2019. It is now read-only.

Prepare to use rls-data 0.12 #114

Merged
merged 3 commits into from
Oct 30, 2017
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
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rls-analysis"
version = "0.7.0"
version = "0.7.1"
authors = ["Nick Cameron <[email protected]>"]
description = "Library for processing rustc's save-analysis data for the RLS"
license = "Apache-2.0/MIT"
Expand All @@ -10,7 +10,7 @@ categories = ["development-tools"]
[dependencies]
rustc-serialize = "0.3"
log = "0.3"
rls-data = "= 0.11"
rls-data = "= 0.12"
rls-span = "0.4"
derive-new = "0.5"

Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,8 @@ impl<L: AnalysisLoader> AnalysisHost<L> {
match def.parent {
Some(p) => {
analysis.with_defs(p, |parent| match def.kind {
DefKind::Field | DefKind::Method | DefKind::Tuple => {
DefKind::Field | DefKind::Method | DefKind::Tuple |
DefKind::TupleVariant | DefKind::StructVariant => {
let ns = name_space_for_def_kind(def.kind);
let mut res = AnalysisHost::<L>::mk_doc_url(parent, analysis)
.unwrap_or_else(|| "".into());
Expand Down
13 changes: 7 additions & 6 deletions src/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,24 @@ impl CrateReader {
// map those when lowering symbols with local crate ids into global registry
// It's worth noting, that we assume that local crate id is 0, whereas
// the external crates will have num in 1..count contiguous range.
trace!("building crate map for {}", prelude.crate_name);
let id = fetch_crate_id(master_crate_map, &prelude.crate_name);
let crate_name = prelude.crate_id.name.clone();
trace!("building crate map for {}", crate_name);
let id = fetch_crate_id(master_crate_map, &crate_name);
let mut crate_map = vec![id];
trace!(" {} -> {}", prelude.crate_name, master_crate_map[&prelude.crate_name]);
trace!(" {} -> {}", crate_name, master_crate_map[&crate_name]);

prelude.external_crates.sort_by(|a, b| a.num.cmp(&b.num));
for c in prelude.external_crates {
assert!(c.num == crate_map.len() as u32);
let id = fetch_crate_id(master_crate_map, &c.name);
let id = fetch_crate_id(master_crate_map, &c.id.name);
crate_map.push(id);
trace!(" {} -> {}", c.name, master_crate_map[&c.name]);
trace!(" {} -> {}", c.id.name, master_crate_map[&c.id.name]);
}

CrateReader {
crate_map,
base_dir: base_dir.to_owned(),
crate_name: prelude.crate_name,
crate_name: crate_name,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ fn read_crate_data(path: &Path) -> Option<Analysis> {
pub fn name_space_for_def_kind(dk: DefKind) -> char {
match dk {
DefKind::Enum |
DefKind::TupleVariant |
DefKind::StructVariant |
DefKind::Struct |
DefKind::Union |
DefKind::Type |
Expand All @@ -141,6 +139,8 @@ pub fn name_space_for_def_kind(dk: DefKind) -> char {
DefKind::Static |
DefKind::Const |
DefKind::Tuple |
DefKind::TupleVariant |
DefKind::StructVariant |
DefKind::Field => 'v',
DefKind::Macro => 'm',
}
Expand Down
5 changes: 2 additions & 3 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ fn test_types() {
assert_type(&host, "TestTrait", DefKind::Trait, &[25]);
assert_type(&host, "test_method", DefKind::Method, &[26]);
assert_type(&host, "FooEnum", DefKind::Enum, &[29]);
// TODO: TupleVariant and StructVariant DefKind when rustc uses rls-data 0.11
assert_type(&host, "TupleVariant", DefKind::Tuple, &[30]);
assert_type(&host, "StructVariant", DefKind::Struct, &[31]);
assert_type(&host, "TupleVariant", DefKind::TupleVariant, &[30]);
assert_type(&host, "StructVariant", DefKind::StructVariant, &[31]);
}
4 changes: 4 additions & 0 deletions test_data/hello/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test_data/hello/save-analysis/hello.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"config":{"output_file":null,"full_docs":false,"pub_only":false,"distro_crate":false,"signatures":false,"borrow_data":false},"prelude":{"crate_name":"hello","crate_root":"src","external_crates":[{"name":"panic_unwind","num":11,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"},{"name":"unwind","num":8,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"},{"name":"std_unicode","num":5,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"},{"name":"core","num":2,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"},{"name":"alloc_jemalloc","num":10,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"},{"name":"libc","num":7,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"},{"name":"alloc","num":4,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"},{"name":"std","num":1,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"},{"name":"compiler_builtins","num":9,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"},{"name":"alloc_system","num":6,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"},{"name":"rand","num":3,"file_name":"/home/jbushart/projects/rls-analysis/test_data/hello/src/main.rs"}],"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":0,"byte_end":112,"line_start":1,"line_end":8,"column_start":1,"column_end":2}},"imports":[],"defs":[{"kind":"Mod","id":{"krate":0,"index":0},"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":0,"byte_end":112,"line_start":1,"line_end":8,"column_start":1,"column_end":2},"name":"","qualname":"::","value":"src/main.rs","parent":null,"children":[{"krate":0,"index":1},{"krate":0,"index":2},{"krate":0,"index":3},{"krate":0,"index":4}],"decl_id":null,"docs":"","sig":null,"attributes":[]},{"kind":"Function","id":{"krate":0,"index":3},"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":3,"byte_end":14,"line_start":1,"line_end":1,"column_start":4,"column_end":15},"name":"print_hello","qualname":"::print_hello","value":"fn () -> ()","parent":null,"children":[],"decl_id":null,"docs":"","sig":null,"attributes":[]},{"kind":"Local","id":{"krate":0,"index":2147483657},"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":27,"byte_end":31,"line_start":2,"line_end":2,"column_start":9,"column_end":13},"name":"name","qualname":"name$8","value":"&str","parent":null,"children":[],"decl_id":null,"docs":"","sig":null,"attributes":[]},{"kind":"Function","id":{"krate":0,"index":4},"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":83,"byte_end":87,"line_start":6,"line_end":6,"column_start":4,"column_end":8},"name":"main","qualname":"::main","value":"fn () -> ()","parent":null,"children":[],"decl_id":null,"docs":"","sig":null,"attributes":[]}],"impls":[],"refs":[{"kind":"Variable","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":70,"byte_end":74,"line_start":3,"line_end":3,"column_start":28,"column_end":32},"ref_id":{"krate":0,"index":2147483657}},{"kind":"Variable","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":70,"byte_end":74,"line_start":3,"line_end":3,"column_start":28,"column_end":32},"ref_id":{"krate":0,"index":2147483658}},{"kind":"Function","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":70,"byte_end":74,"line_start":3,"line_end":3,"column_start":28,"column_end":32},"ref_id":{"krate":2,"index":3323}},{"kind":"Function","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":96,"byte_end":107,"line_start":7,"line_end":7,"column_start":5,"column_end":16},"ref_id":{"krate":0,"index":3}}],"macro_refs":[{"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":47,"byte_end":76,"line_start":3,"line_end":3,"column_start":5,"column_end":34},"qualname":"println","callee_span":{"file_name":[47,99,104,101,99,107,111,117,116,47,115,114,99,47,108,105,98,115,116,100,47,109,97,99,114,111,115,46,114,115],"byte_start":24058,"byte_end":24231,"line_start":144,"line_end":148,"column_start":1,"column_end":2}}],"relations":[]}
{"config":{"output_file":null,"full_docs":false,"pub_only":false,"distro_crate":false,"signatures":false,"borrow_data":false},"prelude":{"crate_id":{"name":"hello","disambiguator":[4972498070786205651,10752139000545052689]},"crate_root":"src","external_crates":[{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":11,"id":{"name":"panic_unwind","disambiguator":[14724309074517047858,14081363051482221763]}},{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":8,"id":{"name":"unwind","disambiguator":[16962421678491010609,14144564669002769638]}},{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":5,"id":{"name":"std_unicode","disambiguator":[7825379778752978812,3737998437093158016]}},{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":2,"id":{"name":"core","disambiguator":[2034893687031163843,15475795989519470532]}},{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":10,"id":{"name":"alloc_jemalloc","disambiguator":[16728898169015843293,537719064825112735]}},{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":7,"id":{"name":"libc","disambiguator":[10024553366994624393,7659320522938082018]}},{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":4,"id":{"name":"alloc","disambiguator":[6987473938317122452,6651568688483122068]}},{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":1,"id":{"name":"std","disambiguator":[16894929902530602639,5439452766102853002]}},{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":9,"id":{"name":"compiler_builtins","disambiguator":[15243808009585947056,16380432114833907945]}},{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":6,"id":{"name":"alloc_system","disambiguator":[9386991845804871092,6259921119180170237]}},{"file_name":"/home/xanewok/repos/rls-analysis/test_data/hello/src/main.rs","num":3,"id":{"name":"rand","disambiguator":[17798033069558174552,12679496062386314490]}}],"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":0,"byte_end":112,"line_start":1,"line_end":8,"column_start":1,"column_end":2}},"imports":[],"defs":[{"kind":"Mod","id":{"krate":0,"index":0},"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":0,"byte_end":112,"line_start":1,"line_end":8,"column_start":1,"column_end":2},"name":"","qualname":"::","value":"src/main.rs","parent":null,"children":[{"krate":0,"index":1},{"krate":0,"index":2},{"krate":0,"index":3},{"krate":0,"index":4}],"decl_id":null,"docs":"","sig":null,"attributes":[]},{"kind":"Function","id":{"krate":0,"index":3},"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":3,"byte_end":14,"line_start":1,"line_end":1,"column_start":4,"column_end":15},"name":"print_hello","qualname":"::print_hello","value":"fn () -> ()","parent":null,"children":[],"decl_id":null,"docs":"","sig":null,"attributes":[]},{"kind":"Local","id":{"krate":0,"index":4294967287},"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":27,"byte_end":31,"line_start":2,"line_end":2,"column_start":9,"column_end":13},"name":"name","qualname":"name$8","value":"&str","parent":null,"children":[],"decl_id":null,"docs":"","sig":null,"attributes":[]},{"kind":"Function","id":{"krate":0,"index":4},"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":83,"byte_end":87,"line_start":6,"line_end":6,"column_start":4,"column_end":8},"name":"main","qualname":"::main","value":"fn () -> ()","parent":null,"children":[],"decl_id":null,"docs":"","sig":null,"attributes":[]}],"impls":[],"refs":[{"kind":"Mod","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1},"ref_id":{"krate":4294967295,"index":4294967295}},{"kind":"Mod","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1},"ref_id":{"krate":4294967295,"index":4294967295}},{"kind":"Mod","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1},"ref_id":{"krate":4294967295,"index":4294967295}},{"kind":"Variable","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":70,"byte_end":74,"line_start":3,"line_end":3,"column_start":28,"column_end":32},"ref_id":{"krate":0,"index":4294967287}},{"kind":"Variable","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":70,"byte_end":74,"line_start":3,"line_end":3,"column_start":28,"column_end":32},"ref_id":{"krate":0,"index":4294967269}},{"kind":"Function","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":70,"byte_end":74,"line_start":3,"line_end":3,"column_start":28,"column_end":32},"ref_id":{"krate":2,"index":3443}},{"kind":"Type","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":70,"byte_end":74,"line_start":3,"line_end":3,"column_start":28,"column_end":32},"ref_id":{"krate":4294967295,"index":4294967295}},{"kind":"Mod","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":70,"byte_end":74,"line_start":3,"line_end":3,"column_start":28,"column_end":32},"ref_id":{"krate":4294967295,"index":4294967295}},{"kind":"Mod","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":70,"byte_end":74,"line_start":3,"line_end":3,"column_start":28,"column_end":32},"ref_id":{"krate":4294967295,"index":4294967295}},{"kind":"Function","span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":96,"byte_end":107,"line_start":7,"line_end":7,"column_start":5,"column_end":16},"ref_id":{"krate":0,"index":3}}],"macro_refs":[{"span":{"file_name":[115,114,99,47,109,97,105,110,46,114,115],"byte_start":47,"byte_end":76,"line_start":3,"line_end":3,"column_start":5,"column_end":34},"qualname":"println","callee_span":{"file_name":[47,104,111,109,101,47,120,97,110,101,119,111,107,47,114,101,112,111,115,47,114,117,115,116,47,115,114,99,47,108,105,98,115,116,100,47,109,97,99,114,111,115,46,114,115],"byte_start":25155,"byte_end":25328,"line_start":150,"line_end":154,"column_start":1,"column_end":2}}],"relations":[]}
32 changes: 17 additions & 15 deletions test_data/make_data.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# This script reproduces all save-analysis data in the test_data directories.

# TODO currently this is broken. Cargo makes files of the form deps/save-analysis/foo-....json
Expand All @@ -8,22 +9,23 @@
# this data because the source is not pinned, therefore the data will change
# regualarly. It should basically just be used as a 'big'-ish set of real-world
# data for smoke testing.
# cd ..
# RUSTFLAGS=-Zsave-analysis cargo build
# rm test_data/rls-analysis/*
# cp target/debug/deps/save-analysis/*.json test_data/rls-analysis
# cd test_data

cd ..
RUSTFLAGS=-Zsave-analysis cargo build
rm test_data/rls-analysis/*
cp target/debug/deps/save-analysis/*.json test_data/rls-analysis
cd test_data

# Hello world test case
# cd hello
# RUSTFLAGS=-Zsave-analysis cargo build
# cp target/debug/save-analysis/hello.json save-analysis
# RUSTFLAGS=-Zsave-analysis-api cargo build
# cp target/debug/save-analysis/hello.json save-analysis-api
# cd ..
cd hello
RUSTFLAGS=-Zsave-analysis cargo build
cp target/debug/deps/save-analysis/hello-*.json save-analysis
#RUSTFLAGS=-Zsave-analysis-api cargo build
#cp target/debug/save-analysis/hello.json save-analysis-api
cd ..

# Types
# cd types
# RUSTFLAGS=-Zsave-analysis cargo build
# cp target/debug/save-analysis/types.json save-analysis
# cd ..
cd types
RUSTFLAGS=-Zsave-analysis cargo build
cp target/debug/deps/save-analysis/types-*.json save-analysis
cd ..
1 change: 1 addition & 0 deletions test_data/rls-analysis/libderive_new-bde12847971b287b.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test_data/rls-analysis/libderive_new-d794dc145b37cf62.json

This file was deleted.

1 change: 0 additions & 1 deletion test_data/rls-analysis/liblog-1832710545ff9d45.json

This file was deleted.

1 change: 1 addition & 0 deletions test_data/rls-analysis/liblog-d22cd0932fa5c1b3.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test_data/rls-analysis/libquote-9882ce675b74d9ff.json

This file was deleted.

1 change: 1 addition & 0 deletions test_data/rls-analysis/libquote-b3cf046a798c19b3.json

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test_data/rls-analysis/librls_data-b0b0e86828c2c73b.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test_data/rls-analysis/librls_data-c632caeb3a7db3c1.json

This file was deleted.

1 change: 1 addition & 0 deletions test_data/rls-analysis/librls_data-fb652b43586148ed.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test_data/rls-analysis/librls_span-3037c86ab62b5ca6.json

This file was deleted.

1 change: 1 addition & 0 deletions test_data/rls-analysis/librls_span-38da590cd9f4aa4f.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test_data/rls-analysis/libsyn-7e8a0ad620b4e083.json

This file was deleted.

1 change: 1 addition & 0 deletions test_data/rls-analysis/libsyn-e39deb67629c1e59.json

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test_data/rust-analysis/liballoc-bad119b0f880de53.json

Large diffs are not rendered by default.

Loading