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 16 pull requests #59941

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
968ea1c
Mark variables captured by reference as mutable correctly
matthewjasper Apr 4, 2019
63080b3
remove lookup_char_pos_adj
matklad Apr 5, 2019
1c3979c
Add book.toml to tools/unstable, add copy_book_toml to scipt
Apr 6, 2019
5ddb339
Remove copy_book_toml method in favor for copy_recursive
Apr 6, 2019
280277a
path -> from
Apr 6, 2019
34c1572
Change root path for unstable-book
Apr 7, 2019
b8e9da7
`asm!` output can neither be promotable nor const
oli-obk Apr 8, 2019
6b01844
Generalize initial "not const" assignments
oli-obk Apr 8, 2019
ec52065
Explicit promotion is indistinguishable from explicit promotion
oli-obk Apr 8, 2019
d3d5673
Get rid of "is not const" naming
oli-obk Apr 8, 2019
c63b9ff
Pacify tidy
oli-obk Apr 8, 2019
ae4717d
Elaborate on implicit promotability
oli-obk Apr 8, 2019
1ad46cd
Fix links on keyword docs.
ehuss Apr 9, 2019
6635fbe
Eliminate `FnBox` usages from libstd.
crlf0710 Apr 9, 2019
2f97552
Re-export NonZero signed variant in std
tesuji Apr 10, 2019
404df31
Update ui test
tesuji Apr 10, 2019
f10394a
Documentation should have proper grammar
oli-obk Apr 10, 2019
acf3ddb
std: Add `{read,write}_vectored` for more types
alexcrichton Apr 10, 2019
825a11e
Fix attributes position in type declaration
GuillaumeGomez Apr 10, 2019
d7f5c50
make duplicate matcher bindings a hard error
mark-i-m Mar 28, 2019
6fd3f5a
forgot one
mark-i-m Apr 11, 2019
22f2afe
Use SecRandomCopyBytes instead of /dev/urandom on MacOS
ebarnard Apr 11, 2019
e149dc0
remove warn
mark-i-m Apr 11, 2019
ca1ab3e
In `-Zprint-type-size` output, sort enum variants by size.
nnethercote Apr 12, 2019
1ce6645
MaybeUninit: remove deprecated functions
RalfJung Apr 12, 2019
fc928a1
Stabilize the `alloc` crate.
SimonSapin Apr 3, 2019
b27bcc0
Fix paste error in split_ascii_whitespace docs.
solson Apr 12, 2019
0a9b214
Exclude some copies of old book editions from search engines
kornelski Apr 12, 2019
b5f537c
Rollup merge of #59675 - SimonSapin:stable-alloc, r=alexcrichton
Centril Apr 13, 2019
433e151
Rollup merge of #59708 - matthewjasper:double-closure-unused-mut, r=p…
Centril Apr 13, 2019
6619f3a
Rollup merge of #59735 - matklad:deadcode, r=sanxiyn
Centril Apr 13, 2019
8ac023f
Rollup merge of #59747 - gruberb:copy-book-toml-unstable-book, r=ehuss
Centril Apr 13, 2019
2fbd7be
Rollup merge of #59796 - oli-obk:const_arg_ice, r=eddyb
Centril Apr 13, 2019
70b22be
Rollup merge of #59818 - crlf0710:eliminate_libstd_fnbox, r=cramertj
Centril Apr 13, 2019
3ec6a1f
Rollup merge of #59830 - ehuss:keyword-links, r=Mark-Simulacrum
Centril Apr 13, 2019
92be8d0
Rollup merge of #59835 - lzutao:nonzero-signed, r=Mark-Simulacrum
Centril Apr 13, 2019
cd62fbd
Rollup merge of #59852 - alexcrichton:more-vectored, r=sfackler
Centril Apr 13, 2019
5bf57e6
Rollup merge of #59855 - GuillaumeGomez:fix-attr-position-in-type-dec…
Centril Apr 13, 2019
c4274c6
Rollup merge of #59858 - mark-i-m:dup-matcher-bindings-3, r=Centril
Centril Apr 13, 2019
0f8eace
Rollup merge of #59879 - ebarnard:patch-1, r=alexcrichton
Centril Apr 13, 2019
64f8018
Rollup merge of #59899 - nnethercote:sort-enum-variants-by-size, r=pn…
Centril Apr 13, 2019
f1ee785
Rollup merge of #59912 - RalfJung:maybe-uninit, r=Centril
Centril Apr 13, 2019
b211523
Rollup merge of #59925 - solson:split_ascii_whitespace-docfix, r=Centril
Centril Apr 13, 2019
db9dd4e
Rollup merge of #59930 - kornelski:first-robots, r=GuillaumeGomez
Centril Apr 13, 2019
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
8 changes: 8 additions & 0 deletions src/doc/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ Disallow: /1.0.0-beta.2/
Disallow: /1.0.0-beta.3/
Disallow: /1.0.0-beta.4/
Disallow: /1.0.0-beta.5/
Disallow: /book/first-edition/
Disallow: /book/second-edition/
Disallow: /stable/book/first-edition/
Disallow: /stable/book/second-edition/
Disallow: /beta/book/first-edition/
Disallow: /beta/book/second-edition/
Disallow: /nightly/book/first-edition/
Disallow: /nightly/book/second-edition/
1 change: 1 addition & 0 deletions src/doc/unstable-book/book.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[book]
title = "The Rust Unstable Book"
author = "The Rust Community"
5 changes: 1 addition & 4 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
//! default global allocator. It is not compatible with the libc allocator API.

#![allow(unused_attributes)]
#![unstable(feature = "alloc",
reason = "this library is unlikely to be stabilized in its current \
form or name",
issue = "27783")]
#![stable(feature = "alloc", since = "1.36.0")]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/prelude/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//!
//! ```
//! # #![allow(unused_imports)]
//! # #![feature(alloc)]
//! #![feature(alloc_prelude)]
//! extern crate alloc;
//! use alloc::prelude::v1::*;
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl<T, A: Alloc> RawVec<T, A> {
/// # Examples
///
/// ```
/// # #![feature(alloc, raw_vec_internals)]
/// # #![feature(raw_vec_internals)]
/// # extern crate alloc;
/// # use std::ptr;
/// # use alloc::raw_vec::RawVec;
Expand Down Expand Up @@ -460,7 +460,7 @@ impl<T, A: Alloc> RawVec<T, A> {
/// # Examples
///
/// ```
/// # #![feature(alloc, raw_vec_internals)]
/// # #![feature(raw_vec_internals)]
/// # extern crate alloc;
/// # use std::ptr;
/// # use alloc::raw_vec::RawVec;
Expand Down
1 change: 0 additions & 1 deletion src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#![deny(rust_2018_idioms)]
#![cfg_attr(not(stage0), deny(internal))]

#![feature(alloc)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![feature(raw_vec_internals)]
Expand Down
34 changes: 0 additions & 34 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,15 +1152,6 @@ impl<T> MaybeUninit<T> {
MaybeUninit { uninit: () }
}

/// Deprecated before stabilization.
#[unstable(feature = "maybe_uninit", issue = "53491")]
#[inline(always)]
// FIXME: still used by stdsimd
// #[rustc_deprecated(since = "1.35.0", reason = "use `uninit` instead")]
pub const fn uninitialized() -> MaybeUninit<T> {
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 Expand Up @@ -1221,14 +1212,6 @@ impl<T> MaybeUninit<T> {
}
}

/// Deprecated before stabilization.
#[unstable(feature = "maybe_uninit", issue = "53491")]
#[inline(always)]
#[rustc_deprecated(since = "1.35.0", reason = "use `write` instead")]
pub fn set(&mut self, val: T) -> &mut T {
self.write(val)
}

/// Gets a pointer to the contained value. Reading from this pointer or turning it
/// into a reference is undefined behavior unless the `MaybeUninit<T>` is initialized.
///
Expand Down Expand Up @@ -1346,15 +1329,6 @@ impl<T> MaybeUninit<T> {
ManuallyDrop::into_inner(self.value)
}

/// Deprecated before stabilization.
#[unstable(feature = "maybe_uninit", issue = "53491")]
#[inline(always)]
// FIXME: still used by stdsimd
// #[rustc_deprecated(since = "1.35.0", reason = "use `assume_init` instead")]
pub unsafe fn into_initialized(self) -> T {
self.assume_init()
}

/// Reads the value from the `MaybeUninit<T>` container. The resulting `T` is subject
/// to the usual drop handling.
///
Expand Down Expand Up @@ -1417,14 +1391,6 @@ impl<T> MaybeUninit<T> {
self.as_ptr().read()
}

/// Deprecated before stabilization.
#[unstable(feature = "maybe_uninit", issue = "53491")]
#[inline(always)]
#[rustc_deprecated(since = "1.35.0", reason = "use `read` instead")]
pub unsafe fn read_initialized(&self) -> T {
self.read()
}

/// Gets a reference to the contained value.
///
/// # Safety
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ impl str {
/// All kinds of ASCII whitespace are considered:
///
/// ```
/// let mut iter = " Mary had\ta little \n\t lamb".split_whitespace();
/// let mut iter = " Mary had\ta little \n\t lamb".split_ascii_whitespace();
/// assert_eq!(Some("Mary"), iter.next());
/// assert_eq!(Some("had"), iter.next());
/// assert_eq!(Some("a"), iter.next());
Expand Down
2 changes: 0 additions & 2 deletions src/libpanic_unwind/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#![deny(rust_2018_idioms)]

#![feature(allocator_api)]
#![feature(alloc)]
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![feature(libc)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}

fn explain_span(self, heading: &str, span: Span) -> (String, Option<Span>) {
let lo = self.sess.source_map().lookup_char_pos_adj(span.lo());
let lo = self.sess.source_map().lookup_char_pos(span.lo());
(
format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize() + 1),
Some(span),
Expand Down
7 changes: 0 additions & 7 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,6 @@ declare_lint! {
"outlives requirements can be inferred"
}

declare_lint! {
pub DUPLICATE_MATCHER_BINDING_NAME,
Deny,
"duplicate macro matcher binding name"
}

/// Some lints that are buffered from `libsyntax`. See `syntax::early_buffered_lints`.
pub mod parser {
declare_lint! {
Expand Down Expand Up @@ -462,7 +456,6 @@ declare_lint_pass! {
DEPRECATED_IN_FUTURE,
AMBIGUOUS_ASSOCIATED_ITEMS,
NESTED_IMPL_TRAIT,
DUPLICATE_MATCHER_BINDING_NAME,
MUTABLE_BORROW_RESERVATION_CONFLICT,
]
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use rustc_data_structures::sync::{self, Lrc};
use crate::hir::def_id::{CrateNum, LOCAL_CRATE};
use crate::hir::intravisit;
use crate::hir;
use crate::lint::builtin::{BuiltinLintDiagnostics, DUPLICATE_MATCHER_BINDING_NAME};
use crate::lint::builtin::BuiltinLintDiagnostics;
use crate::lint::builtin::parser::{QUESTION_MARK_MACRO_SEP, ILL_FORMED_ATTRIBUTE_INPUT};
use crate::session::{Session, DiagnosticMessageId};
use crate::ty::TyCtxt;
Expand Down Expand Up @@ -82,7 +82,6 @@ impl Lint {
match lint_id {
BufferedEarlyLintId::QuestionMarkMacroSep => QUESTION_MARK_MACRO_SEP,
BufferedEarlyLintId::IllFormedAttributeInput => ILL_FORMED_ATTRIBUTE_INPUT,
BufferedEarlyLintId::DuplicateMacroMatcherBindingName => DUPLICATE_MATCHER_BINDING_NAME,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
write!(f, "inside call to `{}`", self.instance)?;
}
if !self.call_site.is_dummy() {
let lo = tcx.sess.source_map().lookup_char_pos_adj(self.call_site.lo());
write!(f, " at {}:{}:{}", lo.filename, lo.line, lo.col.to_usize() + 1)?;
let lo = tcx.sess.source_map().lookup_char_pos(self.call_site.lo());
write!(f, " at {}:{}:{}", lo.file.name, lo.line, lo.col.to_usize() + 1)?;
}
Ok(())
})
Expand Down
8 changes: 7 additions & 1 deletion src/librustc/session/code_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ impl CodeStats {
overall_size: Size,
packed: bool,
opt_discr_size: Option<Size>,
variants: Vec<VariantInfo>) {
mut variants: Vec<VariantInfo>) {
// Sort variants so the largest ones are shown first. A stable sort is
// used here so that source code order is preserved for all variants
// that have the same size.
variants.sort_by(|info1, info2| {
info2.size.cmp(&info1.size)
});
let info = TypeSizeInfo {
kind,
type_description: type_desc.to_string(),
Expand Down
7 changes: 2 additions & 5 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(DUPLICATE_MATCHER_BINDING_NAME),
reference: "issue #57593 <https://github.com/rust-lang/rust/issues/57593>",
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(NESTED_IMPL_TRAIT),
reference: "issue #59014 <https://github.com/rust-lang/rust/issues/59014>",
Expand Down Expand Up @@ -494,6 +489,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
"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",
"converted into hard error, see https://github.com/rust-lang/rust/issues/57742");
}

pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) {
Expand Down
96 changes: 76 additions & 20 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use std::rc::Rc;
use syntax_pos::{Span, DUMMY_SP};

use crate::dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex};
use crate::dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError};
use crate::dataflow::move_paths::{HasMoveData, InitLocation, LookupResult, MoveData, MoveError};
use crate::dataflow::Borrows;
use crate::dataflow::DataflowResultsConsumer;
use crate::dataflow::FlowAtLocation;
Expand Down Expand Up @@ -1277,25 +1277,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
} = self.infcx.tcx.mir_borrowck(def_id);
debug!("{:?} used_mut_upvars={:?}", def_id, used_mut_upvars);
for field in used_mut_upvars {
// This relies on the current way that by-value
// captures of a closure are copied/moved directly
// when generating MIR.
match operands[field.index()] {
Operand::Move(Place::Base(PlaceBase::Local(local)))
| Operand::Copy(Place::Base(PlaceBase::Local(local))) => {
self.used_mut.insert(local);
}
Operand::Move(ref place @ Place::Projection(_))
| Operand::Copy(ref place @ Place::Projection(_)) => {
if let Some(field) = place.is_upvar_field_projection(
self.mir, &self.infcx.tcx) {
self.used_mut_upvars.push(field);
}
}
Operand::Move(Place::Base(PlaceBase::Static(..)))
| Operand::Copy(Place::Base(PlaceBase::Static(..)))
| Operand::Constant(..) => {}
}
self.propagate_closure_used_mut_upvar(&operands[field.index()]);
}
}
AggregateKind::Adt(..)
Expand All @@ -1310,6 +1292,80 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
}
}

fn propagate_closure_used_mut_upvar(&mut self, operand: &Operand<'tcx>) {
let propagate_closure_used_mut_place = |this: &mut Self, place: &Place<'tcx>| {
match *place {
Place::Projection { .. } => {
if let Some(field) = place.is_upvar_field_projection(
this.mir, &this.infcx.tcx) {
this.used_mut_upvars.push(field);
}
}
Place::Base(PlaceBase::Local(local)) => {
this.used_mut.insert(local);
}
Place::Base(PlaceBase::Static(_)) => {}
}
};

// This relies on the current way that by-value
// captures of a closure are copied/moved directly
// when generating MIR.
match *operand {
Operand::Move(Place::Base(PlaceBase::Local(local)))
| Operand::Copy(Place::Base(PlaceBase::Local(local)))
if self.mir.local_decls[local].is_user_variable.is_none() =>
{
if self.mir.local_decls[local].ty.is_mutable_pointer() {
// The variable will be marked as mutable by the borrow.
return;
}
// This is an edge case where we have a `move` closure
// inside a non-move closure, and the inner closure
// contains a mutation:
//
// let mut i = 0;
// || { move || { i += 1; }; };
//
// In this case our usual strategy of assuming that the
// variable will be captured by mutable reference is
// wrong, since `i` can be copied into the inner
// closure from a shared reference.
//
// As such we have to search for the local that this
// capture comes from and mark it as being used as mut.

let temp_mpi = self.move_data.rev_lookup.find_local(local);
let init = if let [init_index] = *self.move_data.init_path_map[temp_mpi] {
&self.move_data.inits[init_index]
} else {
bug!("temporary should be initialized exactly once")
};

let loc = match init.location {
InitLocation::Statement(stmt) => stmt,
_ => bug!("temporary initialized in arguments"),
};

let bbd = &self.mir[loc.block];
let stmt = &bbd.statements[loc.statement_index];
debug!("temporary assigned in: stmt={:?}", stmt);

if let StatementKind::Assign(_, box Rvalue::Ref(_, _, ref source)) = stmt.kind {
propagate_closure_used_mut_place(self, source);
} else {
bug!("closures should only capture user variables \
or references to user variables");
}
}
Operand::Move(ref place)
| Operand::Copy(ref place) => {
propagate_closure_used_mut_place(self, place);
}
Operand::Constant(..) => {}
}
}

fn consume_operand(
&mut self,
context: Context,
Expand Down
16 changes: 10 additions & 6 deletions src/librustc_mir/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ pub enum TempState {
impl TempState {
pub fn is_promotable(&self) -> bool {
debug!("is_promotable: self={:?}", self);
if let TempState::Defined { uses, .. } = *self {
uses > 0
if let TempState::Defined { .. } = *self {
true
} else {
false
}
Expand Down Expand Up @@ -80,9 +80,14 @@ impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> {
context: PlaceContext<'tcx>,
location: Location) {
debug!("visit_local: index={:?} context={:?} location={:?}", index, context, location);
// We're only interested in temporaries
if self.mir.local_kind(index) != LocalKind::Temp {
return;
// We're only interested in temporaries and the return place
match self.mir.local_kind(index) {
| LocalKind::Temp
| LocalKind::ReturnPointer
=> {},
| LocalKind::Arg
| LocalKind::Var
=> return,
}

// Ignore drops, if the temp gets promoted,
Expand All @@ -101,7 +106,6 @@ impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> {
if *temp == TempState::Undefined {
match context {
PlaceContext::MutatingUse(MutatingUseContext::Store) |
PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) |
PlaceContext::MutatingUse(MutatingUseContext::Call) => {
*temp = TempState::Defined {
location,
Expand Down
Loading