diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index d5f806308cf41..6b529d5e0837b 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -279,6 +279,7 @@ impl DefId { } #[inline] + #[track_caller] pub fn expect_local(self) -> LocalDefId { self.as_local().unwrap_or_else(|| panic!("DefId::expect_local: `{:?}` isn't local", self)) } diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index bddbe2b9b0df1..4e32c514d5f68 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -981,7 +981,7 @@ extern "rust-intrinsic" { /// /// Turning a pointer into a `usize`: /// - /// ``` + /// ```no_run /// let ptr = &0; /// let ptr_num_transmute = unsafe { /// std::mem::transmute::<&i32, usize>(ptr) diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 7ef2e95542bba..45964c3a444fe 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -518,7 +518,7 @@ impl *const T { } /// Calculates the distance between two pointers. The returned value is in - /// units of T: the distance in bytes is divided by `mem::size_of::()`. + /// units of T: the distance in bytes divided by `mem::size_of::()`. /// /// This function is the inverse of [`offset`]. /// diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 56f9c84f5af6f..ff5207c1a06e1 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -696,7 +696,7 @@ impl *mut T { } /// Calculates the distance between two pointers. The returned value is in - /// units of T: the distance in bytes is divided by `mem::size_of::()`. + /// units of T: the distance in bytes divided by `mem::size_of::()`. /// /// This function is the inverse of [`offset`]. /// diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 9b5e5d6c0cc4b..dd316bdb2c6ce 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -1222,6 +1222,23 @@ impl OsStr { } } +#[unstable(feature = "slice_concat_ext", issue = "27747")] +impl> alloc::slice::Join<&OsStr> for [S] { + type Output = OsString; + + fn join(slice: &Self, sep: &OsStr) -> OsString { + let Some(first) = slice.first() else { + return OsString::new(); + }; + let first = first.borrow().to_owned(); + slice[1..].iter().fold(first, |mut a, b| { + a.push(sep); + a.push(b.borrow()); + a + }) + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Borrow for OsString { #[inline] diff --git a/library/std/src/ffi/os_str/tests.rs b/library/std/src/ffi/os_str/tests.rs index 283f2b577e896..d7926749aae20 100644 --- a/library/std/src/ffi/os_str/tests.rs +++ b/library/std/src/ffi/os_str/tests.rs @@ -84,6 +84,20 @@ fn test_os_string_reserve_exact() { assert!(os_string.capacity() >= 33) } +#[test] +fn test_os_string_join() { + let strings = [OsStr::new("hello"), OsStr::new("dear"), OsStr::new("world")]; + assert_eq!("hello", strings[..1].join(OsStr::new(" "))); + assert_eq!("hello dear world", strings.join(OsStr::new(" "))); + assert_eq!("hellodearworld", strings.join(OsStr::new(""))); + assert_eq!("hello.\n dear.\n world", strings.join(OsStr::new(".\n "))); + + assert_eq!("dear world", strings[1..].join(&OsString::from(" "))); + + let strings_abc = [OsString::from("a"), OsString::from("b"), OsString::from("c")]; + assert_eq!("a b c", strings_abc.join(OsStr::new(" "))); +} + #[test] fn test_os_string_default() { let os_string: OsString = Default::default(); diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 97c30c422827e..d70befa9d20c8 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -241,6 +241,7 @@ #![feature(intra_doc_pointers)] #![feature(lang_items)] #![feature(let_chains)] +#![feature(let_else)] #![feature(linkage)] #![feature(min_specialization)] #![feature(must_not_suspend)] @@ -300,6 +301,7 @@ #![feature(toowned_clone_into)] #![feature(try_reserve_kind)] #![feature(vec_into_raw_parts)] +#![feature(slice_concat_trait)] // // Library features (unwind): #![feature(panic_unwind)] diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 81c12be8e83c0..12059e0b9c4b5 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1401,6 +1401,18 @@ pre.rust { cursor: pointer; } +@keyframes rotating { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} +#settings-menu.rotate img { + animation: rotating 2s linear infinite; +} + #help-button { font-family: "Fira Sans", Arial, sans-serif; text-align: center; diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 667f89c07e212..66a7d484f33b0 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -301,7 +301,11 @@ function loadCss(cssFileName) { } getSettingsButton().onclick = event => { + addClass(getSettingsButton(), "rotate"); event.preventDefault(); + // Sending request for the CSS and the JS files at the same time so it will + // hopefully be loaded when the JS will generate the settings content. + loadCss("settings"); loadScript(window.settingsJS); }; diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js index 119d4b07665a4..e447d09ab6b97 100644 --- a/src/librustdoc/html/static/js/settings.js +++ b/src/librustdoc/html/static/js/settings.js @@ -3,7 +3,7 @@ /* eslint prefer-const: "error" */ /* eslint prefer-arrow-callback: "error" */ // Local js definitions: -/* global getSettingValue, getVirtualKey, updateLocalStorage, updateSystemTheme, loadCss */ +/* global getSettingValue, getVirtualKey, updateLocalStorage, updateSystemTheme */ /* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */ /* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */ @@ -209,9 +209,6 @@ }, ]; - // First, we add the settings.css file. - loadCss("settings"); - // Then we build the DOM. const el = document.createElement("section"); el.id = "settings"; @@ -274,5 +271,6 @@ if (!isSettingsPage) { switchDisplayedElement(settingsMenu); } + removeClass(getSettingsButton(), "rotate"); }, 0); })(); diff --git a/src/test/ui/lifetimes/issue-64173-unused-lifetimes.rs b/src/test/ui/lifetimes/issue-64173-unused-lifetimes.rs new file mode 100644 index 0000000000000..8080dd7dc34db --- /dev/null +++ b/src/test/ui/lifetimes/issue-64173-unused-lifetimes.rs @@ -0,0 +1,19 @@ +use std::mem::size_of; + +struct Foo<'s> { //~ ERROR: parameter `'s` is never used + array: [(); size_of::<&Self>()], + //~^ ERROR: generic `Self` types are currently not permitted in anonymous constants +} + +// The below is taken from https://github.com/rust-lang/rust/issues/66152#issuecomment-550275017 +// as the root cause seems the same. + +const fn foo() -> usize { + 0 +} + +struct Bar<'a> { //~ ERROR: parameter `'a` is never used + beta: [(); foo::<&'a ()>()], //~ ERROR: a non-static lifetime is not allowed in a `const` +} + +fn main() {} diff --git a/src/test/ui/lifetimes/issue-64173-unused-lifetimes.stderr b/src/test/ui/lifetimes/issue-64173-unused-lifetimes.stderr new file mode 100644 index 0000000000000..a487cbea5371b --- /dev/null +++ b/src/test/ui/lifetimes/issue-64173-unused-lifetimes.stderr @@ -0,0 +1,35 @@ +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/issue-64173-unused-lifetimes.rs:16:23 + | +LL | beta: [(); foo::<&'a ()>()], + | ^^ + | + = note: see issue #76560 for more information + = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable + +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-64173-unused-lifetimes.rs:4:28 + | +LL | array: [(); size_of::<&Self>()], + | ^^^^ + +error[E0392]: parameter `'s` is never used + --> $DIR/issue-64173-unused-lifetimes.rs:3:12 + | +LL | struct Foo<'s> { + | ^^ unused parameter + | + = help: consider removing `'s`, referring to it in a field, or using a marker such as `PhantomData` + +error[E0392]: parameter `'a` is never used + --> $DIR/issue-64173-unused-lifetimes.rs:15:12 + | +LL | struct Bar<'a> { + | ^^ unused parameter + | + = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0392, E0658. +For more information about an error, try `rustc --explain E0392`.