Skip to content

Commit 1528cc2

Browse files
committed
librustdoc: 2024 edition! 🎊
1 parent 96cfc75 commit 1528cc2

File tree

10 files changed

+33
-32
lines changed

10 files changed

+33
-32
lines changed

src/librustdoc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustdoc"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55
build = "build.rs"
66

77
[lib]

src/librustdoc/clean/cfg.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ impl Cfg {
4848
exclude: &FxHashSet<Cfg>,
4949
) -> Result<Option<Cfg>, InvalidCfgError> {
5050
match nested_cfg {
51-
MetaItemInner::MetaItem(ref cfg) => Cfg::parse_without(cfg, exclude),
51+
MetaItemInner::MetaItem(cfg) => Cfg::parse_without(cfg, exclude),
5252
MetaItemInner::Lit(MetaItemLit { kind: LitKind::Bool(b), .. }) => match *b {
5353
true => Ok(Some(Cfg::True)),
5454
false => Ok(Some(Cfg::False)),
5555
},
56-
MetaItemInner::Lit(ref lit) => {
56+
MetaItemInner::Lit(lit) => {
5757
Err(InvalidCfgError { msg: "unexpected literal", span: lit.span })
5858
}
5959
}

src/librustdoc/clean/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ pub(crate) fn clean_generics<'tcx>(
741741
for p in gens.params.iter().filter(|p| !is_impl_trait(p) && !is_elided_lifetime(p)) {
742742
let mut p = clean_generic_param(cx, Some(gens), p);
743743
match &mut p.kind {
744-
GenericParamDefKind::Lifetime { ref mut outlives } => {
744+
GenericParamDefKind::Lifetime { outlives } => {
745745
if let Some(region_pred) = region_predicates.get_mut(&Lifetime(p.name)) {
746746
// We merge bounds in the `where` clause.
747747
for outlive in outlives.drain(..) {
@@ -2688,7 +2688,7 @@ fn filter_doc_attr_ident(ident: Symbol, is_inline: bool) -> bool {
26882688
/// Before calling this function, make sure `normal` is a `#[doc]` attribute.
26892689
fn filter_doc_attr(args: &mut hir::AttrArgs, is_inline: bool) {
26902690
match args {
2691-
hir::AttrArgs::Delimited(ref mut args) => {
2691+
hir::AttrArgs::Delimited(args) => {
26922692
let tokens = filter_tokens_from_list(&args.tokens, |token| {
26932693
!matches!(
26942694
token,

src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl Item {
502502
let Some(links) = cx.cache().intra_doc_links.get(&self.item_id) else { return vec![] };
503503
links
504504
.iter()
505-
.filter_map(|ItemLink { link: s, link_text, page_id: id, ref fragment }| {
505+
.filter_map(|ItemLink { link: s, link_text, page_id: id, fragment }| {
506506
debug!(?id);
507507
if let Ok((mut href, ..)) = href(*id, cx) {
508508
debug!(?href);

src/librustdoc/clean/utils.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
6060
let primitives = local_crate.primitives(cx.tcx);
6161
let keywords = local_crate.keywords(cx.tcx);
6262
{
63-
let ItemKind::ModuleItem(ref mut m) = &mut module.inner.kind else { unreachable!() };
63+
let ItemKind::ModuleItem(m) = &mut module.inner.kind else { unreachable!() };
6464
m.items.extend(primitives.iter().map(|&(def_id, prim)| {
6565
Item::from_def_id_and_parts(
6666
def_id,
@@ -302,7 +302,7 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
302302
use rustc_hir::*;
303303
debug!("trying to get a name from pattern: {p:?}");
304304

305-
Symbol::intern(&match p.kind {
305+
Symbol::intern(&match &p.kind {
306306
// FIXME(never_patterns): does this make sense?
307307
PatKind::Wild
308308
| PatKind::Err(_)
@@ -313,8 +313,9 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
313313
}
314314
PatKind::Binding(_, _, ident, _) => return ident.name,
315315
PatKind::Box(p) | PatKind::Ref(p, _) | PatKind::Guard(p, _) => return name_from_pat(p),
316-
PatKind::TupleStruct(ref p, ..)
317-
| PatKind::Expr(PatExpr { kind: PatExprKind::Path(ref p), .. }) => qpath_to_string(p),
316+
PatKind::TupleStruct(p, ..) | PatKind::Expr(PatExpr { kind: PatExprKind::Path(p), .. }) => {
317+
qpath_to_string(p)
318+
}
318319
PatKind::Or(pats) => {
319320
fmt::from_fn(|f| pats.iter().map(|p| name_from_pat(p)).joined(" | ", f)).to_string()
320321
}
@@ -493,7 +494,7 @@ pub(crate) fn resolve_type(cx: &mut DocContext<'_>, path: Path) -> Type {
493494
pub(crate) fn synthesize_auto_trait_and_blanket_impls(
494495
cx: &mut DocContext<'_>,
495496
item_def_id: DefId,
496-
) -> impl Iterator<Item = Item> {
497+
) -> impl Iterator<Item = Item> + use<> {
497498
let auto_impls = cx
498499
.sess()
499500
.prof

src/librustdoc/html/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl clean::GenericParamDef {
8080
print_generic_bounds(bounds, cx).fmt(f)?;
8181
}
8282

83-
if let Some(ref ty) = default {
83+
if let Some(ty) = default {
8484
f.write_str(" = ")?;
8585
ty.print(cx).fmt(f)?;
8686
}

src/librustdoc/html/render/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ fn assoc_href_attr<'a, 'tcx>(
814814
}
815815

816816
let href = match link {
817-
AssocItemLink::Anchor(Some(ref id)) => Href::AnchorId(id),
817+
AssocItemLink::Anchor(Some(id)) => Href::AnchorId(id),
818818
AssocItemLink::Anchor(None) => Href::Anchor(item_type),
819819
AssocItemLink::GotoSource(did, provided_methods) => {
820820
// We're creating a link from the implementation of an associated item to its
@@ -1168,7 +1168,7 @@ fn render_assoc_item(
11681168
if parent == ItemType::Trait { 4 } else { 0 },
11691169
cx,
11701170
),
1171-
clean::RequiredAssocTypeItem(ref generics, ref bounds) => assoc_type(
1171+
clean::RequiredAssocTypeItem(generics, bounds) => assoc_type(
11721172
w,
11731173
item,
11741174
generics,
@@ -1178,7 +1178,7 @@ fn render_assoc_item(
11781178
if parent == ItemType::Trait { 4 } else { 0 },
11791179
cx,
11801180
),
1181-
clean::AssocTypeItem(ref ty, ref bounds) => assoc_type(
1181+
clean::AssocTypeItem(ty, bounds) => assoc_type(
11821182
w,
11831183
item,
11841184
&ty.generics,
@@ -1773,7 +1773,7 @@ fn render_impl(
17731773
w.push_str("</h4></section>");
17741774
}
17751775
}
1776-
clean::RequiredAssocConstItem(ref generics, ref ty) => {
1776+
clean::RequiredAssocConstItem(generics, ty) => {
17771777
let source_id = format!("{item_type}.{name}");
17781778
let id = cx.derive_id(&source_id);
17791779
write_str(
@@ -1827,7 +1827,7 @@ fn render_impl(
18271827
);
18281828
w.push_str("</h4></section>");
18291829
}
1830-
clean::RequiredAssocTypeItem(ref generics, ref bounds) => {
1830+
clean::RequiredAssocTypeItem(generics, bounds) => {
18311831
let source_id = format!("{item_type}.{name}");
18321832
let id = cx.derive_id(&source_id);
18331833
write_str(

src/librustdoc/html/render/print_item.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -252,24 +252,24 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut String)
252252
item_vars.render_into(buf).unwrap();
253253

254254
match &item.kind {
255-
clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),
256-
clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f, _) => {
255+
clean::ModuleItem(m) => item_module(buf, cx, item, &m.items),
256+
clean::FunctionItem(f) | clean::ForeignFunctionItem(f, _) => {
257257
item_function(buf, cx, item, f)
258258
}
259-
clean::TraitItem(ref t) => item_trait(buf, cx, item, t),
260-
clean::StructItem(ref s) => item_struct(buf, cx, item, s),
261-
clean::UnionItem(ref s) => item_union(buf, cx, item, s),
262-
clean::EnumItem(ref e) => item_enum(buf, cx, item, e),
263-
clean::TypeAliasItem(ref t) => item_type_alias(buf, cx, item, t),
264-
clean::MacroItem(ref m) => item_macro(buf, cx, item, m),
265-
clean::ProcMacroItem(ref m) => item_proc_macro(buf, cx, item, m),
259+
clean::TraitItem(t) => item_trait(buf, cx, item, t),
260+
clean::StructItem(s) => item_struct(buf, cx, item, s),
261+
clean::UnionItem(s) => item_union(buf, cx, item, s),
262+
clean::EnumItem(e) => item_enum(buf, cx, item, e),
263+
clean::TypeAliasItem(t) => item_type_alias(buf, cx, item, t),
264+
clean::MacroItem(m) => item_macro(buf, cx, item, m),
265+
clean::ProcMacroItem(m) => item_proc_macro(buf, cx, item, m),
266266
clean::PrimitiveItem(_) => item_primitive(buf, cx, item),
267-
clean::StaticItem(ref i) => item_static(buf, cx, item, i, None),
268-
clean::ForeignStaticItem(ref i, safety) => item_static(buf, cx, item, i, Some(*safety)),
267+
clean::StaticItem(i) => item_static(buf, cx, item, i, None),
268+
clean::ForeignStaticItem(i, safety) => item_static(buf, cx, item, i, Some(*safety)),
269269
clean::ConstantItem(ci) => item_constant(buf, cx, item, &ci.generics, &ci.type_, &ci.kind),
270270
clean::ForeignTypeItem => item_foreign_type(buf, cx, item),
271271
clean::KeywordItem => item_keyword(buf, cx, item),
272-
clean::TraitAliasItem(ref ta) => item_trait_alias(buf, cx, item, ta),
272+
clean::TraitAliasItem(ta) => item_trait_alias(buf, cx, item, ta),
273273
_ => {
274274
// We don't generate pages for any other type.
275275
unreachable!();
@@ -973,7 +973,7 @@ fn item_trait(w: &mut String, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
973973
extern_crates.insert(did.krate);
974974
}
975975
match implementor.inner_impl().for_.without_borrowed_ref() {
976-
clean::Type::Path { ref path } if !path.is_assoc_ty() => {
976+
clean::Type::Path { path } if !path.is_assoc_ty() => {
977977
let did = path.def_id();
978978
let &mut (prev_did, ref mut has_duplicates) =
979979
implementor_dups.entry(path.last()).or_insert((did, false));

src/librustdoc/html/sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ pub(crate) fn print_src(
333333
source_context: &SourceContext<'_>,
334334
) {
335335
let mut lines = s.lines().count();
336-
let line_info = if let SourceContext::Embedded(ref info) = source_context {
336+
let line_info = if let SourceContext::Embedded(info) = source_context {
337337
highlight::LineInfo::new_scraped(lines as u32, info.offset as u32)
338338
} else {
339339
highlight::LineInfo::new(lines as u32)

src/tools/rustdoc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustdoc-tool"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# Cargo adds a number of paths to the dylib search path on windows, which results in
77
# the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"

0 commit comments

Comments
 (0)