Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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! {
Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -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]);
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_lint/src/if_let_rescope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_lint/src/impl_trait_overcaptures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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! {
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -121,8 +122,9 @@ fn skippable_lints(tcx: TyCtxt<'_>, (): ()) -> UnordSet<LintId> {
.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| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,]);
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_lint/src/non_fmt_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
}

Expand Down
10 changes: 3 additions & 7 deletions compiler/rustc_lint/src/shadowed_into_iter.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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! {
Expand All @@ -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)]
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_lint/src/static_mut_refs.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -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;
}

Expand Down
Loading
Loading