Skip to content

Rollup of 5 pull requests #144181

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 12 commits into from
Jul 20, 2025
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 library/coretests/tests/iter/adapters/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ fn test_double_ended_zip() {

#[test]
#[cfg(panic = "unwind")]
/// Regresion test for #137255
/// Regression test for #137255
/// A previous implementation of Zip TrustedRandomAccess specializations tried to do a lot of work
/// to preserve side-effects of equalizing the iterator lengths during backwards iteration.
/// This lead to several cases of unsoundness, twice due to being left in an inconsistent state
Expand Down
4 changes: 2 additions & 2 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ try:
optional:
# This job is used just to test optional jobs.
# It will be replaced by tier 2 and tier 3 jobs in the future.
- name: optional-mingw-check-1
- name: optional-pr-check-1
env:
IMAGE: mingw-check-1
IMAGE: pr-check-1
<<: *job-linux-4c

# Main CI jobs that have to be green to merge a commit into master
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support/xtensa.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Xtensa targets that support `std` are documented in the [ESP-IDF platform suppor

## Building the targets

The targets can be built by installing the [Xtensa enabled Rust channel](https://github.com/esp-rs/rust/). See instructions in the [RISC-V and Xtensa Targets section of The Rust on ESP Book](https://docs.esp-rs.org/book/installation/riscv-and-xtensa.html).
The targets can be built by installing the [Xtensa enabled Rust channel](https://github.com/esp-rs/rust/). See instructions in the [RISC-V and Xtensa Targets section of The Rust on ESP Book](https://docs.espressif.com/projects/rust/book/installation/index.html).
4 changes: 2 additions & 2 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ impl Type {
}
}

pub(crate) fn generics<'a>(&'a self) -> Option<impl Iterator<Item = &'a Type>> {
pub(crate) fn generics(&self) -> Option<impl Iterator<Item = &Type>> {
match self {
Type::Path { path, .. } => path.generics(),
_ => None,
Expand Down Expand Up @@ -2227,7 +2227,7 @@ impl Path {
self.segments.last().map(|seg| &seg.args)
}

pub(crate) fn generics<'a>(&'a self) -> Option<impl Iterator<Item = &'a Type>> {
pub(crate) fn generics(&self) -> Option<impl Iterator<Item = &Type>> {
self.segments.last().and_then(|seg| {
if let GenericArgs::AngleBracketed { ref args, .. } = seg.args {
Some(args.iter().filter_map(|arg| match arg {
Expand Down
6 changes: 2 additions & 4 deletions src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,11 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
pub(crate) fn print_const(cx: &DocContext<'_>, n: ty::Const<'_>) -> String {
match n.kind() {
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, args: _ }) => {
let s = if let Some(def) = def.as_local() {
if let Some(def) = def.as_local() {
rendered_const(cx.tcx, cx.tcx.hir_body_owned_by(def), def)
} else {
inline::print_inlined_const(cx.tcx, def)
};

s
}
}
// array lengths are obviously usize
ty::ConstKind::Value(cv) if *cv.ty.kind() == ty::Uint(ty::UintTy::Usize) => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ fn run_test(
// the user to exploit nightly-only features on stable
runner_compiler.env("RUSTC_BOOTSTRAP", "1");
runner_compiler.args(compiler_args);
runner_compiler.args(&["--crate-type=bin", "-o"]).arg(&output_file);
runner_compiler.args(["--crate-type=bin", "-o"]).arg(&output_file);
let mut extern_path = std::ffi::OsString::from(format!(
"--extern=doctest_bundle_{edition}=",
edition = doctest.edition
Expand All @@ -657,7 +657,7 @@ fn run_test(
extern_path.push(&output_bundle_file);
runner_compiler.arg(extern_path);
runner_compiler.arg(&runner_input_file);
if std::fs::write(&runner_input_file, &merged_test_code).is_err() {
if std::fs::write(&runner_input_file, merged_test_code).is_err() {
// If we cannot write this file for any reason, we leave. All combined tests will be
// tested as standalone tests.
return Err(TestFailure::CompileError);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/doctest/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl HirCollector<'_> {
.iter()
.filter(|a| a.has_name(sym::attr))
.flat_map(|a| a.meta_item_list().unwrap_or_default())
.map(|i| pprust::meta_list_item_to_string(i))
.map(pprust::meta_list_item_to_string)
{
// Add the additional attributes to the global_crate_attrs vector
self.collector.global_crate_attrs.push(attr);
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/formats/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn run_format_inner<'tcx, T: FormatRenderer<'tcx>>(
let _timer =
prof.generic_activity_with_arg("render_mod_item", item.name.unwrap().to_string());

cx.mod_item_in(&item)?;
cx.mod_item_in(item)?;
let (clean::StrippedItem(box clean::ModuleItem(ref module))
| clean::ModuleItem(ref module)) = item.inner.kind
else {
Expand All @@ -99,7 +99,7 @@ fn run_format_inner<'tcx, T: FormatRenderer<'tcx>>(
} else if let Some(item_name) = item.name
&& !item.is_extern_crate()
{
prof.generic_activity_with_arg("render_item", item_name.as_str()).run(|| cx.item(&item))?;
prof.generic_activity_with_arg("render_item", item_name.as_str()).run(|| cx.item(item))?;
}
Ok(())
}
Expand Down
12 changes: 6 additions & 6 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ impl clean::Generics {
let real_params =
fmt::from_fn(|f| real_params.clone().map(|g| g.print(cx)).joined(", ", f));
if f.alternate() {
write!(f, "<{:#}>", real_params)
write!(f, "<{real_params:#}>")
} else {
write!(f, "&lt;{}&gt;", real_params)
write!(f, "&lt;{real_params}&gt;")
}
})
}
Expand Down Expand Up @@ -594,7 +594,7 @@ pub(crate) fn href_with_root_path(
}
}
};
let url_parts = make_href(root_path, shortty, url_parts, &fqp, is_remote);
let url_parts = make_href(root_path, shortty, url_parts, fqp, is_remote);
Ok((url_parts, shortty, fqp.clone()))
}

Expand Down Expand Up @@ -1115,7 +1115,7 @@ impl clean::Impl {
{
let last = ty.last();
if f.alternate() {
write!(f, "{}<", last)?;
write!(f, "{last}<")?;
self.print_type(inner_type, f, use_absolute, cx)?;
write!(f, ">")?;
} else {
Expand Down Expand Up @@ -1219,7 +1219,7 @@ pub(crate) fn print_params(params: &[clean::Parameter], cx: &Context<'_>) -> imp
.map(|param| {
fmt::from_fn(|f| {
if let Some(name) = param.name {
write!(f, "{}: ", name)?;
write!(f, "{name}: ")?;
}
param.type_.print(cx).fmt(f)
})
Expand Down Expand Up @@ -1341,7 +1341,7 @@ impl clean::FnDecl {
write!(f, "const ")?;
}
if let Some(name) = param.name {
write!(f, "{}: ", name)?;
write!(f, "{name}: ")?;
}
param.type_.print(cx).fmt(f)?;
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ impl<'a> Iterator for TokenIter<'a> {
fn get_real_ident_class(text: &str, allow_path_keywords: bool) -> Option<Class> {
let ignore: &[&str] =
if allow_path_keywords { &["self", "Self", "super", "crate"] } else { &["self", "Self"] };
if ignore.iter().any(|k| *k == text) {
if ignore.contains(&text) {
return None;
}
Some(match text {
Expand Down Expand Up @@ -1159,7 +1159,7 @@ fn string_without_closing_tag<T: Display>(
return Some("</a>");
}
if !open_tag {
write!(out, "{}", text_s).unwrap();
out.write_str(&text_s).unwrap();
return None;
}
let klass_s = klass.as_html();
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,5 @@ pub(crate) fn redirect(url: &str) -> String {
<script>location.replace("{url}" + location.search + location.hash);</script>
</body>
</html>"##,
url = url,
)
}
4 changes: 2 additions & 2 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
if !parse_result.rust {
let added_classes = parse_result.added_classes;
let lang_string = if let Some(lang) = parse_result.unknown.first() {
format!("language-{}", lang)
format!("language-{lang}")
} else {
String::new()
};
Expand Down Expand Up @@ -999,7 +999,7 @@ impl<'a, 'tcx> TagIterator<'a, 'tcx> {

if let Some((_, c)) = self.inner.next() {
if c != '=' {
self.emit_error(format!("expected `=`, found `{}`", c));
self.emit_error(format!("expected `=`, found `{c}`"));
return None;
}
} else {
Expand Down
84 changes: 37 additions & 47 deletions src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,12 @@ impl<'tcx> Context<'tcx> {
if it.is_stripped()
&& let Some(def_id) = it.def_id()
&& def_id.is_local()
&& (self.info.is_inside_inlined_module
|| self.shared.cache.inlined_items.contains(&def_id))
{
if self.info.is_inside_inlined_module
|| self.shared.cache.inlined_items.contains(&def_id)
{
// For now we're forced to generate a redirect page for stripped items until
// `record_extern_fqn` correctly points to external items.
render_redirect_pages = true;
}
// For now we're forced to generate a redirect page for stripped items until
// `record_extern_fqn` correctly points to external items.
render_redirect_pages = true;
}
let mut title = String::new();
if !is_module {
Expand Down Expand Up @@ -254,40 +252,36 @@ impl<'tcx> Context<'tcx> {
&self.shared.style_files,
)
} else {
if let Some(&(ref names, ty)) = self.cache().paths.get(&it.item_id.expect_def_id()) {
if self.current.len() + 1 != names.len()
|| self.current.iter().zip(names.iter()).any(|(a, b)| a != b)
{
// We checked that the redirection isn't pointing to the current file,
// preventing an infinite redirection loop in the generated
// documentation.

let path = fmt::from_fn(|f| {
for name in &names[..names.len() - 1] {
write!(f, "{name}/")?;
}
write!(f, "{}", print_item_path(ty, names.last().unwrap().as_str()))
});
match self.shared.redirections {
Some(ref redirections) => {
let mut current_path = String::new();
for name in &self.current {
current_path.push_str(name.as_str());
current_path.push('/');
}
let _ = write!(
current_path,
"{}",
print_item_path(ty, names.last().unwrap().as_str())
);
redirections.borrow_mut().insert(current_path, path.to_string());
}
None => {
return layout::redirect(&format!(
"{root}{path}",
root = self.root_path()
));
if let Some(&(ref names, ty)) = self.cache().paths.get(&it.item_id.expect_def_id())
&& (self.current.len() + 1 != names.len()
|| self.current.iter().zip(names.iter()).any(|(a, b)| a != b))
{
// We checked that the redirection isn't pointing to the current file,
// preventing an infinite redirection loop in the generated
// documentation.

let path = fmt::from_fn(|f| {
for name in &names[..names.len() - 1] {
write!(f, "{name}/")?;
}
write!(f, "{}", print_item_path(ty, names.last().unwrap().as_str()))
});
match self.shared.redirections {
Some(ref redirections) => {
let mut current_path = String::new();
for name in &self.current {
current_path.push_str(name.as_str());
current_path.push('/');
}
let _ = write!(
current_path,
"{}",
print_item_path(ty, names.last().unwrap().as_str())
);
redirections.borrow_mut().insert(current_path, path.to_string());
}
None => {
return layout::redirect(&format!("{root}{path}", root = self.root_path()));
}
}
}
Expand Down Expand Up @@ -762,11 +756,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
// Flush pending errors.
self.shared.fs.close();
let nb_errors = self.shared.errors.iter().map(|err| self.tcx().dcx().err(err)).count();
if nb_errors > 0 {
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
} else {
Ok(())
}
if nb_errors > 0 { Err(Error::new(io::Error::other("I/O error"), "")) } else { Ok(()) }
}

fn mod_item_in(&mut self, item: &clean::Item) -> Result<(), Error> {
Expand Down Expand Up @@ -842,7 +832,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
self.info.render_redirect_pages = item.is_stripped();
}

let buf = self.render_item(&item, false);
let buf = self.render_item(item, false);
// buf will be empty if the item is stripped and there is no redirect for it
if !buf.is_empty() {
let name = item.name.as_ref().unwrap();
Expand All @@ -853,7 +843,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
self.shared.fs.write(joint_dst, buf)?;

if !self.info.render_redirect_pages {
self.shared.all.borrow_mut().append(full_path(self, &item), &item_type);
self.shared.all.borrow_mut().append(full_path(self, item), &item_type);
}
// If the item is a macro, redirect from the old macro URL (with !)
// to the new one (without).
Expand Down
39 changes: 19 additions & 20 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,10 +1483,10 @@ fn render_deref_methods(
}
}
render_assoc_items_inner(&mut w, cx, container_item, did, what, derefs);
} else if let Some(prim) = target.primitive_type() {
if let Some(&did) = cache.primitive_locations.get(&prim) {
render_assoc_items_inner(&mut w, cx, container_item, did, what, derefs);
}
} else if let Some(prim) = target.primitive_type()
&& let Some(&did) = cache.primitive_locations.get(&prim)
{
render_assoc_items_inner(&mut w, cx, container_item, did, what, derefs);
}
}

Expand Down Expand Up @@ -2058,21 +2058,20 @@ fn render_impl(
// default items which weren't overridden in the implementation block.
// We don't emit documentation for default items if they appear in the
// Implementations on Foreign Types or Implementors sections.
if rendering_params.show_default_items {
if let Some(t) = trait_
&& !impl_.is_negative_trait_impl()
{
render_default_items(
&mut default_impl_items,
&mut impl_items,
cx,
t,
impl_,
&i.impl_item,
render_mode,
rendering_params,
)?;
}
if rendering_params.show_default_items
&& let Some(t) = trait_
&& !impl_.is_negative_trait_impl()
{
render_default_items(
&mut default_impl_items,
&mut impl_items,
cx,
t,
impl_,
&i.impl_item,
render_mode,
rendering_params,
)?;
}
if render_mode == RenderMode::Normal {
let toggled = !(impl_items.is_empty() && default_impl_items.is_empty());
Expand Down Expand Up @@ -2570,7 +2569,7 @@ fn collect_paths_for_type(first_ty: &clean::Type, cache: &Cache) -> Vec<String>
match ty {
clean::Type::Path { path } => process_path(path.def_id()),
clean::Type::Tuple(tys) => {
work.extend(tys.into_iter());
work.extend(tys.iter());
}
clean::Type::Slice(ty) => {
work.push_back(ty);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/ordered_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl OrderedJson {
.into_iter()
.sorted_unstable_by(|a, b| a.borrow().cmp(b.borrow()))
.format_with(",", |item, f| f(item.borrow()));
Self(format!("[{}]", items))
Self(format!("[{items}]"))
}

pub(crate) fn array_unsorted<T: Borrow<Self>, I: IntoIterator<Item = T>>(items: I) -> Self {
Expand Down
Loading
Loading