/src/test/rustdoc/where.rs

https://gitlab.com/rust-lang/rust · Rust · 51 lines · 21 code · 11 blank · 19 comment · 2 complexity · 2567eda407cfcf02700e8937e66aff76 MD5 · raw file

  1. #![feature(generic_associated_types)]
  2. #![crate_name = "foo"]
  3. pub trait MyTrait { fn dummy(&self) { } }
  4. // @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(_) where A: MyTrait"
  5. pub struct Alpha<A>(A) where A: MyTrait;
  6. // @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B> where B: MyTrait"
  7. pub trait Bravo<B> where B: MyTrait { fn get(&self, B: B); }
  8. // @has foo/fn.charlie.html '//pre' "pub fn charlie<C>() where C: MyTrait"
  9. pub fn charlie<C>() where C: MyTrait {}
  10. pub struct Delta<D>(D);
  11. // @has foo/struct.Delta.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \
  12. // "impl<D> Delta<D> where D: MyTrait"
  13. impl<D> Delta<D> where D: MyTrait {
  14. pub fn delta() {}
  15. }
  16. pub struct Echo<E>(E);
  17. // @has 'foo/struct.Simd.html'
  18. // @snapshot SWhere_Simd_item-decl - '//div[@class="docblock item-decl"]'
  19. pub struct Simd<T>([T; 1])
  20. where
  21. T: MyTrait;
  22. // @has 'foo/trait.TraitWhere.html'
  23. // @snapshot SWhere_TraitWhere_item-decl - '//div[@class="docblock item-decl"]'
  24. pub trait TraitWhere {
  25. type Item<'a> where Self: 'a;
  26. }
  27. // @has foo/struct.Echo.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \
  28. // "impl<E> MyTrait for Echo<E> where E: MyTrait"
  29. // @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header in-band"]' \
  30. // "impl<E> MyTrait for Echo<E> where E: MyTrait"
  31. impl<E> MyTrait for Echo<E> where E: MyTrait {}
  32. pub enum Foxtrot<F> { Foxtrot1(F) }
  33. // @has foo/enum.Foxtrot.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \
  34. // "impl<F> MyTrait for Foxtrot<F> where F: MyTrait"
  35. // @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header in-band"]' \
  36. // "impl<F> MyTrait for Foxtrot<F> where F: MyTrait"
  37. impl<F> MyTrait for Foxtrot<F> where F: MyTrait {}
  38. // @has foo/type.Golf.html '//pre[@class="rust typedef"]' \
  39. // "type Golf<T> where T: Clone, = (T, T)"
  40. pub type Golf<T> where T: Clone = (T, T);