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 17 pull requests #55859

Merged
merged 43 commits into from
Nov 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9ed9d6d
resolve: Filter away macro prelude in modules with `#[no_implicit_pre…
petrochenkov Nov 2, 2018
d08a42b
Look at projections from supertraits when constructing trait objects.
alexreg Nov 1, 2018
0e89f57
Added tests.
alexreg Nov 4, 2018
6d3ee41
Added error for duplicate bindings of associated type.
alexreg Nov 5, 2018
7d9ee03
Only do check for trait objects, not trait or trait alias definitions.
alexreg Nov 6, 2018
90a1438
Removed `DUPLICATE_ASSOCIATED_TYPE_BINDINGS` lint.
alexreg Nov 7, 2018
5b2314b
Use `SmallVec` outparams in several functions.
nnethercote Nov 1, 2018
317f494
Fix Rc/Arc allocation layout
murarth Nov 7, 2018
df10965
Prevent ICE in const-prop array oob check
oli-obk Nov 8, 2018
ffa7ce4
Add more regression tests
oli-obk Nov 8, 2018
918f70f
Removed an unneeded instance of `// revisions`; the compare-mode NLL …
pnkfelix Nov 8, 2018
92ef0c4
Make test robust to NLL, in sense of ensuring borrows extend to somet…
pnkfelix Nov 8, 2018
24289a0
Sidestep ICE in `type_of_def_id()` when called from `return_type_impl…
estebank Nov 8, 2018
d0151ca
Switch to using `// revisions` to explicit encode NLL's change to `Bo…
pnkfelix Nov 8, 2018
9b6a568
Fix the expected error annotations.
pnkfelix Nov 8, 2018
a66d7b2
Use `SmallVec` to avoid allocations in `from_decimal_string`.
nnethercote Nov 9, 2018
1206549
Fix tidy
oli-obk Nov 9, 2018
5f91373
Typecheck patterns of all match arms first, so we get types for bindi…
pnkfelix Nov 9, 2018
e6a466e
Fix ICE and find correct return span.
davidtwco Nov 9, 2018
f4c9dd5
Add missing `rustc_promotable` attribute to unsigned `min_value` and …
oli-obk Nov 9, 2018
a90240d
Simplify logic
estebank Nov 9, 2018
3cce5c7
Don't inline virtual calls (take 2)
wesleywiser Nov 7, 2018
38d2f9b
Fix docstring spelling mistakes
dralley Nov 10, 2018
9b4d68e
Fix documentation typos.
waywardmonkeys Nov 10, 2018
48aa602
Set BINARYEN_TRAP_MODE=clamp
nikic Nov 10, 2018
2f8ce73
move all static-file include!s into a single module
QuietMisdreavus Nov 10, 2018
0e912b2
Rollup merge of #55687 - alexreg:fix-24010, r=scalexm
pietroalbini Nov 10, 2018
f0a6e3a
Rollup merge of #55745 - nnethercote:outlives_components-SmallVec, r=…
pietroalbini Nov 10, 2018
d2aeef0
Rollup merge of #55764 - murarth:fix-rc-alloc, r=RalfJung
pietroalbini Nov 10, 2018
e121305
Rollup merge of #55792 - oli-obk:propsicle, r=RalfJung
pietroalbini Nov 10, 2018
8c4bfb8
Rollup merge of #55799 - pnkfelix:remove-useless-revisions-marker-fro…
pietroalbini Nov 10, 2018
ff8ee96
Rollup merge of #55800 - estebank:abolish-ice-for-lifetime, r=oli-obk
pietroalbini Nov 10, 2018
18195d4
Rollup merge of #55801 - pnkfelix:update-box-insensitivity-test-for-n…
pietroalbini Nov 10, 2018
5b0b0ce
Rollup merge of #55802 - wesleywiser:inlined_calls_2_electric_boogalo…
pietroalbini Nov 10, 2018
e8a3934
Rollup merge of #55816 - nnethercote:from_decimal_string-SmallVec, r=…
pietroalbini Nov 10, 2018
c4ca49a
Rollup merge of #55819 - pnkfelix:issue-55810-must-typeck-pats-eagerl…
pietroalbini Nov 10, 2018
4c50964
Rollup merge of #55822 - davidtwco:issue-55394, r=pnkfelix
pietroalbini Nov 10, 2018
0f1c1eb
Rollup merge of #55828 - oli-obk:promotion_strikes_again, r=eddyb
pietroalbini Nov 10, 2018
417b10a
Rollup merge of #55839 - dralley:docstring-spelling, r=TimNN
pietroalbini Nov 10, 2018
17ae507
Rollup merge of #55844 - waywardmonkeys:typo-fixes, r=varkor
pietroalbini Nov 10, 2018
75e920f
Rollup merge of #55630 - petrochenkov:noprelude, r=Centril
kennytm Nov 11, 2018
d0b68c0
Rollup merge of #55845 - nikic:emscripten-clamp-mode, r=alexcrichton
kennytm Nov 11, 2018
7031e4e
Rollup merge of #55856 - QuietMisdreavus:static-discharge, r=Guillaum…
kennytm Nov 11, 2018
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
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:/rust-lang/crates.io-index)",
"rustc_cratesio_shim 0.0.0",
"smallvec 0.6.5 (registry+https:/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