forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#118812 - notriddle:notriddle/assoc-name-int…
…ern, r=GuillaumeGomez rustdoc-search: do not treat associated type names as types [Before](http://notriddle.com/rustdoc-html-demo-6/tor-before/tor_config/list_builder/trait.DirectDefaultEmptyListBuilderAccessors.html?search=DirectDefaultEmptyListBuilderAccessors%3CT%3DT%3E%20-%3E%20Vec%3CT%3E#associatedtype.T) [After](http://notriddle.com/rustdoc-html-demo-6/tor-after/tor_config/list_builder/trait.DirectDefaultEmptyListBuilderAccessors.html?search=DirectDefaultEmptyListBuilderAccessors%3CT%3DT%3E%20-%3E%20Vec%3CT%3E#associatedtype.T) [Profile](http://notriddle.com/rustdoc-html-demo-6/tor-profile/index.html) As a bit of background information: in type-based queries, a type name that does not exist gets treated as a generic type variable. This causes a counterintuitive behavior in the `tor_config` crate, which has a trait with an associated type variable called `T`. This isn't a searchable concrete type, but its name still gets stored in the typeNameIdMap, as a convenient way to intern its name. (The second commit is a mostly unrelated bugfix.)
- Loading branch information
Showing
4 changed files
with
116 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const EXPECTED = [ | ||
{ | ||
'query': 'T -> T', | ||
'correction': null, | ||
'others': [ | ||
{ | ||
'path': 'enum_variant_not_type', | ||
'name': 'my_fn', | ||
}, | ||
{ | ||
'path': 'enum_variant_not_type::AutoCorrectConfounder', | ||
'name': 'assoc_type_acts_like_generic', | ||
}, | ||
], | ||
}, | ||
{ | ||
'query': 'InsertUnnecessarilyLongTypeNameHere -> InsertUnnecessarilyLongTypeNameHere', | ||
'correction': null, | ||
'others': [ | ||
{ | ||
'path': 'enum_variant_not_type', | ||
'name': 'my_fn', | ||
}, | ||
{ | ||
'path': 'enum_variant_not_type::AutoCorrectConfounder', | ||
'name': 'assoc_type_acts_like_generic', | ||
}, | ||
], | ||
}, | ||
{ | ||
'query': 'InsertUnnecessarilyLongTypeNameHere', | ||
'correction': null, | ||
'others': [ | ||
{ | ||
'path': 'enum_variant_not_type::AutoCorrectConfounder', | ||
'name': 'InsertUnnecessarilyLongTypeNameHere', | ||
}, | ||
], | ||
}, | ||
{ | ||
'query': 'InsertUnnecessarilyLongTypeNameHereX', | ||
'correction': null, | ||
'others': [ | ||
{ | ||
'path': 'enum_variant_not_type::AutoCorrectConfounder', | ||
'name': 'InsertUnnecessarilyLongTypeNameHere', | ||
}, | ||
], | ||
}, | ||
{ | ||
'query': 'T', | ||
'correction': null, | ||
'others': [ | ||
{ | ||
'path': 'enum_variant_not_type::MyTrait', | ||
'name': 'T', | ||
}, | ||
], | ||
}, | ||
{ | ||
'query': 'T', | ||
'correction': null, | ||
'others': [ | ||
{ | ||
'path': 'enum_variant_not_type::MyTrait', | ||
'name': 'T', | ||
}, | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pub trait MyTrait { | ||
// Reduced from `arti` crate. | ||
// https://tpo.pages.torproject.net/core/doc/rust/tor_config/list_builder/trait.DirectDefaultEmptyListBuilderAccessors.html#associatedtype.T | ||
type T; | ||
fn not_appearing(&self) -> Option<&Self::T>; | ||
} | ||
|
||
pub fn my_fn<X>(t: X) -> X { t } | ||
|
||
pub trait AutoCorrectConfounder { | ||
type InsertUnnecessarilyLongTypeNameHere; | ||
fn assoc_type_acts_like_generic(&self, x: &Self::InsertUnnecessarilyLongTypeNameHere) | ||
-> Option<&Self::InsertUnnecessarilyLongTypeNameHere>; | ||
} |