mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 04:57:19 +00:00 
			
		
		
		
	 12dc24f460
			
		
	
	
		12dc24f460
		
	
	
	
	
		
			
			This commit is a response to feedback on the displayed type signatures results, by making generics act stricter. Generics are tightened by making order significant. This means `Vec<Allocator>` now matches only with a true vector of allocators, instead of matching the second type param. It also makes unboxing within generics stricter, so `Result<A, B>` only matches if `B` is in the error type and `A` is in the success type. The top level of the function search is unaffected. Find the discussion on: * <https://rust-lang.zulipchat.com/#narrow/stream/393423-t-rustdoc.2Fmeetings/topic/meeting.202024-07-08/near/449965149> * <https://github.com/rust-lang/rust/pull/124544#issuecomment-2204272265> * <https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/deciding.20on.20semantics.20of.20generics.20in.20rustdoc.20search/near/476841363>
		
			
				
	
	
		
			234 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			234 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| // exact-check
 | |
| 
 | |
| const EXPECTED = [
 | |
|     // pinkie with explicit names
 | |
|     {
 | |
|         'query': 'usize, usize -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference', 'name': 'pinky' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<usize>, usize -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference', 'name': 'pinky' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<usize>, reference<usize> -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<mut, usize>, usize -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     // thumb with explicit names
 | |
|     {
 | |
|         'query': 'thumb, thumb -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Thumb', 'name': 'up' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<thumb>, thumb -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Thumb', 'name': 'up' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<thumb>, reference<thumb> -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<mut, thumb>, thumb -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     // index with explicit names
 | |
|     {
 | |
|         'query': 'index, index -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Index', 'name': 'point' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<index>, index -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Index', 'name': 'point' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<index>, reference<index> -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<mut, index>, index -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     // ring with explicit names
 | |
|     {
 | |
|         'query': 'ring, ring -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Ring', 'name': 'wear' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<ring>, ring -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Ring', 'name': 'wear' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<ring>, reference<ring> -> ()',
 | |
|         // can't leave out the `mut`, because can't reorder like that
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<mut, ring>, reference<ring> -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Ring', 'name': 'wear' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<mut, ring>, reference<mut, ring> -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     // middle with explicit names
 | |
|     {
 | |
|         'query': 'middle, middle -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference', 'name': 'show' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<middle>, reference<middle> -> ()',
 | |
|         // can't leave out the mut
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<mut, middle>, reference<mut, middle> -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference', 'name': 'show' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<reference<mut, middle>>, reference<mut, reference<middle>> -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference', 'name': 'show' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<mut, reference<middle>>, reference<reference<mut, middle>> -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference', 'name': 'show' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<reference<mut, middle>>, reference<reference<mut, middle>> -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': 'reference<mut, reference<middle>>, reference<mut, reference<middle>> -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     // pinkie with shorthand
 | |
|     {
 | |
|         'query': '&usize, usize -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference', 'name': 'pinky' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': '&usize, &usize -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': '&mut usize, usize -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     // thumb with shorthand
 | |
|     {
 | |
|         'query': '&thumb, thumb -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Thumb', 'name': 'up' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': '&thumb, &thumb -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': '&mut thumb, thumb -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     // index with explicit names
 | |
|     {
 | |
|         'query': '&index, index -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Index', 'name': 'point' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': '&index, &index -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': '&mut index, index -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     // ring with shorthand
 | |
|     {
 | |
|         'query': '&ring, ring -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Ring', 'name': 'wear' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': '&ring, ring -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Ring', 'name': 'wear' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': '&mut ring, &ring -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference::Ring', 'name': 'wear' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': '&mut ring, &mut ring -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     // middle with shorthand
 | |
|     {
 | |
|         'query': '&middle, &middle -> ()',
 | |
|         // can't leave out the mut
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': '&mut middle, &mut middle -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference', 'name': 'show' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': '&&mut middle, &mut &middle -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference', 'name': 'show' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': '&mut &middle, &&mut middle -> ()',
 | |
|         'others': [
 | |
|             { 'path': 'reference', 'name': 'show' },
 | |
|         ],
 | |
|     },
 | |
|     {
 | |
|         'query': '&&mut middle, &&mut middle -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
|     {
 | |
|         'query': '&mut &middle, &mut &middle -> ()',
 | |
|         'others': [],
 | |
|     },
 | |
| ];
 |