Add example to opaque_hidden_inferred_bound lint
This commit is contained in:
parent
426424b320
commit
7a8854037b
@ -11,13 +11,44 @@ use crate::{LateContext, LateLintPass, LintContext};
|
|||||||
declare_lint! {
|
declare_lint! {
|
||||||
/// The `opaque_hidden_inferred_bound` lint detects cases in which nested
|
/// The `opaque_hidden_inferred_bound` lint detects cases in which nested
|
||||||
/// `impl Trait` in associated type bounds are not written generally enough
|
/// `impl Trait` in associated type bounds are not written generally enough
|
||||||
/// to satisfy the bounds of the associated type. This functionality was
|
/// to satisfy the bounds of the associated type.
|
||||||
/// removed in #97346, but then rolled back in #99860 because it was made
|
|
||||||
/// into a hard error too quickly.
|
|
||||||
///
|
///
|
||||||
/// We plan on reintroducing this as a hard error, but in the mean time, this
|
/// ### Explanation
|
||||||
/// lint serves to warn and suggest fixes for any use-cases which rely on this
|
///
|
||||||
/// behavior.
|
/// This functionality was removed in #97346, but then rolled back in #99860
|
||||||
|
/// because it caused regressions.
|
||||||
|
///
|
||||||
|
/// We plan on reintroducing this as a hard error, but in the mean time,
|
||||||
|
/// this lint serves to warn and suggest fixes for any use-cases which rely
|
||||||
|
/// on this behavior.
|
||||||
|
///
|
||||||
|
/// ### Example
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// trait Trait {
|
||||||
|
/// type Assoc: Send;
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// struct Struct;
|
||||||
|
///
|
||||||
|
/// impl Trait for Struct {
|
||||||
|
/// type Assoc = i32;
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn test() -> impl Trait<Assoc = impl Sized> {
|
||||||
|
/// Struct
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// {{produces}}
|
||||||
|
///
|
||||||
|
/// In this example, `test` declares that the associated type `Assoc` for
|
||||||
|
/// `impl Trait` is `impl Sized`, which does not satisfy the `Send` bound
|
||||||
|
/// on the associated type.
|
||||||
|
///
|
||||||
|
/// Although the hidden type, `i32` does satisfy this bound, we do not
|
||||||
|
/// consider the return type to be well-formed with this lint. It can be
|
||||||
|
/// fixed by changing `impl Sized` into `impl Sized + Send`.
|
||||||
pub OPAQUE_HIDDEN_INFERRED_BOUND,
|
pub OPAQUE_HIDDEN_INFERRED_BOUND,
|
||||||
Warn,
|
Warn,
|
||||||
"detects the use of nested `impl Trait` types in associated type bounds that are not general enough"
|
"detects the use of nested `impl Trait` types in associated type bounds that are not general enough"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user