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 #64456

Merged
merged 50 commits into from
Sep 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
33788c2
Added table containing the system calls used by Instant and SystemTime.
Aug 24, 2019
1478ef4
Update src/libstd/time.rs
DevQps Aug 26, 2019
ff63bf8
Fix minor typo in docs.
goddessfreya Sep 3, 2019
7589d3a
Update other doc.
goddessfreya Sep 3, 2019
b0006df
A few cosmetic improvements to code & comments in liballoc and libcore
alexreg Sep 5, 2019
36b37e2
Remove two unnecessary `clone()` calls.
nnethercote Sep 8, 2019
c1b9a46
Add some assertions on obligation type sizes.
nnethercote Sep 9, 2019
b972ac8
Shrink `ObligationCauseCode` by boxing `MatchExpressionArm`.
nnethercote Sep 6, 2019
2e3b079
Shrink `ObligationCauseCode` by boxing `IfExpression`.
nnethercote Sep 9, 2019
3dd0e2b
Added some context on SGX. Lists Darwin separately.
Sep 9, 2019
5287885
use randSecure and randABytes
bpangWR Sep 10, 2019
83e7976
Merge pull request #20 from Wind-River/rand
BaoshanPang Sep 11, 2019
5e8bf87
Merge pull request #21 from rust-lang/master
BaoshanPang Sep 11, 2019
b731e11
declare EnvKey before use to fix build error
bpangWR Sep 11, 2019
a8c5f90
Fix inconsistent link formatting.
tomasz-rozanski Sep 11, 2019
223600a
Guarantee vec.clear/truncate is O(1) for trivial types
kornelski Sep 11, 2019
2fcd870
Box `DiagnosticBuilder`.
nnethercote Sep 11, 2019
08fa803
Merge pull request #22 from Wind-River/master_002
BaoshanPang Sep 12, 2019
612c394
Trim rustc-workspace-hack
mati865 Sep 11, 2019
e9214a1
codegen: be more explicit about setting giving names to allocas.
eddyb Sep 12, 2019
a2261ad
Inline `mark_neighbours_as_waiting_from`.
nnethercote Sep 13, 2019
a47a5c3
typo fix
Sep 9, 2019
bd25507
Remove raw string literal quotes from error index descriptions
ollie27 Sep 13, 2019
69112a2
Add self to .mailmap
ollie27 Sep 13, 2019
b3b6713
Update src/libstd/time.rs
DevQps Sep 13, 2019
7437f77
Make fn ptr always structural match, regardless of whether formal typ…
pnkfelix Sep 13, 2019
c529294
Regression tests for fn ptr and `#[structural_match]` as discussed in…
pnkfelix Sep 13, 2019
bdad2c5
codegen: use "_N" (like for other locals) instead of "argN", for argu…
eddyb Sep 13, 2019
57e8287
fix #64430
12101111 Sep 13, 2019
b98a844
add ui test for #64430
12101111 Sep 13, 2019
e484f21
add trailing newline
12101111 Sep 13, 2019
094af97
Update value.rs
goddessfreya Sep 14, 2019
58a26c8
Update src/liballoc/raw_vec.rs
alexreg Sep 14, 2019
baaaea3
Rollup merge of #63846 - DevQps:32626-document-time-system-calls, r=r…
Centril Sep 14, 2019
45baedb
Rollup merge of #64116 - ZeGentzy:patch-1, r=oli-obk
Centril Sep 14, 2019
afc5291
Rollup merge of #64203 - alexreg:rush-pr-2, r=centril
Centril Sep 14, 2019
1054158
Rollup merge of #64302 - nnethercote:shrink-ObligationCauseCode, r=za…
Centril Sep 14, 2019
1e2a970
Rollup merge of #64372 - Wind-River:master, r=alexcrichton
Centril Sep 14, 2019
af33a1d
Rollup merge of #64374 - nnethercote:box-DiagnosticBuilder, r=zackmdavis
Centril Sep 14, 2019
c6c2acd
Rollup merge of #64375 - kornelski:vecdrop, r=rkruppe
Centril Sep 14, 2019
ae9d417
Rollup merge of #64378 - Rosto75:master, r=jonas-schievink
Centril Sep 14, 2019
f7dd5d0
Rollup merge of #64384 - mati865:tools_hack, r=alexcrichton
Centril Sep 14, 2019
f669872
Rollup merge of #64393 - Wind-River:master_002_envKey, r=alexcrichton
Centril Sep 14, 2019
5e44c5f
Rollup merge of #64420 - nnethercote:inline-mark_neighbours_as_waitin…
Centril Sep 14, 2019
181d129
Rollup merge of #64422 - ollie27:error_index_generator_stringify, r=M…
Centril Sep 14, 2019
70787c7
Rollup merge of #64423 - ollie27:mailmap, r=Mark-Simulacrum
Centril Sep 14, 2019
4398eb7
Rollup merge of #64425 - guanqun:typo-fix, r=matthewjasper
Centril Sep 14, 2019
5160e4b
Rollup merge of #64431 - pnkfelix:issue-63479-fnptr-is-structural-mat…
Centril Sep 14, 2019
bf1253b
Rollup merge of #64435 - eddyb:arguments-against-arg, r=rkruppe
Centril Sep 14, 2019
1c7959b
Rollup merge of #64439 - 12101111:fix-owned-box, r=Centril
Centril Sep 14, 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
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ Neil Pankey <npankey@gmail.com> <neil@wire.im>
Nick Platt <platt.nicholas@gmail.com>
Nicole Mazzuca <npmazzuca@gmail.com>
Nif Ward <nif.ward@gmail.com>
Oliver Middleton <olliemail27@gmail.com> <ollie27@users.noreply.github.com>
Oliver Scherer <oliver.schneider@kit.edu> <git-spam-no-reply9815368754983@oli-obk.de>
Oliver Scherer <oliver.schneider@kit.edu> <git-spam9815368754983@oli-obk.de>
Oliver Scherer <oliver.schneider@kit.edu> <github333195615777966@oli-obk.de>
Expand Down
4 changes: 0 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3256,13 +3256,9 @@ version = "1.0.0"
dependencies = [
"byteorder",
"crossbeam-utils 0.6.5",
"parking_lot 0.7.1",
"rand 0.6.1",
"scopeguard 0.3.3",
"serde",
"serde_json",
"smallvec",
"syn 0.15.35",
"winapi 0.3.6",
]

Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/collections/linked_list/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ fn test_append() {
assert_eq!(m.pop_front(), Some(elt))
}
assert_eq!(n.len(), 0);
// let's make sure it's working properly, since we
// did some direct changes to private members
// Let's make sure it's working properly, since we
// did some direct changes to private members.
n.push_back(3);
assert_eq!(n.len(), 1);
assert_eq!(n.pop_front(), Some(3));
Expand Down
150 changes: 74 additions & 76 deletions src/liballoc/raw_vec.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/liballoc/raw_vec/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ fn allocator_param() {
use crate::alloc::AllocErr;

// Writing a test of integration between third-party
// allocators and RawVec is a little tricky because the RawVec
// allocators and `RawVec` is a little tricky because the `RawVec`
// API does not expose fallible allocation methods, so we
// cannot check what happens when allocator is exhausted
// (beyond detecting a panic).
//
// Instead, this just checks that the RawVec methods do at
// Instead, this just checks that the `RawVec` methods do at
// least go through the Allocator API when it reserves
// storage.

Expand Down Expand Up @@ -44,7 +44,7 @@ fn allocator_param() {
fn reserve_does_not_overallocate() {
{
let mut v: RawVec<u32> = RawVec::new();
// First `reserve` allocates like `reserve_exact`
// First, `reserve` allocates like `reserve_exact`.
v.reserve(0, 9);
assert_eq!(9, v.capacity());
}
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ impl<T: ?Sized> Rc<T> {
/// let x = Rc::from_raw(x_ptr);
/// assert_eq!(&*x, "hello");
///
/// // Further calls to `Rc::from_raw(x_ptr)` would be memory unsafe.
/// // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.
/// }
///
/// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ impl<T: ?Sized> Arc<T> {
/// let x = Arc::from_raw(x_ptr);
/// assert_eq!(&*x, "hello");
///
/// // Further calls to `Arc::from_raw(x_ptr)` would be memory unsafe.
/// // Further calls to `Arc::from_raw(x_ptr)` would be memory-unsafe.
/// }
///
/// // The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
Expand Down
30 changes: 17 additions & 13 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,21 +685,25 @@ impl<T> Vec<T> {
/// [`drain`]: #method.drain
#[stable(feature = "rust1", since = "1.0.0")]
pub fn truncate(&mut self, len: usize) {
let current_len = self.len;
unsafe {
let mut ptr = self.as_mut_ptr().add(self.len);
// Set the final length at the end, keeping in mind that
// dropping an element might panic. Works around a missed
// optimization, as seen in the following issue:
// https://github.com/rust-lang/rust/issues/51802
let mut local_len = SetLenOnDrop::new(&mut self.len);
if mem::needs_drop::<T>() {
let current_len = self.len;
unsafe {
let mut ptr = self.as_mut_ptr().add(self.len);
// Set the final length at the end, keeping in mind that
// dropping an element might panic. Works around a missed
// optimization, as seen in the following issue:
// https://github.com/rust-lang/rust/issues/51802
let mut local_len = SetLenOnDrop::new(&mut self.len);

// drop any extra elements
for _ in len..current_len {
local_len.decrement_len(1);
ptr = ptr.offset(-1);
ptr::drop_in_place(ptr);
// drop any extra elements
for _ in len..current_len {
local_len.decrement_len(1);
ptr = ptr.offset(-1);
ptr::drop_in_place(ptr);
}
}
} else if len <= self.len {
self.len = len;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ impl dyn Any {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is<T: Any>(&self) -> bool {
// Get TypeId of the type this function is instantiated with
// Get `TypeId` of the type this function is instantiated with.
let t = TypeId::of::<T>();

// Get TypeId of the type in the trait object
// Get `TypeId` of the type in the trait object.
let concrete = self.type_id();

// Compare both TypeIds on equality
// Compare both `TypeId`s on equality.
t == concrete
}

Expand Down
4 changes: 2 additions & 2 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,10 @@ unsafe impl<T: ?Sized> Freeze for *mut T {}
unsafe impl<T: ?Sized> Freeze for &T {}
unsafe impl<T: ?Sized> Freeze for &mut T {}

/// Types which can be safely moved after being pinned.
/// Types that can be safely moved after being pinned.
///
/// Since Rust itself has no notion of immovable types, and considers moves
/// (e.g. through assignment or [`mem::replace`]) to always be safe,
/// (e.g., through assignment or [`mem::replace`]) to always be safe,
/// this trait cannot prevent types from moving by itself.
///
/// Instead it is used to prevent moves through the type system,
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 @@ -1042,7 +1042,7 @@ impl<T: ?Sized> *const T {
(self as *const u8) == null()
}

/// Cast to a pointer to a different type
/// Casts to a pointer of another type.
#[stable(feature = "ptr_cast", since = "1.38.0")]
#[inline]
pub const fn cast<U>(self) -> *const U {
Expand Down Expand Up @@ -1726,7 +1726,7 @@ impl<T: ?Sized> *mut T {
(self as *mut u8) == null_mut()
}

/// Cast to a pointer to a different type
/// Casts to a pointer of another type.
#[stable(feature = "ptr_cast", since = "1.38.0")]
#[inline]
pub const fn cast<U>(self) -> *mut U {
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/ptr/non_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<T: ?Sized> NonNull<T> {
&mut *self.as_ptr()
}

/// Cast to a pointer of another type
/// Casts to a pointer of another type.
#[stable(feature = "nonnull_cast", since = "1.27.0")]
#[inline]
pub const fn cast<U>(self) -> NonNull<U> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub enum ParamName {
Fresh(usize),

/// Indicates an illegal name was given and an error has been
/// repored (so we should squelch other derived errors). Occurs
/// reported (so we should squelch other derived errors). Occurs
/// when, e.g., `'_` is used in the wrong place.
Error,
}
Expand Down
27 changes: 15 additions & 12 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ use crate::hir::def_id::DefId;
use crate::hir::Node;
use crate::infer::opaque_types;
use crate::middle::region;
use crate::traits::{ObligationCause, ObligationCauseCode};
use crate::traits::{IfExpressionCause, MatchExpressionArmCause, ObligationCause};
use crate::traits::{ObligationCauseCode};
use crate::ty::error::TypeError;
use crate::ty::{self, subst::{Subst, SubstsRef}, Region, Ty, TyCtxt, TypeFoldable};
use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
Expand Down Expand Up @@ -624,13 +625,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
}
}
ObligationCauseCode::MatchExpressionArm {
ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
source,
ref prior_arms,
last_ty,
discrim_hir_id,
..
} => match source {
}) => match source {
hir::MatchSource::IfLetDesugar { .. } => {
let msg = "`if let` arms have incompatible types";
err.span_label(cause.span, msg);
Expand Down Expand Up @@ -681,7 +682,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
}
},
ObligationCauseCode::IfExpression { then, outer, semicolon } => {
ObligationCauseCode::IfExpression(box IfExpressionCause { then, outer, semicolon }) => {
err.span_label(then, "expected because of this");
outer.map(|sp| err.span_label(sp, "if and else have incompatible types"));
if let Some(sp) = semicolon {
Expand Down Expand Up @@ -1622,13 +1623,15 @@ impl<'tcx> ObligationCause<'tcx> {
use crate::traits::ObligationCauseCode::*;
match self.code {
CompareImplMethodObligation { .. } => Error0308("method not compatible with trait"),
MatchExpressionArm { source, .. } => Error0308(match source {
hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have incompatible types",
hir::MatchSource::TryDesugar => {
"try expression alternatives have incompatible types"
}
_ => "match arms have incompatible types",
}),
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) =>
Error0308(match source {
hir::MatchSource::IfLetDesugar { .. } =>
"`if let` arms have incompatible types",
hir::MatchSource::TryDesugar => {
"try expression alternatives have incompatible types"
}
_ => "match arms have incompatible types",
}),
IfExpression { .. } => Error0308("if and else have incompatible types"),
IfExpressionWithNoElse => Error0317("if may be missing an else clause"),
MainFunctionType => Error0580("main function has wrong type"),
Expand Down Expand Up @@ -1656,7 +1659,7 @@ impl<'tcx> ObligationCause<'tcx> {
match self.code {
CompareImplMethodObligation { .. } => "method type is compatible with trait",
ExprAssignable => "expression is assignable",
MatchExpressionArm { source, .. } => match source {
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) => match source {
hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
_ => "match arms have compatible types",
},
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub struct RawConst<'tcx> {
pub ty: Ty<'tcx>,
}

/// Represents a constant value in Rust. `Scalar` and `ScalarPair` are optimizations that
/// match the `LocalState` optimizations for easy conversions between `Value` and `ConstValue`.
/// Represents a constant value in Rust. `Scalar` and `Slice` are optimizations for
/// array length computations, enum discriminants and the pattern matching logic.
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord,
RustcEncodable, RustcDecodable, Hash, HashStable)]
pub enum ConstValue<'tcx> {
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ pub struct PendingPredicateObligation<'tcx> {
pub stalled_on: Vec<Ty<'tcx>>,
}

// `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert_size!(PendingPredicateObligation<'_>, 136);

impl<'a, 'tcx> FulfillmentContext<'tcx> {
/// Creates a new fulfillment context.
pub fn new() -> FulfillmentContext<'tcx> {
Expand Down
41 changes: 28 additions & 13 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ pub struct Obligation<'tcx, T> {
pub type PredicateObligation<'tcx> = Obligation<'tcx, ty::Predicate<'tcx>>;
pub type TraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitPredicate<'tcx>>;

// `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert_size!(PredicateObligation<'_>, 112);

/// The reason why we incurred this obligation; used for error reporting.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct ObligationCause<'tcx> {
Expand All @@ -147,7 +151,8 @@ impl<'tcx> ObligationCause<'tcx> {
ObligationCauseCode::StartFunctionType => {
tcx.sess.source_map().def_span(self.span)
}
ObligationCauseCode::MatchExpressionArm { arm_span, .. } => arm_span,
ObligationCauseCode::MatchExpressionArm(
box MatchExpressionArmCause { arm_span, .. }) => arm_span,
_ => self.span,
}
}
Expand Down Expand Up @@ -223,23 +228,13 @@ pub enum ObligationCauseCode<'tcx> {
ExprAssignable,

/// Computing common supertype in the arms of a match expression
MatchExpressionArm {
arm_span: Span,
source: hir::MatchSource,
prior_arms: Vec<Span>,
last_ty: Ty<'tcx>,
discrim_hir_id: hir::HirId,
},
MatchExpressionArm(Box<MatchExpressionArmCause<'tcx>>),

/// Computing common supertype in the pattern guard for the arms of a match expression
MatchExpressionArmPattern { span: Span, ty: Ty<'tcx> },

/// Computing common supertype in an if expression
IfExpression {
then: Span,
outer: Option<Span>,
semicolon: Option<Span>,
},
IfExpression(Box<IfExpressionCause>),

/// Computing common supertype of an if expression with no else counter-part
IfExpressionWithNoElse,
Expand Down Expand Up @@ -269,6 +264,26 @@ pub enum ObligationCauseCode<'tcx> {
TrivialBound,
}

// `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert_size!(ObligationCauseCode<'_>, 32);

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct MatchExpressionArmCause<'tcx> {
pub arm_span: Span,
pub source: hir::MatchSource,
pub prior_arms: Vec<Span>,
pub last_ty: Ty<'tcx>,
pub discrim_hir_id: hir::HirId,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct IfExpressionCause {
pub then: Span,
pub outer: Option<Span>,
pub semicolon: Option<Span>,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DerivedObligationCause<'tcx> {
/// The trait reference of the parent obligation that led to the
Expand Down
20 changes: 11 additions & 9 deletions src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,31 +508,33 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
trait_item_def_id,
}),
super::ExprAssignable => Some(super::ExprAssignable),
super::MatchExpressionArm {
super::MatchExpressionArm(box super::MatchExpressionArmCause {
arm_span,
source,
ref prior_arms,
last_ty,
discrim_hir_id,
} => {
}) => {
tcx.lift(&last_ty).map(|last_ty| {
super::MatchExpressionArm {
super::MatchExpressionArm(box super::MatchExpressionArmCause {
arm_span,
source,
prior_arms: prior_arms.clone(),
last_ty,
discrim_hir_id,
}
})
})
}
super::MatchExpressionArmPattern { span, ty } => {
tcx.lift(&ty).map(|ty| super::MatchExpressionArmPattern { span, ty })
}
super::IfExpression { then, outer, semicolon } => Some(super::IfExpression {
then,
outer,
semicolon,
}),
super::IfExpression(box super::IfExpressionCause { then, outer, semicolon }) => {
Some(super::IfExpression(box super::IfExpressionCause {
then,
outer,
semicolon,
}))
}
super::IfExpressionWithNoElse => Some(super::IfExpressionWithNoElse),
super::MainFunctionType => Some(super::MainFunctionType),
super::StartFunctionType => Some(super::StartFunctionType),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2396,9 +2396,9 @@ impl<'tcx> TyCtxt<'tcx> {
}

#[inline]
pub fn mk_lang_item(self, ty: Ty<'tcx>, item: lang_items::LangItem) -> Ty<'tcx> {
let def_id = self.require_lang_item(item, None);
self.mk_generic_adt(def_id, ty)
pub fn mk_lang_item(self, ty: Ty<'tcx>, item: lang_items::LangItem) -> Option<Ty<'tcx>> {
let def_id = self.lang_items().require(item).ok()?;
Some(self.mk_generic_adt(def_id, ty))
}

#[inline]
Expand Down
Loading