diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 2c8c6a3ce7f17..67c12bcd8914b 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -32,7 +32,7 @@ use rustc_hir::intravisit::FnKind as HirFnKind; use rustc_hir::{self as hir, Body, FnDecl, ImplItemImplKind, PatKind, PredicateOrigin}; // Lints from rustc_lint_defs pub use rustc_lint_defs::builtin::*; -use rustc_lint_defs::{declare_lint, declare_lint_pass, fcw, impl_lint_pass}; +use rustc_lint_defs::{ReportInDeps, declare_lint, declare_lint_pass, impl_lint_pass}; use rustc_middle::ty::consts::ConstExt; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::print::with_no_trimmed_paths; @@ -702,9 +702,7 @@ declare_lint! { pub ANONYMOUS_PARAMETERS, Warn, "detects anonymous parameters", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2018 "trait-fn-parameters"), - }; + @future_incompatible = edition_error(2018, "trait-fn-parameters"); } declare_lint_pass!( @@ -1553,9 +1551,7 @@ declare_lint! { pub ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, Warn, "`...` range patterns are deprecated", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2021 "warnings-promoted-to-error"), - }; + @future_incompatible = edition_error(2021, "warnings-promoted-to-error"); } #[derive(Default)] @@ -1688,9 +1684,7 @@ declare_lint! { pub KEYWORD_IDENTS_2018, Allow, "detects edition keywords being used as an identifier", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2018 "new-keywords"), - }; + @future_incompatible = edition_error(2018, "new-keywords"); } declare_lint! { @@ -1732,9 +1726,7 @@ declare_lint! { pub KEYWORD_IDENTS_2024, Allow, "detects edition keywords being used as an identifier", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2024 "gen-keyword"), - }; + @future_incompatible = edition_error(2024, "gen-keyword"); } declare_lint_pass!( @@ -3151,10 +3143,7 @@ declare_lint! { pub INTERNAL_EQ_TRAIT_METHOD_IMPLS, Warn, "manual implementation of the internal `Eq::assert_receiver_is_total_eq` method", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #152336), - report_in_deps: false, - }; + @future_incompatible = future_release_error(152336, ReportInDeps::No); } declare_lint_pass!(InternalEqTraitMethodImpls => [INTERNAL_EQ_TRAIT_METHOD_IMPLS]); diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index c29cff23acee1..4a2a045d9bf79 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -5,7 +5,7 @@ use hir::intravisit::{self, Visitor}; use rustc_ast::Recovered; use rustc_errors::{Applicability, Diag, Subdiagnostic, SuggestionStyle, msg}; use rustc_hir::{self as hir, HirIdSet}; -use rustc_lint_defs::{LintId, declare_lint, fcw, impl_lint_pass}; +use rustc_lint_defs::{LintId, declare_lint, impl_lint_pass}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::significant_drop_order::{ @@ -83,9 +83,7 @@ declare_lint! { Allow, "`if let` assigns a shorter lifetime to temporary values being pattern-matched against in Edition 2024 and \ rewriting in `match` is an option to preserve the semantics up to Edition 2021", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionSemanticsChange 2024 "temporary-if-let-scope"), - }; + @future_incompatible = edition_semantics_change(2024, "temporary-if-let-scope"); } /// Lint for potential change in program semantics of `if let`s diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index 9d7d0a0df475f..92cb96df9393d 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -9,7 +9,7 @@ use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::outlives::env::OutlivesEnvironment; -use rustc_lint_defs::{declare_lint, declare_lint_pass, fcw}; +use rustc_lint_defs::{declare_lint, declare_lint_pass}; use rustc_macros::Diagnostic; use rustc_middle::middle::resolve_bound_vars::ResolvedArg; use rustc_middle::ty::relate::{ @@ -68,9 +68,7 @@ declare_lint! { pub IMPL_TRAIT_OVERCAPTURES, Allow, "`impl Trait` will capture more lifetimes than possibly intended in edition 2024", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionSemanticsChange 2024 "rpit-lifetime-capture"), - }; + @future_incompatible = edition_semantics_change(2024, "rpit-lifetime-capture"); } declare_lint! { diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index f847d4c6ae904..3694b2c7cad6b 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -16,7 +16,8 @@ use rustc_lint_defs::builtin::{ UNFULFILLED_LINT_EXPECTATIONS, UNKNOWN_LINTS, UNUSED_ATTRIBUTES, }; use rustc_lint_defs::{ - Level, Lint, LintExpectationId, LintId, StableLintExpectationId, UnstableLintExpectationId, + Level, Lint, LintExpectationId, LintId, ReportInDeps, StableLintExpectationId, + UnstableLintExpectationId, }; use rustc_middle::hir::nested_filter; use rustc_middle::lint::{ @@ -121,8 +122,9 @@ fn skippable_lints(tcx: TyCtxt<'_>, (): ()) -> UnordSet { .into_iter() .filter(|lint| { // Lints that show up in future-compat reports must always be run. - let has_future_breakage = - lint.future_incompatible.is_some_and(|fut| fut.report_in_deps); + let has_future_breakage = lint + .future_incompatible + .is_some_and(|fut| matches!(fut.reason.report_in_deps(), ReportInDeps::Yes)); !has_future_breakage && !lint.eval_always }) .filter(|lint| { diff --git a/compiler/rustc_lint/src/macro_expr_fragment_specifier_2024_migration.rs b/compiler/rustc_lint/src/macro_expr_fragment_specifier_2024_migration.rs index 018b921a6b016..84c6b2503fb21 100644 --- a/compiler/rustc_lint/src/macro_expr_fragment_specifier_2024_migration.rs +++ b/compiler/rustc_lint/src/macro_expr_fragment_specifier_2024_migration.rs @@ -2,7 +2,7 @@ use rustc_ast::token::{Token, TokenKind}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; -use rustc_lint_defs::{declare_lint, declare_lint_pass, fcw}; +use rustc_lint_defs::{declare_lint, declare_lint_pass}; use rustc_span::edition::Edition; use rustc_span::sym; use tracing::debug; @@ -70,9 +70,7 @@ declare_lint! { Allow, "The `expr` fragment specifier will accept more expressions in the 2024 edition. \ To keep the existing behavior, use the `expr_2021` fragment specifier.", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionSemanticsChange 2024 "macro-fragment-specifiers"), - }; + @future_incompatible = edition_semantics_change(2024, "macro-fragment-specifiers"); } declare_lint_pass!(Expr2024 => [EDITION_2024_EXPR_FRAGMENT_SPECIFIER,]); diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index 6fd65af794ac6..4f287f9485730 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -4,7 +4,7 @@ use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, Level, msg}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_infer::infer::TyCtxtInferExt; -use rustc_lint_defs::{declare_lint, declare_lint_pass, fcw}; +use rustc_lint_defs::{declare_lint, declare_lint_pass}; use rustc_middle::ty; use rustc_parse_format::{ParseMode, Parser, Piece}; use rustc_span::{InnerSpan, Span, Symbol, bug, hygiene, sym}; @@ -37,10 +37,7 @@ declare_lint! { NON_FMT_PANICS, Warn, "detect single-argument panic!() invocations in which the argument is not a format string", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionSemanticsChange 2021 "panic-macro-consistency"), - explain_reason: false, - }; + @future_incompatible = edition_semantics_change(2021, "panic-macro-consistency").dont_explain_reason(); report_in_external_macro } diff --git a/compiler/rustc_lint/src/shadowed_into_iter.rs b/compiler/rustc_lint/src/shadowed_into_iter.rs index 021499f6b712c..39ca96d311271 100644 --- a/compiler/rustc_lint/src/shadowed_into_iter.rs +++ b/compiler/rustc_lint/src/shadowed_into_iter.rs @@ -1,6 +1,6 @@ use rustc_attr_ir::lang_items::LangItem; use rustc_hir as hir; -use rustc_lint_defs::{declare_lint, fcw, impl_lint_pass}; +use rustc_lint_defs::{declare_lint, impl_lint_pass}; use rustc_middle::ty::{self, Ty}; use crate::diagnostics::{ShadowedIntoIterDiag, ShadowedIntoIterDiagSub}; @@ -29,9 +29,7 @@ declare_lint! { pub ARRAY_INTO_ITER, Warn, "detects calling `into_iter` on arrays in Rust 2015 and 2018", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionSemanticsChange 2021 "IntoIterator-for-arrays"), - }; + @future_incompatible = edition_semantics_change(2021, "IntoIterator-for-arrays"); } declare_lint! { @@ -57,9 +55,7 @@ declare_lint! { pub BOXED_SLICE_INTO_ITER, Warn, "detects calling `into_iter` on boxed slices in Rust 2015, 2018, and 2021", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionSemanticsChange 2024 "intoiterator-box-slice"), - }; + @future_incompatible = edition_semantics_change(2024, "intoiterator-box-slice"); } #[derive(Copy, Clone)] diff --git a/compiler/rustc_lint/src/static_mut_refs.rs b/compiler/rustc_lint/src/static_mut_refs.rs index ddb33edfbabe7..5a7b6d39fe9b8 100644 --- a/compiler/rustc_lint/src/static_mut_refs.rs +++ b/compiler/rustc_lint/src/static_mut_refs.rs @@ -1,7 +1,7 @@ use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::{Expr, Stmt}; -use rustc_lint_defs::{declare_lint, declare_lint_pass, fcw}; +use rustc_lint_defs::{declare_lint, declare_lint_pass}; use rustc_middle::ty::{Mutability, TyKind}; use rustc_span::{BytePos, Span}; @@ -51,10 +51,7 @@ declare_lint! { pub STATIC_MUT_REFS, Warn, "creating a shared reference to mutable static", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2024 "static-mut-references"), - explain_reason: false, - }; + @future_incompatible = edition_error(2024, "static-mut-references").dont_explain_reason(); @edition Edition2024 => Deny; } diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 2a0901e0243b6..6c8ab42f6f3b6 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -7,7 +7,7 @@ //! When removing a lint, make sure to also add a call to `register_removed` in //! compiler/rustc_lint/src/lib.rs. -use crate::{declare_lint, declare_lint_pass, fcw}; +use crate::{ReportInDeps, custom_future_incompatible, declare_lint, declare_lint_pass}; pub mod hardwired { use super::*; @@ -195,10 +195,7 @@ declare_lint! { pub FORBIDDEN_LINT_GROUPS, Warn, "applying forbid to lint-groups", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #81670), - report_in_deps: true, - }; + @future_incompatible = future_release_error(81670, ReportInDeps::Yes); // We exempt `FORBIDDEN_LINT_GROUPS` from `-Dwarnings` because it specifically // triggers in cases (like #80988) where you have `forbid(warnings)`, // and so if we turned that into an error, it'd defeat the purpose of the @@ -236,10 +233,7 @@ declare_lint! { pub ILL_FORMED_ATTRIBUTE_INPUT, Deny, "ill-formed attribute inputs that were previously accepted and used in practice", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #57571), - report_in_deps: true, - }; + @future_incompatible = future_release_error(57571, ReportInDeps::Yes); crate_level_only } @@ -273,10 +267,7 @@ declare_lint! { pub CONFLICTING_REPR_HINTS, Deny, "conflicts between `#[repr(..)]` hints that were previously accepted and used in practice", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #68585), - report_in_deps: true, - }; + @future_incompatible = future_release_error(68585, ReportInDeps::Yes); } declare_lint! { @@ -1385,10 +1376,7 @@ declare_lint! { pub PUB_USE_OF_PRIVATE_EXTERN_CRATE, Deny, "detect public re-exports of private extern crates", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #127909), - report_in_deps: true, - }; + @future_incompatible = future_release_error(127909, ReportInDeps::Yes); } declare_lint! { @@ -1415,10 +1403,7 @@ declare_lint! { pub INVALID_TYPE_PARAM_DEFAULT, Deny, "type parameter default erroneously allowed in invalid location", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #36887), - report_in_deps: true, - }; + @future_incompatible = future_release_error(36887, ReportInDeps::Yes); } declare_lint! { @@ -1554,9 +1539,7 @@ declare_lint! { pub PATTERNS_IN_FNS_WITHOUT_BODY, Deny, "patterns in functions without body were erroneously allowed", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #35203), - }; + @future_incompatible = future_release_error(35203, ReportInDeps::No); } declare_lint! { @@ -1595,9 +1578,7 @@ declare_lint! { pub LATE_BOUND_LIFETIME_ARGUMENTS, Warn, "detects generic lifetime arguments in path segments with late bound lifetime parameters", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #42868), - }; + @future_incompatible = future_release_error(42868, ReportInDeps::No); } declare_lint! { @@ -1634,9 +1615,7 @@ declare_lint! { pub COHERENCE_LEAK_CHECK, Warn, "distinct impls distinguished only by the leak-check code", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!("the behavior may change in a future release" #56105), - }; + @future_incompatible = custom_future_incompatible("the behavior may change in a future release", 56105, ReportInDeps::No); } declare_lint! { @@ -1737,9 +1716,7 @@ declare_lint! { pub RUST_2024_INCOMPATIBLE_PAT, Allow, "detects patterns whose meaning will change in Rust 2024", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionSemanticsChange 2024 "match-ergonomics"), - }; + @future_incompatible = edition_semantics_change(2024, "match-ergonomics"); } declare_lint! { @@ -1884,9 +1861,7 @@ declare_lint! { pub TYVAR_BEHIND_RAW_POINTER, Warn, "raw pointer to an inference variable", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2018 "tyvar-behind-raw-pointer"), - }; + @future_incompatible = edition_error(2018, "tyvar-behind-raw-pointer"); } declare_lint! { @@ -1950,9 +1925,7 @@ declare_lint! { pub BARE_TRAIT_OBJECTS, Warn, "suggest using `dyn Trait` for trait objects", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2021 "warnings-promoted-to-error"), - }; + @future_incompatible = edition_error(2021, "warnings-promoted-to-error"); } declare_lint! { @@ -2004,9 +1977,7 @@ declare_lint! { Allow, "fully qualified paths that start with a module name \ instead of `crate`, `self`, or an extern crate name", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2018 "path-changes"), - }; + @future_incompatible = edition_error( 2018, "path-changes"); } declare_lint! { @@ -2051,15 +2022,14 @@ declare_lint! { pub UNSTABLE_NAME_COLLISIONS, Warn, "detects name collision with an existing but unstable method", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!( - "once this associated item is added to the standard library, \ - the ambiguity may cause an error or change in behavior!" - #48919 - ), - // Note: this item represents future incompatibility of all unstable functions in the - // standard library, and thus should never be removed or changed to an error. - }; + // Note: this item represents future incompatibility of all unstable functions in the + // standard library, and thus should never be removed or changed to an error. + @future_incompatible = custom_future_incompatible( + "once this associated item is added to the standard library, \ + the ambiguity may cause an error or change in behavior!", + 48919, + ReportInDeps::No, + ); } declare_lint! { @@ -2184,10 +2154,7 @@ declare_lint! { pub PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, Deny, "detects proc macro derives using inaccessible names from parent modules", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #83583), - report_in_deps: true, - }; + @future_incompatible = future_release_error(83583, ReportInDeps::Yes); } declare_lint! { @@ -2287,10 +2254,7 @@ declare_lint! { Deny, "macro-expanded `macro_export` macros from the current crate \ cannot be referred to by absolute paths", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #52234), - report_in_deps: true, - }; + @future_incompatible = future_release_error(52234, ReportInDeps::Yes); crate_level_only } @@ -2440,9 +2404,7 @@ declare_lint! { pub AMBIGUOUS_ASSOCIATED_ITEMS, Deny, "ambiguous associated items", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #57644), - }; + @future_incompatible = future_release_error(57644, ReportInDeps::No); } declare_lint! { @@ -2648,10 +2610,7 @@ declare_lint! { pub UNSAFE_OP_IN_UNSAFE_FN, Allow, "unsafe operations in unsafe functions without an explicit unsafe block are deprecated", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2024 "unsafe-op-in-unsafe-fn"), - explain_reason: false - }; + @future_incompatible = edition_error(2024, "unsafe-op-in-unsafe-fn").dont_explain_reason(); @edition Edition2024 => Warn; } @@ -2689,9 +2648,7 @@ declare_lint! { pub CONST_EVALUATABLE_UNCHECKED, Warn, "detects a generic constant is used in a type without a emitting a warning", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #76200), - }; + @future_incompatible = future_release_error(76200, ReportInDeps::No); } declare_lint! { @@ -2747,10 +2704,7 @@ declare_lint! { pub UNINHABITED_STATIC, Deny, "uninhabited static", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #74840), - report_in_deps: true, - }; + @future_incompatible = future_release_error(74840, ReportInDeps::Yes); } declare_lint! { @@ -2913,9 +2867,7 @@ declare_lint! { pub SELF_CONSTRUCTOR_FROM_OUTER_ITEM, Warn, "detect unsupported use of `Self` from outer item", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #124186), - }; + @future_incompatible = future_release_error(124186, ReportInDeps::No); } declare_lint! { @@ -2958,10 +2910,7 @@ declare_lint! { pub SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, Deny, "trailing semicolon in macro body used as expression", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #79813), - report_in_deps: true, - }; + @future_incompatible = future_release_error(79813, ReportInDeps::Yes); } declare_lint! { @@ -3022,10 +2971,7 @@ declare_lint! { pub SEMICOLON_IN_EXPRESSIONS_FROM_NON_LOCAL_MACROS, Warn, "trailing semicolon in macro body used as expression", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #79813), - report_in_deps: true, - }; + @future_incompatible = future_release_error(79813, ReportInDeps::Yes); } declare_lint! { @@ -3069,10 +3015,7 @@ declare_lint! { pub LEGACY_DERIVE_HELPERS, Deny, "detects derive helper attributes that are used before they are introduced", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #79202), - report_in_deps: true, - }; + @future_incompatible = future_release_error(79202, ReportInDeps::Yes); } declare_lint! { @@ -3232,9 +3175,7 @@ declare_lint! { pub UNSTABLE_SYNTAX_PRE_EXPANSION, Warn, "unstable syntax can change at any point in the future, causing a hard error!", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #154045), - }; + @future_incompatible = future_release_error(154045, ReportInDeps::No); } declare_lint! { @@ -3473,10 +3414,7 @@ declare_lint! { pub RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, Allow, "detects closures affected by Rust 2021 changes", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionSemanticsChange 2021 "disjoint-capture-in-closures"), - explain_reason: false, - }; + @future_incompatible = edition_semantics_change(2021, "disjoint-capture-in-closures").dont_explain_reason(); } declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]); @@ -3568,9 +3506,7 @@ declare_lint! { pub RUST_2021_INCOMPATIBLE_OR_PATTERNS, Allow, "detects usage of old versions of or-patterns", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2021 "or-patterns-macro-rules"), - }; + @future_incompatible = edition_error(2021, "or-patterns-macro-rules"); } declare_lint! { @@ -3616,9 +3552,7 @@ declare_lint! { Allow, "detects the usage of trait methods which are ambiguous with traits added to the \ prelude in future editions", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2021 "prelude"), - }; + @future_incompatible = edition_error(2021, "prelude"); } declare_lint! { @@ -3655,9 +3589,7 @@ declare_lint! { Allow, "detects the usage of trait methods which are ambiguous with traits added to the \ prelude in future editions", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2024 "prelude"), - }; + @future_incompatible = edition_error(2024, "prelude"); } declare_lint! { @@ -3691,9 +3623,7 @@ declare_lint! { pub RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, Allow, "identifiers that will be parsed as a prefix in Rust 2021", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionSemanticsChange 2021 "reserving-syntax"), - }; + @future_incompatible = edition_semantics_change(2021, "reserving-syntax"); crate_level_only } @@ -3738,10 +3668,7 @@ declare_lint! { pub UNSUPPORTED_CALLING_CONVENTIONS, Warn, "use of unsupported calling convention", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #137018), - report_in_deps: false, - }; + @future_incompatible = future_release_error(137018, ReportInDeps::No); } declare_lint! { @@ -3782,10 +3709,7 @@ declare_lint! { pub UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS, Warn, "use of unsupported calling convention for function pointer", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #130260), - report_in_deps: true, - }; + @future_incompatible = future_release_error(130260, ReportInDeps::Yes); } declare_lint! { @@ -4289,10 +4213,7 @@ declare_lint! { pub INVALID_MACRO_EXPORT_ARGUMENTS, Deny, "\"invalid_parameter\" isn't a valid argument for `#[macro_export]`", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #57571), - report_in_deps: true, - }; + @future_incompatible = future_release_error(57571, ReportInDeps::Yes); } declare_lint! { @@ -4359,9 +4280,7 @@ declare_lint! { pub AMBIGUOUS_DERIVE_HELPERS, Warn, "detects derive helper attributes that are ambiguous with built-in attributes", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #151276), - }; + @future_incompatible = future_release_error(151276, ReportInDeps::No); } declare_lint! { @@ -4615,10 +4534,7 @@ declare_lint! { pub AMBIGUOUS_GLOB_IMPORTS, Deny, "detects certain glob imports that require reporting an ambiguity error", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #114095), - report_in_deps: true, - }; + @future_incompatible = future_release_error(114095, ReportInDeps::Yes); } declare_lint! { @@ -4688,10 +4604,7 @@ declare_lint! { pub AMBIGUOUS_GLOB_IMPORTED_TRAITS, Warn, "detects uses of ambiguously glob imported traits", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #152822), - report_in_deps: false, - }; + @future_incompatible = future_release_error(152822, ReportInDeps::No); } declare_lint! { @@ -4724,10 +4637,7 @@ declare_lint! { pub AMBIGUOUS_PANIC_IMPORTS, Warn, "detects ambiguous core and std panic imports", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #147319), - report_in_deps: false, - }; + @future_incompatible = future_release_error(147319, ReportInDeps::No); } declare_lint! { @@ -4774,9 +4684,7 @@ declare_lint! { pub AMBIGUOUS_IMPORT_VISIBILITIES, Warn, "detects certain glob imports that require reporting an ambiguity error", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #149145), - }; + @future_incompatible = future_release_error(149145, ReportInDeps::No); } declare_lint! { @@ -4932,10 +4840,7 @@ declare_lint! { pub PRIVATE_MACRO_USE, Deny, "detects certain macro bindings that should not be re-exported", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #120192), - report_in_deps: true, - }; + @future_incompatible = future_release_error(120192, ReportInDeps::Yes); } declare_lint! { @@ -4997,9 +4902,7 @@ declare_lint! { pub UNCOVERED_PARAM_IN_PROJECTION, Warn, "impl contains type parameters that are not covered", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #124559), - }; + @future_incompatible = future_release_error(124559, ReportInDeps::No); } declare_lint! { @@ -5044,9 +4947,7 @@ declare_lint! { pub DEPRECATED_SAFE_2024, Allow, "detects unsafe functions being used as safe functions", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2024 "newly-unsafe-functions"), - }; + @future_incompatible = edition_error(2024, "newly-unsafe-functions"); } declare_lint! { @@ -5079,9 +4980,7 @@ declare_lint! { pub MISSING_UNSAFE_ON_EXTERN, Allow, "detects missing unsafe keyword on extern declarations", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2024 "unsafe-extern"), - }; + @future_incompatible = edition_error(2024, "unsafe-extern"); } declare_lint! { @@ -5119,9 +5018,7 @@ declare_lint! { pub UNSAFE_ATTR_OUTSIDE_UNSAFE, Allow, "detects unsafe attributes outside of unsafe", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2024 "unsafe-attributes"), - }; + @future_incompatible = edition_error(2024, "unsafe-attributes"); } declare_lint! { @@ -5157,10 +5054,7 @@ declare_lint! { pub OUT_OF_SCOPE_MACRO_CALLS, Deny, "detects out of scope calls to `macro_rules` in key-value attributes", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #124535), - report_in_deps: true, - }; + @future_incompatible = future_release_error(124535, ReportInDeps::Yes); } declare_lint! { @@ -5315,9 +5209,7 @@ declare_lint! { pub TAIL_EXPR_DROP_ORDER, Allow, "Detect and warn on significant change in drop order in tail expression location", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionSemanticsChange 2024 "temporary-tail-expr-scope"), - }; + @future_incompatible = edition_semantics_change(2024, "temporary-tail-expr-scope"); } declare_lint! { @@ -5353,9 +5245,7 @@ declare_lint! { pub RUST_2024_GUARDED_STRING_INCOMPATIBLE_SYNTAX, Allow, "will be parsed as a guarded string in Rust 2024", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2024 "reserved-syntax"), - }; + @future_incompatible = edition_error(2024, "reserved-syntax"); crate_level_only } @@ -5394,10 +5284,7 @@ declare_lint! { pub AARCH64_SOFTFLOAT_NEON, Deny, "detects code that could be affected by ABI issues on aarch64 softfloat targets", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #134375), - report_in_deps: true, - }; + @future_incompatible = future_release_error(134375, ReportInDeps::Yes); } declare_lint! { @@ -5433,10 +5320,7 @@ declare_lint! { pub X86_SOFTFLOAT_SSE, Deny, "detects code that could be affected by LLVM backend issues on x86 softfloat targets", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #117938), - report_in_deps: true, - }; + @future_incompatible = future_release_error(117938, ReportInDeps::Yes); } declare_lint! { @@ -5513,10 +5397,7 @@ declare_lint! { pub REPR_C_ENUMS_LARGER_THAN_INT, Warn, "repr(C) enums with discriminant values that do not fit into a C int", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #124403), - report_in_deps: false, - }; + @future_incompatible = future_release_error(124403, ReportInDeps::No); } declare_lint! { @@ -5559,10 +5440,7 @@ declare_lint! { pub VARARGS_WITHOUT_PATTERN, Deny, "detects usage of `...` arguments without a pattern in non-foreign items", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #145544), - report_in_deps: true, - }; + @future_incompatible = future_release_error(145544, ReportInDeps::Yes); } declare_lint! { @@ -5659,10 +5537,7 @@ declare_lint! { pub FLOAT_LITERAL_F32_FALLBACK, Warn, "detects unsuffixed floating point literals whose type fallback to `f32`", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #154024), - report_in_deps: false, - }; + @future_incompatible = future_release_error(154024, ReportInDeps::No); } declare_lint! { @@ -5741,10 +5616,7 @@ declare_lint! { pub METHOD_CALL_ON_DIVERGING_INFER_VAR, Warn, "detects method calls on a result of never-to-any coercion", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #156047), - report_in_deps: true, - }; + @future_incompatible = future_release_error(156047, ReportInDeps::Yes); } declare_lint! { @@ -5798,10 +5670,7 @@ declare_lint! { pub RECURSION_DEPTH_EXCEEDING_LIMIT, Warn, "detects trait solving overflow that only happens with the next solver", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #159228), - report_in_deps: false, - }; + @future_incompatible = future_release_error(159228, ReportInDeps::No); } declare_lint! { diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 4657621c5500d..96fdadcd070ac 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -321,18 +321,6 @@ pub struct FutureIncompatibleInfo { /// Set to false for lints that already include a more detailed /// explanation. pub explain_reason: bool, - /// If set to `true`, this will make future incompatibility warnings show up in cargo's - /// reports. - /// - /// When a future incompatibility warning is first inroduced, set this to `false` - /// (or, rather, don't override the default). This allows crate developers an opportunity - /// to fix the warning before blasting all dependents with a warning they can't fix - /// (dependents have to wait for a new release of the affected crate to be published). - /// - /// After a lint has been in this state for a while, consider setting this to true, so it - /// warns for everyone. It is a good signal that it is ready if you can determine that all - /// or most affected crates on crates.io have been updated. - pub report_in_deps: bool, } #[derive(Copy, Clone, Debug)] @@ -344,6 +332,35 @@ pub struct EditionFcw { #[derive(Copy, Clone, Debug)] pub struct ReleaseFcw { pub issue_number: usize, + + /// If set to `Yes`, this will make future incompatibility warnings show up in cargo's + /// reports. + /// + /// When a future incompatibility warning is first inroduced, set this to `No`. This allows + /// crate developers an opportunity to fix the warning before blasting all dependents with a + /// warning they can't fix (dependents have to wait for a new release of the affected crate to + /// be published). + /// + /// After a lint has been in this state for a while, consider setting this to true, so it + /// warns for everyone. It is a good signal that it is ready if you can determine that all + /// or most affected crates on crates.io have been updated. + pub report_in_deps: ReportInDeps, +} + +/// Whether to make future incompatibility warnings show up in cargo's reports. +/// +/// See [`ReleaseFcw::report_in_deps`]. +#[derive(Copy, Clone, Debug)] +pub enum ReportInDeps { + /// Do **not** report a given future incompatibility warning in cargo's reports. + /// + /// Use this when adding a new warning. + No, + + /// **Do** report a given future incompatibility warning in cargo's reports. + /// + /// Use this after the warning has been emitted for a while, so it warns for everyone. + Yes, } /// The reason for future incompatibility @@ -368,7 +385,7 @@ pub enum FutureIncompatibilityReason { /// future. /// /// After a lint has been in this state for a while and you feel like it is ready to graduate - /// to warning everyone, consider setting [`FutureIncompatibleInfo::report_in_deps`] to true. + /// to warning everyone, consider setting [`ReleaseFcw::report_in_deps`] to true. /// (see its documentation for more guidance) /// /// After some period of time, lints with this variant can be turned into @@ -432,7 +449,7 @@ pub enum FutureIncompatibilityReason { /// /// [`EditionSemanticsChange`]: FutureIncompatibilityReason::EditionSemanticsChange /// [`FutureReleaseSemanticsChange`]: FutureIncompatibilityReason::FutureReleaseSemanticsChange - EditionAndFutureReleaseSemanticsChange(EditionFcw), + EditionAndFutureReleaseSemanticsChange(EditionFcw, ReleaseFcw), /// A custom reason. /// /// Choose this variant if the built-in text of the diagnostic of the @@ -440,20 +457,81 @@ pub enum FutureIncompatibilityReason { /// equivalent to /// [`FutureIncompatibilityReason::FutureReleaseError`]. Custom(&'static str, ReleaseFcw), +} - /// Using the declare_lint macro a reason always needs to be specified. - /// So, this case can't actually be reached but a variant needs to exist for it. - /// Any code panics on seeing this variant. Do not use. - Unreachable, +/// Constructs [`FutureIncompatibilityReason::FutureReleaseError`]; see it's documentation for more +/// information. +pub const fn future_release_error( + issue_number: usize, + report_in_deps: ReportInDeps, +) -> FutureIncompatibleInfo { + FutureIncompatibleInfo::new(FutureIncompatibilityReason::FutureReleaseError(ReleaseFcw { + issue_number, + report_in_deps, + })) +} + +/// Constructs [`FutureIncompatibilityReason::FutureReleaseSemanticsChange`]; see it's documentation for more +/// information. +pub const fn future_release_semantics_change( + issue_number: usize, + report_in_deps: ReportInDeps, +) -> FutureIncompatibleInfo { + FutureIncompatibleInfo::new(FutureIncompatibilityReason::FutureReleaseSemanticsChange( + ReleaseFcw { issue_number, report_in_deps }, + )) +} + +/// Constructs [`FutureIncompatibilityReason::EditionError`]; see it's documentation for more +/// information. +pub const fn edition_error(edition: u16, page_slug: &'static str) -> FutureIncompatibleInfo { + FutureIncompatibleInfo::new(FutureIncompatibilityReason::EditionError(EditionFcw { + edition: edition_from_u16(edition), + page_slug, + })) +} + +/// Constructs [`FutureIncompatibilityReason::EditionSemanticsChange`]; see it's documentation for more +/// information. +pub const fn edition_semantics_change( + edition: u16, + page_slug: &'static str, +) -> FutureIncompatibleInfo { + FutureIncompatibleInfo::new(FutureIncompatibilityReason::EditionSemanticsChange(EditionFcw { + edition: edition_from_u16(edition), + page_slug, + })) +} + +pub const fn custom_future_incompatible( + message: &'static str, + issue_number: usize, + report_in_deps: ReportInDeps, +) -> FutureIncompatibleInfo { + FutureIncompatibleInfo::new(FutureIncompatibilityReason::Custom( + message, + ReleaseFcw { issue_number, report_in_deps }, + )) +} + +const fn edition_from_u16(x: u16) -> Edition { + match x { + 2015 => Edition::Edition2015, + 2018 => Edition::Edition2018, + 2021 => Edition::Edition2021, + 2024 => Edition::Edition2024, + _ => panic!("invalid edition number"), + } } impl FutureIncompatibleInfo { - pub const fn default_fields_for_macro() -> Self { - FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::Unreachable, - explain_reason: true, - report_in_deps: false, - } + const fn new(reason: FutureIncompatibilityReason) -> Self { + FutureIncompatibleInfo { reason, explain_reason: true } + } + + /// Sets [`Self::explain_reason`] to false. + pub const fn dont_explain_reason(self) -> Self { + Self { explain_reason: false, ..self } } } @@ -463,12 +541,11 @@ impl FutureIncompatibilityReason { Self::EditionError(e) | Self::EditionSemanticsChange(e) | Self::EditionAndFutureReleaseError(e) - | Self::EditionAndFutureReleaseSemanticsChange(e) => Some(e.edition), + | Self::EditionAndFutureReleaseSemanticsChange(e, _) => Some(e.edition), FutureIncompatibilityReason::FutureReleaseError(_) | FutureIncompatibilityReason::FutureReleaseSemanticsChange(_) | FutureIncompatibilityReason::Custom(_, _) => None, - Self::Unreachable => unreachable!(), } } @@ -480,8 +557,23 @@ impl FutureIncompatibilityReason { Self::EditionError(edition_fcw) | Self::EditionSemanticsChange(edition_fcw) | Self::EditionAndFutureReleaseError(edition_fcw) - | Self::EditionAndFutureReleaseSemanticsChange(edition_fcw) => edition_fcw.to_string(), - Self::Unreachable => unreachable!(), + | Self::EditionAndFutureReleaseSemanticsChange(edition_fcw, _) => { + edition_fcw.to_string() + } + } + } + + pub fn report_in_deps(&self) -> ReportInDeps { + match self { + FutureIncompatibilityReason::FutureReleaseError(release_fcw) + | FutureIncompatibilityReason::FutureReleaseSemanticsChange(release_fcw) + | FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(_, release_fcw) + | FutureIncompatibilityReason::Custom(_, release_fcw) => release_fcw.report_in_deps, + FutureIncompatibilityReason::EditionError(_edition_fcw) + | FutureIncompatibilityReason::EditionSemanticsChange(_edition_fcw) + | FutureIncompatibilityReason::EditionAndFutureReleaseError(_edition_fcw) => { + ReportInDeps::No + } } } } @@ -702,30 +794,28 @@ macro_rules! declare_lint { ($(#[$attr:meta])* $vis: vis $NAME: ident, $Level: ident, $desc: expr, $(@eval_always = $eval_always:literal)? $(@feature_gate = $gate:ident;)? - $(@future_incompatible = FutureIncompatibleInfo { - reason: $reason:expr, - $($field:ident : $val:expr),* $(,)* - }; )? + $(@future_incompatible = $future_incompatible:expr;)? $(@edition $lint_edition:ident => $edition_level:ident;)? $(@msrv = $msrv:literal;)? $($v:ident),*) => ( $(#[$attr])* - $vis static $NAME: &$crate::Lint = &$crate::Lint { - name: stringify!($NAME), - default_level: $crate::$Level, - desc: $desc, - is_externally_loaded: false, - $($v: true,)* - $(feature_gate: Some(rustc_span::sym::$gate),)? - $(future_incompatible: Some($crate::FutureIncompatibleInfo { - reason: $reason, - $($field: $val,)* - ..$crate::FutureIncompatibleInfo::default_fields_for_macro() - }),)? - $(edition_lint_opts: Some((::rustc_span::edition::Edition::$lint_edition, $crate::$edition_level)),)? - $(eval_always: $eval_always,)? - $(rust_version: Some($crate::Lint::parse_rust_version($msrv)),)? - ..$crate::Lint::default_fields_for_macro() + $vis static $NAME: &$crate::Lint = { + #[allow(unused_imports)] + use $crate::{future_release_error, future_release_semantics_change, edition_error, edition_semantics_change}; + + &$crate::Lint { + name: stringify!($NAME), + default_level: $crate::$Level, + desc: $desc, + is_externally_loaded: false, + $($v: true,)* + $(feature_gate: Some(rustc_span::sym::$gate),)? + $(future_incompatible: Some($future_incompatible),)? + $(edition_lint_opts: Some((::rustc_span::edition::Edition::$lint_edition, $crate::$edition_level)),)? + $(eval_always: $eval_always,)? + $(rust_version: Some($crate::Lint::parse_rust_version($msrv)),)? + ..$crate::Lint::default_fields_for_macro() + } }; ); } @@ -801,53 +891,3 @@ macro_rules! declare_lint_pass { $crate::impl_lint_pass!($name => [$($lint),*]); }; } - -#[macro_export] -macro_rules! fcw { - (FutureReleaseError # $issue_number: literal) => { - $crate:: FutureIncompatibilityReason::FutureReleaseError($crate::ReleaseFcw { issue_number: $issue_number }) - }; - (FutureReleaseSemanticsChange # $issue_number: literal) => { - $crate::FutureIncompatibilityReason::FutureReleaseSemanticsChange($crate::ReleaseFcw { - issue_number: $issue_number, - }) - }; - ($description: literal # $issue_number: literal) => { - $crate::FutureIncompatibilityReason::Custom($description, $crate::ReleaseFcw { - issue_number: $issue_number, - }) - }; - (EditionError $edition_name: tt $page_slug: literal) => { - $crate::FutureIncompatibilityReason::EditionError($crate::EditionFcw { - edition: fcw!(@edition $edition_name), - page_slug: $page_slug, - }) - }; - (EditionSemanticsChange $edition_name: tt $page_slug: literal) => { - $crate::FutureIncompatibilityReason::EditionSemanticsChange($crate::EditionFcw { - edition: fcw!(@edition $edition_name), - page_slug: $page_slug, - }) - }; - (EditionAndFutureReleaseSemanticsChange $edition_name: tt $page_slug: literal) => { - $crate::FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange($crate::EditionFcw { - edition: fcw!(@edition $edition_name), - page_slug: $page_slug, - }) - }; - (EditionAndFutureReleaseError $edition_name: tt $page_slug: literal) => { - $crate::FutureIncompatibilityReason::EditionAndFutureReleaseError($crate::EditionFcw { - edition: fcw!(@edition $edition_name), - page_slug: $page_slug, - }) - }; - (@edition 2024) => { - rustc_span::edition::Edition::Edition2024 - }; - (@edition 2021) => { - rustc_span::edition::Edition::Edition2021 - }; - (@edition 2018) => { - rustc_span::edition::Edition::Edition2018 - }; -} diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 3655d4594aa38..f2e9ca580c37d 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -5,7 +5,7 @@ use rustc_data_structures::sorted_map::SortedMap; use rustc_errors::{Diag, DiagLocation, Diagnostic, EmissionOverride, MultiSpan}; use rustc_hir::{HirId, ItemLocalId}; use rustc_lint_defs::{ - EditionFcw, FutureIncompatibilityReason, Level, Lint, LintExpectationId, LintId, + EditionFcw, FutureIncompatibilityReason, Level, Lint, LintExpectationId, LintId, ReportInDeps, StableLintExpectationId, UnstableLintExpectationId, builtin, }; use rustc_macros::{Decodable, Encodable, StableHash}; @@ -409,7 +409,7 @@ pub fn emit_lint_base<'a, D: Diagnostic<'a> + 'a>( let has_future_breakage = future_incompatible.map_or( // Default allow lints trigger too often for testing. sess.opts.unstable_opts.future_incompat_test && lint.default_level != Level::Allow, - |incompat| incompat.report_in_deps, + |incompat| matches!(incompat.reason.report_in_deps(), ReportInDeps::Yes), ); // Convert lint level to error level. @@ -558,13 +558,13 @@ pub fn emit_lint_base<'a, D: Diagnostic<'a> + 'a>( } FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange( EditionFcw { edition, .. }, + _, ) => { format!( "this changes meaning in Rust {edition} and in a future release in all editions!" ) } FutureIncompatibilityReason::Custom(reason, _) => reason.to_owned(), - FutureIncompatibilityReason::Unreachable => unreachable!(), }; if future_incompatible.explain_reason { diff --git a/src/doc/rustc-dev-guide/src/bug-fix-procedure.md b/src/doc/rustc-dev-guide/src/bug-fix-procedure.md index 5416e361e5d24..34b6ee8d918b1 100644 --- a/src/doc/rustc-dev-guide/src/bug-fix-procedure.md +++ b/src/doc/rustc-dev-guide/src/bug-fix-procedure.md @@ -96,9 +96,7 @@ declare_lint! { pub YOUR_LINT_HERE, Warn, "illegal use of foo bar baz" - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #1234) // your tracking issue here! - }, + @future_incompatible = future_release_error(1234, ReportInDeps::No); // your tracking issue here! } // 2. Add a dedicated lint pass for it. @@ -230,9 +228,7 @@ declare_lint! { pub OVERLAPPING_INHERENT_IMPLS, Deny, // this may also say Warning "two overlapping inherent impls define an item with the same name were erroneously allowed", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(FutureReleaseError #1234), // your tracking issue here! - }, + @future_incompatible = future_release_error(1234, ReportInDeps::No); // your tracking issue here! } ``` diff --git a/src/doc/rustc-dev-guide/src/diagnostics.md b/src/doc/rustc-dev-guide/src/diagnostics.md index 0928f27940885..8ea617c961408 100644 --- a/src/doc/rustc-dev-guide/src/diagnostics.md +++ b/src/doc/rustc-dev-guide/src/diagnostics.md @@ -726,9 +726,7 @@ declare_lint! { pub ANONYMOUS_PARAMETERS, Allow, "detects anonymous parameters", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2018 "slug-of-edition-guide-page") - }; + @future_incompatible = edition_error(2018, "slug-of-edition-guide-page"); } ``` diff --git a/src/doc/rustc-dev-guide/src/guides/editions.md b/src/doc/rustc-dev-guide/src/guides/editions.md index e5f8d38912a09..8cf060f7d6e81 100644 --- a/src/doc/rustc-dev-guide/src/guides/editions.md +++ b/src/doc/rustc-dev-guide/src/guides/editions.md @@ -181,9 +181,7 @@ declare_lint! { pub KEYWORD_IDENTS, Allow, "detects edition keywords being used as an identifier", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionError 2018 "slug-of-edition-guide-page") - }; + @future_incompatible = edition_error(2018, "slug-of-edition-guide-page"); } ```