@@ -13,11 +13,37 @@ declare_lint! {
13
13
/// `impl Trait` in associated type bounds are not written generally enough
14
14
/// to satisfy the bounds of the associated type. This functionality was
15
15
/// removed in #97346, but then rolled back in #99860 because it was made
16
- /// into a hard error too quickly.
16
+ /// into a hard error too quickly and caused regressions .
17
17
///
18
- /// We plan on reintroducing this as a hard error, but in the mean time, this
19
- /// lint serves to warn and suggest fixes for any use-cases which rely on this
20
- /// behavior.
18
+ /// We plan on reintroducing this as a hard error, but in the mean time,
19
+ /// this lint serves to warn and suggest fixes for any use-cases which rely
20
+ /// on this behavior.
21
+ ///
22
+ /// ### Example
23
+ ///
24
+ /// ```
25
+ /// trait Trait {
26
+ /// type Assoc: Send;
27
+ /// }
28
+ ///
29
+ /// struct Struct;
30
+ ///
31
+ /// impl Trait for Struct {
32
+ /// type Assoc = i32;
33
+ /// }
34
+ ///
35
+ /// fn test() -> impl Trait<Assoc = impl Sized> {
36
+ /// Struct
37
+ /// }
38
+ /// ```
39
+ ///
40
+ /// In this example, `test` declares that the associated type `Assoc` for
41
+ /// `impl Trait` is `impl Sized`, which does not satisfy the `Send` bound
42
+ /// on the associated type.
43
+ ///
44
+ /// Although the hidden type, `i32` does satisfy this bound, we do not
45
+ /// consider the return type to be well-formed with this lint. It can be
46
+ /// fixed by changing `impl Sized` into `impl Sized + Send`.
21
47
pub OPAQUE_HIDDEN_INFERRED_BOUND ,
22
48
Warn ,
23
49
"detects the use of nested `impl Trait` types in associated type bounds that are not general enough"
0 commit comments