Rollup merge of #143193 - JonathanBrouwer:link_rework, r=jdonszelmann

Port `#[link]` to the new attribute parsing infrastructure

Ports `link` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197
This commit is contained in:
Stuart Cook
2025-08-28 23:10:33 +10:00
committed by GitHub
60 changed files with 1705 additions and 1083 deletions

View File

@@ -3480,6 +3480,7 @@ dependencies = [
"rustc_parse", "rustc_parse",
"rustc_session", "rustc_session",
"rustc_span", "rustc_span",
"rustc_target",
"thin-vec", "thin-vec",
] ]

View File

@@ -17,5 +17,6 @@ rustc_macros = { path = "../rustc_macros" }
rustc_parse = { path = "../rustc_parse" } rustc_parse = { path = "../rustc_parse" }
rustc_session = { path = "../rustc_session" } rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" } rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
thin-vec.workspace = true thin-vec.workspace = true
# tidy-alphabetical-end # tidy-alphabetical-end

View File

@@ -195,3 +195,55 @@ attr_parsing_invalid_meta_item = expected a literal (`1u8`, `1.0f32`, `"string"`
attr_parsing_suffixed_literal_in_attribute = suffixed literals are not allowed in attributes attr_parsing_suffixed_literal_in_attribute = suffixed literals are not allowed in attributes
.help = instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) .help = instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
attr_parsing_as_needed_compatibility =
linking modifier `as-needed` is only compatible with `dylib` and `framework` linking kinds
attr_parsing_bundle_needs_static =
linking modifier `bundle` is only compatible with `static` linking kind
attr_parsing_empty_link_name =
link name must not be empty
.label = empty link name
attr_parsing_import_name_type_raw =
import name type can only be used with link kind `raw-dylib`
attr_parsing_import_name_type_x86 =
import name type is only supported on x86
attr_parsing_incompatible_wasm_link =
`wasm_import_module` is incompatible with other arguments in `#[link]` attributes
attr_parsing_invalid_link_modifier =
invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed
attr_parsing_link_arg_unstable =
link kind `link-arg` is unstable
attr_parsing_link_cfg_unstable =
link cfg is unstable
attr_parsing_link_framework_apple =
link kind `framework` is only supported on Apple targets
attr_parsing_link_requires_name =
`#[link]` attribute requires a `name = "string"` argument
.label = missing `name` argument
attr_parsing_multiple_modifiers =
multiple `{$modifier}` modifiers in a single `modifiers` argument
attr_parsing_multiple_renamings =
multiple renamings were specified for library `{$lib_name}`
attr_parsing_raw_dylib_no_nul =
link name must not contain NUL characters if link kind is `raw-dylib`
attr_parsing_raw_dylib_elf_unstable =
link kind `raw-dylib` is unstable on ELF platforms
attr_parsing_raw_dylib_only_windows =
link kind `raw-dylib` is only supported on Windows targets
attr_parsing_whole_archive_needs_static =
linking modifier `whole-archive` is only compatible with `static` linking kind

View File

@@ -36,7 +36,7 @@ pub fn parse_cfg_attr<'c, S: Stage>(
parse_cfg_entry(cx, single) parse_cfg_entry(cx, single)
} }
fn parse_cfg_entry<S: Stage>( pub(crate) fn parse_cfg_entry<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>, cx: &mut AcceptContext<'_, '_, S>,
item: &MetaItemOrLitParser<'_>, item: &MetaItemOrLitParser<'_>,
) -> Option<CfgEntry> { ) -> Option<CfgEntry> {

View File

@@ -1,9 +1,21 @@
use rustc_feature::Features;
use rustc_hir::attrs::AttributeKind::{LinkName, LinkOrdinal, LinkSection}; use rustc_hir::attrs::AttributeKind::{LinkName, LinkOrdinal, LinkSection};
use rustc_hir::attrs::Linkage; use rustc_hir::attrs::*;
use rustc_session::Session;
use rustc_session::parse::feature_err;
use rustc_span::kw;
use rustc_target::spec::BinaryFormat;
use super::prelude::*; use super::prelude::*;
use super::util::parse_single_integer; use super::util::parse_single_integer;
use crate::session_diagnostics::{LinkOrdinalOutOfRange, NullOnLinkSection}; use crate::attributes::cfg::parse_cfg_entry;
use crate::fluent_generated;
use crate::session_diagnostics::{
AsNeededCompatibility, BundleNeedsStatic, EmptyLinkName, ImportNameTypeRaw, ImportNameTypeX86,
IncompatibleWasmLink, InvalidLinkModifier, LinkFrameworkApple, LinkOrdinalOutOfRange,
LinkRequiresName, MultipleModifiers, NullOnLinkSection, RawDylibNoNul, RawDylibOnlyWindows,
WholeArchiveNeedsStatic,
};
pub(crate) struct LinkNameParser; pub(crate) struct LinkNameParser;
@@ -34,6 +46,409 @@ impl<S: Stage> SingleAttributeParser<S> for LinkNameParser {
} }
} }
pub(crate) struct LinkParser;
impl<S: Stage> CombineAttributeParser<S> for LinkParser {
type Item = LinkEntry;
const PATH: &[Symbol] = &[sym::link];
const CONVERT: ConvertFn<Self::Item> = AttributeKind::Link;
const TEMPLATE: AttributeTemplate = template!(List: &[
r#"name = "...""#,
r#"name = "...", kind = "dylib|static|...""#,
r#"name = "...", wasm_import_module = "...""#,
r#"name = "...", import_name_type = "decorated|noprefix|undecorated""#,
r#"name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated""#,
], "https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute");
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS); //FIXME Still checked fully in `check_attr.rs`
fn extend<'c>(
cx: &'c mut AcceptContext<'_, '_, S>,
args: &'c ArgParser<'_>,
) -> impl IntoIterator<Item = Self::Item> + 'c {
let mut result = None;
let Some(items) = args.list() else {
cx.expected_list(cx.attr_span);
return result;
};
let sess = cx.sess();
let features = cx.features();
let mut name = None;
let mut kind = None;
let mut modifiers = None;
let mut cfg = None;
let mut wasm_import_module = None;
let mut import_name_type = None;
for item in items.mixed() {
let Some(item) = item.meta_item() else {
cx.unexpected_literal(item.span());
continue;
};
let cont = match item.path().word().map(|ident| ident.name) {
Some(sym::name) => Self::parse_link_name(item, &mut name, cx),
Some(sym::kind) => Self::parse_link_kind(item, &mut kind, cx, sess, features),
Some(sym::modifiers) => Self::parse_link_modifiers(item, &mut modifiers, cx),
Some(sym::cfg) => Self::parse_link_cfg(item, &mut cfg, cx, sess, features),
Some(sym::wasm_import_module) => {
Self::parse_link_wasm_import_module(item, &mut wasm_import_module, cx)
}
Some(sym::import_name_type) => {
Self::parse_link_import_name_type(item, &mut import_name_type, cx)
}
_ => {
cx.expected_specific_argument_strings(
item.span(),
&[
sym::name,
sym::kind,
sym::modifiers,
sym::cfg,
sym::wasm_import_module,
sym::import_name_type,
],
);
true
}
};
if !cont {
return result;
}
}
// Do this outside the above loop so we don't depend on modifiers coming after kinds
let mut verbatim = None;
if let Some((modifiers, span)) = modifiers {
for modifier in modifiers.as_str().split(',') {
let (modifier, value): (Symbol, bool) = match modifier.strip_prefix(&['+', '-']) {
Some(m) => (Symbol::intern(m), modifier.starts_with('+')),
None => {
cx.emit_err(InvalidLinkModifier { span });
continue;
}
};
macro report_unstable_modifier($feature: ident) {
if !features.$feature() {
// FIXME: make this translatable
#[expect(rustc::untranslatable_diagnostic)]
feature_err(
sess,
sym::$feature,
span,
format!("linking modifier `{modifier}` is unstable"),
)
.emit();
}
}
let assign_modifier = |dst: &mut Option<bool>| {
if dst.is_some() {
cx.emit_err(MultipleModifiers { span, modifier });
} else {
*dst = Some(value);
}
};
match (modifier, &mut kind) {
(sym::bundle, Some(NativeLibKind::Static { bundle, .. })) => {
assign_modifier(bundle)
}
(sym::bundle, _) => {
cx.emit_err(BundleNeedsStatic { span });
}
(sym::verbatim, _) => assign_modifier(&mut verbatim),
(
sym::whole_dash_archive,
Some(NativeLibKind::Static { whole_archive, .. }),
) => assign_modifier(whole_archive),
(sym::whole_dash_archive, _) => {
cx.emit_err(WholeArchiveNeedsStatic { span });
}
(sym::as_dash_needed, Some(NativeLibKind::Dylib { as_needed }))
| (sym::as_dash_needed, Some(NativeLibKind::Framework { as_needed })) => {
report_unstable_modifier!(native_link_modifiers_as_needed);
assign_modifier(as_needed)
}
(sym::as_dash_needed, _) => {
cx.emit_err(AsNeededCompatibility { span });
}
_ => {
cx.expected_specific_argument_strings(
span,
&[
sym::bundle,
sym::verbatim,
sym::whole_dash_archive,
sym::as_dash_needed,
],
);
}
}
}
}
if let Some((_, span)) = wasm_import_module {
if name.is_some() || kind.is_some() || modifiers.is_some() || cfg.is_some() {
cx.emit_err(IncompatibleWasmLink { span });
}
}
if wasm_import_module.is_some() {
(name, kind) = (wasm_import_module, Some(NativeLibKind::WasmImportModule));
}
let Some((name, name_span)) = name else {
cx.emit_err(LinkRequiresName { span: cx.attr_span });
return result;
};
// 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) {
cx.emit_err(ImportNameTypeRaw { span });
}
}
if let Some(NativeLibKind::RawDylib) = kind
&& name.as_str().contains('\0')
{
cx.emit_err(RawDylibNoNul { span: name_span });
}
result = Some(LinkEntry {
span: cx.attr_span,
kind: kind.unwrap_or(NativeLibKind::Unspecified),
name,
cfg,
verbatim,
import_name_type,
});
result
}
}
impl LinkParser {
fn parse_link_name<S: Stage>(
item: &MetaItemParser<'_>,
name: &mut Option<(Symbol, Span)>,
cx: &mut AcceptContext<'_, '_, S>,
) -> bool {
if name.is_some() {
cx.duplicate_key(item.span(), sym::name);
return true;
}
let Some(nv) = item.args().name_value() else {
cx.expected_name_value(item.span(), Some(sym::name));
return false;
};
let Some(link_name) = nv.value_as_str() else {
cx.expected_name_value(item.span(), Some(sym::name));
return false;
};
if link_name.is_empty() {
cx.emit_err(EmptyLinkName { span: nv.value_span });
}
*name = Some((link_name, nv.value_span));
true
}
fn parse_link_kind<S: Stage>(
item: &MetaItemParser<'_>,
kind: &mut Option<NativeLibKind>,
cx: &mut AcceptContext<'_, '_, S>,
sess: &Session,
features: &Features,
) -> bool {
if kind.is_some() {
cx.duplicate_key(item.span(), sym::kind);
return true;
}
let Some(nv) = item.args().name_value() else {
cx.expected_name_value(item.span(), Some(sym::kind));
return true;
};
let Some(link_kind) = nv.value_as_str() else {
cx.expected_name_value(item.span(), Some(sym::kind));
return true;
};
let link_kind = match link_kind {
kw::Static => NativeLibKind::Static { bundle: None, whole_archive: None },
sym::dylib => NativeLibKind::Dylib { as_needed: None },
sym::framework => {
if !sess.target.is_like_darwin {
cx.emit_err(LinkFrameworkApple { span: nv.value_span });
}
NativeLibKind::Framework { as_needed: None }
}
sym::raw_dash_dylib => {
if sess.target.is_like_windows {
// raw-dylib is stable and working on Windows
} else if sess.target.binary_format == BinaryFormat::Elf && features.raw_dylib_elf()
{
// raw-dylib is unstable on ELF, but the user opted in
} else if sess.target.binary_format == BinaryFormat::Elf && sess.is_nightly_build()
{
feature_err(
sess,
sym::raw_dylib_elf,
nv.value_span,
fluent_generated::attr_parsing_raw_dylib_elf_unstable,
)
.emit();
} else {
cx.emit_err(RawDylibOnlyWindows { span: nv.value_span });
}
NativeLibKind::RawDylib
}
sym::link_dash_arg => {
if !features.link_arg_attribute() {
feature_err(
sess,
sym::link_arg_attribute,
nv.value_span,
fluent_generated::attr_parsing_link_arg_unstable,
)
.emit();
}
NativeLibKind::LinkArg
}
_kind => {
cx.expected_specific_argument_strings(
nv.value_span,
&[
kw::Static,
sym::dylib,
sym::framework,
sym::raw_dash_dylib,
sym::link_dash_arg,
],
);
return true;
}
};
*kind = Some(link_kind);
true
}
fn parse_link_modifiers<S: Stage>(
item: &MetaItemParser<'_>,
modifiers: &mut Option<(Symbol, Span)>,
cx: &mut AcceptContext<'_, '_, S>,
) -> bool {
if modifiers.is_some() {
cx.duplicate_key(item.span(), sym::modifiers);
return true;
}
let Some(nv) = item.args().name_value() else {
cx.expected_name_value(item.span(), Some(sym::modifiers));
return true;
};
let Some(link_modifiers) = nv.value_as_str() else {
cx.expected_name_value(item.span(), Some(sym::modifiers));
return true;
};
*modifiers = Some((link_modifiers, nv.value_span));
true
}
fn parse_link_cfg<S: Stage>(
item: &MetaItemParser<'_>,
cfg: &mut Option<CfgEntry>,
cx: &mut AcceptContext<'_, '_, S>,
sess: &Session,
features: &Features,
) -> bool {
if cfg.is_some() {
cx.duplicate_key(item.span(), sym::cfg);
return true;
}
let Some(link_cfg) = item.args().list() else {
cx.expected_list(item.span());
return true;
};
let Some(link_cfg) = link_cfg.single() else {
cx.expected_single_argument(item.span());
return true;
};
if !features.link_cfg() {
feature_err(
sess,
sym::link_cfg,
item.span(),
fluent_generated::attr_parsing_link_cfg_unstable,
)
.emit();
}
*cfg = parse_cfg_entry(cx, link_cfg);
true
}
fn parse_link_wasm_import_module<S: Stage>(
item: &MetaItemParser<'_>,
wasm_import_module: &mut Option<(Symbol, Span)>,
cx: &mut AcceptContext<'_, '_, S>,
) -> bool {
if wasm_import_module.is_some() {
cx.duplicate_key(item.span(), sym::wasm_import_module);
return true;
}
let Some(nv) = item.args().name_value() else {
cx.expected_name_value(item.span(), Some(sym::wasm_import_module));
return true;
};
let Some(link_wasm_import_module) = nv.value_as_str() else {
cx.expected_name_value(item.span(), Some(sym::wasm_import_module));
return true;
};
*wasm_import_module = Some((link_wasm_import_module, item.span()));
true
}
fn parse_link_import_name_type<S: Stage>(
item: &MetaItemParser<'_>,
import_name_type: &mut Option<(PeImportNameType, Span)>,
cx: &mut AcceptContext<'_, '_, S>,
) -> bool {
if import_name_type.is_some() {
cx.duplicate_key(item.span(), sym::import_name_type);
return true;
}
let Some(nv) = item.args().name_value() else {
cx.expected_name_value(item.span(), Some(sym::import_name_type));
return true;
};
let Some(link_import_name_type) = nv.value_as_str() else {
cx.expected_name_value(item.span(), Some(sym::import_name_type));
return true;
};
if cx.sess().target.arch != "x86" {
cx.emit_err(ImportNameTypeX86 { span: item.span() });
return true;
}
let link_import_name_type = match link_import_name_type {
sym::decorated => PeImportNameType::Decorated,
sym::noprefix => PeImportNameType::NoPrefix,
sym::undecorated => PeImportNameType::Undecorated,
_ => {
cx.expected_specific_argument_strings(
item.span(),
&[sym::decorated, sym::noprefix, sym::undecorated],
);
return true;
}
};
*import_name_type = Some((link_import_name_type, item.span()));
true
}
}
pub(crate) struct LinkSectionParser; pub(crate) struct LinkSectionParser;
impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser { impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {

View File

@@ -30,7 +30,7 @@ use crate::attributes::dummy::DummyParser;
use crate::attributes::inline::{InlineParser, RustcForceInlineParser}; use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
use crate::attributes::link_attrs::{ use crate::attributes::link_attrs::{
ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser, LinkOrdinalParser, ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser, LinkOrdinalParser,
LinkSectionParser, LinkageParser, StdInternalSymbolParser, LinkParser, LinkSectionParser, LinkageParser, StdInternalSymbolParser,
}; };
use crate::attributes::lint_helpers::{ use crate::attributes::lint_helpers::{
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser, AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
@@ -162,6 +162,7 @@ attribute_parsers!(
Combine<AllowConstFnUnstableParser>, Combine<AllowConstFnUnstableParser>,
Combine<AllowInternalUnstableParser>, Combine<AllowInternalUnstableParser>,
Combine<ForceTargetFeatureParser>, Combine<ForceTargetFeatureParser>,
Combine<LinkParser>,
Combine<ReprParser>, Combine<ReprParser>,
Combine<TargetFeatureParser>, Combine<TargetFeatureParser>,
Combine<UnstableFeatureBoundParser>, Combine<UnstableFeatureBoundParser>,

View File

@@ -79,6 +79,7 @@
// tidy-alphabetical-start // tidy-alphabetical-start
#![allow(internal_features)] #![allow(internal_features)]
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(decl_macro)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![recursion_limit = "256"] #![recursion_limit = "256"]
// tidy-alphabetical-end // tidy-alphabetical-end

View File

@@ -836,3 +836,97 @@ pub(crate) struct InvalidAttrStyle {
pub target_span: Option<Span>, pub target_span: Option<Span>,
pub target: Target, pub target: Target,
} }
#[derive(Diagnostic)]
#[diag(attr_parsing_empty_link_name, code = E0454)]
pub(crate) struct EmptyLinkName {
#[primary_span]
#[label]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_link_framework_apple, code = E0455)]
pub(crate) struct LinkFrameworkApple {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_incompatible_wasm_link)]
pub(crate) struct IncompatibleWasmLink {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_link_requires_name, code = E0459)]
pub(crate) struct LinkRequiresName {
#[primary_span]
#[label]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_raw_dylib_no_nul)]
pub(crate) struct RawDylibNoNul {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_raw_dylib_only_windows, code = E0455)]
pub(crate) struct RawDylibOnlyWindows {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_invalid_link_modifier)]
pub(crate) struct InvalidLinkModifier {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_multiple_modifiers)]
pub(crate) struct MultipleModifiers {
#[primary_span]
pub span: Span,
pub modifier: Symbol,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_import_name_type_x86)]
pub(crate) struct ImportNameTypeX86 {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_bundle_needs_static)]
pub(crate) struct BundleNeedsStatic {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_whole_archive_needs_static)]
pub(crate) struct WholeArchiveNeedsStatic {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_as_needed_compatibility)]
pub(crate) struct AsNeededCompatibility {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(attr_parsing_import_name_type_raw)]
pub(crate) struct ImportNameTypeRaw {
#[primary_span]
pub span: Span,
}

View File

@@ -14,11 +14,13 @@ use itertools::Itertools;
use regex::Regex; use regex::Regex;
use rustc_arena::TypedArena; use rustc_arena::TypedArena;
use rustc_ast::CRATE_NODE_ID; use rustc_ast::CRATE_NODE_ID;
use rustc_attr_parsing::{ShouldEmit, eval_config_entry};
use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::memmap::Mmap; use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{DiagCtxtHandle, LintDiagnostic}; use rustc_errors::{DiagCtxtHandle, LintDiagnostic};
use rustc_fs_util::{TempDirBuilder, fix_windows_verbatim_for_gcc, try_canonicalize}; use rustc_fs_util::{TempDirBuilder, fix_windows_verbatim_for_gcc, try_canonicalize};
use rustc_hir::attrs::NativeLibKind;
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
use rustc_macros::LintDiagnostic; use rustc_macros::LintDiagnostic;
use rustc_metadata::fs::{METADATA_FILENAME, copy_to_stdout, emit_wrapper_file}; use rustc_metadata::fs::{METADATA_FILENAME, copy_to_stdout, emit_wrapper_file};
@@ -38,7 +40,6 @@ use rustc_session::config::{
use rustc_session::lint::builtin::LINKER_MESSAGES; use rustc_session::lint::builtin::LINKER_MESSAGES;
use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename}; use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename};
use rustc_session::search_paths::PathKind; use rustc_session::search_paths::PathKind;
use rustc_session::utils::NativeLibKind;
/// For all the linkers we support, and information they might /// For all the linkers we support, and information they might
/// need out of the shared crate context before we get rid of it. /// need out of the shared crate context before we get rid of it.
use rustc_session::{Session, filesearch}; use rustc_session::{Session, filesearch};
@@ -3019,7 +3020,9 @@ fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) {
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool { fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
match lib.cfg { match lib.cfg {
Some(ref cfg) => rustc_attr_parsing::cfg_matches(cfg, sess, CRATE_NODE_ID, None), Some(ref cfg) => {
eval_config_entry(sess, cfg, CRATE_NODE_ID, None, ShouldEmit::ErrorsAndLints).as_bool()
}
None => true, None => true,
} }
} }

View File

@@ -7,9 +7,9 @@ use rustc_data_structures::base_n::{CASE_INSENSITIVE, ToBaseN};
use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_data_structures::stable_hasher::StableHasher; use rustc_data_structures::stable_hasher::StableHasher;
use rustc_hashes::Hash128; use rustc_hashes::Hash128;
use rustc_hir::attrs::NativeLibKind;
use rustc_session::Session; use rustc_session::Session;
use rustc_session::cstore::DllImport; use rustc_session::cstore::DllImport;
use rustc_session::utils::NativeLibKind;
use rustc_span::Symbol; use rustc_span::Symbol;
use crate::back::archive::ImportLibraryItem; use crate::back::archive::ImportLibraryItem;

View File

@@ -1,10 +1,11 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
use rustc_hir::LangItem; use rustc_hir::LangItem;
use rustc_hir::attrs::PeImportNameType;
use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{self, Instance, TyCtxt}; use rustc_middle::ty::{self, Instance, TyCtxt};
use rustc_middle::{bug, mir, span_bug}; use rustc_middle::{bug, mir, span_bug};
use rustc_session::cstore::{DllCallingConvention, DllImport, PeImportNameType}; use rustc_session::cstore::{DllCallingConvention, DllImport};
use rustc_span::Span; use rustc_span::Span;
use rustc_target::spec::Target; use rustc_target::spec::Target;

View File

@@ -25,10 +25,10 @@ use std::io;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::Arc; use std::sync::Arc;
use rustc_ast as ast;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_data_structures::unord::UnordMap; use rustc_data_structures::unord::UnordMap;
use rustc_hir::CRATE_HIR_ID; use rustc_hir::CRATE_HIR_ID;
use rustc_hir::attrs::{CfgEntry, NativeLibKind};
use rustc_hir::def_id::CrateNum; use rustc_hir::def_id::CrateNum;
use rustc_macros::{Decodable, Encodable, HashStable}; use rustc_macros::{Decodable, Encodable, HashStable};
use rustc_metadata::EncodedMetadata; use rustc_metadata::EncodedMetadata;
@@ -45,7 +45,6 @@ use rustc_session::Session;
use rustc_session::config::{CrateType, OutputFilenames, OutputType, RUST_CGU_EXT}; use rustc_session::config::{CrateType, OutputFilenames, OutputType, RUST_CGU_EXT};
use rustc_session::cstore::{self, CrateSource}; use rustc_session::cstore::{self, CrateSource};
use rustc_session::lint::builtin::LINKER_MESSAGES; use rustc_session::lint::builtin::LINKER_MESSAGES;
use rustc_session::utils::NativeLibKind;
use rustc_span::Symbol; use rustc_span::Symbol;
pub mod assert_module_sources; pub mod assert_module_sources;
@@ -187,7 +186,7 @@ pub struct NativeLib {
pub kind: NativeLibKind, pub kind: NativeLibKind,
pub name: Symbol, pub name: Symbol,
pub filename: Option<Symbol>, pub filename: Option<Symbol>,
pub cfg: Option<ast::MetaItemInner>, pub cfg: Option<CfgEntry>,
pub verbatim: bool, pub verbatim: bool,
pub dll_imports: Vec<cstore::DllImport>, pub dll_imports: Vec<cstore::DllImport>,
} }

View File

@@ -1,8 +1,10 @@
#### Note: this error code is no longer emitted by the compiler.
An unknown "kind" was specified for a link attribute. An unknown "kind" was specified for a link attribute.
Erroneous code example: Erroneous code example:
```compile_fail,E0458 ```ignore (no longer emitted)
#[link(kind = "wonderful_unicorn")] extern "C" {} #[link(kind = "wonderful_unicorn")] extern "C" {}
// error: unknown kind: `wonderful_unicorn` // error: unknown kind: `wonderful_unicorn`
``` ```

View File

@@ -248,6 +248,120 @@ impl IntoDiagArg for MirPhase {
} }
} }
/// Different ways that the PE Format can decorate a symbol name.
/// From <https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-name-type>
#[derive(
Copy,
Clone,
Debug,
Encodable,
Decodable,
HashStable_Generic,
PartialEq,
Eq,
PrintAttribute
)]
pub enum PeImportNameType {
/// IMPORT_ORDINAL
/// Uses the ordinal (i.e., a number) rather than the name.
Ordinal(u16),
/// Same as IMPORT_NAME
/// Name is decorated with all prefixes and suffixes.
Decorated,
/// Same as IMPORT_NAME_NOPREFIX
/// Prefix (e.g., the leading `_` or `@`) is skipped, but suffix is kept.
NoPrefix,
/// Same as IMPORT_NAME_UNDECORATE
/// Prefix (e.g., the leading `_` or `@`) and suffix (the first `@` and all
/// trailing characters) are skipped.
Undecorated,
}
#[derive(
Copy,
Clone,
Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Encodable,
Decodable,
PrintAttribute
)]
#[derive(HashStable_Generic)]
pub enum NativeLibKind {
/// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC)
Static {
/// Whether to bundle objects from static library into produced rlib
bundle: Option<bool>,
/// Whether to link static library without throwing any object files away
whole_archive: Option<bool>,
},
/// Dynamic library (e.g. `libfoo.so` on Linux)
/// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC).
Dylib {
/// Whether the dynamic library will be linked only if it satisfies some undefined symbols
as_needed: Option<bool>,
},
/// Dynamic library (e.g. `foo.dll` on Windows) without a corresponding import library.
/// On Linux, it refers to a generated shared library stub.
RawDylib,
/// A macOS-specific kind of dynamic libraries.
Framework {
/// Whether the framework will be linked only if it satisfies some undefined symbols
as_needed: Option<bool>,
},
/// Argument which is passed to linker, relative order with libraries and other arguments
/// is preserved
LinkArg,
/// Module imported from WebAssembly
WasmImportModule,
/// The library kind wasn't specified, `Dylib` is currently used as a default.
Unspecified,
}
impl NativeLibKind {
pub fn has_modifiers(&self) -> bool {
match self {
NativeLibKind::Static { bundle, whole_archive } => {
bundle.is_some() || whole_archive.is_some()
}
NativeLibKind::Dylib { as_needed } | NativeLibKind::Framework { as_needed } => {
as_needed.is_some()
}
NativeLibKind::RawDylib
| NativeLibKind::Unspecified
| NativeLibKind::LinkArg
| NativeLibKind::WasmImportModule => false,
}
}
pub fn is_statically_included(&self) -> bool {
matches!(self, NativeLibKind::Static { .. })
}
pub fn is_dllimport(&self) -> bool {
matches!(
self,
NativeLibKind::Dylib { .. } | NativeLibKind::RawDylib | NativeLibKind::Unspecified
)
}
}
#[derive(Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)]
pub struct LinkEntry {
pub span: Span,
pub kind: NativeLibKind,
pub name: Symbol,
pub cfg: Option<CfgEntry>,
pub verbatim: Option<bool>,
pub import_name_type: Option<(PeImportNameType, Span)>,
}
/// Represents parsed *built-in* inert attributes. /// Represents parsed *built-in* inert attributes.
/// ///
/// ## Overview /// ## Overview
@@ -418,6 +532,9 @@ pub enum AttributeKind {
/// Represents `#[inline]` and `#[rustc_force_inline]`. /// Represents `#[inline]` and `#[rustc_force_inline]`.
Inline(InlineAttr, Span), Inline(InlineAttr, Span),
/// Represents `#[link]`.
Link(ThinVec<LinkEntry>, Span),
/// Represents `#[link_name]`. /// Represents `#[link_name]`.
LinkName { name: Symbol, span: Span }, LinkName { name: Symbol, span: Span },

View File

@@ -50,6 +50,7 @@ impl AttributeKind {
Fundamental { .. } => Yes, Fundamental { .. } => Yes,
Ignore { .. } => No, Ignore { .. } => No,
Inline(..) => No, Inline(..) => No,
Link(..) => No,
LinkName { .. } => Yes, // Needed for rustdoc LinkName { .. } => Yes, // Needed for rustdoc
LinkOrdinal { .. } => No, LinkOrdinal { .. } => No,
LinkSection { .. } => Yes, // Needed for rustdoc LinkSection { .. } => Yes, // Needed for rustdoc

View File

@@ -8,6 +8,7 @@ use rustc_abi::Align;
use rustc_data_structures::profiling::TimePassesFormat; use rustc_data_structures::profiling::TimePassesFormat;
use rustc_errors::emitter::HumanReadableErrorType; use rustc_errors::emitter::HumanReadableErrorType;
use rustc_errors::{ColorConfig, registry}; use rustc_errors::{ColorConfig, registry};
use rustc_hir::attrs::NativeLibKind;
use rustc_session::config::{ use rustc_session::config::{
AutoDiff, BranchProtection, CFGuard, Cfg, CollapseMacroDebuginfo, CoverageLevel, AutoDiff, BranchProtection, CFGuard, Cfg, CollapseMacroDebuginfo, CoverageLevel,
CoverageOptions, DebugInfo, DumpMonoStatsFormat, ErrorOutputType, ExternEntry, ExternLocation, CoverageOptions, DebugInfo, DumpMonoStatsFormat, ErrorOutputType, ExternEntry, ExternLocation,
@@ -20,7 +21,7 @@ use rustc_session::config::{
}; };
use rustc_session::lint::Level; use rustc_session::lint::Level;
use rustc_session::search_paths::SearchPath; use rustc_session::search_paths::SearchPath;
use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind}; use rustc_session::utils::{CanonicalizedPath, NativeLib};
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, build_session, getopts}; use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, build_session, getopts};
use rustc_span::edition::{DEFAULT_EDITION, Edition}; use rustc_span::edition::{DEFAULT_EDITION, Edition};
use rustc_span::source_map::{RealFileLoader, SourceMapInputs}; use rustc_span::source_map::{RealFileLoader, SourceMapInputs};

View File

@@ -1,6 +1,3 @@
metadata_as_needed_compatibility =
linking modifier `as-needed` is only compatible with `dylib` and `framework` linking kinds
metadata_async_drop_types_in_dependency = metadata_async_drop_types_in_dependency =
found async drop types in dependency `{$extern_crate}`, but async_drop feature is disabled for `{$local_crate}` found async drop types in dependency `{$extern_crate}`, but async_drop feature is disabled for `{$local_crate}`
.help = if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used .help = if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used
@@ -11,9 +8,6 @@ metadata_bad_panic_strategy =
metadata_binary_output_to_tty = metadata_binary_output_to_tty =
option `-o` or `--emit` is used to write binary output type `metadata` to stdout, but stdout is a tty option `-o` or `--emit` is used to write binary output type `metadata` to stdout, but stdout is a tty
metadata_bundle_needs_static =
linking modifier `bundle` is only compatible with `static` linking kind
metadata_cannot_find_crate = metadata_cannot_find_crate =
can't find crate for `{$crate_name}`{$add_info} can't find crate for `{$crate_name}`{$add_info}
@@ -60,10 +54,6 @@ metadata_crate_not_panic_runtime =
metadata_dl_error = metadata_dl_error =
{$path}{$err} {$path}{$err}
metadata_empty_link_name =
link name must not be empty
.label = empty link name
metadata_empty_renaming_target = metadata_empty_renaming_target =
an empty renaming target was specified for library `{$lib_name}` an empty renaming target was specified for library `{$lib_name}`
@@ -108,15 +98,6 @@ metadata_full_metadata_not_found =
metadata_global_alloc_required = metadata_global_alloc_required =
no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait
metadata_import_name_type_form =
import name type must be of the form `import_name_type = "string"`
metadata_import_name_type_raw =
import name type can only be used with link kind `raw-dylib`
metadata_import_name_type_x86 =
import name type is only supported on x86
metadata_incompatible_panic_in_drop_strategy = metadata_incompatible_panic_in_drop_strategy =
the crate `{$crate_name}` is compiled with the panic-in-drop strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}` the crate `{$crate_name}` is compiled with the panic-in-drop strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}`
@@ -143,15 +124,10 @@ metadata_incompatible_target_modifiers_r_missed =
mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}` mixing `{$flag_name_prefixed}` will cause an ABI mismatch in crate `{$local_crate}`
.note = `{$flag_name_prefixed}={$local_value}` in this crate is incompatible with unset `{$flag_name_prefixed}` in dependency `{$extern_crate}` .note = `{$flag_name_prefixed}={$local_value}` in this crate is incompatible with unset `{$flag_name_prefixed}` in dependency `{$extern_crate}`
.help = the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely .help = the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
metadata_incompatible_wasm_link =
`wasm_import_module` is incompatible with other arguments in `#[link]` attributes
metadata_install_missing_components = metadata_install_missing_components =
maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview` maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`
metadata_invalid_link_modifier =
invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed
metadata_invalid_meta_files = metadata_invalid_meta_files =
found invalid metadata files for crate `{$crate_name}`{$add_info} found invalid metadata files for crate `{$crate_name}`{$add_info}
@@ -164,67 +140,18 @@ metadata_lib_framework_apple =
metadata_lib_required = metadata_lib_required =
crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form
metadata_link_arg_unstable =
link kind `link-arg` is unstable
metadata_link_cfg_form =
link cfg must be of the form `cfg(/* predicate */)`
metadata_link_cfg_single_predicate =
link cfg must have a single predicate argument
metadata_link_cfg_unstable =
link cfg is unstable
metadata_link_framework_apple =
link kind `framework` is only supported on Apple targets
metadata_link_kind_form =
link kind must be of the form `kind = "string"`
metadata_link_modifiers_form =
link modifiers must be of the form `modifiers = "string"`
metadata_link_name_form =
link name must be of the form `name = "string"`
metadata_link_ordinal_raw_dylib = metadata_link_ordinal_raw_dylib =
`#[link_ordinal]` is only supported if link kind is `raw-dylib` `#[link_ordinal]` is only supported if link kind is `raw-dylib`
metadata_link_requires_name =
`#[link]` attribute requires a `name = "string"` argument
.label = missing `name` argument
metadata_missing_native_library = metadata_missing_native_library =
could not find native static library `{$libname}`, perhaps an -L flag is missing? could not find native static library `{$libname}`, perhaps an -L flag is missing?
metadata_multiple_candidates = metadata_multiple_candidates =
multiple candidates for `{$flavor}` dependency `{$crate_name}` found multiple candidates for `{$flavor}` dependency `{$crate_name}` found
metadata_multiple_cfgs =
multiple `cfg` arguments in a single `#[link]` attribute
metadata_multiple_import_name_type =
multiple `import_name_type` arguments in a single `#[link]` attribute
metadata_multiple_kinds_in_link =
multiple `kind` arguments in a single `#[link]` attribute
metadata_multiple_link_modifiers =
multiple `modifiers` arguments in a single `#[link]` attribute
metadata_multiple_modifiers =
multiple `{$modifier}` modifiers in a single `modifiers` argument
metadata_multiple_names_in_link =
multiple `name` arguments in a single `#[link]` attribute
metadata_multiple_renamings = metadata_multiple_renamings =
multiple renamings were specified for library `{$lib_name}` multiple renamings were specified for library `{$lib_name}`
metadata_multiple_wasm_import =
multiple `wasm_import_module` arguments in a single `#[link]` attribute
metadata_newer_crate_version = metadata_newer_crate_version =
found possibly newer version of crate `{$crate_name}`{$add_info} found possibly newer version of crate `{$crate_name}`{$add_info}
.note = perhaps that crate needs to be recompiled? .note = perhaps that crate needs to be recompiled?
@@ -263,15 +190,6 @@ metadata_prev_alloc_error_handler =
metadata_prev_global_alloc = metadata_prev_global_alloc =
previous global allocator defined here previous global allocator defined here
metadata_raw_dylib_elf_unstable =
link kind `raw-dylib` is unstable on ELF platforms
metadata_raw_dylib_no_nul =
link name must not contain NUL characters if link kind is `raw-dylib`
metadata_raw_dylib_only_windows =
link kind `raw-dylib` is only supported on Windows targets
metadata_raw_dylib_unsupported_abi = metadata_raw_dylib_unsupported_abi =
ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
@@ -307,19 +225,6 @@ metadata_target_not_installed =
metadata_two_panic_runtimes = metadata_two_panic_runtimes =
cannot link together two panic runtimes: {$prev_name} and {$cur_name} cannot link together two panic runtimes: {$prev_name} and {$cur_name}
metadata_unexpected_link_arg =
unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module, import_name_type
metadata_unknown_import_name_type =
unknown import name type `{$import_name_type}`, expected one of: decorated, noprefix, undecorated
metadata_unknown_link_kind =
unknown link kind `{$kind}`, expected one of: static, dylib, framework, raw-dylib, link-arg
.label = unknown link kind
metadata_unknown_link_modifier =
unknown linking modifier `{$modifier}`, expected one of: bundle, verbatim, whole-archive, as-needed
metadata_unknown_target_modifier_unsafe_allowed = unknown target modifier `{$flag_name}`, requested by `-Cunsafe-allow-abi-mismatch={$flag_name}` metadata_unknown_target_modifier_unsafe_allowed = unknown target modifier `{$flag_name}`, requested by `-Cunsafe-allow-abi-mismatch={$flag_name}`
metadata_wasm_c_abi = metadata_wasm_c_abi =

View File

@@ -83,187 +83,6 @@ pub struct IncompatiblePanicInDropStrategy {
pub desired_strategy: PanicStrategy, pub desired_strategy: PanicStrategy,
} }
#[derive(Diagnostic)]
#[diag(metadata_multiple_names_in_link)]
pub struct MultipleNamesInLink {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_multiple_kinds_in_link)]
pub struct MultipleKindsInLink {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_link_name_form)]
pub struct LinkNameForm {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_link_kind_form)]
pub struct LinkKindForm {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_link_modifiers_form)]
pub struct LinkModifiersForm {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_link_cfg_form)]
pub struct LinkCfgForm {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_wasm_import_form)]
pub struct WasmImportForm {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_empty_link_name, code = E0454)]
pub struct EmptyLinkName {
#[primary_span]
#[label]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_link_framework_apple, code = E0455)]
pub struct LinkFrameworkApple {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_raw_dylib_only_windows, code = E0455)]
pub struct RawDylibOnlyWindows {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_unknown_link_kind, code = E0458)]
pub struct UnknownLinkKind<'a> {
#[primary_span]
#[label]
pub span: Span,
pub kind: &'a str,
}
#[derive(Diagnostic)]
#[diag(metadata_multiple_link_modifiers)]
pub struct MultipleLinkModifiers {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_multiple_cfgs)]
pub struct MultipleCfgs {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_link_cfg_single_predicate)]
pub struct LinkCfgSinglePredicate {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_multiple_wasm_import)]
pub struct MultipleWasmImport {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_unexpected_link_arg)]
pub struct UnexpectedLinkArg {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_invalid_link_modifier)]
pub struct InvalidLinkModifier {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_multiple_modifiers)]
pub struct MultipleModifiers<'a> {
#[primary_span]
pub span: Span,
pub modifier: &'a str,
}
#[derive(Diagnostic)]
#[diag(metadata_bundle_needs_static)]
pub struct BundleNeedsStatic {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_whole_archive_needs_static)]
pub struct WholeArchiveNeedsStatic {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_as_needed_compatibility)]
pub struct AsNeededCompatibility {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_unknown_link_modifier)]
pub struct UnknownLinkModifier<'a> {
#[primary_span]
pub span: Span,
pub modifier: &'a str,
}
#[derive(Diagnostic)]
#[diag(metadata_incompatible_wasm_link)]
pub struct IncompatibleWasmLink {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_link_requires_name, code = E0459)]
pub struct LinkRequiresName {
#[primary_span]
#[label]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_raw_dylib_no_nul)]
pub struct RawDylibNoNul {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(metadata_link_ordinal_raw_dylib)] #[diag(metadata_link_ordinal_raw_dylib)]
pub struct LinkOrdinalRawDylib { pub struct LinkOrdinalRawDylib {
@@ -706,42 +525,6 @@ pub struct LibFilenameForm<'a> {
pub dll_suffix: &'a str, pub dll_suffix: &'a str,
} }
#[derive(Diagnostic)]
#[diag(metadata_multiple_import_name_type)]
pub struct MultipleImportNameType {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_import_name_type_form)]
pub struct ImportNameTypeForm {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_import_name_type_x86)]
pub struct ImportNameTypeX86 {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(metadata_unknown_import_name_type)]
pub struct UnknownImportNameType<'a> {
#[primary_span]
pub span: Span,
pub import_name_type: &'a str,
}
#[derive(Diagnostic)]
#[diag(metadata_import_name_type_raw)]
pub struct ImportNameTypeRaw {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(metadata_wasm_c_abi)] #[diag(metadata_wasm_c_abi)]
pub(crate) struct WasmCAbi { pub(crate) struct WasmCAbi {

View File

@@ -3,25 +3,21 @@ use std::path::{Path, PathBuf};
use rustc_abi::ExternAbi; use rustc_abi::ExternAbi;
use rustc_ast::CRATE_NODE_ID; use rustc_ast::CRATE_NODE_ID;
use rustc_attr_parsing as attr; use rustc_attr_parsing::{ShouldEmit, eval_config_entry};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_hir::attrs::AttributeKind; use rustc_hir::attrs::{AttributeKind, NativeLibKind, PeImportNameType};
use rustc_hir::find_attr; use rustc_hir::find_attr;
use rustc_middle::query::LocalCrate; use rustc_middle::query::LocalCrate;
use rustc_middle::ty::{self, List, Ty, TyCtxt}; use rustc_middle::ty::{self, List, Ty, TyCtxt};
use rustc_session::Session; use rustc_session::Session;
use rustc_session::config::CrateType; use rustc_session::config::CrateType;
use rustc_session::cstore::{ use rustc_session::cstore::{DllCallingConvention, DllImport, ForeignModule, NativeLib};
DllCallingConvention, DllImport, ForeignModule, NativeLib, PeImportNameType,
};
use rustc_session::parse::feature_err;
use rustc_session::search_paths::PathKind; use rustc_session::search_paths::PathKind;
use rustc_session::utils::NativeLibKind; use rustc_span::Symbol;
use rustc_span::def_id::{DefId, LOCAL_CRATE}; use rustc_span::def_id::{DefId, LOCAL_CRATE};
use rustc_span::{Symbol, sym};
use rustc_target::spec::{BinaryFormat, LinkSelfContainedComponents}; use rustc_target::spec::{BinaryFormat, LinkSelfContainedComponents};
use crate::{errors, fluent_generated}; use crate::errors;
/// The fallback directories are passed to linker, but not used when rustc does the search, /// The fallback directories are passed to linker, but not used when rustc does the search,
/// because in the latter case the set of fallback directories cannot always be determined /// because in the latter case the set of fallback directories cannot always be determined
@@ -192,7 +188,9 @@ pub(crate) fn collect(tcx: TyCtxt<'_>, LocalCrate: LocalCrate) -> Vec<NativeLib>
pub(crate) fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool { pub(crate) fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
match lib.cfg { match lib.cfg {
Some(ref cfg) => attr::cfg_matches(cfg, sess, CRATE_NODE_ID, None), Some(ref cfg) => {
eval_config_entry(sess, cfg, CRATE_NODE_ID, None, ShouldEmit::ErrorsAndLints).as_bool()
}
None => true, None => true,
} }
} }
@@ -213,289 +211,23 @@ impl<'tcx> Collector<'tcx> {
return; return;
} }
// Process all of the #[link(..)]-style arguments for attr in
let features = self.tcx.features(); find_attr!(self.tcx.get_all_attrs(def_id), AttributeKind::Link(links, _) => links)
.iter()
for m in self.tcx.get_attrs(def_id, sym::link) { .map(|v| v.iter())
let Some(items) = m.meta_item_list() else { .flatten()
continue;
};
let mut name = None;
let mut kind = None;
let mut modifiers = None;
let mut cfg = None;
let mut wasm_import_module = None;
let mut import_name_type = None;
for item in items.iter() {
match item.name() {
Some(sym::name) => {
if name.is_some() {
sess.dcx().emit_err(errors::MultipleNamesInLink { span: item.span() });
continue;
}
let Some(link_name) = item.value_str() else {
sess.dcx().emit_err(errors::LinkNameForm { span: item.span() });
continue;
};
let span = item.name_value_literal_span().unwrap();
if link_name.is_empty() {
sess.dcx().emit_err(errors::EmptyLinkName { span });
}
name = Some((link_name, span));
}
Some(sym::kind) => {
if kind.is_some() {
sess.dcx().emit_err(errors::MultipleKindsInLink { span: item.span() });
continue;
}
let Some(link_kind) = item.value_str() else {
sess.dcx().emit_err(errors::LinkKindForm { span: item.span() });
continue;
};
let span = item.name_value_literal_span().unwrap();
let link_kind = match link_kind.as_str() {
"static" => NativeLibKind::Static { bundle: None, whole_archive: None },
"dylib" => NativeLibKind::Dylib { as_needed: None },
"framework" => {
if !sess.target.is_like_darwin {
sess.dcx().emit_err(errors::LinkFrameworkApple { span });
}
NativeLibKind::Framework { as_needed: None }
}
"raw-dylib" => {
if sess.target.is_like_windows {
// raw-dylib is stable and working on Windows
} else if sess.target.binary_format == BinaryFormat::Elf
&& features.raw_dylib_elf()
{ {
// raw-dylib is unstable on ELF, but the user opted in let dll_imports = match attr.kind {
} else if sess.target.binary_format == BinaryFormat::Elf NativeLibKind::RawDylib => foreign_items
&& sess.is_nightly_build()
{
feature_err(
sess,
sym::raw_dylib_elf,
span,
fluent_generated::metadata_raw_dylib_elf_unstable,
)
.emit();
} else {
sess.dcx().emit_err(errors::RawDylibOnlyWindows { span });
}
NativeLibKind::RawDylib
}
"link-arg" => {
if !features.link_arg_attribute() {
feature_err(
sess,
sym::link_arg_attribute,
span,
fluent_generated::metadata_link_arg_unstable,
)
.emit();
}
NativeLibKind::LinkArg
}
kind => {
sess.dcx().emit_err(errors::UnknownLinkKind { span, kind });
continue;
}
};
kind = Some(link_kind);
}
Some(sym::modifiers) => {
if modifiers.is_some() {
sess.dcx()
.emit_err(errors::MultipleLinkModifiers { span: item.span() });
continue;
}
let Some(link_modifiers) = item.value_str() else {
sess.dcx().emit_err(errors::LinkModifiersForm { span: item.span() });
continue;
};
modifiers = Some((link_modifiers, item.name_value_literal_span().unwrap()));
}
Some(sym::cfg) => {
if cfg.is_some() {
sess.dcx().emit_err(errors::MultipleCfgs { span: item.span() });
continue;
}
let Some(link_cfg) = item.meta_item_list() else {
sess.dcx().emit_err(errors::LinkCfgForm { span: item.span() });
continue;
};
let [link_cfg] = link_cfg else {
sess.dcx()
.emit_err(errors::LinkCfgSinglePredicate { span: item.span() });
continue;
};
let Some(link_cfg) = link_cfg.meta_item_or_bool() else {
sess.dcx()
.emit_err(errors::LinkCfgSinglePredicate { span: item.span() });
continue;
};
if !features.link_cfg() {
feature_err(
sess,
sym::link_cfg,
item.span(),
fluent_generated::metadata_link_cfg_unstable,
)
.emit();
}
cfg = Some(link_cfg.clone());
}
Some(sym::wasm_import_module) => {
if wasm_import_module.is_some() {
sess.dcx().emit_err(errors::MultipleWasmImport { span: item.span() });
continue;
}
let Some(link_wasm_import_module) = item.value_str() else {
sess.dcx().emit_err(errors::WasmImportForm { span: item.span() });
continue;
};
wasm_import_module = Some((link_wasm_import_module, item.span()));
}
Some(sym::import_name_type) => {
if import_name_type.is_some() {
sess.dcx()
.emit_err(errors::MultipleImportNameType { span: item.span() });
continue;
}
let Some(link_import_name_type) = item.value_str() else {
sess.dcx().emit_err(errors::ImportNameTypeForm { span: item.span() });
continue;
};
if self.tcx.sess.target.arch != "x86" {
sess.dcx().emit_err(errors::ImportNameTypeX86 { span: item.span() });
continue;
}
let link_import_name_type = match link_import_name_type.as_str() {
"decorated" => PeImportNameType::Decorated,
"noprefix" => PeImportNameType::NoPrefix,
"undecorated" => PeImportNameType::Undecorated,
import_name_type => {
sess.dcx().emit_err(errors::UnknownImportNameType {
span: item.span(),
import_name_type,
});
continue;
}
};
import_name_type = Some((link_import_name_type, item.span()));
}
_ => {
sess.dcx().emit_err(errors::UnexpectedLinkArg { span: item.span() });
}
}
}
// Do this outside the above loop so we don't depend on modifiers coming after kinds
let mut verbatim = None;
if let Some((modifiers, span)) = modifiers {
for modifier in modifiers.as_str().split(',') {
let (modifier, value) = match modifier.strip_prefix(&['+', '-']) {
Some(m) => (m, modifier.starts_with('+')),
None => {
sess.dcx().emit_err(errors::InvalidLinkModifier { span });
continue;
}
};
macro report_unstable_modifier($feature: ident) {
if !features.$feature() {
// FIXME: make this translatable
#[expect(rustc::untranslatable_diagnostic)]
feature_err(
sess,
sym::$feature,
span,
format!("linking modifier `{modifier}` is unstable"),
)
.emit();
}
}
let assign_modifier = |dst: &mut Option<bool>| {
if dst.is_some() {
sess.dcx().emit_err(errors::MultipleModifiers { span, modifier });
} else {
*dst = Some(value);
}
};
match (modifier, &mut kind) {
("bundle", Some(NativeLibKind::Static { bundle, .. })) => {
assign_modifier(bundle)
}
("bundle", _) => {
sess.dcx().emit_err(errors::BundleNeedsStatic { span });
}
("verbatim", _) => assign_modifier(&mut verbatim),
("whole-archive", Some(NativeLibKind::Static { whole_archive, .. })) => {
assign_modifier(whole_archive)
}
("whole-archive", _) => {
sess.dcx().emit_err(errors::WholeArchiveNeedsStatic { span });
}
("as-needed", Some(NativeLibKind::Dylib { as_needed }))
| ("as-needed", Some(NativeLibKind::Framework { as_needed })) => {
report_unstable_modifier!(native_link_modifiers_as_needed);
assign_modifier(as_needed)
}
("as-needed", _) => {
sess.dcx().emit_err(errors::AsNeededCompatibility { span });
}
_ => {
sess.dcx().emit_err(errors::UnknownLinkModifier { span, modifier });
}
}
}
}
if let Some((_, span)) = wasm_import_module {
if name.is_some() || kind.is_some() || modifiers.is_some() || cfg.is_some() {
sess.dcx().emit_err(errors::IncompatibleWasmLink { span });
}
}
if wasm_import_module.is_some() {
(name, kind) = (wasm_import_module, Some(NativeLibKind::WasmImportModule));
}
let Some((name, name_span)) = name else {
sess.dcx().emit_err(errors::LinkRequiresName { span: m.span() });
continue;
};
// 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) {
sess.dcx().emit_err(errors::ImportNameTypeRaw { span });
}
}
let dll_imports = match kind {
Some(NativeLibKind::RawDylib) => {
if name.as_str().contains('\0') {
sess.dcx().emit_err(errors::RawDylibNoNul { span: name_span });
}
foreign_items
.iter() .iter()
.map(|&child_item| { .map(|&child_item| {
self.build_dll_import( self.build_dll_import(
abi, abi,
import_name_type.map(|(import_name_type, _)| import_name_type), attr.import_name_type.map(|(import_name_type, _)| import_name_type),
child_item, child_item,
) )
}) })
.collect() .collect(),
}
_ => { _ => {
for &child_item in foreign_items { for &child_item in foreign_items {
if let Some(span) = find_attr!(self.tcx.get_all_attrs(child_item), AttributeKind::LinkOrdinal {span, ..} => *span) if let Some(span) = find_attr!(self.tcx.get_all_attrs(child_item), AttributeKind::LinkOrdinal {span, ..} => *span)
@@ -508,15 +240,20 @@ impl<'tcx> Collector<'tcx> {
} }
}; };
let kind = kind.unwrap_or(NativeLibKind::Unspecified); let filename = find_bundled_library(
let filename = find_bundled_library(name, verbatim, kind, cfg.is_some(), self.tcx); attr.name,
attr.verbatim,
attr.kind,
attr.cfg.is_some(),
self.tcx,
);
self.libs.push(NativeLib { self.libs.push(NativeLib {
name, name: attr.name,
filename, filename,
kind, kind: attr.kind,
cfg, cfg: attr.cfg.clone(),
foreign_module: Some(def_id.to_def_id()), foreign_module: Some(def_id.to_def_id()),
verbatim, verbatim: attr.verbatim,
dll_imports, dll_imports,
}); });
} }

View File

@@ -200,6 +200,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
&Attribute::Parsed(AttributeKind::Sanitize { on_set, off_set, span: attr_span}) => { &Attribute::Parsed(AttributeKind::Sanitize { on_set, off_set, span: attr_span}) => {
self.check_sanitize(attr_span, on_set | off_set, span, target); self.check_sanitize(attr_span, on_set | off_set, span, target);
}, },
Attribute::Parsed(AttributeKind::Link(_, attr_span)) => {
self.check_link(hir_id, *attr_span, span, target)
}
Attribute::Parsed( Attribute::Parsed(
AttributeKind::BodyStability { .. } AttributeKind::BodyStability { .. }
| AttributeKind::ConstStabilityIndirect | AttributeKind::ConstStabilityIndirect
@@ -305,7 +308,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
[sym::rustc_has_incoherent_inherent_impls, ..] => { [sym::rustc_has_incoherent_inherent_impls, ..] => {
self.check_has_incoherent_inherent_impls(attr, span, target) self.check_has_incoherent_inherent_impls(attr, span, target)
} }
[sym::link, ..] => self.check_link(hir_id, attr, span, target),
[sym::macro_export, ..] => self.check_macro_export(hir_id, attr, target), [sym::macro_export, ..] => self.check_macro_export(hir_id, attr, target),
[sym::autodiff_forward, ..] | [sym::autodiff_reverse, ..] => { [sym::autodiff_forward, ..] | [sym::autodiff_reverse, ..] => {
self.check_autodiff(hir_id, attr, span, target) self.check_autodiff(hir_id, attr, span, target)
@@ -1324,7 +1326,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
} }
/// Checks if `#[link]` is applied to an item other than a foreign module. /// Checks if `#[link]` is applied to an item other than a foreign module.
fn check_link(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) { fn check_link(&self, hir_id: HirId, attr_span: Span, span: Span, target: Target) {
if target == Target::ForeignMod if target == Target::ForeignMod
&& let hir::Node::Item(item) = self.tcx.hir_node(hir_id) && let hir::Node::Item(item) = self.tcx.hir_node(hir_id)
&& let Item { kind: ItemKind::ForeignMod { abi, .. }, .. } = item && let Item { kind: ItemKind::ForeignMod { abi, .. }, .. } = item
@@ -1336,7 +1338,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
self.tcx.emit_node_span_lint( self.tcx.emit_node_span_lint(
UNUSED_ATTRIBUTES, UNUSED_ATTRIBUTES,
hir_id, hir_id,
attr.span(), attr_span,
errors::Link { span: (target != Target::ForeignMod).then_some(span) }, errors::Link { span: (target != Target::ForeignMod).then_some(span) },
); );
} }

View File

@@ -5,10 +5,11 @@
//! which have their own parser in `rustc_metadata`.) //! which have their own parser in `rustc_metadata`.)
use rustc_feature::UnstableFeatures; use rustc_feature::UnstableFeatures;
use rustc_hir::attrs::NativeLibKind;
use crate::EarlyDiagCtxt; use crate::EarlyDiagCtxt;
use crate::config::UnstableOptions; use crate::config::UnstableOptions;
use crate::utils::{NativeLib, NativeLibKind}; use crate::utils::NativeLib;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;

View File

@@ -6,8 +6,8 @@ use std::any::Any;
use std::path::PathBuf; use std::path::PathBuf;
use rustc_abi::ExternAbi; use rustc_abi::ExternAbi;
use rustc_ast as ast;
use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock}; use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock};
use rustc_hir::attrs::{CfgEntry, NativeLibKind, PeImportNameType};
use rustc_hir::def_id::{ use rustc_hir::def_id::{
CrateNum, DefId, LOCAL_CRATE, LocalDefId, StableCrateId, StableCrateIdMap, CrateNum, DefId, LOCAL_CRATE, LocalDefId, StableCrateId, StableCrateIdMap,
}; };
@@ -16,7 +16,6 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use crate::search_paths::PathKind; use crate::search_paths::PathKind;
use crate::utils::NativeLibKind;
// lonely orphan structs and enums looking for a better home // lonely orphan structs and enums looking for a better home
@@ -72,7 +71,7 @@ pub struct NativeLib {
pub name: Symbol, pub name: Symbol,
/// If packed_bundled_libs enabled, actual filename of library is stored. /// If packed_bundled_libs enabled, actual filename of library is stored.
pub filename: Option<Symbol>, pub filename: Option<Symbol>,
pub cfg: Option<ast::MetaItemInner>, pub cfg: Option<CfgEntry>,
pub foreign_module: Option<DefId>, pub foreign_module: Option<DefId>,
pub verbatim: Option<bool>, pub verbatim: Option<bool>,
pub dll_imports: Vec<DllImport>, pub dll_imports: Vec<DllImport>,
@@ -88,25 +87,6 @@ impl NativeLib {
} }
} }
/// Different ways that the PE Format can decorate a symbol name.
/// From <https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-name-type>
#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable_Generic, PartialEq, Eq)]
pub enum PeImportNameType {
/// IMPORT_ORDINAL
/// Uses the ordinal (i.e., a number) rather than the name.
Ordinal(u16),
/// Same as IMPORT_NAME
/// Name is decorated with all prefixes and suffixes.
Decorated,
/// Same as IMPORT_NAME_NOPREFIX
/// Prefix (e.g., the leading `_` or `@`) is skipped, but suffix is kept.
NoPrefix,
/// Same as IMPORT_NAME_UNDECORATE
/// Prefix (e.g., the leading `_` or `@`) and suffix (the first `@` and all
/// trailing characters) are skipped.
Undecorated,
}
#[derive(Clone, Debug, Encodable, Decodable, HashStable_Generic)] #[derive(Clone, Debug, Encodable, Decodable, HashStable_Generic)]
pub struct DllImport { pub struct DllImport {
pub name: Symbol, pub name: Symbol,

View File

@@ -3,6 +3,7 @@ use std::sync::OnceLock;
use rustc_data_structures::profiling::VerboseTimingGuard; use rustc_data_structures::profiling::VerboseTimingGuard;
use rustc_fs_util::try_canonicalize; use rustc_fs_util::try_canonicalize;
use rustc_hir::attrs::NativeLibKind;
use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use crate::session::Session; use crate::session::Session;
@@ -17,69 +18,6 @@ impl Session {
} }
} }
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
#[derive(HashStable_Generic)]
pub enum NativeLibKind {
/// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC)
Static {
/// Whether to bundle objects from static library into produced rlib
bundle: Option<bool>,
/// Whether to link static library without throwing any object files away
whole_archive: Option<bool>,
},
/// Dynamic library (e.g. `libfoo.so` on Linux)
/// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC).
Dylib {
/// Whether the dynamic library will be linked only if it satisfies some undefined symbols
as_needed: Option<bool>,
},
/// Dynamic library (e.g. `foo.dll` on Windows) without a corresponding import library.
/// On Linux, it refers to a generated shared library stub.
RawDylib,
/// A macOS-specific kind of dynamic libraries.
Framework {
/// Whether the framework will be linked only if it satisfies some undefined symbols
as_needed: Option<bool>,
},
/// Argument which is passed to linker, relative order with libraries and other arguments
/// is preserved
LinkArg,
/// Module imported from WebAssembly
WasmImportModule,
/// The library kind wasn't specified, `Dylib` is currently used as a default.
Unspecified,
}
impl NativeLibKind {
pub fn has_modifiers(&self) -> bool {
match self {
NativeLibKind::Static { bundle, whole_archive } => {
bundle.is_some() || whole_archive.is_some()
}
NativeLibKind::Dylib { as_needed } | NativeLibKind::Framework { as_needed } => {
as_needed.is_some()
}
NativeLibKind::RawDylib
| NativeLibKind::Unspecified
| NativeLibKind::LinkArg
| NativeLibKind::WasmImportModule => false,
}
}
pub fn is_statically_included(&self) -> bool {
matches!(self, NativeLibKind::Static { .. })
}
pub fn is_dllimport(&self) -> bool {
matches!(
self,
NativeLibKind::Dylib { .. } | NativeLibKind::RawDylib | NativeLibKind::Unspecified
)
}
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
#[derive(HashStable_Generic)] #[derive(HashStable_Generic)]
pub struct NativeLib { pub struct NativeLib {

View File

@@ -466,6 +466,7 @@ symbols! {
arm, arm,
arm_target_feature, arm_target_feature,
array, array,
as_dash_needed: "as-needed",
as_ptr, as_ptr,
as_ref, as_ref,
as_str, as_str,
@@ -592,6 +593,7 @@ symbols! {
btreeset_iter, btreeset_iter,
built, built,
builtin_syntax, builtin_syntax,
bundle,
c, c,
c_dash_variadic, c_dash_variadic,
c_str, c_str,
@@ -817,6 +819,7 @@ symbols! {
decl_macro, decl_macro,
declare_lint_pass, declare_lint_pass,
decode, decode,
decorated,
default_alloc_error_handler, default_alloc_error_handler,
default_field_values, default_field_values,
default_fn, default_fn,
@@ -1075,6 +1078,7 @@ symbols! {
format_macro, format_macro,
format_placeholder, format_placeholder,
format_unsafe_arg, format_unsafe_arg,
framework,
freeze, freeze,
freeze_impls, freeze_impls,
freg, freg,
@@ -1295,6 +1299,7 @@ symbols! {
link_arg_attribute, link_arg_attribute,
link_args, link_args,
link_cfg, link_cfg,
link_dash_arg: "link-arg",
link_llvm_intrinsics, link_llvm_intrinsics,
link_name, link_name,
link_ordinal, link_ordinal,
@@ -1528,6 +1533,7 @@ symbols! {
noop_method_borrow, noop_method_borrow,
noop_method_clone, noop_method_clone,
noop_method_deref, noop_method_deref,
noprefix,
noreturn, noreturn,
nostack, nostack,
not, not,
@@ -1741,6 +1747,7 @@ symbols! {
quote, quote,
range_inclusive_new, range_inclusive_new,
range_step, range_step,
raw_dash_dylib: "raw-dylib",
raw_dylib, raw_dylib,
raw_dylib_elf, raw_dylib_elf,
raw_eq, raw_eq,
@@ -2277,6 +2284,7 @@ symbols! {
unchecked_shl, unchecked_shl,
unchecked_shr, unchecked_shr,
unchecked_sub, unchecked_sub,
undecorated,
underscore_const_names, underscore_const_names,
underscore_imports, underscore_imports,
underscore_lifetimes, underscore_lifetimes,
@@ -2365,6 +2373,7 @@ symbols! {
vecdeque_iter, vecdeque_iter,
vecdeque_reserve, vecdeque_reserve,
vector, vector,
verbatim,
version, version,
vfp2, vfp2,
vis, vis,
@@ -2389,6 +2398,7 @@ symbols! {
weak_odr, weak_odr,
where_clause_attrs, where_clause_attrs,
while_let, while_let,
whole_dash_archive: "whole-archive",
width, width,
windows, windows,
windows_subsystem, windows_subsystem,

View File

@@ -2,8 +2,9 @@
//@ needs-rustc-debug-assertions //@ needs-rustc-debug-assertions
#![feature(extern_types)] #![feature(extern_types)]
#![feature(raw_dylib_elf)]
#[link(name = "bar", import_name_type = "decorated", kind = "raw-dylib")] #[link(name = "bar", kind = "raw-dylib")]
extern "C" { extern "C" {
pub type CrossCrate; pub type CrossCrate;
} }

View File

@@ -81,8 +81,7 @@
#[export_stable = 1] #[export_stable = 1]
//~^ ERROR malformed //~^ ERROR malformed
#[link] #[link]
//~^ ERROR valid forms for the attribute are //~^ ERROR malformed
//~| WARN this was previously accepted by the compiler
#[link_name] #[link_name]
//~^ ERROR malformed //~^ ERROR malformed
#[link_section] #[link_section]

View File

@@ -1,5 +1,5 @@
error[E0539]: malformed `cfg` attribute input error[E0539]: malformed `cfg` attribute input
--> $DIR/malformed-attrs.rs:102:1 --> $DIR/malformed-attrs.rs:101:1
| |
LL | #[cfg] LL | #[cfg]
| ^^^^^^ | ^^^^^^
@@ -10,7 +10,7 @@ LL | #[cfg]
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
error: malformed `cfg_attr` attribute input error: malformed `cfg_attr` attribute input
--> $DIR/malformed-attrs.rs:104:1 --> $DIR/malformed-attrs.rs:103:1
| |
LL | #[cfg_attr] LL | #[cfg_attr]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
@@ -22,7 +22,7 @@ LL | #[cfg_attr(condition, attribute, other_attribute, ...)]
| ++++++++++++++++++++++++++++++++++++++++++++ | ++++++++++++++++++++++++++++++++++++++++++++
error[E0463]: can't find crate for `wloop` error[E0463]: can't find crate for `wloop`
--> $DIR/malformed-attrs.rs:211:1 --> $DIR/malformed-attrs.rs:210:1
| |
LL | extern crate wloop; LL | extern crate wloop;
| ^^^^^^^^^^^^^^^^^^^ can't find crate | ^^^^^^^^^^^^^^^^^^^ can't find crate
@@ -42,7 +42,7 @@ LL | #![windows_subsystem = "windows"]
| +++++++++++ | +++++++++++
error: malformed `instruction_set` attribute input error: malformed `instruction_set` attribute input
--> $DIR/malformed-attrs.rs:106:1 --> $DIR/malformed-attrs.rs:105:1
| |
LL | #[instruction_set] LL | #[instruction_set]
| ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[instruction_set(set)]` | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[instruction_set(set)]`
@@ -50,13 +50,13 @@ LL | #[instruction_set]
= note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-instruction_set-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-instruction_set-attribute>
error: malformed `patchable_function_entry` attribute input error: malformed `patchable_function_entry` attribute input
--> $DIR/malformed-attrs.rs:108:1 --> $DIR/malformed-attrs.rs:107:1
| |
LL | #[patchable_function_entry] LL | #[patchable_function_entry]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]`
error: malformed `must_not_suspend` attribute input error: malformed `must_not_suspend` attribute input
--> $DIR/malformed-attrs.rs:132:1 --> $DIR/malformed-attrs.rs:131:1
| |
LL | #[must_not_suspend()] LL | #[must_not_suspend()]
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
@@ -71,13 +71,13 @@ LL + #[must_not_suspend]
| |
error: malformed `cfi_encoding` attribute input error: malformed `cfi_encoding` attribute input
--> $DIR/malformed-attrs.rs:134:1 --> $DIR/malformed-attrs.rs:133:1
| |
LL | #[cfi_encoding] LL | #[cfi_encoding]
| ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]` | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]`
error: malformed `allow` attribute input error: malformed `allow` attribute input
--> $DIR/malformed-attrs.rs:178:1 --> $DIR/malformed-attrs.rs:177:1
| |
LL | #[allow] LL | #[allow]
| ^^^^^^^^ | ^^^^^^^^
@@ -93,7 +93,7 @@ LL | #[allow(lint1, lint2, lint3, reason = "...")]
| +++++++++++++++++++++++++++++++++++++ | +++++++++++++++++++++++++++++++++++++
error: malformed `expect` attribute input error: malformed `expect` attribute input
--> $DIR/malformed-attrs.rs:180:1 --> $DIR/malformed-attrs.rs:179:1
| |
LL | #[expect] LL | #[expect]
| ^^^^^^^^^ | ^^^^^^^^^
@@ -109,7 +109,7 @@ LL | #[expect(lint1, lint2, lint3, reason = "...")]
| +++++++++++++++++++++++++++++++++++++ | +++++++++++++++++++++++++++++++++++++
error: malformed `warn` attribute input error: malformed `warn` attribute input
--> $DIR/malformed-attrs.rs:182:1 --> $DIR/malformed-attrs.rs:181:1
| |
LL | #[warn] LL | #[warn]
| ^^^^^^^ | ^^^^^^^
@@ -125,7 +125,7 @@ LL | #[warn(lint1, lint2, lint3, reason = "...")]
| +++++++++++++++++++++++++++++++++++++ | +++++++++++++++++++++++++++++++++++++
error: malformed `deny` attribute input error: malformed `deny` attribute input
--> $DIR/malformed-attrs.rs:184:1 --> $DIR/malformed-attrs.rs:183:1
| |
LL | #[deny] LL | #[deny]
| ^^^^^^^ | ^^^^^^^
@@ -141,7 +141,7 @@ LL | #[deny(lint1, lint2, lint3, reason = "...")]
| +++++++++++++++++++++++++++++++++++++ | +++++++++++++++++++++++++++++++++++++
error: malformed `forbid` attribute input error: malformed `forbid` attribute input
--> $DIR/malformed-attrs.rs:186:1 --> $DIR/malformed-attrs.rs:185:1
| |
LL | #[forbid] LL | #[forbid]
| ^^^^^^^^^ | ^^^^^^^^^
@@ -157,7 +157,7 @@ LL | #[forbid(lint1, lint2, lint3, reason = "...")]
| +++++++++++++++++++++++++++++++++++++ | +++++++++++++++++++++++++++++++++++++
error: malformed `debugger_visualizer` attribute input error: malformed `debugger_visualizer` attribute input
--> $DIR/malformed-attrs.rs:188:1 --> $DIR/malformed-attrs.rs:187:1
| |
LL | #[debugger_visualizer] LL | #[debugger_visualizer]
| ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[debugger_visualizer(natvis_file = "...", gdb_script_file = "...")]` | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[debugger_visualizer(natvis_file = "...", gdb_script_file = "...")]`
@@ -165,13 +165,13 @@ LL | #[debugger_visualizer]
= note: for more information, visit <https://doc.rust-lang.org/reference/attributes/debugger.html#the-debugger_visualizer-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/debugger.html#the-debugger_visualizer-attribute>
error: malformed `thread_local` attribute input error: malformed `thread_local` attribute input
--> $DIR/malformed-attrs.rs:203:1 --> $DIR/malformed-attrs.rs:202:1
| |
LL | #[thread_local()] LL | #[thread_local()]
| ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]` | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]`
error: malformed `no_link` attribute input error: malformed `no_link` attribute input
--> $DIR/malformed-attrs.rs:207:1 --> $DIR/malformed-attrs.rs:206:1
| |
LL | #[no_link()] LL | #[no_link()]
| ^^^^^^^^^^^^ help: must be of the form: `#[no_link]` | ^^^^^^^^^^^^ help: must be of the form: `#[no_link]`
@@ -179,7 +179,7 @@ LL | #[no_link()]
= note: for more information, visit <https://doc.rust-lang.org/reference/items/extern-crates.html#the-no_link-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/items/extern-crates.html#the-no_link-attribute>
error: malformed `macro_export` attribute input error: malformed `macro_export` attribute input
--> $DIR/malformed-attrs.rs:214:1 --> $DIR/malformed-attrs.rs:213:1
| |
LL | #[macro_export = 18] LL | #[macro_export = 18]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
@@ -195,25 +195,25 @@ LL + #[macro_export]
| |
error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type
--> $DIR/malformed-attrs.rs:99:1 --> $DIR/malformed-attrs.rs:98:1
| |
LL | #[proc_macro = 18] LL | #[proc_macro = 18]
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type error: the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type
--> $DIR/malformed-attrs.rs:116:1 --> $DIR/malformed-attrs.rs:115:1
| |
LL | #[proc_macro_attribute = 19] LL | #[proc_macro_attribute = 19]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
--> $DIR/malformed-attrs.rs:123:1 --> $DIR/malformed-attrs.rs:122:1
| |
LL | #[proc_macro_derive] LL | #[proc_macro_derive]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint
--> $DIR/malformed-attrs.rs:216:1 --> $DIR/malformed-attrs.rs:215:1
| |
LL | #[allow_internal_unsafe = 1] LL | #[allow_internal_unsafe = 1]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -242,18 +242,8 @@ LL | #[doc]
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html>
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`
--> $DIR/malformed-attrs.rs:83:1
|
LL | #[link]
| ^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
error: invalid argument error: invalid argument
--> $DIR/malformed-attrs.rs:188:1 --> $DIR/malformed-attrs.rs:187:1
| |
LL | #[debugger_visualizer] LL | #[debugger_visualizer]
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
@@ -494,8 +484,27 @@ LL | #[export_stable = 1]
| | didn't expect any arguments here | | didn't expect any arguments here
| help: must be of the form: `#[export_stable]` | help: must be of the form: `#[export_stable]`
error[E0539]: malformed `link` attribute input
--> $DIR/malformed-attrs.rs:83:1
|
LL | #[link]
| ^^^^^^^ expected this to be a list
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL | #[link(name = "...")]
| ++++++++++++++
LL | #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
LL | #[link(name = "...", kind = "dylib|static|...")]
| +++++++++++++++++++++++++++++++++++++++++
LL | #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
= and 1 other candidate
error[E0539]: malformed `link_name` attribute input error[E0539]: malformed `link_name` attribute input
--> $DIR/malformed-attrs.rs:86:1 --> $DIR/malformed-attrs.rs:85:1
| |
LL | #[link_name] LL | #[link_name]
| ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]` | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]`
@@ -503,7 +512,7 @@ LL | #[link_name]
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_name-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_name-attribute>
error[E0539]: malformed `link_section` attribute input error[E0539]: malformed `link_section` attribute input
--> $DIR/malformed-attrs.rs:88:1 --> $DIR/malformed-attrs.rs:87:1
| |
LL | #[link_section] LL | #[link_section]
| ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]` | ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]`
@@ -511,7 +520,7 @@ LL | #[link_section]
= note: for more information, visit <https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute>
error[E0539]: malformed `coverage` attribute input error[E0539]: malformed `coverage` attribute input
--> $DIR/malformed-attrs.rs:90:1 --> $DIR/malformed-attrs.rs:89:1
| |
LL | #[coverage] LL | #[coverage]
| ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -524,7 +533,7 @@ LL | #[coverage(on)]
| ++++ | ++++
error[E0539]: malformed `sanitize` attribute input error[E0539]: malformed `sanitize` attribute input
--> $DIR/malformed-attrs.rs:92:1 --> $DIR/malformed-attrs.rs:91:1
| |
LL | #[sanitize] LL | #[sanitize]
| ^^^^^^^^^^^ expected this to be a list | ^^^^^^^^^^^ expected this to be a list
@@ -542,7 +551,7 @@ LL | #[sanitize(kcfi = "on|off")]
= and 5 other candidates = and 5 other candidates
error[E0565]: malformed `no_implicit_prelude` attribute input error[E0565]: malformed `no_implicit_prelude` attribute input
--> $DIR/malformed-attrs.rs:97:1 --> $DIR/malformed-attrs.rs:96:1
| |
LL | #[no_implicit_prelude = 23] LL | #[no_implicit_prelude = 23]
| ^^^^^^^^^^^^^^^^^^^^^^----^ | ^^^^^^^^^^^^^^^^^^^^^^----^
@@ -551,7 +560,7 @@ LL | #[no_implicit_prelude = 23]
| help: must be of the form: `#[no_implicit_prelude]` | help: must be of the form: `#[no_implicit_prelude]`
error[E0565]: malformed `proc_macro` attribute input error[E0565]: malformed `proc_macro` attribute input
--> $DIR/malformed-attrs.rs:99:1 --> $DIR/malformed-attrs.rs:98:1
| |
LL | #[proc_macro = 18] LL | #[proc_macro = 18]
| ^^^^^^^^^^^^^----^ | ^^^^^^^^^^^^^----^
@@ -560,7 +569,7 @@ LL | #[proc_macro = 18]
| help: must be of the form: `#[proc_macro]` | help: must be of the form: `#[proc_macro]`
error[E0565]: malformed `coroutine` attribute input error[E0565]: malformed `coroutine` attribute input
--> $DIR/malformed-attrs.rs:111:5 --> $DIR/malformed-attrs.rs:110:5
| |
LL | #[coroutine = 63] || {} LL | #[coroutine = 63] || {}
| ^^^^^^^^^^^^----^ | ^^^^^^^^^^^^----^
@@ -569,7 +578,7 @@ LL | #[coroutine = 63] || {}
| help: must be of the form: `#[coroutine]` | help: must be of the form: `#[coroutine]`
error[E0565]: malformed `proc_macro_attribute` attribute input error[E0565]: malformed `proc_macro_attribute` attribute input
--> $DIR/malformed-attrs.rs:116:1 --> $DIR/malformed-attrs.rs:115:1
| |
LL | #[proc_macro_attribute = 19] LL | #[proc_macro_attribute = 19]
| ^^^^^^^^^^^^^^^^^^^^^^^----^ | ^^^^^^^^^^^^^^^^^^^^^^^----^
@@ -578,7 +587,7 @@ LL | #[proc_macro_attribute = 19]
| help: must be of the form: `#[proc_macro_attribute]` | help: must be of the form: `#[proc_macro_attribute]`
error[E0539]: malformed `must_use` attribute input error[E0539]: malformed `must_use` attribute input
--> $DIR/malformed-attrs.rs:119:1 --> $DIR/malformed-attrs.rs:118:1
| |
LL | #[must_use = 1] LL | #[must_use = 1]
| ^^^^^^^^^^^^^-^ | ^^^^^^^^^^^^^-^
@@ -596,7 +605,7 @@ LL + #[must_use]
| |
error[E0539]: malformed `proc_macro_derive` attribute input error[E0539]: malformed `proc_macro_derive` attribute input
--> $DIR/malformed-attrs.rs:123:1 --> $DIR/malformed-attrs.rs:122:1
| |
LL | #[proc_macro_derive] LL | #[proc_macro_derive]
| ^^^^^^^^^^^^^^^^^^^^ expected this to be a list | ^^^^^^^^^^^^^^^^^^^^ expected this to be a list
@@ -610,7 +619,7 @@ LL | #[proc_macro_derive(TraitName, attributes(name1, name2, ...))]
| ++++++++++++++++++++++++++++++++++++++++++ | ++++++++++++++++++++++++++++++++++++++++++
error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input
--> $DIR/malformed-attrs.rs:128:1 --> $DIR/malformed-attrs.rs:127:1
| |
LL | #[rustc_layout_scalar_valid_range_start] LL | #[rustc_layout_scalar_valid_range_start]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -619,7 +628,7 @@ LL | #[rustc_layout_scalar_valid_range_start]
| help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`
error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input
--> $DIR/malformed-attrs.rs:130:1 --> $DIR/malformed-attrs.rs:129:1
| |
LL | #[rustc_layout_scalar_valid_range_end] LL | #[rustc_layout_scalar_valid_range_end]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -628,7 +637,7 @@ LL | #[rustc_layout_scalar_valid_range_end]
| help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]`
error[E0565]: malformed `marker` attribute input error[E0565]: malformed `marker` attribute input
--> $DIR/malformed-attrs.rs:155:1 --> $DIR/malformed-attrs.rs:154:1
| |
LL | #[marker = 3] LL | #[marker = 3]
| ^^^^^^^^^---^ | ^^^^^^^^^---^
@@ -637,7 +646,7 @@ LL | #[marker = 3]
| help: must be of the form: `#[marker]` | help: must be of the form: `#[marker]`
error[E0565]: malformed `fundamental` attribute input error[E0565]: malformed `fundamental` attribute input
--> $DIR/malformed-attrs.rs:157:1 --> $DIR/malformed-attrs.rs:156:1
| |
LL | #[fundamental()] LL | #[fundamental()]
| ^^^^^^^^^^^^^--^ | ^^^^^^^^^^^^^--^
@@ -646,7 +655,7 @@ LL | #[fundamental()]
| help: must be of the form: `#[fundamental]` | help: must be of the form: `#[fundamental]`
error[E0565]: malformed `ffi_pure` attribute input error[E0565]: malformed `ffi_pure` attribute input
--> $DIR/malformed-attrs.rs:165:5 --> $DIR/malformed-attrs.rs:164:5
| |
LL | #[unsafe(ffi_pure = 1)] LL | #[unsafe(ffi_pure = 1)]
| ^^^^^^^^^^^^^^^^^^---^^ | ^^^^^^^^^^^^^^^^^^---^^
@@ -655,7 +664,7 @@ LL | #[unsafe(ffi_pure = 1)]
| help: must be of the form: `#[ffi_pure]` | help: must be of the form: `#[ffi_pure]`
error[E0539]: malformed `link_ordinal` attribute input error[E0539]: malformed `link_ordinal` attribute input
--> $DIR/malformed-attrs.rs:167:5 --> $DIR/malformed-attrs.rs:166:5
| |
LL | #[link_ordinal] LL | #[link_ordinal]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
@@ -666,7 +675,7 @@ LL | #[link_ordinal]
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute>
error[E0565]: malformed `ffi_const` attribute input error[E0565]: malformed `ffi_const` attribute input
--> $DIR/malformed-attrs.rs:171:5 --> $DIR/malformed-attrs.rs:170:5
| |
LL | #[unsafe(ffi_const = 1)] LL | #[unsafe(ffi_const = 1)]
| ^^^^^^^^^^^^^^^^^^^---^^ | ^^^^^^^^^^^^^^^^^^^---^^
@@ -675,7 +684,7 @@ LL | #[unsafe(ffi_const = 1)]
| help: must be of the form: `#[ffi_const]` | help: must be of the form: `#[ffi_const]`
error[E0539]: malformed `linkage` attribute input error[E0539]: malformed `linkage` attribute input
--> $DIR/malformed-attrs.rs:173:5 --> $DIR/malformed-attrs.rs:172:5
| |
LL | #[linkage] LL | #[linkage]
| ^^^^^^^^^^ expected this to be of the form `linkage = "..."` | ^^^^^^^^^^ expected this to be of the form `linkage = "..."`
@@ -693,7 +702,7 @@ LL | #[linkage = "external"]
= and 5 other candidates = and 5 other candidates
error[E0565]: malformed `automatically_derived` attribute input error[E0565]: malformed `automatically_derived` attribute input
--> $DIR/malformed-attrs.rs:191:1 --> $DIR/malformed-attrs.rs:190:1
| |
LL | #[automatically_derived = 18] LL | #[automatically_derived = 18]
| ^^^^^^^^^^^^^^^^^^^^^^^^----^ | ^^^^^^^^^^^^^^^^^^^^^^^^----^
@@ -702,7 +711,7 @@ LL | #[automatically_derived = 18]
| help: must be of the form: `#[automatically_derived]` | help: must be of the form: `#[automatically_derived]`
error[E0565]: malformed `non_exhaustive` attribute input error[E0565]: malformed `non_exhaustive` attribute input
--> $DIR/malformed-attrs.rs:197:1 --> $DIR/malformed-attrs.rs:196:1
| |
LL | #[non_exhaustive = 1] LL | #[non_exhaustive = 1]
| ^^^^^^^^^^^^^^^^^---^ | ^^^^^^^^^^^^^^^^^---^
@@ -711,13 +720,13 @@ LL | #[non_exhaustive = 1]
| help: must be of the form: `#[non_exhaustive]` | help: must be of the form: `#[non_exhaustive]`
error: valid forms for the attribute are `#[macro_use(name1, name2, ...)]` and `#[macro_use]` error: valid forms for the attribute are `#[macro_use(name1, name2, ...)]` and `#[macro_use]`
--> $DIR/malformed-attrs.rs:209:1 --> $DIR/malformed-attrs.rs:208:1
| |
LL | #[macro_use = 1] LL | #[macro_use = 1]
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error[E0565]: malformed `allow_internal_unsafe` attribute input error[E0565]: malformed `allow_internal_unsafe` attribute input
--> $DIR/malformed-attrs.rs:216:1 --> $DIR/malformed-attrs.rs:215:1
| |
LL | #[allow_internal_unsafe = 1] LL | #[allow_internal_unsafe = 1]
| ^^^^^^^^^^^^^^^^^^^^^^^^---^ | ^^^^^^^^^^^^^^^^^^^^^^^^---^
@@ -726,7 +735,7 @@ LL | #[allow_internal_unsafe = 1]
| help: must be of the form: `#[allow_internal_unsafe]` | help: must be of the form: `#[allow_internal_unsafe]`
error[E0565]: malformed `type_const` attribute input error[E0565]: malformed `type_const` attribute input
--> $DIR/malformed-attrs.rs:143:5 --> $DIR/malformed-attrs.rs:142:5
| |
LL | #[type_const = 1] LL | #[type_const = 1]
| ^^^^^^^^^^^^^---^ | ^^^^^^^^^^^^^---^
@@ -759,7 +768,7 @@ LL | #[repr]
| ^^^^^^^ | ^^^^^^^
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
--> $DIR/malformed-attrs.rs:149:1 --> $DIR/malformed-attrs.rs:148:1
| |
LL | #[diagnostic::do_not_recommend()] LL | #[diagnostic::do_not_recommend()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -767,7 +776,7 @@ LL | #[diagnostic::do_not_recommend()]
= note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default
warning: missing options for `on_unimplemented` attribute warning: missing options for `on_unimplemented` attribute
--> $DIR/malformed-attrs.rs:138:1 --> $DIR/malformed-attrs.rs:137:1
| |
LL | #[diagnostic::on_unimplemented] LL | #[diagnostic::on_unimplemented]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -775,7 +784,7 @@ LL | #[diagnostic::on_unimplemented]
= help: at least one of the `message`, `note` and `label` options are expected = help: at least one of the `message`, `note` and `label` options are expected
warning: malformed `on_unimplemented` attribute warning: malformed `on_unimplemented` attribute
--> $DIR/malformed-attrs.rs:140:1 --> $DIR/malformed-attrs.rs:139:1
| |
LL | #[diagnostic::on_unimplemented = 1] LL | #[diagnostic::on_unimplemented = 1]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
@@ -792,7 +801,7 @@ LL | #[inline = 5]
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
--> $DIR/malformed-attrs.rs:94:1 --> $DIR/malformed-attrs.rs:93:1
| |
LL | #[ignore()] LL | #[ignore()]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
@@ -801,7 +810,7 @@ LL | #[ignore()]
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
--> $DIR/malformed-attrs.rs:223:1 --> $DIR/malformed-attrs.rs:222:1
| |
LL | #[ignore = 1] LL | #[ignore = 1]
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
@@ -810,7 +819,7 @@ LL | #[ignore = 1]
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/malformed-attrs.rs:111:23 --> $DIR/malformed-attrs.rs:110:23
| |
LL | fn test() { LL | fn test() {
| - help: a return type might be missing here: `-> _` | - help: a return type might be missing here: `-> _`
@@ -818,7 +827,7 @@ LL | #[coroutine = 63] || {}
| ^^^^^ expected `()`, found coroutine | ^^^^^ expected `()`, found coroutine
| |
= note: expected unit type `()` = note: expected unit type `()`
found coroutine `{coroutine@$DIR/malformed-attrs.rs:111:23: 111:25}` found coroutine `{coroutine@$DIR/malformed-attrs.rs:110:23: 110:25}`
error: aborting due to 77 previous errors; 3 warnings emitted error: aborting due to 77 previous errors; 3 warnings emitted
@@ -848,18 +857,6 @@ LL | #[doc]
= note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html>
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
Future breakage diagnostic:
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`
--> $DIR/malformed-attrs.rs:83:1
|
LL | #[link]
| ^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
Future breakage diagnostic: Future breakage diagnostic:
error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]`
--> $DIR/malformed-attrs.rs:52:1 --> $DIR/malformed-attrs.rs:52:1
@@ -873,7 +870,7 @@ LL | #[inline = 5]
Future breakage diagnostic: Future breakage diagnostic:
error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
--> $DIR/malformed-attrs.rs:94:1 --> $DIR/malformed-attrs.rs:93:1
| |
LL | #[ignore()] LL | #[ignore()]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
@@ -884,7 +881,7 @@ LL | #[ignore()]
Future breakage diagnostic: Future breakage diagnostic:
error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
--> $DIR/malformed-attrs.rs:223:1 --> $DIR/malformed-attrs.rs:222:1
| |
LL | #[ignore = 1] LL | #[ignore = 1]
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^

View File

@@ -1,4 +1,4 @@
#[link(kind = "wonderful_unicorn")] extern "C" {} //~ ERROR E0458 #[link(kind = "wonderful_unicorn")] extern "C" {} //~ ERROR malformed `link` attribute input [E0539]
//~| ERROR E0459 //~| ERROR E0459
fn main() { fn main() {

View File

@@ -1,8 +1,27 @@
error[E0458]: unknown link kind `wonderful_unicorn`, expected one of: static, dylib, framework, raw-dylib, link-arg error[E0539]: malformed `link` attribute input
--> $DIR/E0458.rs:1:15 --> $DIR/E0458.rs:1:1
| |
LL | #[link(kind = "wonderful_unicorn")] extern "C" {} LL | #[link(kind = "wonderful_unicorn")] extern "C" {}
| ^^^^^^^^^^^^^^^^^^^ unknown link kind | ^^^^^^^^^^^^^^-------------------^^
| |
| valid arguments are "static", "dylib", "framework", "raw-dylib" or "link-arg"
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(kind = "wonderful_unicorn")] extern "C" {}
LL + #[link(name = "...")] extern "C" {}
|
LL - #[link(kind = "wonderful_unicorn")] extern "C" {}
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] extern "C" {}
|
LL - #[link(kind = "wonderful_unicorn")] extern "C" {}
LL + #[link(name = "...", kind = "dylib|static|...")] extern "C" {}
|
LL - #[link(kind = "wonderful_unicorn")] extern "C" {}
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] extern "C" {}
|
= and 1 other candidate
error[E0459]: `#[link]` attribute requires a `name = "string"` argument error[E0459]: `#[link]` attribute requires a `name = "string"` argument
--> $DIR/E0458.rs:1:1 --> $DIR/E0458.rs:1:1
@@ -12,5 +31,5 @@ LL | #[link(kind = "wonderful_unicorn")] extern "C" {}
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
Some errors have detailed explanations: E0458, E0459. Some errors have detailed explanations: E0459, E0539.
For more information about an error, try `rustc --explain E0458`. For more information about an error, try `rustc --explain E0459`.

View File

@@ -69,7 +69,7 @@
//~| WARN previously accepted //~| WARN previously accepted
//~| HELP can only be applied to //~| HELP can only be applied to
//~| HELP remove the attribute //~| HELP remove the attribute
#![link()] //~ WARN attribute should be applied to an `extern` block #![link(name = "x")] //~ WARN attribute should be applied to an `extern` block
//~^ WARN this was previously accepted //~^ WARN this was previously accepted
#![link_name = "1900"] #![link_name = "1900"]
//~^ WARN attribute cannot be used on //~^ WARN attribute cannot be used on
@@ -692,38 +692,38 @@ mod link_section {
// Note that this is a `check-pass` test, so it will never invoke the linker. // Note that this is a `check-pass` test, so it will never invoke the linker.
#[link()] #[link(name = "x")]
//~^ WARN attribute should be applied to an `extern` block //~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted //~| WARN this was previously accepted
mod link { mod link {
//~^ NOTE not an `extern` block //~^ NOTE not an `extern` block
mod inner { #![link()] } mod inner { #![link(name = "x")] }
//~^ WARN attribute should be applied to an `extern` block //~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted //~| WARN this was previously accepted
//~| NOTE not an `extern` block //~| NOTE not an `extern` block
#[link()] fn f() { } #[link(name = "x")] fn f() { }
//~^ WARN attribute should be applied to an `extern` block //~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted //~| WARN this was previously accepted
//~| NOTE not an `extern` block //~| NOTE not an `extern` block
#[link()] struct S; #[link(name = "x")] struct S;
//~^ WARN attribute should be applied to an `extern` block //~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted //~| WARN this was previously accepted
//~| NOTE not an `extern` block //~| NOTE not an `extern` block
#[link()] type T = S; #[link(name = "x")] type T = S;
//~^ WARN attribute should be applied to an `extern` block //~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted //~| WARN this was previously accepted
//~| NOTE not an `extern` block //~| NOTE not an `extern` block
#[link()] impl S { } #[link(name = "x")] impl S { }
//~^ WARN attribute should be applied to an `extern` block //~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted //~| WARN this was previously accepted
//~| NOTE not an `extern` block //~| NOTE not an `extern` block
#[link()] extern "Rust" {} #[link(name = "x")] extern "Rust" {}
//~^ WARN attribute should be applied to an `extern` block //~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted //~| WARN this was previously accepted
} }

View File

@@ -223,13 +223,13 @@ LL | #![no_std]
warning: attribute should be applied to an `extern` block with non-Rust ABI warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:695:1 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:695:1
| |
LL | #[link()] LL | #[link(name = "x")]
| ^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
... ...
LL | / mod link { LL | / mod link {
LL | | LL | |
LL | | LL | |
LL | | mod inner { #![link()] } LL | | mod inner { #![link(name = "x")] }
... | ... |
LL | | } LL | | }
| |_- not an `extern` block | |_- not an `extern` block
@@ -316,8 +316,8 @@ LL | #![type_length_limit="0100"]
warning: attribute should be applied to an `extern` block with non-Rust ABI warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1
| |
LL | #![link()] LL | #![link(name = "x")]
| ^^^^^^^^^^ not an `extern` block | ^^^^^^^^^^^^^^^^^^^^ not an `extern` block
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
@@ -462,48 +462,48 @@ LL | #![no_std] impl S { }
warning: attribute should be applied to an `extern` block with non-Rust ABI warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:701:17 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:701:17
| |
LL | mod inner { #![link()] } LL | mod inner { #![link(name = "x")] }
| ------------^^^^^^^^^^-- not an `extern` block | ------------^^^^^^^^^^^^^^^^^^^^-- not an `extern` block
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to an `extern` block with non-Rust ABI warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:706:5 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:706:5
| |
LL | #[link()] fn f() { } LL | #[link(name = "x")] fn f() { }
| ^^^^^^^^^ ---------- not an `extern` block | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to an `extern` block with non-Rust ABI warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:711:5 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:711:5
| |
LL | #[link()] struct S; LL | #[link(name = "x")] struct S;
| ^^^^^^^^^ --------- not an `extern` block | ^^^^^^^^^^^^^^^^^^^ --------- not an `extern` block
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to an `extern` block with non-Rust ABI warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:5 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:5
| |
LL | #[link()] type T = S; LL | #[link(name = "x")] type T = S;
| ^^^^^^^^^ ----------- not an `extern` block | ^^^^^^^^^^^^^^^^^^^ ----------- not an `extern` block
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to an `extern` block with non-Rust ABI warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5
| |
LL | #[link()] impl S { } LL | #[link(name = "x")] impl S { }
| ^^^^^^^^^ ---------- not an `extern` block | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to an `extern` block with non-Rust ABI warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:726:5 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:726:5
| |
LL | #[link()] extern "Rust" {} LL | #[link(name = "x")] extern "Rust" {}
| ^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

View File

@@ -1,4 +1,6 @@
#[link(name = "foo", cfg("rlib"))] //~ ERROR link cfg must have a single predicate argument #[link(name = "foo", cfg("rlib"))]
//~^ ERROR link cfg is unstable
//~| ERROR `cfg` predicate key must be an identifier
extern "C" {} extern "C" {}
fn main() {} fn main() {}

View File

@@ -1,8 +1,18 @@
error: link cfg must have a single predicate argument error[E0658]: link cfg is unstable
--> $DIR/issue-43925.rs:1:22 --> $DIR/issue-43925.rs:1:22
| |
LL | #[link(name = "foo", cfg("rlib"))] LL | #[link(name = "foo", cfg("rlib"))]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
|
= help: add `#![feature(link_cfg)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 1 previous error error: `cfg` predicate key must be an identifier
--> $DIR/issue-43925.rs:1:26
|
LL | #[link(name = "foo", cfg("rlib"))]
| ^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@@ -1,4 +1,4 @@
#[link(name = "foo", cfg())] //~ ERROR link cfg must have a single predicate argument #[link(name = "foo", cfg())] //~ ERROR malformed `link` attribute input
extern "C" {} extern "C" {}
fn main() {} fn main() {}

View File

@@ -1,8 +1,28 @@
error: link cfg must have a single predicate argument error[E0805]: malformed `link` attribute input
--> $DIR/issue-43926.rs:1:22 --> $DIR/issue-43926.rs:1:1
| |
LL | #[link(name = "foo", cfg())] LL | #[link(name = "foo", cfg())]
| ^^^^^ | ^^^^^^^^^^^^^^^^^^^^^-----^^
| |
| expected a single argument here
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "foo", cfg())]
LL + #[link(name = "...")]
|
LL - #[link(name = "foo", cfg())]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "foo", cfg())]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "foo", cfg())]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: aborting due to 1 previous error error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0805`.

View File

@@ -1,8 +1,6 @@
// Top-level ill-formed // Top-level ill-formed
#[link] //~ ERROR valid forms for the attribute are #[link] //~ ERROR malformed
//~| WARN this was previously accepted #[link = "foo"] //~ ERROR malformed
#[link = "foo"] //~ ERROR valid forms for the attribute are
//~| WARN this was previously accepted
extern "C" {} extern "C" {}
fn main() {} fn main() {}

View File

@@ -1,47 +1,45 @@
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-early.rs:2:1 --> $DIR/link-attr-validation-early.rs:2:1
| |
LL | #[link] LL | #[link]
| ^^^^^^^ | ^^^^^^^ expected this to be a list
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default help: try changing it to one of the following valid forms of the attribute
|
LL | #[link(name = "...")]
| ++++++++++++++
LL | #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
LL | #[link(name = "...", kind = "dylib|static|...")]
| +++++++++++++++++++++++++++++++++++++++++
LL | #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
= and 1 other candidate
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-early.rs:4:1 --> $DIR/link-attr-validation-early.rs:3:1
| |
LL | #[link = "foo"] LL | #[link = "foo"]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^ expected this to be a list
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link = "foo"]
LL + #[link(name = "...")]
|
LL - #[link = "foo"]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link = "foo"]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link = "foo"]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
Future incompatibility report: Future breakage diagnostic: For more information about this error, try `rustc --explain E0539`.
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`
--> $DIR/link-attr-validation-early.rs:2:1
|
LL | #[link]
| ^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
Future breakage diagnostic:
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`
--> $DIR/link-attr-validation-early.rs:4:1
|
LL | #[link = "foo"]
| ^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default

View File

@@ -1,38 +1,36 @@
#![feature(link_cfg)] #![feature(link_cfg)]
// Top-level ill-formed // Top-level ill-formed
#[link(name = "...", "literal")] //~ ERROR unexpected `#[link]` argument #[link(name = "...", "literal")] //~ ERROR malformed `link` attribute input
#[link(name = "...", unknown)] //~ ERROR unexpected `#[link]` argument #[link(name = "...", unknown)] //~ ERROR malformed `link` attribute input
extern "C" {} extern "C" {}
// Duplicate arguments // Duplicate arguments
#[link(name = "foo", name = "bar")] //~ ERROR multiple `name` arguments #[link(name = "foo", name = "bar")] //~ ERROR malformed `link` attribute input
#[link(name = "...", kind = "dylib", kind = "bar")] //~ ERROR multiple `kind` arguments #[link(name = "...", kind = "dylib", kind = "bar")] //~ ERROR malformed `link` attribute input
#[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] //~ ERROR multiple `modifiers` arguments #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] //~ ERROR malformed `link` attribute input
#[link(name = "...", cfg(false), cfg(false))] //~ ERROR multiple `cfg` arguments #[link(name = "...", cfg(false), cfg(false))] //~ ERROR malformed `link` attribute input
#[link(wasm_import_module = "foo", wasm_import_module = "bar")] //~ ERROR multiple `wasm_import_module` arguments #[link(wasm_import_module = "foo", wasm_import_module = "bar")] //~ ERROR malformed `link` attribute input
extern "C" {} extern "C" {}
// Ill-formed arguments // Ill-formed arguments
#[link(name)] //~ ERROR link name must be of the form `name = "string"` #[link(name)] //~ ERROR malformed `link` attribute input
//~| ERROR `#[link]` attribute requires a `name = "string"` argument #[link(name())] //~ ERROR malformed `link` attribute input
#[link(name())] //~ ERROR link name must be of the form `name = "string"` #[link(name = "...", kind)] //~ ERROR malformed `link` attribute input
//~| ERROR `#[link]` attribute requires a `name = "string"` argument #[link(name = "...", kind())] //~ ERROR malformed `link` attribute input
#[link(name = "...", kind)] //~ ERROR link kind must be of the form `kind = "string"` #[link(name = "...", modifiers)] //~ ERROR malformed `link` attribute input
#[link(name = "...", kind())] //~ ERROR link kind must be of the form `kind = "string"` #[link(name = "...", modifiers())] //~ ERROR malformed `link` attribute input
#[link(name = "...", modifiers)] //~ ERROR link modifiers must be of the form `modifiers = "string"` #[link(name = "...", cfg)] //~ ERROR malformed `link` attribute input
#[link(name = "...", modifiers())] //~ ERROR link modifiers must be of the form `modifiers = "string"` #[link(name = "...", cfg = "literal")] //~ ERROR malformed `link` attribute input
#[link(name = "...", cfg)] //~ ERROR link cfg must be of the form `cfg(/* predicate */)` #[link(name = "...", cfg("literal"))] //~ ERROR `cfg` predicate key must be an identifier
#[link(name = "...", cfg = "literal")] //~ ERROR link cfg must be of the form `cfg(/* predicate */)` #[link(name = "...", wasm_import_module)] //~ ERROR malformed `link` attribute input
#[link(name = "...", cfg("literal"))] //~ ERROR link cfg must have a single predicate argument #[link(name = "...", wasm_import_module())] //~ ERROR malformed `link` attribute input
#[link(name = "...", wasm_import_module)] //~ ERROR wasm import module must be of the form `wasm_import_module = "string"`
#[link(name = "...", wasm_import_module())] //~ ERROR wasm import module must be of the form `wasm_import_module = "string"`
extern "C" {} extern "C" {}
// Basic modifier validation // Basic modifier validation
#[link(name = "...", modifiers = "")] //~ ERROR invalid linking modifier syntax, expected '+' or '-' prefix #[link(name = "...", modifiers = "")] //~ ERROR invalid linking modifier syntax, expected '+' or '-' prefix
#[link(name = "...", modifiers = "no-plus-minus")] //~ ERROR invalid linking modifier syntax, expected '+' or '-' prefix #[link(name = "...", modifiers = "no-plus-minus")] //~ ERROR invalid linking modifier syntax, expected '+' or '-' prefix
#[link(name = "...", modifiers = "+unknown")] //~ ERROR unknown linking modifier `unknown` #[link(name = "...", modifiers = "+unknown")] //~ ERROR malformed `link` attribute input
#[link(name = "...", modifiers = "+verbatim,+verbatim")] //~ ERROR multiple `verbatim` modifiers #[link(name = "...", modifiers = "+verbatim,+verbatim")] //~ ERROR multiple `verbatim` modifiers
extern "C" {} extern "C" {}

View File

@@ -1,147 +1,472 @@
error: unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module, import_name_type error[E0565]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:4:22 --> $DIR/link-attr-validation-late.rs:4:1
| |
LL | #[link(name = "...", "literal")] LL | #[link(name = "...", "literal")]
| ^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^---------^^
| |
| didn't expect a literal here
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", "literal")]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", "literal")]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", "literal")]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", "literal")]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module, import_name_type error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:5:22 --> $DIR/link-attr-validation-late.rs:5:1
| |
LL | #[link(name = "...", unknown)] LL | #[link(name = "...", unknown)]
| ^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^-------^^
| |
| valid arguments are "name", "kind", "modifiers", "cfg", "wasm_import_module" or "import_name_type"
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", unknown)]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", unknown)]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", unknown)]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", unknown)]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: multiple `name` arguments in a single `#[link]` attribute error[E0538]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:9:22 --> $DIR/link-attr-validation-late.rs:9:1
| |
LL | #[link(name = "foo", name = "bar")] LL | #[link(name = "foo", name = "bar")]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^------------^^
| |
| found `name` used as a key more than once
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "foo", name = "bar")]
LL + #[link(name = "...")]
|
LL - #[link(name = "foo", name = "bar")]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "foo", name = "bar")]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "foo", name = "bar")]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: multiple `kind` arguments in a single `#[link]` attribute error[E0538]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:10:38 --> $DIR/link-attr-validation-late.rs:10:1
| |
LL | #[link(name = "...", kind = "dylib", kind = "bar")] LL | #[link(name = "...", kind = "dylib", kind = "bar")]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------^^
| |
| found `kind` used as a key more than once
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", kind = "dylib", kind = "bar")]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", kind = "dylib", kind = "bar")]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", kind = "dylib", kind = "bar")]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", kind = "dylib", kind = "bar")]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: multiple `modifiers` arguments in a single `#[link]` attribute error[E0538]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:11:47 --> $DIR/link-attr-validation-late.rs:11:1
| |
LL | #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] LL | #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")]
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^
| |
| found `modifiers` used as a key more than once
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: multiple `cfg` arguments in a single `#[link]` attribute error[E0538]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:12:34 --> $DIR/link-attr-validation-late.rs:12:1
| |
LL | #[link(name = "...", cfg(false), cfg(false))] LL | #[link(name = "...", cfg(false), cfg(false))]
| ^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------^^
| |
| found `cfg` used as a key more than once
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", cfg(false), cfg(false))]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", cfg(false), cfg(false))]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", cfg(false), cfg(false))]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", cfg(false), cfg(false))]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: multiple `wasm_import_module` arguments in a single `#[link]` attribute error[E0538]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:13:36 --> $DIR/link-attr-validation-late.rs:13:1
| |
LL | #[link(wasm_import_module = "foo", wasm_import_module = "bar")] LL | #[link(wasm_import_module = "foo", wasm_import_module = "bar")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------^^
| |
error: link name must be of the form `name = "string"` | found `wasm_import_module` used as a key more than once
--> $DIR/link-attr-validation-late.rs:17:8
| |
LL | #[link(name)] = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
| ^^^^ help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(wasm_import_module = "foo", wasm_import_module = "bar")]
LL + #[link(name = "...")]
|
LL - #[link(wasm_import_module = "foo", wasm_import_module = "bar")]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(wasm_import_module = "foo", wasm_import_module = "bar")]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(wasm_import_module = "foo", wasm_import_module = "bar")]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error[E0459]: `#[link]` attribute requires a `name = "string"` argument error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:17:1 --> $DIR/link-attr-validation-late.rs:17:1
| |
LL | #[link(name)] LL | #[link(name)]
| ^^^^^^^^^^^^^ missing `name` argument | ^^^^^^^----^^
| |
| expected this to be of the form `name = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL | #[link(name = "...")]
| +++++++
LL | #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
LL | #[link(name = "...", kind = "dylib|static|...")]
| ++++++++++++++++++++++++++++++++++
LL | #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
= and 1 other candidate
error: link name must be of the form `name = "string"` error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:19:8 --> $DIR/link-attr-validation-late.rs:18:1
| |
LL | #[link(name())] LL | #[link(name())]
| ^^^^^^ | ^^^^^^^------^^
| |
| expected this to be of the form `name = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name())]
LL + #[link(name = "...")]
|
LL - #[link(name())]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name())]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name())]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error[E0459]: `#[link]` attribute requires a `name = "string"` argument error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:19:1 --> $DIR/link-attr-validation-late.rs:19:1
| |
LL | #[link(name())]
| ^^^^^^^^^^^^^^^ missing `name` argument
error: link kind must be of the form `kind = "string"`
--> $DIR/link-attr-validation-late.rs:21:22
|
LL | #[link(name = "...", kind)] LL | #[link(name = "...", kind)]
| ^^^^ | ^^^^^^^^^^^^^^^^^^^^^----^^
| |
| expected this to be of the form `kind = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", kind)]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", kind)]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL | #[link(name = "...", kind = "dylib|static|...")]
| ++++++++++++++++++++
LL | #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
= and 1 other candidate
error: link kind must be of the form `kind = "string"` error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:22:22 --> $DIR/link-attr-validation-late.rs:20:1
| |
LL | #[link(name = "...", kind())] LL | #[link(name = "...", kind())]
| ^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^------^^
| |
| expected this to be of the form `kind = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", kind())]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", kind())]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", kind())]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", kind())]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: link modifiers must be of the form `modifiers = "string"` error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:23:22 --> $DIR/link-attr-validation-late.rs:21:1
| |
LL | #[link(name = "...", modifiers)] LL | #[link(name = "...", modifiers)]
| ^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^---------^^
| |
| expected this to be of the form `modifiers = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", modifiers)]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", modifiers)]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", modifiers)]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", modifiers)]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: link modifiers must be of the form `modifiers = "string"` error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:24:22 --> $DIR/link-attr-validation-late.rs:22:1
| |
LL | #[link(name = "...", modifiers())] LL | #[link(name = "...", modifiers())]
| ^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^-----------^^
| |
| expected this to be of the form `modifiers = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", modifiers())]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", modifiers())]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", modifiers())]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", modifiers())]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: link cfg must be of the form `cfg(/* predicate */)` error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:25:22 --> $DIR/link-attr-validation-late.rs:23:1
| |
LL | #[link(name = "...", cfg)] LL | #[link(name = "...", cfg)]
| ^^^ | ^^^^^^^^^^^^^^^^^^^^^---^^
| |
| expected this to be a list
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", cfg)]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", cfg)]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", cfg)]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", cfg)]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: link cfg must be of the form `cfg(/* predicate */)` error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:26:22 --> $DIR/link-attr-validation-late.rs:24:1
| |
LL | #[link(name = "...", cfg = "literal")] LL | #[link(name = "...", cfg = "literal")]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^---------------^^
| |
| expected this to be a list
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", cfg = "literal")]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", cfg = "literal")]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", cfg = "literal")]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", cfg = "literal")]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: link cfg must have a single predicate argument error: `cfg` predicate key must be an identifier
--> $DIR/link-attr-validation-late.rs:27:22 --> $DIR/link-attr-validation-late.rs:25:26
| |
LL | #[link(name = "...", cfg("literal"))] LL | #[link(name = "...", cfg("literal"))]
| ^^^^^^^^^^^^^^ | ^^^^^^^^^
error: wasm import module must be of the form `wasm_import_module = "string"` error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:28:22 --> $DIR/link-attr-validation-late.rs:26:1
| |
LL | #[link(name = "...", wasm_import_module)] LL | #[link(name = "...", wasm_import_module)]
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^------------------^^
| |
| expected this to be of the form `wasm_import_module = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", wasm_import_module)]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", wasm_import_module)]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", wasm_import_module)]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", wasm_import_module)]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: wasm import module must be of the form `wasm_import_module = "string"` error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:29:22 --> $DIR/link-attr-validation-late.rs:27:1
| |
LL | #[link(name = "...", wasm_import_module())] LL | #[link(name = "...", wasm_import_module())]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^--------------------^^
| |
| expected this to be of the form `wasm_import_module = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", wasm_import_module())]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", wasm_import_module())]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", wasm_import_module())]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", wasm_import_module())]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed
--> $DIR/link-attr-validation-late.rs:33:34 --> $DIR/link-attr-validation-late.rs:31:34
| |
LL | #[link(name = "...", modifiers = "")] LL | #[link(name = "...", modifiers = "")]
| ^^ | ^^
error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed
--> $DIR/link-attr-validation-late.rs:34:34 --> $DIR/link-attr-validation-late.rs:32:34
| |
LL | #[link(name = "...", modifiers = "no-plus-minus")] LL | #[link(name = "...", modifiers = "no-plus-minus")]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: unknown linking modifier `unknown`, expected one of: bundle, verbatim, whole-archive, as-needed error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:35:34 --> $DIR/link-attr-validation-late.rs:33:1
| |
LL | #[link(name = "...", modifiers = "+unknown")] LL | #[link(name = "...", modifiers = "+unknown")]
| ^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------^^
| |
| valid arguments are "bundle", "verbatim", "whole-archive" or "as-needed"
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", modifiers = "+unknown")]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", modifiers = "+unknown")]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", modifiers = "+unknown")]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", modifiers = "+unknown")]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: multiple `verbatim` modifiers in a single `modifiers` argument error: multiple `verbatim` modifiers in a single `modifiers` argument
--> $DIR/link-attr-validation-late.rs:36:34 --> $DIR/link-attr-validation-late.rs:34:34
| |
LL | #[link(name = "...", modifiers = "+verbatim,+verbatim")] LL | #[link(name = "...", modifiers = "+verbatim,+verbatim")]
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 24 previous errors error: aborting due to 22 previous errors
For more information about this error, try `rustc --explain E0459`. Some errors have detailed explanations: E0538, E0539, E0565.
For more information about an error, try `rustc --explain E0538`.

View File

@@ -0,0 +1,12 @@
#[link(name = "foo")]
#[link(
//~^ ERROR malformed `link` attribute input
name = "bar",
kind = "static",
modifiers = "+whole-archive,-whole-archive",
//~^ ERROR multiple `whole-archive` modifiers in a single `modifiers` argument
modifiers = "+bundle"
)]
extern "C" {}
fn main() {}

View File

@@ -0,0 +1,67 @@
error[E0538]: malformed `link` attribute input
--> $DIR/modifiers-override-4.rs:2:1
|
LL | / #[link(
LL | |
LL | | name = "bar",
LL | | kind = "static",
... |
LL | | modifiers = "+bundle"
| | --------------------- found `modifiers` used as a key more than once
LL | | )]
| |__^
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(
LL -
LL - name = "bar",
LL - kind = "static",
LL - modifiers = "+whole-archive,-whole-archive",
LL -
LL - modifiers = "+bundle"
LL - )]
LL + #[link(name = "...")]
|
LL - #[link(
LL -
LL - name = "bar",
LL - kind = "static",
LL - modifiers = "+whole-archive,-whole-archive",
LL -
LL - modifiers = "+bundle"
LL - )]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(
LL -
LL - name = "bar",
LL - kind = "static",
LL - modifiers = "+whole-archive,-whole-archive",
LL -
LL - modifiers = "+bundle"
LL - )]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(
LL -
LL - name = "bar",
LL - kind = "static",
LL - modifiers = "+whole-archive,-whole-archive",
LL -
LL - modifiers = "+bundle"
LL - )]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: multiple `whole-archive` modifiers in a single `modifiers` argument
--> $DIR/modifiers-override-4.rs:6:17
|
LL | modifiers = "+whole-archive,-whole-archive",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0538`.

View File

@@ -4,13 +4,8 @@
#[link( #[link(
name = "bar", name = "bar",
kind = "static", kind = "static",
modifiers = "+whole-archive,-whole-archive",
//~^ ERROR multiple `whole-archive` modifiers in a single `modifiers` argument
modifiers = "+bundle"
//~^ ERROR multiple `modifiers` arguments in a single `#[link]` attribute
)] )]
extern "C" {} extern "C" {}
//~^ ERROR overriding linking modifiers from command line is not supported //~^ ERROR overriding linking modifiers from command line is not supported
//~| ERROR overriding linking modifiers from command line is not supported
fn main() {} fn main() {}

View File

@@ -1,28 +1,8 @@
error: multiple `modifiers` arguments in a single `#[link]` attribute
--> $DIR/modifiers-override.rs:9:5
|
LL | modifiers = "+bundle"
| ^^^^^^^^^^^^^^^^^^^^^
error: multiple `whole-archive` modifiers in a single `modifiers` argument
--> $DIR/modifiers-override.rs:7:17
|
LL | modifiers = "+whole-archive,-whole-archive",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: overriding linking modifiers from command line is not supported error: overriding linking modifiers from command line is not supported
--> $DIR/modifiers-override.rs:12:1 --> $DIR/modifiers-override.rs:8:1
| |
LL | extern "C" {} LL | extern "C" {}
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: overriding linking modifiers from command line is not supported error: aborting due to 1 previous error
--> $DIR/modifiers-override.rs:12:1
|
LL | extern "C" {}
| ^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 4 previous errors

View File

@@ -1,7 +1,10 @@
//@ only-windows //@ add-core-stubs
//@ only-x86 //@ compile-flags: --target i686-pc-windows-msvc
#[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] //@ needs-llvm-components: x86
//~^ ERROR import name type must be of the form `import_name_type = "string"` #![feature(no_core, rustc_attrs, lang_items)]
extern "C" { } #![no_core]
#![crate_type = "lib"]
fn main() {} #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
//~^ ERROR malformed
extern "C" { }

View File

@@ -1,8 +1,28 @@
error: import name type must be of the form `import_name_type = "string"` error[E0539]: malformed `link` attribute input
--> $DIR/import-name-type-invalid-format.rs:3:42 --> $DIR/import-name-type-invalid-format.rs:8:1
| |
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------^^
| |
| expected this to be of the form `import_name_type = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
LL + #[link(name = "...")]
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: aborting due to 1 previous error error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0539`.

View File

@@ -1,8 +1,11 @@
// ignore-tidy-linelength // ignore-tidy-linelength
//@ only-windows //@ add-core-stubs
//@ only-x86 //@ compile-flags: --target i686-pc-windows-msvc
#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] //@ needs-llvm-components: x86
//~^ ERROR multiple `import_name_type` arguments in a single `#[link]` attribute #![feature(no_core, rustc_attrs, lang_items)]
extern "C" { } #![no_core]
#![crate_type = "lib"]
fn main() {} #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
//~^ ERROR malformed
extern "C" { }

View File

@@ -1,8 +1,28 @@
error: multiple `import_name_type` arguments in a single `#[link]` attribute error[E0538]: malformed `link` attribute input
--> $DIR/import-name-type-multiple.rs:4:74 --> $DIR/import-name-type-multiple.rs:9:1
| |
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------^^
| |
| found `import_name_type` used as a key more than once
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
LL + #[link(name = "...")]
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: aborting due to 1 previous error error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0538`.

View File

@@ -1,7 +1,10 @@
//@ only-windows //@ add-core-stubs
//@ only-x86 //@ compile-flags: --target i686-pc-windows-msvc
#[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] //@ needs-llvm-components: x86
//~^ ERROR unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated #![feature(no_core, rustc_attrs, lang_items)]
extern "C" { } #![no_core]
#![crate_type = "lib"]
fn main() {} #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
//~^ ERROR malformed
extern "C" { }

View File

@@ -1,8 +1,28 @@
error: unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated error[E0539]: malformed `link` attribute input
--> $DIR/import-name-type-unknown-value.rs:3:42 --> $DIR/import-name-type-unknown-value.rs:8:1
| |
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------^^
| |
| valid arguments are "decorated", "noprefix" or "undecorated"
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
LL + #[link(name = "...")]
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: aborting due to 1 previous error error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0539`.

View File

@@ -1,5 +1,10 @@
//@ only-windows //@ add-core-stubs
//@ only-x86 //@ compile-flags: --target i686-pc-windows-msvc
//@ needs-llvm-components: x86
#![feature(no_core, rustc_attrs, lang_items)]
#![no_core]
#![crate_type = "lib"]
#[link(name = "foo", import_name_type = "decorated")] #[link(name = "foo", import_name_type = "decorated")]
//~^ ERROR import name type can only be used with link kind `raw-dylib` //~^ ERROR import name type can only be used with link kind `raw-dylib`
extern "C" { } extern "C" { }
@@ -11,5 +16,3 @@ extern "C" { }
// Specifying `import_name_type` before `kind` shouldn't raise an error. // Specifying `import_name_type` before `kind` shouldn't raise an error.
#[link(name = "bar", import_name_type = "decorated", kind = "raw-dylib")] #[link(name = "bar", import_name_type = "decorated", kind = "raw-dylib")]
extern "C" { } extern "C" { }
fn main() {}

View File

@@ -1,11 +1,11 @@
error: import name type can only be used with link kind `raw-dylib` error: import name type can only be used with link kind `raw-dylib`
--> $DIR/import-name-type-unsupported-link-kind.rs:3:22 --> $DIR/import-name-type-unsupported-link-kind.rs:8:22
| |
LL | #[link(name = "foo", import_name_type = "decorated")] LL | #[link(name = "foo", import_name_type = "decorated")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: import name type can only be used with link kind `raw-dylib` error: import name type can only be used with link kind `raw-dylib`
--> $DIR/import-name-type-unsupported-link-kind.rs:7:39 --> $DIR/import-name-type-unsupported-link-kind.rs:12:39
| |
LL | #[link(name = "bar", kind = "static", import_name_type = "decorated")] LL | #[link(name = "bar", kind = "static", import_name_type = "decorated")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -1,7 +1,10 @@
//@ only-windows //@ add-core-stubs
//@ ignore-x86 //@ compile-flags: --target aarch64-pc-windows-msvc
//@ needs-llvm-components: aarch64
#![feature(no_core, rustc_attrs, lang_items)]
#![no_core]
#![crate_type = "lib"]
#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
//~^ ERROR import name type is only supported on x86 //~^ ERROR import name type is only supported on x86
extern "C" { } extern "C" { }
fn main() {}

View File

@@ -1,5 +1,5 @@
error: import name type is only supported on x86 error: import name type is only supported on x86
--> $DIR/import-name-type-x86-only.rs:3:42 --> $DIR/import-name-type-x86-only.rs:8:42
| |
LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -10,7 +10,7 @@ fn test() {}
//~^ ERROR attribute cannot be used on //~^ ERROR attribute cannot be used on
static mut imported_val: i32 = 123; static mut imported_val: i32 = 123;
#[link(name = "exporter", kind = "raw-dylib")] #[link(name = "exporter")]
extern "C" { extern "C" {
#[link_ordinal(13)] #[link_ordinal(13)]
fn imported_function(); fn imported_function();

View File

@@ -4,9 +4,7 @@
//~^ WARN this was previously accepted //~^ WARN this was previously accepted
#[inline = ""] //~ ERROR valid forms for the attribute are #[inline = ""] //~ ERROR valid forms for the attribute are
//~^ WARN this was previously accepted //~^ WARN this was previously accepted
#[link] //~ ERROR valid forms for the attribute are #[link] //~ ERROR malformed
//~^ WARN this was previously accepted #[link = ""] //~ ERROR malformed
#[link = ""] //~ ERROR valid forms for the attribute are
//~^ WARN this was previously accepted
fn main() {} fn main() {}

View File

@@ -9,25 +9,47 @@ LL | #[doc]
= note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html>
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` error[E0539]: malformed `link` attribute input
--> $DIR/malformed-regressions.rs:7:1 --> $DIR/malformed-regressions.rs:7:1
| |
LL | #[link] LL | #[link]
| ^^^^^^^ | ^^^^^^^ expected this to be a list
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL | #[link(name = "...")]
| ++++++++++++++
LL | #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
LL | #[link(name = "...", kind = "dylib|static|...")]
| +++++++++++++++++++++++++++++++++++++++++
LL | #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
= and 1 other candidate
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` error[E0539]: malformed `link` attribute input
--> $DIR/malformed-regressions.rs:9:1 --> $DIR/malformed-regressions.rs:8:1
| |
LL | #[link = ""] LL | #[link = ""]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ expected this to be a list
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link = ""]
LL + #[link(name = "...")]
|
LL - #[link = ""]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link = ""]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link = ""]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
--> $DIR/malformed-regressions.rs:3:1 --> $DIR/malformed-regressions.rs:3:1
@@ -49,6 +71,7 @@ LL | #[inline = ""]
error: aborting due to 5 previous errors error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0539`.
Future incompatibility report: Future breakage diagnostic: Future incompatibility report: Future breakage diagnostic:
error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]` error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]`
--> $DIR/malformed-regressions.rs:1:1 --> $DIR/malformed-regressions.rs:1:1
@@ -61,30 +84,6 @@ LL | #[doc]
= note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html>
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
Future breakage diagnostic:
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`
--> $DIR/malformed-regressions.rs:7:1
|
LL | #[link]
| ^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
Future breakage diagnostic:
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`
--> $DIR/malformed-regressions.rs:9:1
|
LL | #[link = ""]
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
Future breakage diagnostic: Future breakage diagnostic:
error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
--> $DIR/malformed-regressions.rs:3:1 --> $DIR/malformed-regressions.rs:3:1

View File

@@ -38,6 +38,7 @@ fn g() {}
#[link(name = "string"suffix)] #[link(name = "string"suffix)]
//~^ ERROR suffixes on string literals are invalid //~^ ERROR suffixes on string literals are invalid
//~| ERROR malformed `link` attribute input
extern "C" {} extern "C" {}
#[rustc_layout_scalar_valid_range_start(0suffix)] #[rustc_layout_scalar_valid_range_start(0suffix)]

View File

@@ -10,12 +10,6 @@ error: suffixes on string literals are invalid
LL | "C"suffix LL | "C"suffix
| ^^^^^^^^^ invalid suffix `suffix` | ^^^^^^^^^ invalid suffix `suffix`
error: suffixes on string literals are invalid
--> $DIR/bad-lit-suffixes.rs:39:15
|
LL | #[link(name = "string"suffix)]
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
warning: `extern` declarations without an explicit ABI are deprecated warning: `extern` declarations without an explicit ABI are deprecated
--> $DIR/bad-lit-suffixes.rs:3:1 --> $DIR/bad-lit-suffixes.rs:3:1
| |
@@ -160,8 +154,39 @@ LL - #[must_use = "string"suffix]
LL + #[must_use] LL + #[must_use]
| |
error: suffixes on string literals are invalid
--> $DIR/bad-lit-suffixes.rs:39:15
|
LL | #[link(name = "string"suffix)]
| ^^^^^^^^^^^^^^ invalid suffix `suffix`
error[E0539]: malformed `link` attribute input
--> $DIR/bad-lit-suffixes.rs:39:1
|
LL | #[link(name = "string"suffix)]
| ^^^^^^^---------------------^^
| |
| expected this to be of the form `name = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "string"suffix)]
LL + #[link(name = "...")]
|
LL - #[link(name = "string"suffix)]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "string"suffix)]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "string"suffix)]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: invalid suffix `suffix` for number literal error: invalid suffix `suffix` for number literal
--> $DIR/bad-lit-suffixes.rs:43:41 --> $DIR/bad-lit-suffixes.rs:44:41
| |
LL | #[rustc_layout_scalar_valid_range_start(0suffix)] LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
| ^^^^^^^ invalid suffix `suffix` | ^^^^^^^ invalid suffix `suffix`
@@ -169,7 +194,7 @@ LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
= help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)
error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input
--> $DIR/bad-lit-suffixes.rs:43:1 --> $DIR/bad-lit-suffixes.rs:44:1
| |
LL | #[rustc_layout_scalar_valid_range_start(0suffix)] LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^
@@ -177,6 +202,6 @@ LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
| | expected an integer literal here | | expected an integer literal here
| help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`
error: aborting due to 22 previous errors; 2 warnings emitted error: aborting due to 23 previous errors; 2 warnings emitted
For more information about this error, try `rustc --explain E0539`. For more information about this error, try `rustc --explain E0539`.

View File

@@ -1,12 +1,12 @@
#![feature(link_cfg)] #![feature(link_cfg)]
#[link(name = "...", wasm_import_module)] //~ ERROR: must be of the form #[link(name = "...", wasm_import_module)] //~ ERROR: malformed `link` attribute input
extern "C" {} extern "C" {}
#[link(name = "...", wasm_import_module(x))] //~ ERROR: must be of the form #[link(name = "...", wasm_import_module(x))] //~ ERROR: malformed `link` attribute input
extern "C" {} extern "C" {}
#[link(name = "...", wasm_import_module())] //~ ERROR: must be of the form #[link(name = "...", wasm_import_module())] //~ ERROR: malformed `link` attribute input
extern "C" {} extern "C" {}
#[link(wasm_import_module = "foo", name = "bar")] //~ ERROR: `wasm_import_module` is incompatible with other arguments #[link(wasm_import_module = "foo", name = "bar")] //~ ERROR: `wasm_import_module` is incompatible with other arguments

View File

@@ -1,20 +1,77 @@
error: wasm import module must be of the form `wasm_import_module = "string"` error[E0539]: malformed `link` attribute input
--> $DIR/wasm-import-module.rs:3:22 --> $DIR/wasm-import-module.rs:3:1
| |
LL | #[link(name = "...", wasm_import_module)] LL | #[link(name = "...", wasm_import_module)]
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^------------------^^
| |
| expected this to be of the form `wasm_import_module = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", wasm_import_module)]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", wasm_import_module)]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", wasm_import_module)]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", wasm_import_module)]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: wasm import module must be of the form `wasm_import_module = "string"` error[E0539]: malformed `link` attribute input
--> $DIR/wasm-import-module.rs:6:22 --> $DIR/wasm-import-module.rs:6:1
| |
LL | #[link(name = "...", wasm_import_module(x))] LL | #[link(name = "...", wasm_import_module(x))]
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^---------------------^^
| |
| expected this to be of the form `wasm_import_module = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", wasm_import_module(x))]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", wasm_import_module(x))]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", wasm_import_module(x))]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", wasm_import_module(x))]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: wasm import module must be of the form `wasm_import_module = "string"` error[E0539]: malformed `link` attribute input
--> $DIR/wasm-import-module.rs:9:22 --> $DIR/wasm-import-module.rs:9:1
| |
LL | #[link(name = "...", wasm_import_module())] LL | #[link(name = "...", wasm_import_module())]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^--------------------^^
| |
| expected this to be of the form `wasm_import_module = "..."`
|
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
help: try changing it to one of the following valid forms of the attribute
|
LL - #[link(name = "...", wasm_import_module())]
LL + #[link(name = "...")]
|
LL - #[link(name = "...", wasm_import_module())]
LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]
|
LL - #[link(name = "...", wasm_import_module())]
LL + #[link(name = "...", kind = "dylib|static|...")]
|
LL - #[link(name = "...", wasm_import_module())]
LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]
|
= and 1 other candidate
error: `wasm_import_module` is incompatible with other arguments in `#[link]` attributes error: `wasm_import_module` is incompatible with other arguments in `#[link]` attributes
--> $DIR/wasm-import-module.rs:12:8 --> $DIR/wasm-import-module.rs:12:8
@@ -36,3 +93,4 @@ LL | #[link(wasm_import_module = "foo", cfg(false))]
error: aborting due to 6 previous errors error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0539`.