Skip to content

Commit 3eaf6e4

Browse files
authored
Rollup merge of rust-lang#86330 - rylev:update-fcw-handling, r=nikomatsakis
Change how edition based future compatibility warnings are handled This fixes rust-lang#85894 by updating how future compatibility lints work. This makes it more apparent that future compatibility warnings can happen for several different reasons. For now `FutureCompatibilityReasons` are limited to three reasons, but we can easily add more. This also updates the generated warning for FCW's that signal code that will error in a future edition. This makes the diagnostics between FCWs at edition boundaries more distinct from those not happening at an edition boundary. r? `@m-ou-se`
2 parents 5c18ed3 + e7adb02 commit 3eaf6e4

File tree

113 files changed

+473
-636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+473
-636
lines changed

compiler/rustc_lint/src/array_into_iter.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use rustc_errors::Applicability;
33
use rustc_hir as hir;
44
use rustc_middle::ty;
55
use rustc_middle::ty::adjustment::{Adjust, Adjustment};
6-
use rustc_session::lint::FutureBreakage;
6+
use rustc_session::lint::FutureIncompatibilityReason;
7+
use rustc_span::edition::Edition;
78
use rustc_span::symbol::sym;
89

910
declare_lint! {
@@ -37,10 +38,7 @@ declare_lint! {
3738
"detects calling `into_iter` on arrays",
3839
@future_incompatible = FutureIncompatibleInfo {
3940
reference: "issue #66145 <https://github.com/rust-lang/rust/issues/66145>",
40-
edition: None,
41-
future_breakage: Some(FutureBreakage {
42-
date: None
43-
})
41+
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
4442
};
4543
}
4644

compiler/rustc_lint/src/builtin.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
4747
use rustc_middle::ty::subst::{GenericArgKind, Subst};
4848
use rustc_middle::ty::Instance;
4949
use rustc_middle::ty::{self, layout::LayoutError, Ty, TyCtxt};
50+
use rustc_session::lint::FutureIncompatibilityReason;
5051
use rustc_session::Session;
5152
use rustc_span::edition::Edition;
5253
use rustc_span::source_map::Spanned;
@@ -874,7 +875,7 @@ declare_lint! {
874875
"detects anonymous parameters",
875876
@future_incompatible = FutureIncompatibleInfo {
876877
reference: "issue #41686 <https://github.com/rust-lang/rust/issues/41686>",
877-
edition: Some(Edition::Edition2018),
878+
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
878879
};
879880
}
880881

@@ -1663,7 +1664,7 @@ declare_lint! {
16631664
"`...` range patterns are deprecated",
16641665
@future_incompatible = FutureIncompatibleInfo {
16651666
reference: "issue #80165 <https://github.com/rust-lang/rust/issues/80165>",
1666-
edition: Some(Edition::Edition2021),
1667+
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
16671668
};
16681669
}
16691670

@@ -1891,7 +1892,7 @@ declare_lint! {
18911892
"detects edition keywords being used as an identifier",
18921893
@future_incompatible = FutureIncompatibleInfo {
18931894
reference: "issue #49716 <https://github.com/rust-lang/rust/issues/49716>",
1894-
edition: Some(Edition::Edition2018),
1895+
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
18951896
};
18961897
}
18971898

compiler/rustc_lint/src/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ impl LintStore {
209209
bug!("duplicate specification of lint {}", lint.name_lower())
210210
}
211211

212-
if let Some(FutureIncompatibleInfo { edition, .. }) = lint.future_incompatible {
213-
if let Some(edition) = edition {
212+
if let Some(FutureIncompatibleInfo { reason, .. }) = lint.future_incompatible {
213+
if let Some(edition) = reason.edition() {
214214
self.lint_groups
215215
.entry(edition.lint_name())
216216
.or_insert(LintGroup {

compiler/rustc_lint_defs/src/builtin.rs

+6-37
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! compiler code, rather than using their own custom pass. Those
77
//! lints are all available in `rustc_lint::builtin`.
88
9-
use crate::{declare_lint, declare_lint_pass, FutureBreakage};
9+
use crate::{declare_lint, declare_lint_pass, FutureBreakage, FutureIncompatibilityReason};
1010
use rustc_span::edition::Edition;
1111

1212
declare_lint! {
@@ -41,7 +41,6 @@ declare_lint! {
4141
"applying forbid to lint-groups",
4242
@future_incompatible = FutureIncompatibleInfo {
4343
reference: "issue #81670 <https://github.com/rust-lang/rust/issues/81670>",
44-
edition: None,
4544
};
4645
}
4746

@@ -77,7 +76,6 @@ declare_lint! {
7776
"ill-formed attribute inputs that were previously accepted and used in practice",
7877
@future_incompatible = FutureIncompatibleInfo {
7978
reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
80-
edition: None,
8179
};
8280
crate_level_only
8381
}
@@ -114,7 +112,6 @@ declare_lint! {
114112
"conflicts between `#[repr(..)]` hints that were previously accepted and used in practice",
115113
@future_incompatible = FutureIncompatibleInfo {
116114
reference: "issue #68585 <https://github.com/rust-lang/rust/issues/68585>",
117-
edition: None,
118115
};
119116
}
120117

@@ -293,7 +290,6 @@ declare_lint! {
293290
"constant evaluation encountered erroneous expression",
294291
@future_incompatible = FutureIncompatibleInfo {
295292
reference: "issue #71800 <https://github.com/rust-lang/rust/issues/71800>",
296-
edition: None,
297293
};
298294
report_in_external_macro
299295
}
@@ -900,7 +896,6 @@ declare_lint! {
900896
"detect private items in public interfaces not caught by the old implementation",
901897
@future_incompatible = FutureIncompatibleInfo {
902898
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
903-
edition: None,
904899
};
905900
}
906901

@@ -980,7 +975,6 @@ declare_lint! {
980975
"detect public re-exports of private extern crates",
981976
@future_incompatible = FutureIncompatibleInfo {
982977
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
983-
edition: None,
984978
};
985979
}
986980

@@ -1010,7 +1004,6 @@ declare_lint! {
10101004
"type parameter default erroneously allowed in invalid location",
10111005
@future_incompatible = FutureIncompatibleInfo {
10121006
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
1013-
edition: None,
10141007
};
10151008
}
10161009

@@ -1078,7 +1071,6 @@ declare_lint! {
10781071
"detects unaligned references to fields of packed structs",
10791072
@future_incompatible = FutureIncompatibleInfo {
10801073
reference: "issue #82523 <https://github.com/rust-lang/rust/issues/82523>",
1081-
edition: None,
10821074
};
10831075
report_in_external_macro
10841076
}
@@ -1200,7 +1192,6 @@ declare_lint! {
12001192
"patterns in functions without body were erroneously allowed",
12011193
@future_incompatible = FutureIncompatibleInfo {
12021194
reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",
1203-
edition: None,
12041195
};
12051196
}
12061197

@@ -1244,7 +1235,6 @@ declare_lint! {
12441235
"detects missing fragment specifiers in unused `macro_rules!` patterns",
12451236
@future_incompatible = FutureIncompatibleInfo {
12461237
reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
1247-
edition: None,
12481238
};
12491239
}
12501240

@@ -1286,7 +1276,6 @@ declare_lint! {
12861276
"detects generic lifetime arguments in path segments with late bound lifetime parameters",
12871277
@future_incompatible = FutureIncompatibleInfo {
12881278
reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
1289-
edition: None,
12901279
};
12911280
}
12921281

@@ -1322,7 +1311,6 @@ declare_lint! {
13221311
"trait-object types were treated as different depending on marker-trait order",
13231312
@future_incompatible = FutureIncompatibleInfo {
13241313
reference: "issue #56484 <https://github.com/rust-lang/rust/issues/56484>",
1325-
edition: None,
13261314
};
13271315
}
13281316

@@ -1362,7 +1350,6 @@ declare_lint! {
13621350
"distinct impls distinguished only by the leak-check code",
13631351
@future_incompatible = FutureIncompatibleInfo {
13641352
reference: "issue #56105 <https://github.com/rust-lang/rust/issues/56105>",
1365-
edition: None,
13661353
};
13671354
}
13681355

@@ -1554,7 +1541,7 @@ declare_lint! {
15541541
"raw pointer to an inference variable",
15551542
@future_incompatible = FutureIncompatibleInfo {
15561543
reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
1557-
edition: Some(Edition::Edition2018),
1544+
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
15581545
};
15591546
}
15601547

@@ -1621,7 +1608,7 @@ declare_lint! {
16211608
"suggest using `dyn Trait` for trait objects",
16221609
@future_incompatible = FutureIncompatibleInfo {
16231610
reference: "issue #80165 <https://github.com/rust-lang/rust/issues/80165>",
1624-
edition: Some(Edition::Edition2021),
1611+
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
16251612
};
16261613
}
16271614

@@ -1676,7 +1663,7 @@ declare_lint! {
16761663
instead of `crate`, `self`, or an extern crate name",
16771664
@future_incompatible = FutureIncompatibleInfo {
16781665
reference: "issue #53130 <https://github.com/rust-lang/rust/issues/53130>",
1679-
edition: Some(Edition::Edition2018),
1666+
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
16801667
};
16811668
}
16821669

@@ -1725,7 +1712,6 @@ declare_lint! {
17251712
"floating-point literals cannot be used in patterns",
17261713
@future_incompatible = FutureIncompatibleInfo {
17271714
reference: "issue #41620 <https://github.com/rust-lang/rust/issues/41620>",
1728-
edition: None,
17291715
};
17301716
}
17311717

@@ -1769,7 +1755,6 @@ declare_lint! {
17691755
"detects name collision with an existing but unstable method",
17701756
@future_incompatible = FutureIncompatibleInfo {
17711757
reference: "issue #48919 <https://github.com/rust-lang/rust/issues/48919>",
1772-
edition: None,
17731758
// Note: this item represents future incompatibility of all unstable functions in the
17741759
// standard library, and thus should never be removed or changed to an error.
17751760
};
@@ -1873,7 +1858,6 @@ declare_lint! {
18731858
"checks the object safety of where clauses",
18741859
@future_incompatible = FutureIncompatibleInfo {
18751860
reference: "issue #51443 <https://github.com/rust-lang/rust/issues/51443>",
1876-
edition: None,
18771861
};
18781862
}
18791863

@@ -1940,7 +1924,6 @@ declare_lint! {
19401924
"detects proc macro derives using inaccessible names from parent modules",
19411925
@future_incompatible = FutureIncompatibleInfo {
19421926
reference: "issue #83583 <https://github.com/rust-lang/rust/issues/83583>",
1943-
edition: None,
19441927
};
19451928
}
19461929

@@ -2043,7 +2026,6 @@ declare_lint! {
20432026
cannot be referred to by absolute paths",
20442027
@future_incompatible = FutureIncompatibleInfo {
20452028
reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
2046-
edition: None,
20472029
};
20482030
crate_level_only
20492031
}
@@ -2134,7 +2116,6 @@ declare_lint! {
21342116
"constant used in pattern contains value of non-structural-match type in a field or a variant",
21352117
@future_incompatible = FutureIncompatibleInfo {
21362118
reference: "issue #62411 <https://github.com/rust-lang/rust/issues/62411>",
2137-
edition: None,
21382119
};
21392120
}
21402121

@@ -2190,7 +2171,6 @@ declare_lint! {
21902171
"pointers are not structural-match",
21912172
@future_incompatible = FutureIncompatibleInfo {
21922173
reference: "issue #62411 <https://github.com/rust-lang/rust/issues/70861>",
2193-
edition: None,
21942174
};
21952175
}
21962176

@@ -2229,7 +2209,6 @@ declare_lint! {
22292209
expression contains values of non-structural-match types",
22302210
@future_incompatible = FutureIncompatibleInfo {
22312211
reference: "issue #73448 <https://github.com/rust-lang/rust/issues/73448>",
2232-
edition: None,
22332212
};
22342213
}
22352214

@@ -2287,7 +2266,6 @@ declare_lint! {
22872266
"ambiguous associated items",
22882267
@future_incompatible = FutureIncompatibleInfo {
22892268
reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
2290-
edition: None,
22912269
};
22922270
}
22932271

@@ -2318,7 +2296,6 @@ declare_lint! {
23182296
"reservation of a two-phased borrow conflicts with other shared borrows",
23192297
@future_incompatible = FutureIncompatibleInfo {
23202298
reference: "issue #59159 <https://github.com/rust-lang/rust/issues/59159>",
2321-
edition: None,
23222299
};
23232300
}
23242301

@@ -2360,7 +2337,6 @@ declare_lint! {
23602337
"a feature gate that doesn't break dependent crates",
23612338
@future_incompatible = FutureIncompatibleInfo {
23622339
reference: "issue #64266 <https://github.com/rust-lang/rust/issues/64266>",
2363-
edition: None,
23642340
};
23652341
}
23662342

@@ -2589,7 +2565,6 @@ declare_lint! {
25892565
"a C-like enum implementing Drop is cast",
25902566
@future_incompatible = FutureIncompatibleInfo {
25912567
reference: "issue #73333 <https://github.com/rust-lang/rust/issues/73333>",
2592-
edition: None,
25932568
};
25942569
}
25952570

@@ -2629,7 +2604,6 @@ declare_lint! {
26292604
"detects a generic constant is used in a type without a emitting a warning",
26302605
@future_incompatible = FutureIncompatibleInfo {
26312606
reference: "issue #76200 <https://github.com/rust-lang/rust/issues/76200>",
2632-
edition: None,
26332607
};
26342608
}
26352609

@@ -2688,7 +2662,6 @@ declare_lint! {
26882662
"uninhabited static",
26892663
@future_incompatible = FutureIncompatibleInfo {
26902664
reference: "issue #74840 <https://github.com/rust-lang/rust/issues/74840>",
2691-
edition: None,
26922665
};
26932666
}
26942667

@@ -2758,7 +2731,6 @@ declare_lint! {
27582731
"unsupported naked function definitions",
27592732
@future_incompatible = FutureIncompatibleInfo {
27602733
reference: "issue #32408 <https://github.com/rust-lang/rust/issues/32408>",
2761-
edition: None,
27622734
};
27632735
}
27642736

@@ -2831,7 +2803,6 @@ declare_lint! {
28312803
"trailing semicolon in macro body used as expression",
28322804
@future_incompatible = FutureIncompatibleInfo {
28332805
reference: "issue #79813 <https://github.com/rust-lang/rust/issues/79813>",
2834-
edition: None,
28352806
};
28362807
}
28372808

@@ -3154,7 +3125,6 @@ declare_lint! {
31543125
"detects invalid `#[doc(...)]` attributes",
31553126
@future_incompatible = FutureIncompatibleInfo {
31563127
reference: "issue #82730 <https://github.com/rust-lang/rust/issues/82730>",
3157-
edition: None,
31583128
};
31593129
}
31603130

@@ -3201,7 +3171,6 @@ declare_lint! {
32013171
"detects usage of old versions of certain proc-macro crates",
32023172
@future_incompatible = FutureIncompatibleInfo {
32033173
reference: "issue #83125 <https://github.com/rust-lang/rust/issues/83125>",
3204-
edition: None,
32053174
future_breakage: Some(FutureBreakage {
32063175
date: None
32073176
})
@@ -3242,7 +3211,7 @@ declare_lint! {
32423211
"detects usage of old versions of or-patterns",
32433212
@future_incompatible = FutureIncompatibleInfo {
32443213
reference: "issue #84869 <https://github.com/rust-lang/rust/issues/84869>",
3245-
edition: Some(Edition::Edition2021),
3214+
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
32463215
};
32473216
}
32483217

@@ -3291,6 +3260,6 @@ declare_lint! {
32913260
prelude in future editions",
32923261
@future_incompatible = FutureIncompatibleInfo {
32933262
reference: "issue #85684 <https://github.com/rust-lang/rust/issues/85684>",
3294-
edition: Some(Edition::Edition2021),
3263+
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
32953264
};
32963265
}

0 commit comments

Comments
 (0)