Merge pull request #118833 from oxalica/rust-analyzer
This commit is contained in:
commit
3272d2f6df
@ -1,16 +1,58 @@
|
|||||||
{ pkgs, callPackage, CoreServices }:
|
{ lib, stdenv, fetchFromGitHub, rustPlatform, CoreServices, cmake
|
||||||
|
, libiconv
|
||||||
|
, useMimalloc ? false
|
||||||
|
, doCheck ? true
|
||||||
|
}:
|
||||||
|
|
||||||
{
|
let
|
||||||
rust-analyzer-unwrapped = callPackage ./generic.nix rec {
|
rev = "2021-04-05";
|
||||||
rev = "2021-03-22";
|
in
|
||||||
version = "unstable-${rev}";
|
|
||||||
sha256 = "sha256-Q8yr5x4+R9UCk5kw/nJgBtGVBeZTDwyuwpyNJUKSPzA=";
|
|
||||||
cargoSha256 = "sha256-cJ5KPNrX1H4IfHENDGyU2rgxl5TTqvoeXk7558oqwuA=";
|
|
||||||
|
|
||||||
inherit CoreServices;
|
rustPlatform.buildRustPackage {
|
||||||
|
pname = "rust-analyzer-unwrapped";
|
||||||
|
version = "unstable-${rev}";
|
||||||
|
cargoSha256 = "sha256-kDwdKa08E0h24lOOa7ALeNqHlMjMry/ru1qwCIyKmuE=";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "rust-analyzer";
|
||||||
|
repo = "rust-analyzer";
|
||||||
|
inherit rev;
|
||||||
|
sha256 = "sha256-ZDxy87F3uz8bTF1/2LIy5r4Nv/M3xe97F7mwJNEFcUs=";
|
||||||
};
|
};
|
||||||
|
|
||||||
rust-analyzer = callPackage ./wrapper.nix {} {
|
buildAndTestSubdir = "crates/rust-analyzer";
|
||||||
unwrapped = pkgs.rust-analyzer-unwrapped;
|
|
||||||
|
cargoBuildFlags = lib.optional useMimalloc "--features=mimalloc";
|
||||||
|
|
||||||
|
nativeBuildInputs = lib.optional useMimalloc cmake;
|
||||||
|
|
||||||
|
buildInputs = lib.optionals stdenv.isDarwin [
|
||||||
|
CoreServices
|
||||||
|
libiconv
|
||||||
|
];
|
||||||
|
|
||||||
|
RUST_ANALYZER_REV = rev;
|
||||||
|
|
||||||
|
inherit doCheck;
|
||||||
|
preCheck = lib.optionalString doCheck ''
|
||||||
|
export RUST_SRC_PATH=${rustPlatform.rustLibSrc}
|
||||||
|
'';
|
||||||
|
|
||||||
|
doInstallCheck = true;
|
||||||
|
installCheckPhase = ''
|
||||||
|
runHook preInstallCheck
|
||||||
|
versionOutput="$($out/bin/rust-analyzer --version)"
|
||||||
|
echo "'rust-analyzer --version' returns: $versionOutput"
|
||||||
|
[[ "$versionOutput" == "rust-analyzer ${rev}" ]]
|
||||||
|
runHook postInstallCheck
|
||||||
|
'';
|
||||||
|
|
||||||
|
passthru.updateScript = ./update.sh;
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "An experimental modular compiler frontend for the Rust language";
|
||||||
|
homepage = "https://github.com/rust-analyzer/rust-analyzer";
|
||||||
|
license = with licenses; [ mit asl20 ];
|
||||||
|
maintainers = with maintainers; [ oxalica ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
{ lib, stdenv, fetchFromGitHub, rustPlatform, CoreServices, cmake
|
|
||||||
, libiconv
|
|
||||||
, useMimalloc ? false
|
|
||||||
, doCheck ? true
|
|
||||||
|
|
||||||
# Version specific args
|
|
||||||
, rev, version, sha256, cargoSha256
|
|
||||||
}:
|
|
||||||
|
|
||||||
rustPlatform.buildRustPackage {
|
|
||||||
pname = "rust-analyzer-unwrapped";
|
|
||||||
inherit version cargoSha256;
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "rust-analyzer";
|
|
||||||
repo = "rust-analyzer";
|
|
||||||
inherit rev sha256;
|
|
||||||
};
|
|
||||||
|
|
||||||
buildAndTestSubdir = "crates/rust-analyzer";
|
|
||||||
|
|
||||||
cargoBuildFlags = lib.optional useMimalloc "--features=mimalloc";
|
|
||||||
|
|
||||||
nativeBuildInputs = lib.optional useMimalloc cmake;
|
|
||||||
|
|
||||||
buildInputs = lib.optionals stdenv.isDarwin [
|
|
||||||
CoreServices
|
|
||||||
libiconv
|
|
||||||
];
|
|
||||||
|
|
||||||
RUST_ANALYZER_REV = rev;
|
|
||||||
|
|
||||||
inherit doCheck;
|
|
||||||
preCheck = lib.optionalString doCheck ''
|
|
||||||
export RUST_SRC_PATH=${rustPlatform.rustLibSrc}
|
|
||||||
'';
|
|
||||||
|
|
||||||
doInstallCheck = true;
|
|
||||||
installCheckPhase = ''
|
|
||||||
runHook preInstallCheck
|
|
||||||
versionOutput="$($out/bin/rust-analyzer --version)"
|
|
||||||
echo "'rust-analyzer --version' returns: $versionOutput"
|
|
||||||
[[ "$versionOutput" == "rust-analyzer ${rev}" ]]
|
|
||||||
runHook postInstallCheck
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru.updateScript = ./update.sh;
|
|
||||||
|
|
||||||
patches = [ ./rust_1_49.patch ];
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description = "An experimental modular compiler frontend for the Rust language";
|
|
||||||
homepage = "https://github.com/rust-analyzer/rust-analyzer";
|
|
||||||
license = with licenses; [ mit asl20 ];
|
|
||||||
maintainers = with maintainers; [ oxalica ];
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs
|
|
||||||
index 4e75a7b14..91f51a1a7 100644
|
|
||||||
--- a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs
|
|
||||||
+++ b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs
|
|
||||||
@@ -93,7 +93,7 @@ fn validate_method_call_expr(
|
|
||||||
let krate = module.krate();
|
|
||||||
|
|
||||||
let iter_trait = FamousDefs(sema, Some(krate)).core_iter_Iterator()?;
|
|
||||||
- it_type.impls_trait(sema.db, iter_trait, &[]).then(|| (expr, receiver))
|
|
||||||
+ if it_type.impls_trait(sema.db, iter_trait, &[]) { Some((expr, receiver)) } else { None }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
@ -25,7 +25,7 @@ echo "$old_rev -> $rev"
|
|||||||
sha256=$(nix-prefetch -f "$nixpkgs" rust-analyzer-unwrapped.src --rev "$rev")
|
sha256=$(nix-prefetch -f "$nixpkgs" rust-analyzer-unwrapped.src --rev "$rev")
|
||||||
# Clear cargoSha256 to avoid inconsistency.
|
# Clear cargoSha256 to avoid inconsistency.
|
||||||
sed -e "s#rev = \".*\"#rev = \"$rev\"#" \
|
sed -e "s#rev = \".*\"#rev = \"$rev\"#" \
|
||||||
-e "s#sha256 = \".*\"#sha256 = \"$sha256\"#" \
|
-e "/fetchFromGitHub/,/}/ s#sha256 = \".*\"#sha256 = \"$sha256\"#" \
|
||||||
-e "s#cargoSha256 = \".*\"#cargoSha256 = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"#" \
|
-e "s#cargoSha256 = \".*\"#cargoSha256 = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"#" \
|
||||||
--in-place ./default.nix
|
--in-place ./default.nix
|
||||||
node_src="$(nix-build "$nixpkgs" -A rust-analyzer.src --no-out-link)/editors/code"
|
node_src="$(nix-build "$nixpkgs" -A rust-analyzer.src --no-out-link)/editors/code"
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
{ lib, rustPlatform, runCommandNoCC, makeWrapper }:
|
{ lib, rustPlatform, runCommand, makeWrapper, rust-analyzer-unwrapped
|
||||||
|
, pname ? "rust-analyzer"
|
||||||
lib.makeOverridable ({
|
, version ? rust-analyzer-unwrapped.version
|
||||||
unwrapped,
|
|
||||||
pname ? "rust-analyzer",
|
|
||||||
version ? unwrapped.version,
|
|
||||||
# Use name from `RUST_SRC_PATH`
|
# Use name from `RUST_SRC_PATH`
|
||||||
rustSrc ? rustPlatform.rustLibSrc,
|
, rustSrc ? rustPlatform.rustLibSrc
|
||||||
}: runCommandNoCC "${pname}-${version}" {
|
}:
|
||||||
|
runCommand "${pname}-${version}" {
|
||||||
inherit pname version;
|
inherit pname version;
|
||||||
inherit (unwrapped) src meta;
|
inherit (rust-analyzer-unwrapped) src meta;
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
} ''
|
} ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
makeWrapper ${unwrapped}/bin/rust-analyzer $out/bin/rust-analyzer \
|
makeWrapper ${rust-analyzer-unwrapped}/bin/rust-analyzer $out/bin/rust-analyzer \
|
||||||
--set-default RUST_SRC_PATH "${rustSrc}"
|
--set-default RUST_SRC_PATH "${rustSrc}"
|
||||||
'')
|
''
|
||||||
|
@ -11323,10 +11323,10 @@ in
|
|||||||
rustracerd = callPackage ../development/tools/rust/racerd {
|
rustracerd = callPackage ../development/tools/rust/racerd {
|
||||||
inherit (darwin.apple_sdk.frameworks) Security;
|
inherit (darwin.apple_sdk.frameworks) Security;
|
||||||
};
|
};
|
||||||
inherit (callPackage ../development/tools/rust/rust-analyzer {
|
rust-analyzer-unwrapped = callPackage ../development/tools/rust/rust-analyzer {
|
||||||
inherit (darwin.apple_sdk.frameworks) CoreServices;
|
inherit (darwin.apple_sdk.frameworks) CoreServices;
|
||||||
})
|
};
|
||||||
rust-analyzer-unwrapped rust-analyzer;
|
rust-analyzer = callPackage ../development/tools/rust/rust-analyzer/wrapper.nix { };
|
||||||
rust-bindgen = callPackage ../development/tools/rust/bindgen { };
|
rust-bindgen = callPackage ../development/tools/rust/bindgen { };
|
||||||
rust-cbindgen = callPackage ../development/tools/rust/cbindgen {
|
rust-cbindgen = callPackage ../development/tools/rust/cbindgen {
|
||||||
inherit (darwin.apple_sdk.frameworks) Security;
|
inherit (darwin.apple_sdk.frameworks) Security;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user