Skip to content

Commit e04270f

Browse files
committed
decouple "reporting in deps" from future incompatibility reason
1 parent 52882f6 commit e04270f

File tree

4 files changed

+54
-91
lines changed

4 files changed

+54
-91
lines changed

compiler/rustc_lint/src/levels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn lints_that_dont_need_to_run(tcx: TyCtxt<'_>, (): ()) -> UnordSet<LintId> {
126126
.filter(|lint| {
127127
// Lints that show up in future-compat reports must always be run.
128128
let has_future_breakage =
129-
lint.future_incompatible.is_some_and(|fut| fut.reason.has_future_breakage());
129+
lint.future_incompatible.is_some_and(|fut| fut.report_in_deps);
130130
!has_future_breakage && !lint.eval_always
131131
})
132132
.filter(|lint| {

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ declare_lint! {
178178
Warn,
179179
"applying forbid to lint-groups",
180180
@future_incompatible = FutureIncompatibleInfo {
181-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
181+
reason: FutureIncompatibilityReason::FutureReleaseError,
182182
reference: "issue #81670 <https://github.com/rust-lang/rust/issues/81670>",
183+
report_in_deps: true,
183184
};
184185
}
185186

@@ -214,7 +215,7 @@ declare_lint! {
214215
Deny,
215216
"ill-formed attribute inputs that were previously accepted and used in practice",
216217
@future_incompatible = FutureIncompatibleInfo {
217-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
218+
reason: FutureIncompatibilityReason::FutureReleaseError,
218219
reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
219220
};
220221
crate_level_only
@@ -251,8 +252,9 @@ declare_lint! {
251252
Deny,
252253
"conflicts between `#[repr(..)]` hints that were previously accepted and used in practice",
253254
@future_incompatible = FutureIncompatibleInfo {
254-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
255+
reason: FutureIncompatibilityReason::FutureReleaseError,
255256
reference: "issue #68585 <https://github.com/rust-lang/rust/issues/68585>",
257+
report_in_deps: true,
256258
};
257259
}
258260

@@ -1240,8 +1242,9 @@ declare_lint! {
12401242
Deny,
12411243
"detect public re-exports of private extern crates",
12421244
@future_incompatible = FutureIncompatibleInfo {
1243-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
1245+
reason: FutureIncompatibilityReason::FutureReleaseError,
12441246
reference: "issue #127909 <https://github.com/rust-lang/rust/issues/127909>",
1247+
report_in_deps: true,
12451248
};
12461249
}
12471250

@@ -1270,8 +1273,9 @@ declare_lint! {
12701273
Deny,
12711274
"type parameter default erroneously allowed in invalid location",
12721275
@future_incompatible = FutureIncompatibleInfo {
1273-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
1276+
reason: FutureIncompatibilityReason::FutureReleaseError,
12741277
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
1278+
report_in_deps: true,
12751279
};
12761280
}
12771281

@@ -1409,7 +1413,7 @@ declare_lint! {
14091413
Deny,
14101414
"patterns in functions without body were erroneously allowed",
14111415
@future_incompatible = FutureIncompatibleInfo {
1412-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
1416+
reason: FutureIncompatibilityReason::FutureReleaseError,
14131417
reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",
14141418
};
14151419
}
@@ -1453,8 +1457,9 @@ declare_lint! {
14531457
Deny,
14541458
"detects missing fragment specifiers in unused `macro_rules!` patterns",
14551459
@future_incompatible = FutureIncompatibleInfo {
1456-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
1460+
reason: FutureIncompatibilityReason::FutureReleaseError,
14571461
reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
1462+
report_in_deps: true,
14581463
};
14591464
}
14601465

@@ -1495,7 +1500,7 @@ declare_lint! {
14951500
Warn,
14961501
"detects generic lifetime arguments in path segments with late bound lifetime parameters",
14971502
@future_incompatible = FutureIncompatibleInfo {
1498-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
1503+
reason: FutureIncompatibilityReason::FutureReleaseError,
14991504
reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
15001505
};
15011506
}
@@ -2122,8 +2127,9 @@ declare_lint! {
21222127
Deny,
21232128
"detects proc macro derives using inaccessible names from parent modules",
21242129
@future_incompatible = FutureIncompatibleInfo {
2125-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
2130+
reason: FutureIncompatibilityReason::FutureReleaseError,
21262131
reference: "issue #83583 <https://github.com/rust-lang/rust/issues/83583>",
2132+
report_in_deps: true,
21272133
};
21282134
}
21292135

@@ -2225,7 +2231,7 @@ declare_lint! {
22252231
"macro-expanded `macro_export` macros from the current crate \
22262232
cannot be referred to by absolute paths",
22272233
@future_incompatible = FutureIncompatibleInfo {
2228-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2234+
reason: FutureIncompatibilityReason::FutureReleaseError,
22292235
reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
22302236
};
22312237
crate_level_only
@@ -2346,7 +2352,7 @@ declare_lint! {
23462352
Deny,
23472353
"ambiguous associated items",
23482354
@future_incompatible = FutureIncompatibleInfo {
2349-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2355+
reason: FutureIncompatibilityReason::FutureReleaseError,
23502356
reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
23512357
};
23522358
}
@@ -2362,8 +2368,9 @@ declare_lint! {
23622368
Deny,
23632369
"a feature gate that doesn't break dependent crates",
23642370
@future_incompatible = FutureIncompatibleInfo {
2365-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
2371+
reason: FutureIncompatibilityReason::FutureReleaseError,
23662372
reference: "issue #64266 <https://github.com/rust-lang/rust/issues/64266>",
2373+
report_in_deps: true,
23672374
};
23682375
}
23692376

@@ -2674,7 +2681,7 @@ declare_lint! {
26742681
Warn,
26752682
"detects a generic constant is used in a type without a emitting a warning",
26762683
@future_incompatible = FutureIncompatibleInfo {
2677-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2684+
reason: FutureIncompatibilityReason::FutureReleaseError,
26782685
reference: "issue #76200 <https://github.com/rust-lang/rust/issues/76200>",
26792686
};
26802687
}
@@ -2733,7 +2740,7 @@ declare_lint! {
27332740
Warn,
27342741
"uninhabited static",
27352742
@future_incompatible = FutureIncompatibleInfo {
2736-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2743+
reason: FutureIncompatibilityReason::FutureReleaseError,
27372744
reference: "issue #74840 <https://github.com/rust-lang/rust/issues/74840>",
27382745
};
27392746
}
@@ -2866,7 +2873,7 @@ declare_lint! {
28662873
Warn,
28672874
"detect unsupported use of `Self` from outer item",
28682875
@future_incompatible = FutureIncompatibleInfo {
2869-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2876+
reason: FutureIncompatibilityReason::FutureReleaseError,
28702877
reference: "issue #124186 <https://github.com/rust-lang/rust/issues/124186>",
28712878
};
28722879
}
@@ -2912,8 +2919,9 @@ declare_lint! {
29122919
Warn,
29132920
"trailing semicolon in macro body used as expression",
29142921
@future_incompatible = FutureIncompatibleInfo {
2915-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
2922+
reason: FutureIncompatibilityReason::FutureReleaseError,
29162923
reference: "issue #79813 <https://github.com/rust-lang/rust/issues/79813>",
2924+
report_in_deps: true,
29172925
};
29182926
}
29192927

@@ -2959,7 +2967,7 @@ declare_lint! {
29592967
Warn,
29602968
"detects derive helper attributes that are used before they are introduced",
29612969
@future_incompatible = FutureIncompatibleInfo {
2962-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2970+
reason: FutureIncompatibilityReason::FutureReleaseError,
29632971
reference: "issue #79202 <https://github.com/rust-lang/rust/issues/79202>",
29642972
};
29652973
}
@@ -3126,7 +3134,7 @@ declare_lint! {
31263134
Warn,
31273135
"transparent type contains an external ZST that is marked #[non_exhaustive] or contains private fields",
31283136
@future_incompatible = FutureIncompatibleInfo {
3129-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
3137+
reason: FutureIncompatibilityReason::FutureReleaseError,
31303138
reference: "issue #78586 <https://github.com/rust-lang/rust/issues/78586>",
31313139
};
31323140
}
@@ -3177,7 +3185,7 @@ declare_lint! {
31773185
Warn,
31783186
"unstable syntax can change at any point in the future, causing a hard error!",
31793187
@future_incompatible = FutureIncompatibleInfo {
3180-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
3188+
reason: FutureIncompatibilityReason::FutureReleaseError,
31813189
reference: "issue #65860 <https://github.com/rust-lang/rust/issues/65860>",
31823190
};
31833191
}
@@ -3685,8 +3693,9 @@ declare_lint! {
36853693
Warn,
36863694
"use of unsupported calling convention for function pointer",
36873695
@future_incompatible = FutureIncompatibleInfo {
3688-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
3696+
reason: FutureIncompatibilityReason::FutureReleaseError,
36893697
reference: "issue #130260 <https://github.com/rust-lang/rust/issues/130260>",
3698+
report_in_deps: true,
36903699
};
36913700
}
36923701

@@ -4368,7 +4377,7 @@ declare_lint! {
43684377
Warn,
43694378
"detects certain glob imports that require reporting an ambiguity error",
43704379
@future_incompatible = FutureIncompatibleInfo {
4371-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4380+
reason: FutureIncompatibilityReason::FutureReleaseError,
43724381
reference: "issue #114095 <https://github.com/rust-lang/rust/issues/114095>",
43734382
};
43744383
}
@@ -4523,7 +4532,7 @@ declare_lint! {
45234532
Deny,
45244533
"elided lifetimes cannot be used in associated constants in impls",
45254534
@future_incompatible = FutureIncompatibleInfo {
4526-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4535+
reason: FutureIncompatibilityReason::FutureReleaseError,
45274536
reference: "issue #115010 <https://github.com/rust-lang/rust/issues/115010>",
45284537
};
45294538
}
@@ -4570,7 +4579,7 @@ declare_lint! {
45704579
Warn,
45714580
"detects certain macro bindings that should not be re-exported",
45724581
@future_incompatible = FutureIncompatibleInfo {
4573-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4582+
reason: FutureIncompatibilityReason::FutureReleaseError,
45744583
reference: "issue #120192 <https://github.com/rust-lang/rust/issues/120192>",
45754584
};
45764585
}
@@ -4635,7 +4644,7 @@ declare_lint! {
46354644
Warn,
46364645
"impl contains type parameters that are not covered",
46374646
@future_incompatible = FutureIncompatibleInfo {
4638-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4647+
reason: FutureIncompatibilityReason::FutureReleaseError,
46394648
reference: "issue #124559 <https://github.com/rust-lang/rust/issues/124559>",
46404649
};
46414650
}
@@ -4799,7 +4808,7 @@ declare_lint! {
47994808
Warn,
48004809
"detects out of scope calls to `macro_rules` in key-value attributes",
48014810
@future_incompatible = FutureIncompatibleInfo {
4802-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4811+
reason: FutureIncompatibilityReason::FutureReleaseError,
48034812
reference: "issue #124535 <https://github.com/rust-lang/rust/issues/124535>",
48044813
};
48054814
}
@@ -5040,8 +5049,9 @@ declare_lint! {
50405049
Warn,
50415050
"detects code relying on rustc's non-spec-compliant wasm C ABI",
50425051
@future_incompatible = FutureIncompatibleInfo {
5043-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
5052+
reason: FutureIncompatibilityReason::FutureReleaseError,
50445053
reference: "issue #138762 <https://github.com/rust-lang/rust/issues/138762>",
5054+
report_in_deps: true,
50455055
};
50465056
}
50475057

@@ -5081,7 +5091,8 @@ declare_lint! {
50815091
Warn,
50825092
"detects code that could be affected by ABI issues on aarch64 softfloat targets",
50835093
@future_incompatible = FutureIncompatibleInfo {
5084-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
5094+
reason: FutureIncompatibilityReason::FutureReleaseError,
50855095
reference: "issue #134375 <https://github.com/rust-lang/rust/issues/134375>",
5096+
report_in_deps: true,
50865097
};
50875098
}

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 13 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ pub struct FutureIncompatibleInfo {
361361
/// Set to false for lints that already include a more detailed
362362
/// explanation.
363363
pub explain_reason: bool,
364+
/// If set to true, this will make future incompatibility warnings show up in cargo's
365+
/// reports.
366+
pub report_in_deps: bool,
364367
}
365368

366369
/// The reason for future incompatibility
@@ -379,47 +382,12 @@ pub struct FutureIncompatibleInfo {
379382
#[derive(Copy, Clone, Debug)]
380383
pub enum FutureIncompatibilityReason {
381384
/// This will be an error in a future release for all editions
382-
///
383-
/// This will *not* show up in cargo's future breakage report.
384-
/// The warning will hence only be seen in local crates, not in dependencies.
385-
///
386-
/// Choose this variant when you are first introducing a "future
387-
/// incompatible" warning that is intended to eventually be fixed in the
388-
/// future. This allows crate developers an opportunity to fix the warning
389-
/// before blasting all dependents with a warning they can't fix
390-
/// (dependents have to wait for a new release of the affected crate to be
391-
/// published).
392-
///
393-
/// After a lint has been in this state for a while, consider graduating
394-
/// it to [`FutureIncompatibilityReason::FutureReleaseErrorReportInDeps`].
395-
FutureReleaseErrorDontReportInDeps,
396-
/// This will be an error in a future release, and
397-
/// Cargo should create a report even for dependencies
398-
///
399-
/// This is the *only* reason that will make future incompatibility warnings show up in cargo's
400-
/// reports. All other future incompatibility warnings are not visible when they occur in a
401-
/// dependency.
402-
///
403-
/// Choose this variant after the lint has been sitting in the
404-
/// [`FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps`]
405-
/// state for a while, and you feel like it is ready to graduate to
406-
/// warning everyone. It is a good signal that it is ready if you can
407-
/// determine that all or most affected crates on crates.io have been
408-
/// updated.
409-
///
410-
/// After some period of time, lints with this variant can be turned into
411-
/// hard errors (and the lint removed). Preferably when there is some
412-
/// confidence that the number of impacted projects is very small (few
413-
/// should have a broken dependency in their dependency tree).
414-
///
415-
/// [`EditionAndFutureReleaseError`]: FutureIncompatibilityReason::EditionAndFutureReleaseError
416-
FutureReleaseErrorReportInDeps,
385+
FutureReleaseError,
417386
/// Code that changes meaning in some way in a
418387
/// future release.
419388
///
420389
/// Choose this variant when the semantics of existing code is changing,
421-
/// (as opposed to
422-
/// [`FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps`],
390+
/// (as opposed to [`FutureIncompatibilityReason::FutureReleaseError`],
423391
/// which is for when code is going to be rejected in the future).
424392
FutureReleaseSemanticsChange,
425393
/// Previously accepted code that will become an
@@ -454,13 +422,12 @@ pub enum FutureIncompatibilityReason {
454422
/// This will be an error in the provided edition *and* in a future
455423
/// release.
456424
///
457-
/// This variant a combination of [`FutureReleaseErrorDontReportInDeps`]
458-
/// and [`EditionError`]. This is useful in rare cases when we
459-
/// want to have "preview" of a breaking change in an edition, but do a
460-
/// breaking change later on all editions anyway.
425+
/// This variant a combination of [`FutureReleaseError`] and [`EditionError`].
426+
/// This is useful in rare cases when we want to have "preview" of a breaking
427+
/// change in an edition, but do a breaking change later on all editions anyway.
461428
///
462429
/// [`EditionError`]: FutureIncompatibilityReason::EditionError
463-
/// [`FutureReleaseErrorDontReportInDeps`]: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps
430+
/// [`FutureReleaseError`]: FutureIncompatibilityReason::FutureReleaseError
464431
EditionAndFutureReleaseError(Edition),
465432
/// This will change meaning in the provided edition *and* in a future
466433
/// release.
@@ -478,7 +445,7 @@ pub enum FutureIncompatibilityReason {
478445
/// Choose this variant if the built-in text of the diagnostic of the
479446
/// other variants doesn't match your situation. This is behaviorally
480447
/// equivalent to
481-
/// [`FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps`].
448+
/// [`FutureIncompatibilityReason::FutureReleaseError`].
482449
Custom(&'static str),
483450
}
484451

@@ -490,34 +457,20 @@ impl FutureIncompatibilityReason {
490457
| Self::EditionAndFutureReleaseError(e)
491458
| Self::EditionAndFutureReleaseSemanticsChange(e) => Some(e),
492459

493-
FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps
494-
| FutureIncompatibilityReason::FutureReleaseErrorReportInDeps
460+
FutureIncompatibilityReason::FutureReleaseError
495461
| FutureIncompatibilityReason::FutureReleaseSemanticsChange
496462
| FutureIncompatibilityReason::Custom(_) => None,
497463
}
498464
}
499-
500-
pub fn has_future_breakage(self) -> bool {
501-
match self {
502-
FutureIncompatibilityReason::FutureReleaseErrorReportInDeps => true,
503-
504-
FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps
505-
| FutureIncompatibilityReason::FutureReleaseSemanticsChange
506-
| FutureIncompatibilityReason::EditionError(_)
507-
| FutureIncompatibilityReason::EditionSemanticsChange(_)
508-
| FutureIncompatibilityReason::EditionAndFutureReleaseError(_)
509-
| FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(_)
510-
| FutureIncompatibilityReason::Custom(_) => false,
511-
}
512-
}
513465
}
514466

515467
impl FutureIncompatibleInfo {
516468
pub const fn default_fields_for_macro() -> Self {
517469
FutureIncompatibleInfo {
518470
reference: "",
519-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
471+
reason: FutureIncompatibilityReason::FutureReleaseError,
520472
explain_reason: true,
473+
report_in_deps: false,
521474
}
522475
}
523476
}

0 commit comments

Comments
 (0)