@@ -1390,20 +1390,32 @@ declare_lint! {
1390
1390
///
1391
1391
/// ### Explanation
1392
1392
///
1393
- /// The trait bounds in a type alias are currently ignored, and should not
1394
- /// be included to avoid confusion. This was previously allowed
1395
- /// unintentionally; this may become a hard error in the future.
1393
+ /// Trait and lifetime bounds on generic parameters and in where clauses of
1394
+ /// type aliases are not checked at usage sites of the type alias. Moreover,
1395
+ /// they are not thoroughly checked for correctness at their definition site
1396
+ /// either similar to the aliased type.
1397
+ ///
1398
+ /// This is a known limitation of the type checker that may be lifted in a
1399
+ /// future edition. Permitting such bounds in light of this was unintentional.
1400
+ ///
1401
+ /// While these bounds may have secondary effects such as enabling the use of
1402
+ /// "shorthand" associated type paths[^1] and affecting the default trait
1403
+ /// object lifetime[^2] of trait object types passed to the type alias, this
1404
+ /// should not have been allowed until the aforementioned restrictions of the
1405
+ /// type checker have been lifted.
1406
+ ///
1407
+ /// Using such bounds is highly discouraged as they are actively misleading.
1408
+ ///
1409
+ /// [^1]: I.e., paths of the form `T::Assoc` where `T` is a type parameter
1410
+ /// bounded by trait `Trait` which defines an associated type called `Assoc`
1411
+ /// as opposed to a fully qualified path of the form `<T as Trait>::Assoc`.
1412
+ /// [^2]: <https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes>
1396
1413
TYPE_ALIAS_BOUNDS ,
1397
1414
Warn ,
1398
1415
"bounds in type aliases are not enforced"
1399
1416
}
1400
1417
1401
- declare_lint_pass ! (
1402
- /// Lint for trait and lifetime bounds in type aliases being mostly ignored.
1403
- /// They are relevant when using associated types, but otherwise neither checked
1404
- /// at definition site nor enforced at use site.
1405
- TypeAliasBounds => [ TYPE_ALIAS_BOUNDS ]
1406
- ) ;
1418
+ declare_lint_pass ! ( TypeAliasBounds => [ TYPE_ALIAS_BOUNDS ] ) ;
1407
1419
1408
1420
impl TypeAliasBounds {
1409
1421
pub ( crate ) fn affects_object_lifetime_defaults ( pred : & hir:: WherePredicate < ' _ > ) -> bool {
0 commit comments