mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-30 16:43:41 +00:00
port 5 new diagnostics that appeared in master
This commit is contained in:
parent
0d65819d52
commit
30adfd6a17
@ -255,3 +255,18 @@ metadata_crate_location_unknown_type =
|
||||
|
||||
metadata_lib_filename_form =
|
||||
file name should be lib*.rlib or {dll_prefix}*.{dll_suffix}
|
||||
|
||||
metadata_multiple_import_name_type =
|
||||
multiple `import_name_type` arguments in a single `#[link]` attribute
|
||||
|
||||
metadata_import_name_type_form =
|
||||
import name type must be of the form `import_name_type = "string"`
|
||||
|
||||
metadata_import_name_type_x86 =
|
||||
import name type is only supported on x86
|
||||
|
||||
metadata_unknown_import_name_type =
|
||||
unknown import name type `{$import_name_type}`, expected one of: decorated, noprefix, undecorated
|
||||
|
||||
metadata_import_name_type_raw =
|
||||
import name type can only be used with link kind `raw-dylib`
|
||||
|
@ -634,3 +634,39 @@ pub struct LibFilenameForm<'a> {
|
||||
pub dll_prefix: &'a str,
|
||||
pub dll_suffix: &'a str,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(metadata::multiple_import_name_type)]
|
||||
pub struct MultipleImportNameType {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(metadata::import_name_type_form)]
|
||||
pub struct ImportNameTypeForm {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(metadata::import_name_type_x86)]
|
||||
pub struct ImportNameTypeX86 {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(metadata::unknown_import_name_type)]
|
||||
pub struct UnknownImportNameType<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub import_name_type: &'a str,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(metadata::import_name_type_raw)]
|
||||
pub struct ImportNameTypeRaw {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
@ -13,13 +13,14 @@ use rustc_target::spec::abi::Abi;
|
||||
|
||||
use crate::errors::{
|
||||
AsNeededCompatibility, BundleNeedsStatic, EmptyLinkName, EmptyRenamingTarget,
|
||||
FrameworkOnlyWindows, IncompatibleWasmLink, InvalidLinkModifier, LibFrameworkApple,
|
||||
LinkCfgForm, LinkCfgSinglePredicate, LinkFrameworkApple, LinkKindForm, LinkModifiersForm,
|
||||
LinkNameForm, LinkOrdinalRawDylib, LinkRequiresName, MultipleCfgs, MultipleKindsInLink,
|
||||
MultipleLinkModifiers, MultipleModifiers, MultipleNamesInLink, MultipleRenamings,
|
||||
MultipleWasmImport, NoLinkModOverride, RawDylibNoNul, RenamingNoLink, UnexpectedLinkArg,
|
||||
UnknownLinkKind, UnknownLinkModifier, UnsupportedAbi, UnsupportedAbiI686, WasmImportForm,
|
||||
WholeArchiveNeedsStatic,
|
||||
FrameworkOnlyWindows, ImportNameTypeForm, ImportNameTypeRaw, ImportNameTypeX86,
|
||||
IncompatibleWasmLink, InvalidLinkModifier, LibFrameworkApple, LinkCfgForm,
|
||||
LinkCfgSinglePredicate, LinkFrameworkApple, LinkKindForm, LinkModifiersForm, LinkNameForm,
|
||||
LinkOrdinalRawDylib, LinkRequiresName, MultipleCfgs, MultipleImportNameType,
|
||||
MultipleKindsInLink, MultipleLinkModifiers, MultipleModifiers, MultipleNamesInLink,
|
||||
MultipleRenamings, MultipleWasmImport, NoLinkModOverride, RawDylibNoNul, RenamingNoLink,
|
||||
UnexpectedLinkArg, UnknownImportNameType, UnknownLinkKind, UnknownLinkModifier, UnsupportedAbi,
|
||||
UnsupportedAbiI686, WasmImportForm, WholeArchiveNeedsStatic,
|
||||
};
|
||||
|
||||
pub(crate) fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLib> {
|
||||
@ -178,18 +179,15 @@ impl<'tcx> Collector<'tcx> {
|
||||
}
|
||||
sym::import_name_type => {
|
||||
if import_name_type.is_some() {
|
||||
let msg = "multiple `import_name_type` arguments in a single `#[link]` attribute";
|
||||
sess.span_err(item.span(), msg);
|
||||
sess.emit_err(MultipleImportNameType { span: item.span() });
|
||||
continue;
|
||||
}
|
||||
let Some(link_import_name_type) = item.value_str() else {
|
||||
let msg = "import name type must be of the form `import_name_type = \"string\"`";
|
||||
sess.span_err(item.span(), msg);
|
||||
sess.emit_err(ImportNameTypeForm { span: item.span() });
|
||||
continue;
|
||||
};
|
||||
if self.tcx.sess.target.arch != "x86" {
|
||||
let msg = "import name type is only supported on x86";
|
||||
sess.span_err(item.span(), msg);
|
||||
sess.emit_err(ImportNameTypeX86 { span: item.span() });
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -198,11 +196,10 @@ impl<'tcx> Collector<'tcx> {
|
||||
"noprefix" => PeImportNameType::NoPrefix,
|
||||
"undecorated" => PeImportNameType::Undecorated,
|
||||
import_name_type => {
|
||||
let msg = format!(
|
||||
"unknown import name type `{import_name_type}`, expected one of: \
|
||||
decorated, noprefix, undecorated"
|
||||
);
|
||||
sess.span_err(item.span(), msg);
|
||||
sess.emit_err(UnknownImportNameType {
|
||||
span: item.span(),
|
||||
import_name_type,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@ -301,8 +298,7 @@ impl<'tcx> Collector<'tcx> {
|
||||
// Do this outside of the loop so that `import_name_type` can be specified before `kind`.
|
||||
if let Some((_, span)) = import_name_type {
|
||||
if kind != Some(NativeLibKind::RawDylib) {
|
||||
let msg = "import name type can only be used with link kind `raw-dylib`";
|
||||
sess.span_err(span, msg);
|
||||
sess.emit_err(ImportNameTypeRaw { span });
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user