From dc49fdd2256bde48d90dde356355d6fc31e8f855 Mon Sep 17 00:00:00 2001 From: Sayantan Chakraborty <142906350+sayantn@users.noreply.github.com> Date: Fri, 27 Dec 2024 11:47:34 +0530 Subject: [PATCH 1/9] Add `kl` and `widekl` target features, and the feature gate --- compiler/rustc_feature/src/unstable.rs | 2 ++ compiler/rustc_span/src/symbol.rs | 1 + compiler/rustc_target/src/target_features.rs | 2 ++ tests/ui/check-cfg/target_feature.stderr | 2 ++ .../ui/feature-gates/feature-gate-keylocker_x86.rs | 6 ++++++ .../feature-gates/feature-gate-keylocker_x86.stderr | 13 +++++++++++++ 6 files changed, 26 insertions(+) create mode 100644 tests/ui/feature-gates/feature-gate-keylocker_x86.rs create mode 100644 tests/ui/feature-gates/feature-gate-keylocker_x86.stderr diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index d40823d2ed627..6807339c668c5 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -525,6 +525,8 @@ declare_features! ( (unstable, inline_const_pat, "1.58.0", Some(76001)), /// Allows using `pointer` and `reference` in intra-doc links (unstable, intra_doc_pointers, "1.51.0", Some(80896)), + // Allows using the `kl` and `widekl` target features and the associated intrinsics + (unstable, keylocker_x86, "CURRENT_RUSTC_VERSION", Some(134813)), // Allows setting the threshold for the `large_assignments` lint. (unstable, large_assignments, "1.52.0", Some(83518)), /// Allow to have type alias types for inter-crate use. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index bdfbfb1e38dd3..cb0c5ae6ad139 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1149,6 +1149,7 @@ symbols! { iterator, iterator_collect_fn, kcfi, + keylocker_x86, keyword, kind, kreg, diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index f594d20f9286f..69ff03e7e24b8 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -401,6 +401,7 @@ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("fma", Stable, &["avx"]), ("fxsr", Stable, &[]), ("gfni", Unstable(sym::avx512_target_feature), &["sse2"]), + ("kl", Unstable(sym::keylocker_x86), &["sse2"]), ("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]), ("lzcnt", Stable, &[]), ("movbe", Stable, &[]), @@ -425,6 +426,7 @@ const X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("tbm", Unstable(sym::tbm_target_feature), &[]), ("vaes", Unstable(sym::avx512_target_feature), &["avx2", "aes"]), ("vpclmulqdq", Unstable(sym::avx512_target_feature), &["avx", "pclmulqdq"]), + ("widekl", Unstable(sym::keylocker_x86), &["kl"]), ("x87", Unstable(sym::x87_target_feature), &[]), ("xop", Unstable(sym::xop_target_feature), &[/*"fma4", */ "avx", "sse4a"]), ("xsave", Stable, &[]), diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 70fec8a350aa1..7c1588781f5b4 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -127,6 +127,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `isa-68881` `isa-68882` `jsconv` +`kl` `lahfsahf` `lasx` `lbt` @@ -270,6 +271,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `vsx` `wfxt` `wide-arithmetic` +`widekl` `x87` `xop` `xsave` diff --git a/tests/ui/feature-gates/feature-gate-keylocker_x86.rs b/tests/ui/feature-gates/feature-gate-keylocker_x86.rs new file mode 100644 index 0000000000000..cef80ad41a892 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-keylocker_x86.rs @@ -0,0 +1,6 @@ +//@ only-x86_64 +#[target_feature(enable = "kl")] +//~^ ERROR: currently unstable +unsafe fn foo() {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr b/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr new file mode 100644 index 0000000000000..ed814d3a3ce2e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr @@ -0,0 +1,13 @@ +error[E0658]: the target feature `kl` is currently unstable + --> $DIR/feature-gate-keylocker_x86.rs:2:18 + | +LL | #[target_feature(enable = "kl")] + | ^^^^^^^^^^^^^ + | + = note: see issue #134813 for more information + = help: add `#![feature(keylocker_x86)]` 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 + +For more information about this error, try `rustc --explain E0658`. From a063cf5f1c151873f753905c75d8e67115308f9d Mon Sep 17 00:00:00 2001 From: "Alexis (Poliorcetics) Bourget" Date: Thu, 26 Dec 2024 23:41:58 +0100 Subject: [PATCH 2/9] fix(rustdoc): always use a channel when linking to doc.rust-lang.org --- src/librustdoc/clean/mod.rs | 2 +- src/librustdoc/clean/utils.rs | 6 +++--- src/librustdoc/core.rs | 2 +- src/librustdoc/html/layout.rs | 2 +- src/librustdoc/html/render/context.rs | 4 ++-- src/librustdoc/html/render/mod.rs | 4 ++-- src/librustdoc/html/render/print_item.rs | 2 +- src/librustdoc/html/static/js/main.js | 16 ++++++++-------- src/librustdoc/html/static/js/search.js | 9 +++++---- src/librustdoc/html/templates/type_layout.html | 2 +- .../html/templates/type_layout_size.html | 2 +- src/librustdoc/lib.rs | 4 ++-- src/librustdoc/passes/collect_intra_doc_links.rs | 2 +- tests/rustdoc/type-layout.rs | 4 ++-- 14 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 7853e311a040c..f13428fc4203c 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1934,7 +1934,7 @@ fn can_elide_trait_object_lifetime_bound<'tcx>( preds: &'tcx ty::List>, tcx: TyCtxt<'tcx>, ) -> bool { - // Below we quote extracts from https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes + // Below we quote extracts from https://doc.rust-lang.org/stable/reference/lifetime-elision.html#default-trait-object-lifetimes // > If the trait object is used as a type argument of a generic type then the containing type is // > first used to try to infer a bound. diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 77040aeb94d77..65722eff1dab8 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -590,9 +590,9 @@ pub(crate) fn attrs_have_doc_flag<'a>( /// so that the channel is consistent. /// /// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable. -pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL"); -pub(crate) static DOC_CHANNEL: Lazy<&'static str> = - Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').find(|c| !c.is_empty()).unwrap()); +pub(crate) const DOC_RUST_LANG_ORG_VERSION: &str = env!("DOC_RUST_LANG_ORG_CHANNEL"); +pub(crate) static RUSTDOC_VERSION: Lazy<&'static str> = + Lazy::new(|| DOC_RUST_LANG_ORG_VERSION.rsplit('/').find(|c| !c.is_empty()).unwrap()); /// Render a sequence of macro arms in a format suitable for displaying to the user /// as part of an item declaration. diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 0437ebb585768..d6b2b53d34cbc 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -387,7 +387,7 @@ pub(crate) fn run_global_ctxt( let help = format!( "The following guide may be of use:\n\ {}/rustdoc/how-to-write-documentation.html", - crate::DOC_RUST_LANG_ORG_CHANNEL + crate::DOC_RUST_LANG_ORG_VERSION ); tcx.node_lint( crate::lint::MISSING_CRATE_LEVEL_DOCS, diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index b4bc0b80d6c66..d957cf1b569e3 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -112,7 +112,7 @@ pub(crate) fn render( display_krate_with_trailing_slash, display_krate_version_number, display_krate_version_extra, - rust_channel: *crate::clean::utils::DOC_CHANNEL, + rust_channel: *crate::clean::utils::RUSTDOC_VERSION, rustdoc_version, } .render() diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 5d96dbc0ee659..1cefdf96bbcd2 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -32,7 +32,7 @@ use crate::html::render::write_shared::write_shared; use crate::html::url_parts_builder::UrlPartsBuilder; use crate::html::{layout, sources, static_files}; use crate::scrape_examples::AllCallLocations; -use crate::try_err; +use crate::{DOC_RUST_LANG_ORG_VERSION, try_err}; /// Major driving force in all rustdoc rendering. This contains information /// about where in the tree-like hierarchy rendering is occurring and controls @@ -730,7 +730,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { ", ) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index a27a9d202eb80..f7dcb87e4f3d0 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -79,7 +79,7 @@ use crate::html::markdown::{ use crate::html::static_files::SCRAPE_EXAMPLES_HELP_MD; use crate::html::{highlight, sources}; use crate::scrape_examples::{CallData, CallLocation}; -use crate::{DOC_RUST_LANG_ORG_CHANNEL, try_none}; +use crate::{DOC_RUST_LANG_ORG_VERSION, try_none}; pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ { fmt::from_fn(move |f| { @@ -480,7 +480,7 @@ fn scrape_examples_help(shared: &SharedContext<'_>) -> String { content.push_str(&format!( "## More information\n\n\ If you want more information about this feature, please read the [corresponding chapter in \ - the Rustdoc book]({DOC_RUST_LANG_ORG_CHANNEL}/rustdoc/scraped-examples.html)." + the Rustdoc book]({DOC_RUST_LANG_ORG_VERSION}/rustdoc/scraped-examples.html)." )); let mut ids = IdMap::default(); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 37fea09ace310..c50adf116160a 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -924,7 +924,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra dyn compatible.

\

In older versions of Rust, dyn compatibility was called \"object safety\", \ so this trait is not object safe.

", - base = crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL + base = crate::clean::utils::DOC_RUST_LANG_ORG_VERSION ), ); } diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index ccf4002bb300d..bfd5cb7764fd4 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1534,10 +1534,10 @@ function preLoadCss(cssUrl) { function buildHelpMenu() { const book_info = document.createElement("span"); - const channel = getVar("channel"); + const drloChannel = `https://doc.rust-lang.org/${getVar("channel")}`; book_info.className = "top"; book_info.innerHTML = `You can find more information in \ -the rustdoc book.`; +the rustdoc book.`; const shortcuts = [ ["?", "Show this help dialog"], @@ -1557,8 +1557,8 @@ function preLoadCss(cssUrl) { div_shortcuts.innerHTML = "

Keyboard Shortcuts

" + shortcuts + "
"; const infos = [ - `For a full list of all search features, take a look here.`, + `For a full list of all search features, take a look \ + here.`, "Prefix searches with a type followed by a colon (e.g., fn:) to \ restrict the search to a given item kind.", "Accepted kinds are: fn, mod, struct, \ @@ -1568,10 +1568,10 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm -> vec or String, enum:Cow -> bool)", "You can look for items with an exact name by putting double quotes around \ your request: \"string\"", - "Look for functions that accept or return \ - slices and \ - arrays by writing \ - square brackets (e.g., -> [u8] or [] -> Option)", + `Look for functions that accept or return \ + slices and \ + arrays by writing square \ + brackets (e.g., -> [u8] or [] -> Option)`, "Look for items inside another one by searching for a path: vec::Vec", ].map(x => "

" + x + "

").join(""); const div_infos = document.createElement("div"); diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 1ad32721e0687..662e951069973 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1,5 +1,5 @@ // ignore-tidy-filelength -/* global addClass, getNakedUrl, getSettingValue */ +/* global addClass, getNakedUrl, getSettingValue, getVar */ /* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi, exports */ "use strict"; @@ -4923,17 +4923,18 @@ ${item.displayPath}${name}\ } }); } else if (query.error === null) { + const dlroChannel = `https://doc.rust-lang.org/${getVar("channel")}`; output.className = "search-failed" + extraClass; output.innerHTML = "No results :(
" + "Try on DuckDuckGo?

" + "Or try looking in one of these:"; diff --git a/src/librustdoc/html/templates/type_layout.html b/src/librustdoc/html/templates/type_layout.html index 9c62826ccc2e3..0034552bdd3b7 100644 --- a/src/librustdoc/html/templates/type_layout.html +++ b/src/librustdoc/html/templates/type_layout.html @@ -10,7 +10,7 @@

{# #} unstable and may even differ between compilations. {#+ #} The only exception is types with certain repr(...) {#+ #} attributes. Please see the Rust Reference's {#+ #} - “Type Layout” {#+ #} + “Type Layout” {#+ #} chapter for details on type layout guarantees. {# #}

{# #} {# #} diff --git a/src/librustdoc/html/templates/type_layout_size.html b/src/librustdoc/html/templates/type_layout_size.html index 9c2b39edc9f37..5256b6c8f2ace 100644 --- a/src/librustdoc/html/templates/type_layout_size.html +++ b/src/librustdoc/html/templates/type_layout_size.html @@ -7,6 +7,6 @@ {{ size +}} bytes {% endif %} {% if is_uninhabited %} - {# +#} (uninhabited) + {# +#} (uninhabited) {% endif %} {% endif %} diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index bb954a31891ad..45f42e61fbf7a 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -82,7 +82,7 @@ use rustc_session::config::{ErrorOutputType, RustcOptGroup, make_crate_type_opti use rustc_session::{EarlyDiagCtxt, getopts}; use tracing::info; -use crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL; +use crate::clean::utils::DOC_RUST_LANG_ORG_VERSION; /// A macro to create a FxHashMap. /// @@ -710,7 +710,7 @@ fn usage(argv0: &str) { println!("{}", options.usage(&format!("{argv0} [options] "))); println!(" @path Read newline separated options from `path`\n"); println!( - "More information available at {DOC_RUST_LANG_ORG_CHANNEL}/rustdoc/what-is-rustdoc.html", + "More information available at {DOC_RUST_LANG_ORG_VERSION}/rustdoc/what-is-rustdoc.html", ); } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index a777b45b8070b..9fe8b99e8af87 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -2168,7 +2168,7 @@ fn disambiguator_error( report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp, _link_range| { let msg = format!( "see {}/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators", - crate::DOC_RUST_LANG_ORG_CHANNEL + crate::DOC_RUST_LANG_ORG_VERSION ); diag.note(msg); }); diff --git a/tests/rustdoc/type-layout.rs b/tests/rustdoc/type-layout.rs index 5f34c8b99e0ff..6de435dbcc143 100644 --- a/tests/rustdoc/type-layout.rs +++ b/tests/rustdoc/type-layout.rs @@ -86,11 +86,11 @@ pub enum WithNiche { } //@ hasraw type_layout/enum.Uninhabited.html 'Size: ' -//@ hasraw - '0 bytes (uninhabited)' +//@ hasraw - '0 bytes (uninhabited)' pub enum Uninhabited {} //@ hasraw type_layout/struct.Uninhabited2.html 'Size: ' -//@ hasraw - '8 bytes (uninhabited)' +//@ hasraw - '8 bytes (uninhabited)' pub struct Uninhabited2(std::convert::Infallible, u64); pub trait Project { type Assoc; } From 139d6ba054a1a4cc5fe64981ad46fd5547bd4916 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Thu, 30 Jan 2025 16:51:08 +0000 Subject: [PATCH 3/9] set rustc dylib on manually constructed rustc command Signed-off-by: onur-ozkan --- src/bootstrap/src/core/builder/cargo.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 1b413dcb07efb..79a65aedd9edb 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -653,7 +653,10 @@ impl Builder<'_> { // Build proc macros both for the host and the target unless proc-macros are not // supported by the target. if target != compiler.host && cmd_kind != Kind::Check { - let error = command(self.rustc(compiler)) + let mut rustc_cmd = command(self.rustc(compiler)); + self.add_rustc_lib_path(compiler, &mut rustc_cmd); + + let error = rustc_cmd .arg("--target") .arg(target.rustc_target_arg()) .arg("--print=file-names") @@ -661,6 +664,7 @@ impl Builder<'_> { .arg("-") .run_capture(self) .stderr(); + let not_supported = error .lines() .any(|line| line.contains("unsupported crate type `proc-macro`")); From 88260f4ba4b0b9f86094bd1b2495c027bf959dbe Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 21 Jan 2025 18:00:04 +0100 Subject: [PATCH 4/9] bootstrap: only build `crt{begin,end}.o` when compiling to MUSL only MUSL needs those objects and trying to compile them to other targets, e.g. Windows or macOS, will produce C compilation errors check the target before shelling out to the C compiler and tweak `make_run` to skip the actual C compilation when the target is not MUSL fixes #135782 --- src/bootstrap/src/core/build_steps/compile.rs | 2 +- src/bootstrap/src/core/build_steps/llvm.rs | 4 +++- src/bootstrap/src/core/config/config.rs | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index fd9bf47234c63..ba8f2cc618d75 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -339,7 +339,7 @@ fn copy_self_contained_objects( // to using gcc from a glibc-targeting toolchain for linking. // To do that we have to distribute musl startup objects as a part of Rust toolchain // and link with them manually in the self-contained mode. - if target.contains("musl") && !target.contains("unikraft") { + if target.needs_crt_begin_end() { let srcdir = builder.musl_libdir(target).unwrap_or_else(|| { panic!("Target {:?} does not have a \"musl-libdir\" key", target.triple) }); diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index cf55fff4078ac..370673dfca153 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -1295,7 +1295,9 @@ impl Step for CrtBeginEnd { } fn make_run(run: RunConfig<'_>) { - run.builder.ensure(CrtBeginEnd { target: run.target }); + if run.target.needs_crt_begin_end() { + run.builder.ensure(CrtBeginEnd { target: run.target }); + } } /// Build crtbegin.o/crtend.o for musl target. diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index b5310108dbf70..40c995895434f 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -573,6 +573,10 @@ impl TargetSelection { env::var("OSTYPE").is_ok_and(|v| v.to_lowercase().contains("cygwin")) } + pub fn needs_crt_begin_end(&self) -> bool { + self.contains("musl") && !self.contains("unikraft") + } + /// Path to the file defining the custom target, if any. pub fn filepath(&self) -> Option<&Path> { self.file.as_ref().map(Path::new) From acb3bab5d945cb6a2c9a91c91599152c933dd59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Fri, 31 Jan 2025 14:43:49 +0800 Subject: [PATCH 5/9] bootstrap: add wrapper macros for `tracing`-gated tracing macros - Add wrapper macros for `error!`, `warn!`, `info!`, `debug!` and `trace!`, which `cfg(feature = "tracing")`-gates the underlying `tracing` macros. - This is not done for `span!` or `event!` because they can return span guards, and you can't really wrap that. - This is also not possible for `tracing::instrument` attribute proc-macro unless you use another attribute proc-macro to wrap that. --- src/bootstrap/src/bin/main.rs | 12 ++--- src/bootstrap/src/lib.rs | 87 +++++++++++++++--------------- src/bootstrap/src/utils/mod.rs | 2 + src/bootstrap/src/utils/tracing.rs | 49 +++++++++++++++++ 4 files changed, 99 insertions(+), 51 deletions(-) create mode 100644 src/bootstrap/src/utils/tracing.rs diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs index 5fcf7eda8df79..441674936c666 100644 --- a/src/bootstrap/src/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs @@ -11,12 +11,12 @@ use std::str::FromStr; use std::{env, process}; use bootstrap::{ - Build, CONFIG_CHANGE_HISTORY, Config, Flags, Subcommand, find_recent_config_change_ids, + Build, CONFIG_CHANGE_HISTORY, Config, Flags, Subcommand, debug, find_recent_config_change_ids, human_readable_changes, t, }; use build_helper::ci::CiEnv; #[cfg(feature = "tracing")] -use tracing::{debug, instrument}; +use tracing::instrument; #[cfg_attr(feature = "tracing", instrument(level = "trace", name = "main"))] fn main() { @@ -29,10 +29,8 @@ fn main() { return; } - #[cfg(feature = "tracing")] debug!("parsing flags"); let flags = Flags::parse(&args); - #[cfg(feature = "tracing")] debug!("parsing config based on flags"); let config = Config::parse(flags); @@ -95,7 +93,6 @@ fn main() { let dump_bootstrap_shims = config.dump_bootstrap_shims; let out_dir = config.out.clone(); - #[cfg(feature = "tracing")] debug!("creating new build based on config"); Build::new(config).build(); @@ -207,8 +204,9 @@ fn check_version(config: &Config) -> Option { // Due to the conditional compilation via the `tracing` cargo feature, this means that `tracing` // usages in bootstrap need to be also gated behind the `tracing` feature: // -// - `tracing` macros (like `trace!`) and anything from `tracing`, `tracing_subscriber` and -// `tracing-tree` will need to be gated by `#[cfg(feature = "tracing")]`. +// - `tracing` macros with log levels (`trace!`, `debug!`, `warn!`, `info`, `error`) should not be +// used *directly*. You should use the wrapped `tracing` macros which gate the actual invocations +// behind `feature = "tracing"`. // - `tracing`'s `#[instrument(..)]` macro will need to be gated like `#![cfg_attr(feature = // "tracing", instrument(..))]`. #[cfg(feature = "tracing")] diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index d56f35f866cb8..2dd83d5938e9d 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -28,8 +28,6 @@ use std::{env, fs, io, str}; use build_helper::ci::gha; use build_helper::exit; use termcolor::{ColorChoice, StandardStream, WriteColor}; -#[cfg(feature = "tracing")] -use tracing::{debug, instrument, span, trace}; use utils::build_stamp::BuildStamp; use utils::channel::GitInfo; @@ -46,6 +44,8 @@ pub use core::builder::PathSet; pub use core::config::Config; pub use core::config::flags::{Flags, Subcommand}; +#[cfg(feature = "tracing")] +use tracing::{instrument, span}; pub use utils::change_tracker::{ CONFIG_CHANGE_HISTORY, find_recent_config_change_ids, human_readable_changes, }; @@ -541,72 +541,71 @@ impl Build { /// Executes the entire build, as configured by the flags and configuration. #[cfg_attr(feature = "tracing", instrument(level = "debug", name = "Build::build", skip_all))] pub fn build(&mut self) { - #[cfg(feature = "tracing")] trace!("setting up job management"); unsafe { crate::utils::job::setup(self); } - #[cfg(feature = "tracing")] - trace!("downloading rustfmt early"); - // Download rustfmt early so that it can be used in rust-analyzer configs. + trace!("downloading rustfmt early"); let _ = &builder::Builder::new(self).initial_rustfmt(); - #[cfg(feature = "tracing")] - let hardcoded_span = - span!(tracing::Level::DEBUG, "handling hardcoded subcommands (Format, Suggest, Perf)") - .entered(); - - // hardcoded subcommands - match &self.config.cmd { - Subcommand::Format { check, all } => { - return core::build_steps::format::format( - &builder::Builder::new(self), - *check, - *all, - &self.config.paths, - ); - } - Subcommand::Suggest { run } => { - return core::build_steps::suggest::suggest(&builder::Builder::new(self), *run); - } - Subcommand::Perf { .. } => { - return core::build_steps::perf::perf(&builder::Builder::new(self)); - } - _cmd => { - #[cfg(feature = "tracing")] - debug!(cmd = ?_cmd, "not a hardcoded subcommand; returning to normal handling"); + // Handle hard-coded subcommands. + { + #[cfg(feature = "tracing")] + let _hardcoded_span = span!( + tracing::Level::DEBUG, + "handling hardcoded subcommands (Format, Suggest, Perf)" + ) + .entered(); + + match &self.config.cmd { + Subcommand::Format { check, all } => { + return core::build_steps::format::format( + &builder::Builder::new(self), + *check, + *all, + &self.config.paths, + ); + } + Subcommand::Suggest { run } => { + return core::build_steps::suggest::suggest(&builder::Builder::new(self), *run); + } + Subcommand::Perf { .. } => { + return core::build_steps::perf::perf(&builder::Builder::new(self)); + } + _cmd => { + debug!(cmd = ?_cmd, "not a hardcoded subcommand; returning to normal handling"); + } } - } - #[cfg(feature = "tracing")] - drop(hardcoded_span); - #[cfg(feature = "tracing")] - debug!("handling subcommand normally"); + debug!("handling subcommand normally"); + } if !self.config.dry_run() { #[cfg(feature = "tracing")] let _real_run_span = span!(tracing::Level::DEBUG, "executing real run").entered(); + // We first do a dry-run. This is a sanity-check to ensure that + // steps don't do anything expensive in the dry-run. { #[cfg(feature = "tracing")] let _sanity_check_span = span!(tracing::Level::DEBUG, "(1) executing dry-run sanity-check").entered(); - - // We first do a dry-run. This is a sanity-check to ensure that - // steps don't do anything expensive in the dry-run. self.config.dry_run = DryRun::SelfCheck; let builder = builder::Builder::new(self); builder.execute_cli(); } - #[cfg(feature = "tracing")] - let _actual_run_span = - span!(tracing::Level::DEBUG, "(2) executing actual run").entered(); - self.config.dry_run = DryRun::Disabled; - let builder = builder::Builder::new(self); - builder.execute_cli(); + // Actual run. + { + #[cfg(feature = "tracing")] + let _actual_run_span = + span!(tracing::Level::DEBUG, "(2) executing actual run").entered(); + self.config.dry_run = DryRun::Disabled; + let builder = builder::Builder::new(self); + builder.execute_cli(); + } } else { #[cfg(feature = "tracing")] let _dry_run_span = span!(tracing::Level::DEBUG, "executing dry run").entered(); diff --git a/src/bootstrap/src/utils/mod.rs b/src/bootstrap/src/utils/mod.rs index ea56932b40437..caef8ce3088a7 100644 --- a/src/bootstrap/src/utils/mod.rs +++ b/src/bootstrap/src/utils/mod.rs @@ -14,6 +14,8 @@ pub(crate) mod render_tests; pub(crate) mod shared_helpers; pub(crate) mod tarball; +pub(crate) mod tracing; + #[cfg(feature = "build-metrics")] pub(crate) mod metrics; diff --git a/src/bootstrap/src/utils/tracing.rs b/src/bootstrap/src/utils/tracing.rs new file mode 100644 index 0000000000000..9cd3b6165be61 --- /dev/null +++ b/src/bootstrap/src/utils/tracing.rs @@ -0,0 +1,49 @@ +//! Wrapper macros for [`tracing`] macros to avoid having to write `cfg(feature = "tracing")`-gated +//! `debug!`/`trace!` everytime, e.g. +//! +//! ```rust,ignore (example) +//! #[cfg(feature = "tracing")] +//! trace!("..."); +//! ``` +//! +//! When `feature = "tracing"` is inactive, these macros expand to nothing. + +#[macro_export] +macro_rules! trace { + ($($tokens:tt)*) => { + #[cfg(feature = "tracing")] + ::tracing::trace!($($tokens)*) + } +} + +#[macro_export] +macro_rules! debug { + ($($tokens:tt)*) => { + #[cfg(feature = "tracing")] + ::tracing::debug!($($tokens)*) + } +} + +#[macro_export] +macro_rules! warn { + ($($tokens:tt)*) => { + #[cfg(feature = "tracing")] + ::tracing::warn!($($tokens)*) + } +} + +#[macro_export] +macro_rules! info { + ($($tokens:tt)*) => { + #[cfg(feature = "tracing")] + ::tracing::info!($($tokens)*) + } +} + +#[macro_export] +macro_rules! error { + ($($tokens:tt)*) => { + #[cfg(feature = "tracing")] + ::tracing::error!($($tokens)*) + } +} From 0878692e0d4ea9e2ad39d37a1c70e5bf4bf563e4 Mon Sep 17 00:00:00 2001 From: vayunbiyani Date: Tue, 21 Jan 2025 15:06:52 -0500 Subject: [PATCH 6/9] Ported tests/ui/simd to use the intrinsic macro --- tests/ui/simd/array-trait.rs | 10 ++- tests/ui/simd/array-type.rs | 10 ++- tests/ui/simd/generics.rs | 5 +- tests/ui/simd/intrinsic/float-math-pass.rs | 74 +++++++++++++------ .../ui/simd/intrinsic/generic-arithmetic-2.rs | 67 ++++++++++++----- .../intrinsic/generic-arithmetic-2.stderr | 48 ++++++------ .../simd/intrinsic/generic-arithmetic-pass.rs | 67 ++++++++++++----- .../generic-arithmetic-saturating-2.rs | 10 ++- .../generic-arithmetic-saturating-2.stderr | 4 +- .../generic-arithmetic-saturating-pass.rs | 10 ++- tests/ui/simd/intrinsic/generic-as.rs | 6 +- .../ui/simd/intrinsic/generic-bitmask-pass.rs | 5 +- tests/ui/simd/intrinsic/generic-bitmask.rs | 5 +- .../ui/simd/intrinsic/generic-bitmask.stderr | 10 +-- tests/ui/simd/intrinsic/generic-bswap-byte.rs | 5 +- tests/ui/simd/intrinsic/generic-cast-pass.rs | 6 +- .../intrinsic/generic-cast-pointer-width.rs | 5 +- tests/ui/simd/intrinsic/generic-cast.rs | 5 +- tests/ui/simd/intrinsic/generic-cast.stderr | 8 +- .../simd/intrinsic/generic-comparison-pass.rs | 26 +++++-- tests/ui/simd/intrinsic/generic-comparison.rs | 26 +++++-- .../simd/intrinsic/generic-comparison.stderr | 36 ++++----- .../simd/intrinsic/generic-elements-pass.rs | 13 ++-- tests/ui/simd/intrinsic/generic-elements.rs | 19 +++-- .../ui/simd/intrinsic/generic-elements.stderr | 42 +++++------ .../ui/simd/intrinsic/generic-gather-pass.rs | 9 ++- .../simd/intrinsic/generic-reduction-pass.rs | 45 +++++++---- tests/ui/simd/intrinsic/generic-reduction.rs | 28 ++++--- .../simd/intrinsic/generic-reduction.stderr | 20 ++--- .../ui/simd/intrinsic/generic-select-pass.rs | 10 ++- tests/ui/simd/intrinsic/generic-select.rs | 11 ++- tests/ui/simd/intrinsic/generic-select.stderr | 16 ++-- tests/ui/simd/intrinsic/generic-shuffle.rs | 6 +- .../simd/intrinsic/inlining-issue67557-ice.rs | 5 +- .../ui/simd/intrinsic/inlining-issue67557.rs | 5 +- tests/ui/simd/intrinsic/issue-85855.rs | 21 +++--- tests/ui/simd/intrinsic/issue-85855.stderr | 18 ++--- tests/ui/simd/intrinsic/ptr-cast.rs | 14 ++-- tests/ui/simd/issue-105439.rs | 5 +- tests/ui/simd/issue-39720.rs | 5 +- tests/ui/simd/issue-85915-simd-ptrs.rs | 10 ++- tests/ui/simd/issue-89193.rs | 5 +- tests/ui/simd/masked-load-store-build-fail.rs | 10 ++- .../simd/masked-load-store-build-fail.stderr | 16 ++-- tests/ui/simd/masked-load-store-check-fail.rs | 9 ++- .../simd/masked-load-store-check-fail.stderr | 20 ++--- tests/ui/simd/masked-load-store.rs | 9 ++- .../monomorphize-shuffle-index.generic.stderr | 2 +- tests/ui/simd/monomorphize-shuffle-index.rs | 15 ++-- tests/ui/simd/repr_packed.rs | 5 +- tests/ui/simd/shuffle.rs | 5 +- tests/ui/simd/simd-bitmask-notpow2.rs | 10 ++- tests/ui/simd/simd-bitmask.rs | 10 ++- 53 files changed, 518 insertions(+), 348 deletions(-) diff --git a/tests/ui/simd/array-trait.rs b/tests/ui/simd/array-trait.rs index 67583bf82087d..32cbf01428cad 100644 --- a/tests/ui/simd/array-trait.rs +++ b/tests/ui/simd/array-trait.rs @@ -24,10 +24,12 @@ pub struct T([S::Lane; S::SIZE]); //~| ERROR SIMD vector element type should be a primitive scalar //~| ERROR unconstrained generic constant -extern "rust-intrinsic" { - fn simd_insert(x: T, idx: u32, y: E) -> T; - fn simd_extract(x: T, idx: u32) -> E; -} +#[rustc_intrinsic] +unsafe fn simd_insert(x: T, idx: u32, y: E) -> T; + +#[rustc_intrinsic] +unsafe fn simd_extract(x: T, idx: u32) -> E; + pub fn main() { let mut t = T::([0; 4]); diff --git a/tests/ui/simd/array-type.rs b/tests/ui/simd/array-type.rs index 8ca53b1a453fc..d1de700441694 100644 --- a/tests/ui/simd/array-type.rs +++ b/tests/ui/simd/array-type.rs @@ -12,10 +12,12 @@ struct S([i32; 4]); #[derive(Copy, Clone)] struct T([i32; N]); -extern "rust-intrinsic" { - fn simd_insert(x: T, idx: u32, y: E) -> T; - fn simd_extract(x: T, idx: u32) -> E; -} +#[rustc_intrinsic] +unsafe fn simd_insert(x: T, idx: u32, y: E) -> T; + +#[rustc_intrinsic] +unsafe fn simd_extract(x: T, idx: u32) -> E; + pub fn main() { let mut s = S([0; 4]); diff --git a/tests/ui/simd/generics.rs b/tests/ui/simd/generics.rs index f96a7cd75e933..453ed86c14a9c 100644 --- a/tests/ui/simd/generics.rs +++ b/tests/ui/simd/generics.rs @@ -21,9 +21,8 @@ struct B([T; 4]); struct C([T; N]); -extern "rust-intrinsic" { - fn simd_add(x: T, y: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_add(x: T, y: T) -> T; fn add>(lhs: T, rhs: T) -> T { lhs + rhs diff --git a/tests/ui/simd/intrinsic/float-math-pass.rs b/tests/ui/simd/intrinsic/float-math-pass.rs index 24b9941133ee7..74cb51a06068e 100644 --- a/tests/ui/simd/intrinsic/float-math-pass.rs +++ b/tests/ui/simd/intrinsic/float-math-pass.rs @@ -15,27 +15,59 @@ #[derive(Copy, Clone, PartialEq, Debug)] struct f32x4(pub [f32; 4]); -extern "rust-intrinsic" { - fn simd_fsqrt(x: T) -> T; - fn simd_fabs(x: T) -> T; - fn simd_fsin(x: T) -> T; - fn simd_fcos(x: T) -> T; - fn simd_fexp(x: T) -> T; - fn simd_fexp2(x: T) -> T; - fn simd_fma(x: T, y: T, z: T) -> T; - fn simd_relaxed_fma(x: T, y: T, z: T) -> T; - fn simd_flog(x: T) -> T; - fn simd_flog10(x: T) -> T; - fn simd_flog2(x: T) -> T; - fn simd_fpow(x: T, y: T) -> T; - fn simd_fpowi(x: T, y: i32) -> T; - - // rounding functions - fn simd_ceil(x: T) -> T; - fn simd_floor(x: T) -> T; - fn simd_round(x: T) -> T; - fn simd_trunc(x: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_fsqrt(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fabs(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fsin(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fcos(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fexp(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fexp2(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fma(x: T, y: T, z: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_relaxed_fma(x: T, y: T, z: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_flog(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_flog10(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_flog2(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fpow(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fpowi(x: T, y: i32) -> T; + + +// rounding functions +#[rustc_intrinsic] +unsafe fn simd_ceil(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_floor(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_round(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_trunc(x: T) -> T; + macro_rules! assert_approx_eq_f32 { ($a:expr, $b:expr) => ({ diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs index 663bcdf198193..0fcff8584c850 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs @@ -14,25 +14,54 @@ pub struct u32x4(pub [u32; 4]); #[derive(Copy, Clone)] pub struct f32x4(pub [f32; 4]); -extern "rust-intrinsic" { - fn simd_add(x: T, y: T) -> T; - fn simd_sub(x: T, y: T) -> T; - fn simd_mul(x: T, y: T) -> T; - fn simd_div(x: T, y: T) -> T; - fn simd_rem(x: T, y: T) -> T; - fn simd_shl(x: T, y: T) -> T; - fn simd_shr(x: T, y: T) -> T; - fn simd_and(x: T, y: T) -> T; - fn simd_or(x: T, y: T) -> T; - fn simd_xor(x: T, y: T) -> T; - - fn simd_neg(x: T) -> T; - fn simd_bswap(x: T) -> T; - fn simd_bitreverse(x: T) -> T; - fn simd_ctlz(x: T) -> T; - fn simd_ctpop(x: T) -> T; - fn simd_cttz(x: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_add(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_sub(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_mul(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_div(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_rem(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_shl(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_shr(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_and(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_or(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_xor(x: T, y: T) -> T; + + +#[rustc_intrinsic] +unsafe fn simd_neg(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_bswap(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_bitreverse(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_ctlz(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_ctpop(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_cttz(x: T) -> T; fn main() { let x = i32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr index 6f5f86d7d374c..e67de2fe9034d 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr @@ -1,143 +1,143 @@ error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:81:9 + --> $DIR/generic-arithmetic-2.rs:110:9 | LL | simd_add(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:83:9 + --> $DIR/generic-arithmetic-2.rs:112:9 | LL | simd_sub(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:85:9 + --> $DIR/generic-arithmetic-2.rs:114:9 | LL | simd_mul(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:87:9 + --> $DIR/generic-arithmetic-2.rs:116:9 | LL | simd_div(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:89:9 + --> $DIR/generic-arithmetic-2.rs:118:9 | LL | simd_shl(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:91:9 + --> $DIR/generic-arithmetic-2.rs:120:9 | LL | simd_shr(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:93:9 + --> $DIR/generic-arithmetic-2.rs:122:9 | LL | simd_and(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:95:9 + --> $DIR/generic-arithmetic-2.rs:124:9 | LL | simd_or(0, 0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:97:9 + --> $DIR/generic-arithmetic-2.rs:126:9 | LL | simd_xor(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:100:9 + --> $DIR/generic-arithmetic-2.rs:129:9 | LL | simd_neg(0); | ^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:102:9 + --> $DIR/generic-arithmetic-2.rs:131:9 | LL | simd_bswap(0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:104:9 + --> $DIR/generic-arithmetic-2.rs:133:9 | LL | simd_bitreverse(0); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:106:9 + --> $DIR/generic-arithmetic-2.rs:135:9 | LL | simd_ctlz(0); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:108:9 + --> $DIR/generic-arithmetic-2.rs:137:9 | LL | simd_cttz(0); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:111:9 + --> $DIR/generic-arithmetic-2.rs:140:9 | LL | simd_shl(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:113:9 + --> $DIR/generic-arithmetic-2.rs:142:9 | LL | simd_shr(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:115:9 + --> $DIR/generic-arithmetic-2.rs:144:9 | LL | simd_and(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:117:9 + --> $DIR/generic-arithmetic-2.rs:146:9 | LL | simd_or(z, z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:119:9 + --> $DIR/generic-arithmetic-2.rs:148:9 | LL | simd_xor(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:121:9 + --> $DIR/generic-arithmetic-2.rs:150:9 | LL | simd_bswap(z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:123:9 + --> $DIR/generic-arithmetic-2.rs:152:9 | LL | simd_bitreverse(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:125:9 + --> $DIR/generic-arithmetic-2.rs:154:9 | LL | simd_ctlz(z); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctpop` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:127:9 + --> $DIR/generic-arithmetic-2.rs:156:9 | LL | simd_ctpop(z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:129:9 + --> $DIR/generic-arithmetic-2.rs:158:9 | LL | simd_cttz(z); | ^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index e4eb2a9da2718..4a18c0164e4b8 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -23,25 +23,54 @@ macro_rules! all_eq { }}; } -extern "rust-intrinsic" { - fn simd_add(x: T, y: T) -> T; - fn simd_sub(x: T, y: T) -> T; - fn simd_mul(x: T, y: T) -> T; - fn simd_div(x: T, y: T) -> T; - fn simd_rem(x: T, y: T) -> T; - fn simd_shl(x: T, y: T) -> T; - fn simd_shr(x: T, y: T) -> T; - fn simd_and(x: T, y: T) -> T; - fn simd_or(x: T, y: T) -> T; - fn simd_xor(x: T, y: T) -> T; - - fn simd_neg(x: T) -> T; - fn simd_bswap(x: T) -> T; - fn simd_bitreverse(x: T) -> T; - fn simd_ctlz(x: T) -> T; - fn simd_ctpop(x: T) -> T; - fn simd_cttz(x: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_add(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_sub(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_mul(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_div(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_rem(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_shl(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_shr(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_and(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_or(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_xor(x: T, y: T) -> T; + + +#[rustc_intrinsic] +unsafe fn simd_neg(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_bswap(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_bitreverse(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_ctlz(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_ctpop(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_cttz(x: T) -> T; fn main() { let x1 = i32x4([1, 2, 3, 4]); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs index ec6ac78df1a7a..85464402d6af1 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs @@ -14,10 +14,12 @@ pub struct x4(pub [T; 4]); #[derive(Copy, Clone)] pub struct f32x4(pub [f32; 4]); -extern "rust-intrinsic" { - fn simd_saturating_add(x: T, y: T) -> T; - fn simd_saturating_sub(x: T, y: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_saturating_add(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_saturating_sub(x: T, y: T) -> T; + fn main() { let x = i32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr index f349cb56560cc..cf275db7e435f 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr @@ -1,11 +1,11 @@ error[E0511]: invalid monomorphization of `simd_saturating_add` intrinsic: expected element type `f32` of vector type `f32x4` to be a signed or unsigned integer type - --> $DIR/generic-arithmetic-saturating-2.rs:33:9 + --> $DIR/generic-arithmetic-saturating-2.rs:35:9 | LL | simd_saturating_add(z, z); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_saturating_sub` intrinsic: expected element type `f32` of vector type `f32x4` to be a signed or unsigned integer type - --> $DIR/generic-arithmetic-saturating-2.rs:35:9 + --> $DIR/generic-arithmetic-saturating-2.rs:37:9 | LL | simd_saturating_sub(z, z); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs index 57bda5c2d624e..5fe65257d15f0 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs @@ -12,10 +12,12 @@ struct u32x4(pub [u32; 4]); #[derive(Copy, Clone)] struct I32([i32; N]); -extern "rust-intrinsic" { - fn simd_saturating_add(x: T, y: T) -> T; - fn simd_saturating_sub(x: T, y: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_saturating_add(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_saturating_sub(x: T, y: T) -> T; + fn main() { // unsigned diff --git a/tests/ui/simd/intrinsic/generic-as.rs b/tests/ui/simd/intrinsic/generic-as.rs index e97bf12c14473..124ca56bc889b 100644 --- a/tests/ui/simd/intrinsic/generic-as.rs +++ b/tests/ui/simd/intrinsic/generic-as.rs @@ -2,9 +2,9 @@ #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_as(x: T) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_as(x: T) -> U; #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/intrinsic/generic-bitmask-pass.rs b/tests/ui/simd/intrinsic/generic-bitmask-pass.rs index db10020bd469b..08526991fbe1f 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask-pass.rs +++ b/tests/ui/simd/intrinsic/generic-bitmask-pass.rs @@ -21,9 +21,8 @@ struct u8x4(pub [u8; 4]); #[derive(Copy, Clone, PartialEq, Debug)] struct Tx4(pub [T; 4]); -extern "rust-intrinsic" { - fn simd_bitmask(x: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_bitmask(x: T) -> U; fn main() { let z = u32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-bitmask.rs b/tests/ui/simd/intrinsic/generic-bitmask.rs index 29b9279c370f5..49589d22bbfa9 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask.rs +++ b/tests/ui/simd/intrinsic/generic-bitmask.rs @@ -30,9 +30,8 @@ struct u8x32([u8; 32]); #[derive(Copy, Clone)] struct u8x64([u8; 64]); -extern "rust-intrinsic" { - fn simd_bitmask(x: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_bitmask(x: T) -> U; fn main() { let m2 = u32x2([0; 2]); diff --git a/tests/ui/simd/intrinsic/generic-bitmask.stderr b/tests/ui/simd/intrinsic/generic-bitmask.stderr index 0de3f8eead86d..c217bb2d8f1aa 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask.stderr +++ b/tests/ui/simd/intrinsic/generic-bitmask.stderr @@ -1,29 +1,29 @@ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u16`, expected `u8` or `[u8; 1]` - --> $DIR/generic-bitmask.rs:53:22 + --> $DIR/generic-bitmask.rs:52:22 | LL | let _: u16 = simd_bitmask(m2); | ^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u16`, expected `u8` or `[u8; 1]` - --> $DIR/generic-bitmask.rs:56:22 + --> $DIR/generic-bitmask.rs:55:22 | LL | let _: u16 = simd_bitmask(m8); | ^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u32`, expected `u16` or `[u8; 2]` - --> $DIR/generic-bitmask.rs:59:22 + --> $DIR/generic-bitmask.rs:58:22 | LL | let _: u32 = simd_bitmask(m16); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u64`, expected `u32` or `[u8; 4]` - --> $DIR/generic-bitmask.rs:62:22 + --> $DIR/generic-bitmask.rs:61:22 | LL | let _: u64 = simd_bitmask(m32); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u128`, expected `u64` or `[u8; 8]` - --> $DIR/generic-bitmask.rs:65:23 + --> $DIR/generic-bitmask.rs:64:23 | LL | let _: u128 = simd_bitmask(m64); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-bswap-byte.rs b/tests/ui/simd/intrinsic/generic-bswap-byte.rs index f1702538165d3..4521573636c01 100644 --- a/tests/ui/simd/intrinsic/generic-bswap-byte.rs +++ b/tests/ui/simd/intrinsic/generic-bswap-byte.rs @@ -10,9 +10,8 @@ struct i8x4([i8; 4]); #[derive(Copy, Clone)] struct u8x4([u8; 4]); -extern "rust-intrinsic" { - fn simd_bswap(x: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_bswap(x: T) -> T; fn main() { unsafe { diff --git a/tests/ui/simd/intrinsic/generic-cast-pass.rs b/tests/ui/simd/intrinsic/generic-cast-pass.rs index e0319a6461ad2..2155d84586471 100644 --- a/tests/ui/simd/intrinsic/generic-cast-pass.rs +++ b/tests/ui/simd/intrinsic/generic-cast-pass.rs @@ -3,9 +3,9 @@ #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_cast(x: T) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_cast(x: T) -> U; use std::cmp::{max, min}; diff --git a/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs b/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs index 1c09a9fbf3bfd..9f28898654f2f 100644 --- a/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs +++ b/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs @@ -1,9 +1,8 @@ //@ run-pass #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_cast(x: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_cast(x: T) -> U; #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/intrinsic/generic-cast.rs b/tests/ui/simd/intrinsic/generic-cast.rs index 33978a2f7395d..7f398804eb4f3 100644 --- a/tests/ui/simd/intrinsic/generic-cast.rs +++ b/tests/ui/simd/intrinsic/generic-cast.rs @@ -21,9 +21,8 @@ struct f32x4([f32; 4]); struct f32x8([f32; 8]); -extern "rust-intrinsic" { - fn simd_cast(x: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_cast(x: T) -> U; fn main() { let x = i32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-cast.stderr b/tests/ui/simd/intrinsic/generic-cast.stderr index 2f9d44037afb5..1b6ac03f8c964 100644 --- a/tests/ui/simd/intrinsic/generic-cast.stderr +++ b/tests/ui/simd/intrinsic/generic-cast.stderr @@ -1,23 +1,23 @@ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-cast.rs:32:9 + --> $DIR/generic-cast.rs:31:9 | LL | simd_cast::(0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-cast.rs:34:9 + --> $DIR/generic-cast.rs:33:9 | LL | simd_cast::(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-cast.rs:36:9 + --> $DIR/generic-cast.rs:35:9 | LL | simd_cast::(x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8 - --> $DIR/generic-cast.rs:38:9 + --> $DIR/generic-cast.rs:37:9 | LL | simd_cast::<_, i32x8>(x); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-comparison-pass.rs b/tests/ui/simd/intrinsic/generic-comparison-pass.rs index a4d84a4c53482..68f98372e1dc7 100644 --- a/tests/ui/simd/intrinsic/generic-comparison-pass.rs +++ b/tests/ui/simd/intrinsic/generic-comparison-pass.rs @@ -14,14 +14,24 @@ struct u32x4(pub [u32; 4]); #[derive(Copy, Clone)] struct f32x4(pub [f32; 4]); -extern "rust-intrinsic" { - fn simd_eq(x: T, y: T) -> U; - fn simd_ne(x: T, y: T) -> U; - fn simd_lt(x: T, y: T) -> U; - fn simd_le(x: T, y: T) -> U; - fn simd_gt(x: T, y: T) -> U; - fn simd_ge(x: T, y: T) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_eq(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_ne(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_lt(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_le(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_gt(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_ge(x: T, y: T) -> U; macro_rules! cmp { ($method: ident($lhs: expr, $rhs: expr)) => {{ diff --git a/tests/ui/simd/intrinsic/generic-comparison.rs b/tests/ui/simd/intrinsic/generic-comparison.rs index f7f0655f3d244..e5adb49f6a3b0 100644 --- a/tests/ui/simd/intrinsic/generic-comparison.rs +++ b/tests/ui/simd/intrinsic/generic-comparison.rs @@ -11,14 +11,24 @@ struct i32x4([i32; 4]); #[allow(non_camel_case_types)] struct i16x8([i16; 8]); -extern "rust-intrinsic" { - fn simd_eq(x: T, y: T) -> U; - fn simd_ne(x: T, y: T) -> U; - fn simd_lt(x: T, y: T) -> U; - fn simd_le(x: T, y: T) -> U; - fn simd_gt(x: T, y: T) -> U; - fn simd_ge(x: T, y: T) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_eq(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_ne(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_lt(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_le(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_gt(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_ge(x: T, y: T) -> U; fn main() { let x = i32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-comparison.stderr b/tests/ui/simd/intrinsic/generic-comparison.stderr index ac4d491882742..cc66d2ce40a91 100644 --- a/tests/ui/simd/intrinsic/generic-comparison.stderr +++ b/tests/ui/simd/intrinsic/generic-comparison.stderr @@ -1,107 +1,107 @@ error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:27:9 + --> $DIR/generic-comparison.rs:37:9 | LL | simd_eq::(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:29:9 + --> $DIR/generic-comparison.rs:39:9 | LL | simd_ne::(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:31:9 + --> $DIR/generic-comparison.rs:41:9 | LL | simd_lt::(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:33:9 + --> $DIR/generic-comparison.rs:43:9 | LL | simd_le::(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:35:9 + --> $DIR/generic-comparison.rs:45:9 | LL | simd_gt::(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:37:9 + --> $DIR/generic-comparison.rs:47:9 | LL | simd_ge::(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:40:9 + --> $DIR/generic-comparison.rs:50:9 | LL | simd_eq::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:42:9 + --> $DIR/generic-comparison.rs:52:9 | LL | simd_ne::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:44:9 + --> $DIR/generic-comparison.rs:54:9 | LL | simd_lt::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:46:9 + --> $DIR/generic-comparison.rs:56:9 | LL | simd_le::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:48:9 + --> $DIR/generic-comparison.rs:58:9 | LL | simd_gt::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:50:9 + --> $DIR/generic-comparison.rs:60:9 | LL | simd_ge::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:53:9 + --> $DIR/generic-comparison.rs:63:9 | LL | simd_eq::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:55:9 + --> $DIR/generic-comparison.rs:65:9 | LL | simd_ne::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:57:9 + --> $DIR/generic-comparison.rs:67:9 | LL | simd_lt::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:59:9 + --> $DIR/generic-comparison.rs:69:9 | LL | simd_le::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:61:9 + --> $DIR/generic-comparison.rs:71:9 | LL | simd_gt::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:63:9 + --> $DIR/generic-comparison.rs:73:9 | LL | simd_ge::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-elements-pass.rs b/tests/ui/simd/intrinsic/generic-elements-pass.rs index 7b1bda4fbcd5f..8cb600bc9e45a 100644 --- a/tests/ui/simd/intrinsic/generic-elements-pass.rs +++ b/tests/ui/simd/intrinsic/generic-elements-pass.rs @@ -16,12 +16,15 @@ struct i32x4([i32; 4]); #[allow(non_camel_case_types)] struct i32x8([i32; 8]); -extern "rust-intrinsic" { - fn simd_insert(x: T, idx: u32, y: E) -> T; - fn simd_extract(x: T, idx: u32) -> E; +#[rustc_intrinsic] +unsafe fn simd_insert(x: T, idx: u32, y: E) -> T; - fn simd_shuffle(x: T, y: T, idx: I) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_extract(x: T, idx: u32) -> E; + + +#[rustc_intrinsic] +unsafe fn simd_shuffle(x: T, y: T, idx: I) -> U; #[repr(simd)] struct SimdShuffleIdx([u32; LEN]); diff --git a/tests/ui/simd/intrinsic/generic-elements.rs b/tests/ui/simd/intrinsic/generic-elements.rs index 5d784a25eab4a..4be6645f029c5 100644 --- a/tests/ui/simd/intrinsic/generic-elements.rs +++ b/tests/ui/simd/intrinsic/generic-elements.rs @@ -29,13 +29,20 @@ struct f32x4([f32; 4]); #[allow(non_camel_case_types)] struct f32x8([f32; 8]); -extern "rust-intrinsic" { - fn simd_insert(x: T, idx: u32, y: E) -> T; - fn simd_extract(x: T, idx: u32) -> E; - fn simd_shuffle(x: T, y: T, idx: I) -> U; - fn simd_shuffle_generic(x: T, y: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_insert(x: T, idx: u32, y: E) -> T; + +#[rustc_intrinsic] +unsafe fn simd_extract(x: T, idx: u32) -> E; + + +#[rustc_intrinsic] +unsafe fn simd_shuffle(x: T, y: T, idx: I) -> U; + +#[rustc_intrinsic] +unsafe fn simd_shuffle_generic(x: T, y: T) -> U; + #[repr(simd)] struct SimdShuffleIdx([u32; LEN]); diff --git a/tests/ui/simd/intrinsic/generic-elements.stderr b/tests/ui/simd/intrinsic/generic-elements.stderr index fd726d7532600..8104c3ba5a2ed 100644 --- a/tests/ui/simd/intrinsic/generic-elements.stderr +++ b/tests/ui/simd/intrinsic/generic-elements.stderr @@ -1,125 +1,125 @@ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:47:9 + --> $DIR/generic-elements.rs:54:9 | LL | simd_insert(0, 0, 0); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected inserted type `i32` (element of input `i32x4`), found `f64` - --> $DIR/generic-elements.rs:49:9 + --> $DIR/generic-elements.rs:56:9 | LL | simd_insert(x, 0, 1.0); | ^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_extract` intrinsic: expected return type `i32` (element of input `i32x4`), found `f32` - --> $DIR/generic-elements.rs:51:9 + --> $DIR/generic-elements.rs:58:9 | LL | simd_extract::<_, f32>(x, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:55:9 + --> $DIR/generic-elements.rs:62:9 | LL | simd_shuffle::(0, 0, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:58:9 + --> $DIR/generic-elements.rs:65:9 | LL | simd_shuffle::(0, 0, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:61:9 + --> $DIR/generic-elements.rs:68:9 | LL | simd_shuffle::(0, 0, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - --> $DIR/generic-elements.rs:64:9 + --> $DIR/generic-elements.rs:71:9 | LL | simd_shuffle::<_, _, f32x2>(x, x, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - --> $DIR/generic-elements.rs:66:9 + --> $DIR/generic-elements.rs:73:9 | LL | simd_shuffle::<_, _, f32x4>(x, x, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - --> $DIR/generic-elements.rs:68:9 + --> $DIR/generic-elements.rs:75:9 | LL | simd_shuffle::<_, _, f32x8>(x, x, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 2, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:71:9 + --> $DIR/generic-elements.rs:78:9 | LL | simd_shuffle::<_, _, i32x8>(x, x, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 4, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:73:9 + --> $DIR/generic-elements.rs:80:9 | LL | simd_shuffle::<_, _, i32x8>(x, x, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 8, found `i32x2` with length 2 - --> $DIR/generic-elements.rs:75:9 + --> $DIR/generic-elements.rs:82:9 | LL | simd_shuffle::<_, _, i32x2>(x, x, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:79:9 + --> $DIR/generic-elements.rs:86:9 | LL | simd_shuffle_generic::(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:82:9 + --> $DIR/generic-elements.rs:89:9 | LL | simd_shuffle_generic::(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:85:9 + --> $DIR/generic-elements.rs:92:9 | LL | simd_shuffle_generic::(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - --> $DIR/generic-elements.rs:88:9 + --> $DIR/generic-elements.rs:95:9 | LL | simd_shuffle_generic::<_, f32x2, I2>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - --> $DIR/generic-elements.rs:90:9 + --> $DIR/generic-elements.rs:97:9 | LL | simd_shuffle_generic::<_, f32x4, I4>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - --> $DIR/generic-elements.rs:92:9 + --> $DIR/generic-elements.rs:99:9 | LL | simd_shuffle_generic::<_, f32x8, I8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 2, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:95:9 + --> $DIR/generic-elements.rs:102:9 | LL | simd_shuffle_generic::<_, i32x8, I2>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 4, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:97:9 + --> $DIR/generic-elements.rs:104:9 | LL | simd_shuffle_generic::<_, i32x8, I4>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 8, found `i32x2` with length 2 - --> $DIR/generic-elements.rs:99:9 + --> $DIR/generic-elements.rs:106:9 | LL | simd_shuffle_generic::<_, i32x2, I8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-gather-pass.rs b/tests/ui/simd/intrinsic/generic-gather-pass.rs index 3315d1cdaa22d..0b2cf47e98980 100644 --- a/tests/ui/simd/intrinsic/generic-gather-pass.rs +++ b/tests/ui/simd/intrinsic/generic-gather-pass.rs @@ -10,10 +10,11 @@ #[derive(Copy, Clone, PartialEq, Debug)] struct x4(pub [T; 4]); -extern "rust-intrinsic" { - fn simd_gather(x: T, y: U, z: V) -> T; - fn simd_scatter(x: T, y: U, z: V) -> (); -} +#[rustc_intrinsic] +unsafe fn simd_gather(x: T, y: U, z: V) -> T; + +#[rustc_intrinsic] +unsafe fn simd_scatter(x: T, y: U, z: V) -> (); fn main() { let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; diff --git a/tests/ui/simd/intrinsic/generic-reduction-pass.rs b/tests/ui/simd/intrinsic/generic-reduction-pass.rs index 699fb396259dc..8408d0f203bfb 100644 --- a/tests/ui/simd/intrinsic/generic-reduction-pass.rs +++ b/tests/ui/simd/intrinsic/generic-reduction-pass.rs @@ -24,19 +24,38 @@ struct f32x4(pub [f32; 4]); #[derive(Copy, Clone)] struct b8x4(pub [i8; 4]); -extern "rust-intrinsic" { - fn simd_reduce_add_unordered(x: T) -> U; - fn simd_reduce_mul_unordered(x: T) -> U; - fn simd_reduce_add_ordered(x: T, acc: U) -> U; - fn simd_reduce_mul_ordered(x: T, acc: U) -> U; - fn simd_reduce_min(x: T) -> U; - fn simd_reduce_max(x: T) -> U; - fn simd_reduce_and(x: T) -> U; - fn simd_reduce_or(x: T) -> U; - fn simd_reduce_xor(x: T) -> U; - fn simd_reduce_all(x: T) -> bool; - fn simd_reduce_any(x: T) -> bool; -} +#[rustc_intrinsic] +unsafe fn simd_reduce_add_unordered(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_mul_unordered(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_add_ordered(x: T, acc: U) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_mul_ordered(x: T, acc: U) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_min(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_max(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_and(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_or(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_xor(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_all(x: T) -> bool; + +#[rustc_intrinsic] +unsafe fn simd_reduce_any(x: T) -> bool; fn main() { unsafe { diff --git a/tests/ui/simd/intrinsic/generic-reduction.rs b/tests/ui/simd/intrinsic/generic-reduction.rs index 1986deafb6ab5..ead13250643c1 100644 --- a/tests/ui/simd/intrinsic/generic-reduction.rs +++ b/tests/ui/simd/intrinsic/generic-reduction.rs @@ -15,16 +15,26 @@ pub struct f32x4(pub [f32; 4]); #[derive(Copy, Clone)] pub struct u32x4(pub [u32; 4]); +#[rustc_intrinsic] +unsafe fn simd_reduce_add_ordered(x: T, y: U) -> U; -extern "rust-intrinsic" { - fn simd_reduce_add_ordered(x: T, y: U) -> U; - fn simd_reduce_mul_ordered(x: T, y: U) -> U; - fn simd_reduce_and(x: T) -> U; - fn simd_reduce_or(x: T) -> U; - fn simd_reduce_xor(x: T) -> U; - fn simd_reduce_all(x: T) -> bool; - fn simd_reduce_any(x: T) -> bool; -} +#[rustc_intrinsic] +unsafe fn simd_reduce_mul_ordered(x: T, y: U) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_and(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_or(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_xor(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_all(x: T) -> bool; + +#[rustc_intrinsic] +unsafe fn simd_reduce_any(x: T) -> bool; fn main() { let x = u32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-reduction.stderr b/tests/ui/simd/intrinsic/generic-reduction.stderr index 1028faf69a7bc..302b9ae1d778a 100644 --- a/tests/ui/simd/intrinsic/generic-reduction.stderr +++ b/tests/ui/simd/intrinsic/generic-reduction.stderr @@ -1,59 +1,59 @@ error[E0511]: invalid monomorphization of `simd_reduce_add_ordered` intrinsic: expected return type `f32` (element of input `f32x4`), found `i32` - --> $DIR/generic-reduction.rs:34:9 + --> $DIR/generic-reduction.rs:44:9 | LL | simd_reduce_add_ordered(z, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_mul_ordered` intrinsic: expected return type `f32` (element of input `f32x4`), found `i32` - --> $DIR/generic-reduction.rs:36:9 + --> $DIR/generic-reduction.rs:46:9 | LL | simd_reduce_mul_ordered(z, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` - --> $DIR/generic-reduction.rs:39:22 + --> $DIR/generic-reduction.rs:49:22 | LL | let _: f32 = simd_reduce_and(x); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` - --> $DIR/generic-reduction.rs:41:22 + --> $DIR/generic-reduction.rs:51:22 | LL | let _: f32 = simd_reduce_or(x); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` - --> $DIR/generic-reduction.rs:43:22 + --> $DIR/generic-reduction.rs:53:22 | LL | let _: f32 = simd_reduce_xor(x); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: unsupported simd_reduce_and from `f32x4` with element `f32` to `f32` - --> $DIR/generic-reduction.rs:46:22 + --> $DIR/generic-reduction.rs:56:22 | LL | let _: f32 = simd_reduce_and(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: unsupported simd_reduce_or from `f32x4` with element `f32` to `f32` - --> $DIR/generic-reduction.rs:48:22 + --> $DIR/generic-reduction.rs:58:22 | LL | let _: f32 = simd_reduce_or(z); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: unsupported simd_reduce_xor from `f32x4` with element `f32` to `f32` - --> $DIR/generic-reduction.rs:50:22 + --> $DIR/generic-reduction.rs:60:22 | LL | let _: f32 = simd_reduce_xor(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_all` intrinsic: unsupported simd_reduce_all from `f32x4` with element `f32` to `bool` - --> $DIR/generic-reduction.rs:53:23 + --> $DIR/generic-reduction.rs:63:23 | LL | let _: bool = simd_reduce_all(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_any` intrinsic: unsupported simd_reduce_any from `f32x4` with element `f32` to `bool` - --> $DIR/generic-reduction.rs:55:23 + --> $DIR/generic-reduction.rs:65:23 | LL | let _: bool = simd_reduce_any(z); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-select-pass.rs b/tests/ui/simd/intrinsic/generic-select-pass.rs index 5690bad504844..6b1b6cb79dbc9 100644 --- a/tests/ui/simd/intrinsic/generic-select-pass.rs +++ b/tests/ui/simd/intrinsic/generic-select-pass.rs @@ -29,10 +29,12 @@ struct f32x4(pub [f32; 4]); #[derive(Copy, Clone, PartialEq, Debug)] struct b8x4(pub [i8; 4]); -extern "rust-intrinsic" { - fn simd_select(x: T, a: U, b: U) -> U; - fn simd_select_bitmask(x: T, a: U, b: U) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_select(x: T, a: U, b: U) -> U; + +#[rustc_intrinsic] +unsafe fn simd_select_bitmask(x: T, a: U, b: U) -> U; + fn main() { let m0 = b8x4([!0, !0, !0, !0]); diff --git a/tests/ui/simd/intrinsic/generic-select.rs b/tests/ui/simd/intrinsic/generic-select.rs index 52e02649590ab..340fe3f35929c 100644 --- a/tests/ui/simd/intrinsic/generic-select.rs +++ b/tests/ui/simd/intrinsic/generic-select.rs @@ -22,10 +22,13 @@ struct b8x4(pub [i8; 4]); #[derive(Copy, Clone, PartialEq)] struct b8x8(pub [i8; 8]); -extern "rust-intrinsic" { - fn simd_select(x: T, a: U, b: U) -> U; - fn simd_select_bitmask(x: T, a: U, b: U) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_select(x: T, a: U, b: U) -> U; + +#[rustc_intrinsic] +unsafe fn simd_select_bitmask(x: T, a: U, b: U) -> U; + fn main() { let m4 = b8x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-select.stderr b/tests/ui/simd/intrinsic/generic-select.stderr index d576f1bc77473..a97fc91f951d1 100644 --- a/tests/ui/simd/intrinsic/generic-select.stderr +++ b/tests/ui/simd/intrinsic/generic-select.stderr @@ -1,47 +1,47 @@ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mismatched lengths: mask length `8` != other vector length `4` - --> $DIR/generic-select.rs:39:9 + --> $DIR/generic-select.rs:42:9 | LL | simd_select(m8, x, x); | ^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `u32`, expected `i_` - --> $DIR/generic-select.rs:42:9 + --> $DIR/generic-select.rs:45:9 | LL | simd_select(x, x, x); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `f32`, expected `i_` - --> $DIR/generic-select.rs:45:9 + --> $DIR/generic-select.rs:48:9 | LL | simd_select(z, z, z); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select` intrinsic: expected SIMD argument type, found non-SIMD `u32` - --> $DIR/generic-select.rs:48:9 + --> $DIR/generic-select.rs:51:9 | LL | simd_select(m4, 0u32, 1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: invalid bitmask `u16`, expected `u8` or `[u8; 1]` - --> $DIR/generic-select.rs:51:9 + --> $DIR/generic-select.rs:54:9 | LL | simd_select_bitmask(0u16, x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: expected SIMD argument type, found non-SIMD `u32` - --> $DIR/generic-select.rs:54:9 + --> $DIR/generic-select.rs:57:9 | LL | simd_select_bitmask(0u8, 1u32, 2u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: invalid bitmask `f32`, expected `u8` or `[u8; 1]` - --> $DIR/generic-select.rs:57:9 + --> $DIR/generic-select.rs:60:9 | LL | simd_select_bitmask(0.0f32, x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: invalid bitmask `&str`, expected `u8` or `[u8; 1]` - --> $DIR/generic-select.rs:60:9 + --> $DIR/generic-select.rs:63:9 | LL | simd_select_bitmask("x", x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-shuffle.rs b/tests/ui/simd/intrinsic/generic-shuffle.rs index 2752718d99d6b..1223b8ebe1903 100644 --- a/tests/ui/simd/intrinsic/generic-shuffle.rs +++ b/tests/ui/simd/intrinsic/generic-shuffle.rs @@ -9,9 +9,9 @@ #[derive(Copy, Clone)] pub struct Simd([T; N]); -extern "rust-intrinsic" { - fn simd_shuffle(a: T, b: T, i: I) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_shuffle(a: T, b: T, i: I) -> U; + fn main() { const I: Simd = Simd([0; 2]); diff --git a/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs b/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs index d9239ef5801ae..b324ac40749fa 100644 --- a/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs +++ b/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs @@ -5,9 +5,8 @@ //@ compile-flags: -Zmir-opt-level=4 #![feature(intrinsics, repr_simd)] -extern "rust-intrinsic" { - fn simd_shuffle(x: T, y: T, idx: I) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_shuffle(x: T, y: T, idx: I) -> U; #[repr(simd)] #[derive(Debug, PartialEq)] diff --git a/tests/ui/simd/intrinsic/inlining-issue67557.rs b/tests/ui/simd/intrinsic/inlining-issue67557.rs index 23dd5075f96b6..319bb15c01570 100644 --- a/tests/ui/simd/intrinsic/inlining-issue67557.rs +++ b/tests/ui/simd/intrinsic/inlining-issue67557.rs @@ -5,9 +5,8 @@ //@ compile-flags: -Zmir-opt-level=4 #![feature(intrinsics, repr_simd)] -extern "rust-intrinsic" { - fn simd_shuffle(x: T, y: T, idx: I) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_shuffle(x: T, y: T, idx: I) -> U; #[repr(simd)] #[derive(Debug, PartialEq)] diff --git a/tests/ui/simd/intrinsic/issue-85855.rs b/tests/ui/simd/intrinsic/issue-85855.rs index dc04699f7f89d..daeea793d1bce 100644 --- a/tests/ui/simd/intrinsic/issue-85855.rs +++ b/tests/ui/simd/intrinsic/issue-85855.rs @@ -5,15 +5,18 @@ #![feature(intrinsics)] #![crate_type="lib"] -extern "rust-intrinsic" { - fn simd_saturating_add<'a, T: 'a>(x: T, y: T); - //~^ ERROR: intrinsic has wrong number of lifetime parameters - fn simd_add<'a, T>(x: T, y: T) -> T; +#[rustc_intrinsic] +unsafe fn simd_saturating_add<'a, T: 'a>(x: T, y: T); +//~^ ERROR: intrinsic has wrong number of lifetime parameters - fn simd_sub(x: T, y: U); - //~^ ERROR: intrinsic has wrong number of type parameters +#[rustc_intrinsic] +unsafe fn simd_add<'a, T>(x: T, y: T) -> T; - fn simd_mul(x: T, y: T); - //~^ ERROR: intrinsic has wrong number of const parameters -} +#[rustc_intrinsic] +unsafe fn simd_sub(x: T, y: U); +//~^ ERROR: intrinsic has wrong number of type parameters + +#[rustc_intrinsic] +unsafe fn simd_mul(x: T, y: T); +//~^ ERROR: intrinsic has wrong number of const parameters diff --git a/tests/ui/simd/intrinsic/issue-85855.stderr b/tests/ui/simd/intrinsic/issue-85855.stderr index fb2f1fbc5b1cc..b91a606ba68a1 100644 --- a/tests/ui/simd/intrinsic/issue-85855.stderr +++ b/tests/ui/simd/intrinsic/issue-85855.stderr @@ -1,20 +1,20 @@ error[E0094]: intrinsic has wrong number of lifetime parameters: found 1, expected 0 - --> $DIR/issue-85855.rs:9:27 + --> $DIR/issue-85855.rs:10:30 | -LL | fn simd_saturating_add<'a, T: 'a>(x: T, y: T); - | ^^^^^^^^^^^ expected 0 lifetime parameters +LL | unsafe fn simd_saturating_add<'a, T: 'a>(x: T, y: T); + | ^^^^^^^^^^^ expected 0 lifetime parameters error[E0094]: intrinsic has wrong number of type parameters: found 2, expected 1 - --> $DIR/issue-85855.rs:14:16 + --> $DIR/issue-85855.rs:17:19 | -LL | fn simd_sub(x: T, y: U); - | ^^^^^^ expected 1 type parameter +LL | unsafe fn simd_sub(x: T, y: U); + | ^^^^^^ expected 1 type parameter error[E0094]: intrinsic has wrong number of const parameters: found 1, expected 0 - --> $DIR/issue-85855.rs:17:16 + --> $DIR/issue-85855.rs:21:19 | -LL | fn simd_mul(x: T, y: T); - | ^^^^^^^^^^^^^^^^^^^ expected 0 const parameters +LL | unsafe fn simd_mul(x: T, y: T); + | ^^^^^^^^^^^^^^^^^^^ expected 0 const parameters error: aborting due to 3 previous errors diff --git a/tests/ui/simd/intrinsic/ptr-cast.rs b/tests/ui/simd/intrinsic/ptr-cast.rs index 0490734b48ac5..559b8ba1b5c2d 100644 --- a/tests/ui/simd/intrinsic/ptr-cast.rs +++ b/tests/ui/simd/intrinsic/ptr-cast.rs @@ -2,11 +2,15 @@ #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_cast_ptr(x: T) -> U; - fn simd_expose_provenance(x: T) -> U; - fn simd_with_exposed_provenance(x: T) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_cast_ptr(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_expose_provenance(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_with_exposed_provenance(x: T) -> U; #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/issue-105439.rs b/tests/ui/simd/issue-105439.rs index 3cb43fc8b1af9..108bb282df2af 100644 --- a/tests/ui/simd/issue-105439.rs +++ b/tests/ui/simd/issue-105439.rs @@ -9,9 +9,8 @@ #[repr(simd)] struct i32x4([i32; 4]); -extern "rust-intrinsic" { - pub(crate) fn simd_add(x: T, y: T) -> T; -} +#[rustc_intrinsic] +pub(crate) unsafe fn simd_add(x: T, y: T) -> T; #[inline(always)] fn to_array(a: i32x4) -> [i32; 4] { diff --git a/tests/ui/simd/issue-39720.rs b/tests/ui/simd/issue-39720.rs index 2b51c0224c633..8d7666faaf933 100644 --- a/tests/ui/simd/issue-39720.rs +++ b/tests/ui/simd/issue-39720.rs @@ -11,9 +11,8 @@ pub struct Char3(pub [i8; 3]); #[derive(Copy, Clone, Debug)] pub struct Short3(pub [i16; 3]); -extern "rust-intrinsic" { - fn simd_cast(x: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_cast(x: T) -> U; fn main() { let cast: Short3 = unsafe { simd_cast(Char3([10, -3, -9])) }; diff --git a/tests/ui/simd/issue-85915-simd-ptrs.rs b/tests/ui/simd/issue-85915-simd-ptrs.rs index edf60e0205c29..2e7baf48ee326 100644 --- a/tests/ui/simd/issue-85915-simd-ptrs.rs +++ b/tests/ui/simd/issue-85915-simd-ptrs.rs @@ -22,10 +22,12 @@ struct f32x4([f32; 4]); #[derive(Copy, Clone, PartialEq, Debug)] struct i32x4([i32; 4]); -extern "rust-intrinsic" { - fn simd_gather(x: T, y: U, z: V) -> T; - fn simd_scatter(x: T, y: U, z: V) -> (); -} + +#[rustc_intrinsic] +unsafe fn simd_gather(x: T, y: U, z: V) -> T; + +#[rustc_intrinsic] +unsafe fn simd_scatter(x: T, y: U, z: V) -> (); fn main() { let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; diff --git a/tests/ui/simd/issue-89193.rs b/tests/ui/simd/issue-89193.rs index 9530124a7cc81..4b4fb9d916968 100644 --- a/tests/ui/simd/issue-89193.rs +++ b/tests/ui/simd/issue-89193.rs @@ -10,9 +10,8 @@ #[derive(Copy, Clone, PartialEq, Debug)] struct x4(pub [T; 4]); -extern "rust-intrinsic" { - fn simd_gather(x: T, y: U, z: V) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_gather(x: T, y: U, z: V) -> T; fn main() { let x: [usize; 4] = [10, 11, 12, 13]; diff --git a/tests/ui/simd/masked-load-store-build-fail.rs b/tests/ui/simd/masked-load-store-build-fail.rs index fbd657763c984..b8742184eb02c 100644 --- a/tests/ui/simd/masked-load-store-build-fail.rs +++ b/tests/ui/simd/masked-load-store-build-fail.rs @@ -1,10 +1,12 @@ //@ build-fail #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_masked_load(mask: M, pointer: P, values: T) -> T; - fn simd_masked_store(mask: M, pointer: P, values: T) -> (); -} + +#[rustc_intrinsic] +unsafe fn simd_masked_load(mask: M, pointer: P, values: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_masked_store(mask: M, pointer: P, values: T) -> (); #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/masked-load-store-build-fail.stderr b/tests/ui/simd/masked-load-store-build-fail.stderr index 59af83fe0e893..8a8d8eb99e278 100644 --- a/tests/ui/simd/masked-load-store-build-fail.stderr +++ b/tests/ui/simd/masked-load-store-build-fail.stderr @@ -1,5 +1,5 @@ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected third argument with length 8 (same as input type `Simd`), found `Simd` with length 4 - --> $DIR/masked-load-store-build-fail.rs:18:9 + --> $DIR/masked-load-store-build-fail.rs:20:9 | LL | / simd_masked_load( LL | | Simd::([-1, 0, -1, -1, 0, 0, 0, 0]), @@ -9,7 +9,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected element type `u8` of second argument `*const i8` to be a pointer to the element type `u8` of the first argument `Simd`, found `u8` != `*_ u8` - --> $DIR/masked-load-store-build-fail.rs:25:9 + --> $DIR/masked-load-store-build-fail.rs:27:9 | LL | / simd_masked_load( LL | | Simd::([-1, 0, -1, -1]), @@ -19,7 +19,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd`, found `u32` != `*_ u32` - --> $DIR/masked-load-store-build-fail.rs:32:9 + --> $DIR/masked-load-store-build-fail.rs:34:9 | LL | / simd_masked_load( LL | | Simd::([-1, 0, -1, -1]), @@ -29,7 +29,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected element type `u8` of third argument `Simd` to be a signed integer type - --> $DIR/masked-load-store-build-fail.rs:39:9 + --> $DIR/masked-load-store-build-fail.rs:41:9 | LL | / simd_masked_load( LL | | Simd::([1, 0, 1, 1]), @@ -39,7 +39,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd`, found `u32` != `*mut u32` - --> $DIR/masked-load-store-build-fail.rs:46:9 + --> $DIR/masked-load-store-build-fail.rs:48:9 | LL | / simd_masked_store( LL | | Simd([-1i8; 4]), @@ -49,7 +49,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected element type `u8` of second argument `*const u8` to be a pointer to the element type `u8` of the first argument `Simd`, found `u8` != `*mut u8` - --> $DIR/masked-load-store-build-fail.rs:53:9 + --> $DIR/masked-load-store-build-fail.rs:55:9 | LL | / simd_masked_store( LL | | Simd([-1i8; 4]), @@ -59,7 +59,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected third argument with length 4 (same as input type `Simd`), found `Simd` with length 2 - --> $DIR/masked-load-store-build-fail.rs:60:9 + --> $DIR/masked-load-store-build-fail.rs:62:9 | LL | / simd_masked_store( LL | | Simd([-1i8; 4]), @@ -69,7 +69,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected element type `u8` of third argument `Simd` to be a signed integer type - --> $DIR/masked-load-store-build-fail.rs:67:9 + --> $DIR/masked-load-store-build-fail.rs:69:9 | LL | / simd_masked_store( LL | | Simd([1u32; 4]), diff --git a/tests/ui/simd/masked-load-store-check-fail.rs b/tests/ui/simd/masked-load-store-check-fail.rs index 39c82c41385ce..0f36bf6443f9b 100644 --- a/tests/ui/simd/masked-load-store-check-fail.rs +++ b/tests/ui/simd/masked-load-store-check-fail.rs @@ -1,10 +1,11 @@ //@ check-fail #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_masked_load(mask: M, pointer: P, values: T) -> T; - fn simd_masked_store(mask: M, pointer: P, values: T) -> (); -} +#[rustc_intrinsic] +unsafe fn simd_masked_load(mask: M, pointer: P, values: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_masked_store(mask: M, pointer: P, values: T) -> (); #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/masked-load-store-check-fail.stderr b/tests/ui/simd/masked-load-store-check-fail.stderr index 5d205d607c9f8..fa65798fc94d3 100644 --- a/tests/ui/simd/masked-load-store-check-fail.stderr +++ b/tests/ui/simd/masked-load-store-check-fail.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/masked-load-store-check-fail.rs:21:13 + --> $DIR/masked-load-store-check-fail.rs:22:13 | LL | let _x: Simd = simd_masked_load( | ---------------- arguments to this function are incorrect @@ -10,7 +10,7 @@ LL | Simd::([9; 4]) = note: expected struct `Simd<_, 2>` found struct `Simd<_, 4>` help: the return type of this call is `Simd` due to the type of the argument passed - --> $DIR/masked-load-store-check-fail.rs:18:31 + --> $DIR/masked-load-store-check-fail.rs:19:31 | LL | let _x: Simd = simd_masked_load( | _______________________________^ @@ -21,13 +21,13 @@ LL | | Simd::([9; 4]) LL | | ); | |_________^ note: function defined here - --> $DIR/masked-load-store-check-fail.rs:5:8 + --> $DIR/masked-load-store-check-fail.rs:5:11 | -LL | fn simd_masked_load(mask: M, pointer: P, values: T) -> T; - | ^^^^^^^^^^^^^^^^ +LL | unsafe fn simd_masked_load(mask: M, pointer: P, values: T) -> T; + | ^^^^^^^^^^^^^^^^ --------- error[E0308]: mismatched types - --> $DIR/masked-load-store-check-fail.rs:28:13 + --> $DIR/masked-load-store-check-fail.rs:29:13 | LL | let _x: Simd = simd_masked_load( | ---------------- arguments to this function are incorrect @@ -38,7 +38,7 @@ LL | default = note: expected struct `Simd` found struct `Simd` help: the return type of this call is `Simd` due to the type of the argument passed - --> $DIR/masked-load-store-check-fail.rs:25:32 + --> $DIR/masked-load-store-check-fail.rs:26:32 | LL | let _x: Simd = simd_masked_load( | ________________________________^ @@ -49,10 +49,10 @@ LL | | default LL | | ); | |_________^ note: function defined here - --> $DIR/masked-load-store-check-fail.rs:5:8 + --> $DIR/masked-load-store-check-fail.rs:5:11 | -LL | fn simd_masked_load(mask: M, pointer: P, values: T) -> T; - | ^^^^^^^^^^^^^^^^ +LL | unsafe fn simd_masked_load(mask: M, pointer: P, values: T) -> T; + | ^^^^^^^^^^^^^^^^ --------- error: aborting due to 2 previous errors diff --git a/tests/ui/simd/masked-load-store.rs b/tests/ui/simd/masked-load-store.rs index 902143f92615e..4b4195f51f186 100644 --- a/tests/ui/simd/masked-load-store.rs +++ b/tests/ui/simd/masked-load-store.rs @@ -1,10 +1,11 @@ //@ run-pass #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_masked_load(mask: M, pointer: P, values: T) -> T; - fn simd_masked_store(mask: M, pointer: P, values: T) -> (); -} +#[rustc_intrinsic] +unsafe fn simd_masked_load(mask: M, pointer: P, values: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_masked_store(mask: M, pointer: P, values: T) -> (); #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/monomorphize-shuffle-index.generic.stderr b/tests/ui/simd/monomorphize-shuffle-index.generic.stderr index 2d1fa1f8da225..b0a8da59fac1f 100644 --- a/tests/ui/simd/monomorphize-shuffle-index.generic.stderr +++ b/tests/ui/simd/monomorphize-shuffle-index.generic.stderr @@ -1,5 +1,5 @@ error: overly complex generic constant - --> $DIR/monomorphize-shuffle-index.rs:29:45 + --> $DIR/monomorphize-shuffle-index.rs:32:45 | LL | return simd_shuffle_generic::<_, _, { &Self::I.0 }>(a, b); | ^^----------^^ diff --git a/tests/ui/simd/monomorphize-shuffle-index.rs b/tests/ui/simd/monomorphize-shuffle-index.rs index 140cf6fbe96a9..01926408a2ceb 100644 --- a/tests/ui/simd/monomorphize-shuffle-index.rs +++ b/tests/ui/simd/monomorphize-shuffle-index.rs @@ -4,12 +4,15 @@ #![feature(repr_simd, intrinsics, adt_const_params, unsized_const_params, generic_const_exprs)] #![allow(incomplete_features)] -extern "rust-intrinsic" { - #[cfg(old)] - fn simd_shuffle(a: T, b: T, i: I) -> U; - #[cfg(any(generic, generic_with_fn))] - fn simd_shuffle_generic(a: T, b: T) -> U; -} + +#[rustc_intrinsic] +#[cfg(old)] +unsafe fn simd_shuffle(a: T, b: T, i: I) -> U; + +#[rustc_intrinsic] +#[cfg(any(generic, generic_with_fn))] +unsafe fn simd_shuffle_generic(a: T, b: T) -> U; + #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/repr_packed.rs b/tests/ui/simd/repr_packed.rs index 1ba15bda98dd2..a666892226eaa 100644 --- a/tests/ui/simd/repr_packed.rs +++ b/tests/ui/simd/repr_packed.rs @@ -22,9 +22,8 @@ fn check_ty() { check_size_align::(); } -extern "rust-intrinsic" { - fn simd_add(a: T, b: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_add(a: T, b: T) -> T; fn main() { check_ty::(); diff --git a/tests/ui/simd/shuffle.rs b/tests/ui/simd/shuffle.rs index 96c0ed2118f9e..2cae5a1e7de2a 100644 --- a/tests/ui/simd/shuffle.rs +++ b/tests/ui/simd/shuffle.rs @@ -8,9 +8,8 @@ use std::marker::ConstParamTy; -extern "rust-intrinsic" { - fn simd_shuffle(a: T, b: T, i: I) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_shuffle(a: T, b: T, i: I) -> U; #[derive(Copy, Clone, ConstParamTy, PartialEq, Eq)] #[repr(simd)] diff --git a/tests/ui/simd/simd-bitmask-notpow2.rs b/tests/ui/simd/simd-bitmask-notpow2.rs index 3499bf33ed577..d7572ef4a2a4d 100644 --- a/tests/ui/simd/simd-bitmask-notpow2.rs +++ b/tests/ui/simd/simd-bitmask-notpow2.rs @@ -4,10 +4,12 @@ //@ ignore-endian-big #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_bitmask(v: T) -> U; - fn simd_select_bitmask(m: T, a: U, b: U) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_bitmask(v: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_select_bitmask(m: T, a: U, b: U) -> U; + fn main() { // Non-power-of-2 multi-byte mask. diff --git a/tests/ui/simd/simd-bitmask.rs b/tests/ui/simd/simd-bitmask.rs index 82f73fca95124..4275ab0f40c9d 100644 --- a/tests/ui/simd/simd-bitmask.rs +++ b/tests/ui/simd/simd-bitmask.rs @@ -1,10 +1,12 @@ //@run-pass #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_bitmask(v: T) -> U; - fn simd_select_bitmask(m: T, a: U, b: U) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_bitmask(v: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_select_bitmask(m: T, a: U, b: U) -> U; + #[derive(Copy, Clone)] #[repr(simd)] From 7de67a16c57872a0529384bac04bbbe01eebc221 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 3 Feb 2025 12:51:58 +1100 Subject: [PATCH 7/9] Flatten the option check in `lower_pattern_range_endpoint` --- .../rustc_mir_build/src/thir/pattern/mod.rs | 59 +++++++++---------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 20a728d6d5b2c..f8f00c02ad2c8 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -159,38 +159,35 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { (Option>, Option>, Option), ErrorGuaranteed, > { - match expr { - None => Ok((None, None, None)), - Some(expr) => { - let (kind, ascr, inline_const) = match self.lower_lit(expr) { - PatKind::ExpandedConstant { subpattern, def_id, is_inline: true } => { - (subpattern.kind, None, def_id.as_local()) - } - PatKind::ExpandedConstant { subpattern, is_inline: false, .. } => { - (subpattern.kind, None, None) - } - PatKind::AscribeUserType { ascription, subpattern: box Pat { kind, .. } } => { - (kind, Some(ascription), None) - } - kind => (kind, None, None), - }; - let value = match kind { - PatKind::Constant { value } => value, - PatKind::ExpandedConstant { subpattern, .. } - if let PatKind::Constant { value } = subpattern.kind => - { - value - } - _ => { - let msg = format!( - "found bad range pattern endpoint `{expr:?}` outside of error recovery" - ); - return Err(self.tcx.dcx().span_delayed_bug(expr.span, msg)); - } - }; - Ok((Some(PatRangeBoundary::Finite(value)), ascr, inline_const)) + let Some(expr) = expr else { return Ok((None, None, None)) }; + + let (kind, ascr, inline_const) = match self.lower_lit(expr) { + PatKind::ExpandedConstant { subpattern, def_id, is_inline: true } => { + (subpattern.kind, None, def_id.as_local()) } - } + PatKind::ExpandedConstant { subpattern, is_inline: false, .. } => { + (subpattern.kind, None, None) + } + PatKind::AscribeUserType { ascription, subpattern: box Pat { kind, .. } } => { + (kind, Some(ascription), None) + } + kind => (kind, None, None), + }; + let value = match kind { + PatKind::Constant { value } => value, + PatKind::ExpandedConstant { subpattern, .. } + if let PatKind::Constant { value } = subpattern.kind => + { + value + } + _ => { + let msg = format!( + "found bad range pattern endpoint `{expr:?}` outside of error recovery" + ); + return Err(self.tcx.dcx().span_delayed_bug(expr.span, msg)); + } + }; + Ok((Some(PatRangeBoundary::Finite(value)), ascr, inline_const)) } /// Overflowing literals are linted against in a late pass. This is mostly fine, except when we From 85f4cdc62692f27e897ba0da2cd5fae30a19f740 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 3 Feb 2025 14:18:04 +1100 Subject: [PATCH 8/9] Return range endpoint ascriptions/consts via a `&mut Vec` --- .../rustc_mir_build/src/thir/pattern/mod.rs | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index f8f00c02ad2c8..3aa2b343b557a 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -155,11 +155,11 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { fn lower_pattern_range_endpoint( &mut self, expr: Option<&'tcx hir::PatExpr<'tcx>>, - ) -> Result< - (Option>, Option>, Option), - ErrorGuaranteed, - > { - let Some(expr) = expr else { return Ok((None, None, None)) }; + // Out-parameters collecting extra data to be reapplied by the caller + ascriptions: &mut Vec>, + inline_consts: &mut Vec, + ) -> Result>, ErrorGuaranteed> { + let Some(expr) = expr else { return Ok(None) }; let (kind, ascr, inline_const) = match self.lower_lit(expr) { PatKind::ExpandedConstant { subpattern, def_id, is_inline: true } => { @@ -187,7 +187,10 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { return Err(self.tcx.dcx().span_delayed_bug(expr.span, msg)); } }; - Ok((Some(PatRangeBoundary::Finite(value)), ascr, inline_const)) + + ascriptions.extend(ascr); + inline_consts.extend(inline_const); + Ok(Some(PatRangeBoundary::Finite(value))) } /// Overflowing literals are linted against in a late pass. This is mostly fine, except when we @@ -250,11 +253,15 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { self.tcx.dcx().span_bug(span, msg); } - let (lo, lo_ascr, lo_inline) = self.lower_pattern_range_endpoint(lo_expr)?; - let (hi, hi_ascr, hi_inline) = self.lower_pattern_range_endpoint(hi_expr)?; + // Collect extra data while lowering the endpoints, to be reapplied later. + let mut ascriptions = vec![]; + let mut inline_consts = vec![]; + + let mut lower_endpoint = + |expr| self.lower_pattern_range_endpoint(expr, &mut ascriptions, &mut inline_consts); - let lo = lo.unwrap_or(PatRangeBoundary::NegInfinity); - let hi = hi.unwrap_or(PatRangeBoundary::PosInfinity); + let lo = lower_endpoint(lo_expr)?.unwrap_or(PatRangeBoundary::NegInfinity); + let hi = lower_endpoint(hi_expr)?.unwrap_or(PatRangeBoundary::PosInfinity); let cmp = lo.compare_with(hi, ty, self.tcx, self.typing_env); let mut kind = PatKind::Range(Box::new(PatRange { lo, hi, end, ty })); @@ -295,13 +302,13 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { // If we are handling a range with associated constants (e.g. // `Foo::<'a>::A..=Foo::B`), we need to put the ascriptions for the associated // constants somewhere. Have them on the range pattern. - for ascription in [lo_ascr, hi_ascr].into_iter().flatten() { + for ascription in ascriptions { kind = PatKind::AscribeUserType { ascription, subpattern: Box::new(Pat { span, ty, kind }), }; } - for def in [lo_inline, hi_inline].into_iter().flatten() { + for def in inline_consts { kind = PatKind::ExpandedConstant { def_id: def.to_def_id(), is_inline: true, From 2fb1261c2156087d003359db25b13b282934669c Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 3 Feb 2025 14:29:13 +1100 Subject: [PATCH 9/9] Simplify the pattern unpeeling in `lower_pattern_range_endpoint` --- .../rustc_mir_build/src/thir/pattern/mod.rs | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 3aa2b343b557a..0aa61152330a7 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -161,35 +161,34 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { ) -> Result>, ErrorGuaranteed> { let Some(expr) = expr else { return Ok(None) }; - let (kind, ascr, inline_const) = match self.lower_lit(expr) { - PatKind::ExpandedConstant { subpattern, def_id, is_inline: true } => { - (subpattern.kind, None, def_id.as_local()) - } - PatKind::ExpandedConstant { subpattern, is_inline: false, .. } => { - (subpattern.kind, None, None) - } - PatKind::AscribeUserType { ascription, subpattern: box Pat { kind, .. } } => { - (kind, Some(ascription), None) - } - kind => (kind, None, None), - }; - let value = match kind { - PatKind::Constant { value } => value, - PatKind::ExpandedConstant { subpattern, .. } - if let PatKind::Constant { value } = subpattern.kind => - { - value - } - _ => { - let msg = format!( - "found bad range pattern endpoint `{expr:?}` outside of error recovery" - ); - return Err(self.tcx.dcx().span_delayed_bug(expr.span, msg)); + // Lower the endpoint into a temporary `PatKind` that will then be + // deconstructed to obtain the constant value and other data. + let mut kind: PatKind<'tcx> = self.lower_lit(expr); + + // Unpeel any ascription or inline-const wrapper nodes. + loop { + match kind { + PatKind::AscribeUserType { ascription, subpattern } => { + ascriptions.push(ascription); + kind = subpattern.kind; + } + PatKind::ExpandedConstant { is_inline, def_id, subpattern } => { + if is_inline { + inline_consts.extend(def_id.as_local()); + } + kind = subpattern.kind; + } + _ => break, } + } + + // The unpeeled kind should now be a constant, giving us the endpoint value. + let PatKind::Constant { value } = kind else { + let msg = + format!("found bad range pattern endpoint `{expr:?}` outside of error recovery"); + return Err(self.tcx.dcx().span_delayed_bug(expr.span, msg)); }; - ascriptions.extend(ascr); - inline_consts.extend(inline_const); Ok(Some(PatRangeBoundary::Finite(value))) }