Skip to content

Commit

Permalink
Auto merge of #55859 - pietroalbini:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 17 pull requests

Successful merges:

 - #55630 (resolve: Filter away macro prelude in modules with `#[no_implicit_prelude]` on 2018 edition)
 - #55687 (Take supertraits into account when calculating associated types)
 - #55745 (Convert `outlives_components`' return value to a `SmallVec` outparam.)
 - #55764 (Fix Rc/Arc allocation layout)
 - #55792 (Prevent ICE in const-prop array oob check)
 - #55799 (Removed unneeded instance of `// revisions` from a lint test)
 - #55800 (Fix ICE in `return_type_impl_trait`)
 - #55801 (NLL: Update box insensitivity test)
 - #55802 (Don't inline virtual calls (take 2))
 - #55816 (Use `SmallVec` to avoid allocations in `from_decimal_string`.)
 - #55819 (Typecheck patterns of all match arms first, so we get types for bindings)
 - #55822 (ICE with #![feature(nll)] and elided lifetimes)
 - #55828 (Add missing `rustc_promotable` attribute to unsigned `min_value` and `max_value`)
 - #55839 (Fix docstring spelling mistakes)
 - #55844 (Fix documentation typos.)
 - #55845 (Set BINARYEN_TRAP_MODE=clamp)
 - #55856 (rustdoc: refactor: move all static-file include!s into a single module)
  • Loading branch information
bors committed Nov 11, 2018
2 parents 9b8f902 + 7031e4e commit b76ee83
Show file tree
Hide file tree
Showing 85 changed files with 1,117 additions and 666 deletions.
1 change: 1 addition & 0 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,7 @@ version = "0.0.0"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_cratesio_shim 0.0.0",
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand Down
6 changes: 4 additions & 2 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,14 +672,16 @@ impl<T: ?Sized> Rc<T> {
// Previously, layout was calculated on the expression
// `&*(ptr as *const RcBox<T>)`, but this created a misaligned
// reference (see #54908).
let (layout, _) = Layout::new::<RcBox<()>>()
.extend(Layout::for_value(&*ptr)).unwrap();
let layout = Layout::new::<RcBox<()>>()
.extend(Layout::for_value(&*ptr)).unwrap().0
.pad_to_align().unwrap();

let mem = Global.alloc(layout)
.unwrap_or_else(|_| handle_alloc_error(layout));

// Initialize the RcBox
let inner = set_data_ptr(ptr as *mut T, mem.as_ptr() as *mut u8) as *mut RcBox<T>;
debug_assert_eq!(Layout::for_value(&*inner), layout);

ptr::write(&mut (*inner).strong, Cell::new(1));
ptr::write(&mut (*inner).weak, Cell::new(1));
Expand Down
6 changes: 4 additions & 2 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,16 @@ impl<T: ?Sized> Arc<T> {
// Previously, layout was calculated on the expression
// `&*(ptr as *const ArcInner<T>)`, but this created a misaligned
// reference (see #54908).
let (layout, _) = Layout::new::<ArcInner<()>>()
.extend(Layout::for_value(&*ptr)).unwrap();
let layout = Layout::new::<ArcInner<()>>()
.extend(Layout::for_value(&*ptr)).unwrap().0
.pad_to_align().unwrap();

let mem = Global.alloc(layout)
.unwrap_or_else(|_| handle_alloc_error(layout));

// Initialize the ArcInner
let inner = set_data_ptr(ptr as *mut T, mem.as_ptr() as *mut u8) as *mut ArcInner<T>;
debug_assert_eq!(Layout::for_value(&*inner), layout);

ptr::write(&mut (*inner).strong, atomic::AtomicUsize::new(1));
ptr::write(&mut (*inner).weak, atomic::AtomicUsize::new(1));
Expand Down
21 changes: 19 additions & 2 deletions src/libcore/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,23 @@ impl Layout {
len_rounded_up.wrapping_sub(len)
}

/// Creates a layout by rounding the size of this layout up to a multiple
/// of the layout's alignment.
///
/// Returns `Err` if the padded size would overflow.
///
/// This is equivalent to adding the result of `padding_needed_for`
/// to the layout's current size.
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
#[inline]
pub fn pad_to_align(&self) -> Result<Layout, LayoutErr> {
let pad = self.padding_needed_for(self.align());
let new_size = self.size().checked_add(pad)
.ok_or(LayoutErr { private: () })?;

Layout::from_size_align(new_size, self.align())
}

/// Creates a layout describing the record for `n` instances of
/// `self`, with a suitable amount of padding between each to
/// ensure that each instance is given its requested size and
Expand Down Expand Up @@ -506,7 +523,7 @@ pub unsafe trait GlobalAlloc {
ptr
}

/// Shink or grow a block of memory to the given `new_size`.
/// Shrink or grow a block of memory to the given `new_size`.
/// The block is described by the given `ptr` pointer and `layout`.
///
/// If this returns a non-null pointer, then ownership of the memory block
Expand Down Expand Up @@ -757,7 +774,7 @@ pub unsafe trait Alloc {
// realloc. alloc_excess, realloc_excess

/// Returns a pointer suitable for holding data described by
/// a new layout with `layout`’s alginment and a size given
/// a new layout with `layout`’s alignment and a size given
/// by `new_size`. To
/// accomplish this, this may extend or shrink the allocation
/// referenced by `ptr` to fit the new layout.
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use ops;
use pin::Pin;
use task::{Poll, LocalWaker};

/// A future represents an asychronous computation.
/// A future represents an asynchronous computation.
///
/// A future is a value that may not have finished computing yet. This kind of
/// "asynchronous value" makes it possible for a thread to continue doing useful
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ mod nonzero;
mod tuple;
mod unit;

// Pull in the the `coresimd` crate directly into libcore. This is where all the
// Pull in the `coresimd` crate directly into libcore. This is where all the
// architecture-specific (and vendor-specific) intrinsics are defined. AKA
// things like SIMD and such. Note that the actual source for all this lies in a
// different repository, rust-lang-nursery/stdsimd. That's why the setup here is
Expand Down
7 changes: 3 additions & 4 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,8 @@ macro_rules! try {
/// assert_eq!(v, b"s = \"abc 123\"");
/// ```
///
/// Note: This macro can be used in `no_std` setups as well
/// In a `no_std` setup you are responsible for the
/// implementation details of the components.
/// Note: This macro can be used in `no_std` setups as well.
/// In a `no_std` setup you are responsible for the implementation details of the components.
///
/// ```no_run
/// # extern crate core;
Expand Down Expand Up @@ -440,7 +439,7 @@ macro_rules! writeln {
///
/// If the determination that the code is unreachable proves incorrect, the
/// program immediately terminates with a [`panic!`]. The function [`unreachable_unchecked`],
/// which belongs to the [`std::hint`] module, informs the compilier to
/// which belongs to the [`std::hint`] module, informs the compiler to
/// optimize the code out of the release version entirely.
///
/// [`panic!`]: ../std/macro.panic.html
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub fn forget<T>(t: T) {
///
/// ## Size of Enums
///
/// Enums that carry no data other than the descriminant have the same size as C enums
/// Enums that carry no data other than the discriminant have the same size as C enums
/// on the platform they are compiled for.
///
/// ## Size of Unions
Expand Down Expand Up @@ -1081,7 +1081,7 @@ impl<T> MaybeUninit<T> {
///
/// # Unsafety
///
/// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
/// state, otherwise this will immediately cause undefined behavior.
#[unstable(feature = "maybe_uninit", issue = "53491")]
pub unsafe fn into_inner(self) -> T {
Expand All @@ -1092,7 +1092,7 @@ impl<T> MaybeUninit<T> {
///
/// # Unsafety
///
/// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
/// state, otherwise this will immediately cause undefined behavior.
#[unstable(feature = "maybe_uninit", issue = "53491")]
pub unsafe fn get_ref(&self) -> &T {
Expand All @@ -1103,7 +1103,7 @@ impl<T> MaybeUninit<T> {
///
/// # Unsafety
///
/// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
/// state, otherwise this will immediately cause undefined behavior.
#[unstable(feature = "maybe_uninit", issue = "53491")]
pub unsafe fn get_mut(&mut self) -> &mut T {
Expand Down
2 changes: 2 additions & 0 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,7 @@ Basic usage:
", $Feature, "assert_eq!(", stringify!($SelfT), "::min_value(), 0);", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_promotable]
#[inline]
pub const fn min_value() -> Self { 0 }
}
Expand All @@ -2168,6 +2169,7 @@ Basic usage:
stringify!($MaxV), ");", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_promotable]
#[inline]
pub const fn max_value() -> Self { !0 }
}
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! It is sometimes useful to have objects that are guaranteed to not move,
//! in the sense that their placement in memory does not change, and can thus be relied upon.
//!
//! A prime example of such a scenario would be building self-referencial structs,
//! A prime example of such a scenario would be building self-referential structs,
//! since moving an object with pointers to itself will invalidate them,
//! which could cause undefined behavior.
//!
Expand Down Expand Up @@ -39,7 +39,7 @@
//! use std::marker::Pinned;
//! use std::ptr::NonNull;
//!
//! // This is a self referencial struct since the slice field points to the data field.
//! // This is a self-referential struct since the slice field points to the data field.
//! // We cannot inform the compiler about that with a normal reference,
//! // since this pattern cannot be described with the usual borrowing rules.
//! // Instead we use a raw pointer, though one which is known to not be null,
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub use intrinsics::write_bytes;
///
/// Additionally, if `T` is not [`Copy`], using the pointed-to value after
/// calling `drop_in_place` can cause undefined behavior. Note that `*to_drop =
/// foo` counts as a use because it will cause the the value to be dropped
/// foo` counts as a use because it will cause the value to be dropped
/// again. [`write`] can be used to overwrite data without causing it to be
/// dropped.
///
Expand Down Expand Up @@ -371,7 +371,7 @@ pub(crate) unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
#[inline]
unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
// The approach here is to utilize simd to swap x & y efficiently. Testing reveals
// that swapping either 32 bytes or 64 bytes at a time is most efficient for intel
// that swapping either 32 bytes or 64 bytes at a time is most efficient for Intel
// Haswell E processors. LLVM is more able to optimize if we give a struct a
// #[repr(simd)], even if we don't actually use this struct directly.
//
Expand Down Expand Up @@ -1005,7 +1005,7 @@ impl<T: ?Sized> *const T {
/// # Null-unchecked version
///
/// If you are sure the pointer can never be null and are looking for some kind of
/// `as_ref_unchecked` that returns the `&T` instead of `Option<&T>, know that you can
/// `as_ref_unchecked` that returns the `&T` instead of `Option<&T>`, know that you can
/// dereference the pointer directly.
///
/// ```
Expand Down Expand Up @@ -1625,7 +1625,7 @@ impl<T: ?Sized> *mut T {
/// # Null-unchecked version
///
/// If you are sure the pointer can never be null and are looking for some kind of
/// `as_ref_unchecked` that returns the `&T` instead of `Option<&T>, know that you can
/// `as_ref_unchecked` that returns the `&T` instead of `Option<&T>`, know that you can
/// dereference the pointer directly.
///
/// ```
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ static X: u32 = 42;


register_diagnostics! {
// E0006 // merged with E0005
// E0006, // merged with E0005
// E0101, // replaced with E0282
// E0102, // replaced with E0282
// E0134,
Expand Down Expand Up @@ -2183,9 +2183,7 @@ register_diagnostics! {
E0657, // `impl Trait` can only capture lifetimes bound at the fn level
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders

E0697, // closures cannot be static

E0707, // multiple elided lifetimes used in arguments of `async fn`
E0708, // `async` non-`move` closures with arguments are not currently supported
E0709, // multiple different lifetimes used in arguments of `async fn`
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,9 @@ pub enum TraitBoundModifier {
}

/// The AST represents all type param bounds as types.
/// typeck::collect::compute_bounds matches these against
/// the "special" built-in traits (see middle::lang_items) and
/// detects Copy, Send and Sync.
/// `typeck::collect::compute_bounds` matches these against
/// the "special" built-in traits (see `middle::lang_items`) and
/// detects `Copy`, `Send` and `Sync`.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum GenericBound {
Trait(PolyTraitRef, TraitBoundModifier),
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let mut types = vec![concrete_ty];
let bound_region = |r| self.sub_regions(infer::CallReturn(span), least_region, r);
while let Some(ty) = types.pop() {
let mut components = self.tcx.outlives_components(ty);
let mut components = smallvec![];
self.tcx.push_outlives_components(ty, &mut components);
while let Some(component) = components.pop() {
match component {
Component::Region(r) => {
Expand Down
17 changes: 9 additions & 8 deletions src/librustc/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

//! Code that handles "type-outlives" constraints like `T: 'a`. This
//! is based on the `outlives_components` function defined on the tcx,
//! is based on the `push_outlives_components` function defined on the tcx,
//! but it adds a bit of heuristics on top, in particular to deal with
//! associated types and projections.
//!
Expand Down Expand Up @@ -307,31 +307,32 @@ where

assert!(!ty.has_escaping_bound_vars());

let components = self.tcx.outlives_components(ty);
self.components_must_outlive(origin, components, region);
let mut components = smallvec![];
self.tcx.push_outlives_components(ty, &mut components);
self.components_must_outlive(origin, &components, region);
}

fn components_must_outlive(
&mut self,
origin: infer::SubregionOrigin<'tcx>,
components: Vec<Component<'tcx>>,
components: &[Component<'tcx>],
region: ty::Region<'tcx>,
) {
for component in components {
for component in components.iter() {
let origin = origin.clone();
match component {
Component::Region(region1) => {
self.delegate
.push_sub_region_constraint(origin, region, region1);
}
Component::Param(param_ty) => {
self.param_ty_must_outlive(origin, region, param_ty);
self.param_ty_must_outlive(origin, region, *param_ty);
}
Component::Projection(projection_ty) => {
self.projection_must_outlive(origin, region, projection_ty);
self.projection_must_outlive(origin, region, *projection_ty);
}
Component::EscapingProjection(subcomponents) => {
self.components_must_outlive(origin, subcomponents, region);
self.components_must_outlive(origin, &subcomponents, region);
}
Component::UnresolvedInferenceVariable(v) => {
// ignore this, we presume it will yield an error
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
.map(|subty| self.type_bound(subty))
.collect::<Vec<_>>();

let mut regions = ty.regions();
let mut regions = smallvec![];
ty.push_regions(&mut regions);
regions.retain(|r| !r.is_late_bound()); // ignore late-bound regions
bounds.push(VerifyBound::AllBounds(
regions
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 @@ -300,12 +300,6 @@ declare_lint! {
"detects labels that are never used"
}

declare_lint! {
pub DUPLICATE_ASSOCIATED_TYPE_BINDINGS,
Warn,
"warns about duplicate associated type bindings in generics"
}

declare_lint! {
pub DUPLICATE_MACRO_EXPORTS,
Deny,
Expand Down Expand Up @@ -418,7 +412,6 @@ impl LintPass for HardwiredLints {
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
UNSTABLE_NAME_COLLISIONS,
IRREFUTABLE_LET_PATTERNS,
DUPLICATE_ASSOCIATED_TYPE_BINDINGS,
DUPLICATE_MACRO_EXPORTS,
INTRA_DOC_LINK_RESOLUTION_FAILURE,
MISSING_DOC_CODE_EXAMPLES,
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,10 @@ impl Session {
self.opts.debugging_opts.teach && self.diagnostic().must_teach(code)
}

pub fn rust_2015(&self) -> bool {
self.opts.edition == Edition::Edition2015
}

/// Are we allowed to use features from the Rust 2018 edition?
pub fn rust_2018(&self) -> bool {
self.opts.edition >= Edition::Edition2018
Expand Down
7 changes: 2 additions & 5 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ pub use self::select::{EvaluationResult, IntercrateAmbiguityCause, OverflowError
pub use self::specialize::{OverlapError, specialization_graph, translate_substs};
pub use self::specialize::find_associated_item;
pub use self::engine::{TraitEngine, TraitEngineExt};
pub use self::util::elaborate_predicates;
pub use self::util::supertraits;
pub use self::util::Supertraits;
pub use self::util::supertrait_def_ids;
pub use self::util::SupertraitDefIds;
pub use self::util::{elaborate_predicates, elaborate_trait_ref, elaborate_trait_refs};
pub use self::util::{supertraits, supertrait_def_ids, Supertraits, SupertraitDefIds};
pub use self::util::transitive_bounds;

#[allow(dead_code)]
Expand Down
Loading

0 comments on commit b76ee83

Please sign in to comment.