// edition:2018 // aux-build: extern_crate.rs #![crate_name = "foo"] extern crate extern_crate; // @has foo/fn.extern_fn.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub fn extern_fn() -> impl Iterator' pub use extern_crate::extern_fn; // @has foo/struct.ExternTy.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub struct ExternTy {' pub use extern_crate::ExternTy; // @has foo/type.TyAlias.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'type TyAlias = ExternTy;' pub use extern_crate::TyAlias; // @has foo/trait.WTrait.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub trait WTrait' // @has - '//div[@class="item-decl"]/pre[@class="rust"]' 'fn hey() -> usize' pub use extern_crate::WTrait; // @has foo/trait.Trait.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub trait Trait' // @has - '//*[@id="impl-Trait%3C1%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<1> for u8' // @has - '//*[@id="impl-Trait%3C2%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<2> for u8' // @has - '//*[@id="impl-Trait%3C{1%20+%202}%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<{1 + 2}> for u8' // @has - '//*[@id="impl-Trait%3CN%3E-for-%5Bu8%3B%20N%5D"]//h3[@class="code-header"]' \ // 'impl Trait for [u8; N]' pub trait Trait {} impl Trait<1> for u8 {} impl Trait<2> for u8 {} impl Trait<{1 + 2}> for u8 {} impl Trait for [u8; N] {} // @has foo/struct.Foo.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub struct Foowhere u8: Trait' pub struct Foo where u8: Trait; // @has foo/struct.Bar.html '//div[@class="item-decl"]/pre[@class="rust"]' 'pub struct Bar(_)' pub struct Bar([T; N]); // @has foo/struct.Foo.html '//*[@id="impl-Foo%3CM%3E"]/h3[@class="code-header"]' 'impl Foowhere u8: Trait' impl Foo where u8: Trait { // @has - '//*[@id="associatedconstant.FOO_ASSOC"]' 'pub const FOO_ASSOC: usize' pub const FOO_ASSOC: usize = M + 13; // @has - '//*[@id="method.hey"]' 'pub fn hey(&self) -> Bar' pub fn hey(&self) -> Bar { Bar([0; N]) } } // @has foo/struct.Bar.html '//*[@id="impl-Bar%3Cu8%2C%20M%3E"]/h3[@class="code-header"]' 'impl Bar' impl Bar { // @has - '//*[@id="method.hey"]' \ // 'pub fn hey(&self) -> Foowhere u8: Trait' pub fn hey(&self) -> Foo where u8: Trait { Foo } } // @has foo/fn.test.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub fn test() -> impl Traitwhere u8: Trait' pub fn test() -> impl Trait where u8: Trait { 2u8 } // @has foo/fn.a_sink.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub async fn a_sink(v: [u8; N]) -> impl Trait' pub async fn a_sink(v: [u8; N]) -> impl Trait { v } // @has foo/fn.b_sink.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub async fn b_sink(_: impl Trait)' pub async fn b_sink(_: impl Trait) {} // @has foo/fn.concrete.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub fn concrete() -> [u8; 22]' pub fn concrete() -> [u8; 3 + std::mem::size_of::() << 1] { Default::default() } // @has foo/type.Faz.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'type Faz = [u8; N];' pub type Faz = [u8; N]; // @has foo/type.Fiz.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'type Fiz = [[u8; N]; 48];' pub type Fiz = [[u8; N]; 3 << 4]; macro_rules! define_me { ($t:tt<$q:tt>) => { pub struct $t([u8; $q]); } } // @has foo/struct.Foz.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub struct Foz(_);' define_me!(Foz); trait Q { const ASSOC: usize; } impl Q for [u8; N] { const ASSOC: usize = N; } // @has foo/fn.q_user.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub fn q_user() -> [u8; 13]' pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] { [0; <[u8; 13] as Q>::ASSOC] } // @has foo/union.Union.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub union Union' pub union Union { // @has - //pre "pub arr: [u8; N]" pub arr: [u8; N], // @has - //pre "pub another_arr: [(); N]" pub another_arr: [(); N], } // @has foo/enum.Enum.html '//div[@class="item-decl"]/pre[@class="rust"]' \ // 'pub enum Enum' pub enum Enum { // @has - //pre "Variant([u8; N])" Variant([u8; N]), // @has - //pre "EmptyVariant" EmptyVariant, }