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

Commit 2dd6a7a

Browse files
authored
Merge pull request #114 from Xanewok/patchwork
Prepare to use rls-data 0.12
2 parents 05f2336 + 72019d7 commit 2dd6a7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+83
-55
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rls-analysis"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
authors = ["Nick Cameron <[email protected]>"]
55
description = "Library for processing rustc's save-analysis data for the RLS"
66
license = "Apache-2.0/MIT"
@@ -10,7 +10,7 @@ categories = ["development-tools"]
1010
[dependencies]
1111
rustc-serialize = "0.3"
1212
log = "0.3"
13-
rls-data = "= 0.11"
13+
rls-data = "= 0.12"
1414
rls-span = "0.4"
1515
derive-new = "0.5"
1616

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ impl<L: AnalysisLoader> AnalysisHost<L> {
487487
match def.parent {
488488
Some(p) => {
489489
analysis.with_defs(p, |parent| match def.kind {
490-
DefKind::Field | DefKind::Method | DefKind::Tuple => {
490+
DefKind::Field | DefKind::Method | DefKind::Tuple |
491+
DefKind::TupleVariant | DefKind::StructVariant => {
491492
let ns = name_space_for_def_kind(def.kind);
492493
let mut res = AnalysisHost::<L>::mk_doc_url(parent, analysis)
493494
.unwrap_or_else(|| "".into());

src/lowering.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,24 @@ impl CrateReader {
108108
// map those when lowering symbols with local crate ids into global registry
109109
// It's worth noting, that we assume that local crate id is 0, whereas
110110
// the external crates will have num in 1..count contiguous range.
111-
trace!("building crate map for {}", prelude.crate_name);
112-
let id = fetch_crate_id(master_crate_map, &prelude.crate_name);
111+
let crate_name = prelude.crate_id.name.clone();
112+
trace!("building crate map for {}", crate_name);
113+
let id = fetch_crate_id(master_crate_map, &crate_name);
113114
let mut crate_map = vec![id];
114-
trace!(" {} -> {}", prelude.crate_name, master_crate_map[&prelude.crate_name]);
115+
trace!(" {} -> {}", crate_name, master_crate_map[&crate_name]);
115116

116117
prelude.external_crates.sort_by(|a, b| a.num.cmp(&b.num));
117118
for c in prelude.external_crates {
118119
assert!(c.num == crate_map.len() as u32);
119-
let id = fetch_crate_id(master_crate_map, &c.name);
120+
let id = fetch_crate_id(master_crate_map, &c.id.name);
120121
crate_map.push(id);
121-
trace!(" {} -> {}", c.name, master_crate_map[&c.name]);
122+
trace!(" {} -> {}", c.id.name, master_crate_map[&c.id.name]);
122123
}
123124

124125
CrateReader {
125126
crate_map,
126127
base_dir: base_dir.to_owned(),
127-
crate_name: prelude.crate_name,
128+
crate_name: crate_name,
128129
}
129130
}
130131

src/raw.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ fn read_crate_data(path: &Path) -> Option<Analysis> {
127127
pub fn name_space_for_def_kind(dk: DefKind) -> char {
128128
match dk {
129129
DefKind::Enum |
130-
DefKind::TupleVariant |
131-
DefKind::StructVariant |
132130
DefKind::Struct |
133131
DefKind::Union |
134132
DefKind::Type |
@@ -141,6 +139,8 @@ pub fn name_space_for_def_kind(dk: DefKind) -> char {
141139
DefKind::Static |
142140
DefKind::Const |
143141
DefKind::Tuple |
142+
DefKind::TupleVariant |
143+
DefKind::StructVariant |
144144
DefKind::Field => 'v',
145145
DefKind::Macro => 'm',
146146
}

src/test/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ fn test_types() {
293293
assert_type(&host, "TestTrait", DefKind::Trait, &[25]);
294294
assert_type(&host, "test_method", DefKind::Method, &[26]);
295295
assert_type(&host, "FooEnum", DefKind::Enum, &[29]);
296-
// TODO: TupleVariant and StructVariant DefKind when rustc uses rls-data 0.11
297-
assert_type(&host, "TupleVariant", DefKind::Tuple, &[30]);
298-
assert_type(&host, "StructVariant", DefKind::Struct, &[31]);
296+
assert_type(&host, "TupleVariant", DefKind::TupleVariant, &[30]);
297+
assert_type(&host, "StructVariant", DefKind::StructVariant, &[31]);
299298
}

test_data/hello/Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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":[]}
1+
{"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":[]}

test_data/make_data.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
# This script reproduces all save-analysis data in the test_data directories.
23

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

1719
# Hello world test case
18-
# cd hello
19-
# RUSTFLAGS=-Zsave-analysis cargo build
20-
# cp target/debug/save-analysis/hello.json save-analysis
21-
# RUSTFLAGS=-Zsave-analysis-api cargo build
22-
# cp target/debug/save-analysis/hello.json save-analysis-api
23-
# cd ..
20+
cd hello
21+
RUSTFLAGS=-Zsave-analysis cargo build
22+
cp target/debug/deps/save-analysis/hello-*.json save-analysis
23+
#RUSTFLAGS=-Zsave-analysis-api cargo build
24+
#cp target/debug/save-analysis/hello.json save-analysis-api
25+
cd ..
2426

2527
# Types
26-
# cd types
27-
# RUSTFLAGS=-Zsave-analysis cargo build
28-
# cp target/debug/save-analysis/types.json save-analysis
29-
# cd ..
28+
cd types
29+
RUSTFLAGS=-Zsave-analysis cargo build
30+
cp target/debug/deps/save-analysis/types-*.json save-analysis
31+
cd ..

test_data/rls-analysis/libderive_new-bde12847971b287b.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)