Skip to content

Commit 59083c5

Browse files
committed
Auto merge of rust-lang#107967 - matthiaskrgr:rollup-7wvbla5, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#107748 (refer to new home) - rust-lang#107842 (Patch `build/rustfmt/lib/*.so` for NixOS) - rust-lang#107930 (Improve JS function itemTypeFromName code a bit) - rust-lang#107934 (rustdoc: account for intra-doc links in `<meta name="description">`) - rust-lang#107943 (Document `PointerLike`) - rust-lang#107954 (avoid mixing accesses of ptrs derived from a mutable ref and parent ptrs) - rust-lang#107955 (fix UB in ancient test) - rust-lang#107964 (rustdoc: use tighter line height in h1 and h2) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5b8f284 + 1d4397b commit 59083c5

File tree

16 files changed

+65
-32
lines changed

16 files changed

+65
-32
lines changed

compiler/rustc_session/src/session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub struct Session {
156156
/// `-C metadata` arguments passed to the compiler. Its value forms a unique
157157
/// global identifier for the crate. It is used to allow multiple crates
158158
/// with the same name to coexist. See the
159-
/// `rustc_codegen_llvm::back::symbol_names` module for more information.
159+
/// `rustc_symbol_mangling` crate for more information.
160160
pub stable_crate_id: OnceCell<StableCrateId>,
161161

162162
features: OnceCell<rustc_feature::Features>,

library/core/src/marker.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,10 @@ pub trait Destruct {}
871871
#[rustc_deny_explicit_impl]
872872
pub trait Tuple {}
873873

874-
/// A marker for things
874+
/// A marker for pointer-like types.
875+
///
876+
/// All types that have the same size and alignment as a `usize` or
877+
/// `*const ()` automatically implement this trait.
875878
#[unstable(feature = "pointer_like_trait", issue = "none")]
876879
#[cfg_attr(bootstrap, lang = "pointer_sized")]
877880
#[cfg_attr(not(bootstrap), lang = "pointer_like")]

library/core/tests/ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn test() {
2525
snd: isize,
2626
}
2727
let mut p = Pair { fst: 10, snd: 20 };
28-
let pptr: *mut Pair = &mut p;
28+
let pptr: *mut Pair = addr_of_mut!(p);
2929
let iptr: *mut isize = pptr as *mut isize;
3030
assert_eq!(*iptr, 10);
3131
*iptr = 30;
@@ -1070,8 +1070,8 @@ fn swap_copy_untyped() {
10701070
let mut x = 5u8;
10711071
let mut y = 6u8;
10721072

1073-
let ptr1 = &mut x as *mut u8 as *mut bool;
1074-
let ptr2 = &mut y as *mut u8 as *mut bool;
1073+
let ptr1 = addr_of_mut!(x).cast::<bool>();
1074+
let ptr2 = addr_of_mut!(y).cast::<bool>();
10751075

10761076
unsafe {
10771077
ptr::swap(ptr1, ptr2);

src/bootstrap/download.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ impl Config {
181181
// appear to have this (even when `../lib` is redundant).
182182
// NOTE: there are only two paths here, delimited by a `:`
183183
let mut entries = OsString::from("$ORIGIN/../lib:");
184-
entries.push(t!(fs::canonicalize(nix_deps_dir)));
185-
entries.push("/lib");
184+
entries.push(t!(fs::canonicalize(nix_deps_dir)).join("lib"));
186185
entries
187186
};
188187
patchelf.args(&[OsString::from("--set-rpath"), rpath_entries]);
@@ -370,6 +369,13 @@ impl Config {
370369
if self.should_fix_bins_and_dylibs() {
371370
self.fix_bin_or_dylib(&bin_root.join("bin").join("rustfmt"));
372371
self.fix_bin_or_dylib(&bin_root.join("bin").join("cargo-fmt"));
372+
let lib_dir = bin_root.join("lib");
373+
for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
374+
let lib = t!(lib);
375+
if lib.path().extension() == Some(OsStr::new("so")) {
376+
self.fix_bin_or_dylib(&lib.path());
377+
}
378+
}
373379
}
374380

375381
self.create(&rustfmt_stamp, &channel);

src/librustdoc/html/markdown.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1176,14 +1176,23 @@ pub(crate) fn short_markdown_summary(markdown: &str, link_names: &[RenderedLink]
11761176
/// - Headings, links, and formatting are stripped.
11771177
/// - Inline code is rendered as-is, surrounded by backticks.
11781178
/// - HTML and code blocks are ignored.
1179-
pub(crate) fn plain_text_summary(md: &str) -> String {
1179+
pub(crate) fn plain_text_summary(md: &str, link_names: &[RenderedLink]) -> String {
11801180
if md.is_empty() {
11811181
return String::new();
11821182
}
11831183

11841184
let mut s = String::with_capacity(md.len() * 3 / 2);
11851185

1186-
for event in Parser::new_ext(md, summary_opts()) {
1186+
let mut replacer = |broken_link: BrokenLink<'_>| {
1187+
link_names
1188+
.iter()
1189+
.find(|link| link.original_text.as_str() == &*broken_link.reference)
1190+
.map(|link| (link.href.as_str().into(), link.new_text.as_str().into()))
1191+
};
1192+
1193+
let p = Parser::new_with_broken_link_callback(md, summary_opts(), Some(&mut replacer));
1194+
1195+
for event in p {
11871196
match &event {
11881197
Event::Text(text) => s.push_str(text),
11891198
Event::Code(code) => {

src/librustdoc/html/markdown/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fn test_short_markdown_summary() {
249249
#[test]
250250
fn test_plain_text_summary() {
251251
fn t(input: &str, expect: &str) {
252-
let output = plain_text_summary(input);
252+
let output = plain_text_summary(input, &[]);
253253
assert_eq!(output, expect, "original: {}", input);
254254
}
255255

src/librustdoc/html/render/context.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ impl<'tcx> Context<'tcx> {
182182
};
183183
title.push_str(" - Rust");
184184
let tyname = it.type_();
185-
let desc = it.doc_value().as_ref().map(|doc| plain_text_summary(doc));
185+
let desc = it
186+
.doc_value()
187+
.as_ref()
188+
.map(|doc| plain_text_summary(doc, &it.link_names(&self.cache())));
186189
let desc = if let Some(desc) = desc {
187190
desc
188191
} else if it.is_crate() {

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

+8
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ h1, h2, h3, h4 {
174174
.top-doc .docblock > h4 {
175175
border-bottom: 1px solid var(--headings-border-bottom-color);
176176
}
177+
/* while line-height 1.5 is required for any "block of text",
178+
which WCAG defines as more than one sentence, it looks weird for
179+
very large main headers */
180+
h1, h2 {
181+
line-height: 1.25;
182+
padding-top: 3px;
183+
padding-bottom: 9px;
184+
}
177185
h3.code-header {
178186
font-size: 1.125rem; /* 18px */
179187
}

src/librustdoc/html/static/js/search.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,11 @@ function initSearch(rawSearchIndex) {
142142
}
143143

144144
function itemTypeFromName(typename) {
145-
for (let i = 0, len = itemTypes.length; i < len; ++i) {
146-
if (itemTypes[i] === typename) {
147-
return i;
148-
}
145+
const index = itemTypes.findIndex(i => i === typename);
146+
if (index < 0) {
147+
throw new Error("Unknown type filter `" + typename + "`");
149148
}
150-
151-
throw new Error("Unknown type filter `" + typename + "`");
149+
return index;
152150
}
153151

154152
/**

tests/rustdoc-gui/mobile.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ assert-css: (".main-heading", {
1212
"flex-direction": "column"
1313
})
1414

15-
assert-property: (".mobile-topbar h2", {"offsetHeight": 36})
15+
assert-property: (".mobile-topbar h2", {"offsetHeight": 33})
1616

1717
// Note: We can't use assert-text here because the 'Since' is set by CSS and
1818
// is therefore not part of the DOM.

tests/rustdoc-gui/scrape-examples-layout.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ assert-property: (
4040
store-value: (offset_y, 4)
4141

4242
// First with desktop
43-
assert-position: (".scraped-example .code-wrapper", {"y": 255})
44-
assert-position: (".scraped-example .code-wrapper .prev", {"y": 255 + |offset_y|})
43+
assert-position: (".scraped-example .code-wrapper", {"y": 253})
44+
assert-position: (".scraped-example .code-wrapper .prev", {"y": 253 + |offset_y|})
4545

4646
// Then with mobile
4747
size: (600, 600)
48-
assert-position: (".scraped-example .code-wrapper", {"y": 314})
49-
assert-position: (".scraped-example .code-wrapper .prev", {"y": 314 + |offset_y|})
48+
assert-position: (".scraped-example .code-wrapper", {"y": 308})
49+
assert-position: (".scraped-example .code-wrapper .prev", {"y": 308 + |offset_y|})

tests/rustdoc-gui/search-result-display.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ size: (900, 900)
2222

2323
// First we check the current width, height and position.
2424
assert-css: ("#crate-search", {"width": "223px"})
25-
assert-css: (".search-results-title", {"height": "44px", "width": "640px"})
25+
assert-css: (".search-results-title", {"height": "50px", "width": "640px"})
2626
assert-css: ("#search", {"width": "640px"})
2727

2828
// Then we update the text of one of the `<option>`.
@@ -33,7 +33,7 @@ text: (
3333

3434
// Then we compare again to confirm the height didn't change.
3535
assert-css: ("#crate-search", {"width": "527px"})
36-
assert-css: (".search-results-title", {"height": "44px", "width": "640px"})
36+
assert-css: (".search-results-title", {"height": "50px", "width": "640px"})
3737
// And we check that the `<select>` isn't bigger than its container (".search-results-title").
3838
assert-css: ("#search", {"width": "640px"})
3939

tests/rustdoc-gui/sidebar-mobile-scroll.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
66

77
// Scroll down.
88
scroll-to: "//h2[@id='blanket-implementations']"
9-
assert-window-property: {"pageYOffset": "627"}
9+
assert-window-property: {"pageYOffset": "622"}
1010

1111
// Open the sidebar menu.
1212
click: ".sidebar-menu-toggle"
@@ -21,11 +21,11 @@ assert-window-property: {"pageYOffset": "0"}
2121
// Close the sidebar menu. Make sure the scroll position gets restored.
2222
click: ".sidebar-menu-toggle"
2323
wait-for-css: (".sidebar", {"left": "-1000px"})
24-
assert-window-property: {"pageYOffset": "627"}
24+
assert-window-property: {"pageYOffset": "622"}
2525

2626
// Now test that scrollability returns when the browser window is just resized.
2727
click: ".sidebar-menu-toggle"
2828
wait-for-css: (".sidebar", {"left": "0px"})
2929
assert-window-property: {"pageYOffset": "0"}
3030
size: (900, 600)
31-
assert-window-property: {"pageYOffset": "627"}
31+
assert-window-property: {"pageYOffset": "622"}

tests/rustdoc-gui/sidebar-mobile.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ assert-property: (".mobile-topbar", {"clientHeight": "45"})
4545
// so the target is not obscured by the topbar.
4646
click: ".sidebar-menu-toggle"
4747
click: ".sidebar-elems section .block li > a"
48-
assert-position: ("#method\.must_use", {"y": 45})
48+
assert-position: ("#method\.must_use", {"y": 46})
4949

5050
// Check that the bottom-most item on the sidebar menu can be scrolled fully into view.
5151
click: ".sidebar-menu-toggle"

tests/rustdoc/description.rs

+6
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ pub mod foo_mod {
2222
// 'Only paragraph.'
2323
/// Only paragraph.
2424
pub fn foo_fn() {}
25+
26+
// @has 'foo/fn.bar_fn.html' '//meta[@name="description"]/@content' \
27+
// 'Description with intra-doc link to foo_fn and [nonexistent_item] and foo_fn.'
28+
#[allow(rustdoc::broken_intra_doc_links)]
29+
/// Description with intra-doc link to [foo_fn] and [nonexistent_item] and [foo_fn](self::foo_fn).
30+
pub fn bar_fn() {}

tests/ui/regions/regions-mock-codegen.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ struct Ccx {
2222
x: isize,
2323
}
2424

25-
fn allocate(_bcx: &arena) -> &Bcx<'_> {
25+
fn allocate(_bcx: &arena) -> &mut Bcx<'_> {
2626
unsafe {
2727
let layout = Layout::new::<Bcx>();
2828
let ptr = Global.allocate(layout).unwrap_or_else(|_| handle_alloc_error(layout));
29-
&*(ptr.as_ptr() as *const _)
29+
&mut *ptr.as_ptr().cast()
3030
}
3131
}
3232

33-
fn h<'a>(bcx: &'a Bcx<'a>) -> &'a Bcx<'a> {
33+
fn h<'a>(bcx: &'a Bcx<'a>) -> &'a mut Bcx<'a> {
3434
return allocate(bcx.fcx.arena);
3535
}
3636

3737
fn g(fcx: &Fcx) {
3838
let bcx = Bcx { fcx };
3939
let bcx2 = h(&bcx);
4040
unsafe {
41-
Global.deallocate(NonNull::new_unchecked(bcx2 as *const _ as *mut _), Layout::new::<Bcx>());
41+
Global.deallocate(NonNull::new_unchecked(bcx2 as *mut _ as *mut _), Layout::new::<Bcx>());
4242
}
4343
}
4444

0 commit comments

Comments
 (0)