@@ -3372,7 +3372,9 @@ declare_lint_pass! {
3372
3372
OVERLAPPING_RANGE_ENDPOINTS ,
3373
3373
PATTERNS_IN_FNS_WITHOUT_BODY ,
3374
3374
POINTER_STRUCTURAL_MATCH ,
3375
+ PRIVATE_BOUNDS ,
3375
3376
PRIVATE_IN_PUBLIC ,
3377
+ PRIVATE_INTERFACES ,
3376
3378
PROC_MACRO_BACK_COMPAT ,
3377
3379
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK ,
3378
3380
PUB_USE_OF_PRIVATE_EXTERN_CRATE ,
@@ -3399,6 +3401,7 @@ declare_lint_pass! {
3399
3401
UNINHABITED_STATIC ,
3400
3402
UNKNOWN_CRATE_TYPES ,
3401
3403
UNKNOWN_LINTS ,
3404
+ UNNAMEABLE_TYPES ,
3402
3405
UNREACHABLE_CODE ,
3403
3406
UNREACHABLE_PATTERNS ,
3404
3407
UNSAFE_OP_IN_UNSAFE_FN ,
@@ -4251,3 +4254,95 @@ declare_lint! {
4251
4254
Warn ,
4252
4255
"\" invalid_parameter\" isn't a valid argument for `#[macro_export]`" ,
4253
4256
}
4257
+
4258
+ declare_lint ! {
4259
+ /// The `private_interfaces` lint detects types in a primary interface of an item,
4260
+ /// that are more private than the item itself. Primary interface of an item is all
4261
+ /// its interface except for bounds on generic parameters and where clauses.
4262
+ ///
4263
+ /// ### Example
4264
+ ///
4265
+ /// ```rust,compile_fail
4266
+ /// # #![allow(unused)]
4267
+ /// # #![allow(private_in_public)]
4268
+ /// #![deny(private_interfaces)]
4269
+ /// struct SemiPriv;
4270
+ ///
4271
+ /// mod m1 {
4272
+ /// struct Priv;
4273
+ /// impl crate::SemiPriv {
4274
+ /// pub fn f(_: Priv) {}
4275
+ /// }
4276
+ /// }
4277
+ ///
4278
+ /// # fn main() {}
4279
+ /// ```
4280
+ ///
4281
+ /// {{produces}}
4282
+ ///
4283
+ /// ### Explanation
4284
+ ///
4285
+ /// Having something private in primary interface guarantees that
4286
+ /// the item will be unusable from outer modules due to type privacy.
4287
+ pub PRIVATE_INTERFACES ,
4288
+ Allow ,
4289
+ "private type in primary interface of an item" ,
4290
+ }
4291
+
4292
+ declare_lint ! {
4293
+ /// The `private_bounds` lint detects types in a secondary interface of an item,
4294
+ /// that are more private than the item itself. Secondary interface of an item consists of
4295
+ /// bounds on generic parameters and where clauses, including supertraits for trait items.
4296
+ ///
4297
+ /// ### Example
4298
+ ///
4299
+ /// ```rust,compile_fail
4300
+ /// # #![allow(private_in_public)]
4301
+ /// # #![allow(unused)]
4302
+ /// #![deny(private_bounds)]
4303
+ ///
4304
+ /// struct PrivTy;
4305
+ /// pub struct S
4306
+ /// where PrivTy:
4307
+ /// {}
4308
+ /// # fn main() {}
4309
+ /// ```
4310
+ ///
4311
+ /// {{produces}}
4312
+ ///
4313
+ /// ### Explanation
4314
+ ///
4315
+ /// Having private types or traits in item bounds makes it less clear what interface
4316
+ /// the item actually provides.
4317
+ pub PRIVATE_BOUNDS ,
4318
+ Allow ,
4319
+ "private type in secondary interface of an item"
4320
+ }
4321
+
4322
+ declare_lint ! {
4323
+ /// The `unnameable_types` lint detects types for which you can get objects of that type,
4324
+ /// but cannot name the type itself.
4325
+ ///
4326
+ /// ### Example
4327
+ ///
4328
+ /// ```rust,compile_fail
4329
+ /// # #![allow(unused)]
4330
+ /// #![deny(unnameable_types)]
4331
+ /// mod m {
4332
+ /// pub struct S;
4333
+ /// }
4334
+ ///
4335
+ /// pub fn get_voldemort() -> m::S { m::S }
4336
+ /// # fn main() {}
4337
+ /// ```
4338
+ ///
4339
+ /// {{produces}}
4340
+ ///
4341
+ /// ### Explanation
4342
+ ///
4343
+ /// It is often expected that if you can obtain an object of type `T`, then
4344
+ /// you can name the type `T` as well, this lint attempts to enforce this rule.
4345
+ pub UNNAMEABLE_TYPES ,
4346
+ Allow ,
4347
+ "effective visibility of a type is larger than the area in which it can be named"
4348
+ }
0 commit comments