Skip to content

Commit 9714e13

Browse files
committed
Auto merge of #96759 - compiler-errors:rollup-p4jtm92, r=compiler-errors
Rollup of 7 pull requests Successful merges: - #96174 (mark ptr-int-transmute test as no_run) - #96639 (Fix typo in `offset_from` documentation) - #96704 (Add rotation animation on settings button when loading) - #96730 (Add a regression test for #64173 and #66152) - #96741 (Improve settings loading strategy) - #96744 (Implement [OsStr]::join) - #96747 (Add `track_caller` to `DefId::expect_local()`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 74cea9f + b8c829b commit 9714e13

File tree

12 files changed

+109
-7
lines changed

12 files changed

+109
-7
lines changed

compiler/rustc_span/src/def_id.rs

+1
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ impl DefId {
279279
}
280280

281281
#[inline]
282+
#[track_caller]
282283
pub fn expect_local(self) -> LocalDefId {
283284
self.as_local().unwrap_or_else(|| panic!("DefId::expect_local: `{:?}` isn't local", self))
284285
}

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ extern "rust-intrinsic" {
981981
///
982982
/// Turning a pointer into a `usize`:
983983
///
984-
/// ```
984+
/// ```no_run
985985
/// let ptr = &0;
986986
/// let ptr_num_transmute = unsafe {
987987
/// std::mem::transmute::<&i32, usize>(ptr)

library/core/src/ptr/const_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl<T: ?Sized> *const T {
518518
}
519519

520520
/// Calculates the distance between two pointers. The returned value is in
521-
/// units of T: the distance in bytes is divided by `mem::size_of::<T>()`.
521+
/// units of T: the distance in bytes divided by `mem::size_of::<T>()`.
522522
///
523523
/// This function is the inverse of [`offset`].
524524
///

library/core/src/ptr/mut_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ impl<T: ?Sized> *mut T {
696696
}
697697

698698
/// Calculates the distance between two pointers. The returned value is in
699-
/// units of T: the distance in bytes is divided by `mem::size_of::<T>()`.
699+
/// units of T: the distance in bytes divided by `mem::size_of::<T>()`.
700700
///
701701
/// This function is the inverse of [`offset`].
702702
///

library/std/src/ffi/os_str.rs

+17
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,23 @@ impl OsStr {
12221222
}
12231223
}
12241224

1225+
#[unstable(feature = "slice_concat_ext", issue = "27747")]
1226+
impl<S: Borrow<OsStr>> alloc::slice::Join<&OsStr> for [S] {
1227+
type Output = OsString;
1228+
1229+
fn join(slice: &Self, sep: &OsStr) -> OsString {
1230+
let Some(first) = slice.first() else {
1231+
return OsString::new();
1232+
};
1233+
let first = first.borrow().to_owned();
1234+
slice[1..].iter().fold(first, |mut a, b| {
1235+
a.push(sep);
1236+
a.push(b.borrow());
1237+
a
1238+
})
1239+
}
1240+
}
1241+
12251242
#[stable(feature = "rust1", since = "1.0.0")]
12261243
impl Borrow<OsStr> for OsString {
12271244
#[inline]

library/std/src/ffi/os_str/tests.rs

+14
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ fn test_os_string_reserve_exact() {
8484
assert!(os_string.capacity() >= 33)
8585
}
8686

87+
#[test]
88+
fn test_os_string_join() {
89+
let strings = [OsStr::new("hello"), OsStr::new("dear"), OsStr::new("world")];
90+
assert_eq!("hello", strings[..1].join(OsStr::new(" ")));
91+
assert_eq!("hello dear world", strings.join(OsStr::new(" ")));
92+
assert_eq!("hellodearworld", strings.join(OsStr::new("")));
93+
assert_eq!("hello.\n dear.\n world", strings.join(OsStr::new(".\n ")));
94+
95+
assert_eq!("dear world", strings[1..].join(&OsString::from(" ")));
96+
97+
let strings_abc = [OsString::from("a"), OsString::from("b"), OsString::from("c")];
98+
assert_eq!("a b c", strings_abc.join(OsStr::new(" ")));
99+
}
100+
87101
#[test]
88102
fn test_os_string_default() {
89103
let os_string: OsString = Default::default();

library/std/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
#![feature(intra_doc_pointers)]
242242
#![feature(lang_items)]
243243
#![feature(let_chains)]
244+
#![feature(let_else)]
244245
#![feature(linkage)]
245246
#![feature(min_specialization)]
246247
#![feature(must_not_suspend)]
@@ -300,6 +301,7 @@
300301
#![feature(toowned_clone_into)]
301302
#![feature(try_reserve_kind)]
302303
#![feature(vec_into_raw_parts)]
304+
#![feature(slice_concat_trait)]
303305
//
304306
// Library features (unwind):
305307
#![feature(panic_unwind)]

src/librustdoc/html/static/css/rustdoc.css

+12
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,18 @@ pre.rust {
14011401
cursor: pointer;
14021402
}
14031403

1404+
@keyframes rotating {
1405+
from {
1406+
transform: rotate(0deg);
1407+
}
1408+
to {
1409+
transform: rotate(360deg);
1410+
}
1411+
}
1412+
#settings-menu.rotate img {
1413+
animation: rotating 2s linear infinite;
1414+
}
1415+
14041416
#help-button {
14051417
font-family: "Fira Sans", Arial, sans-serif;
14061418
text-align: center;

src/librustdoc/html/static/js/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@ function loadCss(cssFileName) {
301301
}
302302

303303
getSettingsButton().onclick = event => {
304+
addClass(getSettingsButton(), "rotate");
304305
event.preventDefault();
306+
// Sending request for the CSS and the JS files at the same time so it will
307+
// hopefully be loaded when the JS will generate the settings content.
308+
loadCss("settings");
305309
loadScript(window.settingsJS);
306310
};
307311

src/librustdoc/html/static/js/settings.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* eslint prefer-const: "error" */
44
/* eslint prefer-arrow-callback: "error" */
55
// Local js definitions:
6-
/* global getSettingValue, getVirtualKey, updateLocalStorage, updateSystemTheme, loadCss */
6+
/* global getSettingValue, getVirtualKey, updateLocalStorage, updateSystemTheme */
77
/* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */
88
/* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */
99

@@ -209,9 +209,6 @@
209209
},
210210
];
211211

212-
// First, we add the settings.css file.
213-
loadCss("settings");
214-
215212
// Then we build the DOM.
216213
const el = document.createElement("section");
217214
el.id = "settings";
@@ -274,5 +271,6 @@
274271
if (!isSettingsPage) {
275272
switchDisplayedElement(settingsMenu);
276273
}
274+
removeClass(getSettingsButton(), "rotate");
277275
}, 0);
278276
})();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::mem::size_of;
2+
3+
struct Foo<'s> { //~ ERROR: parameter `'s` is never used
4+
array: [(); size_of::<&Self>()],
5+
//~^ ERROR: generic `Self` types are currently not permitted in anonymous constants
6+
}
7+
8+
// The below is taken from https://github.com/rust-lang/rust/issues/66152#issuecomment-550275017
9+
// as the root cause seems the same.
10+
11+
const fn foo<T>() -> usize {
12+
0
13+
}
14+
15+
struct Bar<'a> { //~ ERROR: parameter `'a` is never used
16+
beta: [(); foo::<&'a ()>()], //~ ERROR: a non-static lifetime is not allowed in a `const`
17+
}
18+
19+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error[E0658]: a non-static lifetime is not allowed in a `const`
2+
--> $DIR/issue-64173-unused-lifetimes.rs:16:23
3+
|
4+
LL | beta: [(); foo::<&'a ()>()],
5+
| ^^
6+
|
7+
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
8+
= help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
9+
10+
error: generic `Self` types are currently not permitted in anonymous constants
11+
--> $DIR/issue-64173-unused-lifetimes.rs:4:28
12+
|
13+
LL | array: [(); size_of::<&Self>()],
14+
| ^^^^
15+
16+
error[E0392]: parameter `'s` is never used
17+
--> $DIR/issue-64173-unused-lifetimes.rs:3:12
18+
|
19+
LL | struct Foo<'s> {
20+
| ^^ unused parameter
21+
|
22+
= help: consider removing `'s`, referring to it in a field, or using a marker such as `PhantomData`
23+
24+
error[E0392]: parameter `'a` is never used
25+
--> $DIR/issue-64173-unused-lifetimes.rs:15:12
26+
|
27+
LL | struct Bar<'a> {
28+
| ^^ unused parameter
29+
|
30+
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
31+
32+
error: aborting due to 4 previous errors
33+
34+
Some errors have detailed explanations: E0392, E0658.
35+
For more information about an error, try `rustc --explain E0392`.

0 commit comments

Comments
 (0)