migrate the rest of weak_lang_items.rs to translateable diagnostics
This commit is contained in:
parent
1222541cfd
commit
c103c3059f
3 changed files with 15 additions and 20 deletions
|
@ -358,6 +358,9 @@ passes_deprecated_annotation_has_no_effect =
|
||||||
this `#[deprecated]` annotation has no effect
|
this `#[deprecated]` annotation has no effect
|
||||||
.suggestion = remove the unnecessary deprecation attribute
|
.suggestion = remove the unnecessary deprecation attribute
|
||||||
|
|
||||||
|
passes_unknown_external_lang_item =
|
||||||
|
unknown external lang item: `{$lang_item}`
|
||||||
|
|
||||||
passes_missing_panic_handler =
|
passes_missing_panic_handler =
|
||||||
`#[panic_handler]` function required, but not found
|
`#[panic_handler]` function required, but not found
|
||||||
|
|
||||||
|
@ -384,6 +387,3 @@ passes_local_duplicate_lang_item =
|
||||||
passes_invalid_attr_at_crate_level =
|
passes_invalid_attr_at_crate_level =
|
||||||
`{$name}` attribute cannot be used at crate level
|
`{$name}` attribute cannot be used at crate level
|
||||||
.suggestion = perhaps you meant to use an outer attribute
|
.suggestion = perhaps you meant to use an outer attribute
|
||||||
|
|
||||||
passes_deprecated_annotation_has_no_effect = this `#[deprecated]` annotation has no effect
|
|
||||||
.suggestion = remove the unnecessary deprecation attribute
|
|
||||||
|
|
|
@ -678,6 +678,14 @@ pub struct DeprecatedAnnotationHasNoEffect {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(passes::unknown_external_lang_item, code = "E0264")]
|
||||||
|
pub struct UnknownExternLangItem {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub lang_item: Symbol,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(passes::missing_panic_handler)]
|
#[diag(passes::missing_panic_handler)]
|
||||||
pub struct MissingPanicHandler;
|
pub struct MissingPanicHandler;
|
||||||
|
@ -744,10 +752,3 @@ impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
|
||||||
diag
|
diag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
|
||||||
#[diag(passes::deprecated_annotation_has_no_effect)]
|
|
||||||
pub struct DeprecatedAnnotationHasNoEffect {
|
|
||||||
#[suggestion(applicability = "machine-applicable", code = "")]
|
|
||||||
pub span: Span,
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
//! Validity checking for weak lang items
|
//! Validity checking for weak lang items
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::struct_span_err;
|
|
||||||
use rustc_hir::lang_items::{self, LangItem};
|
use rustc_hir::lang_items::{self, LangItem};
|
||||||
use rustc_hir::weak_lang_items::WEAK_ITEMS_REFS;
|
use rustc_hir::weak_lang_items::WEAK_ITEMS_REFS;
|
||||||
use rustc_middle::middle::lang_items::required;
|
use rustc_middle::middle::lang_items::required;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::config::CrateType;
|
use rustc_session::config::CrateType;
|
||||||
|
|
||||||
use crate::errors::{MissingAllocErrorHandler, MissingLangItem, MissingPanicHandler};
|
use crate::errors::{
|
||||||
|
MissingAllocErrorHandler, MissingLangItem, MissingPanicHandler, UnknownExternLangItem,
|
||||||
|
};
|
||||||
|
|
||||||
/// Checks the crate for usage of weak lang items, returning a vector of all the
|
/// Checks the crate for usage of weak lang items, returning a vector of all the
|
||||||
/// language items required by this crate, but not defined yet.
|
/// 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
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let span = tcx.def_span(id.def_id);
|
let span = tcx.def_span(id.def_id);
|
||||||
struct_span_err!(
|
tcx.sess.emit_err(UnknownExternLangItem { span, lang_item });
|
||||||
tcx.sess,
|
|
||||||
span,
|
|
||||||
E0264,
|
|
||||||
"unknown external lang item: `{}`",
|
|
||||||
lang_item
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue