Skip to content

Commit 690a578

Browse files
committed
Migrate BuiltinLintDiag::MissingAbi to use LintDiagnostic directly
1 parent b5c714c commit 690a578

File tree

9 files changed

+14
-22
lines changed

9 files changed

+14
-22
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4136,7 +4136,6 @@ dependencies = [
41364136
name = "rustc_lint_defs"
41374137
version = "0.0.0"
41384138
dependencies = [
4139-
"rustc_abi",
41404139
"rustc_ast",
41414140
"rustc_data_structures",
41424141
"rustc_error_messages",

compiler/rustc_ast_passes/messages.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ ast_passes_extern_without_abi = `extern` declarations without an explicit ABI ar
113113
.suggestion = specify an ABI
114114
.help = prior to Rust 2024, a default ABI was inferred
115115
116+
ast_passes_extern_without_abi_sugg = `extern` declarations without an explicit ABI are deprecated
117+
.label = ABI should be specified here
118+
.suggestion = explicitly specify the {$default_abi} ABI
119+
116120
ast_passes_feature_on_non_nightly = `#![feature]` may not be used on the {$channel} release channel
117121
.suggestion = remove the attribute
118122
.stable_since = the feature `{$name}` has been stable since `{$since}` and no longer requires an attribute to enable

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ impl<'a> AstValidator<'a> {
876876
MISSING_ABI,
877877
id,
878878
span,
879-
BuiltinLintDiag::MissingAbi(span, ExternAbi::FALLBACK),
879+
errors::MissingAbiSugg { span, default_abi: ExternAbi::FALLBACK },
880880
)
881881
}
882882
}

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_abi::ExternAbi;
44
use rustc_ast::ParamKindOrd;
55
use rustc_errors::codes::*;
66
use rustc_errors::{Applicability, Diag, EmissionGuarantee, Subdiagnostic};
7-
use rustc_macros::{Diagnostic, Subdiagnostic};
7+
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
88
use rustc_span::{Ident, Span, Symbol};
99

1010
use crate::fluent_generated as fluent;
@@ -815,6 +815,14 @@ pub(crate) struct MissingAbi {
815815
pub span: Span,
816816
}
817817

818+
#[derive(LintDiagnostic)]
819+
#[diag(ast_passes_extern_without_abi_sugg)]
820+
pub(crate) struct MissingAbiSugg {
821+
#[suggestion(code = "extern {default_abi}", applicability = "machine-applicable")]
822+
pub span: Span,
823+
pub default_abi: ExternAbi,
824+
}
825+
818826
#[derive(Diagnostic)]
819827
#[diag(ast_passes_abi_custom_safe_foreign_function)]
820828
pub(crate) struct AbiCustomSafeForeignFunction {

compiler/rustc_lint/messages.ftl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,6 @@ lint_expectation = this lint expectation is unfulfilled
271271
lint_extern_crate_not_idiomatic = `extern crate` is not idiomatic in the new edition
272272
.suggestion = convert it to a `use`
273273
274-
lint_extern_without_abi = `extern` declarations without an explicit ABI are deprecated
275-
.label = ABI should be specified here
276-
.suggestion = explicitly specify the {$default_abi} ABI
277-
278274
lint_for_loops_over_fallibles =
279275
for loop over {$article} `{$ref_prefix}{$ty}`. This is more readably written as an `if let` statement
280276
.suggestion = consider using `if let` to clear intent

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ pub fn decorate_builtin_lint(
158158
}
159159
.decorate_lint(diag);
160160
}
161-
BuiltinLintDiag::MissingAbi(label_span, default_abi) => {
162-
lints::MissingAbi { span: label_span, default_abi }.decorate_lint(diag);
163-
}
164161
BuiltinLintDiag::LegacyDeriveHelpers(label_span) => {
165162
lints::LegacyDeriveHelpers { span: label_span }.decorate_lint(diag);
166163
}

compiler/rustc_lint/src/lints.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![allow(rustc::untranslatable_diagnostic)]
22
use std::num::NonZero;
33

4-
use rustc_abi::ExternAbi;
54
use rustc_errors::codes::*;
65
use rustc_errors::{
76
Applicability, Diag, DiagArgValue, DiagMessage, DiagStyledString, ElidedLifetimeInPathSubdiag,
@@ -2879,14 +2878,6 @@ pub(crate) struct PatternsInFnsWithoutBodySub {
28792878
pub ident: Ident,
28802879
}
28812880

2882-
#[derive(LintDiagnostic)]
2883-
#[diag(lint_extern_without_abi)]
2884-
pub(crate) struct MissingAbi {
2885-
#[suggestion(code = "extern {default_abi}", applicability = "machine-applicable")]
2886-
pub span: Span,
2887-
pub default_abi: ExternAbi,
2888-
}
2889-
28902881
#[derive(LintDiagnostic)]
28912882
#[diag(lint_legacy_derive_helpers)]
28922883
pub(crate) struct LegacyDeriveHelpers {

compiler/rustc_lint_defs/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
rustc_abi = { path = "../rustc_abi" }
98
rustc_ast = { path = "../rustc_ast" }
109
rustc_data_structures = { path = "../rustc_data_structures" }
1110
rustc_error_messages = { path = "../rustc_error_messages" }

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::borrow::Cow;
22

3-
use rustc_abi::ExternAbi;
43
use rustc_ast::AttrId;
54
use rustc_ast::attr::AttributeExt;
65
use rustc_data_structures::fx::FxIndexSet;
@@ -647,7 +646,6 @@ pub enum BuiltinLintDiag {
647646
path: String,
648647
since_kind: DeprecatedSinceKind,
649648
},
650-
MissingAbi(Span, ExternAbi),
651649
UnusedDocComment(Span),
652650
UnusedBuiltinAttribute {
653651
attr_name: Symbol,

0 commit comments

Comments
 (0)