@@ -586,15 +586,21 @@ but warn-by-default in the 2018 edition.
586
586
587
587
### Future-incompatible lints
588
588
589
- Future-incompatible lints are for signalling to the user that code they have
589
+ The use of the term ` future-incompatible ` within the compiler has a slightly
590
+ broader meaning than what rustc exposes to users of the compiler.
591
+
592
+ Inside rustc, future-incompatible lints are for signalling to the user that code they have
590
593
written may not compile in the future. In general, future-incompatible code
591
594
exists for two reasons:
592
595
* the user has written unsound code that the compiler mistakenly accepted. While
593
596
it is within Rust's backwards compatibility guarantees to fix the soundness hole
594
597
(breaking the user's code), the lint is there to warn the user that this will happen
595
- in some upcoming version * regardless of which edition they are on* .
598
+ in some upcoming version of rustc * regardless of which edition the code uses* . This is the
599
+ meaning that rustc exclusively exposes to users as "future incompatible".
596
600
* the user has written code that will either no longer compiler * or* will change
597
- meaning in an upcoming edition.
601
+ meaning in an upcoming * edition* . These are often called "edition lints" and can be
602
+ typically seen in the various "edition compatibility" lint groups (e.g., ` rust_2021_compatibility ` )
603
+ that are used to lint against code that will break if the user updates the crate's edition.
598
604
599
605
A future-incompatible lint should be declared with the ` @future_incompatible `
600
606
additional "field":
@@ -611,9 +617,17 @@ declare_lint! {
611
617
}
612
618
```
613
619
614
- Notice the ` reason ` field which describes why the future- incompatible change is happening.
620
+ Notice the ` reason ` field which describes why the future incompatible change is happening.
615
621
This will change the diagnostic message the user receives as well as determine which
616
- lint groups the lint is added to.
622
+ lint groups the lint is added to. In the example above, the lint is an "edition lint"
623
+ (since it's "reason" is ` EditionError ` ) signifying to the user that the use of anonymous
624
+ parameters will no longer compile in Rust 2018 and beyond.
625
+
626
+ Inside [ LintStore::register_lints] [ fi-lint-groupings ] , lints with ` future_incompatible `
627
+ fields get placed into either edition-based lint groups (if their ` reason ` is tied to
628
+ an edition) or into the ` future_incompatibility ` lint group.
629
+
630
+ [ fi-lint-groupings ] : https://github.com/rust-lang/rust/blob/51fd129ac12d5bfeca7d216c47b0e337bf13e0c2/compiler/rustc_lint/src/context.rs#L212-L237
617
631
618
632
If you need a combination of options that's not supported by the
619
633
` declare_lint! ` macro, you can always change the ` declare_lint! ` macro
0 commit comments