]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc-ui/impl-fn-nesting.rs
Auto merge of #107618 - chriswailes:linker-arg, r=albertlarsan68
[rust.git] / tests / rustdoc-ui / impl-fn-nesting.rs
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;
7     fn f();
8 }
9
10 /// This function has docs
11 pub 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 }