Update the description of lint type_alias_bounds
This commit is contained in:
parent
d67b61637e
commit
5859dff742
1 changed files with 21 additions and 9 deletions
|
@ -1390,20 +1390,32 @@ declare_lint! {
|
||||||
///
|
///
|
||||||
/// ### Explanation
|
/// ### Explanation
|
||||||
///
|
///
|
||||||
/// The trait bounds in a type alias are currently ignored, and should not
|
/// Trait and lifetime bounds on generic parameters and in where clauses of
|
||||||
/// be included to avoid confusion. This was previously allowed
|
/// type aliases are not checked at usage sites of the type alias. Moreover,
|
||||||
/// unintentionally; this may become a hard error in the future.
|
/// they are not thoroughly checked for correctness at their definition site
|
||||||
|
/// either similar to the aliased type.
|
||||||
|
///
|
||||||
|
/// This is a known limitation of the type checker that may be lifted in a
|
||||||
|
/// future edition. Permitting such bounds in light of this was unintentional.
|
||||||
|
///
|
||||||
|
/// While these bounds may have secondary effects such as enabling the use of
|
||||||
|
/// "shorthand" associated type paths[^1] and affecting the default trait
|
||||||
|
/// object lifetime[^2] of trait object types passed to the type alias, this
|
||||||
|
/// should not have been allowed until the aforementioned restrictions of the
|
||||||
|
/// type checker have been lifted.
|
||||||
|
///
|
||||||
|
/// Using such bounds is highly discouraged as they are actively misleading.
|
||||||
|
///
|
||||||
|
/// [^1]: I.e., paths of the form `T::Assoc` where `T` is a type parameter
|
||||||
|
/// bounded by trait `Trait` which defines an associated type called `Assoc`
|
||||||
|
/// as opposed to a fully qualified path of the form `<T as Trait>::Assoc`.
|
||||||
|
/// [^2]: <https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes>
|
||||||
TYPE_ALIAS_BOUNDS,
|
TYPE_ALIAS_BOUNDS,
|
||||||
Warn,
|
Warn,
|
||||||
"bounds in type aliases are not enforced"
|
"bounds in type aliases are not enforced"
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint_pass!(
|
declare_lint_pass!(TypeAliasBounds => [TYPE_ALIAS_BOUNDS]);
|
||||||
/// Lint for trait and lifetime bounds in type aliases being mostly ignored.
|
|
||||||
/// They are relevant when using associated types, but otherwise neither checked
|
|
||||||
/// at definition site nor enforced at use site.
|
|
||||||
TypeAliasBounds => [TYPE_ALIAS_BOUNDS]
|
|
||||||
);
|
|
||||||
|
|
||||||
impl TypeAliasBounds {
|
impl TypeAliasBounds {
|
||||||
pub(crate) fn affects_object_lifetime_defaults(pred: &hir::WherePredicate<'_>) -> bool {
|
pub(crate) fn affects_object_lifetime_defaults(pred: &hir::WherePredicate<'_>) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue