aboutsummaryrefslogtreecommitdiff
path: root/pkgs/development/tools/rust/rust-analyzer
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/tools/rust/rust-analyzer')
-rw-r--r--pkgs/development/tools/rust/rust-analyzer/default.nix6
-rw-r--r--pkgs/development/tools/rust/rust-analyzer/generic.nix7
-rw-r--r--pkgs/development/tools/rust/rust-analyzer/no-track_env_var.patch120
-rwxr-xr-xpkgs/development/tools/rust/rust-analyzer/update.sh12
-rw-r--r--pkgs/development/tools/rust/rust-analyzer/wrapper.nix5
5 files changed, 13 insertions, 137 deletions
diff --git a/pkgs/development/tools/rust/rust-analyzer/default.nix b/pkgs/development/tools/rust/rust-analyzer/default.nix
index 2e6db32966d4..a398b7e504df 100644
--- a/pkgs/development/tools/rust/rust-analyzer/default.nix
+++ b/pkgs/development/tools/rust/rust-analyzer/default.nix
@@ -2,10 +2,10 @@
{
rust-analyzer-unwrapped = callPackage ./generic.nix rec {
- rev = "2020-10-19";
+ rev = "2020-11-09";
version = "unstable-${rev}";
- sha256 = "1xvyk1d26zn1d9i42h78qsm6bg57nhn1rgr46jwa46gsb31nabjh";
- cargoSha256 = "18s5yrc9fdj2ndylwyf07l0kmwxka7mnbj254xmq3g7ragw71xjw";
+ sha256 = "sha256-SX9dvx2JtYZBxA3+dHQKX/jrjbAMy37/SAybDjlYcSs=";
+ cargoSha256 = "sha256-+td+wMmI+MyGz9oPC+SPO2TmAV0+3lOORNY7xf6s3vI=";
};
rust-analyzer = callPackage ./wrapper.nix {} {
diff --git a/pkgs/development/tools/rust/rust-analyzer/generic.nix b/pkgs/development/tools/rust/rust-analyzer/generic.nix
index ca72f91953cf..1bab5b951837 100644
--- a/pkgs/development/tools/rust/rust-analyzer/generic.nix
+++ b/pkgs/development/tools/rust/rust-analyzer/generic.nix
@@ -16,11 +16,6 @@ rustPlatform.buildRustPackage {
inherit rev sha256;
};
- # FIXME: Temporary fixes for our rust 1.46.0
- patches = [
- ./no-track_env_var.patch # Requires rustc 1.47.0
- ];
-
buildAndTestSubdir = "crates/rust-analyzer";
cargoBuildFlags = lib.optional useMimalloc "--features=mimalloc";
@@ -34,7 +29,7 @@ rustPlatform.buildRustPackage {
inherit doCheck;
preCheck = lib.optionalString doCheck ''
- export RUST_SRC_PATH=${rustPlatform.rustcSrc}
+ export RUST_SRC_PATH=${rustPlatform.rustLibSrc}
'';
doInstallCheck = true;
diff --git a/pkgs/development/tools/rust/rust-analyzer/no-track_env_var.patch b/pkgs/development/tools/rust/rust-analyzer/no-track_env_var.patch
deleted file mode 100644
index f5173c4bacbc..000000000000
--- a/pkgs/development/tools/rust/rust-analyzer/no-track_env_var.patch
+++ /dev/null
@@ -1,120 +0,0 @@
-This patch revert 3d169bd3f4cdc2dc3dd09eadbbc17c19214d69f3 (Add track_env_var to the proc macro server).
-
-diff --git a/crates/proc_macro_srv/src/proc_macro/bridge/client.rs b/crates/proc_macro_srv/src/proc_macro/bridge/client.rs
-index 55d6330cc..cb4b3bdb0 100644
---- a/crates/proc_macro_srv/src/proc_macro/bridge/client.rs
-+++ b/crates/proc_macro_srv/src/proc_macro/bridge/client.rs
-@@ -160,7 +160,6 @@ macro_rules! define_handles {
- }
- define_handles! {
- 'owned:
-- FreeFunctions,
- TokenStream,
- TokenStreamBuilder,
- TokenStreamIter,
-diff --git a/crates/proc_macro_srv/src/proc_macro/bridge/mod.rs b/crates/proc_macro_srv/src/proc_macro/bridge/mod.rs
-index b97886eb9..aeb05aad4 100644
---- a/crates/proc_macro_srv/src/proc_macro/bridge/mod.rs
-+++ b/crates/proc_macro_srv/src/proc_macro/bridge/mod.rs
-@@ -57,10 +57,6 @@ use std::thread;
- macro_rules! with_api {
- ($S:ident, $self:ident, $m:ident) => {
- $m! {
-- FreeFunctions {
-- fn drop($self: $S::FreeFunctions);
-- fn track_env_var(var: &str, value: Option<&str>);
-- },
- TokenStream {
- fn drop($self: $S::TokenStream);
- fn clone($self: &$S::TokenStream) -> $S::TokenStream;
-diff --git a/crates/proc_macro_srv/src/proc_macro/bridge/server.rs b/crates/proc_macro_srv/src/proc_macro/bridge/server.rs
-index 3acb239af..45d41ac02 100644
---- a/crates/proc_macro_srv/src/proc_macro/bridge/server.rs
-+++ b/crates/proc_macro_srv/src/proc_macro/bridge/server.rs
-@@ -11,8 +11,6 @@ use super::client::HandleStore;
- /// Declare an associated item of one of the traits below, optionally
- /// adjusting it (i.e., adding bounds to types and default bodies to methods).
- macro_rules! associated_item {
-- (type FreeFunctions) =>
-- (type FreeFunctions: 'static;);
- (type TokenStream) =>
- (type TokenStream: 'static + Clone;);
- (type TokenStreamBuilder) =>
-diff --git a/crates/proc_macro_srv/src/proc_macro/mod.rs b/crates/proc_macro_srv/src/proc_macro/mod.rs
-index fc6e7344f..ee0dc9722 100644
---- a/crates/proc_macro_srv/src/proc_macro/mod.rs
-+++ b/crates/proc_macro_srv/src/proc_macro/mod.rs
-@@ -924,25 +924,3 @@ impl fmt::Debug for Literal {
- self.0.fmt(f)
- }
- }
--
--pub mod tracked_env {
-- use std::env::{self, VarError};
-- use std::ffi::OsStr;
--
-- /// Retrieve an environment variable and add it to build dependency info.
-- /// Build system executing the compiler will know that the variable was accessed during
-- /// compilation, and will be able to rerun the build when the value of that variable changes.
-- /// Besides the dependency tracking this function should be equivalent to `env::var` from the
-- /// standard library, except that the argument must be UTF-8.
-- pub fn var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
-- use std::ops::Deref;
--
-- let key: &str = key.as_ref();
-- let value = env::var(key);
-- super::bridge::client::FreeFunctions::track_env_var(
-- key,
-- value.as_ref().map(|t| t.deref()).ok(),
-- );
-- value
-- }
--}
-diff --git a/crates/proc_macro_srv/src/rustc_server.rs b/crates/proc_macro_srv/src/rustc_server.rs
-index c5fe3591e..7d1695c86 100644
---- a/crates/proc_macro_srv/src/rustc_server.rs
-+++ b/crates/proc_macro_srv/src/rustc_server.rs
-@@ -242,8 +242,6 @@ impl TokenStreamBuilder {
- }
- }
-
--pub struct FreeFunctions;
--
- #[derive(Clone)]
- pub struct TokenStreamIter {
- trees: IntoIter<TokenTree>,
-@@ -256,7 +254,6 @@ pub struct Rustc {
- }
-
- impl server::Types for Rustc {
-- type FreeFunctions = FreeFunctions;
- type TokenStream = TokenStream;
- type TokenStreamBuilder = TokenStreamBuilder;
- type TokenStreamIter = TokenStreamIter;
-@@ -270,13 +267,6 @@ impl server::Types for Rustc {
- type MultiSpan = Vec<Span>;
- }
-
--impl server::FreeFunctions for Rustc {
-- fn track_env_var(&mut self, _var: &str, _value: Option<&str>) {
-- // FIXME: track env var accesses
-- // https://github.com/rust-lang/rust/pull/71858
-- }
--}
--
- impl server::TokenStream for Rustc {
- fn new(&mut self) -> Self::TokenStream {
- Self::TokenStream::new()
-diff --git a/xtask/src/install.rs b/xtask/src/install.rs
-index fcc4f05e4..d829790d7 100644
---- a/xtask/src/install.rs
-+++ b/xtask/src/install.rs
-@@ -7,7 +7,7 @@ use anyhow::{bail, format_err, Context, Result};
- use crate::not_bash::{pushd, run};
-
- // Latest stable, feel free to send a PR if this lags behind.
--const REQUIRED_RUST_VERSION: u32 = 47;
-+const REQUIRED_RUST_VERSION: u32 = 46;
-
- pub struct InstallCmd {
- pub client: Option<ClientOpt>,
diff --git a/pkgs/development/tools/rust/rust-analyzer/update.sh b/pkgs/development/tools/rust/rust-analyzer/update.sh
index b0435be72083..f08ea67cf22d 100755
--- a/pkgs/development/tools/rust/rust-analyzer/update.sh
+++ b/pkgs/development/tools/rust/rust-analyzer/update.sh
@@ -24,24 +24,24 @@ echo "$old_rev -> $rev"
sha256=$(nix-prefetch -f "$nixpkgs" rust-analyzer-unwrapped.src --rev "$rev")
# Clear cargoSha256 to avoid inconsistency.
-sed -e "s/rev = \".*\"/rev = \"$rev\"/" \
- -e "s/sha256 = \".*\"/sha256 = \"$sha256\"/" \
- -e "s/cargoSha256 = \".*\"/cargoSha256 = \"\"/" \
+sed -e "s#rev = \".*\"#rev = \"$rev\"#" \
+ -e "s#sha256 = \".*\"#sha256 = \"$sha256\"#" \
+ -e "s#cargoSha256 = \".*\"#cargoSha256 = \"\"#" \
--in-place ./default.nix
node_src="$(nix-build "$nixpkgs" -A rust-analyzer.src --no-out-link)/editors/code"
# Check vscode compatibility
req_vscode_ver="$(jq '.engines.vscode' "$node_src/package.json" --raw-output)"
req_vscode_ver="${req_vscode_ver#^}"
-cur_vscode_ver="$(nix eval --raw -f "$nixpkgs" vscode.version)"
-if [[ "$(nix eval "(builtins.compareVersions \"$req_vscode_ver\" \"$cur_vscode_ver\")")" -gt 0 ]]; then
+cur_vscode_ver="$(nix-instantiate --eval --strict "$nixpkgs" -A vscode.version | tr -d '"')"
+if [[ "$(nix-instantiate --eval --strict -E "(builtins.compareVersions \"$req_vscode_ver\" \"$cur_vscode_ver\")")" -gt 0 ]]; then
echo "vscode $cur_vscode_ver is incompatible with the extension requiring ^$req_vscode_ver"
exit 1
fi
echo "Prebuilding for cargoSha256"
cargo_sha256=$(nix-prefetch "{ sha256 }: (import $nixpkgs {}).rust-analyzer-unwrapped.cargoDeps.overrideAttrs (_: { outputHash = sha256; })")
-sed "s/cargoSha256 = \".*\"/cargoSha256 = \"$cargo_sha256\"/" \
+sed "s#cargoSha256 = \".*\"#cargoSha256 = \"$cargo_sha256\"#" \
--in-place ./default.nix
# Update vscode extension
diff --git a/pkgs/development/tools/rust/rust-analyzer/wrapper.nix b/pkgs/development/tools/rust/rust-analyzer/wrapper.nix
index 8ca3ff1a6d20..bed206281826 100644
--- a/pkgs/development/tools/rust/rust-analyzer/wrapper.nix
+++ b/pkgs/development/tools/rust/rust-analyzer/wrapper.nix
@@ -4,7 +4,8 @@ lib.makeOverridable ({
unwrapped,
pname ? "rust-analyzer",
version ? unwrapped.version,
- rustcSrc ? rustPlatform.rustcSrc,
+ # Use name from `RUST_SRC_PATH`
+ rustSrc ? rustPlatform.rustLibSrc,
}: runCommandNoCC "${pname}-${version}" {
inherit pname version;
inherit (unwrapped) src meta;
@@ -12,5 +13,5 @@ lib.makeOverridable ({
} ''
mkdir -p $out/bin
makeWrapper ${unwrapped}/bin/rust-analyzer $out/bin/rust-analyzer \
- --set-default RUST_SRC_PATH "${rustcSrc}"
+ --set-default RUST_SRC_PATH "${rustSrc}"
'')