Skip to content

Rollup of 18 pull requests #139612

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

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a11fbee
Small code improvement in rustdoc hidden stripper
GuillaumeGomez Mar 7, 2025
e89c849
Clean up librustdoc::html::render to be better encapsulated
xizheyin Mar 17, 2025
abe6e88
Allow drivers to supply a list of extra symbols to intern
Alexendoo Mar 19, 2025
f9770e7
Test linking and running no_std binaries
madsmtm Mar 24, 2025
b8c4c16
Suppress missing field error when autoderef bottoms out in infer
compiler-errors Apr 5, 2025
34e9759
compiletest: Trim whitespace from environment variable names
Zalathar Apr 8, 2025
a0d9c87
Inline `calc_default_binding_mode`
Nadrieril Apr 6, 2025
9f57903
Insert adjustments incrementally
Nadrieril Apr 6, 2025
19950b5
Turn the peeling loop into a recursive call
Nadrieril Apr 6, 2025
38adb99
Reorganize `check_pat_inner`
Nadrieril Apr 6, 2025
6588018
Return a type from `check_pat_inner`
Nadrieril Apr 6, 2025
f458151
Remove redundant assignment
Nadrieril Apr 6, 2025
12311ef
fix title of offset_of_enum feature
programmerjake Apr 8, 2025
f151cea
emit a better error message for using the macro incorrectly
ZuseZ4 Apr 9, 2025
f419b18
Return early on an error path in `parse_item_impl`.
nnethercote Apr 8, 2025
7ae5c7f
Avoid an empty trait name in impl blocks.
nnethercote Apr 9, 2025
b2aa9d0
Remove some dead or leftover code related to rustc-intrinsic abi removal
oli-obk Apr 8, 2025
cf68565
Temporarily leave the review rotation
fmease Apr 9, 2025
32c8f7d
librustdoc: remove IndexItem::new, use previous fields constructor
xizheyin Apr 9, 2025
67ff336
saethlin is back from vacation
saethlin Apr 9, 2025
50d0ce1
Ensure `swap_nonoverlapping` is really always untyped
scottmcm Feb 22, 2025
b06a88f
Add a Miri test for 134713
scottmcm Feb 22, 2025
8b227a4
rustdoc: Enable Markdown extensions when looking for doctests
camelid Apr 9, 2025
63dcac8
skip `tests/codegen/swap-small-types` when debug assertions are on
scottmcm Apr 9, 2025
7103aea
Tracking issue template: fine-grained information on style update status
joshtriplett Apr 9, 2025
d21ee7e
Update `compiler-builtins` to 0.1.153
tgross35 Apr 9, 2025
99b048c
compiletest: update to Edition 2024
jieyouxu Apr 10, 2025
37c9a3c
Rollup merge of #137412 - scottmcm:redo-swap, r=cuviper
Zalathar Apr 10, 2025
d5f5509
Rollup merge of #138167 - GuillaumeGomez:rustdoc-hidden-stripper-impr…
Zalathar Apr 10, 2025
3a9ab8d
Rollup merge of #138605 - xizheyin:issue-138567, r=GuillaumeGomez
Zalathar Apr 10, 2025
af220c3
Rollup merge of #138682 - Alexendoo:extra-symbols, r=fee1-dead
Zalathar Apr 10, 2025
b7a7423
Rollup merge of #138904 - madsmtm:apple-test-no-std, r=tgross35
Zalathar Apr 10, 2025
0f80846
Rollup merge of #139423 - compiler-errors:field-autoderef, r=oli-obk
Zalathar Apr 10, 2025
6171b06
Rollup merge of #139449 - Nadrieril:peel-recursive, r=lcnr
Zalathar Apr 10, 2025
f5b6e88
Rollup merge of #139507 - Zalathar:trim-env-name, r=jieyouxu
Zalathar Apr 10, 2025
b316fb7
Rollup merge of #139530 - oli-obk:rustc-intrinsic-cleanup, r=RalfJung
Zalathar Apr 10, 2025
3657f4d
Rollup merge of #139560 - programmerjake:patch-5, r=jieyouxu
Zalathar Apr 10, 2025
a41c699
Rollup merge of #139563 - EnzymeAD:better-autodiff-err, r=jieyouxu
Zalathar Apr 10, 2025
49e0b9e
Rollup merge of #139568 - nnethercote:empty-trait-name, r=compiler-er…
Zalathar Apr 10, 2025
3358dce
Rollup merge of #139580 - fmease:unrotate, r=fmease
Zalathar Apr 10, 2025
13faa56
Rollup merge of #139589 - saethlin:vacation, r=camelid
Zalathar Apr 10, 2025
aacbcd1
Rollup merge of #139592 - camelid:doctest-md-opts, r=notriddle
Zalathar Apr 10, 2025
9145955
Rollup merge of #139599 - joshtriplett:style-tracking, r=traviscross
Zalathar Apr 10, 2025
57db7af
Rollup merge of #139600 - tgross35:update-builtins, r=tgross35
Zalathar Apr 10, 2025
e43645e
Rollup merge of #139606 - jieyouxu:compiletest-edition2024, r=compile…
Zalathar Apr 10, 2025
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
Prev Previous commit
Next Next commit
Clean up librustdoc::html::render to be better encapsulated
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
  • Loading branch information
xizheyin committed Mar 24, 2025
commit e89c84913690bad837b658ade502cb0af7df768b
14 changes: 7 additions & 7 deletions src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,20 +574,20 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
);
let aliases = item.attrs.get_doc_aliases();
let deprecation = item.deprecation(tcx);
let index_item = IndexItem {
ty: item.type_(),
defid: Some(defid),
let index_item = IndexItem::new(
item.type_(),
Some(defid),
name,
path,
desc,
parent: parent_did,
parent_idx: None,
exact_path: None,
parent_did,
None,
None,
impl_id,
search_type,
aliases,
deprecation,
};
);
cache.search_index.push(index_item);
}

Expand Down
93 changes: 61 additions & 32 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
//! is cloned per-thread and contains information about what is currently being
//! rendered.
//!
//! The main entry point to the rendering system is the implementation of
//! `FormatRenderer` on `Context`.
//!
//! In order to speed up rendering (mostly because of markdown rendering), the
//! rendering process has been parallelized. This parallelization is only
//! exposed through the `crate` method on the context, and then also from the
Expand Down Expand Up @@ -90,15 +93,15 @@ pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display {
/// Specifies whether rendering directly implemented trait items or ones from a certain Deref
/// impl.
#[derive(Copy, Clone, Debug)]
pub(crate) enum AssocItemRender<'a> {
enum AssocItemRender<'a> {
All,
DerefFor { trait_: &'a clean::Path, type_: &'a clean::Type, deref_mut_: bool },
}

/// For different handling of associated items from the Deref target of a type rather than the type
/// itself.
#[derive(Copy, Clone, PartialEq)]
pub(crate) enum RenderMode {
enum RenderMode {
Normal,
ForDeref { mut_: bool },
}
Expand All @@ -110,23 +113,55 @@ pub(crate) enum RenderMode {
/// by hand to a large JS file at the end of cache-creation.
#[derive(Debug)]
pub(crate) struct IndexItem {
pub(crate) ty: ItemType,
pub(crate) defid: Option<DefId>,
pub(crate) name: Symbol,
pub(crate) path: String,
pub(crate) desc: String,
pub(crate) parent: Option<DefId>,
pub(crate) parent_idx: Option<isize>,
pub(crate) exact_path: Option<String>,
pub(crate) impl_id: Option<DefId>,
pub(crate) search_type: Option<IndexItemFunctionType>,
pub(crate) aliases: Box<[Symbol]>,
pub(crate) deprecation: Option<Deprecation>,
ty: ItemType,
defid: Option<DefId>,
name: Symbol,
path: String,
desc: String,
parent: Option<DefId>,
parent_idx: Option<isize>,
exact_path: Option<String>,
impl_id: Option<DefId>,
search_type: Option<IndexItemFunctionType>,
aliases: Box<[Symbol]>,
deprecation: Option<Deprecation>,
}

impl IndexItem {
pub fn new(
ty: ItemType,
defid: Option<DefId>,
name: Symbol,
path: String,
desc: String,
parent: Option<DefId>,
parent_idx: Option<isize>,
exact_path: Option<String>,
impl_id: Option<DefId>,
search_type: Option<IndexItemFunctionType>,
aliases: Box<[Symbol]>,
deprecation: Option<Deprecation>,
) -> Self {
Self {
ty,
defid,
name,
path,
desc,
parent,
parent_idx,
exact_path,
impl_id,
search_type,
aliases,
deprecation,
}
}
}

/// A type used for the search index.
#[derive(Debug, Eq, PartialEq)]
pub(crate) struct RenderType {
struct RenderType {
id: Option<RenderTypeId>,
generics: Option<Vec<RenderType>>,
bindings: Option<Vec<(RenderTypeId, Vec<RenderType>)>>,
Expand All @@ -137,7 +172,7 @@ impl RenderType {
// The contents of the lists are always integers in self-terminating hex
// form, handled by `RenderTypeId::write_to_string`, so no commas are
// needed to separate the items.
pub fn write_to_string(&self, string: &mut String) {
fn write_to_string(&self, string: &mut String) {
fn write_optional_id(id: Option<RenderTypeId>, string: &mut String) {
// 0 is a sentinel, everything else is one-indexed
match id {
Expand Down Expand Up @@ -177,7 +212,7 @@ impl RenderType {
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum RenderTypeId {
enum RenderTypeId {
DefId(DefId),
Primitive(clean::PrimitiveType),
AssociatedType(Symbol),
Expand All @@ -186,7 +221,7 @@ pub(crate) enum RenderTypeId {
}

impl RenderTypeId {
pub fn write_to_string(&self, string: &mut String) {
fn write_to_string(&self, string: &mut String) {
let id: i32 = match &self {
// 0 is a sentinel, everything else is one-indexed
// concrete type
Expand All @@ -209,7 +244,7 @@ pub(crate) struct IndexItemFunctionType {
}

impl IndexItemFunctionType {
pub fn write_to_string<'a>(
fn write_to_string<'a>(
&'a self,
string: &mut String,
backref_queue: &mut VecDeque<&'a IndexItemFunctionType>,
Expand Down Expand Up @@ -309,7 +344,7 @@ impl ItemEntry {
}

impl ItemEntry {
pub(crate) fn print(&self) -> impl fmt::Display {
fn print(&self) -> impl fmt::Display {
fmt::from_fn(move |f| write!(f, "<a href=\"{}\">{}</a>", self.url, Escape(&self.name)))
}
}
Expand Down Expand Up @@ -760,7 +795,7 @@ fn short_item_info(

// Render the list of items inside one of the sections "Trait Implementations",
// "Auto Trait Implementations," "Blanket Trait Implementations" (on struct/enum pages).
pub(crate) fn render_impls(
fn render_impls(
cx: &Context<'_>,
mut w: impl Write,
impls: &[&Impl],
Expand Down Expand Up @@ -1201,7 +1236,7 @@ impl<'a> AssocItemLink<'a> {
}
}

pub fn write_section_heading(
fn write_section_heading(
title: &str,
id: &str,
extra_class: Option<&str>,
Expand All @@ -1226,7 +1261,7 @@ fn write_impl_section_heading(title: &str, id: &str) -> impl fmt::Display {
write_section_heading(title, id, None, "")
}

pub(crate) fn render_all_impls(
fn render_all_impls(
mut w: impl Write,
cx: &Context<'_>,
containing_item: &clean::Item,
Expand Down Expand Up @@ -1473,10 +1508,7 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) ->
}
}

pub(crate) fn notable_traits_button(
ty: &clean::Type,
cx: &Context<'_>,
) -> Option<impl fmt::Display> {
fn notable_traits_button(ty: &clean::Type, cx: &Context<'_>) -> Option<impl fmt::Display> {
if ty.is_unit() {
// Very common fast path.
return None;
Expand Down Expand Up @@ -1588,10 +1620,7 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
(format!("{:#}", ty.print(cx)), out)
}

pub(crate) fn notable_traits_json<'a>(
tys: impl Iterator<Item = &'a clean::Type>,
cx: &Context<'_>,
) -> String {
fn notable_traits_json<'a>(tys: impl Iterator<Item = &'a clean::Type>, cx: &Context<'_>) -> String {
let mut mp: Vec<(String, String)> = tys.map(|ty| notable_traits_decl(ty, cx)).collect();
mp.sort_by(|(name1, _html1), (name2, _html2)| name1.cmp(name2));
struct NotableTraitsMap(Vec<(String, String)>);
Expand Down Expand Up @@ -2171,7 +2200,7 @@ fn render_rightside(
})
}

pub(crate) fn render_impl_summary(
fn render_impl_summary(
cx: &Context<'_>,
i: &Impl,
parent: &clean::Item,
Expand Down
Loading