mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 04:57:19 +00:00 
			
		
		
		
	 28f17d97a9
			
		
	
	
		28f17d97a9
		
	
	
	
	
		
			
			The search sorting code already sorts by item type discriminant, putting things with smaller discriminants first. There was also a special case for sorting keywords and primitives earlier, and this commit removes it by giving them lower discriminants. The sorting code has another criteria where items with descriptions appear earlier than items without, and that criteria has higher priority than the item type. This shouldn't matter, though, because primitives and keywords normally only appear in the standard library, and it always gives them descriptions.
		
			
				
	
	
		
			246 lines
		
	
	
		
			6.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			246 lines
		
	
	
		
			6.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const PARSED = [
 | |
|     {
 | |
|         query: 'A<B=C>',
 | |
|         elems: [
 | |
|             {
 | |
|                 name: "a",
 | |
|                 fullPath: ["a"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "a",
 | |
|                 generics: [],
 | |
|                 bindings: [
 | |
|                     [
 | |
|                         'b',
 | |
|                         [
 | |
|                             {
 | |
|                                 name: "c",
 | |
|                                 fullPath: ["c"],
 | |
|                                 pathWithoutLast: [],
 | |
|                                 pathLast: "c",
 | |
|                                 generics: [],
 | |
|                                 typeFilter: -1,
 | |
|                             },
 | |
|                         ]
 | |
|                     ],
 | |
|                 ],
 | |
|                 typeFilter: -1,
 | |
|             },
 | |
|         ],
 | |
|         foundElems: 1,
 | |
|         original: 'A<B=C>',
 | |
|         returned: [],
 | |
|         userQuery: 'a<b=c>',
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: 'A<B = C>',
 | |
|         elems: [
 | |
|             {
 | |
|                 name: "a",
 | |
|                 fullPath: ["a"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "a",
 | |
|                 generics: [],
 | |
|                 bindings: [
 | |
|                     [
 | |
|                         'b',
 | |
|                         [{
 | |
|                             name: "c",
 | |
|                             fullPath: ["c"],
 | |
|                             pathWithoutLast: [],
 | |
|                             pathLast: "c",
 | |
|                             generics: [],
 | |
|                             typeFilter: -1,
 | |
|                         }]
 | |
|                     ],
 | |
|                 ],
 | |
|                 typeFilter: -1,
 | |
|             },
 | |
|         ],
 | |
|         foundElems: 1,
 | |
|         original: 'A<B = C>',
 | |
|         returned: [],
 | |
|         userQuery: 'a<b = c>',
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: 'A<B=!>',
 | |
|         elems: [
 | |
|             {
 | |
|                 name: "a",
 | |
|                 fullPath: ["a"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "a",
 | |
|                 generics: [],
 | |
|                 bindings: [
 | |
|                     [
 | |
|                         'b',
 | |
|                         [{
 | |
|                             name: "never",
 | |
|                             fullPath: ["never"],
 | |
|                             pathWithoutLast: [],
 | |
|                             pathLast: "never",
 | |
|                             generics: [],
 | |
|                             typeFilter: 1,
 | |
|                         }]
 | |
|                     ],
 | |
|                 ],
 | |
|                 typeFilter: -1,
 | |
|             },
 | |
|         ],
 | |
|         foundElems: 1,
 | |
|         original: 'A<B=!>',
 | |
|         returned: [],
 | |
|         userQuery: 'a<b=!>',
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: 'A<B=[]>',
 | |
|         elems: [
 | |
|             {
 | |
|                 name: "a",
 | |
|                 fullPath: ["a"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "a",
 | |
|                 generics: [],
 | |
|                 bindings: [
 | |
|                     [
 | |
|                         'b',
 | |
|                         [{
 | |
|                             name: "[]",
 | |
|                             fullPath: ["[]"],
 | |
|                             pathWithoutLast: [],
 | |
|                             pathLast: "[]",
 | |
|                             generics: [],
 | |
|                             typeFilter: 1,
 | |
|                         }]
 | |
|                     ],
 | |
|                 ],
 | |
|                 typeFilter: -1,
 | |
|             },
 | |
|         ],
 | |
|         foundElems: 1,
 | |
|         original: 'A<B=[]>',
 | |
|         returned: [],
 | |
|         userQuery: 'a<b=[]>',
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: 'A<B=[!]>',
 | |
|         elems: [
 | |
|             {
 | |
|                 name: "a",
 | |
|                 fullPath: ["a"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "a",
 | |
|                 generics: [],
 | |
|                 bindings: [
 | |
|                     [
 | |
|                         'b',
 | |
|                         [{
 | |
|                             name: "[]",
 | |
|                             fullPath: ["[]"],
 | |
|                             pathWithoutLast: [],
 | |
|                             pathLast: "[]",
 | |
|                             generics: [
 | |
|                                 {
 | |
|                                     name: "never",
 | |
|                                     fullPath: ["never"],
 | |
|                                     pathWithoutLast: [],
 | |
|                                     pathLast: "never",
 | |
|                                     generics: [],
 | |
|                                     typeFilter: 1,
 | |
|                                 },
 | |
|                             ],
 | |
|                             typeFilter: 1,
 | |
|                         }]
 | |
|                     ],
 | |
|                 ],
 | |
|                 typeFilter: -1,
 | |
|             },
 | |
|         ],
 | |
|         foundElems: 1,
 | |
|         original: 'A<B=[!]>',
 | |
|         returned: [],
 | |
|         userQuery: 'a<b=[!]>',
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: 'A<B=C=>',
 | |
|         elems: [],
 | |
|         foundElems: 0,
 | |
|         original: 'A<B=C=>',
 | |
|         returned: [],
 | |
|         userQuery: 'a<b=c=>',
 | |
|         error: "Cannot write `=` twice in a binding",
 | |
|     },
 | |
|     {
 | |
|         query: 'A<B=>',
 | |
|         elems: [],
 | |
|         foundElems: 0,
 | |
|         original: 'A<B=>',
 | |
|         returned: [],
 | |
|         userQuery: 'a<b=>',
 | |
|         error: "Unexpected `>` after `=`",
 | |
|     },
 | |
|     {
 | |
|         query: 'B=C',
 | |
|         elems: [],
 | |
|         foundElems: 0,
 | |
|         original: 'B=C',
 | |
|         returned: [],
 | |
|         userQuery: 'b=c',
 | |
|         error: "Type parameter `=` must be within generics list",
 | |
|     },
 | |
|     {
 | |
|         query: '[B=C]',
 | |
|         elems: [],
 | |
|         foundElems: 0,
 | |
|         original: '[B=C]',
 | |
|         returned: [],
 | |
|         userQuery: '[b=c]',
 | |
|         error: "Type parameter `=` cannot be within slice `[]`",
 | |
|     },
 | |
|     {
 | |
|         query: 'A<B<X>=C>',
 | |
|         elems: [
 | |
|             {
 | |
|                 name: "a",
 | |
|                 fullPath: ["a"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "a",
 | |
|                 generics: [],
 | |
|                 bindings: [
 | |
|                     [
 | |
|                         'b',
 | |
|                         [
 | |
|                             {
 | |
|                                 name: "c",
 | |
|                                 fullPath: ["c"],
 | |
|                                 pathWithoutLast: [],
 | |
|                                 pathLast: "c",
 | |
|                                 generics: [],
 | |
|                                 typeFilter: -1,
 | |
|                             },
 | |
|                             {
 | |
|                                 name: "x",
 | |
|                                 fullPath: ["x"],
 | |
|                                 pathWithoutLast: [],
 | |
|                                 pathLast: "x",
 | |
|                                 generics: [],
 | |
|                                 typeFilter: -1,
 | |
|                             },
 | |
|                         ],
 | |
|                     ],
 | |
|                 ],
 | |
|                 typeFilter: -1,
 | |
|             },
 | |
|         ],
 | |
|         foundElems: 1,
 | |
|         original: 'A<B<X>=C>',
 | |
|         returned: [],
 | |
|         userQuery: 'a<b<x>=c>',
 | |
|         error: null,
 | |
|     },
 | |
| ];
 |