Auto merge of #145958 - Zalathar:rollup-ii9z77c, r=Zalathar

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#142727 (wasm: rm static mut)
 - rust-lang/rust#143193 (Port `#[link]` to the new attribute parsing infrastructure )
 - rust-lang/rust#144864 (No source fixes)
 - rust-lang/rust#145913 (Add spin_loop hint for LoongArch)
 - rust-lang/rust#145926 (compiletest: Remove several remnants of the old libtest-based executor)
 - rust-lang/rust#145928 (Rename `Location::file_with_nul` to `file_as_c_str`)
 - rust-lang/rust#145930 (`const`ify (the unstable) `str::as_str`)
 - rust-lang/rust#145941 (Disable `integer_to_ptr_transmutes` suggestion for unsized types)
 - rust-lang/rust#145953 (Update `icu_list` to 2.0)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-08-28 13:41:38 +00:00
commit 1f7dcc878d
128 changed files with 2187 additions and 1717 deletions

View file

@ -1674,30 +1674,40 @@ checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47"
dependencies = [
"displaydoc",
"potential_utf",
"yoke 0.8.0",
"yoke",
"zerofrom",
"zerovec 0.11.4",
"zerovec",
]
[[package]]
name = "icu_list"
version = "1.5.0"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbfeda1d7775b6548edd4e8b7562304a559a91ed56ab56e18961a053f367c365"
checksum = "e26f94ec776bb8b28cedc7dcf91033b822c5cb4c1783cf7a3f796fc168aa0c8b"
dependencies = [
"displaydoc",
"icu_list_data",
"icu_locid_transform",
"icu_provider 1.5.0",
"regex-automata 0.2.0",
"writeable 0.5.5",
"icu_provider",
"regex-automata 0.4.9",
"serde",
"writeable",
"zerovec",
]
[[package]]
name = "icu_list_data"
version = "1.5.1"
name = "icu_locale"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52b1a7fbdbf3958f1be8354cb59ac73f165b7b7082d447ff2090355c9a069120"
checksum = "6ae5921528335e91da1b6c695dbf1ec37df5ac13faa3f91e5640be93aa2fbefd"
dependencies = [
"displaydoc",
"icu_collections",
"icu_locale_core",
"icu_locale_data",
"icu_provider",
"potential_utf",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_locale_core"
@ -1706,44 +1716,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a"
dependencies = [
"displaydoc",
"litemap 0.8.0",
"tinystr 0.8.1",
"writeable 0.6.1",
"zerovec 0.11.4",
"litemap",
"tinystr",
"writeable",
"zerovec",
]
[[package]]
name = "icu_locid"
version = "1.5.0"
name = "icu_locale_data"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637"
dependencies = [
"displaydoc",
"litemap 0.7.5",
"tinystr 0.7.6",
"writeable 0.5.5",
"zerovec 0.10.4",
]
[[package]]
name = "icu_locid_transform"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e"
dependencies = [
"displaydoc",
"icu_locid",
"icu_locid_transform_data",
"icu_provider 1.5.0",
"tinystr 0.7.6",
"zerovec 0.10.4",
]
[[package]]
name = "icu_locid_transform_data"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d"
checksum = "4fdef0c124749d06a743c69e938350816554eb63ac979166590e2b4ee4252765"
[[package]]
name = "icu_normalizer"
@ -1755,9 +1738,9 @@ dependencies = [
"icu_collections",
"icu_normalizer_data",
"icu_properties",
"icu_provider 2.0.0",
"icu_provider",
"smallvec",
"zerovec 0.11.4",
"zerovec",
]
[[package]]
@ -1776,10 +1759,10 @@ dependencies = [
"icu_collections",
"icu_locale_core",
"icu_properties_data",
"icu_provider 2.0.0",
"icu_provider",
"potential_utf",
"zerotrie",
"zerovec 0.11.4",
"zerovec",
]
[[package]]
@ -1788,23 +1771,6 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632"
[[package]]
name = "icu_provider"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9"
dependencies = [
"displaydoc",
"icu_locid",
"icu_provider_macros",
"stable_deref_trait",
"tinystr 0.7.6",
"writeable 0.5.5",
"yoke 0.7.5",
"zerofrom",
"zerovec 0.10.4",
]
[[package]]
name = "icu_provider"
version = "2.0.0"
@ -1814,36 +1780,12 @@ dependencies = [
"displaydoc",
"icu_locale_core",
"stable_deref_trait",
"tinystr 0.8.1",
"writeable 0.6.1",
"yoke 0.8.0",
"tinystr",
"writeable",
"yoke",
"zerofrom",
"zerotrie",
"zerovec 0.11.4",
]
[[package]]
name = "icu_provider_adapters"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6324dfd08348a8e0374a447ebd334044d766b1839bb8d5ccf2482a99a77c0bc"
dependencies = [
"icu_locid",
"icu_locid_transform",
"icu_provider 1.5.0",
"tinystr 0.7.6",
"zerovec 0.10.4",
]
[[package]]
name = "icu_provider_macros"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.106",
"zerovec",
]
[[package]]
@ -2243,12 +2185,6 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
[[package]]
name = "litemap"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856"
[[package]]
name = "litemap"
version = "0.8.0"
@ -2959,7 +2895,8 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585"
dependencies = [
"zerovec 0.11.4",
"serde",
"zerovec",
]
[[package]]
@ -3205,15 +3142,6 @@ dependencies = [
"regex-syntax 0.6.29",
]
[[package]]
name = "regex-automata"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9368763f5a9b804326f3af749e16f9abf378d227bcdee7634b13d8f17793782"
dependencies = [
"memchr",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
@ -3480,6 +3408,7 @@ dependencies = [
"rustc_parse",
"rustc_session",
"rustc_span",
"rustc_target",
"thin-vec",
]
@ -3488,10 +3417,9 @@ name = "rustc_baked_icu_data"
version = "0.0.0"
dependencies = [
"icu_list",
"icu_locid",
"icu_locid_transform",
"icu_provider 1.5.0",
"zerovec 0.10.4",
"icu_locale",
"icu_provider",
"zerovec",
]
[[package]]
@ -3764,8 +3692,7 @@ dependencies = [
"fluent-bundle",
"fluent-syntax",
"icu_list",
"icu_locid",
"icu_provider_adapters",
"icu_locale",
"intl-memoizer",
"rustc_ast",
"rustc_ast_pretty",
@ -5497,16 +5424,6 @@ dependencies = [
"libc",
]
[[package]]
name = "tinystr"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f"
dependencies = [
"displaydoc",
"zerovec 0.10.4",
]
[[package]]
name = "tinystr"
version = "0.8.1"
@ -5514,7 +5431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b"
dependencies = [
"displaydoc",
"zerovec 0.11.4",
"zerovec",
]
[[package]]
@ -5779,7 +5696,7 @@ version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dce1bf08044d4b7a94028c93786f8566047edc11110595914de93362559bc658"
dependencies = [
"tinystr 0.8.1",
"tinystr",
]
[[package]]
@ -5789,7 +5706,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5957eb82e346d7add14182a3315a7e298f04e1ba4baac36f7f0dbfedba5fc25"
dependencies = [
"proc-macro-hack",
"tinystr 0.8.1",
"tinystr",
"unic-langid-impl",
"unic-langid-macros-impl",
]
@ -6683,12 +6600,6 @@ dependencies = [
"wasmparser 0.237.0",
]
[[package]]
name = "writeable"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]]
name = "writeable"
version = "0.6.1"
@ -6727,18 +6638,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "yoke"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40"
dependencies = [
"serde",
"stable_deref_trait",
"yoke-derive 0.7.5",
"zerofrom",
]
[[package]]
name = "yoke"
version = "0.8.0"
@ -6747,22 +6646,10 @@ checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc"
dependencies = [
"serde",
"stable_deref_trait",
"yoke-derive 0.8.0",
"yoke-derive",
"zerofrom",
]
[[package]]
name = "yoke-derive"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.106",
"synstructure",
]
[[package]]
name = "yoke-derive"
version = "0.8.0"
@ -6823,41 +6710,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595"
dependencies = [
"displaydoc",
"yoke 0.8.0",
"yoke",
"zerofrom",
]
[[package]]
name = "zerovec"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079"
dependencies = [
"yoke 0.7.5",
"zerofrom",
"zerovec-derive 0.10.3",
]
[[package]]
name = "zerovec"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b"
dependencies = [
"yoke 0.8.0",
"yoke",
"zerofrom",
"zerovec-derive 0.11.1",
]
[[package]]
name = "zerovec-derive"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.106",
"zerovec-derive",
]
[[package]]

View file

@ -17,5 +17,6 @@ rustc_macros = { path = "../rustc_macros" }
rustc_parse = { path = "../rustc_parse" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
thin-vec.workspace = true
# 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
.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)
}
fn parse_cfg_entry<S: Stage>(
pub(crate) fn parse_cfg_entry<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
item: &MetaItemOrLitParser<'_>,
) -> Option<CfgEntry> {

View file

@ -1,9 +1,21 @@
use rustc_feature::Features;
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::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;
@ -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;
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::link_attrs::{
ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser, LinkOrdinalParser,
LinkSectionParser, LinkageParser, StdInternalSymbolParser,
LinkParser, LinkSectionParser, LinkageParser, StdInternalSymbolParser,
};
use crate::attributes::lint_helpers::{
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
@ -162,6 +162,7 @@ attribute_parsers!(
Combine<AllowConstFnUnstableParser>,
Combine<AllowInternalUnstableParser>,
Combine<ForceTargetFeatureParser>,
Combine<LinkParser>,
Combine<ReprParser>,
Combine<TargetFeatureParser>,
Combine<UnstableFeatureBoundParser>,

View file

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

View file

@ -836,3 +836,97 @@ pub(crate) struct InvalidAttrStyle {
pub target_span: Option<Span>,
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

@ -5,9 +5,8 @@ edition = "2024"
[dependencies]
# tidy-alphabetical-start
icu_list = "1.2"
icu_locid = "1.2"
icu_locid_transform = "1.3.2"
icu_provider = { version = "1.2", features = ["sync"] }
zerovec = "0.10.0"
icu_list = { version = "2.0", default-features = false }
icu_locale = { version = "2.0", default-features = false, features = ["compiled_data"] }
icu_provider = { version = "2.0", features = ["baked", "sync"] }
zerovec = "0.11.0"
# tidy-alphabetical-end

View file

@ -1,2 +0,0 @@
// @generated
impl_any_provider!(BakedDataProvider);

File diff suppressed because one or more lines are too long

View file

@ -1,46 +0,0 @@
// @generated
/// Marks a type as a data provider. You can then use macros like
/// `impl_core_helloworld_v1` to add implementations.
///
/// ```ignore
/// struct MyProvider;
/// const _: () = {
/// include!("path/to/generated/macros.rs");
/// make_provider!(MyProvider);
/// impl_core_helloworld_v1!(MyProvider);
/// }
/// ```
#[doc(hidden)]
#[macro_export]
macro_rules! __make_provider {
($ name : ty) => {
#[clippy::msrv = "1.66"]
impl $name {
#[doc(hidden)]
#[allow(dead_code)]
pub const MUST_USE_MAKE_PROVIDER_MACRO: () = ();
}
};
}
#[doc(inline)]
pub use __make_provider as make_provider;
#[macro_use]
#[path = "macros/fallback_likelysubtags_v1.data.rs"]
mod fallback_likelysubtags_v1;
#[doc(inline)]
pub use __impl_fallback_likelysubtags_v1 as impl_fallback_likelysubtags_v1;
#[macro_use]
#[path = "macros/fallback_parents_v1.data.rs"]
mod fallback_parents_v1;
#[doc(inline)]
pub use __impl_fallback_parents_v1 as impl_fallback_parents_v1;
#[macro_use]
#[path = "macros/fallback_supplement_co_v1.data.rs"]
mod fallback_supplement_co_v1;
#[doc(inline)]
pub use __impl_fallback_supplement_co_v1 as impl_fallback_supplement_co_v1;
#[macro_use]
#[path = "macros/list_and_v1.data.rs"]
mod list_and_v1;
#[doc(inline)]
pub use __impl_list_and_v1 as impl_list_and_v1;

View file

@ -1,40 +0,0 @@
// @generated
/// Implement `DataProvider<LocaleFallbackLikelySubtagsV1Marker>` on the given struct using the data
/// hardcoded in this file. This allows the struct to be used with
/// `icu`'s `_unstable` constructors.
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_fallback_likelysubtags_v1 {
($ provider : ty) => {
#[clippy::msrv = "1.66"]
const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO;
#[clippy::msrv = "1.66"]
impl $provider {
#[doc(hidden)]
pub const SINGLETON_FALLBACK_LIKELYSUBTAGS_V1: &'static <icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker as icu_provider::DataMarker>::Yokeable = &icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1 {
l2s: unsafe {
#[allow(unused_unsafe)]
zerovec::ZeroMap::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"am\0ar\0as\0be\0bg\0bgcbhobn\0brxchrcv\0doiel\0fa\0gu\0he\0hi\0hy\0ja\0ka\0kk\0km\0kn\0ko\0kokks\0ky\0lo\0maimk\0ml\0mn\0mnimr\0my\0ne\0or\0pa\0ps\0rajru\0sa\0satsd\0si\0sr\0ta\0te\0tg\0th\0ti\0tt\0uk\0ur\0yuezh\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"EthiArabBengCyrlCyrlDevaDevaBengDevaCherCyrlDevaGrekArabGujrHebrDevaArmnJpanGeorCyrlKhmrKndaKoreDevaArabCyrlLaooDevaCyrlMlymCyrlBengDevaMymrDevaOryaGuruArabDevaCyrlDevaOlckArabSinhCyrlTamlTeluCyrlThaiEthiCyrlCyrlArabHantHans") })
},
lr2s: unsafe {
#[allow(unused_unsafe)]
zerovec::ZeroMap2d::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"az\0ha\0kk\0ky\0mn\0ms\0pa\0sd\0sr\0tg\0uz\0yuezh\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\x03\0\0\0\x05\0\0\0\t\0\0\0\x0B\0\0\0\x0C\0\0\0\r\0\0\0\x0E\0\0\0\x0F\0\0\0\x13\0\0\0\x14\0\0\0\x16\0\0\0\x17\0\0\0&\0\0\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"IQ\0IR\0RU\0CM\0SD\0AF\0CN\0IR\0MN\0CN\0TR\0CN\0CC\0PK\0IN\0ME\0RO\0RU\0TR\0PK\0AF\0CN\0CN\0AU\0BN\0GB\0GF\0HK\0ID\0MO\0PA\0PF\0PH\0SR\0TH\0TW\0US\0VN\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"ArabArabCyrlArabArabArabArabArabArabArabLatnMongArabArabDevaLatnLatnLatnLatnArabArabCyrlHansHantHantHantHantHantHantHantHantHantHantHantHantHantHantHant") })
},
l2r: unsafe {
#[allow(unused_unsafe)]
zerovec::ZeroMap::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"af\0am\0ar\0as\0astaz\0be\0bg\0bgcbhobn\0br\0brxbs\0ca\0cebchrcs\0cv\0cy\0da\0de\0doidsbel\0en\0es\0et\0eu\0fa\0ff\0fi\0filfo\0fr\0ga\0gd\0gl\0gu\0ha\0he\0hi\0hr\0hsbhu\0hy\0ia\0id\0ig\0is\0it\0ja\0jv\0ka\0keakgpkk\0km\0kn\0ko\0kokks\0ky\0lo\0lt\0lv\0maimi\0mk\0ml\0mn\0mnimr\0ms\0my\0ne\0nl\0nn\0no\0or\0pa\0pcmpl\0ps\0pt\0qu\0rajrm\0ro\0ru\0sa\0satsc\0sd\0si\0sk\0sl\0so\0sq\0sr\0su\0sv\0sw\0ta\0te\0tg\0th\0ti\0tk\0to\0tr\0tt\0uk\0ur\0uz\0vi\0wo\0xh\0yo\0yrlyuezh\0zu\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"ZA\0ET\0EG\0IN\0ES\0AZ\0BY\0BG\0IN\0IN\0BD\0FR\0IN\0BA\0ES\0PH\0US\0CZ\0RU\0GB\0DK\0DE\0IN\0DE\0GR\0US\0ES\0EE\0ES\0IR\0SN\0FI\0PH\0FO\0FR\0IE\0GB\0ES\0IN\0NG\0IL\0IN\0HR\0DE\0HU\0AM\x00001ID\0NG\0IS\0IT\0JP\0ID\0GE\0CV\0BR\0KZ\0KH\0IN\0KR\0IN\0IN\0KG\0LA\0LT\0LV\0IN\0NZ\0MK\0IN\0MN\0IN\0IN\0MY\0MM\0NP\0NL\0NO\0NO\0IN\0IN\0NG\0PL\0AF\0BR\0PE\0IN\0CH\0RO\0RU\0IN\0IN\0IT\0PK\0LK\0SK\0SI\0SO\0AL\0RS\0ID\0SE\0TZ\0IN\0IN\0TJ\0TH\0ET\0TM\0TO\0TR\0RU\0UA\0PK\0UZ\0VN\0SN\0ZA\0NG\0BR\0HK\0CN\0ZA\0") })
},
ls2r: unsafe {
#[allow(unused_unsafe)]
zerovec::ZeroMap2d::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"az\0en\0ff\0kk\0ky\0mn\0pa\0sd\0tg\0uz\0yuezh\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\x01\0\0\0\x02\0\0\0\x03\0\0\0\x04\0\0\0\x06\0\0\0\x07\0\0\0\x08\0\0\0\x0B\0\0\0\x0C\0\0\0\r\0\0\0\x0E\0\0\0\x11\0\0\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"ArabShawAdlmArabArabLatnMongArabDevaKhojSindArabArabHansBopoHanbHant") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"IR\0GB\0GN\0CN\0CN\0TR\0CN\0PK\0IN\0IN\0IN\0PK\0AF\0CN\0TW\0TW\0TW\0") })
},
};
}
#[clippy::msrv = "1.66"]
impl icu_provider::DataProvider<icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker> for $provider {
fn load(&self, req: icu_provider::DataRequest) -> Result<icu_provider::DataResponse<icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker>, icu_provider::DataError> {
if req.locale.is_empty() { Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_FALLBACK_LIKELYSUBTAGS_V1)), metadata: Default::default() }) } else { Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(<icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker as icu_provider::KeyedDataMarker>::KEY, req)) }
}
}
};
}

View file

@ -1,28 +0,0 @@
// @generated
/// Implement `DataProvider<LocaleFallbackParentsV1Marker>` on the given struct using the data
/// hardcoded in this file. This allows the struct to be used with
/// `icu`'s `_unstable` constructors.
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_fallback_parents_v1 {
($ provider : ty) => {
#[clippy::msrv = "1.66"]
const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO;
#[clippy::msrv = "1.66"]
impl $provider {
#[doc(hidden)]
pub const SINGLETON_FALLBACK_PARENTS_V1: &'static <icu_locid_transform::provider::LocaleFallbackParentsV1Marker as icu_provider::DataMarker>::Yokeable = &icu_locid_transform::provider::LocaleFallbackParentsV1 {
parents: unsafe {
#[allow(unused_unsafe)]
zerovec::ZeroMap::from_parts_unchecked(unsafe { zerovec::VarZeroVec::from_bytes_unchecked(b"\x84\0\0\0\0\0\x06\0\x0B\0\x10\0\x15\0\x1A\0\x1F\0$\0)\0.\x003\08\0=\0B\0G\0L\0Q\0V\0[\0`\0e\0j\0o\0t\0y\0~\0\x83\0\x88\0\x8D\0\x92\0\x97\0\x9C\0\xA1\0\xA6\0\xAB\0\xB0\0\xB5\0\xBA\0\xBF\0\xC4\0\xC9\0\xCE\0\xD3\0\xD8\0\xDD\0\xE2\0\xE7\0\xEC\0\xF1\0\xF6\0\xFB\0\0\x01\x05\x01\n\x01\x0F\x01\x14\x01\x19\x01\x1E\x01#\x01(\x01-\x012\x017\x01<\x01A\x01F\x01K\x01P\x01U\x01Z\x01_\x01d\x01i\x01n\x01s\x01x\x01}\x01\x82\x01\x87\x01\x8C\x01\x91\x01\x96\x01\x9B\x01\xA0\x01\xA5\x01\xAA\x01\xAF\x01\xB4\x01\xB9\x01\xBE\x01\xC3\x01\xC8\x01\xCD\x01\xD2\x01\xD7\x01\xDC\x01\xE1\x01\xE6\x01\xEB\x01\xF0\x01\xF5\x01\xFA\x01\xFF\x01\x04\x02\t\x02\x0E\x02\x13\x02\x18\x02\x1D\x02\"\x02'\x02,\x021\x026\x02;\x02@\x02G\x02I\x02K\x02M\x02R\x02W\x02\\\x02a\x02f\x02k\x02p\x02u\x02z\x02\x7F\x02\x84\x02\x89\x02en-150en-AGen-AIen-ATen-AUen-BBen-BEen-BMen-BSen-BWen-BZen-CCen-CHen-CKen-CMen-CXen-CYen-DEen-DGen-DKen-DMen-ERen-FIen-FJen-FKen-FMen-GBen-GDen-GGen-GHen-GIen-GMen-GYen-HKen-IEen-ILen-IMen-INen-IOen-JEen-JMen-KEen-KIen-KNen-KYen-LCen-LRen-LSen-MGen-MOen-MSen-MTen-MUen-MVen-MWen-MYen-NAen-NFen-NGen-NLen-NRen-NUen-NZen-PGen-PKen-PNen-PWen-RWen-SBen-SCen-SDen-SEen-SGen-SHen-SIen-SLen-SSen-SXen-SZen-TCen-TKen-TOen-TTen-TVen-TZen-UGen-VCen-VGen-VUen-WSen-ZAen-ZMen-ZWes-ARes-BOes-BRes-BZes-CLes-COes-CRes-CUes-DOes-ECes-GTes-HNes-MXes-NIes-PAes-PEes-PRes-PYes-SVes-USes-UYes-VEhi-Latnhtnbnnno-NOpt-AOpt-CHpt-CVpt-FRpt-GQpt-GWpt-LUpt-MOpt-MZpt-STpt-TLzh-Hant-MO") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01150en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01150en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01150en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01150en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01150en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01150en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01150en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01150en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01150en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001en\0\0\0\0\0\0\x01001es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419es\0\0\0\0\0\0\x01419en\0\0\0\0\0\0\x01IN\0fr\0\0\0\0\0\0\x01HT\0no\0\0\0\0\0\0\0\0\0\0no\0\0\0\0\0\0\0\0\0\0no\0\0\0\0\0\0\0\0\0\0pt\0\0\0\0\0\0\x01PT\0pt\0\0\0\0\0\0\x01PT\0pt\0\0\0\0\0\0\x01PT\0pt\0\0\0\0\0\0\x01PT\0pt\0\0\0\0\0\0\x01PT\0pt\0\0\0\0\0\0\x01PT\0pt\0\0\0\0\0\0\x01PT\0pt\0\0\0\0\0\0\x01PT\0pt\0\0\0\0\0\0\x01PT\0pt\0\0\0\0\0\0\x01PT\0pt\0\0\0\0\0\0\x01PT\0zh\0\x01Hant\x01HK\0") })
},
};
}
#[clippy::msrv = "1.66"]
impl icu_provider::DataProvider<icu_locid_transform::provider::LocaleFallbackParentsV1Marker> for $provider {
fn load(&self, req: icu_provider::DataRequest) -> Result<icu_provider::DataResponse<icu_locid_transform::provider::LocaleFallbackParentsV1Marker>, icu_provider::DataError> {
if req.locale.is_empty() { Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_FALLBACK_PARENTS_V1)), metadata: Default::default() }) } else { Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(<icu_locid_transform::provider::LocaleFallbackParentsV1Marker as icu_provider::KeyedDataMarker>::KEY, req)) }
}
}
};
}

View file

@ -1,32 +0,0 @@
// @generated
/// Implement `DataProvider<CollationFallbackSupplementV1Marker>` on the given struct using the data
/// hardcoded in this file. This allows the struct to be used with
/// `icu`'s `_unstable` constructors.
#[doc(hidden)]
#[macro_export]
macro_rules! __impl_fallback_supplement_co_v1 {
($ provider : ty) => {
#[clippy::msrv = "1.66"]
const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO;
#[clippy::msrv = "1.66"]
impl $provider {
#[doc(hidden)]
pub const SINGLETON_FALLBACK_SUPPLEMENT_CO_V1: &'static <icu_locid_transform::provider::CollationFallbackSupplementV1Marker as icu_provider::DataMarker>::Yokeable = &icu_locid_transform::provider::LocaleFallbackSupplementV1 {
parents: unsafe {
#[allow(unused_unsafe)]
zerovec::ZeroMap::from_parts_unchecked(unsafe { zerovec::VarZeroVec::from_bytes_unchecked(b"\x01\0\0\0\0\0yue") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"zh\0\x01Hant\0\0\0\0") })
},
unicode_extension_defaults: unsafe {
#[allow(unused_unsafe)]
zerovec::ZeroMap2d::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"co") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\x02\0\0\0") }, unsafe { zerovec::VarZeroVec::from_bytes_unchecked(b"\x02\0\0\0\0\0\x02\0zhzh-Hant") }, unsafe { zerovec::VarZeroVec::from_bytes_unchecked(b"\x02\0\0\0\0\0\x06\0pinyinstroke") })
},
};
}
#[clippy::msrv = "1.66"]
impl icu_provider::DataProvider<icu_locid_transform::provider::CollationFallbackSupplementV1Marker> for $provider {
fn load(&self, req: icu_provider::DataRequest) -> Result<icu_provider::DataResponse<icu_locid_transform::provider::CollationFallbackSupplementV1Marker>, icu_provider::DataError> {
if req.locale.is_empty() { Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_FALLBACK_SUPPLEMENT_CO_V1)), metadata: Default::default() }) } else { Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(<icu_locid_transform::provider::CollationFallbackSupplementV1Marker as icu_provider::KeyedDataMarker>::KEY, req)) }
}
}
};
}

File diff suppressed because one or more lines are too long

View file

@ -1,31 +1,40 @@
// @generated
include!("macros.rs");
include!("list_and_v1.rs.data");
/// Marks a type as a data provider. You can then use macros like
/// `impl_core_helloworld_v1` to add implementations.
///
/// ```ignore
/// struct MyProvider;
/// const _: () = {
/// include!("path/to/generated/macros.rs");
/// make_provider!(MyProvider);
/// impl_core_helloworld_v1!(MyProvider);
/// }
/// ```
#[doc(hidden)]
#[macro_export]
macro_rules! __make_provider {
($ name : ty) => {
#[clippy::msrv = "1.82"]
impl $name {
#[allow(dead_code)]
pub(crate) const MUST_USE_MAKE_PROVIDER_MACRO: () = ();
}
icu_provider::marker::impl_data_provider_never_marker!($name);
};
}
#[doc(inline)]
pub use __make_provider as make_provider;
/// This macro requires the following crates:
/// * `icu_list`
/// * `icu_locale/compiled_data`
/// * `icu_provider`
/// * `icu_provider/baked`
/// * `zerovec`
#[allow(unused_macros)]
macro_rules! impl_data_provider {
($ provider : ty) => {
make_provider!($provider);
impl_fallback_likelysubtags_v1!($provider);
impl_fallback_parents_v1!($provider);
impl_fallback_supplement_co_v1!($provider);
impl_list_and_v1!($provider);
};
}
#[allow(unused_macros)]
macro_rules! impl_any_provider {
($ provider : ty) => {
#[clippy::msrv = "1.66"]
impl icu_provider::AnyProvider for $provider {
fn load_any(&self, key: icu_provider::DataKey, req: icu_provider::DataRequest) -> Result<icu_provider::AnyResponse, icu_provider::DataError> {
match key.hashed() {
h if h == <icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker as icu_provider::KeyedDataMarker>::KEY.hashed() => icu_provider::DataProvider::<icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker>::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response),
h if h == <icu_locid_transform::provider::LocaleFallbackParentsV1Marker as icu_provider::KeyedDataMarker>::KEY.hashed() => icu_provider::DataProvider::<icu_locid_transform::provider::LocaleFallbackParentsV1Marker>::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response),
h if h == <icu_locid_transform::provider::CollationFallbackSupplementV1Marker as icu_provider::KeyedDataMarker>::KEY.hashed() => icu_provider::DataProvider::<icu_locid_transform::provider::CollationFallbackSupplementV1Marker>::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response),
h if h == <icu_list::provider::AndListV1Marker as icu_provider::KeyedDataMarker>::KEY.hashed() => icu_provider::DataProvider::<icu_list::provider::AndListV1Marker>::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response),
_ => Err(icu_provider::DataErrorKind::MissingDataKey.with_req(key, req)),
}
}
}
};
}
#[clippy::msrv = "1.66"]
pub struct BakedDataProvider;
impl_data_provider!(BakedDataProvider);

View file

@ -14,10 +14,9 @@
//! To regenerate the data, run this command:
//!
//! ```text
//! icu4x-datagen -W --pretty --fingerprint --use-separate-crates \
//! --format mod -l en es fr it ja pt ru tr zh zh-Hans zh-Hant \
//! -k list/and@1 fallback/likelysubtags@1 fallback/parents@1 fallback/supplement/co@1 \
//! --cldr-tag latest --icuexport-tag latest -o src/data
//! icu4x-datagen -W --pretty --use-separate-crates \
//! --format baked --locales @en @es @fr @it @ja @pt @ru @tr @zh @zh-Hans @zh-Hant \
//! -m ListAndV1 -o src/data
//! ```
// tidy-alphabetical-start
@ -29,26 +28,26 @@
// #![warn(unreachable_pub)] // don't use because this crate is mostly generated code
// tidy-alphabetical-end
mod data {
include!("data/mod.rs");
include!("data/any.rs");
}
pub struct BakedDataProvider;
pub use data::BakedDataProvider;
include!("data/mod.rs");
const _: () = {
impl_data_provider!(BakedDataProvider);
};
pub const fn baked_data_provider() -> BakedDataProvider {
data::BakedDataProvider
BakedDataProvider
}
pub mod supported_locales {
pub const EN: icu_locid::Locale = icu_locid::locale!("en");
pub const ES: icu_locid::Locale = icu_locid::locale!("es");
pub const FR: icu_locid::Locale = icu_locid::locale!("fr");
pub const IT: icu_locid::Locale = icu_locid::locale!("it");
pub const JA: icu_locid::Locale = icu_locid::locale!("ja");
pub const PT: icu_locid::Locale = icu_locid::locale!("pt");
pub const RU: icu_locid::Locale = icu_locid::locale!("ru");
pub const TR: icu_locid::Locale = icu_locid::locale!("tr");
pub const ZH_HANS: icu_locid::Locale = icu_locid::locale!("zh-Hans");
pub const ZH_HANT: icu_locid::Locale = icu_locid::locale!("zh-Hant");
pub const EN: icu_locale::Locale = icu_locale::locale!("en");
pub const ES: icu_locale::Locale = icu_locale::locale!("es");
pub const FR: icu_locale::Locale = icu_locale::locale!("fr");
pub const IT: icu_locale::Locale = icu_locale::locale!("it");
pub const JA: icu_locale::Locale = icu_locale::locale!("ja");
pub const PT: icu_locale::Locale = icu_locale::locale!("pt");
pub const RU: icu_locale::Locale = icu_locale::locale!("ru");
pub const TR: icu_locale::Locale = icu_locale::locale!("tr");
pub const ZH_HANS: icu_locale::Locale = icu_locale::locale!("zh-Hans");
pub const ZH_HANT: icu_locale::Locale = icu_locale::locale!("zh-Hant");
}

View file

@ -14,11 +14,13 @@ use itertools::Itertools;
use regex::Regex;
use rustc_arena::TypedArena;
use rustc_ast::CRATE_NODE_ID;
use rustc_attr_parsing::{ShouldEmit, eval_config_entry};
use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{DiagCtxtHandle, LintDiagnostic};
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_macros::LintDiagnostic;
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::output::{check_file_is_writeable, invalid_output_for_target, out_filename};
use rustc_session::search_paths::PathKind;
use rustc_session::utils::NativeLibKind;
/// For all the linkers we support, and information they might
/// need out of the shared crate context before we get rid of it.
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 {
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,
}
}

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::stable_hasher::StableHasher;
use rustc_hashes::Hash128;
use rustc_hir::attrs::NativeLibKind;
use rustc_session::Session;
use rustc_session::cstore::DllImport;
use rustc_session::utils::NativeLibKind;
use rustc_span::Symbol;
use crate::back::archive::ImportLibraryItem;

View file

@ -1,10 +1,11 @@
#![allow(non_camel_case_types)]
use rustc_hir::LangItem;
use rustc_hir::attrs::PeImportNameType;
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{self, Instance, TyCtxt};
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_target::spec::Target;

View file

@ -25,10 +25,10 @@ use std::io;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use rustc_ast as ast;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_data_structures::unord::UnordMap;
use rustc_hir::CRATE_HIR_ID;
use rustc_hir::attrs::{CfgEntry, NativeLibKind};
use rustc_hir::def_id::CrateNum;
use rustc_macros::{Decodable, Encodable, HashStable};
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::cstore::{self, CrateSource};
use rustc_session::lint::builtin::LINKER_MESSAGES;
use rustc_session::utils::NativeLibKind;
use rustc_span::Symbol;
pub mod assert_module_sources;
@ -187,7 +186,7 @@ pub struct NativeLib {
pub kind: NativeLibKind,
pub name: Symbol,
pub filename: Option<Symbol>,
pub cfg: Option<ast::MetaItemInner>,
pub cfg: Option<CfgEntry>,
pub verbatim: bool,
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.
Erroneous code example:
```compile_fail,E0458
```ignore (no longer emitted)
#[link(kind = "wonderful_unicorn")] extern "C" {}
// error: unknown kind: `wonderful_unicorn`
```

View file

@ -7,9 +7,8 @@ edition = "2024"
# tidy-alphabetical-start
fluent-bundle = "0.16"
fluent-syntax = "0.12"
icu_list = "1.2"
icu_locid = "1.2"
icu_provider_adapters = "1.2"
icu_list = { version = "2.0", default-features = false, features = ["alloc"] }
icu_locale = { version = "2.0", default-features = false }
intl-memoizer = "0.5.1"
rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }

View file

@ -15,7 +15,6 @@ use fluent_bundle::FluentResource;
pub use fluent_bundle::types::FluentType;
pub use fluent_bundle::{self, FluentArgs, FluentError, FluentValue};
use fluent_syntax::parser::ParserError;
use icu_provider_adapters::fallback::{LocaleFallbackProvider, LocaleFallbacker};
use intl_memoizer::concurrent::IntlLangMemoizer;
use rustc_data_structures::sync::{DynSend, IntoDynSyncSend};
use rustc_macros::{Decodable, Encodable};
@ -515,8 +514,8 @@ impl From<Vec<Span>> for MultiSpan {
}
}
fn icu_locale_from_unic_langid(lang: LanguageIdentifier) -> Option<icu_locid::Locale> {
icu_locid::Locale::try_from_bytes(lang.to_string().as_bytes()).ok()
fn icu_locale_from_unic_langid(lang: LanguageIdentifier) -> Option<icu_locale::Locale> {
icu_locale::Locale::try_from_str(&lang.to_string()).ok()
}
pub fn fluent_value_from_str_list_sep_by_and(l: Vec<Cow<'_, str>>) -> FluentValue<'_> {
@ -568,21 +567,15 @@ pub fn fluent_value_from_str_list_sep_by_and(l: Vec<Cow<'_, str>>) -> FluentValu
where
Self: Sized,
{
let baked_data_provider = rustc_baked_icu_data::baked_data_provider();
let locale_fallbacker =
LocaleFallbacker::try_new_with_any_provider(&baked_data_provider)
.expect("Failed to create fallback provider");
let data_provider =
LocaleFallbackProvider::new_with_fallbacker(baked_data_provider, locale_fallbacker);
let locale = icu_locale_from_unic_langid(lang)
.unwrap_or_else(|| rustc_baked_icu_data::supported_locales::EN);
let list_formatter =
icu_list::ListFormatter::try_new_and_with_length_with_any_provider(
&data_provider,
&locale.into(),
icu_list::ListLength::Wide,
)
.expect("Failed to create list formatter");
let list_formatter = icu_list::ListFormatter::try_new_and_unstable(
&rustc_baked_icu_data::BakedDataProvider,
locale.into(),
icu_list::options::ListFormatterOptions::default()
.with_length(icu_list::options::ListLength::Wide),
)
.expect("Failed to create list formatter");
Ok(MemoizableListFormatter(list_formatter))
}

View file

@ -1462,7 +1462,7 @@ impl HumanEmitter {
max_line_num_len: usize,
is_secondary: bool,
is_cont: bool,
) -> io::Result<()> {
) -> io::Result<CodeWindowStatus> {
let mut buffer = StyledBuffer::new();
if !msp.has_primary_spans() && !msp.has_span_labels() && is_secondary && !self.short_message
@ -1575,12 +1575,14 @@ impl HumanEmitter {
}
let mut annotated_files = FileWithAnnotatedLines::collect_annotations(self, args, msp);
trace!("{annotated_files:#?}");
let mut code_window_status = CodeWindowStatus::Open;
// Make sure our primary file comes first
let primary_span = msp.primary_span().unwrap_or_default();
let (Some(sm), false) = (self.sm.as_ref(), primary_span.is_dummy()) else {
// If we don't have span information, emit and exit
return emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message);
return emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)
.map(|_| code_window_status);
};
let primary_lo = sm.lookup_char_pos(primary_span.lo());
if let Ok(pos) =
@ -1589,6 +1591,9 @@ impl HumanEmitter {
annotated_files.swap(0, pos);
}
// An end column separator should be emitted when a file with with a
// source, is followed by one without a source
let mut col_sep_before_no_show_source = false;
let annotated_files_len = annotated_files.len();
// Print out the annotate source lines that correspond with the error
for (file_idx, annotated_file) in annotated_files.into_iter().enumerate() {
@ -1599,6 +1604,26 @@ impl HumanEmitter {
&annotated_file.file,
) {
if !self.short_message {
// Add an end column separator when a file without a source
// comes after one with a source
// ╭▸ $DIR/deriving-meta-unknown-trait.rs:1:10
// │
// LL │ #[derive(Eqr)]
// │ ━━━
// ╰╴ (<- It prints *this* line)
// ╭▸ $SRC_DIR/core/src/cmp.rs:356:0
// │
// ╰╴note: similarly named derive macro `Eq` defined here
if col_sep_before_no_show_source {
let buffer_msg_line_offset = buffer.num_lines();
self.draw_col_separator_end(
&mut buffer,
buffer_msg_line_offset,
max_line_num_len + 1,
);
}
col_sep_before_no_show_source = false;
// We'll just print an unannotated message.
for (annotation_id, line) in annotated_file.lines.iter().enumerate() {
let mut annotations = line.annotations.clone();
@ -1639,29 +1664,42 @@ impl HumanEmitter {
}
line_idx += 1;
}
for (label, is_primary) in labels.into_iter() {
if is_cont
&& file_idx == annotated_files_len - 1
&& annotation_id == annotated_file.lines.len() - 1
&& !labels.is_empty()
{
code_window_status = CodeWindowStatus::Closed;
}
let labels_len = labels.len();
for (label_idx, (label, is_primary)) in labels.into_iter().enumerate() {
let style = if is_primary {
Style::LabelPrimary
} else {
Style::LabelSecondary
};
let pipe = self.col_separator();
buffer.prepend(line_idx, &format!(" {pipe}"), Style::LineNumber);
for _ in 0..max_line_num_len {
buffer.prepend(line_idx, " ", Style::NoStyle);
}
self.draw_col_separator_no_space(
&mut buffer,
line_idx,
max_line_num_len + 1,
);
line_idx += 1;
let chr = self.note_separator();
buffer.append(line_idx, &format!(" {chr} note: "), style);
for _ in 0..max_line_num_len {
buffer.prepend(line_idx, " ", Style::NoStyle);
}
self.draw_note_separator(
&mut buffer,
line_idx,
max_line_num_len + 1,
label_idx != labels_len - 1,
);
buffer.append(line_idx, "note", Style::MainHeaderMsg);
buffer.append(line_idx, ": ", Style::NoStyle);
buffer.append(line_idx, label, style);
line_idx += 1;
}
}
}
continue;
} else {
col_sep_before_no_show_source = true;
}
// print out the span location and spacer before we print the annotated source
@ -1976,7 +2014,7 @@ impl HumanEmitter {
// final step: take our styled buffer, render it, then output it
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
Ok(())
Ok(code_window_status)
}
fn column_width(&self, code_offset: usize) -> usize {
@ -2491,7 +2529,7 @@ impl HumanEmitter {
!children.is_empty()
|| suggestions.iter().any(|s| s.style != SuggestionStyle::CompletelyHidden),
) {
Ok(()) => {
Ok(code_window_status) => {
if !children.is_empty()
|| suggestions.iter().any(|s| s.style != SuggestionStyle::CompletelyHidden)
{
@ -2502,7 +2540,7 @@ impl HumanEmitter {
{
// We'll continue the vertical bar to point into the next note.
self.draw_col_separator_no_space(&mut buffer, 0, max_line_num_len + 1);
} else {
} else if matches!(code_window_status, CodeWindowStatus::Open) {
// We'll close the vertical bar to visually end the code window.
self.draw_col_separator_end(&mut buffer, 0, max_line_num_len + 1);
}
@ -2829,10 +2867,11 @@ impl HumanEmitter {
}
}
fn note_separator(&self) -> char {
fn note_separator(&self, is_cont: bool) -> &'static str {
match self.theme {
OutputTheme::Ascii => '=',
OutputTheme::Unicode => '╰',
OutputTheme::Ascii => "= ",
OutputTheme::Unicode if is_cont => "",
OutputTheme::Unicode => "",
}
}
@ -2945,11 +2984,7 @@ impl HumanEmitter {
col: usize,
is_cont: bool,
) {
let chr = match self.theme {
OutputTheme::Ascii => "= ",
OutputTheme::Unicode if is_cont => "",
OutputTheme::Unicode => "",
};
let chr = self.note_separator(is_cont);
buffer.puts(line, col, chr, Style::LineNumber);
}
@ -3050,6 +3085,12 @@ enum DisplaySuggestion {
Add,
}
#[derive(Clone, Copy, Debug)]
enum CodeWindowStatus {
Closed,
Open,
}
impl FileWithAnnotatedLines {
/// Preprocess all the annotations so that they are grouped by file and by line number
/// This helps us quickly iterate over the whole message (including secondary file spans)

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.
///
/// ## Overview
@ -418,6 +532,9 @@ pub enum AttributeKind {
/// Represents `#[inline]` and `#[rustc_force_inline]`.
Inline(InlineAttr, Span),
/// Represents `#[link]`.
Link(ThinVec<LinkEntry>, Span),
/// Represents `#[link_name]`.
LinkName { name: Symbol, span: Span },

View file

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

View file

@ -8,6 +8,7 @@ use rustc_abi::Align;
use rustc_data_structures::profiling::TimePassesFormat;
use rustc_errors::emitter::HumanReadableErrorType;
use rustc_errors::{ColorConfig, registry};
use rustc_hir::attrs::NativeLibKind;
use rustc_session::config::{
AutoDiff, BranchProtection, CFGuard, Cfg, CollapseMacroDebuginfo, CoverageLevel,
CoverageOptions, DebugInfo, DumpMonoStatsFormat, ErrorOutputType, ExternEntry, ExternLocation,
@ -20,7 +21,7 @@ use rustc_session::config::{
};
use rustc_session::lint::Level;
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_span::edition::{DEFAULT_EDITION, Edition};
use rustc_span::source_map::{RealFileLoader, SourceMapInputs};

View file

@ -1554,7 +1554,7 @@ impl<'a> LintDiagnostic<'a, ()> for DropGlue<'_> {
#[help(lint_help_exposed_provenance)]
pub(crate) struct IntegerToPtrTransmutes<'tcx> {
#[subdiagnostic]
pub suggestion: IntegerToPtrTransmutesSuggestion<'tcx>,
pub suggestion: Option<IntegerToPtrTransmutesSuggestion<'tcx>>,
}
#[derive(Subdiagnostic)]

View file

@ -169,19 +169,25 @@ fn check_int_to_ptr_transmute<'tcx>(
expr.hir_id,
expr.span,
IntegerToPtrTransmutes {
suggestion: if dst.is_ref() {
IntegerToPtrTransmutesSuggestion::ToRef {
dst: *inner_ty,
suffix,
ref_mutbl: mutbl.prefix_str(),
start_call: expr.span.shrink_to_lo().until(arg.span),
}
suggestion: if layout_inner_ty.is_sized() {
Some(if dst.is_ref() {
IntegerToPtrTransmutesSuggestion::ToRef {
dst: *inner_ty,
suffix,
ref_mutbl: mutbl.prefix_str(),
start_call: expr.span.shrink_to_lo().until(arg.span),
}
} else {
IntegerToPtrTransmutesSuggestion::ToPtr {
dst: *inner_ty,
suffix,
start_call: expr.span.shrink_to_lo().until(arg.span),
}
})
} else {
IntegerToPtrTransmutesSuggestion::ToPtr {
dst: *inner_ty,
suffix,
start_call: expr.span.shrink_to_lo().until(arg.span),
}
// We can't suggest using `with_exposed_provenance` for unsized type
// so don't suggest anything.
None
},
},
);

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 =
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
@ -11,9 +8,6 @@ metadata_bad_panic_strategy =
metadata_binary_output_to_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 =
can't find crate for `{$crate_name}`{$add_info}
@ -60,10 +54,6 @@ metadata_crate_not_panic_runtime =
metadata_dl_error =
{$path}{$err}
metadata_empty_link_name =
link name must not be empty
.label = empty link name
metadata_empty_renaming_target =
an empty renaming target was specified for library `{$lib_name}`
@ -108,15 +98,6 @@ metadata_full_metadata_not_found =
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
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 =
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}`
.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
metadata_incompatible_wasm_link =
`wasm_import_module` is incompatible with other arguments in `#[link]` attributes
metadata_install_missing_components =
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 =
found invalid metadata files for crate `{$crate_name}`{$add_info}
@ -164,67 +140,18 @@ metadata_lib_framework_apple =
metadata_lib_required =
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 =
`#[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 =
could not find native static library `{$libname}`, perhaps an -L flag is missing?
metadata_multiple_candidates =
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 =
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 =
found possibly newer version of crate `{$crate_name}`{$add_info}
.note = perhaps that crate needs to be recompiled?
@ -263,15 +190,6 @@ metadata_prev_alloc_error_handler =
metadata_prev_global_alloc =
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 =
ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
@ -307,19 +225,6 @@ metadata_target_not_installed =
metadata_two_panic_runtimes =
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_wasm_c_abi =

View file

@ -83,187 +83,6 @@ pub struct IncompatiblePanicInDropStrategy {
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)]
#[diag(metadata_link_ordinal_raw_dylib)]
pub struct LinkOrdinalRawDylib {
@ -706,42 +525,6 @@ pub struct LibFilenameForm<'a> {
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)]
#[diag(metadata_wasm_c_abi)]
pub(crate) struct WasmCAbi {

View file

@ -3,25 +3,21 @@ use std::path::{Path, PathBuf};
use rustc_abi::ExternAbi;
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_hir::attrs::AttributeKind;
use rustc_hir::attrs::{AttributeKind, NativeLibKind, PeImportNameType};
use rustc_hir::find_attr;
use rustc_middle::query::LocalCrate;
use rustc_middle::ty::{self, List, Ty, TyCtxt};
use rustc_session::Session;
use rustc_session::config::CrateType;
use rustc_session::cstore::{
DllCallingConvention, DllImport, ForeignModule, NativeLib, PeImportNameType,
};
use rustc_session::parse::feature_err;
use rustc_session::cstore::{DllCallingConvention, DllImport, ForeignModule, NativeLib};
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::{Symbol, sym};
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,
/// 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 {
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,
}
}
@ -213,289 +211,23 @@ impl<'tcx> Collector<'tcx> {
return;
}
// Process all of the #[link(..)]-style arguments
let features = self.tcx.features();
for m in self.tcx.get_attrs(def_id, sym::link) {
let Some(items) = m.meta_item_list() else {
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
} else if sess.target.binary_format == BinaryFormat::Elf
&& 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()
.map(|&child_item| {
self.build_dll_import(
abi,
import_name_type.map(|(import_name_type, _)| import_name_type),
child_item,
)
})
.collect()
}
for attr in
find_attr!(self.tcx.get_all_attrs(def_id), AttributeKind::Link(links, _) => links)
.iter()
.map(|v| v.iter())
.flatten()
{
let dll_imports = match attr.kind {
NativeLibKind::RawDylib => foreign_items
.iter()
.map(|&child_item| {
self.build_dll_import(
abi,
attr.import_name_type.map(|(import_name_type, _)| import_name_type),
child_item,
)
})
.collect(),
_ => {
for &child_item in foreign_items {
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(name, verbatim, kind, cfg.is_some(), self.tcx);
let filename = find_bundled_library(
attr.name,
attr.verbatim,
attr.kind,
attr.cfg.is_some(),
self.tcx,
);
self.libs.push(NativeLib {
name,
name: attr.name,
filename,
kind,
cfg,
kind: attr.kind,
cfg: attr.cfg.clone(),
foreign_module: Some(def_id.to_def_id()),
verbatim,
verbatim: attr.verbatim,
dll_imports,
});
}

View file

@ -200,6 +200,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
&Attribute::Parsed(AttributeKind::Sanitize { on_set, off_set, span: attr_span}) => {
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(
AttributeKind::BodyStability { .. }
| AttributeKind::ConstStabilityIndirect
@ -305,7 +308,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
[sym::rustc_has_incoherent_inherent_impls, ..] => {
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::autodiff_forward, ..] | [sym::autodiff_reverse, ..] => {
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.
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
&& let hir::Node::Item(item) = self.tcx.hir_node(hir_id)
&& let Item { kind: ItemKind::ForeignMod { abi, .. }, .. } = item
@ -1336,7 +1338,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
self.tcx.emit_node_span_lint(
UNUSED_ATTRIBUTES,
hir_id,
attr.span(),
attr_span,
errors::Link { span: (target != Target::ForeignMod).then_some(span) },
);
}

View file

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

View file

@ -6,8 +6,8 @@ use std::any::Any;
use std::path::PathBuf;
use rustc_abi::ExternAbi;
use rustc_ast as ast;
use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock};
use rustc_hir::attrs::{CfgEntry, NativeLibKind, PeImportNameType};
use rustc_hir::def_id::{
CrateNum, DefId, LOCAL_CRATE, LocalDefId, StableCrateId, StableCrateIdMap,
};
@ -16,7 +16,6 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::{Span, Symbol};
use crate::search_paths::PathKind;
use crate::utils::NativeLibKind;
// lonely orphan structs and enums looking for a better home
@ -72,7 +71,7 @@ pub struct NativeLib {
pub name: Symbol,
/// If packed_bundled_libs enabled, actual filename of library is stored.
pub filename: Option<Symbol>,
pub cfg: Option<ast::MetaItemInner>,
pub cfg: Option<CfgEntry>,
pub foreign_module: Option<DefId>,
pub verbatim: Option<bool>,
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)]
pub struct DllImport {
pub name: Symbol,

View file

@ -3,6 +3,7 @@ use std::sync::OnceLock;
use rustc_data_structures::profiling::VerboseTimingGuard;
use rustc_fs_util::try_canonicalize;
use rustc_hir::attrs::NativeLibKind;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
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(HashStable_Generic)]
pub struct NativeLib {

View file

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

View file

@ -267,39 +267,29 @@ pub const unsafe fn assert_unchecked(cond: bool) {
#[inline(always)]
#[stable(feature = "renamed_spin_loop", since = "1.49.0")]
pub fn spin_loop() {
#[cfg(target_arch = "x86")]
{
// SAFETY: the `cfg` attr ensures that we only execute this on x86 targets.
unsafe { crate::arch::x86::_mm_pause() };
}
#[cfg(target_arch = "x86_64")]
{
// SAFETY: the `cfg` attr ensures that we only execute this on x86_64 targets.
unsafe { crate::arch::x86_64::_mm_pause() };
}
#[cfg(target_arch = "riscv32")]
{
crate::arch::riscv32::pause();
}
#[cfg(target_arch = "riscv64")]
{
crate::arch::riscv64::pause();
}
#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))]
{
// SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) };
}
#[cfg(all(target_arch = "arm", target_feature = "v6"))]
{
// SAFETY: the `cfg` attr ensures that we only execute this on arm targets
// with support for the v6 feature.
unsafe { crate::arch::arm::__yield() };
crate::cfg_select! {
target_arch = "x86" => {
// SAFETY: the `cfg` attr ensures that we only execute this on x86 targets.
unsafe { crate::arch::x86::_mm_pause() }
}
target_arch = "x86_64" => {
// SAFETY: the `cfg` attr ensures that we only execute this on x86_64 targets.
unsafe { crate::arch::x86_64::_mm_pause() }
}
target_arch = "riscv32" => crate::arch::riscv32::pause(),
target_arch = "riscv64" => crate::arch::riscv64::pause(),
any(target_arch = "aarch64", target_arch = "arm64ec") => {
// SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) }
}
all(target_arch = "arm", target_feature = "v6") => {
// SAFETY: the `cfg` attr ensures that we only execute this on arm targets
// with support for the v6 feature.
unsafe { crate::arch::arm::__yield() }
}
target_arch = "loongarch32" => crate::arch::loongarch32::ibar::<0>(),
target_arch = "loongarch64" => crate::arch::loongarch64::ibar::<0>(),
_ => { /* do nothing */ }
}
}

View file

@ -39,7 +39,7 @@ use crate::ptr::NonNull;
pub struct Location<'a> {
// A raw pointer is used rather than a reference because the pointer is valid for one more byte
// than the length stored in this pointer; the additional byte is the NUL-terminator used by
// `Location::file_with_nul`.
// `Location::file_as_c_str`.
filename: NonNull<str>,
line: u32,
col: u32,
@ -195,7 +195,7 @@ impl<'a> Location<'a> {
#[must_use]
#[unstable(feature = "file_with_nul", issue = "141727")]
#[inline]
pub const fn file_with_nul(&self) -> &'a CStr {
pub const fn file_as_c_str(&self) -> &'a CStr {
let filename = self.filename.as_ptr();
// SAFETY: The filename is valid for `filename_len+1` bytes, so this addition can't

View file

@ -3072,7 +3072,7 @@ impl str {
/// for example references to `Box<str>` or `Arc<str>`.
#[inline]
#[unstable(feature = "str_as_str", issue = "130366")]
pub fn as_str(&self) -> &str {
pub const fn as_str(&self) -> &str {
self
}
}

View file

@ -16,12 +16,15 @@
//! The crate itself provides a global allocator which on wasm has no
//! synchronization as there are no threads!
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
#![allow(static_mut_refs)]
use core::cell::SyncUnsafeCell;
use crate::alloc::{GlobalAlloc, Layout, System};
static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::Dlmalloc::new();
struct SyncDlmalloc(dlmalloc::Dlmalloc);
unsafe impl Sync for SyncDlmalloc {}
static DLMALLOC: SyncUnsafeCell<SyncDlmalloc> =
SyncUnsafeCell::new(SyncDlmalloc(dlmalloc::Dlmalloc::new()));
#[stable(feature = "alloc_system_type", since = "1.28.0")]
unsafe impl GlobalAlloc for System {
@ -30,7 +33,7 @@ unsafe impl GlobalAlloc for System {
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling malloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.malloc(layout.size(), layout.align()) }
unsafe { (*DLMALLOC.get()).0.malloc(layout.size(), layout.align()) }
}
#[inline]
@ -38,7 +41,7 @@ unsafe impl GlobalAlloc for System {
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling calloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.calloc(layout.size(), layout.align()) }
unsafe { (*DLMALLOC.get()).0.calloc(layout.size(), layout.align()) }
}
#[inline]
@ -46,7 +49,7 @@ unsafe impl GlobalAlloc for System {
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling free() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.free(ptr, layout.size(), layout.align()) }
unsafe { (*DLMALLOC.get()).0.free(ptr, layout.size(), layout.align()) }
}
#[inline]
@ -54,7 +57,7 @@ unsafe impl GlobalAlloc for System {
// SAFETY: DLMALLOC access is guaranteed to be safe because the lock gives us unique and non-reentrant access.
// Calling realloc() is safe because preconditions on this function match the trait method preconditions.
let _lock = lock::lock();
unsafe { DLMALLOC.realloc(ptr, layout.size(), layout.align(), new_size) }
unsafe { (*DLMALLOC.get()).0.realloc(ptr, layout.size(), layout.align(), new_size) }
}
}

View file

@ -2025,8 +2025,6 @@ HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}
cmd.arg("--verbose");
}
cmd.arg("--json");
if builder.config.rustc_debug_assertions {
cmd.arg("--with-rustc-debug-assertions");
}

View file

@ -8,7 +8,7 @@ use camino::{Utf8Path, Utf8PathBuf};
use semver::Version;
use serde::de::{Deserialize, Deserializer, Error as _};
use crate::executor::{ColorConfig, OutputFormat};
use crate::executor::ColorConfig;
use crate::fatal;
use crate::util::{Utf8PathBufExt, add_dylib_path, string_enum};
@ -565,13 +565,6 @@ pub struct Config {
/// FIXME: this is *way* too coarse; the user can't select *which* info to verbosely dump.
pub verbose: bool,
/// (Useless) Adjust libtest output format.
///
/// FIXME: the hand-rolled executor does not support non-JSON output, because `compiletest` need
/// to package test outcome as `libtest`-esque JSON that `bootstrap` can intercept *anyway*.
/// However, now that we don't use the `libtest` executor, this is useless.
pub format: OutputFormat,
/// Whether to use colors in test output.
///
/// Note: the exact control mechanism is delegated to [`colored`].
@ -768,7 +761,6 @@ impl Config {
adb_device_status: Default::default(),
lldb_python_dir: Default::default(),
verbose: Default::default(),
format: Default::default(),
color: Default::default(),
remote_test_client: Default::default(),
compare_mode: Default::default(),

View file

@ -1,5 +1,9 @@
//! This module contains a reimplementation of the subset of libtest
//! functionality needed by compiletest.
//!
//! FIXME(Zalathar): Much of this code was originally designed to mimic libtest
//! as closely as possible, for ease of migration. Now that libtest is no longer
//! used, we can potentially redesign things to be a better fit for compiletest.
use std::borrow::Cow;
use std::collections::HashMap;
@ -207,7 +211,7 @@ impl TestOutcome {
///
/// Adapted from `filter_tests` in libtest.
///
/// FIXME(#139660): After the libtest dependency is removed, redesign the whole filtering system to
/// FIXME(#139660): Now that libtest has been removed, redesign the whole filtering system to
/// do a better job of understanding and filtering _paths_, instead of being tied to libtest's
/// substring/exact matching behaviour.
fn filter_tests(opts: &Config, tests: Vec<CollectedTest>) -> Vec<CollectedTest> {
@ -249,7 +253,7 @@ fn get_concurrency() -> usize {
}
}
/// Information needed to create a `test::TestDescAndFn`.
/// Information that was historically needed to create a libtest `TestDescAndFn`.
pub(crate) struct CollectedTest {
pub(crate) desc: CollectedTestDesc,
pub(crate) config: Arc<Config>,
@ -257,7 +261,7 @@ pub(crate) struct CollectedTest {
pub(crate) revision: Option<String>,
}
/// Information needed to create a `test::TestDesc`.
/// Information that was historically needed to create a libtest `TestDesc`.
pub(crate) struct CollectedTestDesc {
pub(crate) name: String,
pub(crate) ignore: bool,
@ -274,18 +278,6 @@ pub enum ColorConfig {
NeverColor,
}
/// Format of the test results output.
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub enum OutputFormat {
/// Verbose output
Pretty,
/// Quiet output
#[default]
Terse,
/// JSON output
Json,
}
/// Whether test is expected to panic or not.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub(crate) enum ShouldPanic {

View file

@ -43,7 +43,7 @@ use crate::common::{
expected_output_path, output_base_dir, output_relative_path,
};
use crate::directives::DirectivesCache;
use crate::executor::{CollectedTest, ColorConfig, OutputFormat};
use crate::executor::{CollectedTest, ColorConfig};
use crate::util::logv;
/// Creates the `Config` instance for this invocation of compiletest.
@ -137,9 +137,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
"overwrite stderr/stdout files instead of complaining about a mismatch",
)
.optflag("", "fail-fast", "stop as soon as possible after any test fails")
.optflag("", "quiet", "print one character per test instead of one line")
.optopt("", "color", "coloring: auto, always, never", "WHEN")
.optflag("", "json", "emit json output instead of plaintext output")
.optopt("", "target", "the target to build for", "TARGET")
.optopt("", "host", "the host to build for", "HOST")
.optopt("", "cdb", "path to CDB to use for CDB debuginfo tests", "PATH")
@ -203,7 +201,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
"COMMAND",
)
.reqopt("", "minicore-path", "path to minicore aux library", "PATH")
.optflag("N", "no-new-executor", "disables the new test executor, and uses libtest instead")
.optopt(
"",
"debugger",
@ -436,12 +433,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
&& !opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
lldb_python_dir: matches.opt_str("lldb-python-dir"),
verbose: matches.opt_present("verbose"),
format: match (matches.opt_present("quiet"), matches.opt_present("json")) {
(true, true) => panic!("--quiet and --json are incompatible"),
(true, false) => OutputFormat::Terse,
(false, true) => OutputFormat::Json,
(false, false) => OutputFormat::Pretty,
},
only_modified: matches.opt_present("only-modified"),
color,
remote_test_client: matches.opt_str("remote-test-client").map(Utf8PathBuf::from),
@ -527,7 +518,6 @@ pub fn log_config(config: &Config) {
logv(c, format!("target-linker: {:?}", config.target_linker));
logv(c, format!("host-linker: {:?}", config.host_linker));
logv(c, format!("verbose: {}", config.verbose));
logv(c, format!("format: {:?}", config.format));
logv(c, format!("minicore_path: {}", config.minicore_path));
logv(c, "\n".to_string());
}
@ -601,7 +591,7 @@ pub fn run_tests(config: Arc<Config>) {
configs.push(config.clone());
};
// Discover all of the tests in the test suite directory, and build a libtest
// Discover all of the tests in the test suite directory, and build a `CollectedTest`
// structure for each test (or each revision of a multi-revision test).
let mut tests = Vec::new();
for c in configs {
@ -613,50 +603,35 @@ pub fn run_tests(config: Arc<Config>) {
// Delegate to the executor to filter and run the big list of test structures
// created during test discovery. When the executor decides to run a test,
// it will return control to the rest of compiletest by calling `runtest::run`.
// FIXME(Zalathar): Once we're confident that we won't need to revert the
// removal of the libtest-based executor, remove this Result and other
// remnants of the old executor.
let res: io::Result<bool> = Ok(executor::run_tests(&config, tests));
let ok = executor::run_tests(&config, tests);
// Check the outcome reported by libtest.
match res {
Ok(true) => {}
Ok(false) => {
// We want to report that the tests failed, but we also want to give
// some indication of just what tests we were running. Especially on
// CI, where there can be cross-compiled tests for a lot of
// architectures, without this critical information it can be quite
// easy to miss which tests failed, and as such fail to reproduce
// the failure locally.
// Check the outcome reported by the executor.
if !ok {
// We want to report that the tests failed, but we also want to give
// some indication of just what tests we were running. Especially on
// CI, where there can be cross-compiled tests for a lot of
// architectures, without this critical information it can be quite
// easy to miss which tests failed, and as such fail to reproduce
// the failure locally.
let mut msg = String::from("Some tests failed in compiletest");
write!(msg, " suite={}", config.suite).unwrap();
let mut msg = String::from("Some tests failed in compiletest");
write!(msg, " suite={}", config.suite).unwrap();
if let Some(compare_mode) = config.compare_mode.as_ref() {
write!(msg, " compare_mode={}", compare_mode).unwrap();
}
if let Some(pass_mode) = config.force_pass_mode.as_ref() {
write!(msg, " pass_mode={}", pass_mode).unwrap();
}
write!(msg, " mode={}", config.mode).unwrap();
write!(msg, " host={}", config.host).unwrap();
write!(msg, " target={}", config.target).unwrap();
println!("{msg}");
std::process::exit(1);
if let Some(compare_mode) = config.compare_mode.as_ref() {
write!(msg, " compare_mode={}", compare_mode).unwrap();
}
Err(e) => {
// We don't know if tests passed or not, but if there was an error
// during testing we don't want to just succeed (we may not have
// tested something), so fail.
//
// This should realistically "never" happen, so don't try to make
// this a pretty error message.
panic!("I/O failure during tests: {:?}", e);
if let Some(pass_mode) = config.force_pass_mode.as_ref() {
write!(msg, " pass_mode={}", pass_mode).unwrap();
}
write!(msg, " mode={}", config.mode).unwrap();
write!(msg, " host={}", config.host).unwrap();
write!(msg, " target={}", config.target).unwrap();
println!("{msg}");
std::process::exit(1);
}
}
@ -691,7 +666,11 @@ impl TestCollector {
///
/// This always inspects _all_ test files in the suite (e.g. all 17k+ ui tests),
/// regardless of whether any filters/tests were specified on the command-line,
/// because filtering is handled later by libtest.
/// because filtering is handled later by code that was copied from libtest.
///
/// FIXME(Zalathar): Now that we no longer rely on libtest, try to overhaul
/// test discovery to take into account the filters/tests specified on the
/// command-line, instead of having to enumerate everything.
pub(crate) fn collect_and_make_tests(config: Arc<Config>) -> Vec<CollectedTest> {
debug!("making tests from {}", config.src_test_suite_root);
let common_inputs_stamp = common_inputs_stamp(&config);
@ -805,7 +784,7 @@ fn modified_tests(config: &Config, dir: &Utf8Path) -> Result<Vec<Utf8PathBuf>, S
}
/// Recursively scans a directory to find test files and create test structures
/// that will be handed over to libtest.
/// that will be handed over to the executor.
fn collect_tests_from_dir(
cx: &TestCollectorCx,
dir: &Utf8Path,
@ -871,7 +850,7 @@ fn collect_tests_from_dir(
if is_test(file_name)
&& (!cx.config.only_modified || cx.modified_tests.contains(&file_path))
{
// We found a test file, so create the corresponding libtest structures.
// We found a test file, so create the corresponding test structures.
debug!(%file_path, "found test file");
// Record the stem of the test file, to check for overlaps later.
@ -915,7 +894,7 @@ pub fn is_test(file_name: &str) -> bool {
}
/// For a single test file, creates one or more test structures (one per revision) that can be
/// handed over to libtest to run, possibly in parallel.
/// handed over to the executor to run, possibly in parallel.
fn make_test(cx: &TestCollectorCx, collector: &mut TestCollector, testpaths: &TestPaths) {
// For run-make tests, each "test file" is actually a _directory_ containing an `rmake.rs`. But
// for the purposes of directive parsing, we want to look at that recipe file, not the directory
@ -929,7 +908,7 @@ fn make_test(cx: &TestCollectorCx, collector: &mut TestCollector, testpaths: &Te
// Scan the test file to discover its revisions, if any.
let early_props = EarlyProps::from_file(&cx.config, &test_path);
// Normally we create one libtest structure per revision, with two exceptions:
// Normally we create one structure per revision, with two exceptions:
// - If a test doesn't use revisions, create a dummy revision (None) so that
// the test can still run.
// - Incremental tests inherently can't run their revisions in parallel, so
@ -944,12 +923,12 @@ fn make_test(cx: &TestCollectorCx, collector: &mut TestCollector, testpaths: &Te
// For each revision (or the sole dummy revision), create and append a
// `CollectedTest` that can be handed over to the test executor.
collector.tests.extend(revisions.into_iter().map(|revision| {
// Create a test name and description to hand over to libtest.
// Create a test name and description to hand over to the executor.
let src_file = fs::File::open(&test_path).expect("open test file to parse ignores");
let test_name = make_test_name(&cx.config, testpaths, revision);
// Create a libtest description for the test/revision.
// Create a description struct for the test/revision.
// This is where `ignore-*`/`only-*`/`needs-*` directives are handled,
// because they need to set the libtest ignored flag.
// because they historically needed to set the libtest ignored flag.
let mut desc = make_test_description(
&cx.config,
&cx.cache,
@ -961,10 +940,12 @@ fn make_test(cx: &TestCollectorCx, collector: &mut TestCollector, testpaths: &Te
);
// If a test's inputs haven't changed since the last time it ran,
// mark it as ignored so that libtest will skip it.
// mark it as ignored so that the executor will skip it.
if !cx.config.force_rerun && is_up_to_date(cx, testpaths, &early_props, revision) {
desc.ignore = true;
// Keep this in sync with the "up-to-date" message detected by bootstrap.
// FIXME(Zalathar): Now that we are no longer tied to libtest, we could
// find a less fragile way to communicate this status to bootstrap.
desc.ignore_message = Some("up-to-date".into());
}
@ -1104,7 +1085,7 @@ impl Stamp {
}
}
/// Creates a name for this test/revision that can be handed over to libtest.
/// Creates a name for this test/revision that can be handed over to the executor.
fn make_test_name(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> String {
// Print the name of the file, relative to the sources root.
let path = testpaths.file.strip_prefix(&config.src_root).unwrap();

View file

@ -2222,7 +2222,7 @@ impl<'test> TestCx<'test> {
.env("PAGER", "")
.stdin(File::open(&diff_filename).unwrap())
// Capture output and print it explicitly so it will in turn be
// captured by libtest.
// captured by output-capture.
.output()
.unwrap();
assert!(output.status.success());

View file

@ -308,7 +308,7 @@ impl TestCx<'_> {
let stdout = String::from_utf8_lossy(&stdout).into_owned();
let stderr = String::from_utf8_lossy(&stderr).into_owned();
// This conditions on `status.success()` so we don't print output twice on error.
// NOTE: this code is called from a libtest thread, so it's hidden by default unless --nocapture is passed.
// NOTE: this code is called from an executor thread, so it's hidden by default unless --no-capture is passed.
self.dump_output(status.success(), &cmd.get_program().to_string_lossy(), &stdout, &stderr);
if !status.success() {
let res = ProcRes { status, stdout, stderr, truncated, cmdline: format!("{:?}", cmd) };

View file

@ -287,14 +287,12 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
"gimli",
"gsgdt",
"hashbrown",
"icu_collections",
"icu_list",
"icu_list_data",
"icu_locid",
"icu_locid_transform",
"icu_locid_transform_data",
"icu_locale",
"icu_locale_core",
"icu_locale_data",
"icu_provider",
"icu_provider_adapters",
"icu_provider_macros",
"ident_case",
"indexmap",
"intl-memoizer",
@ -332,6 +330,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
"polonius-engine",
"portable-atomic", // dependency for platforms doesn't support `AtomicU64` in std
"portable-atomic-util",
"potential_utf",
"ppv-lite86",
"proc-macro-hack",
"proc-macro2",
@ -447,6 +446,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
"zerocopy-derive",
"zerofrom",
"zerofrom-derive",
"zerotrie",
"zerovec",
"zerovec-derive",
// tidy-alphabetical-end

View file

@ -2,8 +2,9 @@
//@ needs-rustc-debug-assertions
#![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" {
pub type CrossCrate;
}

View file

@ -25,6 +25,7 @@ error[E0599]: no method named `poll` found for struct `Pin<&mut impl Future<Outp
|
LL | match fut.as_mut().poll(ctx) {
| ^^^^ method not found in `Pin<&mut impl Future<Output = ()>>`
|
--> $SRC_DIR/core/src/future/future.rs:LL:COL
|
= note: the method is available for `Pin<&mut impl Future<Output = ()>>` here

View file

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

View file

@ -1,5 +1,5 @@
error[E0539]: malformed `cfg` attribute input
--> $DIR/malformed-attrs.rs:102:1
--> $DIR/malformed-attrs.rs:101:1
|
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>
error: malformed `cfg_attr` attribute input
--> $DIR/malformed-attrs.rs:104:1
--> $DIR/malformed-attrs.rs:103:1
|
LL | #[cfg_attr]
| ^^^^^^^^^^^
@ -22,7 +22,7 @@ LL | #[cfg_attr(condition, attribute, other_attribute, ...)]
| ++++++++++++++++++++++++++++++++++++++++++++
error[E0463]: can't find crate for `wloop`
--> $DIR/malformed-attrs.rs:211:1
--> $DIR/malformed-attrs.rs:210:1
|
LL | extern crate wloop;
| ^^^^^^^^^^^^^^^^^^^ can't find crate
@ -42,7 +42,7 @@ LL | #![windows_subsystem = "windows"]
| +++++++++++
error: malformed `instruction_set` attribute input
--> $DIR/malformed-attrs.rs:106:1
--> $DIR/malformed-attrs.rs:105:1
|
LL | #[instruction_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>
error: malformed `patchable_function_entry` attribute input
--> $DIR/malformed-attrs.rs:108:1
--> $DIR/malformed-attrs.rs:107:1
|
LL | #[patchable_function_entry]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]`
error: malformed `must_not_suspend` attribute input
--> $DIR/malformed-attrs.rs:132:1
--> $DIR/malformed-attrs.rs:131:1
|
LL | #[must_not_suspend()]
| ^^^^^^^^^^^^^^^^^^^^^
@ -71,13 +71,13 @@ LL + #[must_not_suspend]
|
error: malformed `cfi_encoding` attribute input
--> $DIR/malformed-attrs.rs:134:1
--> $DIR/malformed-attrs.rs:133:1
|
LL | #[cfi_encoding]
| ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]`
error: malformed `allow` attribute input
--> $DIR/malformed-attrs.rs:178:1
--> $DIR/malformed-attrs.rs:177:1
|
LL | #[allow]
| ^^^^^^^^
@ -93,7 +93,7 @@ LL | #[allow(lint1, lint2, lint3, reason = "...")]
| +++++++++++++++++++++++++++++++++++++
error: malformed `expect` attribute input
--> $DIR/malformed-attrs.rs:180:1
--> $DIR/malformed-attrs.rs:179:1
|
LL | #[expect]
| ^^^^^^^^^
@ -109,7 +109,7 @@ LL | #[expect(lint1, lint2, lint3, reason = "...")]
| +++++++++++++++++++++++++++++++++++++
error: malformed `warn` attribute input
--> $DIR/malformed-attrs.rs:182:1
--> $DIR/malformed-attrs.rs:181:1
|
LL | #[warn]
| ^^^^^^^
@ -125,7 +125,7 @@ LL | #[warn(lint1, lint2, lint3, reason = "...")]
| +++++++++++++++++++++++++++++++++++++
error: malformed `deny` attribute input
--> $DIR/malformed-attrs.rs:184:1
--> $DIR/malformed-attrs.rs:183:1
|
LL | #[deny]
| ^^^^^^^
@ -141,7 +141,7 @@ LL | #[deny(lint1, lint2, lint3, reason = "...")]
| +++++++++++++++++++++++++++++++++++++
error: malformed `forbid` attribute input
--> $DIR/malformed-attrs.rs:186:1
--> $DIR/malformed-attrs.rs:185:1
|
LL | #[forbid]
| ^^^^^^^^^
@ -157,7 +157,7 @@ LL | #[forbid(lint1, lint2, lint3, reason = "...")]
| +++++++++++++++++++++++++++++++++++++
error: malformed `debugger_visualizer` attribute input
--> $DIR/malformed-attrs.rs:188:1
--> $DIR/malformed-attrs.rs:187:1
|
LL | #[debugger_visualizer]
| ^^^^^^^^^^^^^^^^^^^^^^ 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>
error: malformed `thread_local` attribute input
--> $DIR/malformed-attrs.rs:203:1
--> $DIR/malformed-attrs.rs:202:1
|
LL | #[thread_local()]
| ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]`
error: malformed `no_link` attribute input
--> $DIR/malformed-attrs.rs:207:1
--> $DIR/malformed-attrs.rs:206:1
|
LL | #[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>
error: malformed `macro_export` attribute input
--> $DIR/malformed-attrs.rs:214:1
--> $DIR/malformed-attrs.rs:213:1
|
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
--> $DIR/malformed-attrs.rs:99:1
--> $DIR/malformed-attrs.rs:98:1
|
LL | #[proc_macro = 18]
| ^^^^^^^^^^^^^^^^^^
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]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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]
| ^^^^^^^^^^^^^^^^^^^^
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]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -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, 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
--> $DIR/malformed-attrs.rs:188:1
--> $DIR/malformed-attrs.rs:187:1
|
LL | #[debugger_visualizer]
| ^^^^^^^^^^^^^^^^^^^^^^
@ -494,8 +484,27 @@ LL | #[export_stable = 1]
| | didn't expect any arguments here
| 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
--> $DIR/malformed-attrs.rs:86:1
--> $DIR/malformed-attrs.rs:85:1
|
LL | #[link_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>
error[E0539]: malformed `link_section` attribute input
--> $DIR/malformed-attrs.rs:88:1
--> $DIR/malformed-attrs.rs:87:1
|
LL | #[link_section]
| ^^^^^^^^^^^^^^^ 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>
error[E0539]: malformed `coverage` attribute input
--> $DIR/malformed-attrs.rs:90:1
--> $DIR/malformed-attrs.rs:89:1
|
LL | #[coverage]
| ^^^^^^^^^^^ 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
--> $DIR/malformed-attrs.rs:92:1
--> $DIR/malformed-attrs.rs:91:1
|
LL | #[sanitize]
| ^^^^^^^^^^^ expected this to be a list
@ -542,7 +551,7 @@ LL | #[sanitize(kcfi = "on|off")]
= and 5 other candidates
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]
| ^^^^^^^^^^^^^^^^^^^^^^----^
@ -551,7 +560,7 @@ LL | #[no_implicit_prelude = 23]
| help: must be of the form: `#[no_implicit_prelude]`
error[E0565]: malformed `proc_macro` attribute input
--> $DIR/malformed-attrs.rs:99:1
--> $DIR/malformed-attrs.rs:98:1
|
LL | #[proc_macro = 18]
| ^^^^^^^^^^^^^----^
@ -560,7 +569,7 @@ LL | #[proc_macro = 18]
| help: must be of the form: `#[proc_macro]`
error[E0565]: malformed `coroutine` attribute input
--> $DIR/malformed-attrs.rs:111:5
--> $DIR/malformed-attrs.rs:110:5
|
LL | #[coroutine = 63] || {}
| ^^^^^^^^^^^^----^
@ -569,7 +578,7 @@ LL | #[coroutine = 63] || {}
| help: must be of the form: `#[coroutine]`
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]
| ^^^^^^^^^^^^^^^^^^^^^^^----^
@ -578,7 +587,7 @@ LL | #[proc_macro_attribute = 19]
| help: must be of the form: `#[proc_macro_attribute]`
error[E0539]: malformed `must_use` attribute input
--> $DIR/malformed-attrs.rs:119:1
--> $DIR/malformed-attrs.rs:118:1
|
LL | #[must_use = 1]
| ^^^^^^^^^^^^^-^
@ -596,7 +605,7 @@ LL + #[must_use]
|
error[E0539]: malformed `proc_macro_derive` attribute input
--> $DIR/malformed-attrs.rs:123:1
--> $DIR/malformed-attrs.rs:122:1
|
LL | #[proc_macro_derive]
| ^^^^^^^^^^^^^^^^^^^^ 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
--> $DIR/malformed-attrs.rs:128:1
--> $DIR/malformed-attrs.rs:127:1
|
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)]`
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]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -628,7 +637,7 @@ LL | #[rustc_layout_scalar_valid_range_end]
| help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]`
error[E0565]: malformed `marker` attribute input
--> $DIR/malformed-attrs.rs:155:1
--> $DIR/malformed-attrs.rs:154:1
|
LL | #[marker = 3]
| ^^^^^^^^^---^
@ -637,7 +646,7 @@ LL | #[marker = 3]
| help: must be of the form: `#[marker]`
error[E0565]: malformed `fundamental` attribute input
--> $DIR/malformed-attrs.rs:157:1
--> $DIR/malformed-attrs.rs:156:1
|
LL | #[fundamental()]
| ^^^^^^^^^^^^^--^
@ -646,7 +655,7 @@ LL | #[fundamental()]
| help: must be of the form: `#[fundamental]`
error[E0565]: malformed `ffi_pure` attribute input
--> $DIR/malformed-attrs.rs:165:5
--> $DIR/malformed-attrs.rs:164:5
|
LL | #[unsafe(ffi_pure = 1)]
| ^^^^^^^^^^^^^^^^^^---^^
@ -655,7 +664,7 @@ LL | #[unsafe(ffi_pure = 1)]
| help: must be of the form: `#[ffi_pure]`
error[E0539]: malformed `link_ordinal` attribute input
--> $DIR/malformed-attrs.rs:167:5
--> $DIR/malformed-attrs.rs:166:5
|
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>
error[E0565]: malformed `ffi_const` attribute input
--> $DIR/malformed-attrs.rs:171:5
--> $DIR/malformed-attrs.rs:170:5
|
LL | #[unsafe(ffi_const = 1)]
| ^^^^^^^^^^^^^^^^^^^---^^
@ -675,7 +684,7 @@ LL | #[unsafe(ffi_const = 1)]
| help: must be of the form: `#[ffi_const]`
error[E0539]: malformed `linkage` attribute input
--> $DIR/malformed-attrs.rs:173:5
--> $DIR/malformed-attrs.rs:172:5
|
LL | #[linkage]
| ^^^^^^^^^^ expected this to be of the form `linkage = "..."`
@ -693,7 +702,7 @@ LL | #[linkage = "external"]
= and 5 other candidates
error[E0565]: malformed `automatically_derived` attribute input
--> $DIR/malformed-attrs.rs:191:1
--> $DIR/malformed-attrs.rs:190:1
|
LL | #[automatically_derived = 18]
| ^^^^^^^^^^^^^^^^^^^^^^^^----^
@ -702,7 +711,7 @@ LL | #[automatically_derived = 18]
| help: must be of the form: `#[automatically_derived]`
error[E0565]: malformed `non_exhaustive` attribute input
--> $DIR/malformed-attrs.rs:197:1
--> $DIR/malformed-attrs.rs:196:1
|
LL | #[non_exhaustive = 1]
| ^^^^^^^^^^^^^^^^^---^
@ -711,13 +720,13 @@ LL | #[non_exhaustive = 1]
| help: must be of the form: `#[non_exhaustive]`
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]
| ^^^^^^^^^^^^^^^^
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]
| ^^^^^^^^^^^^^^^^^^^^^^^^---^
@ -726,7 +735,7 @@ LL | #[allow_internal_unsafe = 1]
| help: must be of the form: `#[allow_internal_unsafe]`
error[E0565]: malformed `type_const` attribute input
--> $DIR/malformed-attrs.rs:143:5
--> $DIR/malformed-attrs.rs:142:5
|
LL | #[type_const = 1]
| ^^^^^^^^^^^^^---^
@ -759,7 +768,7 @@ LL | #[repr]
| ^^^^^^^
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()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -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
warning: missing options for `on_unimplemented` attribute
--> $DIR/malformed-attrs.rs:138:1
--> $DIR/malformed-attrs.rs:137:1
|
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
warning: malformed `on_unimplemented` attribute
--> $DIR/malformed-attrs.rs:140:1
--> $DIR/malformed-attrs.rs:139:1
|
LL | #[diagnostic::on_unimplemented = 1]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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>
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()]
| ^^^^^^^^^^^
@ -801,7 +810,7 @@ LL | #[ignore()]
= 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]`
--> $DIR/malformed-attrs.rs:223:1
--> $DIR/malformed-attrs.rs:222: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>
error[E0308]: mismatched types
--> $DIR/malformed-attrs.rs:111:23
--> $DIR/malformed-attrs.rs:110:23
|
LL | fn test() {
| - help: a return type might be missing here: `-> _`
@ -818,7 +827,7 @@ LL | #[coroutine = 63] || {}
| ^^^^^ expected `()`, found coroutine
|
= 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
@ -848,18 +857,6 @@ LL | #[doc]
= 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
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:
error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]`
--> $DIR/malformed-attrs.rs:52:1
@ -873,7 +870,7 @@ LL | #[inline = 5]
Future breakage diagnostic:
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()]
| ^^^^^^^^^^^
@ -884,7 +881,7 @@ LL | #[ignore()]
Future breakage diagnostic:
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]
| ^^^^^^^^^^^^^

View file

@ -57,10 +57,10 @@ error[E0412]: cannot find type `F` in this scope
|
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
| ^
|
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|
LL | self , ... , self , self , ... ) where Fn : FnOnce ( & 'a & 'b usize ) {

View file

@ -9,10 +9,10 @@ error[E0412]: cannot find type `F` in this scope
|
LL | _func: F,
| ^
|
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|
LL | _func: Fn,

View file

@ -3,6 +3,7 @@ error[E0412]: cannot find type `n` in this scope
|
LL | type_ascribe!(2, n([u8; || 1]))
| ^ help: a trait with a similar name exists: `Fn`
|
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here

View file

@ -3,10 +3,10 @@ error[E0412]: cannot find type `F` in this scope
|
LL | let f: F = async { 1 };
| ^
|
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|
LL | let f: Fn = async { 1 };

View file

@ -6,6 +6,7 @@ LL | const FOO: &A = &A::Field(Cow::Borrowed("foo"));
...
LL | FOO => todo!(),
| ^^^ constant of non-structural type
|
--> $SRC_DIR/alloc/src/borrow.rs:LL:COL
|
= note: `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns

View file

@ -3,6 +3,7 @@ error: cannot find derive macro `Eqr` in this scope
|
LL | #[derive(Eqr)]
| ^^^ help: a derive macro with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named derive macro `Eq` defined here
@ -12,6 +13,7 @@ error: cannot find derive macro `Eqr` in this scope
|
LL | #[derive(Eqr)]
| ^^^ help: a derive macro with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named derive macro `Eq` defined here

View file

@ -3,6 +3,7 @@ error: cannot find macro `prinltn` in this scope
|
LL | prinltn!();
| ^^^^^^^ help: a macro with a similar name exists: `println`
|
--> $SRC_DIR/std/src/macros.rs:LL:COL
|
= note: similarly named macro `println` defined here

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
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
--> $DIR/E0458.rs:1:15
error[E0539]: malformed `link` attribute input
--> $DIR/E0458.rs:1:1
|
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
--> $DIR/E0458.rs:1:1
@ -12,5 +31,5 @@ LL | #[link(kind = "wonderful_unicorn")] extern "C" {}
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0458, E0459.
For more information about an error, try `rustc --explain E0458`.
Some errors have detailed explanations: E0459, E0539.
For more information about an error, try `rustc --explain E0459`.

View file

@ -69,7 +69,7 @@
//~| WARN previously accepted
//~| HELP can only be applied to
//~| 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
#![link_name = "1900"]
//~^ 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.
#[link()]
#[link(name = "x")]
//~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted
mod link {
//~^ NOTE not an `extern` block
mod inner { #![link()] }
mod inner { #![link(name = "x")] }
//~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted
//~| NOTE not an `extern` block
#[link()] fn f() { }
#[link(name = "x")] fn f() { }
//~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted
//~| NOTE not an `extern` block
#[link()] struct S;
#[link(name = "x")] struct S;
//~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted
//~| 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 this was previously accepted
//~| NOTE not an `extern` block
#[link()] impl S { }
#[link(name = "x")] impl S { }
//~^ WARN attribute should be applied to an `extern` block
//~| WARN this was previously accepted
//~| NOTE not an `extern` block
#[link()] extern "Rust" {}
#[link(name = "x")] extern "Rust" {}
//~^ WARN attribute should be applied to an `extern` block
//~| 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
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:695:1
|
LL | #[link()]
| ^^^^^^^^^
LL | #[link(name = "x")]
| ^^^^^^^^^^^^^^^^^^^
...
LL | / mod link {
LL | |
LL | |
LL | | mod inner { #![link()] }
LL | | mod inner { #![link(name = "x")] }
... |
LL | | }
| |_- 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
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1
|
LL | #![link()]
| ^^^^^^^^^^ not an `extern` block
LL | #![link(name = "x")]
| ^^^^^^^^^^^^^^^^^^^^ 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!
@ -462,48 +462,48 @@ LL | #![no_std] impl S { }
warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:701:17
|
LL | mod inner { #![link()] }
| ------------^^^^^^^^^^-- not an `extern` block
LL | mod inner { #![link(name = "x")] }
| ------------^^^^^^^^^^^^^^^^^^^^-- 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: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:706:5
|
LL | #[link()] fn f() { }
| ^^^^^^^^^ ---------- not an `extern` block
LL | #[link(name = "x")] fn f() { }
| ^^^^^^^^^^^^^^^^^^^ ---------- 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: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:711:5
|
LL | #[link()] struct S;
| ^^^^^^^^^ --------- not an `extern` block
LL | #[link(name = "x")] struct S;
| ^^^^^^^^^^^^^^^^^^^ --------- 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: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:5
|
LL | #[link()] type T = S;
| ^^^^^^^^^ ----------- not an `extern` block
LL | #[link(name = "x")] type T = S;
| ^^^^^^^^^^^^^^^^^^^ ----------- 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: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5
|
LL | #[link()] impl S { }
| ^^^^^^^^^ ---------- not an `extern` block
LL | #[link(name = "x")] impl S { }
| ^^^^^^^^^^^^^^^^^^^ ---------- 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: attribute should be applied to an `extern` block with non-Rust ABI
--> $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!

View file

@ -3,6 +3,7 @@ error[E0599]: no method named `fmt` found for opaque type `impl Debug` in the cu
|
LL | x.fmt(f);
| ^^^ method not found in `impl Debug`
|
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
= note: the method is available for `impl Debug` here

View file

@ -48,6 +48,7 @@ error[E0643]: method `hash` has incompatible signature for trait
|
LL | fn hash(&self, hasher: &mut impl Hasher) {}
| ^^^^^^^^^^^ expected generic parameter, found `impl Trait`
|
--> $SRC_DIR/core/src/hash/mod.rs:LL:COL
|
= note: declaration in trait here

View file

@ -3,10 +3,10 @@ error: the item `TryFrom` is imported redundantly
|
LL | use std::convert::TryFrom;
| ^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `TryFrom` is already defined here
|
note: the lint level is defined here
--> $DIR/suggest-remove-issue-121315.rs:2:25
|
@ -18,6 +18,7 @@ error: the item `TryFrom` is imported redundantly
|
LL | use std::convert::{TryFrom, TryInto};
| ^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `TryFrom` is already defined here
@ -27,6 +28,7 @@ error: the item `TryInto` is imported redundantly
|
LL | use std::convert::{TryFrom, TryInto};
| ^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `TryInto` is already defined here
@ -48,6 +50,7 @@ error: the item `Into` is imported redundantly
|
LL | use std::convert::{AsMut, Into};
| ^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `Into` is already defined here

View file

@ -3,10 +3,10 @@ error[E0573]: expected type, found variant `NoResult`
|
LL | fn new() -> NoResult<MyEnum, String> {
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/core/src/result.rs:LL:COL
|
= note: similarly named enum `Result` defined here
|
help: try using the variant's enum
|
LL - fn new() -> NoResult<MyEnum, String> {
@ -57,10 +57,10 @@ error[E0573]: expected type, found variant `NoResult`
|
LL | fn newer() -> NoResult<foo::MyEnum, String> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/core/src/result.rs:LL:COL
|
= note: similarly named enum `Result` defined here
|
help: try using the variant's enum
|
LL - fn newer() -> NoResult<foo::MyEnum, String> {

View file

@ -3,6 +3,7 @@ error[E0530]: match bindings cannot shadow unit variants
|
LL | None @ _ => {}
| ^^^^ cannot be named the same as a unit variant
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the unit variant `None` is defined here

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" {}
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
|
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" {}
fn main() {}

View file

@ -1,8 +1,28 @@
error: link cfg must have a single predicate argument
--> $DIR/issue-43926.rs:1:22
error[E0805]: malformed `link` attribute input
--> $DIR/issue-43926.rs:1:1
|
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
For more information about this error, try `rustc --explain E0805`.

View file

@ -1,8 +1,6 @@
// Top-level ill-formed
#[link] //~ ERROR valid forms for the attribute are
//~| WARN this was previously accepted
#[link = "foo"] //~ ERROR valid forms for the attribute are
//~| WARN this was previously accepted
#[link] //~ ERROR malformed
#[link = "foo"] //~ ERROR malformed
extern "C" {}
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
|
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: `#[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")]`
--> $DIR/link-attr-validation-early.rs:4:1
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-early.rs:3:1
|
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>
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
Future incompatibility report: 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: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
For more information about this error, try `rustc --explain E0539`.

View file

@ -1,38 +1,36 @@
#![feature(link_cfg)]
// Top-level ill-formed
#[link(name = "...", "literal")] //~ ERROR unexpected `#[link]` argument
#[link(name = "...", unknown)] //~ ERROR unexpected `#[link]` argument
#[link(name = "...", "literal")] //~ ERROR malformed `link` attribute input
#[link(name = "...", unknown)] //~ ERROR malformed `link` attribute input
extern "C" {}
// Duplicate arguments
#[link(name = "foo", name = "bar")] //~ ERROR multiple `name` arguments
#[link(name = "...", kind = "dylib", kind = "bar")] //~ ERROR multiple `kind` arguments
#[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] //~ ERROR multiple `modifiers` arguments
#[link(name = "...", cfg(false), cfg(false))] //~ ERROR multiple `cfg` arguments
#[link(wasm_import_module = "foo", wasm_import_module = "bar")] //~ ERROR multiple `wasm_import_module` arguments
#[link(name = "foo", name = "bar")] //~ ERROR malformed `link` attribute input
#[link(name = "...", kind = "dylib", kind = "bar")] //~ ERROR malformed `link` attribute input
#[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] //~ ERROR malformed `link` attribute input
#[link(name = "...", cfg(false), cfg(false))] //~ ERROR malformed `link` attribute input
#[link(wasm_import_module = "foo", wasm_import_module = "bar")] //~ ERROR malformed `link` attribute input
extern "C" {}
// Ill-formed arguments
#[link(name)] //~ ERROR link name must be of the form `name = "string"`
//~| ERROR `#[link]` attribute requires a `name = "string"` argument
#[link(name())] //~ ERROR link name must be of the form `name = "string"`
//~| ERROR `#[link]` attribute requires a `name = "string"` argument
#[link(name = "...", kind)] //~ ERROR link kind must be of the form `kind = "string"`
#[link(name = "...", kind())] //~ ERROR link kind must be of the form `kind = "string"`
#[link(name = "...", modifiers)] //~ ERROR link modifiers must be of the form `modifiers = "string"`
#[link(name = "...", modifiers())] //~ ERROR link modifiers must be of the form `modifiers = "string"`
#[link(name = "...", cfg)] //~ ERROR link cfg must be of the form `cfg(/* predicate */)`
#[link(name = "...", cfg = "literal")] //~ ERROR link cfg must be of the form `cfg(/* predicate */)`
#[link(name = "...", cfg("literal"))] //~ ERROR link cfg must have a single predicate argument
#[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"`
#[link(name)] //~ ERROR malformed `link` attribute input
#[link(name())] //~ ERROR malformed `link` attribute input
#[link(name = "...", kind)] //~ ERROR malformed `link` attribute input
#[link(name = "...", kind())] //~ ERROR malformed `link` attribute input
#[link(name = "...", modifiers)] //~ ERROR malformed `link` attribute input
#[link(name = "...", modifiers())] //~ ERROR malformed `link` attribute input
#[link(name = "...", cfg)] //~ ERROR malformed `link` attribute input
#[link(name = "...", cfg = "literal")] //~ ERROR malformed `link` attribute input
#[link(name = "...", cfg("literal"))] //~ ERROR `cfg` predicate key must be an identifier
#[link(name = "...", wasm_import_module)] //~ ERROR malformed `link` attribute input
#[link(name = "...", wasm_import_module())] //~ ERROR malformed `link` attribute input
extern "C" {}
// Basic modifier validation
#[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 = "+unknown")] //~ ERROR unknown linking modifier `unknown`
#[link(name = "...", modifiers = "+unknown")] //~ ERROR malformed `link` attribute input
#[link(name = "...", modifiers = "+verbatim,+verbatim")] //~ ERROR multiple `verbatim` modifiers
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
--> $DIR/link-attr-validation-late.rs:4:22
error[E0565]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:4:1
|
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
--> $DIR/link-attr-validation-late.rs:5:22
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:5:1
|
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
--> $DIR/link-attr-validation-late.rs:9:22
error[E0538]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:9:1
|
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
--> $DIR/link-attr-validation-late.rs:10:38
error[E0538]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:10:1
|
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
--> $DIR/link-attr-validation-late.rs:11:47
error[E0538]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:11:1
|
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
--> $DIR/link-attr-validation-late.rs:12:34
error[E0538]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:12:1
|
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
--> $DIR/link-attr-validation-late.rs:13:36
error[E0538]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:13:1
|
LL | #[link(wasm_import_module = "foo", wasm_import_module = "bar")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: link name must be of the form `name = "string"`
--> $DIR/link-attr-validation-late.rs:17:8
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------^^
| |
| found `wasm_import_module` used as a key more than once
|
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
|
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"`
--> $DIR/link-attr-validation-late.rs:19:8
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:18:1
|
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
|
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)]
| ^^^^
| ^^^^^^^^^^^^^^^^^^^^^----^^
| |
| 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"`
--> $DIR/link-attr-validation-late.rs:22:22
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:20:1
|
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"`
--> $DIR/link-attr-validation-late.rs:23:22
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:21:1
|
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"`
--> $DIR/link-attr-validation-late.rs:24:22
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:22:1
|
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 */)`
--> $DIR/link-attr-validation-late.rs:25:22
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:23:1
|
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 */)`
--> $DIR/link-attr-validation-late.rs:26:22
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:24:1
|
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
--> $DIR/link-attr-validation-late.rs:27:22
error: `cfg` predicate key must be an identifier
--> $DIR/link-attr-validation-late.rs:25:26
|
LL | #[link(name = "...", cfg("literal"))]
| ^^^^^^^^^^^^^^
| ^^^^^^^^^
error: wasm import module must be of the form `wasm_import_module = "string"`
--> $DIR/link-attr-validation-late.rs:28:22
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:26:1
|
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"`
--> $DIR/link-attr-validation-late.rs:29:22
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:27:1
|
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
--> $DIR/link-attr-validation-late.rs:33:34
--> $DIR/link-attr-validation-late.rs:31:34
|
LL | #[link(name = "...", modifiers = "")]
| ^^
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")]
| ^^^^^^^^^^^^^^^
error: unknown linking modifier `unknown`, expected one of: bundle, verbatim, whole-archive, as-needed
--> $DIR/link-attr-validation-late.rs:35:34
error[E0539]: malformed `link` attribute input
--> $DIR/link-attr-validation-late.rs:33:1
|
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
--> $DIR/link-attr-validation-late.rs:36:34
--> $DIR/link-attr-validation-late.rs:34:34
|
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(
name = "bar",
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" {}
//~^ ERROR overriding linking modifiers from command line is not supported
//~| ERROR overriding linking modifiers from command line is not supported
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
--> $DIR/modifiers-override.rs:12:1
--> $DIR/modifiers-override.rs:8:1
|
LL | extern "C" {}
| ^^^^^^^^^^^^^
error: overriding linking modifiers from command line is not supported
--> $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
error: aborting due to 1 previous error

View file

@ -1,7 +1,10 @@
//@ only-windows
//@ only-x86
#[link(name = "foo", kind = "raw-dylib", import_name_type = 6)]
//~^ ERROR import name type must be of the form `import_name_type = "string"`
extern "C" { }
//@ add-core-stubs
//@ compile-flags: --target i686-pc-windows-msvc
//@ needs-llvm-components: x86
#![feature(no_core, rustc_attrs, lang_items)]
#![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"`
--> $DIR/import-name-type-invalid-format.rs:3:42
error[E0539]: malformed `link` attribute input
--> $DIR/import-name-type-invalid-format.rs:8:1
|
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
For more information about this error, try `rustc --explain E0539`.

View file

@ -1,8 +1,11 @@
// ignore-tidy-linelength
//@ only-windows
//@ only-x86
#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")]
//~^ ERROR multiple `import_name_type` arguments in a single `#[link]` attribute
extern "C" { }
//@ add-core-stubs
//@ compile-flags: --target i686-pc-windows-msvc
//@ needs-llvm-components: x86
#![feature(no_core, rustc_attrs, lang_items)]
#![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
--> $DIR/import-name-type-multiple.rs:4:74
error[E0538]: malformed `link` attribute input
--> $DIR/import-name-type-multiple.rs:9:1
|
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
For more information about this error, try `rustc --explain E0538`.

View file

@ -1,7 +1,10 @@
//@ only-windows
//@ only-x86
#[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")]
//~^ ERROR unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated
extern "C" { }
//@ add-core-stubs
//@ compile-flags: --target i686-pc-windows-msvc
//@ needs-llvm-components: x86
#![feature(no_core, rustc_attrs, lang_items)]
#![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
--> $DIR/import-name-type-unknown-value.rs:3:42
error[E0539]: malformed `link` attribute input
--> $DIR/import-name-type-unknown-value.rs:8:1
|
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
For more information about this error, try `rustc --explain E0539`.

View file

@ -1,5 +1,10 @@
//@ only-windows
//@ only-x86
//@ add-core-stubs
//@ 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")]
//~^ ERROR import name type can only be used with link kind `raw-dylib`
extern "C" { }
@ -11,5 +16,3 @@ extern "C" { }
// Specifying `import_name_type` before `kind` shouldn't raise an error.
#[link(name = "bar", import_name_type = "decorated", kind = "raw-dylib")]
extern "C" { }
fn main() {}

View file

@ -1,11 +1,11 @@
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")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,7 +1,10 @@
//@ only-windows
//@ ignore-x86
//@ add-core-stubs
//@ 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")]
//~^ ERROR import name type is only supported on x86
extern "C" { }
fn main() {}

View file

@ -1,5 +1,5 @@
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")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

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

View file

@ -0,0 +1,23 @@
// Checks for the `integer_to_pointer_transmutes` lint with unsized types
//
// Related to https://github.com/rust-lang/rust/issues/145935
//@ check-pass
#![allow(non_camel_case_types)]
#![allow(unused_unsafe)]
#[cfg(target_pointer_width = "64")]
type usizemetadata = i128;
#[cfg(target_pointer_width = "32")]
type usizemetadata = i64;
unsafe fn unsized_type(a: usize) {
let _ref = unsafe { std::mem::transmute::<usizemetadata, &'static str>(0xff) };
//~^ WARN transmuting an integer to a pointer
let _ptr = unsafe { std::mem::transmute::<usizemetadata, *const [u8]>(0xff) };
//~^ WARN transmuting an integer to a pointer
}
fn main() {}

View file

@ -0,0 +1,27 @@
warning: transmuting an integer to a pointer creates a pointer without provenance
--> $DIR/int_to_ptr-unsized.rs:17:25
|
LL | let _ref = unsafe { std::mem::transmute::<usizemetadata, &'static str>(0xff) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this is dangerous because dereferencing the resulting pointer is undefined behavior
= note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
= help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`
= help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>
= help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
= note: `#[warn(integer_to_ptr_transmutes)]` on by default
warning: transmuting an integer to a pointer creates a pointer without provenance
--> $DIR/int_to_ptr-unsized.rs:19:25
|
LL | let _ptr = unsafe { std::mem::transmute::<usizemetadata, *const [u8]>(0xff) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this is dangerous because dereferencing the resulting pointer is undefined behavior
= note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
= help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`
= help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>
= help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
warning: 2 warnings emitted

View file

@ -3,10 +3,10 @@ warning: the item `String` is imported redundantly
|
LL | use std::string::String;
| ^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `String` is already defined here
|
note: the lint level is defined here
--> $DIR/use-redundant-issue-71450.rs:3:9
|

View file

@ -3,10 +3,10 @@ warning: the item `Some` is imported redundantly
|
LL | use std::option::Option::Some;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `Some` is already defined here
|
note: the lint level is defined here
--> $DIR/use-redundant-prelude-rust-2015.rs:3:9
|
@ -18,6 +18,7 @@ warning: the item `None` is imported redundantly
|
LL | use std::option::Option::None;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `None` is already defined here
@ -27,6 +28,7 @@ warning: the item `Ok` is imported redundantly
|
LL | use std::result::Result::Ok;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `Ok` is already defined here
@ -36,6 +38,7 @@ warning: the item `Err` is imported redundantly
|
LL | use std::result::Result::Err;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `Err` is already defined here

View file

@ -3,10 +3,10 @@ warning: the item `TryFrom` is imported redundantly
|
LL | use std::convert::TryFrom;
| ^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `TryFrom` is already defined here
|
note: the lint level is defined here
--> $DIR/use-redundant-prelude-rust-2021.rs:3:9
|
@ -18,6 +18,7 @@ warning: the item `TryInto` is imported redundantly
|
LL | use std::convert::TryInto;
| ^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `TryInto` is already defined here

View file

@ -3,6 +3,7 @@ error: cannot find macro `printlx` in this scope
|
LL | printlx!("oh noes!");
| ^^^^^^^ help: a macro with a similar name exists: `println`
|
--> $SRC_DIR/std/src/macros.rs:LL:COL
|
= note: similarly named macro `println` defined here

View file

@ -3,6 +3,7 @@ error: cannot find macro `inline` in this scope
|
LL | inline!();
| ^^^^^^ help: a macro with a similar name exists: `line`
|
--> $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
= note: similarly named macro `line` defined here

Some files were not shown because too many files have changed in this diff Show more