rust/tests/rustdoc-js/enum-variant-not-type.rs
Michael Howell 92b84f849a rustdoc-search: do not treat associated type names as types
Before: http://notriddle.com/rustdoc-html-demo-6/tor-before/tor_config/

After: http://notriddle.com/rustdoc-html-demo-6/tor-after/tor_config/

Profile: http://notriddle.com/rustdoc-html-demo-6/tor-profile/

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.
2023-12-10 16:52:21 -07:00

15 lines
532 B
Rust

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>;
}