Hello community, here is the log from the commit of package racer for openSUSE:Factory checked in at 2017-11-29 10:52:37 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/racer (Old) and /work/SRC/openSUSE:Factory/.racer.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "racer" Wed Nov 29 10:52:37 2017 rev:6 rq:545596 version:2.0.12 Changes: -------- --- /work/SRC/openSUSE:Factory/racer/racer.changes 2017-09-07 22:16:12.809615133 +0200 +++ /work/SRC/openSUSE:Factory/.racer.new/racer.changes 2017-11-29 10:52:40.796606685 +0100 @@ -1,0 +2,8 @@ +Sun Nov 26 00:15:30 UTC 2017 - jones...@protonmail.com + +- Update to 2.0.12 + + Fix bug that broke completions in previous release +- Version 2.0.11 + + Use rustup to find libstd path even when used as library + +------------------------------------------------------------------- Old: ---- racer-2.0.10.tar.gz New: ---- racer-2.0.12.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ racer.spec ++++++ --- /var/tmp/diff_new_pack.tLbsCd/_old 2017-11-29 10:52:43.928493062 +0100 +++ /var/tmp/diff_new_pack.tLbsCd/_new 2017-11-29 10:52:43.928493062 +0100 @@ -4,7 +4,7 @@ # Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2016 Michal Vyskocil, michal.vysko...@opensuse.org # Copyright (c) 2016 Kristoffer Gronlund, kgronl...@suse.com -# Copyright (c) 2017 Luke Jones, luke.nukem.jo...@gmail.com +# Copyright (c) 2017 Luke Jones, jones...@protonmail.com # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -20,7 +20,7 @@ Name: racer -Version: 2.0.10 +Version: 2.0.12 Release: 0 Summary: Code completion for Rust License: MIT ++++++ README.packager ++++++ --- /var/tmp/diff_new_pack.tLbsCd/_old 2017-11-29 10:52:43.968491611 +0100 +++ /var/tmp/diff_new_pack.tLbsCd/_new 2017-11-29 10:52:43.972491466 +0100 @@ -2,11 +2,13 @@ 1. Install cargo and cargo-vendor from devel:languages:rust -2. Clone the wanted version of the package and archive it +2. If there is no official release available for d/l, then you will need + to clone the wanted version of the package and archive it. + See the list of version tags with 'git tag -l' git clone https://github.com/phildawes/racer - cd cargo - git checkout -b packaged-version 1.2.5 + cd racer + git checkout 1.2.5 git archive --format=tar --prefix=racer-1.2.5/ HEAD | xz >racer-1.2.5.tar.xz 3. Generate the vendor package @@ -15,3 +17,33 @@ tar c vendor/ | xz > vendor.tar.xz 3. Update the OBS package with these .tar.xz archives. + +4. The required cargo config will be different to what cargo vendor outputs, + if there is not already a config in the package, then the following is + required: + + %prep + %setup -q + %setup -q -D -T -a 1 + mkdir cargo-home + cat >cargo-home/config <<EOF + [source.crates-io] + registry = 'https://github.com/rust-lang/crates.io-index' + replace-with = 'vendored-sources' + [source.vendored-sources] + directory = './vendor' + EOF + + %build + export CARGO_HOME=`pwd`/cargo-home/ + cargo build --release %{?_smp_mflags} + + %install + mkdir build + export CARGO_HOME=`pwd`/cargo-home/ + cargo install --root=build + mkdir -p %{buildroot}%{_bindir} + install -Dm0755 build/bin/racer %{buildroot}%{_bindir}/racer + + This method of packaging Rust programs and libraries is likely to change in + the near future. \ No newline at end of file ++++++ racer-2.0.10.tar.gz -> racer-2.0.12.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/CHANGELOG.md new/racer-2.0.12/CHANGELOG.md --- old/racer-2.0.10/CHANGELOG.md 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/CHANGELOG.md 2017-10-31 17:45:52.000000000 +0100 @@ -8,6 +8,14 @@ No changes, yet! +## 2.0.12 + +- Fix bug that broke completions in previous release #807 + +## 2.0.11 + +- Use `rustup` to find libstd path even when used as library #799 + ## 2.0.10 - Support resolving `use as` aliases declared in multi-element `use` statements #753 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/Cargo.lock new/racer-2.0.12/Cargo.lock --- old/racer-2.0.10/Cargo.lock 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/Cargo.lock 2017-10-31 17:45:52.000000000 +0100 @@ -1,19 +1,3 @@ -[root] -name = "racer" -version = "2.0.10" -dependencies = [ - "clap 2.24.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_errors 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "typed-arena 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "aho-corasick" version = "0.5.3" @@ -33,7 +17,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -44,20 +28,20 @@ [[package]] name = "bitflags" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" -version = "2.24.2" +version = "2.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -75,21 +59,34 @@ version = "0.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "conv" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "custom_derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "env_logger" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -109,17 +106,34 @@ [[package]] name = "libc" -version = "0.2.22" +version = "0.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.3.7" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "magenta" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "magenta-sys" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "matches" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -127,7 +141,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -141,11 +155,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "racer" +version = "2.0.12" +dependencies = [ + "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_errors 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "rand" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -188,11 +218,11 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -210,18 +240,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_errors 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "term" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -234,17 +264,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "textwrap" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "thread-id" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -272,18 +311,8 @@ ] [[package]] -name = "typed-arena" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "unicode-normalization" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-segmentation" -version = "1.2.0" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -321,20 +350,24 @@ "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" "checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" -"checksum clap 2.24.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b8f69e518f967224e628896b54e41ff6acfb4dcfefc5076325c36525dac900f" +"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" +"checksum clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3451e409013178663435d6f15fdb212f14ee4424a3d74f979d081d0a66b6f1f2" "checksum clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "5b4fabf979ddf6419a313c1c0ada4a5b95cfd2049c56e8418d622d27b4b6ff32" "checksum clippy_lints 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "ce96ec05bfe018a0d5d43da115e54850ea2217981ff0f2e462780ab9d594651a" +"checksum conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299" +"checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" "checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" -"checksum libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "babb8281da88cba992fa1f4ddec7d63ed96280a1a53ec9b919fd37b53d71e502" -"checksum log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5141eca02775a762cc6cd564d8d2c50f67c0ea3a372cbf1c51592b3e029e10ad" -"checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" +"checksum libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d1419b2939a0bc44b77feb34661583c7546b532b192feab36249ab584b86856c" +"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" +"checksum magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf0336886480e671965f794bc9b6fce88503563013d1bfb7a502c81fe3ac527" +"checksum magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40d014c7011ac470ae28e2f76a02bfea4a8480f73e701353b49ad7a8d75f4699" +"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce" "checksum quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45" -"checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d" +"checksum rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb250fd207a4729c976794d03db689c9be1d634ab5a1c9da9492a13d8fecbcdf" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" @@ -343,15 +376,14 @@ "checksum syntex_errors 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9e52bffe6202cfb67587784cf23e0ec5bf26d331eef4922a16d5c42e12aa1e9b" "checksum syntex_pos 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)" = "955ef4b16af4c468e4680d1497f873ff288f557d338180649e18f915af5e15ac" "checksum syntex_syntax 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)" = "76a302e717e348aa372ff577791c3832395650073b8d8432f8b3cb170b34afde" -"checksum term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d168af3930b369cfe245132550579d47dfd873d69470755a19c2c6568dbbd989" +"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" "checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209" +"checksum textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df8e08afc40ae3459e4838f303e465aa50d823df8d7f83ca88108f6d3afe7edd" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" "checksum toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "0590d72182e50e879c4da3b11c6488dae18fccb1ae0c7a3eda18e16795844796" "checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" -"checksum typed-arena 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5934776c3ac1bea4a9d56620d6bf2d483b20d394e49581db40f187e1118ff667" -"checksum unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e28fa37426fceeb5cf8f41ee273faa7c82c47dc8fba5853402841e665fcd86ff" -"checksum unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8083c594e02b8ae1654ae26f0ade5158b119bd88ad0e8227a5d8fcd72407946" +"checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" "checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" "checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/Cargo.toml new/racer-2.0.12/Cargo.toml --- old/racer-2.0.10/Cargo.toml 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/Cargo.toml 2017-10-31 17:45:52.000000000 +0100 @@ -1,7 +1,7 @@ [package] name = "racer" -version = "2.0.10" +version = "2.0.12" license = "MIT" description = "Code completion for Rust" authors = ["Phil Dawes <p...@phildawes.net>"] @@ -26,8 +26,8 @@ syntex_errors = "0.52.0" toml = "0.2.1" env_logger = "0.3.4" -typed-arena = "1.2" clap = "2.19" +lazy_static = "0.2" [dependencies.clippy] version = "0.0.103" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/README.md new/racer-2.0.12/README.md --- old/racer-2.0.10/README.md 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/README.md 2017-10-31 17:45:52.000000000 +0100 @@ -58,6 +58,10 @@ Gedit integration can be found [here](https://github.com/isamert/gracer). +### Builder integration + +Gnome Builder integration can be found [here](https://github.com/deikatsuo/bracer) + ### Kate integration The Kate community maintains a [plugin](https://cgit.kde.org/kate.git/tree/addons/rustcompletion). It is bundled with recent releases of Kate (tested with 16.08 - read more [here](https://blogs.kde.org/2015/05/22/updates-kates-rust-plugin-syntax-highlighting-and-rust-source-mime-type)). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/src/bin/main.rs new/racer-2.0.12/src/bin/main.rs --- old/racer-2.0.10/src/bin/main.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/src/bin/main.rs 2017-10-31 17:45:52.000000000 +0100 @@ -1,6 +1,4 @@ #[macro_use] extern crate log; -extern crate syntex_syntax; -extern crate toml; extern crate env_logger; #[macro_use] extern crate clap; @@ -182,7 +180,7 @@ } fn validate_rust_src_path_env_var() { - match racer::check_rust_src_env_var() { + match racer::get_rust_src_path() { Ok(_) => (), Err(err) => { println!("{}", err); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/src/racer/ast.rs new/racer-2.0.12/src/racer/ast.rs --- old/racer-2.0.10/src/racer/ast.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/src/racer/ast.rs 2017-10-31 17:45:52.000000000 +0100 @@ -114,9 +114,9 @@ ast::ViewPathList(ref pth, ref paths) => { let basepath = to_racer_path(pth); for path in paths { - /// Figure out the identifier being introduced to the local - /// namespace. This will differ from the import name if an `as` - /// was used. + // Figure out the identifier being introduced to the local + // namespace. This will differ from the import name if an `as` + // was used. let ident = path.node.rename.unwrap_or(path.node.name).name.to_string(); let name = path.node.name.name.to_string(); @@ -527,9 +527,10 @@ } ExprKind::Path(_, ref path) => { debug!("expr is a path {:?}", to_racer_path(path)); + let codemap::BytePos(lo) = path.span.lo; self.result = resolve_ast_path(path, &self.scope.filepath, - self.scope.point, + self.scope.point + lo as usize, self.session).and_then(|m| { let msrc = self.session.load_file_and_mask_comments(&m.filepath); typeinf::get_type_of_match(m, msrc.as_src(), self.session) @@ -695,10 +696,46 @@ }; } + ExprKind::Match(_, ref arms) => { + debug!("match expr"); + + for arm in arms { + self.visit_expr(&arm.body); + + // All match arms need to return the same result, so if we found a result + // we can end the search. + if self.result.is_some() { + break; + } + } + } + + ExprKind::If(_, ref block, ref else_block) | + ExprKind::IfLet(_, _, ref block, ref else_block) => { + debug!("if/iflet expr"); + + visit::walk_block(self, &block); + + // if the block does not resolve to a type, try the else block + if self.result.is_none() && else_block.is_some() { + self.visit_expr(&else_block.as_ref().unwrap()); + } + } + + ExprKind::Block(ref block) => { + debug!("block expr"); + visit::walk_block(self, &block); + } + _ => { debug!("- Could not match expr node type: {:?}",expr.node); } - } + }; + } + + fn visit_mac(&mut self, mac: &ast::Mac) { + // Just do nothing if we see a macro, but also prevent the panic! in the default impl. + debug!("ignoring visit_mac: {:?}", mac); } } @@ -1117,7 +1154,8 @@ scope: scope, session: session, srctxt: stmtstr.clone(), - pos: pos, result: None + pos: pos, + result: None }; if let Some(stmt) = string_to_stmt(stmtstr) { visit::walk_stmt(&mut v, &stmt); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/src/racer/cargo.rs new/racer-2.0.12/src/racer/cargo.rs --- old/racer-2.0.10/src/racer/cargo.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/src/racer/cargo.rs 2017-10-31 17:45:52.000000000 +0100 @@ -518,8 +518,34 @@ fn find_cargo_tomlfile<P>(file: P) -> Option<PathBuf> where P: Into<PathBuf> { - find_next_crate_root(file) - .map(|mut f| { f.push("Cargo.toml"); f }) + find_next_crate_root(file).map(|mut f| { + f.push("Cargo.toml"); + f + }) +} + +/// Find workspace root by traversing up the directory tree +/// +/// Checks every Cargo.toml found while searching up the directory tree to see if it has a +/// [workspace] section in its top level. +fn find_workspace_root<P>(path: P) -> Option<PathBuf> + where P: Into<PathBuf> +{ + let mut path = path.into(); + path.push("Cargo.toml"); + trace!("find_workspace_root checking {:?}", path); + if path.exists() && + parse_toml_file(&path).as_ref().and_then(|toml| toml.get("workspace")).is_some() { + trace!("find_workspace_root found workspace section in {:?}", path); + path.pop(); + Some(path) + } else if path.pop() && path.pop() { + // If we haven't found the root and there is still more to search, discard the current + // Cargo.toml, move up a directory, and try again. + find_workspace_root(path) + } else { + None + } } /// Find crate root by traversing up the directory tree searching @@ -673,9 +699,18 @@ if let Some(tomlfile) = find_cargo_tomlfile(from_path.to_path_buf()) { // look in the lockfile first, if there is one + // also search workspaces for a lockfile trace!("get_crate_file tomlfile is {:?}", tomlfile); + + let absolute_path = env::current_dir().unwrap().join(from_path); + let workspace = find_workspace_root(absolute_path); + let mut lockfile = tomlfile.clone(); lockfile.pop(); + if let Some(workspace) = workspace { + lockfile = workspace; + trace!("get_crate_file workspace is {:?}", lockfile); + } lockfile.push("Cargo.lock"); if lockfile.exists() { if let Some(f) = find_src_via_lockfile(kratename, &lockfile) { @@ -686,18 +721,19 @@ } // oh, no luck with the lockfile. Try the tomlfile - return find_src_via_tomlfile(kratename, &tomlfile) + return find_src_via_tomlfile(kratename, &tomlfile); } None } #[cfg(test)] mod tests { + extern crate env_logger; use std::path::PathBuf; #[test] fn get_crate_file_from_overrides() { - let _ = ::env_logger::init(); + let _ = env_logger::init(); let mut start_from = PathBuf::from(env!("CARGO_MANIFEST_DIR")); start_from.push("fixtures"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/src/racer/core.rs new/racer-2.0.12/src/racer/core.rs --- old/racer-2.0.10/src/racer/core.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/src/racer/core.rs 2017-10-31 17:45:52.000000000 +0100 @@ -84,7 +84,7 @@ } /// Context, source, and etc. for detected completion or definition -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub struct Match { pub matchstr: String, pub filepath: path::PathBuf, @@ -249,7 +249,7 @@ } // The racer implementation of an ast::Path. Difference is that it is Send-able -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub struct Path { pub global: bool, pub segments: Vec<PathSegment> @@ -336,7 +336,7 @@ } } -#[derive(Debug,Clone)] +#[derive(Debug, Clone, PartialEq)] pub struct PathSegment { pub name: String, pub types: Vec<Path> @@ -352,7 +352,7 @@ } /// Information about generic types in a match -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub struct PathSearch { pub path: Path, pub filepath: path::PathBuf, @@ -997,9 +997,9 @@ let line = src_text[linestart..pos].trim().rsplit(';').nth(0).unwrap(); debug!("Complete path with line: {:?}", line); - /// Test if the **path expression** starts with `::`, in which case the path - /// should be checked against the global namespace rather than the items currently - /// in scope. + // Test if the **path expression** starts with `::`, in which case the path + // should be checked against the global namespace rather than the items currently + // in scope. let is_global = expr.starts_with("::"); let is_use = line.starts_with("use "); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/src/racer/lib.rs new/racer-2.0.12/src/racer/lib.rs --- old/racer-2.0.10/src/racer/lib.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/src/racer/lib.rs 2017-10-31 17:45:52.000000000 +0100 @@ -5,12 +5,11 @@ #![cfg_attr(all(feature = "clippy", not(test)), deny(print_stdout))] #[macro_use] extern crate log; +#[macro_use] extern crate lazy_static; extern crate syntex_syntax; extern crate syntex_errors; extern crate toml; -extern crate env_logger; -extern crate typed_arena; #[macro_use] mod testutils; @@ -33,4 +32,4 @@ pub use core::{FileCache, Session, Coordinate, Location, FileLoader, Point, SourceByteRange}; pub use util::expand_ident; -pub use util::{RustSrcPathError, check_rust_src_env_var}; +pub use util::{RustSrcPathError, get_rust_src_path}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/src/racer/matchers.rs new/racer-2.0.12/src/racer/matchers.rs --- old/racer-2.0.10/src/racer/matchers.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/src/racer/matchers.rs 2017-10-31 17:45:52.000000000 +0100 @@ -59,8 +59,8 @@ // optional (pub\s+)?(unsafe\s+)? for pat in ["pub", "unsafe"].into_iter() { if src[start..].starts_with(pat) { - /// Rust added support for `pub(in codegen)`; we need to consume the visibility - /// specifier for the rest of the code to keep working. + // Rust added support for `pub(in codegen)`; we need to consume the visibility + // specifier for the rest of the code to keep working. let allow_scope = pat == &"pub"; let mut levels = 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/src/racer/nameres.rs new/racer-2.0.12/src/racer/nameres.rs --- old/racer-2.0.10/src/racer/nameres.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/src/racer/nameres.rs 2017-10-31 17:45:52.000000000 +0100 @@ -3,20 +3,22 @@ use {core, ast, matchers, scopes, typeinf}; use core::SearchType::{self, ExactMatch, StartsWith}; use core::{Match, Src, Session, Coordinate, SessionExt, Ty, Point}; -use core::MatchType::{Module, Function, Struct, Enum, FnArg, Trait, StructField, Impl, TraitImpl, MatchArm, Builtin}; +use core::MatchType::{Module, Function, Struct, Enum, FnArg, Trait, StructField, + Impl, TraitImpl, MatchArm, Builtin}; use core::Namespace; -use util::{self, closure_valid_arg_scope, symbol_matches, txt_matches, find_ident_end}; + +use util::{self, closure_valid_arg_scope, symbol_matches, txt_matches, + find_ident_end, get_rust_src_path}; use matchers::find_doc; use cargo; use std::path::{Path, PathBuf}; -use std::{self, vec}; +use std::{self, vec, iter}; use matchers::PendingImports; -#[cfg(unix)] -pub const PATH_SEP: char = ':'; -#[cfg(windows)] -pub const PATH_SEP: char = ';'; +lazy_static! { + pub static ref RUST_SRC_PATH: PathBuf = get_rust_src_path().unwrap(); +} fn search_struct_fields(searchstr: &str, structmatch: &Match, search_type: SearchType, session: &Session) -> vec::IntoIter<Match> { @@ -502,7 +504,7 @@ return true; } - /// Remove visibility declarations, such as restricted visibility + // Remove visibility declarations, such as restricted visibility let trimmed = if preblock.starts_with("pub") { util::trim_visibility(preblock) } else { @@ -575,21 +577,33 @@ out.into_iter() } +#[test] +fn test_do_file_search() { + let cache = core::FileCache::default(); + let session = Session::new(&cache); + let mut matches = do_file_search("std", &Path::new("."), &session); + + assert!(matches.len() > 1); + + let first_match = matches.next().unwrap(); + + assert!(first_match.filepath.ends_with("src/libstd/lib.rs")); +} + pub fn do_file_search( searchstr: &str, currentdir: &Path, session: &Session ) -> vec::IntoIter<Match> { - debug!("do_file_search {}", searchstr); + debug!("do_file_search with search string \"{}\"", searchstr); let mut out = Vec::new(); - let srcpaths = std::env::var("RUST_SRC_PATH").unwrap_or("".into()); - debug!("do_file_search srcpaths {}", srcpaths); - let mut v = srcpaths.split(PATH_SEP).collect::<Vec<_>>(); - v.push(currentdir.to_str().unwrap()); - debug!("do_file_search v is {:?}", v); - for srcpath in v.into_iter() { - if let Ok(iter) = std::fs::read_dir(Path::new(srcpath)) { + let srcpath = RUST_SRC_PATH.as_ref(); + debug!("do_file_search srcpath: {:?}", srcpath); + let v = &[srcpath, currentdir][..]; + debug!("do_file_search v: {:?}", v); + for srcpath in v { + if let Ok(iter) = std::fs::read_dir(srcpath) { for fpath_buf in iter.filter_map(|res| res.ok().map(|entry| entry.path())) { // skip filenames that can't be decoded let fname = match fpath_buf.file_name().and_then(|n| n.to_str()) { @@ -730,23 +744,20 @@ return Some(p); } - let srcpaths = std::env::var("RUST_SRC_PATH").expect("RUST_SRC_PATH is set"); - let v = srcpaths.split(PATH_SEP).collect::<Vec<_>>(); - for srcpath in v.into_iter() { - { - // try lib<name>/lib.rs, like in the rust source dir - let cratelibname = format!("lib{}", name); - let filepath = Path::new(srcpath).join(cratelibname).join("lib.rs"); - if filepath.exists() || session.contains_file(&filepath) { - return Some(filepath); - } - } - { - // try <name>/lib.rs - let filepath = Path::new(srcpath).join(name).join("lib.rs"); - if filepath.exists() || session.contains_file(&filepath) { - return Some(filepath); - } + let srcpath = &*RUST_SRC_PATH; + { + // try lib<name>/lib.rs, like in the rust source dir + let cratelibname = format!("lib{}", name); + let filepath = srcpath.join(cratelibname).join("lib.rs"); + if filepath.exists() || session.contains_file(&filepath) { + return Some(filepath); + } + } + { + // try <name>/lib.rs + let filepath = srcpath.join(name).join("lib.rs"); + if filepath.exists() || session.contains_file(&filepath) { + return Some(filepath); } } None @@ -1091,29 +1102,21 @@ let mut out : Vec<Match> = Vec::new(); // find the prelude file from the search path and scan it - let srcpaths = match std::env::var("RUST_SRC_PATH") { - Ok(paths) => paths, - Err(_) => return out.into_iter() - }; - - let v = srcpaths.split(PATH_SEP).collect::<Vec<_>>(); - - for srcpath in v.into_iter() { - let filepath = Path::new(srcpath).join("libstd").join("prelude").join("v1.rs"); - if filepath.exists() || session.contains_file(&filepath) { - let msrc = session.load_file_and_mask_comments(&filepath); - let is_local = true; - for m in search_scope(0, 0, msrc.as_src(), pathseg, &filepath, search_type, is_local, namespace, session, pending_imports) { - out.push(m); - } + let srcpath = &*RUST_SRC_PATH; + let filepath = srcpath.join("libstd").join("prelude").join("v1.rs"); + if filepath.exists() || session.contains_file(&filepath) { + let msrc = session.load_file_and_mask_comments(&filepath); + let is_local = true; + for m in search_scope(0, 0, msrc.as_src(), pathseg, &filepath, search_type, is_local, namespace, session, pending_imports) { + out.push(m); } } out.into_iter() } pub fn resolve_path_with_str(path: &core::Path, filepath: &Path, pos: Point, - search_type: SearchType, namespace: Namespace, - session: &Session) -> vec::IntoIter<Match> { + search_type: SearchType, namespace: Namespace, + session: &Session) -> vec::IntoIter<Match> { debug!("resolve_path_with_str {:?}", path); let mut out = Vec::new(); @@ -1159,7 +1162,7 @@ } /// Attempt to resolve a name which occurs in a given file. -pub(crate) fn resolve_name(pathseg: &core::PathSegment, filepath: &Path, pos: Point, +pub fn resolve_name(pathseg: &core::PathSegment, filepath: &Path, pos: Point, search_type: SearchType, namespace: Namespace, session: &Session, pending_imports: &PendingImports) -> vec::IntoIter<Match> { let mut out = Vec::new(); @@ -1401,7 +1404,7 @@ } } -pub(crate) fn resolve_method(point: Point, msrc: Src, searchstr: &str, +pub fn resolve_method(point: Point, msrc: Src, searchstr: &str, filepath: &Path, search_type: SearchType, session: &Session, pending_imports: &PendingImports) -> Vec<Match> { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/src/racer/scopes.rs new/racer-2.0.12/src/racer/scopes.rs --- old/racer-2.0.10/src/racer/scopes.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/src/racer/scopes.rs 2017-10-31 17:45:52.000000000 +0100 @@ -366,17 +366,27 @@ assert_eq!((2, 5), expand_search_expr("..foo", 4)) } +fn fill_gaps(buffer: &str, result: &mut String, start: usize, prev: usize) { + for _ in 0..((start-prev)/buffer.len()) { result.push_str(buffer); } + result.push_str(&buffer[..((start-prev)%buffer.len())]); +} + pub fn mask_comments(src: Src) -> String { let mut result = String::with_capacity(src.len()); let buf_byte = &[b' '; 128]; let buffer = from_utf8(buf_byte).unwrap(); let mut prev: usize = 0; for (start, end) in src.chunk_indices() { - for _ in 0..((start-prev)/128) { result.push_str(buffer); } - result.push_str(&buffer[..((start-prev)%128)]); + fill_gaps(buffer, &mut result, start, prev); result.push_str(&src[start..end]); prev = end; } + + // Fill up if the comment was at the end + if src.len() > prev { + fill_gaps(buffer, &mut result, src.len(), prev); + } + result } @@ -400,17 +410,14 @@ }, b'}' => { if levels == 1 { - let num_spaces = pos-start; - for _ in 0..(num_spaces/128) { result.push_str(buffer); } - result.push_str(&buffer[..((num_spaces)%128)]); + fill_gaps(buffer, &mut result, pos, start); result.push_str("}"); start = pos; } levels -= 1; }, b'\n' if levels > 0 => { - for _ in 0..((pos-start)/128) { result.push_str(buffer); } - result.push_str(&buffer[..((pos-start)%128)]); + fill_gaps(buffer, &mut result, pos, start); result.push('\n'); start = pos+1; }, @@ -421,8 +428,7 @@ start = pos; } if levels > 0 { - for _ in 0..((pos - start)/128) { result.push_str(buffer); } - result.push_str(&buffer[..((pos-start)%128)]); + fill_gaps(buffer, &mut result, pos, start); } else { result.push_str(&src[start..pos]); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/src/racer/typeinf.rs new/racer-2.0.12/src/racer/typeinf.rs --- old/racer-2.0.10/src/racer/typeinf.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/src/racer/typeinf.rs 2017-10-31 17:45:52.000000000 +0100 @@ -28,12 +28,12 @@ } pub fn first_param_is_self(blob: &str) -> bool { - /// Restricted visibility introduces the possibility of `pub(in ...)` at the start - /// of a method declaration. To counteract this, we restrict the search to only - /// look at text _after_ the visibility declaration. - /// - /// Having found the end of the visibility declaration, we now start the search - /// for method parameters. + // Restricted visibility introduces the possibility of `pub(in ...)` at the start + // of a method declaration. To counteract this, we restrict the search to only + // look at text _after_ the visibility declaration. + // + // Having found the end of the visibility declaration, we now start the search + // for method parameters. let blob = util::trim_visibility(blob); // skip generic arg @@ -153,7 +153,7 @@ debug!("get_type_of_let_expr calling parse_let |{}|", blob); let pos = m.point - point - start; - let scope = Scope{ filepath: m.filepath.clone(), point: m.point }; + let scope = Scope{ filepath: m.filepath.clone(), point: point }; ast::get_let_type(blob.to_owned(), pos, scope, session) } else { None @@ -172,7 +172,7 @@ debug!("get_type_of_let_block_expr calling get_let_type |{}|", blob); let pos = m.point - stmtstart - point - start; - let scope = Scope{ filepath: m.filepath.clone(), point: m.point }; + let scope = Scope{ filepath: m.filepath.clone(), point: stmtstart }; ast::get_let_type(blob.to_owned(), pos, scope, session) } else { None @@ -208,7 +208,7 @@ debug!("get_type_of_for_expr: |{}| {} {} {} {}", blob, m.point, stmtstart, forpos, start); let pos = m.point + 8 - stmtstart - forpos - start; - let scope = Scope{ filepath: m.filepath.clone(), point: m.point + 8 }; + let scope = Scope{ filepath: m.filepath.clone(), point: stmtstart }; ast::get_let_type(blob.to_owned(), pos, scope, session) } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/src/racer/util.rs new/racer-2.0.12/src/racer/util.rs --- old/racer-2.0.10/src/racer/util.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/src/racer/util.rs 2017-10-31 17:45:52.000000000 +0100 @@ -4,9 +4,13 @@ use std::rc::Rc; use core::{IndexedSource, Session, SessionExt, Location, LocationExt, Point}; - use core::SearchType::{self, ExactMatch, StartsWith}; +#[cfg(unix)] +pub const PATH_SEP: char = ':'; +#[cfg(windows)] +pub const PATH_SEP: char = ';'; + pub fn is_pattern_char(c: char) -> bool { c.is_alphanumeric() || c.is_whitespace() || (c == '_') || (c == ':') || (c == '.') } @@ -259,7 +263,7 @@ /// Error type returned from [`check_rust_src_env_var()`] /// /// [`check_rust_src_env_var()`]: fn.check_rust_src_env_var.html -#[derive(Debug)] +#[derive(Debug, PartialEq)] pub enum RustSrcPathError { Missing, DoesNotExist(path::PathBuf), @@ -323,25 +327,32 @@ None } -/// Check for `RUST_SRC_PATH` environment variable validity and presence +/// Get the path for Rust standard library source code. +/// Checks first the paths in the `RUST_SRC_PATH` environment variable. +/// +/// If the environment variable is _not_ set, it checks the rust sys +/// root for the `rust-src` component. /// -/// If the environment variable is _not_ set, try and set it from the rust sys -/// root. +/// If that isn't available, checks `/usr/local/src/rust/src` and +/// `/usr/src/rust/src` as default values. /// -/// If the rust src path is there and valid or can be set, Ok(()) is returned. -/// Otherwise, an error with the appropriate reason is provided. +/// If the Rust standard library source code cannot be found, returns +/// `Err(racer::RustSrcPathError::Missing)`. +/// +/// If the path in `RUST_SRC_PATH` or the path in rust sys root is invalid, +/// returns a corresponding error. If a valid path is found, returns that path. /// /// # Examples /// /// ``` /// extern crate racer; /// -/// match racer::check_rust_src_env_var() { -/// Ok(()) => { +/// match racer::get_rust_src_path() { +/// Ok(_path) => { /// // RUST_SRC_PATH is valid /// }, /// Err(racer::RustSrcPathError::Missing) => { -/// // path is not set or not found in sysroot +/// // path is not set /// }, /// Err(racer::RustSrcPathError::DoesNotExist(_path)) => { /// // provided path doesnt point to valid file @@ -351,54 +362,165 @@ /// } /// } /// ``` -pub fn check_rust_src_env_var() -> ::std::result::Result<(), RustSrcPathError> { +pub fn get_rust_src_path() -> ::std::result::Result<path::PathBuf, RustSrcPathError> { use std::env; - use nameres; - match env::var("RUST_SRC_PATH") { - Ok(ref srcpaths) if !srcpaths.is_empty() => { - // TODO implementation has the same behavior as the original - // (before returning an error) where only the first path in - // RUST_SRC_PATH is considered. This should either expect a single - // path to be provided, or all paths should be considered. The - // latter option would need to be supported in the rest of racer. - - // Unwrap is ok here since split returns the original string - // even if it doesn't contain the split pattern. - let v = srcpaths.split(nameres::PATH_SEP).next().unwrap(); - let f = path::Path::new(v); - if !f.exists() { - Err(RustSrcPathError::DoesNotExist(f.to_path_buf())) - } else if !f.join("libstd").exists() { - Err(RustSrcPathError::NotRustSourceTree(f.join("libstd"))) - } else { - Ok(()) - } - }, - _ => { - if let Some(path) = check_rust_sysroot() { - env::set_var("RUST_SRC_PATH", path); - Ok(()) - } else { - let default_paths = [ - "/usr/local/src/rust/src", - "/usr/src/rust/src", - ]; - - for &path in &default_paths { - let f = path::Path::new(path); - if f.exists() { - env::set_var("RUST_SRC_PATH", path); - return Ok(()) - } - } + debug!("Getting rust source path. Trying env var RUST_SRC_PATH."); - Err(RustSrcPathError::Missing) + if let Ok(ref srcpaths) = env::var("RUST_SRC_PATH") { + if !srcpaths.is_empty() { + for path in srcpaths.split(PATH_SEP) { + return validate_rust_src_path(path::PathBuf::from(path)); } } + }; + + debug!("Nope. Trying rustc --sysroot and appending lib/rustlib/src/rust/src to that."); + + if let Some(path) = check_rust_sysroot() { + return validate_rust_src_path(path); + }; + + debug!("Nope. Trying default paths: /usr/local/src/rust/src and /usr/src/rust/src"); + + let default_paths = [ + "/usr/local/src/rust/src", + "/usr/src/rust/src", + ]; + + for path in default_paths.iter() { + if let Ok(path) = validate_rust_src_path(path::PathBuf::from(path)) { + return Ok(path); + } + } + + debug!("Nope. Rust source path not found!"); + + return Err(RustSrcPathError::Missing) +} + +fn validate_rust_src_path(path: path::PathBuf) -> ::std::result::Result<path::PathBuf, RustSrcPathError> { + if !path.exists() { + Err(RustSrcPathError::DoesNotExist(path.to_path_buf())) + } else if !path.join("libstd").exists() { + Err(RustSrcPathError::NotRustSourceTree(path.join("libstd"))) + } else { + Ok(path.to_path_buf()) } } +#[cfg(test)] +lazy_static! { + static ref TEST_SEMAPHORE: ::std::sync::Mutex<()> = ::std::sync::Mutex::new(()); +} + +#[test] +fn test_get_rust_src_path_env_ok() { + use std::env; + + let _guard = TEST_SEMAPHORE.lock().unwrap(); + + let original = env::var_os("RUST_SRC_PATH"); + if env::var_os("RUST_SRC_PATH").is_none() { + env::set_var("RUST_SRC_PATH", check_rust_sysroot().unwrap()); + } + let result = get_rust_src_path(); + + match original { + Some(path) => env::set_var("RUST_SRC_PATH", path), + None => env::remove_var("RUST_SRC_PATH"), + } + assert!(result.is_ok()); +} + +#[test] +fn test_get_rust_src_path_does_not_exist() { + use std::env; + + let _guard = TEST_SEMAPHORE.lock().unwrap(); + + let original = env::var_os("RUST_SRC_PATH"); + env::set_var("RUST_SRC_PATH", "test_path"); + let result = get_rust_src_path(); + + match original { + Some(path) => env::set_var("RUST_SRC_PATH", path), + None => env::remove_var("RUST_SRC_PATH"), + } + + assert_eq!(Err(RustSrcPathError::DoesNotExist(path::PathBuf::from("test_path"))), + result); +} + +#[test] +fn test_get_rust_src_path_not_rust_source_tree() { + use std::env; + + let _guard = TEST_SEMAPHORE.lock().unwrap(); + + let original = env::var_os("RUST_SRC_PATH"); + + env::set_var("RUST_SRC_PATH", "/"); + + let result = get_rust_src_path(); + + match original { + Some(path) => env::set_var("RUST_SRC_PATH", path), + None => env::remove_var("RUST_SRC_PATH"), + } + + assert_eq!(Err(RustSrcPathError::NotRustSourceTree(path::PathBuf::from("/libstd"))), + result); + +} + +#[test] +fn test_get_rust_src_path_missing() { + use std::env; + + let _guard = TEST_SEMAPHORE.lock().unwrap(); + + let path = env::var_os("PATH").unwrap(); + let original = env::var_os("RUST_SRC_PATH"); + + env::remove_var("RUST_SRC_PATH"); + env::remove_var("PATH"); + + let result = get_rust_src_path(); + + env::set_var("PATH", path); + match original { + Some(path) => env::set_var("RUST_SRC_PATH", path), + None => env::remove_var("RUST_SRC_PATH"), + } + + assert_eq!(Err(RustSrcPathError::Missing), + result); +} + +#[test] +fn test_get_rust_src_path_rustup_ok() { + use std::env; + + let _guard = TEST_SEMAPHORE.lock().unwrap(); + let original = env::var_os("RUST_SRC_PATH"); + env::remove_var("RUST_SRC_PATH"); + + let result = get_rust_src_path(); + + match original { + Some(path) => env::set_var("RUST_SRC_PATH", path), + None => env::remove_var("RUST_SRC_PATH"), + } + + match result { + Ok(_) => (), + Err(_) => panic!("Couldn't get the path via rustup! \ + Rustup and the component rust-src needs to be installed for this test to pass!"), + } +} + + /// An immutable stack implemented as a linked list backed by a thread's stack. pub struct StackLinkedListNode<'stack, T>(Option<StackLinkedListNodeData<'stack, T>>) where T: 'stack; @@ -483,8 +605,8 @@ /// Checks if the completion point is in a function declaration by looking /// to see if the second-to-last word is `fn`. pub fn in_fn_name(line_before_point: &str) -> bool { - /// Determine if the cursor is sitting in the whitespace after typing `fn ` before - /// typing a name. + // Determine if the cursor is sitting in the whitespace after typing `fn ` before + // typing a name. let has_started_name = !line_before_point.ends_with(|c: char| c.is_whitespace()); let mut words = line_before_point.split_whitespace().rev(); @@ -511,4 +633,4 @@ assert!(in_fn_name("fn ")); assert!(!in_fn_name("fn foo(b")); assert!(!in_fn_name("fn")); -} \ No newline at end of file +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/racer-2.0.10/tests/system.rs new/racer-2.0.12/tests/system.rs --- old/racer-2.0.10/tests/system.rs 2017-07-28 17:49:18.000000000 +0200 +++ new/racer-2.0.12/tests/system.rs 2017-10-31 17:45:52.000000000 +0100 @@ -3982,3 +3982,127 @@ assert_eq!(got.matchstr, "Bar"); assert_eq!(got.mtype, MatchType::Trait); } + +// Issue: https://github.com/racer-rust/racer/issues/755 +#[test] +fn completes_for_match_type_inference_let_expr() { + let _lock = sync!(); + + let src = r#" + use std::fs::File; + + fn main() { + let f = File::open("hey"); + + let f = match f { + Ok(file) => file, + Err(error) => { + panic!("Error opening file: {:?}", error) + } + }; + f.set_p~ermissions(/* args */); + } + "#; + + let got = get_only_completion(src, None); + assert_eq!(got.matchstr, "set_permissions"); + assert_eq!(got.mtype, MatchType::Function); +} + +#[test] +fn completes_for_match_type_inference_let_expr_with_block() { + let _lock = sync!(); + + let src = r#" + use std::fs::File; + + fn main() { + let f = File::open("hey"); + + let f = match f { + Ok(file) => { file }, + Err(error) => { + panic!("Error opening file: {:?}", error) + } + }; + f.set_p~ermissions(/* args */); + } + "#; + + let got = get_only_completion(src, None); + assert_eq!(got.matchstr, "set_permissions"); + assert_eq!(got.mtype, MatchType::Function); +} + +#[test] +fn completes_for_match_type_inference_let_expr_with_return() { + let _lock = sync!(); + + let src = r#" + use std::fs::File; + + fn test() -> String { + let f = File::open("hey"); + + let f = match f { + Err(error) => { + return "result".to_string(); + }, + Ok(file) => { file } + }; + + f.set_p~ermissions(/* args */); + } + "#; + + let got = get_only_completion(src, None); + assert_eq!(got.matchstr, "set_permissions"); + assert_eq!(got.mtype, MatchType::Function); +} + +#[test] +fn completes_for_let_if_let() { + let _lock = sync!(); + + let src = r#" + use std::fs::File; + + fn test() -> String { + let f = File::open("hey"); + + let f = if let Ok(f) = f { f } else { return "result".to_string(); }; + + f.set_p~ermissions(/* args */); + } + "#; + + let got = get_only_completion(src, None); + assert_eq!(got.matchstr, "set_permissions"); + assert_eq!(got.mtype, MatchType::Function); +} + +#[test] +fn completes_for_match_type_inference_with_if() { + let _lock = sync!(); + + let src = r#" + use std::fs::File; + + fn test() -> String { + let f = File::open("hey"); + + let f = match f { + Err(error) => { + return "result".to_string(); + }, + Ok(file) => { if file.sync_data().is_ok() { return "nice".to_string(); } else { file } } + }; + + f.set_p~ermissions(/* args */); + } + "#; + + let got = get_only_completion(src, None); + assert_eq!(got.matchstr, "set_permissions"); + assert_eq!(got.mtype, MatchType::Function); +} ++++++ vendor.tar.xz ++++++ ++++ 55875 lines of diff (skipped)