Skip to content

Commit

Permalink
Auto merge of rust-lang#62873 - Centril:rollup-ncnuelj, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests

Successful merges:

 - rust-lang#62709 (Test that maplike FromIter satisfies uniqueness)
 - rust-lang#62713 (Stabilize <*mut _>::cast and <*const _>::cast)
 - rust-lang#62746 ( do not use assume_init in std::io)
 - rust-lang#62787 (Fix typo in src/libstd/net/udp.rs doc comment)
 - rust-lang#62788 (normalize use of backticks in compiler messages for libcore/ptr)
 - rust-lang#62799 (use const array repeat expressions for uninit_array)
 - rust-lang#62810 (normalize use of backticks in compiler messages for librustc_lint)
 - rust-lang#62812 (normalize use of backticks in compiler messages for librustc_metadata)
 - rust-lang#62832 (normalize use of backticks in compiler messages for librustc_incremental)
 - rust-lang#62845 (read: fix doc comment)
 - rust-lang#62853 (normalize use of backticks in compiler messages for librustc/hir)
 - rust-lang#62854 (Fix typo in Unicode character name)
 - rust-lang#62858 (Change wrong variable name.)
 - rust-lang#62870 (fix lexing of comments with many \r)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jul 22, 2019
2 parents 4bc1ce7 + 376382a commit e649e90
Show file tree
Hide file tree
Showing 62 changed files with 212 additions and 154 deletions.
8 changes: 4 additions & 4 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ use Entry::*;
///
/// // look up the values associated with some keys.
/// let to_find = ["Up!", "Office Space"];
/// for book in &to_find {
/// match movie_reviews.get(book) {
/// Some(review) => println!("{}: {}", book, review),
/// None => println!("{} is unreviewed.", book)
/// for movie in &to_find {
/// match movie_reviews.get(movie) {
/// Some(review) => println!("{}: {}", movie, review),
/// None => println!("{} is unreviewed.", movie)
/// }
/// }
///
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ impl<K, V> LeafNode<K, V> {
LeafNode {
// As a general policy, we leave fields uninitialized if they can be, as this should
// be both slightly faster and easier to track in Valgrind.
keys: uninitialized_array![_; CAPACITY],
vals: uninitialized_array![_; CAPACITY],
keys: uninit_array![_; CAPACITY],
vals: uninit_array![_; CAPACITY],
parent: ptr::null(),
parent_idx: MaybeUninit::uninit(),
len: 0
Expand Down Expand Up @@ -159,7 +159,7 @@ impl<K, V> InternalNode<K, V> {
unsafe fn new() -> Self {
InternalNode {
data: LeafNode::new(),
edges: uninitialized_array![_; 2*B],
edges: uninit_array![_; 2*B],
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@
#![feature(box_syntax)]
#![feature(cfg_target_has_atomic)]
#![feature(coerce_unsized)]
#![cfg_attr(not(bootstrap), feature(const_in_array_repeat_expressions))]
#![feature(dispatch_from_dyn)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![feature(exact_size_is_empty)]
#![feature(fmt_internals)]
#![feature(fn_traits)]
#![feature(fundamental)]
#![feature(internal_uninit_const)]
#![feature(lang_items)]
#![feature(libc)]
#![feature(nll)]
Expand Down
7 changes: 4 additions & 3 deletions src/libcore/fmt/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ fn float_to_decimal_common_exact<T>(fmt: &mut Formatter<'_>, num: &T,
unsafe {
let mut buf = MaybeUninit::<[u8; 1024]>::uninit(); // enough for f32 and f64
let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 4]>::uninit();
// FIXME(#53491): Technically, this is calling `get_mut` on an uninitialized
// `MaybeUninit` (here and elsewhere in this file). Revisit this once
// FIXME(#53491): This is calling `get_mut` on an uninitialized
// `MaybeUninit` (here and elsewhere in this file). Revisit this once
// we decided whether that is valid or not.
// Using `freeze` is *not enough*; `flt2dec::Part` is an enum!
// We can do this only because we are libstd and coupled to the compiler.
// (FWIW, using `freeze` would not be enough; `flt2dec::Part` is an enum!)
let formatted = flt2dec::to_exact_fixed_str(flt2dec::strategy::grisu::format_exact,
*num, sign, precision,
false, buf.get_mut(), parts.get_mut());
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ trait GenericRadix {
// characters for a base 2 number.
let zero = T::zero();
let is_nonnegative = x >= zero;
let mut buf = uninitialized_array![u8; 128];
let mut buf = [MaybeUninit::<u8>::uninit(); 128];
let mut curr = buf.len();
let base = T::from_u8(Self::BASE);
if is_nonnegative {
Expand Down Expand Up @@ -189,7 +189,7 @@ static DEC_DIGITS_LUT: &[u8; 200] =
macro_rules! impl_Display {
($($t:ident),* as $u:ident via $conv_fn:ident named $name:ident) => {
fn $name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut buf = uninitialized_array![u8; 39];
let mut buf = [MaybeUninit::<u8>::uninit(); 39];
let mut curr = buf.len() as isize;
let buf_ptr = MaybeUninit::first_ptr_mut(&mut buf);
let lut_ptr = DEC_DIGITS_LUT.as_ptr();
Expand Down
23 changes: 20 additions & 3 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,20 +626,37 @@ macro_rules! todo {
/// Creates an array of [`MaybeUninit`].
///
/// This macro constructs an uninitialized array of the type `[MaybeUninit<K>; N]`.
/// It exists solely because bootstrap does not yet support const array-init expressions.
///
/// [`MaybeUninit`]: mem/union.MaybeUninit.html
// FIXME: Remove both versions of this macro once bootstrap is 1.38.
#[macro_export]
#[unstable(feature = "maybe_uninit_array", issue = "53491")]
macro_rules! uninitialized_array {
#[cfg(bootstrap)]
macro_rules! uninit_array {
// This `assume_init` is safe because an array of `MaybeUninit` does not
// require initialization.
// FIXME(#49147): Could be replaced by an array initializer, once those can
// be any const expression.
($t:ty; $size:expr) => (unsafe {
MaybeUninit::<[MaybeUninit<$t>; $size]>::uninit().assume_init()
});
}

/// Creates an array of [`MaybeUninit`].
///
/// This macro constructs an uninitialized array of the type `[MaybeUninit<K>; N]`.
/// It exists solely because bootstrap does not yet support const array-init expressions.
///
/// [`MaybeUninit`]: mem/union.MaybeUninit.html
// FIXME: Just inline this version of the macro once bootstrap is 1.38.
#[macro_export]
#[unstable(feature = "maybe_uninit_array", issue = "53491")]
#[cfg(not(bootstrap))]
macro_rules! uninit_array {
($t:ty; $size:expr) => (
[MaybeUninit::<$t>::UNINIT; $size]
);
}

/// Built-in macros to the compiler itself.
///
/// These macros do not have any corresponding definition with a `macro_rules!`
Expand Down
5 changes: 5 additions & 0 deletions src/libcore/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ impl<T> MaybeUninit<T> {
MaybeUninit { uninit: () }
}

/// A promotable constant, equivalent to `uninit()`.
#[unstable(feature = "internal_uninit_const", issue = "0",
reason = "hack to work around promotability")]
pub const UNINIT: Self = Self::uninit();

/// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being
/// filled with `0` bytes. It depends on `T` whether that already makes for
/// proper initialization. For example, `MaybeUninit<usize>::zeroed()` is initialized,
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ impl<T: ?Sized> *const T {
}

/// Cast to a pointer to a different type
#[unstable(feature = "ptr_cast", issue = "60602")]
#[stable(feature = "ptr_cast", since = "1.38.0")]
#[inline]
pub const fn cast<U>(self) -> *const U {
self as _
Expand Down Expand Up @@ -1678,7 +1678,7 @@ impl<T: ?Sized> *mut T {
}

/// Cast to a pointer to a different type
#[unstable(feature = "ptr_cast", issue = "60602")]
#[stable(feature = "ptr_cast", since = "1.38.0")]
#[inline]
pub const fn cast<U>(self) -> *mut U {
self as _
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/ptr/unique.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use crate::ptr::NonNull;
/// Unlike `*mut T`, `Unique<T>` is covariant over `T`. This should always be correct
/// for any type which upholds Unique's aliasing requirements.
#[unstable(feature = "ptr_internals", issue = "0",
reason = "use NonNull instead and consider PhantomData<T> \
(if you also use #[may_dangle]), Send, and/or Sync")]
reason = "use `NonNull` instead and consider `PhantomData<T>` \
(if you also use `#[may_dangle]`), `Send`, and/or `Sync`")]
#[doc(hidden)]
#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/slice/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ fn partition_in_blocks<T, F>(v: &mut [T], pivot: &T, is_less: &mut F) -> usize
let mut block_l = BLOCK;
let mut start_l = ptr::null_mut();
let mut end_l = ptr::null_mut();
let mut offsets_l: [MaybeUninit<u8>; BLOCK] = uninitialized_array![u8; BLOCK];
let mut offsets_l = [MaybeUninit::<u8>::uninit(); BLOCK];

// The current block on the right side (from `r.sub(block_r)` to `r`).
let mut r = unsafe { l.add(v.len()) };
let mut block_r = BLOCK;
let mut start_r = ptr::null_mut();
let mut end_r = ptr::null_mut();
let mut offsets_r: [MaybeUninit<u8>; BLOCK] = uninitialized_array![u8; BLOCK];
let mut offsets_r = [MaybeUninit::<u8>::uninit(); BLOCK];

// FIXME: When we get VLAs, try creating one array of length `min(v.len(), 2 * BLOCK)` rather
// than two fixed-size arrays of length `BLOCK`. VLAs might be more cache-efficient.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/def_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ impl CrateNum {
pub fn as_usize(self) -> usize {
match self {
CrateNum::Index(id) => id.as_usize(),
_ => bug!("tried to get index of nonstandard crate {:?}", self),
_ => bug!("tried to get index of non-standard crate {:?}", self),
}
}

pub fn as_u32(self) -> u32 {
match self {
CrateNum::Index(id) => id.as_u32(),
_ => bug!("tried to get index of nonstandard crate {:?}", self),
_ => bug!("tried to get index of non-standard crate {:?}", self),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,8 +1693,8 @@ impl<'a> LoweringContext<'a> {
if pos == ImplTraitPosition::Binding &&
nightly_options::is_nightly_build() {
help!(err,
"add #![feature(impl_trait_in_bindings)] to the crate attributes \
to enable");
"add `#![feature(impl_trait_in_bindings)]` to the crate \
attributes to enable");
}
err.emit();
hir::TyKind::Err
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/assert_dep_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_wou
for &(target_span, _, _, _) in then_this_would_need {
tcx.sess.span_err(
target_span,
"no #[rustc_if_this_changed] annotation detected");
"no `#[rustc_if_this_changed]` annotation detected");

}
return;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/persist/dirty_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ impl FindAllAttrs<'tcx> {
for attr in &self.found_attrs {
if !checked_attrs.contains(&attr.id) {
self.tcx.sess.span_err(attr.span, &format!("found unchecked \
#[rustc_dirty]/#[rustc_clean] attribute"));
`#[rustc_dirty]` / `#[rustc_clean]` attribute"));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_incremental/persist/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ fn find_source_directory_in_iter<I>(iter: I,
if source_directories_already_tried.contains(&session_dir) ||
!is_session_directory(&directory_name) ||
!is_finalized(&directory_name) {
debug!("find_source_directory_in_iter - ignoring.");
debug!("find_source_directory_in_iter - ignoring");
continue
}

Expand Down Expand Up @@ -693,7 +693,7 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> {
let timestamp = match extract_timestamp_from_session_dir(lock_file_name) {
Ok(timestamp) => timestamp,
Err(()) => {
debug!("Found lock-file with malformed timestamp: {}",
debug!("found lock-file with malformed timestamp: {}",
crate_directory.join(&lock_file_name).display());
// Ignore it
continue
Expand Down Expand Up @@ -746,7 +746,7 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> {
let timestamp = match extract_timestamp_from_session_dir(directory_name) {
Ok(timestamp) => timestamp,
Err(()) => {
debug!("Found session-dir with malformed timestamp: {}",
debug!("found session-dir with malformed timestamp: {}",
crate_directory.join(directory_name).display());
// Ignore it
continue
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
if !self.impling_types.as_ref().unwrap().contains(&item.hir_id) {
cx.span_lint(MISSING_DEBUG_IMPLEMENTATIONS,
item.span,
"type does not implement `fmt::Debug`; consider adding #[derive(Debug)] \
"type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` \
or a manual implementation")
}
}
Expand Down Expand Up @@ -867,7 +867,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
if attr::contains_name(&it.attrs, sym::no_mangle) {
// Const items do not refer to a particular location in memory, and therefore
// don't have anything to attach a symbol to
let msg = "const items should never be #[no_mangle]";
let msg = "const items should never be `#[no_mangle]`";
let mut err = cx.struct_span_lint(NO_MANGLE_CONST_ITEMS, it.span, msg);

// account for "pub const" (#45562)
Expand Down Expand Up @@ -1358,7 +1358,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
declare_lint! {
UNNAMEABLE_TEST_ITEMS,
Warn,
"detects an item that cannot be named being marked as #[test_case]",
"detects an item that cannot be named being marked as `#[test_case]`",
report_in_external_macro: true
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
store.register_removed("resolve_trait_on_defaulted_unit",
"converted into hard error, see https://github.com/rust-lang/rust/issues/48950");
store.register_removed("private_no_mangle_fns",
"no longer a warning, #[no_mangle] functions always exported");
"no longer a warning, `#[no_mangle]` functions always exported");
store.register_removed("private_no_mangle_statics",
"no longer a warning, #[no_mangle] statics always exported");
"no longer a warning, `#[no_mangle]` statics always exported");
store.register_removed("bad_repr",
"replaced with a generic attribute input check");
store.register_removed("duplicate_matcher_binding_name",
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use log::debug;
declare_lint! {
pub UNUSED_MUST_USE,
Warn,
"unused result of a type flagged as #[must_use]",
"unused result of a type flagged as `#[must_use]`",
report_in_external_macro: true
}

Expand Down Expand Up @@ -316,7 +316,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes {

let name = attr.name_or_empty();
if !attr::is_used(attr) {
debug!("Emitting warning for: {:?}", attr);
debug!("emitting warning for: {:?}", attr);
cx.span_lint(UNUSED_ATTRIBUTES, attr.span, "unused attribute");
// Is it a builtin attribute that must be used at the crate level?
let known_crate = attr_info.map(|&&(_, ty, ..)| {
Expand All @@ -332,7 +332,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes {
let msg = match attr.style {
ast::AttrStyle::Outer => {
"crate-level attribute should be an inner attribute: add an exclamation \
mark: #![foo]"
mark: `#![foo]`"
}
ast::AttrStyle::Inner => "crate-level attribute should be in the root module",
};
Expand Down Expand Up @@ -570,9 +570,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation {
if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(_, m)) = adj.kind {
let msg = match m {
adjustment::AutoBorrowMutability::Immutable =>
"unnecessary allocation, use & instead",
"unnecessary allocation, use `&` instead",
adjustment::AutoBorrowMutability::Mutable { .. }=>
"unnecessary allocation, use &mut instead"
"unnecessary allocation, use `&mut` instead"
};
cx.span_lint(UNUSED_ALLOCATION, e.span, msg);
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,14 +938,14 @@ impl<'a> CrateLoader<'a> {
}
match global_allocator {
Some(Some(other_crate)) => {
self.sess.err(&format!("the #[global_allocator] in {} \
self.sess.err(&format!("the `#[global_allocator]` in {} \
conflicts with this global \
allocator in: {}",
other_crate,
data.root.name));
}
Some(None) => {
self.sess.err(&format!("the #[global_allocator] in this \
self.sess.err(&format!("the `#[global_allocator]` in this \
crate conflicts with global \
allocator in: {}", data.root.name));
}
Expand All @@ -971,7 +971,7 @@ impl<'a> CrateLoader<'a> {
if !has_default {
self.sess.err("no global memory allocator found but one is \
required; link to std or \
add #[global_allocator] to a static item \
add `#[global_allocator]` to a static item \
that implements the GlobalAlloc trait.");
}
self.sess.allocator_kind.set(Some(AllocatorKind::DefaultLib));
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_metadata/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ E0454: r##"
A link name was given with an empty name. Erroneous code example:
```ignore (cannot-test-this-because-rustdoc-stops-compile-fail-before-codegen)
#[link(name = "")] extern {} // error: #[link(name = "")] given with empty name
#[link(name = "")] extern {}
// error: `#[link(name = "")]` given with empty name
```
The rust compiler cannot link to an external library if you don't give it its
Expand Down Expand Up @@ -61,7 +62,7 @@ A link was used without a name parameter. Erroneous code example:
```ignore (cannot-test-this-because-rustdoc-stops-compile-fail-before-codegen)
#[link(kind = "dylib")] extern {}
// error: #[link(...)] specified without `name = "foo"`
// error: `#[link(...)]` specified without `name = "foo"`
```
Please add the name parameter to allow the rust compiler to find the library
Expand Down
Loading

0 comments on commit e649e90

Please sign in to comment.