@@ -1459,20 +1459,32 @@ declare_lint! {
1459
1459
///
1460
1460
/// ### Explanation
1461
1461
///
1462
- /// The trait bounds in a type alias are currently ignored, and should not
1463
- /// be included to avoid confusion. This was previously allowed
1464
- /// unintentionally; this may become a hard error in the future.
1462
+ /// Trait and lifetime bounds on generic parameters and in where clauses of
1463
+ /// type aliases are not checked at usage sites of the type alias. Moreover,
1464
+ /// they are not thoroughly checked for correctness at their definition site
1465
+ /// either similar to the aliased type.
1466
+ ///
1467
+ /// This is a known limitation of the type checker that may be lifted in a
1468
+ /// future edition. Permitting such bounds in light of this was unintentional.
1469
+ ///
1470
+ /// While these bounds may have secondary effects such as enabling the use of
1471
+ /// "shorthand" associated type paths[^1] and affecting the default trait
1472
+ /// object lifetime[^2] of trait object types passed to the type alias, this
1473
+ /// should not have been allowed until the aforementioned restrictions of the
1474
+ /// type checker have been lifted.
1475
+ ///
1476
+ /// Using such bounds is highly discouraged as they are actively misleading.
1477
+ ///
1478
+ /// [^1]: I.e., paths of the form `T::Assoc` where `T` is a type parameter
1479
+ /// bounded by trait `Trait` which defines an associated type called `Assoc`
1480
+ /// as opposed to a fully qualified path of the form `<T as Trait>::Assoc`.
1481
+ /// [^2]: <https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes>
1465
1482
TYPE_ALIAS_BOUNDS ,
1466
1483
Warn ,
1467
1484
"bounds in type aliases are not enforced"
1468
1485
}
1469
1486
1470
- declare_lint_pass ! (
1471
- /// Lint for trait and lifetime bounds in type aliases being mostly ignored.
1472
- /// They are relevant when using associated types, but otherwise neither checked
1473
- /// at definition site nor enforced at use site.
1474
- TypeAliasBounds => [ TYPE_ALIAS_BOUNDS ]
1475
- ) ;
1487
+ declare_lint_pass ! ( TypeAliasBounds => [ TYPE_ALIAS_BOUNDS ] ) ;
1476
1488
1477
1489
impl TypeAliasBounds {
1478
1490
pub ( crate ) fn affects_object_lifetime_defaults ( pred : & hir:: WherePredicate < ' _ > ) -> bool {
0 commit comments