Skip to content

Commit e11a9fa

Browse files
committed
Auto merge of #84501 - JohnTitor:rollup-wxu1thu, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #83990 (implement `TrustedRandomAccess` for `Take` iterator adapter) - #84250 (bootstrap: use bash on illumos to run install scripts) - #84320 (Use details tag for trait implementors.) - #84436 (Make a few functions private) - #84453 (Document From implementations for Waker and RawWaker) - #84458 (Remove unnecessary fields and parameters in rustdoc) - #84485 (Add some associated type bounds tests) - #84489 (Mention FusedIterator case in Iterator::fuse doc) - #84492 (rustdoc: Remove unnecessary dummy span) - #84496 (Add some specialization tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a7aba58 + ec61abf commit e11a9fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+324
-152
lines changed

compiler/rustc_session/src/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ pub const fn default_lib_output() -> CrateType {
797797
CrateType::Rlib
798798
}
799799

800-
pub fn default_configuration(sess: &Session) -> CrateConfig {
800+
fn default_configuration(sess: &Session) -> CrateConfig {
801801
let end = &sess.target.endian;
802802
let arch = &sess.target.arch;
803803
let wordsz = sess.target.pointer_width.to_string();
@@ -892,7 +892,7 @@ pub fn build_configuration(sess: &Session, mut user_cfg: CrateConfig) -> CrateCo
892892
user_cfg
893893
}
894894

895-
pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> Target {
895+
pub(super) fn build_target_config(opts: &Options, target_override: Option<Target>) -> Target {
896896
let target_result = target_override.map_or_else(|| Target::search(&opts.target_triple), Ok);
897897
let target = target_result.unwrap_or_else(|e| {
898898
early_error(

library/alloc/src/task.rs

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ pub trait Wake {
8787

8888
#[stable(feature = "wake_trait", since = "1.51.0")]
8989
impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for Waker {
90+
/// Use a `Wake`-able type as a `Waker`.
91+
///
92+
/// No heap allocations or atomic operations are used for this conversion.
9093
fn from(waker: Arc<W>) -> Waker {
9194
// SAFETY: This is safe because raw_waker safely constructs
9295
// a RawWaker from Arc<W>.
@@ -96,6 +99,9 @@ impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for Waker {
9699

97100
#[stable(feature = "wake_trait", since = "1.51.0")]
98101
impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for RawWaker {
102+
/// Use a `Wake`-able type as a `RawWaker`.
103+
///
104+
/// No heap allocations or atomic operations are used for this conversion.
99105
fn from(waker: Arc<W>) -> RawWaker {
100106
raw_waker(waker)
101107
}

library/core/src/iter/adapters/take.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use crate::cmp;
2-
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedLen};
2+
use crate::iter::{
3+
adapters::zip::try_get_unchecked, adapters::SourceIter, FusedIterator, InPlaceIterable,
4+
TrustedLen, TrustedRandomAccess,
5+
};
36
use crate::ops::{ControlFlow, Try};
47

58
/// An iterator that only iterates over the first `n` iterations of `iter`.
@@ -111,6 +114,15 @@ where
111114

112115
self.try_fold(init, ok(fold)).unwrap()
113116
}
117+
118+
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> <I as Iterator>::Item
119+
where
120+
Self: TrustedRandomAccess,
121+
{
122+
// SAFETY: the caller must uphold the contract for
123+
// `Iterator::__iterator_get_unchecked`.
124+
unsafe { try_get_unchecked(&mut self.iter, idx) }
125+
}
114126
}
115127

116128
#[unstable(issue = "none", feature = "inplace_iteration")]
@@ -207,3 +219,12 @@ impl<I> FusedIterator for Take<I> where I: FusedIterator {}
207219

208220
#[unstable(feature = "trusted_len", issue = "37572")]
209221
unsafe impl<I: TrustedLen> TrustedLen for Take<I> {}
222+
223+
#[doc(hidden)]
224+
#[unstable(feature = "trusted_random_access", issue = "none")]
225+
unsafe impl<I> TrustedRandomAccess for Take<I>
226+
where
227+
I: TrustedRandomAccess,
228+
{
229+
const MAY_HAVE_SIDE_EFFECT: bool = I::MAY_HAVE_SIDE_EFFECT;
230+
}

library/core/src/iter/traits/iterator.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,12 @@ pub trait Iterator {
14951495
/// [`Some(T)`] again. `fuse()` adapts an iterator, ensuring that after a
14961496
/// [`None`] is given, it will always return [`None`] forever.
14971497
///
1498+
/// Note that the [`Fuse`] wrapper is a no-op on iterators that implement
1499+
/// the [`FusedIterator`] trait. `fuse()` may therefore behave incorrectly
1500+
/// if the [`FusedIterator`] trait is improperly implemented.
1501+
///
14981502
/// [`Some(T)`]: Some
1503+
/// [`FusedIterator`]: crate::iter::FusedIterator
14991504
///
15001505
/// # Examples
15011506
///

src/bootstrap/install.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ use crate::Compiler;
1717
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
1818
use crate::config::{Config, TargetSelection};
1919

20+
#[cfg(target_os = "illumos")]
21+
const SHELL: &str = "bash";
22+
#[cfg(not(target_os = "illumos"))]
23+
const SHELL: &str = "sh";
24+
2025
fn install_sh(
2126
builder: &Builder<'_>,
2227
package: &str,
@@ -37,7 +42,7 @@ fn install_sh(
3742
let empty_dir = builder.out.join("tmp/empty_dir");
3843
t!(fs::create_dir_all(&empty_dir));
3944

40-
let mut cmd = Command::new("sh");
45+
let mut cmd = Command::new(SHELL);
4146
cmd.current_dir(&empty_dir)
4247
.arg(sanitize_sh(&tarball.decompressed_output().join("install.sh")))
4348
.arg(format!("--prefix={}", prepare_dir(prefix)))

src/librustdoc/formats/renderer.rs

+12-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_middle::ty::TyCtxt;
2-
use rustc_span::{edition::Edition, Symbol};
2+
use rustc_span::Symbol;
33

44
use crate::clean;
55
use crate::config::RenderOptions;
@@ -23,7 +23,6 @@ crate trait FormatRenderer<'tcx>: Sized {
2323
fn init(
2424
krate: clean::Crate,
2525
options: RenderOptions,
26-
edition: Edition,
2726
cache: Cache,
2827
tcx: TyCtxt<'tcx>,
2928
) -> Result<(Self, clean::Crate), Error>;
@@ -35,19 +34,15 @@ crate trait FormatRenderer<'tcx>: Sized {
3534
fn item(&mut self, item: clean::Item) -> Result<(), Error>;
3635

3736
/// Renders a module (should not handle recursing into children).
38-
fn mod_item_in(&mut self, item: &clean::Item, item_name: &str) -> Result<(), Error>;
37+
fn mod_item_in(&mut self, item: &clean::Item) -> Result<(), Error>;
3938

4039
/// Runs after recursively rendering all sub-items of a module.
41-
fn mod_item_out(&mut self, item_name: &str) -> Result<(), Error>;
40+
fn mod_item_out(&mut self) -> Result<(), Error> {
41+
Ok(())
42+
}
4243

4344
/// Post processing hook for cleanup and dumping output to files.
44-
///
45-
/// A handler is available if the renderer wants to report errors.
46-
fn after_krate(
47-
&mut self,
48-
crate_name: Symbol,
49-
diag: &rustc_errors::Handler,
50-
) -> Result<(), Error>;
45+
fn after_krate(&mut self) -> Result<(), Error>;
5146

5247
fn cache(&self) -> &Cache;
5348
}
@@ -57,37 +52,31 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
5752
krate: clean::Crate,
5853
options: RenderOptions,
5954
cache: Cache,
60-
diag: &rustc_errors::Handler,
61-
edition: Edition,
6255
tcx: TyCtxt<'tcx>,
6356
) -> Result<(), Error> {
6457
let prof = &tcx.sess.prof;
6558

6659
let emit_crate = options.should_emit_crate();
6760
let (mut format_renderer, krate) = prof
6861
.extra_verbose_generic_activity("create_renderer", T::descr())
69-
.run(|| T::init(krate, options, edition, cache, tcx))?;
62+
.run(|| T::init(krate, options, cache, tcx))?;
7063

7164
if !emit_crate {
7265
return Ok(());
7366
}
7467

7568
// Render the crate documentation
76-
let crate_name = krate.name;
7769
let mut work = vec![(format_renderer.make_child_renderer(), krate.module)];
7870

7971
let unknown = Symbol::intern("<unknown item>");
8072
while let Some((mut cx, item)) = work.pop() {
8173
if item.is_mod() && T::RUN_ON_MODULE {
8274
// modules are special because they add a namespace. We also need to
8375
// recurse into the items of the module as well.
84-
let name = item.name.as_ref().unwrap().to_string();
85-
if name.is_empty() {
86-
panic!("Unexpected module with empty name");
87-
}
88-
let _timer = prof.generic_activity_with_arg("render_mod_item", name.as_str());
76+
let _timer =
77+
prof.generic_activity_with_arg("render_mod_item", item.name.unwrap().to_string());
8978

90-
cx.mod_item_in(&item, &name)?;
79+
cx.mod_item_in(&item)?;
9180
let module = match *item.kind {
9281
clean::StrippedItem(box clean::ModuleItem(m)) | clean::ModuleItem(m) => m,
9382
_ => unreachable!(),
@@ -97,7 +86,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
9786
work.push((cx.make_child_renderer(), it));
9887
}
9988

100-
cx.mod_item_out(&name)?;
89+
cx.mod_item_out()?;
10190
// FIXME: checking `item.name.is_some()` is very implicit and leads to lots of special
10291
// cases. Use an explicit match instead.
10392
} else if item.name.is_some() && !item.is_extern_crate() {
@@ -106,5 +95,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
10695
}
10796
}
10897
prof.extra_verbose_generic_activity("renderer_after_krate", T::descr())
109-
.run(|| format_renderer.after_krate(crate_name, diag))
98+
.run(|| format_renderer.after_krate())
11099
}

src/librustdoc/html/render/context.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_middle::ty::TyCtxt;
1111
use rustc_session::Session;
1212
use rustc_span::edition::Edition;
1313
use rustc_span::source_map::FileName;
14-
use rustc_span::{symbol::sym, Symbol};
14+
use rustc_span::symbol::sym;
1515

1616
use super::cache::{build_index, ExternalLocation};
1717
use super::print_item::{full_path, item_path, print_item};
@@ -111,8 +111,6 @@ crate struct SharedContext<'tcx> {
111111
crate static_root_path: Option<String>,
112112
/// The fs handle we are working with.
113113
crate fs: DocFS,
114-
/// The default edition used to parse doctests.
115-
crate edition: Edition,
116114
pub(super) codes: ErrorCodes,
117115
pub(super) playground: Option<markdown::Playground>,
118116
all: RefCell<AllTypes>,
@@ -141,6 +139,10 @@ impl SharedContext<'_> {
141139
crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option<String> {
142140
if self.collapsed { item.collapsed_doc_value() } else { item.doc_value() }
143141
}
142+
143+
crate fn edition(&self) -> Edition {
144+
self.tcx.sess.edition()
145+
}
144146
}
145147

146148
impl<'tcx> Context<'tcx> {
@@ -346,7 +348,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
346348
fn init(
347349
mut krate: clean::Crate,
348350
options: RenderOptions,
349-
edition: Edition,
350351
mut cache: Cache,
351352
tcx: TyCtxt<'tcx>,
352353
) -> Result<(Self, clean::Crate), Error> {
@@ -435,7 +436,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
435436
resource_suffix,
436437
static_root_path,
437438
fs: DocFS::new(sender),
438-
edition,
439439
codes: ErrorCodes::from(unstable_features.is_nightly_build()),
440440
playground,
441441
all: RefCell::new(AllTypes::new()),
@@ -494,11 +494,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
494494
}
495495
}
496496

497-
fn after_krate(
498-
&mut self,
499-
crate_name: Symbol,
500-
diag: &rustc_errors::Handler,
501-
) -> Result<(), Error> {
497+
fn after_krate(&mut self) -> Result<(), Error> {
498+
let crate_name = self.tcx().crate_name(LOCAL_CRATE);
502499
let final_file = self.dst.join(&*crate_name.as_str()).join("all.html");
503500
let settings_file = self.dst.join("settings.html");
504501

@@ -572,15 +569,16 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
572569

573570
// Flush pending errors.
574571
Rc::get_mut(&mut self.shared).unwrap().fs.close();
575-
let nb_errors = self.shared.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
572+
let nb_errors =
573+
self.shared.errors.iter().map(|err| self.tcx().sess.struct_err(&err).emit()).count();
576574
if nb_errors > 0 {
577575
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
578576
} else {
579577
Ok(())
580578
}
581579
}
582580

583-
fn mod_item_in(&mut self, item: &clean::Item, item_name: &str) -> Result<(), Error> {
581+
fn mod_item_in(&mut self, item: &clean::Item) -> Result<(), Error> {
584582
// Stripped modules survive the rustdoc passes (i.e., `strip-private`)
585583
// if they contain impls for public types. These modules can also
586584
// contain items such as publicly re-exported structures.
@@ -592,8 +590,9 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
592590
self.render_redirect_pages = item.is_stripped();
593591
}
594592
let scx = &self.shared;
595-
self.dst.push(item_name);
596-
self.current.push(item_name.to_owned());
593+
let item_name = item.name.as_ref().unwrap().to_string();
594+
self.dst.push(&item_name);
595+
self.current.push(item_name);
597596

598597
info!("Recursing into {}", self.dst.display());
599598

@@ -619,7 +618,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
619618
Ok(())
620619
}
621620

622-
fn mod_item_out(&mut self, _item_name: &str) -> Result<(), Error> {
621+
fn mod_item_out(&mut self) -> Result<(), Error> {
623622
info!("Recursed; leaving {}", self.dst.display());
624623

625624
// Go back to where we were at

0 commit comments

Comments
 (0)