Skip to content

Commit

Permalink
Auto merge of rust-lang#87746 - JohnTitor:rollup-zaapqgl, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - rust-lang#81797 (Add `core::stream::from_iter`)
 - rust-lang#87267 (Remove space after negative sign in Literal to_string)
 - rust-lang#87663 (Rustdoc accessibility: use an icon for the [-]/[+] controls)
 - rust-lang#87720 (don't use .into() to convert types to identical types (clippy::useless_conversion))
 - rust-lang#87723 (Use .contains instead of manual reimplementation.)
 - rust-lang#87729 (Remove the aarch64 `crypto` target_feature)
 - rust-lang#87731 (Update cargo)
 - rust-lang#87734 (Test dropping union fields more)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Aug 3, 2021
2 parents a6ece56 + 7c5588e commit 2b8de6f
Show file tree
Hide file tree
Showing 35 changed files with 375 additions and 67 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock
Expand Up @@ -255,7 +255,7 @@ checksum = "81a18687293a1546b67c246452202bbbf143d239cb43494cc163da14979082da"

[[package]]
name = "cargo"
version = "0.56.0"
version = "0.57.0"
dependencies = [
"anyhow",
"atty",
Expand Down Expand Up @@ -388,7 +388,7 @@ dependencies = [

[[package]]
name = "cargo-util"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"anyhow",
"core-foundation",
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Expand Up @@ -47,8 +47,6 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("sve", Some(sym::aarch64_target_feature)),
// FEAT_CRC
("crc", Some(sym::aarch64_target_feature)),
// Cryptographic extension
("crypto", Some(sym::aarch64_target_feature)),
// FEAT_RAS
("ras", Some(sym::aarch64_target_feature)),
// FEAT_LSE
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_expand/src/proc_macro_server.rs
Expand Up @@ -582,6 +582,9 @@ impl server::Literal for Rustc<'_> {

Ok(Literal { lit, span: self.call_site })
}
fn to_string(&mut self, literal: &Self::Literal) -> String {
literal.lit.to_string()
}
fn debug_kind(&mut self, literal: &Self::Literal) -> String {
format!("{:?}", literal.lit.kind)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/interpret/operand.rs
Expand Up @@ -599,7 +599,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let ptr = self.global_base_pointer(Pointer::new(id, offset))?;
Operand::Indirect(MemPlace::from_ptr(ptr.into(), layout.align.abi))
}
ConstValue::Scalar(x) => Operand::Immediate(tag_scalar(x.into())?.into()),
ConstValue::Scalar(x) => Operand::Immediate(tag_scalar(x)?.into()),
ConstValue::Slice { data, start, end } => {
// We rely on mutability being set correctly in `data` to prevent writes
// where none should happen.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/interpret/terminator.rs
Expand Up @@ -73,7 +73,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
ty::FnPtr(sig) => {
let caller_abi = sig.abi();
let fn_ptr = self.read_pointer(&func)?;
let fn_val = self.memory.get_fn(fn_ptr.into())?;
let fn_val = self.memory.get_fn(fn_ptr)?;
(
fn_val,
caller_abi,
Expand Down
Expand Up @@ -211,7 +211,7 @@ fn find_branch_value_info<'tcx>(
return None;
};
let branch_value_scalar = branch_value.literal.try_to_scalar()?;
Some((branch_value_scalar.into(), branch_value_ty, *to_switch_on))
Some((branch_value_scalar, branch_value_ty, *to_switch_on))
}
_ => None,
}
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/num/mod.rs
Expand Up @@ -847,7 +847,7 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32) -> Result<T, Par
use self::ParseIntError as PIE;

assert!(
radix >= 2 && radix <= 36,
(2..=36).contains(&radix),
"from_str_radix_int: must lie in the range `[2, 36]` - found {}",
radix
);
Expand Down
38 changes: 38 additions & 0 deletions library/core/src/stream/from_iter.rs
@@ -0,0 +1,38 @@
use crate::pin::Pin;

use crate::stream::Stream;
use crate::task::{Context, Poll};

/// A stream that was created from iterator.
///
/// This stream is created by the [`from_iter`] function.
/// See it documentation for more.
///
/// [`from_iter`]: fn.from_iter.html
#[unstable(feature = "stream_from_iter", issue = "81798")]
#[derive(Clone, Debug)]
pub struct FromIter<I> {
iter: I,
}

#[unstable(feature = "stream_from_iter", issue = "81798")]
impl<I> Unpin for FromIter<I> {}

/// Converts an iterator into a stream.
#[unstable(feature = "stream_from_iter", issue = "81798")]
pub fn from_iter<I: IntoIterator>(iter: I) -> FromIter<I::IntoIter> {
FromIter { iter: iter.into_iter() }
}

#[unstable(feature = "stream_from_iter", issue = "81798")]
impl<I: Iterator> Stream for FromIter<I> {
type Item = I::Item;

fn poll_next(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Poll::Ready(self.iter.next())
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
}
}
2 changes: 2 additions & 0 deletions library/core/src/stream/mod.rs
Expand Up @@ -122,6 +122,8 @@
//! warning: unused result that must be used: streams do nothing unless polled
//! ```

mod from_iter;
mod stream;

pub use from_iter::{from_iter, FromIter};
pub use stream::Stream;
1 change: 1 addition & 0 deletions library/proc_macro/src/bridge/mod.rs
Expand Up @@ -109,6 +109,7 @@ macro_rules! with_api {
fn drop($self: $S::Literal);
fn clone($self: &$S::Literal) -> $S::Literal;
fn from_str(s: &str) -> Result<$S::Literal, ()>;
fn to_string($self: &$S::Literal) -> String;
fn debug_kind($self: &$S::Literal) -> String;
fn symbol($self: &$S::Literal) -> String;
fn suffix($self: &$S::Literal) -> Option<String>;
Expand Down
2 changes: 1 addition & 1 deletion library/proc_macro/src/lib.rs
Expand Up @@ -1195,7 +1195,7 @@ impl FromStr for Literal {
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
impl ToString for Literal {
fn to_string(&self) -> String {
TokenStream::from(TokenTree::from(self.clone())).to_string()
self.0.to_string()
}
}

Expand Down
38 changes: 36 additions & 2 deletions library/std/tests/run-time-detect.rs
Expand Up @@ -16,22 +16,56 @@
fn arm_linux() {
println!("neon: {}", is_arm_feature_detected!("neon"));
println!("pmull: {}", is_arm_feature_detected!("pmull"));
println!("crypto: {}", is_arm_feature_detected!("crypto"));
println!("crc: {}", is_arm_feature_detected!("crc"));
println!("aes: {}", is_arm_feature_detected!("aes"));
println!("sha2: {}", is_arm_feature_detected!("sha2"));
}

#[test]
#[cfg(all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")))]
fn aarch64_linux() {
println!("fp: {}", is_aarch64_feature_detected!("fp"));
println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
println!("neon: {}", is_aarch64_feature_detected!("neon"));
println!("asimd: {}", is_aarch64_feature_detected!("asimd"));
println!("pmull: {}", is_aarch64_feature_detected!("pmull"));
println!("fp: {}", is_aarch64_feature_detected!("fp"));
println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
println!("sve: {}", is_aarch64_feature_detected!("sve"));
println!("crc: {}", is_aarch64_feature_detected!("crc"));
println!("lse: {}", is_aarch64_feature_detected!("lse"));
println!("lse2: {}", is_aarch64_feature_detected!("lse2"));
println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
println!("rcpc2: {}", is_aarch64_feature_detected!("rcpc2"));
println!("dotprod: {}", is_aarch64_feature_detected!("dotprod"));
println!("tme: {}", is_aarch64_feature_detected!("tme"));
println!("fhm: {}", is_aarch64_feature_detected!("fhm"));
println!("dit: {}", is_aarch64_feature_detected!("dit"));
println!("flagm: {}", is_aarch64_feature_detected!("flagm"));
println!("ssbs: {}", is_aarch64_feature_detected!("ssbs"));
println!("sb: {}", is_aarch64_feature_detected!("sb"));
println!("pauth: {}", is_aarch64_feature_detected!("pauth"));
println!("dpb: {}", is_aarch64_feature_detected!("dpb"));
println!("dpb2: {}", is_aarch64_feature_detected!("dpb2"));
println!("sve2: {}", is_aarch64_feature_detected!("sve2"));
println!("sve2-aes: {}", is_aarch64_feature_detected!("sve2-aes"));
println!("sve2-sm4: {}", is_aarch64_feature_detected!("sve2-sm4"));
println!("sve2-sha3: {}", is_aarch64_feature_detected!("sve2-sha3"));
println!("sve2-bitperm: {}", is_aarch64_feature_detected!("sve2-bitperm"));
println!("frintts: {}", is_aarch64_feature_detected!("frintts"));
println!("i8mm: {}", is_aarch64_feature_detected!("i8mm"));
println!("f32mm: {}", is_aarch64_feature_detected!("f32mm"));
println!("f64mm: {}", is_aarch64_feature_detected!("f64mm"));
println!("bf16: {}", is_aarch64_feature_detected!("bf16"));
println!("rand: {}", is_aarch64_feature_detected!("rand"));
println!("bti: {}", is_aarch64_feature_detected!("bti"));
println!("mte: {}", is_aarch64_feature_detected!("mte"));
println!("jsconv: {}", is_aarch64_feature_detected!("jsconv"));
println!("fcma: {}", is_aarch64_feature_detected!("fcma"));
println!("aes: {}", is_aarch64_feature_detected!("aes"));
println!("sha2: {}", is_aarch64_feature_detected!("sha2"));
println!("sha3: {}", is_aarch64_feature_detected!("sha3"));
println!("sm4: {}", is_aarch64_feature_detected!("sm4"));
}

#[test]
Expand Down
9 changes: 4 additions & 5 deletions src/librustdoc/clean/mod.rs
Expand Up @@ -675,11 +675,10 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
if let Some(((_, trait_did, name), rhs)) =
proj.as_ref().and_then(|(lhs, rhs)| Some((lhs.projection()?, rhs)))
{
impl_trait_proj.entry(param_idx).or_default().push((
trait_did.into(),
name,
rhs,
));
impl_trait_proj
.entry(param_idx)
.or_default()
.push((trait_did, name, rhs));
}

return None;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/types.rs
Expand Up @@ -1614,7 +1614,7 @@ impl Type {
impl Type {
fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId> {
let t: PrimitiveType = match *self {
ResolvedPath { did, .. } => return Some(did.into()),
ResolvedPath { did, .. } => return Some(did),
DynTrait(ref bounds, _) => return bounds[0].trait_.inner_def_id(cache),
Primitive(p) => return cache.and_then(|c| c.primitive_locations.get(&p).cloned()),
BorrowedRef { type_: box Generic(..), .. } => PrimitiveType::Reference,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/formats/cache.rs
Expand Up @@ -228,7 +228,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
if i.blanket_impl.is_none() {
self.cache
.implementors
.entry(did.into())
.entry(did)
.or_default()
.push(Impl { impl_item: item.clone() });
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/format.rs
Expand Up @@ -688,7 +688,7 @@ crate fn anchor<'a, 'cx: 'a>(
text: &'a str,
cx: &'cx Context<'_>,
) -> impl fmt::Display + 'a {
let parts = href(did.into(), cx);
let parts = href(did, cx);
display_fn(move |f| {
if let Ok((url, short_ty, fqp)) = parts {
write!(
Expand Down Expand Up @@ -921,7 +921,7 @@ fn fmt_type<'cx>(
// everything comes in as a fully resolved QPath (hard to
// look at).
box clean::ResolvedPath { did, .. } => {
match href(did.into(), cx) {
match href(did, cx) {
Ok((ref url, _, ref path)) if !f.alternate() => {
write!(
f,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/cache.rs
Expand Up @@ -42,7 +42,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
name: item.name.unwrap().to_string(),
path: fqp[..fqp.len() - 1].join("::"),
desc,
parent: Some(did.into()),
parent: Some(did),
parent_idx: None,
search_type: get_index_search_type(&item, tcx),
aliases: item.attrs.get_doc_aliases(),
Expand Down
40 changes: 39 additions & 1 deletion src/librustdoc/html/render/write_shared.rs
Expand Up @@ -175,9 +175,45 @@ pub(super) fn write_shared(
cx.write_shared(SharedResource::InvocationSpecific { basename: p }, content, &options.emit)
};

fn add_background_image_to_css(
cx: &Context<'_>,
css: &mut String,
rule: &str,
file: &'static str,
) {
css.push_str(&format!(
"{} {{ background-image: url({}); }}",
rule,
SharedResource::ToolchainSpecific { basename: file }
.path(cx)
.file_name()
.unwrap()
.to_str()
.unwrap()
))
}

// Add all the static files. These may already exist, but we just
// overwrite them anyway to make sure that they're fresh and up-to-date.
let mut rustdoc_css = static_files::RUSTDOC_CSS.to_owned();
add_background_image_to_css(
cx,
&mut rustdoc_css,
"details.undocumented[open] > summary::before, \
details.rustdoc-toggle[open] > summary::before, \
details.rustdoc-toggle[open] > summary.hideme::before",
"toggle-minus.svg",
);
add_background_image_to_css(
cx,
&mut rustdoc_css,
"details.undocumented > summary::before, details.rustdoc-toggle > summary::before",
"toggle-plus.svg",
);
write_minify("rustdoc.css", &rustdoc_css)?;

// Add all the static files. These may already exist, but we just
// overwrite them anyway to make sure that they're fresh and up-to-date.
write_minify("rustdoc.css", static_files::RUSTDOC_CSS)?;
write_minify("settings.css", static_files::SETTINGS_CSS)?;
write_minify("noscript.css", static_files::NOSCRIPT_CSS)?;

Expand Down Expand Up @@ -217,6 +253,8 @@ pub(super) fn write_shared(
write_toolchain("wheel.svg", static_files::WHEEL_SVG)?;
write_toolchain("clipboard.svg", static_files::CLIPBOARD_SVG)?;
write_toolchain("down-arrow.svg", static_files::DOWN_ARROW_SVG)?;
write_toolchain("toggle-minus.svg", static_files::TOGGLE_MINUS_PNG)?;
write_toolchain("toggle-plus.svg", static_files::TOGGLE_PLUS_PNG)?;

let mut themes: Vec<&String> = themes.iter().collect();
themes.sort();
Expand Down

0 comments on commit 2b8de6f

Please sign in to comment.