Skip to content

Commit

Permalink
Auto merge of #66208 - JohnTitor:rollup-2umgjer, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - #65554 (Enhance the documentation of BufReader for potential data loss)
 - #65580 (Add `MaybeUninit` methods `uninit_array`, `slice_get_ref`, `slice_get_mut`)
 - #66049 (consistent handling of missing sysroot spans)
 - #66056 (rustc_metadata: Some reorganization of the module structure)
 - #66123 (No more hidden elements)
 - #66157 (Improve math log documentation examples)
 - #66165 (Ignore these tests ,since the called commands doesn't exist in VxWorks)
 - #66190 (rustc_target: inline abi::FloatTy into abi::Primitive.)

Failed merges:

 - #66188 (`MethodSig` -> `FnSig` & Use it in `ItemKind::Fn`)

r? @ghost
  • Loading branch information
bors committed Nov 8, 2019
2 parents d257440 + 1969f41 commit c34472b
Show file tree
Hide file tree
Showing 110 changed files with 459 additions and 348 deletions.
3 changes: 1 addition & 2 deletions src/etc/generate-deriving-span-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
os.path.join(os.path.dirname(__file__), '../test/ui/derives/'))

TEMPLATE = """\
// ignore-x86
// ^ due to stderr output differences
// ignore-x86 FIXME: missing sysroot spans (#53081)
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
{error_deriving}
Expand Down
63 changes: 63 additions & 0 deletions src/libcore/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,43 @@ impl<T> MaybeUninit<T> {
MaybeUninit { uninit: () }
}

/// Create a new array of `MaybeUninit<T>` items, in an uninitialized state.
///
/// Note: in a future Rust version this method may become unnecessary
/// when array literal syntax allows
/// [repeating const expressions](https://github.com/rust-lang/rust/issues/49147).
/// The example below could then use `let mut buf = [MaybeUninit::<u8>::uninit(); 32];`.
///
/// # Examples
///
/// ```no_run
/// #![feature(maybe_uninit_uninit_array, maybe_uninit_extra, maybe_uninit_slice_assume_init)]
///
/// use std::mem::MaybeUninit;
///
/// extern "C" {
/// fn read_into_buffer(ptr: *mut u8, max_len: usize) -> usize;
/// }
///
/// /// Returns a (possibly smaller) slice of data that was actually read
/// fn read(buf: &mut [MaybeUninit<u8>]) -> &[u8] {
/// unsafe {
/// let len = read_into_buffer(buf.as_mut_ptr() as *mut u8, buf.len());
/// MaybeUninit::slice_get_ref(&buf[..len])
/// }
/// }
///
/// let mut buf: [MaybeUninit<u8>; 32] = MaybeUninit::uninit_array();
/// let data = read(&mut buf);
/// ```
#[unstable(feature = "maybe_uninit_uninit_array", issue = "0")]
#[inline(always)]
pub fn uninit_array<const LEN: usize>() -> [Self; LEN] {
unsafe {
MaybeUninit::<[MaybeUninit<T>; LEN]>::uninit().assume_init()
}
}

/// A promotable constant, equivalent to `uninit()`.
#[unstable(feature = "internal_uninit_const", issue = "0",
reason = "hack to work around promotability")]
Expand Down Expand Up @@ -692,6 +729,32 @@ impl<T> MaybeUninit<T> {
&mut *self.value
}

/// Assuming all the elements are initialized, get a slice to them.
///
/// # Safety
///
/// It is up to the caller to guarantee that the `MaybeUninit<T>` elements
/// really are in an initialized state.
/// Calling this when the content is not yet fully initialized causes undefined behavior.
#[unstable(feature = "maybe_uninit_slice_assume_init", issue = "0")]
#[inline(always)]
pub unsafe fn slice_get_ref(slice: &[Self]) -> &[T] {
&*(slice as *const [Self] as *const [T])
}

/// Assuming all the elements are initialized, get a mutable slice to them.
///
/// # Safety
///
/// It is up to the caller to guarantee that the `MaybeUninit<T>` elements
/// really are in an initialized state.
/// Calling this when the content is not yet fully initialized causes undefined behavior.
#[unstable(feature = "maybe_uninit_slice_assume_init", issue = "0")]
#[inline(always)]
pub unsafe fn slice_get_mut(slice: &mut [Self]) -> &mut [T] {
&mut *(slice as *mut [Self] as *mut [T])
}

/// Gets a pointer to the first element of the array.
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
#[inline(always)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
impl_stable_hash_for!(enum ::rustc_target::abi::FloatTy { F32, F64 });
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });
Expand Down
17 changes: 9 additions & 8 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ impl PrimitiveExt for Primitive {
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
match *self {
Int(i, signed) => i.to_ty(tcx, signed),
Float(FloatTy::F32) => tcx.types.f32,
Float(FloatTy::F64) => tcx.types.f64,
F32 => tcx.types.f32,
F64 => tcx.types.f64,
Pointer => tcx.mk_mut_ptr(tcx.mk_unit()),
}
}
Expand All @@ -144,7 +144,7 @@ impl PrimitiveExt for Primitive {
match *self {
Int(i, signed) => i.to_ty(tcx, signed),
Pointer => tcx.types.usize,
Float(..) => bug!("floats do not have an int type"),
F32 | F64 => bug!("floats do not have an int type"),
}
}
}
Expand Down Expand Up @@ -538,10 +538,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
ty::Uint(ity) => {
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
}
ty::Float(fty) => scalar(Float(match fty {
ast::FloatTy::F32 => FloatTy::F32,
ast::FloatTy::F64 => FloatTy::F64,
})),
ty::Float(fty) => scalar(match fty {
ast::FloatTy::F32 => F32,
ast::FloatTy::F64 => F64,
}),
ty::FnPtr(_) => {
let mut ptr = scalar_unit(Pointer);
ptr.valid_range = 1..=*ptr.valid_range.end();
Expand Down Expand Up @@ -2457,7 +2457,8 @@ impl_stable_hash_for!(enum crate::ty::layout::Integer {

impl_stable_hash_for!(enum crate::ty::layout::Primitive {
Int(integer, signed),
Float(fty),
F32,
F64,
Pointer
});

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1904,8 +1904,8 @@ fn prepare_enum_metadata(

let discr_type = match discr.value {
layout::Int(t, _) => t,
layout::Float(layout::FloatTy::F32) => Integer::I32,
layout::Float(layout::FloatTy::F64) => Integer::I64,
layout::F32 => Integer::I32,
layout::F64 => Integer::I64,
layout::Pointer => cx.data_layout().ptr_sized_integer(),
}.to_ty(cx.tcx, false);

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Primitive};
use rustc::mir::interpret::GlobalId;
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
use rustc::hir;
use rustc_target::abi::{FloatTy, HasDataLayout};
use rustc_target::abi::HasDataLayout;
use syntax::ast;

use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
Expand Down Expand Up @@ -163,12 +163,12 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
emit_va_arg(self, args[0], ret_ty)
}
}
Primitive::Float(FloatTy::F64) |
Primitive::F64 |
Primitive::Pointer => {
emit_va_arg(self, args[0], ret_ty)
}
// `va_arg` should never be used with the return type f32.
Primitive::Float(FloatTy::F32) => {
Primitive::F32 => {
bug!("the va_arg intrinsic does not work with `f32`")
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::common::*;
use crate::type_::Type;
use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::{self, Align, LayoutOf, FnAbiExt, PointeeInfo, Size, TyLayout};
use rustc_target::abi::{FloatTy, TyLayoutMethods};
use rustc_target::abi::TyLayoutMethods;
use rustc::ty::print::obsolete::DefPathBasedNames;
use rustc_codegen_ssa::traits::*;

Expand Down Expand Up @@ -300,8 +300,8 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
scalar: &layout::Scalar, offset: Size) -> &'a Type {
match scalar.value {
layout::Int(i, _) => cx.type_from_integer( i),
layout::Float(FloatTy::F32) => cx.type_f32(),
layout::Float(FloatTy::F64) => cx.type_f64(),
layout::F32 => cx.type_f32(),
layout::F64 => cx.type_f64(),
layout::Pointer => {
// If we know the alignment, pick something better than i8.
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::cstore::{self, CStore, MetadataBlob};
use crate::locator::{self, CratePaths};
use crate::schema::{CrateRoot, CrateDep};
use crate::rmeta::{CrateRoot, CrateDep};
use rustc_data_structures::sync::{Lock, Once, AtomicCell};

use rustc::hir::def_id::CrateNum;
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_metadata/cstore.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The crate store - a central repo for information collected about external
// crates and libraries

use crate::schema;
use crate::rmeta;
use rustc::dep_graph::DepNodeIndex;
use rustc::hir::def_id::{CrateNum, DefIndex};
use rustc::hir::map::definitions::DefPathTable;
Expand All @@ -17,7 +17,7 @@ use syntax_expand::base::SyntaxExtension;
use syntax_pos;
use proc_macro::bridge::client::ProcMacro;

pub use crate::cstore_impl::{provide, provide_extern};
pub use crate::rmeta::{provide, provide_extern};

// A map from external crate numbers (as decoded from some crate file) to
// local crate numbers (as generated during this session). Each external
Expand Down Expand Up @@ -49,7 +49,7 @@ crate struct CrateMetadata {
/// lifetime is only used behind `Lazy`, and therefore acts like an
/// universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
/// is being used to decode those values.
crate root: schema::CrateRoot<'static>,
crate root: rmeta::CrateRoot<'static>,
/// For each definition in this crate, we encode a key. When the
/// crate is loaded, we read all the keys and put them in this
/// hashmap, which gives the reverse mapping. This allows us to
Expand All @@ -59,7 +59,7 @@ crate struct CrateMetadata {
/// Trait impl data.
/// FIXME: Used only from queries and can use query cache,
/// so pre-decoding can probably be avoided.
crate trait_impls: FxHashMap<(u32, DefIndex), schema::Lazy<[DefIndex]>>,
crate trait_impls: FxHashMap<(u32, DefIndex), rmeta::Lazy<[DefIndex]>>,
/// Proc macro descriptions for this crate, if it's a proc macro crate.
crate raw_proc_macros: Option<&'static [ProcMacro]>,
/// Source maps for code from the crate.
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ extern crate rustc_data_structures;

pub mod error_codes;

mod encoder;
mod decoder;
mod dependency_format;
mod cstore_impl;
mod foreign_modules;
mod link_args;
mod native_libs;
mod schema;
mod table;
mod rmeta;

pub mod creader;
pub mod cstore;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@

use crate::cstore::MetadataBlob;
use crate::creader::Library;
use crate::schema::{METADATA_HEADER, rustc_version};
use crate::rmeta::{METADATA_HEADER, rustc_version};

use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::svh::Svh;
Expand Down
Loading

0 comments on commit c34472b

Please sign in to comment.