Skip to content

Commit c34472b

Browse files
committed
Auto merge of #66208 - JohnTitor:rollup-2umgjer, r=JohnTitor
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
2 parents d257440 + 1969f41 commit c34472b

File tree

110 files changed

+459
-348
lines changed

Some content is hidden

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

110 files changed

+459
-348
lines changed

Diff for: src/etc/generate-deriving-span-tests.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
os.path.join(os.path.dirname(__file__), '../test/ui/derives/'))
1515

1616
TEMPLATE = """\
17-
// ignore-x86
18-
// ^ due to stderr output differences
17+
// ignore-x86 FIXME: missing sysroot spans (#53081)
1918
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
2019
2120
{error_deriving}

Diff for: src/libcore/mem/maybe_uninit.rs

+63
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,43 @@ impl<T> MaybeUninit<T> {
260260
MaybeUninit { uninit: () }
261261
}
262262

263+
/// Create a new array of `MaybeUninit<T>` items, in an uninitialized state.
264+
///
265+
/// Note: in a future Rust version this method may become unnecessary
266+
/// when array literal syntax allows
267+
/// [repeating const expressions](https://github.com/rust-lang/rust/issues/49147).
268+
/// The example below could then use `let mut buf = [MaybeUninit::<u8>::uninit(); 32];`.
269+
///
270+
/// # Examples
271+
///
272+
/// ```no_run
273+
/// #![feature(maybe_uninit_uninit_array, maybe_uninit_extra, maybe_uninit_slice_assume_init)]
274+
///
275+
/// use std::mem::MaybeUninit;
276+
///
277+
/// extern "C" {
278+
/// fn read_into_buffer(ptr: *mut u8, max_len: usize) -> usize;
279+
/// }
280+
///
281+
/// /// Returns a (possibly smaller) slice of data that was actually read
282+
/// fn read(buf: &mut [MaybeUninit<u8>]) -> &[u8] {
283+
/// unsafe {
284+
/// let len = read_into_buffer(buf.as_mut_ptr() as *mut u8, buf.len());
285+
/// MaybeUninit::slice_get_ref(&buf[..len])
286+
/// }
287+
/// }
288+
///
289+
/// let mut buf: [MaybeUninit<u8>; 32] = MaybeUninit::uninit_array();
290+
/// let data = read(&mut buf);
291+
/// ```
292+
#[unstable(feature = "maybe_uninit_uninit_array", issue = "0")]
293+
#[inline(always)]
294+
pub fn uninit_array<const LEN: usize>() -> [Self; LEN] {
295+
unsafe {
296+
MaybeUninit::<[MaybeUninit<T>; LEN]>::uninit().assume_init()
297+
}
298+
}
299+
263300
/// A promotable constant, equivalent to `uninit()`.
264301
#[unstable(feature = "internal_uninit_const", issue = "0",
265302
reason = "hack to work around promotability")]
@@ -692,6 +729,32 @@ impl<T> MaybeUninit<T> {
692729
&mut *self.value
693730
}
694731

732+
/// Assuming all the elements are initialized, get a slice to them.
733+
///
734+
/// # Safety
735+
///
736+
/// It is up to the caller to guarantee that the `MaybeUninit<T>` elements
737+
/// really are in an initialized state.
738+
/// Calling this when the content is not yet fully initialized causes undefined behavior.
739+
#[unstable(feature = "maybe_uninit_slice_assume_init", issue = "0")]
740+
#[inline(always)]
741+
pub unsafe fn slice_get_ref(slice: &[Self]) -> &[T] {
742+
&*(slice as *const [Self] as *const [T])
743+
}
744+
745+
/// Assuming all the elements are initialized, get a mutable slice to them.
746+
///
747+
/// # Safety
748+
///
749+
/// It is up to the caller to guarantee that the `MaybeUninit<T>` elements
750+
/// really are in an initialized state.
751+
/// Calling this when the content is not yet fully initialized causes undefined behavior.
752+
#[unstable(feature = "maybe_uninit_slice_assume_init", issue = "0")]
753+
#[inline(always)]
754+
pub unsafe fn slice_get_mut(slice: &mut [Self]) -> &mut [T] {
755+
&mut *(slice as *mut [Self] as *mut [T])
756+
}
757+
695758
/// Gets a pointer to the first element of the array.
696759
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
697760
#[inline(always)]

Diff for: src/librustc/ich/impls_syntax.rs

-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
162162
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
163163
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
164164
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
165-
impl_stable_hash_for!(enum ::rustc_target::abi::FloatTy { F32, F64 });
166165
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
167166
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
168167
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });

Diff for: src/librustc/ty/layout.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ impl PrimitiveExt for Primitive {
132132
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
133133
match *self {
134134
Int(i, signed) => i.to_ty(tcx, signed),
135-
Float(FloatTy::F32) => tcx.types.f32,
136-
Float(FloatTy::F64) => tcx.types.f64,
135+
F32 => tcx.types.f32,
136+
F64 => tcx.types.f64,
137137
Pointer => tcx.mk_mut_ptr(tcx.mk_unit()),
138138
}
139139
}
@@ -144,7 +144,7 @@ impl PrimitiveExt for Primitive {
144144
match *self {
145145
Int(i, signed) => i.to_ty(tcx, signed),
146146
Pointer => tcx.types.usize,
147-
Float(..) => bug!("floats do not have an int type"),
147+
F32 | F64 => bug!("floats do not have an int type"),
148148
}
149149
}
150150
}
@@ -538,10 +538,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
538538
ty::Uint(ity) => {
539539
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
540540
}
541-
ty::Float(fty) => scalar(Float(match fty {
542-
ast::FloatTy::F32 => FloatTy::F32,
543-
ast::FloatTy::F64 => FloatTy::F64,
544-
})),
541+
ty::Float(fty) => scalar(match fty {
542+
ast::FloatTy::F32 => F32,
543+
ast::FloatTy::F64 => F64,
544+
}),
545545
ty::FnPtr(_) => {
546546
let mut ptr = scalar_unit(Pointer);
547547
ptr.valid_range = 1..=*ptr.valid_range.end();
@@ -2457,7 +2457,8 @@ impl_stable_hash_for!(enum crate::ty::layout::Integer {
24572457

24582458
impl_stable_hash_for!(enum crate::ty::layout::Primitive {
24592459
Int(integer, signed),
2460-
Float(fty),
2460+
F32,
2461+
F64,
24612462
Pointer
24622463
});
24632464

Diff for: src/librustc_codegen_llvm/debuginfo/metadata.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1904,8 +1904,8 @@ fn prepare_enum_metadata(
19041904

19051905
let discr_type = match discr.value {
19061906
layout::Int(t, _) => t,
1907-
layout::Float(layout::FloatTy::F32) => Integer::I32,
1908-
layout::Float(layout::FloatTy::F64) => Integer::I64,
1907+
layout::F32 => Integer::I32,
1908+
layout::F64 => Integer::I64,
19091909
layout::Pointer => cx.data_layout().ptr_sized_integer(),
19101910
}.to_ty(cx.tcx, false);
19111911

Diff for: src/librustc_codegen_llvm/intrinsic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Primitive};
1818
use rustc::mir::interpret::GlobalId;
1919
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
2020
use rustc::hir;
21-
use rustc_target::abi::{FloatTy, HasDataLayout};
21+
use rustc_target::abi::HasDataLayout;
2222
use syntax::ast;
2323

2424
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
@@ -163,12 +163,12 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
163163
emit_va_arg(self, args[0], ret_ty)
164164
}
165165
}
166-
Primitive::Float(FloatTy::F64) |
166+
Primitive::F64 |
167167
Primitive::Pointer => {
168168
emit_va_arg(self, args[0], ret_ty)
169169
}
170170
// `va_arg` should never be used with the return type f32.
171-
Primitive::Float(FloatTy::F32) => {
171+
Primitive::F32 => {
172172
bug!("the va_arg intrinsic does not work with `f32`")
173173
}
174174
}

Diff for: src/librustc_codegen_llvm/type_of.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::common::*;
33
use crate::type_::Type;
44
use rustc::ty::{self, Ty, TypeFoldable};
55
use rustc::ty::layout::{self, Align, LayoutOf, FnAbiExt, PointeeInfo, Size, TyLayout};
6-
use rustc_target::abi::{FloatTy, TyLayoutMethods};
6+
use rustc_target::abi::TyLayoutMethods;
77
use rustc::ty::print::obsolete::DefPathBasedNames;
88
use rustc_codegen_ssa::traits::*;
99

@@ -300,8 +300,8 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
300300
scalar: &layout::Scalar, offset: Size) -> &'a Type {
301301
match scalar.value {
302302
layout::Int(i, _) => cx.type_from_integer( i),
303-
layout::Float(FloatTy::F32) => cx.type_f32(),
304-
layout::Float(FloatTy::F64) => cx.type_f64(),
303+
layout::F32 => cx.type_f32(),
304+
layout::F64 => cx.type_f64(),
305305
layout::Pointer => {
306306
// If we know the alignment, pick something better than i8.
307307
let pointee = if let Some(pointee) = self.pointee_info_at(cx, offset) {

Diff for: src/librustc_metadata/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::cstore::{self, CStore, MetadataBlob};
44
use crate::locator::{self, CratePaths};
5-
use crate::schema::{CrateRoot, CrateDep};
5+
use crate::rmeta::{CrateRoot, CrateDep};
66
use rustc_data_structures::sync::{Lock, Once, AtomicCell};
77

88
use rustc::hir::def_id::CrateNum;

Diff for: src/librustc_metadata/cstore.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// The crate store - a central repo for information collected about external
22
// crates and libraries
33

4-
use crate::schema;
4+
use crate::rmeta;
55
use rustc::dep_graph::DepNodeIndex;
66
use rustc::hir::def_id::{CrateNum, DefIndex};
77
use rustc::hir::map::definitions::DefPathTable;
@@ -17,7 +17,7 @@ use syntax_expand::base::SyntaxExtension;
1717
use syntax_pos;
1818
use proc_macro::bridge::client::ProcMacro;
1919

20-
pub use crate::cstore_impl::{provide, provide_extern};
20+
pub use crate::rmeta::{provide, provide_extern};
2121

2222
// A map from external crate numbers (as decoded from some crate file) to
2323
// local crate numbers (as generated during this session). Each external
@@ -49,7 +49,7 @@ crate struct CrateMetadata {
4949
/// lifetime is only used behind `Lazy`, and therefore acts like an
5050
/// universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
5151
/// is being used to decode those values.
52-
crate root: schema::CrateRoot<'static>,
52+
crate root: rmeta::CrateRoot<'static>,
5353
/// For each definition in this crate, we encode a key. When the
5454
/// crate is loaded, we read all the keys and put them in this
5555
/// hashmap, which gives the reverse mapping. This allows us to
@@ -59,7 +59,7 @@ crate struct CrateMetadata {
5959
/// Trait impl data.
6060
/// FIXME: Used only from queries and can use query cache,
6161
/// so pre-decoding can probably be avoided.
62-
crate trait_impls: FxHashMap<(u32, DefIndex), schema::Lazy<[DefIndex]>>,
62+
crate trait_impls: FxHashMap<(u32, DefIndex), rmeta::Lazy<[DefIndex]>>,
6363
/// Proc macro descriptions for this crate, if it's a proc macro crate.
6464
crate raw_proc_macros: Option<&'static [ProcMacro]>,
6565
/// Source maps for code from the crate.

Diff for: src/librustc_metadata/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,11 @@ extern crate rustc_data_structures;
2626

2727
pub mod error_codes;
2828

29-
mod encoder;
30-
mod decoder;
3129
mod dependency_format;
32-
mod cstore_impl;
3330
mod foreign_modules;
3431
mod link_args;
3532
mod native_libs;
36-
mod schema;
37-
mod table;
33+
mod rmeta;
3834

3935
pub mod creader;
4036
pub mod cstore;

Diff for: src/librustc_metadata/locator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
215215
use crate::cstore::MetadataBlob;
216216
use crate::creader::Library;
217-
use crate::schema::{METADATA_HEADER, rustc_version};
217+
use crate::rmeta::{METADATA_HEADER, rustc_version};
218218

219219
use rustc_data_structures::fx::FxHashSet;
220220
use rustc_data_structures::svh::Svh;

0 commit comments

Comments
 (0)