Skip to content
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

Rollup of 10 pull requests #84501

Merged
merged 27 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
37a5b51
implement TrustedRandomAccess for Take iterator adapter
the8472 Apr 8, 2021
4873271
bootstrap: use bash on illumos to run install scripts
jclulow Apr 16, 2021
569096c
rustdoc: use details tag for trait implementors
jsha Apr 18, 2021
1a46b26
Make a few functions private
jyn514 Apr 22, 2021
60ff298
Document From implementations for Waker and RawWaker
notriddle Apr 22, 2021
f435f71
Remove unnecessary `crate_name` parameter to `after_krate`
jyn514 Apr 22, 2021
68db586
Remove unnecessary `diag` parameter to `after_krate`
jyn514 Apr 22, 2021
640cc74
Remove unnecessary `edition` parameter to renderer
jyn514 Apr 22, 2021
423963c
Remove unnecessary `edition` field on SharedContext
jyn514 Apr 22, 2021
7f6d540
Remove unnecessary `item_name` parameter to `mod_item_out`
jyn514 Apr 22, 2021
edb60a9
Remove unnecessary item_name parameter to `mod_item_in`
jyn514 Apr 22, 2021
8f41de5
Add test for issue #83017
marmeladema Apr 23, 2021
3b96dfe
Add test for issue #81193
marmeladema Apr 23, 2021
21b3b27
Mention FusedIterator case in Iterator::fuse doc
amorison Apr 23, 2021
7c50b82
rustdoc: Remove unnecessary dummy span
jyn514 Apr 23, 2021
a657e17
Add test for issue #33017
marmeladema Apr 23, 2021
9b430df
Add test for issue #51892
marmeladema Apr 23, 2021
c00439f
Rollup merge of #83990 - the8472:take-trusted-len, r=dtolnay
JohnTitor Apr 24, 2021
5321f95
Rollup merge of #84250 - jclulow:illumos-bash-bootstrap, r=Mark-Simul…
JohnTitor Apr 24, 2021
b454469
Rollup merge of #84320 - jsha:details-implementors, r=Manishearth,Nem…
JohnTitor Apr 24, 2021
570eed7
Rollup merge of #84436 - jyn514:private, r=petrochenkov
JohnTitor Apr 24, 2021
ed5646b
Rollup merge of #84453 - notriddle:waker-from-docs, r=cramertj
JohnTitor Apr 24, 2021
8d75898
Rollup merge of #84458 - jyn514:cleanup-after-krate, r=GuillaumeGomez
JohnTitor Apr 24, 2021
740e1f4
Rollup merge of #84485 - marmeladema:trait-tests, r=jackh726
JohnTitor Apr 24, 2021
ed991a3
Rollup merge of #84489 - amorison:issue-83969-fix, r=yaahc
JohnTitor Apr 24, 2021
aae871d
Rollup merge of #84492 - jyn514:span, r=camelid
JohnTitor Apr 24, 2021
ec61abf
Rollup merge of #84496 - marmeladema:specialization-test, r=JohnTitor
JohnTitor Apr 24, 2021
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
4 changes: 2 additions & 2 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ pub const fn default_lib_output() -> CrateType {
CrateType::Rlib
}

pub fn default_configuration(sess: &Session) -> CrateConfig {
fn default_configuration(sess: &Session) -> CrateConfig {
let end = &sess.target.endian;
let arch = &sess.target.arch;
let wordsz = sess.target.pointer_width.to_string();
Expand Down Expand Up @@ -892,7 +892,7 @@ pub fn build_configuration(sess: &Session, mut user_cfg: CrateConfig) -> CrateCo
user_cfg
}

pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> Target {
pub(super) fn build_target_config(opts: &Options, target_override: Option<Target>) -> Target {
let target_result = target_override.map_or_else(|| Target::search(&opts.target_triple), Ok);
let target = target_result.unwrap_or_else(|e| {
early_error(
Expand Down
6 changes: 6 additions & 0 deletions library/alloc/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ pub trait Wake {

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

#[stable(feature = "wake_trait", since = "1.51.0")]
impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for RawWaker {
/// Use a `Wake`-able type as a `RawWaker`.
///
/// No heap allocations or atomic operations are used for this conversion.
fn from(waker: Arc<W>) -> RawWaker {
raw_waker(waker)
}
Expand Down
23 changes: 22 additions & 1 deletion library/core/src/iter/adapters/take.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::cmp;
use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedLen};
use crate::iter::{
adapters::zip::try_get_unchecked, adapters::SourceIter, FusedIterator, InPlaceIterable,
TrustedLen, TrustedRandomAccess,
};
use crate::ops::{ControlFlow, Try};

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

self.try_fold(init, ok(fold)).unwrap()
}

unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> <I as Iterator>::Item
where
Self: TrustedRandomAccess,
{
// SAFETY: the caller must uphold the contract for
// `Iterator::__iterator_get_unchecked`.
unsafe { try_get_unchecked(&mut self.iter, idx) }
}
}

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

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<I: TrustedLen> TrustedLen for Take<I> {}

#[doc(hidden)]
#[unstable(feature = "trusted_random_access", issue = "none")]
unsafe impl<I> TrustedRandomAccess for Take<I>
where
I: TrustedRandomAccess,
{
const MAY_HAVE_SIDE_EFFECT: bool = I::MAY_HAVE_SIDE_EFFECT;
}
5 changes: 5 additions & 0 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,12 @@ pub trait Iterator {
/// [`Some(T)`] again. `fuse()` adapts an iterator, ensuring that after a
/// [`None`] is given, it will always return [`None`] forever.
///
/// Note that the [`Fuse`] wrapper is a no-op on iterators that implement
/// the [`FusedIterator`] trait. `fuse()` may therefore behave incorrectly
/// if the [`FusedIterator`] trait is improperly implemented.
///
/// [`Some(T)`]: Some
/// [`FusedIterator`]: crate::iter::FusedIterator
///
/// # Examples
///
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ use crate::Compiler;
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::config::{Config, TargetSelection};

#[cfg(target_os = "illumos")]
const SHELL: &str = "bash";
#[cfg(not(target_os = "illumos"))]
const SHELL: &str = "sh";

fn install_sh(
builder: &Builder<'_>,
package: &str,
Expand All @@ -37,7 +42,7 @@ fn install_sh(
let empty_dir = builder.out.join("tmp/empty_dir");
t!(fs::create_dir_all(&empty_dir));

let mut cmd = Command::new("sh");
let mut cmd = Command::new(SHELL);
cmd.current_dir(&empty_dir)
.arg(sanitize_sh(&tarball.decompressed_output().join("install.sh")))
.arg(format!("--prefix={}", prepare_dir(prefix)))
Expand Down
35 changes: 12 additions & 23 deletions src/librustdoc/formats/renderer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rustc_middle::ty::TyCtxt;
use rustc_span::{edition::Edition, Symbol};
use rustc_span::Symbol;

use crate::clean;
use crate::config::RenderOptions;
Expand All @@ -23,7 +23,6 @@ crate trait FormatRenderer<'tcx>: Sized {
fn init(
krate: clean::Crate,
options: RenderOptions,
edition: Edition,
cache: Cache,
tcx: TyCtxt<'tcx>,
) -> Result<(Self, clean::Crate), Error>;
Expand All @@ -35,19 +34,15 @@ crate trait FormatRenderer<'tcx>: Sized {
fn item(&mut self, item: clean::Item) -> Result<(), Error>;

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

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

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

fn cache(&self) -> &Cache;
}
Expand All @@ -57,37 +52,31 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
krate: clean::Crate,
options: RenderOptions,
cache: Cache,
diag: &rustc_errors::Handler,
edition: Edition,
tcx: TyCtxt<'tcx>,
) -> Result<(), Error> {
let prof = &tcx.sess.prof;

let emit_crate = options.should_emit_crate();
let (mut format_renderer, krate) = prof
.extra_verbose_generic_activity("create_renderer", T::descr())
.run(|| T::init(krate, options, edition, cache, tcx))?;
.run(|| T::init(krate, options, cache, tcx))?;

if !emit_crate {
return Ok(());
}

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

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

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

cx.mod_item_out(&name)?;
cx.mod_item_out()?;
// FIXME: checking `item.name.is_some()` is very implicit and leads to lots of special
// cases. Use an explicit match instead.
} else if item.name.is_some() && !item.is_extern_crate() {
Expand All @@ -106,5 +95,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
}
}
prof.extra_verbose_generic_activity("renderer_after_krate", T::descr())
.run(|| format_renderer.after_krate(crate_name, diag))
.run(|| format_renderer.after_krate())
}
29 changes: 14 additions & 15 deletions src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use rustc_span::edition::Edition;
use rustc_span::source_map::FileName;
use rustc_span::{symbol::sym, Symbol};
use rustc_span::symbol::sym;

use super::cache::{build_index, ExternalLocation};
use super::print_item::{full_path, item_path, print_item};
Expand Down Expand Up @@ -111,8 +111,6 @@ crate struct SharedContext<'tcx> {
crate static_root_path: Option<String>,
/// The fs handle we are working with.
crate fs: DocFS,
/// The default edition used to parse doctests.
crate edition: Edition,
pub(super) codes: ErrorCodes,
pub(super) playground: Option<markdown::Playground>,
all: RefCell<AllTypes>,
Expand Down Expand Up @@ -141,6 +139,10 @@ impl SharedContext<'_> {
crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option<String> {
if self.collapsed { item.collapsed_doc_value() } else { item.doc_value() }
}

crate fn edition(&self) -> Edition {
self.tcx.sess.edition()
}
}

impl<'tcx> Context<'tcx> {
Expand Down Expand Up @@ -346,7 +348,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
fn init(
mut krate: clean::Crate,
options: RenderOptions,
edition: Edition,
mut cache: Cache,
tcx: TyCtxt<'tcx>,
) -> Result<(Self, clean::Crate), Error> {
Expand Down Expand Up @@ -435,7 +436,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
resource_suffix,
static_root_path,
fs: DocFS::new(sender),
edition,
codes: ErrorCodes::from(unstable_features.is_nightly_build()),
playground,
all: RefCell::new(AllTypes::new()),
Expand Down Expand Up @@ -494,11 +494,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
}
}

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

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

// Flush pending errors.
Rc::get_mut(&mut self.shared).unwrap().fs.close();
let nb_errors = self.shared.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
let nb_errors =
self.shared.errors.iter().map(|err| self.tcx().sess.struct_err(&err).emit()).count();
if nb_errors > 0 {
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
} else {
Ok(())
}
}

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

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

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

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

// Go back to where we were at
Expand Down
Loading