Merge pull request #142851 from oxalica/rust-analyzer

This commit is contained in:
Sandro 2021-11-02 16:01:44 +01:00 committed by GitHub
commit df535fa0f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 2107 additions and 2297 deletions

View File

@ -119,5 +119,7 @@ appimageTools.wrapType2 {
license = licenses.unfree;
maintainers = with maintainers; [ kamadorueda ];
platforms = [ "x86_64-linux" ];
# gpgme for i686-linux failed to build.
broken = true;
};
}

View File

@ -89,6 +89,9 @@ let
pkgs.lib.makeBinPath [ pkgs.nodejs ]
}
'';
# See: https://github.com/NixOS/nixpkgs/issues/142196
# [...]/@hyperspace/cli/node_modules/.bin/node-gyp-build: /usr/bin/env: bad interpreter: No such file or directory
meta.broken = true;
};
mdctl-cli = super."@medable/mdctl-cli".override {

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,10 @@
{ lib, stdenv, fetchFromGitHub, rustPlatform, CoreServices, cmake
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, rustPlatform
, CoreServices
, cmake
, libiconv
, useMimalloc ? false
, doCheck ? true
@ -6,23 +12,46 @@
rustPlatform.buildRustPackage rec {
pname = "rust-analyzer-unwrapped";
version = "2021-09-20";
cargoSha256 = "sha256-OPolZ0oXGRcKvWxXkRMjyEXzvf1p41hGfHBpbDbLJck=";
version = "2021-10-25";
cargoSha256 = "sha256-PCQxXNpv4krdLBhyINoZT5QxV2hCqXpp1mqs0dUu4Ag=";
src = fetchFromGitHub {
owner = "rust-analyzer";
repo = "rust-analyzer";
rev = version;
sha256 = "sha256-k2UGz+h9++8wtV+XdGZbWysjkIDe+UNudKL46eisZzw=";
sha256 = "sha256-3AMRwtEmITIvUdR/NINQTPatkjhmS1dQsbbsefIDYAE=";
};
patches = [
# Code format and git history check require more dependencies but don't really matter for packaging.
# So just ignore them.
./ignore-git-and-rustfmt-tests.patch
];
# Patch for our rust 1.54.0 in nixpkgs. Remove it when we have rust >= 1.55.0
./no-1-55-control-flow.patch
# Revert edition 2021 related code since we have rust 1.55.0 in nixpkgs currently.
# Remove them when we have rust >= 1.56.0
# They change Cargo.toml so go `cargoPatches`.
cargoPatches = [
(fetchpatch {
url = "https://github.com/rust-analyzer/rust-analyzer/commit/f0ad6fa68bf98d317518bb75da01b7bb7abe98d3.patch";
revert = true;
sha256 = "sha256-ksX2j1Pgtd+M+FmXTEljm1nUxJwcY8GDQ9784Lb1uM4=";
})
(fetchpatch {
url = "https://github.com/rust-analyzer/rust-analyzer/commit/8457ae34bdbca117b2ef73787b214161440e21f9.patch";
revert = true;
sha256 = "sha256-w1Py1bvZ2/tDQDZVMNmPRo6i6uA4H3YYZY4rXlo0iqg=";
})
(fetchpatch {
url = "https://github.com/rust-analyzer/rust-analyzer/commit/ca44b6892e3e66765355d4e645f74df3d184c03b.patch";
revert = true;
sha256 = "sha256-N1TWlLxEg6oxFkns1ieVVvLAkrHq2WOr1tbkNvZvDFg=";
})
(fetchpatch {
url = "https://github.com/rust-analyzer/rust-analyzer/commit/1294bfce865c556184c9327af4a8953ca940aec8.patch";
revert = true;
sha256 = "sha256-65eZxAjsuUln6lzSihIP26x15PELLDL4yk9wiVzJ0hE=";
})
];
buildAndTestSubdir = "crates/rust-analyzer";

View File

@ -1,212 +0,0 @@
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 3b0c29e87..2841a39e2 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -31,7 +31,7 @@ pub mod db;
mod display;
-use std::{iter, ops::ControlFlow, sync::Arc};
+use std::{iter, sync::Arc};
use arrayvec::ArrayVec;
use base_db::{CrateDisplayName, CrateId, Edition, FileId};
@@ -70,7 +70,7 @@ use itertools::Itertools;
use nameres::diagnostics::DefDiagnosticKind;
use once_cell::unsync::Lazy;
use rustc_hash::FxHashSet;
-use stdx::{format_to, impl_from};
+use stdx::{format_to, impl_from, ControlFlow};
use syntax::{
ast::{self, AttrsOwner, NameOwner},
AstNode, AstPtr, SmolStr, SyntaxKind, SyntaxNodePtr,
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs
index c88a8b653..039b5589e 100644
--- a/crates/hir_ty/src/method_resolution.rs
+++ b/crates/hir_ty/src/method_resolution.rs
@@ -2,7 +2,7 @@
//! For details about how this works in rustc, see the method lookup page in the
//! [rustc guide](https://rust-lang.github.io/rustc-guide/method-lookup.html)
//! and the corresponding code mostly in librustc_typeck/check/method/probe.rs.
-use std::{iter, ops::ControlFlow, sync::Arc};
+use std::{iter, sync::Arc};
use arrayvec::ArrayVec;
use base_db::{CrateId, Edition};
@@ -13,6 +13,7 @@ use hir_def::{
};
use hir_expand::name::Name;
use rustc_hash::{FxHashMap, FxHashSet};
+use stdx::{try_control_flow, ControlFlow};
use crate::{
autoderef,
@@ -483,7 +484,7 @@ pub fn iterate_method_candidates_dyn(
let deref_chain = autoderef_method_receiver(db, krate, ty);
for i in 0..deref_chain.len() {
- iterate_method_candidates_with_autoref(
+ try_control_flow!(iterate_method_candidates_with_autoref(
&deref_chain[i..],
db,
env.clone(),
@@ -492,7 +493,7 @@ pub fn iterate_method_candidates_dyn(
visible_from_module,
name,
callback,
- )?;
+ ));
}
ControlFlow::Continue(())
}
@@ -522,7 +523,7 @@ fn iterate_method_candidates_with_autoref(
name: Option<&Name>,
mut callback: &mut dyn FnMut(&Canonical<Ty>, AssocItemId) -> ControlFlow<()>,
) -> ControlFlow<()> {
- iterate_method_candidates_by_receiver(
+ try_control_flow!(iterate_method_candidates_by_receiver(
&deref_chain[0],
&deref_chain[1..],
db,
@@ -532,7 +533,7 @@ fn iterate_method_candidates_with_autoref(
visible_from_module,
name,
&mut callback,
- )?;
+ ));
let refed = Canonical {
binders: deref_chain[0].binders.clone(),
@@ -540,7 +541,7 @@ fn iterate_method_candidates_with_autoref(
.intern(&Interner),
};
- iterate_method_candidates_by_receiver(
+ try_control_flow!(iterate_method_candidates_by_receiver(
&refed,
deref_chain,
db,
@@ -550,7 +551,7 @@ fn iterate_method_candidates_with_autoref(
visible_from_module,
name,
&mut callback,
- )?;
+ ));
let ref_muted = Canonical {
binders: deref_chain[0].binders.clone(),
@@ -586,7 +587,7 @@ fn iterate_method_candidates_by_receiver(
// be found in any of the derefs of receiver_ty, so we have to go through
// that.
for self_ty in std::iter::once(receiver_ty).chain(rest_of_deref_chain) {
- iterate_inherent_methods(
+ try_control_flow!(iterate_inherent_methods(
self_ty,
db,
env.clone(),
@@ -595,11 +596,11 @@ fn iterate_method_candidates_by_receiver(
krate,
visible_from_module,
&mut callback,
- )?
+ ))
}
for self_ty in std::iter::once(receiver_ty).chain(rest_of_deref_chain) {
- iterate_trait_method_candidates(
+ try_control_flow!(iterate_trait_method_candidates(
self_ty,
db,
env.clone(),
@@ -608,7 +609,7 @@ fn iterate_method_candidates_by_receiver(
name,
Some(receiver_ty),
&mut callback,
- )?
+ ))
}
ControlFlow::Continue(())
@@ -624,7 +625,7 @@ fn iterate_method_candidates_for_self_ty(
name: Option<&Name>,
mut callback: &mut dyn FnMut(&Canonical<Ty>, AssocItemId) -> ControlFlow<()>,
) -> ControlFlow<()> {
- iterate_inherent_methods(
+ try_control_flow!(iterate_inherent_methods(
self_ty,
db,
env.clone(),
@@ -633,7 +634,7 @@ fn iterate_method_candidates_for_self_ty(
krate,
visible_from_module,
&mut callback,
- )?;
+ ));
iterate_trait_method_candidates(self_ty, db, env, krate, traits_in_scope, name, None, callback)
}
@@ -697,7 +698,7 @@ fn iterate_trait_method_candidates(
}
known_implemented = true;
// FIXME: we shouldn't be ignoring the binders here
- callback(self_ty, *item)?
+ try_control_flow!(callback(self_ty, *item))
}
}
ControlFlow::Continue(())
@@ -774,7 +775,7 @@ fn iterate_inherent_methods(
continue;
}
let receiver_ty = receiver_ty.unwrap_or(self_ty);
- callback(receiver_ty, item)?;
+ try_control_flow!(callback(receiver_ty, item));
}
}
}
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 506d3ba3c..590963c17 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -1,4 +1,4 @@
-use std::{collections::HashSet, ops::ControlFlow};
+use std::collections::HashSet;
use either::Either;
use hir::{AsAssocItem, HasAttrs, HasSource, HirDisplay, Semantics, TypeInfo};
@@ -12,7 +12,7 @@ use ide_db::{
RootDatabase,
};
use itertools::Itertools;
-use stdx::format_to;
+use stdx::{format_to, ControlFlow};
use syntax::{
algo, ast, display::fn_as_proc_macro_label, match_ast, AstNode, Direction, SyntaxKind::*,
SyntaxNode, SyntaxToken, TextRange, TextSize, T,
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs
index e7d4753de..fddf95147 100644
--- a/crates/stdx/src/lib.rs
+++ b/crates/stdx/src/lib.rs
@@ -7,6 +7,22 @@ pub mod panic_context;
pub use always_assert::{always, never};
+/// std::ops::ControlFlow from rust std 1.55.0
+pub enum ControlFlow<B, C = ()> {
+ Continue(C),
+ Break(B),
+}
+
+#[macro_export]
+macro_rules! try_control_flow {
+ ($e:expr) => {
+ match $e {
+ $crate::ControlFlow::Continue(c) => c,
+ $crate::ControlFlow::Break(b) => return $crate::ControlFlow::Break(b),
+ }
+ };
+}
+
#[inline(always)]
pub fn is_ci() -> bool {
option_env!("CI").is_some()

View File

@ -1,11 +1,11 @@
{
"name": "rust-analyzer",
"version": "0.2.751",
"version": "0.2.792",
"dependencies": {
"https-proxy-agent": "^5.0.0",
"node-fetch": "^2.6.1",
"vscode-languageclient": "^7.1.0-next.5",
"d3": "^7.0.0",
"vscode-languageclient": "8.0.0-next.2",
"d3": "^7.1.0",
"d3-graphviz": "^4.0.0",
"@types/glob": "^7.1.4",
"@types/mocha": "^8.2.3",
@ -20,7 +20,7 @@
"tslib": "^2.3.0",
"typescript": "^4.3.5",
"typescript-formatter": "^7.2.2",
"vsce": "^1.95.1",
"vsce": "=1.95.1",
"vscode-test": "^1.5.1"
}
}

View File

@ -15,7 +15,7 @@
"memory-streams": "^0.1.3",
"vscode-debugprotocol": "^1.47.0",
"vscode-debugadapter-testsupport": "^1.47.0",
"vsce": "^1.88.0",
"vsce": "=1.88.0",
"webpack": "^5.37.1",
"webpack-cli": "^4.7.0",
"ts-loader": "^8.0.0"