@@ -881,6 +881,13 @@ function initSearch(rawSearchIndex) {
881
881
return a - b ;
882
882
}
883
883
884
+ // sort deprecated items later
885
+ a = aaa . item . deprecated ;
886
+ b = bbb . item . deprecated ;
887
+ if ( a !== b ) {
888
+ return a - b ;
889
+ }
890
+
884
891
// sort by crate (current crate comes first)
885
892
a = ( aaa . item . crate !== preferredCrate ) ;
886
893
b = ( bbb . item . crate !== preferredCrate ) ;
@@ -1244,6 +1251,7 @@ function initSearch(rawSearchIndex) {
1244
1251
parent : item . parent ,
1245
1252
type : item . type ,
1246
1253
is_alias : true ,
1254
+ deprecated : item . deprecated ,
1247
1255
} ;
1248
1256
}
1249
1257
@@ -2064,10 +2072,11 @@ function initSearch(rawSearchIndex) {
2064
2072
* n: Array<string>,
2065
2073
* t: String,
2066
2074
* d: Array<string>,
2067
- * q: Array<string>,
2075
+ * q: Array<[Number, string] >,
2068
2076
* i: Array<Number>,
2069
2077
* f: Array<RawFunctionSearchType>,
2070
2078
* p: Array<Object>,
2079
+ * c: Array<Number>
2071
2080
* }}
2072
2081
*/
2073
2082
const crateCorpus = rawSearchIndex [ crate ] ;
@@ -2086,6 +2095,7 @@ function initSearch(rawSearchIndex) {
2086
2095
type : null ,
2087
2096
id : id ,
2088
2097
normalizedName : crate . indexOf ( "_" ) === - 1 ? crate : crate . replace ( / _ / g, "" ) ,
2098
+ deprecated : null ,
2089
2099
} ;
2090
2100
id += 1 ;
2091
2101
searchIndex . push ( crateRow ) ;
@@ -2095,14 +2105,20 @@ function initSearch(rawSearchIndex) {
2095
2105
const itemTypes = crateCorpus . t ;
2096
2106
// an array of (String) item names
2097
2107
const itemNames = crateCorpus . n ;
2098
- // an array of (String) full paths (or empty string for previous path)
2099
- const itemPaths = crateCorpus . q ;
2108
+ // an array of [(Number) item index,
2109
+ // (String) full path]
2110
+ // an item whose index is not present will fall back to the previous present path
2111
+ // i.e. if indices 4 and 11 are present, but 5-10 and 12-13 are not present,
2112
+ // 5-10 will fall back to the path for 4 and 12-13 will fall back to the path for 11
2113
+ const itemPaths = new Map ( crateCorpus . q ) ;
2100
2114
// an array of (String) descriptions
2101
2115
const itemDescs = crateCorpus . d ;
2102
2116
// an array of (Number) the parent path index + 1 to `paths`, or 0 if none
2103
2117
const itemParentIdxs = crateCorpus . i ;
2104
2118
// an array of (Object | null) the type of the function, if any
2105
2119
const itemFunctionSearchTypes = crateCorpus . f ;
2120
+ // an array of (Number) indices for the deprecated items
2121
+ const deprecatedItems = new Set ( crateCorpus . c ) ;
2106
2122
// an array of [(Number) item type,
2107
2123
// (String) name]
2108
2124
const paths = crateCorpus . p ;
@@ -2142,12 +2158,13 @@ function initSearch(rawSearchIndex) {
2142
2158
crate : crate ,
2143
2159
ty : itemTypes . charCodeAt ( i ) - charA ,
2144
2160
name : itemNames [ i ] ,
2145
- path : itemPaths [ i ] ? itemPaths [ i ] : lastPath ,
2161
+ path : itemPaths . has ( i ) ? itemPaths . get ( i ) : lastPath ,
2146
2162
desc : itemDescs [ i ] ,
2147
2163
parent : itemParentIdxs [ i ] > 0 ? paths [ itemParentIdxs [ i ] - 1 ] : undefined ,
2148
2164
type : buildFunctionSearchType ( itemFunctionSearchTypes [ i ] , lowercasePaths ) ,
2149
2165
id : id ,
2150
2166
normalizedName : word . indexOf ( "_" ) === - 1 ? word : word . replace ( / _ / g, "" ) ,
2167
+ deprecated : deprecatedItems . has ( i ) ,
2151
2168
} ;
2152
2169
id += 1 ;
2153
2170
searchIndex . push ( row ) ;
0 commit comments