@@ -388,18 +388,19 @@ pass.
388
388
[ `FnKind::Fn` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/visit/enum.FnKind.html#variant.Fn
389
389
[ ident ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/symbol/struct.Ident.html
390
390
391
- ## Specifying the lint's minimum supported Rust version (msrv )
391
+ ## Specifying the lint's minimum supported Rust version (MSRV )
392
392
393
- Projects supporting older versions of Rust would need to disable a lint if it targets features
394
- present in later versions. Support for this can be added by specifying an msrv in your lint like so,
393
+ Projects supporting older versions of Rust would need to disable a lint if it
394
+ targets features present in later versions. Support for this can be added by
395
+ specifying an MSRV in your lint like so,
395
396
396
397
``` rust
397
398
const MANUAL_STRIP_MSRV : RustcVersion = RustcVersion :: new (1 , 45 , 0 );
398
399
```
399
400
400
- The project's msrv will also have to be an attribute in the lint so you'll have to add a struct
401
- and constructor for your lint. The project's msrv needs to be passed when the lint is registered
402
- in ` lib.rs `
401
+ The project's MSRV will also have to be an attribute in the lint so you'll have
402
+ to add a struct and constructor for your lint. The project's MSRV needs to be
403
+ passed when the lint is registered in ` lib.rs `
403
404
404
405
``` rust
405
406
pub struct ManualStrip {
@@ -414,18 +415,19 @@ impl ManualStrip {
414
415
}
415
416
```
416
417
417
- The project's msrv can then be matched against the lint's msrv in the LintPass using the ` meets_msrv ` utility
418
- function.
418
+ The project's MSRV can then be matched against the lint's ` msrv ` in the LintPass
419
+ using the ` meets_msrv ` utility function.
419
420
420
421
``` rust
421
422
if ! meets_msrv (self . msrv. as_ref (), & MANUAL_STRIP_MSRV ) {
422
423
return ;
423
424
}
424
425
```
425
426
426
- The project's msrv can also be specified as an inner attribute, which overrides the value from
427
- ` clippy.toml ` . This can be accounted for using the ` extract_msrv_attr!(LintContext) ` macro and passing
428
- LateContext/EarlyContext.
427
+ The project's MSRV can also be specified as an inner attribute, which overrides
428
+ the value from ` clippy.toml ` . This can be accounted for using the
429
+ ` extract_msrv_attr!(LintContext) ` macro and passing
430
+ ` LateContext ` /` EarlyContext ` .
429
431
430
432
``` rust
431
433
impl <'tcx > LateLintPass <'tcx > for ManualStrip {
@@ -436,8 +438,20 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip {
436
438
}
437
439
```
438
440
439
- Once the msrv is added to the lint, a relevant test case should be added to ` tests/ui/min_rust_version_attr.rs `
440
- which verifies that the lint isn't emitted if the project's msrv is lower.
441
+ Once the ` msrv ` is added to the lint, a relevant test case should be added to
442
+ ` tests/ui/min_rust_version_attr.rs ` which verifies that the lint isn't emitted
443
+ if the project's MSRV is lower.
444
+
445
+ As a last step, the lint should be added to the lint documentation. This is done
446
+ in ` clippy_lints/src/utils/conf.rs ` :
447
+
448
+ ``` rust
449
+ define_Conf! {
450
+ /// Lint: LIST, OF, LINTS, <THE_NEWLY_ADDED_LINT>. The minimum rust version that the project supports
451
+ (msrv , " msrv" : Option <String >, None ),
452
+ ...
453
+ }
454
+ ```
441
455
442
456
## Author lint
443
457
0 commit comments