Skip to content

Rollup of 8 pull requests #107967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub struct Session {
/// `-C metadata` arguments passed to the compiler. Its value forms a unique
/// global identifier for the crate. It is used to allow multiple crates
/// with the same name to coexist. See the
/// `rustc_codegen_llvm::back::symbol_names` module for more information.
/// `rustc_symbol_mangling` crate for more information.
pub stable_crate_id: OnceCell<StableCrateId>,

features: OnceCell<rustc_feature::Features>,
Expand Down
5 changes: 4 additions & 1 deletion library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,10 @@ pub trait Destruct {}
#[rustc_deny_explicit_impl]
pub trait Tuple {}

/// A marker for things
/// A marker for pointer-like types.
///
/// All types that have the same size and alignment as a `usize` or
/// `*const ()` automatically implement this trait.
#[unstable(feature = "pointer_like_trait", issue = "none")]
#[cfg_attr(bootstrap, lang = "pointer_sized")]
#[cfg_attr(not(bootstrap), lang = "pointer_like")]
Expand Down
6 changes: 3 additions & 3 deletions library/core/tests/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn test() {
snd: isize,
}
let mut p = Pair { fst: 10, snd: 20 };
let pptr: *mut Pair = &mut p;
let pptr: *mut Pair = addr_of_mut!(p);
let iptr: *mut isize = pptr as *mut isize;
assert_eq!(*iptr, 10);
*iptr = 30;
Expand Down Expand Up @@ -1070,8 +1070,8 @@ fn swap_copy_untyped() {
let mut x = 5u8;
let mut y = 6u8;

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

unsafe {
ptr::swap(ptr1, ptr2);
Expand Down
10 changes: 8 additions & 2 deletions src/bootstrap/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ impl Config {
// appear to have this (even when `../lib` is redundant).
// NOTE: there are only two paths here, delimited by a `:`
let mut entries = OsString::from("$ORIGIN/../lib:");
entries.push(t!(fs::canonicalize(nix_deps_dir)));
entries.push("/lib");
entries.push(t!(fs::canonicalize(nix_deps_dir)).join("lib"));
entries
};
patchelf.args(&[OsString::from("--set-rpath"), rpath_entries]);
Expand Down Expand Up @@ -370,6 +369,13 @@ impl Config {
if self.should_fix_bins_and_dylibs() {
self.fix_bin_or_dylib(&bin_root.join("bin").join("rustfmt"));
self.fix_bin_or_dylib(&bin_root.join("bin").join("cargo-fmt"));
let lib_dir = bin_root.join("lib");
for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
let lib = t!(lib);
if lib.path().extension() == Some(OsStr::new("so")) {
self.fix_bin_or_dylib(&lib.path());
}
}
}

self.create(&rustfmt_stamp, &channel);
Expand Down
13 changes: 11 additions & 2 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,14 +1176,23 @@ pub(crate) fn short_markdown_summary(markdown: &str, link_names: &[RenderedLink]
/// - Headings, links, and formatting are stripped.
/// - Inline code is rendered as-is, surrounded by backticks.
/// - HTML and code blocks are ignored.
pub(crate) fn plain_text_summary(md: &str) -> String {
pub(crate) fn plain_text_summary(md: &str, link_names: &[RenderedLink]) -> String {
if md.is_empty() {
return String::new();
}

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

for event in Parser::new_ext(md, summary_opts()) {
let mut replacer = |broken_link: BrokenLink<'_>| {
link_names
.iter()
.find(|link| link.original_text.as_str() == &*broken_link.reference)
.map(|link| (link.href.as_str().into(), link.new_text.as_str().into()))
};

let p = Parser::new_with_broken_link_callback(md, summary_opts(), Some(&mut replacer));

for event in p {
match &event {
Event::Text(text) => s.push_str(text),
Event::Code(code) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fn test_short_markdown_summary() {
#[test]
fn test_plain_text_summary() {
fn t(input: &str, expect: &str) {
let output = plain_text_summary(input);
let output = plain_text_summary(input, &[]);
assert_eq!(output, expect, "original: {}", input);
}

Expand Down
5 changes: 4 additions & 1 deletion src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ impl<'tcx> Context<'tcx> {
};
title.push_str(" - Rust");
let tyname = it.type_();
let desc = it.doc_value().as_ref().map(|doc| plain_text_summary(doc));
let desc = it
.doc_value()
.as_ref()
.map(|doc| plain_text_summary(doc, &it.link_names(&self.cache())));
let desc = if let Some(desc) = desc {
desc
} else if it.is_crate() {
Expand Down
8 changes: 8 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ h1, h2, h3, h4 {
.top-doc .docblock > h4 {
border-bottom: 1px solid var(--headings-border-bottom-color);
}
/* while line-height 1.5 is required for any "block of text",
which WCAG defines as more than one sentence, it looks weird for
very large main headers */
h1, h2 {
line-height: 1.25;
padding-top: 3px;
padding-bottom: 9px;
}
h3.code-header {
font-size: 1.125rem; /* 18px */
}
Expand Down
10 changes: 4 additions & 6 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,11 @@ function initSearch(rawSearchIndex) {
}

function itemTypeFromName(typename) {
for (let i = 0, len = itemTypes.length; i < len; ++i) {
if (itemTypes[i] === typename) {
return i;
}
const index = itemTypes.findIndex(i => i === typename);
if (index < 0) {
throw new Error("Unknown type filter `" + typename + "`");
}

throw new Error("Unknown type filter `" + typename + "`");
return index;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-gui/mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ assert-css: (".main-heading", {
"flex-direction": "column"
})

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

// Note: We can't use assert-text here because the 'Since' is set by CSS and
// is therefore not part of the DOM.
Expand Down
8 changes: 4 additions & 4 deletions tests/rustdoc-gui/scrape-examples-layout.goml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ assert-property: (
store-value: (offset_y, 4)

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

// Then with mobile
size: (600, 600)
assert-position: (".scraped-example .code-wrapper", {"y": 314})
assert-position: (".scraped-example .code-wrapper .prev", {"y": 314 + |offset_y|})
assert-position: (".scraped-example .code-wrapper", {"y": 308})
assert-position: (".scraped-example .code-wrapper .prev", {"y": 308 + |offset_y|})
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/search-result-display.goml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ size: (900, 900)

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

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

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

Expand Down
6 changes: 3 additions & 3 deletions tests/rustdoc-gui/sidebar-mobile-scroll.goml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ assert-css: (".sidebar", {"display": "block", "left": "-1000px"})

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

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

// Now test that scrollability returns when the browser window is just resized.
click: ".sidebar-menu-toggle"
wait-for-css: (".sidebar", {"left": "0px"})
assert-window-property: {"pageYOffset": "0"}
size: (900, 600)
assert-window-property: {"pageYOffset": "627"}
assert-window-property: {"pageYOffset": "622"}
2 changes: 1 addition & 1 deletion tests/rustdoc-gui/sidebar-mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ assert-property: (".mobile-topbar", {"clientHeight": "45"})
// so the target is not obscured by the topbar.
click: ".sidebar-menu-toggle"
click: ".sidebar-elems section .block li > a"
assert-position: ("#method\.must_use", {"y": 45})
assert-position: ("#method\.must_use", {"y": 46})

// Check that the bottom-most item on the sidebar menu can be scrolled fully into view.
click: ".sidebar-menu-toggle"
Expand Down
6 changes: 6 additions & 0 deletions tests/rustdoc/description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ pub mod foo_mod {
// 'Only paragraph.'
/// Only paragraph.
pub fn foo_fn() {}

// @has 'foo/fn.bar_fn.html' '//meta[@name="description"]/@content' \
// 'Description with intra-doc link to foo_fn and [nonexistent_item] and foo_fn.'
#[allow(rustdoc::broken_intra_doc_links)]
/// Description with intra-doc link to [foo_fn] and [nonexistent_item] and [foo_fn](self::foo_fn).
pub fn bar_fn() {}
8 changes: 4 additions & 4 deletions tests/ui/regions/regions-mock-codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ struct Ccx {
x: isize,
}

fn allocate(_bcx: &arena) -> &Bcx<'_> {
fn allocate(_bcx: &arena) -> &mut Bcx<'_> {
unsafe {
let layout = Layout::new::<Bcx>();
let ptr = Global.allocate(layout).unwrap_or_else(|_| handle_alloc_error(layout));
&*(ptr.as_ptr() as *const _)
&mut *ptr.as_ptr().cast()
}
}

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

fn g(fcx: &Fcx) {
let bcx = Bcx { fcx };
let bcx2 = h(&bcx);
unsafe {
Global.deallocate(NonNull::new_unchecked(bcx2 as *const _ as *mut _), Layout::new::<Bcx>());
Global.deallocate(NonNull::new_unchecked(bcx2 as *mut _ as *mut _), Layout::new::<Bcx>());
}
}

Expand Down