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
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 = "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 :(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