9
9
//! The `cli` submodule implements some batch-processing analysis, primarily as
10
10
//! a debugging aid.
11
11
12
+ /// Any toolchain less than this version will likely not work with rust-analyzer built from this revision.
13
+ pub const MINIMUM_SUPPORTED_TOOLCHAIN_VERSION : semver:: Version = semver:: Version {
14
+ major : 1 ,
15
+ minor : 78 ,
16
+ patch : 0 ,
17
+ pre : semver:: Prerelease :: EMPTY ,
18
+ build : semver:: BuildMetadata :: EMPTY ,
19
+ } ;
20
+
12
21
pub mod cli;
13
22
14
23
mod command;
@@ -47,10 +56,7 @@ use self::lsp::ext as lsp_ext;
47
56
#[ cfg( test) ]
48
57
mod integrated_benchmarks;
49
58
50
- use hir:: Mutability ;
51
- use ide:: { CompletionItem , CompletionItemRefMode , CompletionRelevance } ;
52
59
use serde:: de:: DeserializeOwned ;
53
- use tenthash:: TentHash ;
54
60
55
61
pub use crate :: {
56
62
lsp:: capabilities:: server_capabilities, main_loop:: main_loop, reload:: ws_to_crate_graph,
@@ -65,115 +71,6 @@ pub fn from_json<T: DeserializeOwned>(
65
71
. map_err ( |e| anyhow:: format_err!( "Failed to deserialize {what}: {e}; {json}" ) )
66
72
}
67
73
68
- fn completion_item_hash ( item : & CompletionItem , is_ref_completion : bool ) -> [ u8 ; 20 ] {
69
- fn hash_completion_relevance ( hasher : & mut TentHash , relevance : & CompletionRelevance ) {
70
- use ide_completion:: {
71
- CompletionRelevancePostfixMatch , CompletionRelevanceReturnType ,
72
- CompletionRelevanceTypeMatch ,
73
- } ;
74
-
75
- hasher. update ( [
76
- u8:: from ( relevance. exact_name_match ) ,
77
- u8:: from ( relevance. is_local ) ,
78
- u8:: from ( relevance. is_name_already_imported ) ,
79
- u8:: from ( relevance. requires_import ) ,
80
- u8:: from ( relevance. is_private_editable ) ,
81
- ] ) ;
82
-
83
- match relevance. type_match {
84
- None => hasher. update ( [ 0u8 ] ) ,
85
- Some ( CompletionRelevanceTypeMatch :: CouldUnify ) => hasher. update ( [ 1u8 ] ) ,
86
- Some ( CompletionRelevanceTypeMatch :: Exact ) => hasher. update ( [ 2u8 ] ) ,
87
- }
88
-
89
- hasher. update ( [ u8:: from ( relevance. trait_ . is_some ( ) ) ] ) ;
90
- if let Some ( trait_) = & relevance. trait_ {
91
- hasher. update ( [ u8:: from ( trait_. is_op_method ) , u8:: from ( trait_. notable_trait ) ] ) ;
92
- }
93
-
94
- match relevance. postfix_match {
95
- None => hasher. update ( [ 0u8 ] ) ,
96
- Some ( CompletionRelevancePostfixMatch :: NonExact ) => hasher. update ( [ 1u8 ] ) ,
97
- Some ( CompletionRelevancePostfixMatch :: Exact ) => hasher. update ( [ 2u8 ] ) ,
98
- }
99
-
100
- hasher. update ( [ u8:: from ( relevance. function . is_some ( ) ) ] ) ;
101
- if let Some ( function) = & relevance. function {
102
- hasher. update ( [ u8:: from ( function. has_params ) , u8:: from ( function. has_self_param ) ] ) ;
103
- let discriminant: u8 = match function. return_type {
104
- CompletionRelevanceReturnType :: Other => 0 ,
105
- CompletionRelevanceReturnType :: DirectConstructor => 1 ,
106
- CompletionRelevanceReturnType :: Constructor => 2 ,
107
- CompletionRelevanceReturnType :: Builder => 3 ,
108
- } ;
109
- hasher. update ( [ discriminant] ) ;
110
- }
111
- }
112
-
113
- let mut hasher = TentHash :: new ( ) ;
114
- hasher. update ( [
115
- u8:: from ( is_ref_completion) ,
116
- u8:: from ( item. is_snippet ) ,
117
- u8:: from ( item. deprecated ) ,
118
- u8:: from ( item. trigger_call_info ) ,
119
- ] ) ;
120
-
121
- hasher. update ( item. label . primary . len ( ) . to_ne_bytes ( ) ) ;
122
- hasher. update ( & item. label . primary ) ;
123
-
124
- hasher. update ( [ u8:: from ( item. label . detail_left . is_some ( ) ) ] ) ;
125
- if let Some ( label_detail) = & item. label . detail_left {
126
- hasher. update ( label_detail. len ( ) . to_ne_bytes ( ) ) ;
127
- hasher. update ( label_detail) ;
128
- }
129
-
130
- hasher. update ( [ u8:: from ( item. label . detail_right . is_some ( ) ) ] ) ;
131
- if let Some ( label_detail) = & item. label . detail_right {
132
- hasher. update ( label_detail. len ( ) . to_ne_bytes ( ) ) ;
133
- hasher. update ( label_detail) ;
134
- }
135
-
136
- // NB: do not hash edits or source range, as those may change between the time the client sends the resolve request
137
- // and the time it receives it: some editors do allow changing the buffer between that, leading to ranges being different.
138
- //
139
- // Documentation hashing is skipped too, as it's a large blob to process,
140
- // while not really making completion properties more unique as they are already.
141
-
142
- let kind_tag = item. kind . tag ( ) ;
143
- hasher. update ( kind_tag. len ( ) . to_ne_bytes ( ) ) ;
144
- hasher. update ( kind_tag) ;
145
-
146
- hasher. update ( item. lookup . len ( ) . to_ne_bytes ( ) ) ;
147
- hasher. update ( & item. lookup ) ;
148
-
149
- hasher. update ( [ u8:: from ( item. detail . is_some ( ) ) ] ) ;
150
- if let Some ( detail) = & item. detail {
151
- hasher. update ( detail. len ( ) . to_ne_bytes ( ) ) ;
152
- hasher. update ( detail) ;
153
- }
154
-
155
- hash_completion_relevance ( & mut hasher, & item. relevance ) ;
156
-
157
- hasher. update ( [ u8:: from ( item. ref_match . is_some ( ) ) ] ) ;
158
- if let Some ( ( ref_mode, text_size) ) = & item. ref_match {
159
- let discriminant = match ref_mode {
160
- CompletionItemRefMode :: Reference ( Mutability :: Shared ) => 0u8 ,
161
- CompletionItemRefMode :: Reference ( Mutability :: Mut ) => 1u8 ,
162
- CompletionItemRefMode :: Dereference => 2u8 ,
163
- } ;
164
- hasher. update ( [ discriminant] ) ;
165
- hasher. update ( u32:: from ( * text_size) . to_ne_bytes ( ) ) ;
166
- }
167
-
168
- hasher. update ( item. import_to_add . len ( ) . to_ne_bytes ( ) ) ;
169
- for import_path in & item. import_to_add {
170
- hasher. update ( import_path. len ( ) . to_ne_bytes ( ) ) ;
171
- hasher. update ( import_path) ;
172
- }
173
-
174
- hasher. finalize ( )
175
- }
176
-
177
74
#[ doc( hidden) ]
178
75
macro_rules! try_default_ {
179
76
( $it: expr $( , ) ?) => {
0 commit comments