Skip to content

Commit c103c30

Browse files
committed
migrate the rest of weak_lang_items.rs to translateable diagnostics
1 parent 1222541 commit c103c30

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

compiler/rustc_error_messages/locales/en-US/passes.ftl

+3-3
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ passes_deprecated_annotation_has_no_effect =
358358
this `#[deprecated]` annotation has no effect
359359
.suggestion = remove the unnecessary deprecation attribute
360360
361+
passes_unknown_external_lang_item =
362+
unknown external lang item: `{$lang_item}`
363+
361364
passes_missing_panic_handler =
362365
`#[panic_handler]` function required, but not found
363366
@@ -384,6 +387,3 @@ passes_local_duplicate_lang_item =
384387
passes_invalid_attr_at_crate_level =
385388
`{$name}` attribute cannot be used at crate level
386389
.suggestion = perhaps you meant to use an outer attribute
387-
388-
passes_deprecated_annotation_has_no_effect = this `#[deprecated]` annotation has no effect
389-
.suggestion = remove the unnecessary deprecation attribute

compiler/rustc_passes/src/errors.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,14 @@ pub struct DeprecatedAnnotationHasNoEffect {
678678
pub span: Span,
679679
}
680680

681+
#[derive(Diagnostic)]
682+
#[diag(passes::unknown_external_lang_item, code = "E0264")]
683+
pub struct UnknownExternLangItem {
684+
#[primary_span]
685+
pub span: Span,
686+
pub lang_item: Symbol,
687+
}
688+
681689
#[derive(Diagnostic)]
682690
#[diag(passes::missing_panic_handler)]
683691
pub struct MissingPanicHandler;
@@ -744,10 +752,3 @@ impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
744752
diag
745753
}
746754
}
747-
748-
#[derive(LintDiagnostic)]
749-
#[diag(passes::deprecated_annotation_has_no_effect)]
750-
pub struct DeprecatedAnnotationHasNoEffect {
751-
#[suggestion(applicability = "machine-applicable", code = "")]
752-
pub span: Span,
753-
}

compiler/rustc_passes/src/weak_lang_items.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//! Validity checking for weak lang items
22
33
use rustc_data_structures::fx::FxHashSet;
4-
use rustc_errors::struct_span_err;
54
use rustc_hir::lang_items::{self, LangItem};
65
use rustc_hir::weak_lang_items::WEAK_ITEMS_REFS;
76
use rustc_middle::middle::lang_items::required;
87
use rustc_middle::ty::TyCtxt;
98
use rustc_session::config::CrateType;
109

11-
use crate::errors::{MissingAllocErrorHandler, MissingLangItem, MissingPanicHandler};
10+
use crate::errors::{
11+
MissingAllocErrorHandler, MissingLangItem, MissingPanicHandler, UnknownExternLangItem,
12+
};
1213

1314
/// Checks the crate for usage of weak lang items, returning a vector of all the
1415
/// language items required by this crate, but not defined yet.
@@ -33,14 +34,7 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem
3334
}
3435
} else {
3536
let span = tcx.def_span(id.def_id);
36-
struct_span_err!(
37-
tcx.sess,
38-
span,
39-
E0264,
40-
"unknown external lang item: `{}`",
41-
lang_item
42-
)
43-
.emit();
37+
tcx.sess.emit_err(UnknownExternLangItem { span, lang_item });
4438
}
4539
}
4640
}

0 commit comments

Comments
 (0)