1 // Ensure that rustdoc gives errors for trait impls inside function bodies that don't resolve. 2 // See https://github.com/rust-lang/rust/pull/73566 3 pub struct ValidType; 4 pub trait ValidTrait {} 5 pub trait NeedsBody { 6 type Item; f()7 fn f(); 8 } 9 10 /// This function has docs f<B: UnknownBound>(a: UnknownType, b: B)11pub fn f<B: UnknownBound>(a: UnknownType, b: B) { 12 //~^ ERROR cannot find trait `UnknownBound` in this scope 13 //~| ERROR cannot find type `UnknownType` in this scope 14 impl UnknownTrait for ValidType {} //~ ERROR cannot find trait `UnknownTrait` 15 impl<T: UnknownBound> UnknownTrait for T {} 16 //~^ ERROR cannot find trait `UnknownBound` in this scope 17 //~| ERROR cannot find trait `UnknownTrait` in this scope 18 impl ValidTrait for UnknownType {} 19 //~^ ERROR cannot find type `UnknownType` in this scope 20 impl ValidTrait for ValidType where ValidTrait: UnknownBound {} 21 //~^ ERROR cannot find trait `UnknownBound` in this scope 22 23 /// This impl has documentation 24 impl NeedsBody for ValidType { 25 type Item = UnknownType; 26 //~^ ERROR cannot find type `UnknownType` in this scope 27 28 /// This function has documentation 29 fn f() { 30 <UnknownTypeShouldBeIgnored>::a(); 31 content::shouldnt::matter(); 32 unknown_macro!(); 33 //~^ ERROR cannot find macro `unknown_macro` in this scope 34 35 /// This is documentation for a macro 36 macro_rules! can_define_macros_here_too { 37 () => { 38 this::content::should::also::be::ignored() 39 } 40 } 41 can_define_macros_here_too!(); 42 43 /// This also is documented. 44 pub fn doubly_nested(c: UnknownType) { 45 //~^ ERROR cannot find type `UnknownType` in this scope 46 } 47 } 48 } 49 } 50