diff options
-rw-r--r-- | Cargo.lock | 12 | ||||
-rw-r--r-- | crates/ra_hir/src/db.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/db.rs | 19 | ||||
-rw-r--r-- | crates/ra_ide_db/Cargo.toml | 3 | ||||
-rw-r--r-- | crates/ra_ide_db/src/change.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_db/src/line_index.rs | 8 | ||||
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/syntax_node.rs | 4 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 22 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 32 | ||||
-rw-r--r-- | crates/stdx/src/lib.rs | 30 | ||||
-rw-r--r-- | editors/code/package.json | 12 | ||||
-rw-r--r-- | editors/code/src/client.ts | 1 | ||||
-rw-r--r-- | xtask/tests/tidy.rs | 1 |
15 files changed, 107 insertions, 49 deletions
diff --git a/Cargo.lock b/Cargo.lock index 280d97432..029698808 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -619,9 +619,9 @@ dependencies = [ | |||
619 | 619 | ||
620 | [[package]] | 620 | [[package]] |
621 | name = "lsp-types" | 621 | name = "lsp-types" |
622 | version = "0.77.0" | 622 | version = "0.78.0" |
623 | source = "registry+https://github.com/rust-lang/crates.io-index" | 623 | source = "registry+https://github.com/rust-lang/crates.io-index" |
624 | checksum = "897c6c8930fbf12b67deffc83729287bb379dd5e5a4bd0ae2d81eff8d6503db6" | 624 | checksum = "d2e6cf68e3492cfa2035f0382c1da1b6ab045db0320feca505b86b4f13d66c27" |
625 | dependencies = [ | 625 | dependencies = [ |
626 | "base64", | 626 | "base64", |
627 | "bitflags", | 627 | "bitflags", |
@@ -1077,7 +1077,7 @@ dependencies = [ | |||
1077 | "ra_text_edit", | 1077 | "ra_text_edit", |
1078 | "rayon", | 1078 | "rayon", |
1079 | "rustc-hash", | 1079 | "rustc-hash", |
1080 | "superslice", | 1080 | "stdx", |
1081 | "test_utils", | 1081 | "test_utils", |
1082 | ] | 1082 | ] |
1083 | 1083 | ||
@@ -1584,12 +1584,6 @@ name = "stdx" | |||
1584 | version = "0.1.0" | 1584 | version = "0.1.0" |
1585 | 1585 | ||
1586 | [[package]] | 1586 | [[package]] |
1587 | name = "superslice" | ||
1588 | version = "1.0.0" | ||
1589 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1590 | checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" | ||
1591 | |||
1592 | [[package]] | ||
1593 | name = "syn" | 1587 | name = "syn" |
1594 | version = "1.0.35" | 1588 | version = "1.0.35" |
1595 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1589 | source = "registry+https://github.com/rust-lang/crates.io-index" |
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 1ad92a1f8..a2b9f3e35 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -11,7 +11,7 @@ pub use hir_def::db::{ | |||
11 | }; | 11 | }; |
12 | pub use hir_expand::db::{ | 12 | pub use hir_expand::db::{ |
13 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternEagerExpansionQuery, InternMacroQuery, | 13 | AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternEagerExpansionQuery, InternMacroQuery, |
14 | MacroArgQuery, MacroDefQuery, MacroExpandQuery, ParseMacroQuery, | 14 | MacroArgTextQuery, MacroDefQuery, MacroExpandQuery, ParseMacroQuery, |
15 | }; | 15 | }; |
16 | pub use hir_ty::db::{ | 16 | pub use hir_ty::db::{ |
17 | AssociatedTyDataQuery, AssociatedTyValueQuery, CallableItemSignatureQuery, FieldTypesQuery, | 17 | AssociatedTyDataQuery, AssociatedTyValueQuery, CallableItemSignatureQuery, FieldTypesQuery, |
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index bf30d7151..e0ad1567f 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs | |||
@@ -6,7 +6,7 @@ use mbe::{ExpandResult, MacroRules}; | |||
6 | use ra_db::{salsa, SourceDatabase}; | 6 | use ra_db::{salsa, SourceDatabase}; |
7 | use ra_parser::FragmentKind; | 7 | use ra_parser::FragmentKind; |
8 | use ra_prof::profile; | 8 | use ra_prof::profile; |
9 | use ra_syntax::{algo::diff, AstNode, Parse, SyntaxKind::*, SyntaxNode}; | 9 | use ra_syntax::{algo::diff, AstNode, GreenNode, Parse, SyntaxKind::*, SyntaxNode}; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | ast_id_map::AstIdMap, BuiltinDeriveExpander, BuiltinFnLikeExpander, EagerCallLoc, EagerMacroId, | 12 | ast_id_map::AstIdMap, BuiltinDeriveExpander, BuiltinFnLikeExpander, EagerCallLoc, EagerMacroId, |
@@ -72,6 +72,8 @@ pub trait AstDatabase: SourceDatabase { | |||
72 | 72 | ||
73 | #[salsa::interned] | 73 | #[salsa::interned] |
74 | fn intern_macro(&self, macro_call: MacroCallLoc) -> LazyMacroId; | 74 | fn intern_macro(&self, macro_call: MacroCallLoc) -> LazyMacroId; |
75 | fn macro_arg_text(&self, id: MacroCallId) -> Option<GreenNode>; | ||
76 | #[salsa::transparent] | ||
75 | fn macro_arg(&self, id: MacroCallId) -> Option<Arc<(tt::Subtree, mbe::TokenMap)>>; | 77 | fn macro_arg(&self, id: MacroCallId) -> Option<Arc<(tt::Subtree, mbe::TokenMap)>>; |
76 | fn macro_def(&self, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>>; | 78 | fn macro_def(&self, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>>; |
77 | fn parse_macro(&self, macro_file: MacroFile) | 79 | fn parse_macro(&self, macro_file: MacroFile) |
@@ -148,10 +150,7 @@ pub(crate) fn macro_def( | |||
148 | } | 150 | } |
149 | } | 151 | } |
150 | 152 | ||
151 | pub(crate) fn macro_arg( | 153 | pub(crate) fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<GreenNode> { |
152 | db: &dyn AstDatabase, | ||
153 | id: MacroCallId, | ||
154 | ) -> Option<Arc<(tt::Subtree, mbe::TokenMap)>> { | ||
155 | let id = match id { | 154 | let id = match id { |
156 | MacroCallId::LazyMacro(id) => id, | 155 | MacroCallId::LazyMacro(id) => id, |
157 | MacroCallId::EagerMacro(_id) => { | 156 | MacroCallId::EagerMacro(_id) => { |
@@ -161,7 +160,15 @@ pub(crate) fn macro_arg( | |||
161 | }; | 160 | }; |
162 | let loc = db.lookup_intern_macro(id); | 161 | let loc = db.lookup_intern_macro(id); |
163 | let arg = loc.kind.arg(db)?; | 162 | let arg = loc.kind.arg(db)?; |
164 | let (tt, tmap) = mbe::syntax_node_to_token_tree(&arg)?; | 163 | Some(arg.green().clone()) |
164 | } | ||
165 | |||
166 | pub(crate) fn macro_arg( | ||
167 | db: &dyn AstDatabase, | ||
168 | id: MacroCallId, | ||
169 | ) -> Option<Arc<(tt::Subtree, mbe::TokenMap)>> { | ||
170 | let arg = db.macro_arg_text(id)?; | ||
171 | let (tt, tmap) = mbe::syntax_node_to_token_tree(&SyntaxNode::new_root(arg))?; | ||
165 | Some(Arc::new((tt, tmap))) | 172 | Some(Arc::new((tt, tmap))) |
166 | } | 173 | } |
167 | 174 | ||
diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml index bcddad60c..2716a38cc 100644 --- a/crates/ra_ide_db/Cargo.toml +++ b/crates/ra_ide_db/Cargo.toml | |||
@@ -16,10 +16,11 @@ log = "0.4.8" | |||
16 | rayon = "1.3.0" | 16 | rayon = "1.3.0" |
17 | fst = { version = "0.4", default-features = false } | 17 | fst = { version = "0.4", default-features = false } |
18 | rustc-hash = "1.1.0" | 18 | rustc-hash = "1.1.0" |
19 | superslice = "1.0.0" | ||
20 | once_cell = "1.3.1" | 19 | once_cell = "1.3.1" |
21 | either = "1.5.3" | 20 | either = "1.5.3" |
22 | 21 | ||
22 | stdx = { path = "../stdx" } | ||
23 | |||
23 | ra_syntax = { path = "../ra_syntax" } | 24 | ra_syntax = { path = "../ra_syntax" } |
24 | ra_text_edit = { path = "../ra_text_edit" } | 25 | ra_text_edit = { path = "../ra_text_edit" } |
25 | ra_db = { path = "../ra_db" } | 26 | ra_db = { path = "../ra_db" } |
diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index a1bb3043b..32d9a8d1f 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs | |||
@@ -151,7 +151,7 @@ impl RootDatabase { | |||
151 | 151 | ||
152 | // Macros do take significant space, but less then the syntax trees | 152 | // Macros do take significant space, but less then the syntax trees |
153 | // self.query(hir::db::MacroDefQuery).sweep(sweep); | 153 | // self.query(hir::db::MacroDefQuery).sweep(sweep); |
154 | // self.query(hir::db::MacroArgQuery).sweep(sweep); | 154 | // self.query(hir::db::MacroArgTextQuery).sweep(sweep); |
155 | // self.query(hir::db::MacroExpandQuery).sweep(sweep); | 155 | // self.query(hir::db::MacroExpandQuery).sweep(sweep); |
156 | 156 | ||
157 | hir::db::AstIdMapQuery.in_db(self).sweep(sweep); | 157 | hir::db::AstIdMapQuery.in_db(self).sweep(sweep); |
@@ -199,7 +199,7 @@ impl RootDatabase { | |||
199 | 199 | ||
200 | // AstDatabase | 200 | // AstDatabase |
201 | hir::db::AstIdMapQuery | 201 | hir::db::AstIdMapQuery |
202 | hir::db::MacroArgQuery | 202 | hir::db::MacroArgTextQuery |
203 | hir::db::MacroDefQuery | 203 | hir::db::MacroDefQuery |
204 | hir::db::ParseMacroQuery | 204 | hir::db::ParseMacroQuery |
205 | hir::db::MacroExpandQuery | 205 | hir::db::MacroExpandQuery |
diff --git a/crates/ra_ide_db/src/line_index.rs b/crates/ra_ide_db/src/line_index.rs index c7c744fce..2ab662098 100644 --- a/crates/ra_ide_db/src/line_index.rs +++ b/crates/ra_ide_db/src/line_index.rs | |||
@@ -4,7 +4,7 @@ use std::iter; | |||
4 | 4 | ||
5 | use ra_syntax::{TextRange, TextSize}; | 5 | use ra_syntax::{TextRange, TextSize}; |
6 | use rustc_hash::FxHashMap; | 6 | use rustc_hash::FxHashMap; |
7 | use superslice::Ext; | 7 | use stdx::partition_point; |
8 | 8 | ||
9 | #[derive(Clone, Debug, PartialEq, Eq)] | 9 | #[derive(Clone, Debug, PartialEq, Eq)] |
10 | pub struct LineIndex { | 10 | pub struct LineIndex { |
@@ -89,7 +89,7 @@ impl LineIndex { | |||
89 | } | 89 | } |
90 | 90 | ||
91 | pub fn line_col(&self, offset: TextSize) -> LineCol { | 91 | pub fn line_col(&self, offset: TextSize) -> LineCol { |
92 | let line = self.newlines.upper_bound(&offset) - 1; | 92 | let line = partition_point(&self.newlines, |&it| it <= offset) - 1; |
93 | let line_start_offset = self.newlines[line]; | 93 | let line_start_offset = self.newlines[line]; |
94 | let col = offset - line_start_offset; | 94 | let col = offset - line_start_offset; |
95 | 95 | ||
@@ -103,8 +103,8 @@ impl LineIndex { | |||
103 | } | 103 | } |
104 | 104 | ||
105 | pub fn lines(&self, range: TextRange) -> impl Iterator<Item = TextRange> + '_ { | 105 | pub fn lines(&self, range: TextRange) -> impl Iterator<Item = TextRange> + '_ { |
106 | let lo = self.newlines.lower_bound(&range.start()); | 106 | let lo = partition_point(&self.newlines, |&it| it < range.start()); |
107 | let hi = self.newlines.upper_bound(&range.end()); | 107 | let hi = partition_point(&self.newlines, |&it| it <= range.end()); |
108 | let all = iter::once(range.start()) | 108 | let all = iter::once(range.start()) |
109 | .chain(self.newlines[lo..hi].iter().copied()) | 109 | .chain(self.newlines[lo..hi].iter().copied()) |
110 | .chain(iter::once(range.end())); | 110 | .chain(iter::once(range.end())); |
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 9b7664576..ac59455e7 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -42,8 +42,6 @@ use std::{marker::PhantomData, sync::Arc}; | |||
42 | use ra_text_edit::Indel; | 42 | use ra_text_edit::Indel; |
43 | use stdx::format_to; | 43 | use stdx::format_to; |
44 | 44 | ||
45 | use crate::syntax_node::GreenNode; | ||
46 | |||
47 | pub use crate::{ | 45 | pub use crate::{ |
48 | algo::InsertPosition, | 46 | algo::InsertPosition, |
49 | ast::{AstNode, AstToken}, | 47 | ast::{AstNode, AstToken}, |
@@ -51,7 +49,7 @@ pub use crate::{ | |||
51 | ptr::{AstPtr, SyntaxNodePtr}, | 49 | ptr::{AstPtr, SyntaxNodePtr}, |
52 | syntax_error::SyntaxError, | 50 | syntax_error::SyntaxError, |
53 | syntax_node::{ | 51 | syntax_node::{ |
54 | Direction, NodeOrToken, SyntaxElement, SyntaxElementChildren, SyntaxNode, | 52 | Direction, GreenNode, NodeOrToken, SyntaxElement, SyntaxElementChildren, SyntaxNode, |
55 | SyntaxNodeChildren, SyntaxToken, SyntaxTreeBuilder, | 53 | SyntaxNodeChildren, SyntaxToken, SyntaxTreeBuilder, |
56 | }, | 54 | }, |
57 | }; | 55 | }; |
diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs index 9650b8781..a7dbdba7b 100644 --- a/crates/ra_syntax/src/syntax_node.rs +++ b/crates/ra_syntax/src/syntax_node.rs | |||
@@ -10,7 +10,9 @@ use rowan::{GreenNodeBuilder, Language}; | |||
10 | 10 | ||
11 | use crate::{Parse, SmolStr, SyntaxError, SyntaxKind, TextSize}; | 11 | use crate::{Parse, SmolStr, SyntaxError, SyntaxKind, TextSize}; |
12 | 12 | ||
13 | pub(crate) use rowan::{GreenNode, GreenToken}; | 13 | pub use rowan::GreenNode; |
14 | |||
15 | pub(crate) use rowan::GreenToken; | ||
14 | 16 | ||
15 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 17 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
16 | pub enum RustLanguage {} | 18 | pub enum RustLanguage {} |
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 023c104d1..758aa1c5d 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -20,7 +20,7 @@ env_logger = { version = "0.7.1", default-features = false } | |||
20 | itertools = "0.9.0" | 20 | itertools = "0.9.0" |
21 | jod-thread = "0.1.0" | 21 | jod-thread = "0.1.0" |
22 | log = "0.4.8" | 22 | log = "0.4.8" |
23 | lsp-types = { version = "0.77.0", features = ["proposed"] } | 23 | lsp-types = { version = "0.78.0", features = ["proposed"] } |
24 | parking_lot = "0.11.0" | 24 | parking_lot = "0.11.0" |
25 | pico-args = "0.3.1" | 25 | pico-args = "0.3.1" |
26 | rand = { version = "0.7.3", features = ["small_rng"] } | 26 | rand = { version = "0.7.3", features = ["small_rng"] } |
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index d880570d2..8d8c9442b 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -15,7 +15,7 @@ use lsp_types::{ | |||
15 | DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, | 15 | DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, |
16 | Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams, | 16 | Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams, |
17 | SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, | 17 | SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, |
18 | TextDocumentIdentifier, Url, WorkspaceEdit, | 18 | SymbolTag, TextDocumentIdentifier, Url, WorkspaceEdit, |
19 | }; | 19 | }; |
20 | use ra_ide::{ | 20 | use ra_ide::{ |
21 | FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, | 21 | FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, |
@@ -253,10 +253,17 @@ pub(crate) fn handle_document_symbol( | |||
253 | let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new(); | 253 | let mut parents: Vec<(DocumentSymbol, Option<usize>)> = Vec::new(); |
254 | 254 | ||
255 | for symbol in snap.analysis.file_structure(file_id)? { | 255 | for symbol in snap.analysis.file_structure(file_id)? { |
256 | let mut tags = Vec::new(); | ||
257 | if symbol.deprecated { | ||
258 | tags.push(SymbolTag::Deprecated) | ||
259 | }; | ||
260 | |||
261 | #[allow(deprecated)] | ||
256 | let doc_symbol = DocumentSymbol { | 262 | let doc_symbol = DocumentSymbol { |
257 | name: symbol.label, | 263 | name: symbol.label, |
258 | detail: symbol.detail, | 264 | detail: symbol.detail, |
259 | kind: to_proto::symbol_kind(symbol.kind), | 265 | kind: to_proto::symbol_kind(symbol.kind), |
266 | tags: Some(tags), | ||
260 | deprecated: Some(symbol.deprecated), | 267 | deprecated: Some(symbol.deprecated), |
261 | range: to_proto::range(&line_index, symbol.node_range), | 268 | range: to_proto::range(&line_index, symbol.node_range), |
262 | selection_range: to_proto::range(&line_index, symbol.navigation_range), | 269 | selection_range: to_proto::range(&line_index, symbol.navigation_range), |
@@ -296,9 +303,19 @@ pub(crate) fn handle_document_symbol( | |||
296 | url: &Url, | 303 | url: &Url, |
297 | res: &mut Vec<SymbolInformation>, | 304 | res: &mut Vec<SymbolInformation>, |
298 | ) { | 305 | ) { |
306 | let mut tags = Vec::new(); | ||
307 | |||
308 | #[allow(deprecated)] | ||
309 | match symbol.deprecated { | ||
310 | Some(true) => tags.push(SymbolTag::Deprecated), | ||
311 | _ => {} | ||
312 | } | ||
313 | |||
314 | #[allow(deprecated)] | ||
299 | res.push(SymbolInformation { | 315 | res.push(SymbolInformation { |
300 | name: symbol.name.clone(), | 316 | name: symbol.name.clone(), |
301 | kind: symbol.kind, | 317 | kind: symbol.kind, |
318 | tags: Some(tags), | ||
302 | deprecated: symbol.deprecated, | 319 | deprecated: symbol.deprecated, |
303 | location: Location::new(url.clone(), symbol.range), | 320 | location: Location::new(url.clone(), symbol.range), |
304 | container_name, | 321 | container_name, |
@@ -342,9 +359,12 @@ pub(crate) fn handle_workspace_symbol( | |||
342 | let mut res = Vec::new(); | 359 | let mut res = Vec::new(); |
343 | for nav in snap.analysis.symbol_search(query)? { | 360 | for nav in snap.analysis.symbol_search(query)? { |
344 | let container_name = nav.container_name.as_ref().map(|v| v.to_string()); | 361 | let container_name = nav.container_name.as_ref().map(|v| v.to_string()); |
362 | |||
363 | #[allow(deprecated)] | ||
345 | let info = SymbolInformation { | 364 | let info = SymbolInformation { |
346 | name: nav.name.to_string(), | 365 | name: nav.name.to_string(), |
347 | kind: to_proto::symbol_kind(nav.kind), | 366 | kind: to_proto::symbol_kind(nav.kind), |
367 | tags: None, | ||
348 | location: to_proto::location_from_nav(snap, nav)?, | 368 | location: to_proto::location_from_nav(snap, nav)?, |
349 | container_name, | 369 | container_name, |
350 | deprecated: None, | 370 | deprecated: None, |
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index f6d8daeed..ac95e428e 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -97,22 +97,6 @@ impl fmt::Debug for Event { | |||
97 | } | 97 | } |
98 | 98 | ||
99 | impl GlobalState { | 99 | impl GlobalState { |
100 | fn next_event(&self, inbox: &Receiver<lsp_server::Message>) -> Option<Event> { | ||
101 | select! { | ||
102 | recv(inbox) -> msg => | ||
103 | msg.ok().map(Event::Lsp), | ||
104 | |||
105 | recv(self.task_pool.receiver) -> task => | ||
106 | Some(Event::Task(task.unwrap())), | ||
107 | |||
108 | recv(self.loader.receiver) -> task => | ||
109 | Some(Event::Vfs(task.unwrap())), | ||
110 | |||
111 | recv(self.flycheck_receiver) -> task => | ||
112 | Some(Event::Flycheck(task.unwrap())), | ||
113 | } | ||
114 | } | ||
115 | |||
116 | fn run(mut self, inbox: Receiver<lsp_server::Message>) -> Result<()> { | 100 | fn run(mut self, inbox: Receiver<lsp_server::Message>) -> Result<()> { |
117 | if self.config.linked_projects.is_empty() && self.config.notifications.cargo_toml_not_found | 101 | if self.config.linked_projects.is_empty() && self.config.notifications.cargo_toml_not_found |
118 | { | 102 | { |
@@ -169,6 +153,22 @@ impl GlobalState { | |||
169 | Err("client exited without proper shutdown sequence")? | 153 | Err("client exited without proper shutdown sequence")? |
170 | } | 154 | } |
171 | 155 | ||
156 | fn next_event(&self, inbox: &Receiver<lsp_server::Message>) -> Option<Event> { | ||
157 | select! { | ||
158 | recv(inbox) -> msg => | ||
159 | msg.ok().map(Event::Lsp), | ||
160 | |||
161 | recv(self.task_pool.receiver) -> task => | ||
162 | Some(Event::Task(task.unwrap())), | ||
163 | |||
164 | recv(self.loader.receiver) -> task => | ||
165 | Some(Event::Vfs(task.unwrap())), | ||
166 | |||
167 | recv(self.flycheck_receiver) -> task => | ||
168 | Some(Event::Flycheck(task.unwrap())), | ||
169 | } | ||
170 | } | ||
171 | |||
172 | fn handle_event(&mut self, event: Event) -> Result<()> { | 172 | fn handle_event(&mut self, event: Event) -> Result<()> { |
173 | let loop_start = Instant::now(); | 173 | let loop_start = Instant::now(); |
174 | // NOTE: don't count blocking select! call as a loop-turn time | 174 | // NOTE: don't count blocking select! call as a loop-turn time |
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 988853ed2..ea0e6b949 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs | |||
@@ -158,6 +158,36 @@ impl<'a> Iterator for LinesWithEnds<'a> { | |||
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | // https://github.com/rust-lang/rust/issues/73831 | ||
162 | pub fn partition_point<T, P>(slice: &[T], mut pred: P) -> usize | ||
163 | where | ||
164 | P: FnMut(&T) -> bool, | ||
165 | { | ||
166 | let mut left = 0; | ||
167 | let mut right = slice.len(); | ||
168 | |||
169 | while left != right { | ||
170 | let mid = left + (right - left) / 2; | ||
171 | // SAFETY: | ||
172 | // When left < right, left <= mid < right. | ||
173 | // Therefore left always increases and right always decreases, | ||
174 | // and either of them is selected. | ||
175 | // In both cases left <= right is satisfied. | ||
176 | // Therefore if left < right in a step, | ||
177 | // left <= right is satisfied in the next step. | ||
178 | // Therefore as long as left != right, 0 <= left < right <= len is satisfied | ||
179 | // and if this case 0 <= mid < len is satisfied too. | ||
180 | let value = unsafe { slice.get_unchecked(mid) }; | ||
181 | if pred(value) { | ||
182 | left = mid + 1; | ||
183 | } else { | ||
184 | right = mid; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | left | ||
189 | } | ||
190 | |||
161 | #[cfg(test)] | 191 | #[cfg(test)] |
162 | mod tests { | 192 | mod tests { |
163 | use super::*; | 193 | use super::*; |
diff --git a/editors/code/package.json b/editors/code/package.json index aac4ba94f..448e2269f 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -655,24 +655,30 @@ | |||
655 | "problemMatchers": [ | 655 | "problemMatchers": [ |
656 | { | 656 | { |
657 | "name": "rustc", | 657 | "name": "rustc", |
658 | "owner": "rustc", | ||
659 | "source": "rustc", | ||
658 | "fileLocation": [ | 660 | "fileLocation": [ |
659 | "relative", | 661 | "autoDetect", |
660 | "${workspaceRoot}" | 662 | "${workspaceRoot}" |
661 | ], | 663 | ], |
662 | "pattern": "$rustc" | 664 | "pattern": "$rustc" |
663 | }, | 665 | }, |
664 | { | 666 | { |
665 | "name": "rustc-json", | 667 | "name": "rustc-json", |
668 | "owner": "rustc", | ||
669 | "source": "rustc", | ||
666 | "fileLocation": [ | 670 | "fileLocation": [ |
667 | "relative", | 671 | "autoDetect", |
668 | "${workspaceRoot}" | 672 | "${workspaceRoot}" |
669 | ], | 673 | ], |
670 | "pattern": "$rustc-json" | 674 | "pattern": "$rustc-json" |
671 | }, | 675 | }, |
672 | { | 676 | { |
673 | "name": "rustc-watch", | 677 | "name": "rustc-watch", |
678 | "owner": "rustc", | ||
679 | "source": "rustc", | ||
674 | "fileLocation": [ | 680 | "fileLocation": [ |
675 | "relative", | 681 | "autoDetect", |
676 | "${workspaceRoot}" | 682 | "${workspaceRoot}" |
677 | ], | 683 | ], |
678 | "background": { | 684 | "background": { |
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 41ffac7b3..18948cb3c 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -41,6 +41,7 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient | |||
41 | const clientOptions: lc.LanguageClientOptions = { | 41 | const clientOptions: lc.LanguageClientOptions = { |
42 | documentSelector: [{ scheme: 'file', language: 'rust' }], | 42 | documentSelector: [{ scheme: 'file', language: 'rust' }], |
43 | initializationOptions: vscode.workspace.getConfiguration("rust-analyzer"), | 43 | initializationOptions: vscode.workspace.getConfiguration("rust-analyzer"), |
44 | diagnosticCollectionName: "rustc", | ||
44 | traceOutputChannel, | 45 | traceOutputChannel, |
45 | middleware: { | 46 | middleware: { |
46 | // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 | 47 | // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 |
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index ca14e8ac1..adadffc53 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs | |||
@@ -53,7 +53,6 @@ fn rust_files_are_tidy() { | |||
53 | fn check_licenses() { | 53 | fn check_licenses() { |
54 | let expected = " | 54 | let expected = " |
55 | 0BSD OR MIT OR Apache-2.0 | 55 | 0BSD OR MIT OR Apache-2.0 |
56 | Apache-2.0 | ||
57 | Apache-2.0 OR BSL-1.0 | 56 | Apache-2.0 OR BSL-1.0 |
58 | Apache-2.0 OR MIT | 57 | Apache-2.0 OR MIT |
59 | Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT | 58 | Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT |