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

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 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
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
6dc1483
Provide a span if main function is not present in crate
Mark-Simulacrum Sep 8, 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
c69a9f0
Rollup merge of #63846 - DevQps:32626-document-time-system-calls, r=r…
Centril Sep 14, 2019
47af328
Rollup merge of #64116 - ZeGentzy:patch-1, r=oli-obk
Centril Sep 14, 2019
2834212
Rollup merge of #64290 - Mark-Simulacrum:span-no-main, r=estebank
Centril Sep 14, 2019
07d9cd2
Rollup merge of #64302 - nnethercote:shrink-ObligationCauseCode, r=za…
Centril Sep 14, 2019
0b74b2d
Rollup merge of #64372 - Wind-River:master, r=alexcrichton
Centril Sep 14, 2019
c9faf1f
Rollup merge of #64374 - nnethercote:box-DiagnosticBuilder, r=zackmdavis
Centril Sep 14, 2019
1ef6f1e
Rollup merge of #64375 - kornelski:vecdrop, r=rkruppe
Centril Sep 14, 2019
9883cc5
Rollup merge of #64378 - Rosto75:master, r=jonas-schievink
Centril Sep 14, 2019
4bfa11f
Rollup merge of #64384 - mati865:tools_hack, r=alexcrichton
Centril Sep 14, 2019
63e0887
Rollup merge of #64393 - Wind-River:master_002_envKey, r=alexcrichton
Centril Sep 14, 2019
fd7a7b9
Rollup merge of #64420 - nnethercote:inline-mark_neighbours_as_waitin…
Centril Sep 14, 2019
5747851
Rollup merge of #64422 - ollie27:error_index_generator_stringify, r=M…
Centril Sep 14, 2019
88ea39e
Rollup merge of #64423 - ollie27:mailmap, r=Mark-Simulacrum
Centril Sep 14, 2019
6eab5e7
Rollup merge of #64425 - guanqun:typo-fix, r=matthewjasper
Centril Sep 14, 2019
a51ebc1
Rollup merge of #64431 - pnkfelix:issue-63479-fnptr-is-structural-mat…
Centril Sep 14, 2019
eae08ef
Rollup merge of #64435 - eddyb:arguments-against-arg, r=rkruppe
Centril Sep 14, 2019
a5826ab
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
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
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
74 changes: 44 additions & 30 deletions src/librustc/middle/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ struct EntryContext<'a, 'tcx> {

map: &'a hir_map::Map<'tcx>,

/// The top-level function called 'main'.
/// The top-level function called `main`.
main_fn: Option<(HirId, Span)>,

/// The function that has attribute named 'main'.
/// The function that has attribute named `main`.
attr_main_fn: Option<(HirId, Span)>,

/// The function that has the attribute 'start' on it.
start_fn: Option<(HirId, Span)>,

/// The functions that one might think are 'main' but aren't, e.g.
/// The functions that one might think are `main` but aren't, e.g.
/// main functions not defined at the top level. For diagnostics.
non_main_fns: Vec<(HirId, Span)> ,
}
Expand Down Expand Up @@ -88,7 +88,7 @@ fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType {
EntryPointType::MainAttr
} else if item.ident.name == sym::main {
if at_root {
// This is a top-level function so can be 'main'.
// This is a top-level function so can be `main`.
EntryPointType::MainNamed
} else {
EntryPointType::OtherMain
Expand All @@ -109,7 +109,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
ctxt.main_fn = Some((item.hir_id, item.span));
} else {
span_err!(ctxt.session, item.span, E0136,
"multiple 'main' functions");
"multiple `main` functions");
}
},
EntryPointType::OtherMain => {
Expand All @@ -130,7 +130,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
if ctxt.start_fn.is_none() {
ctxt.start_fn = Some((item.hir_id, item.span));
} else {
struct_span_err!(ctxt.session, item.span, E0138, "multiple 'start' functions")
struct_span_err!(ctxt.session, item.span, E0138, "multiple `start` functions")
.span_label(ctxt.start_fn.unwrap().1, "previous `start` function here")
.span_label(item.span, "multiple `start` functions")
.emit();
Expand All @@ -148,34 +148,48 @@ fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) -> Option<(De
} else if let Some((hir_id, _)) = visitor.main_fn {
Some((tcx.hir().local_def_id(hir_id), EntryFnType::Main))
} else {
// There is no main function.
let mut err = struct_err!(tcx.sess, E0601,
"`main` function not found in crate `{}`", tcx.crate_name(LOCAL_CRATE));
if !visitor.non_main_fns.is_empty() {
// There were some functions named 'main' though. Try to give the user a hint.
err.note("the main function must be defined at the crate level \
but you have one or more functions named 'main' that are not \
defined at the crate level. Either move the definition or \
attach the `#[main]` attribute to override this behavior.");
for &(_, span) in &visitor.non_main_fns {
err.span_note(span, "here is a function named 'main'");
}
err.emit();
} else {
if let Some(ref filename) = tcx.sess.local_crate_source_file {
err.note(&format!("consider adding a `main` function to `{}`", filename.display()));
}
if tcx.sess.teach(&err.get_code().unwrap()) {
err.note("If you don't know the basics of Rust, you can go look to the Rust Book \
to get started: https://doc.rust-lang.org/book/");
}
err.emit();
}

no_main_err(tcx, visitor);
None
}
}

fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) {
// There is no main function.
let mut err = struct_err!(tcx.sess, E0601,
"`main` function not found in crate `{}`", tcx.crate_name(LOCAL_CRATE));
let filename = &tcx.sess.local_crate_source_file;
let note = if !visitor.non_main_fns.is_empty() {
for &(_, span) in &visitor.non_main_fns {
err.span_note(span, "here is a function named `main`");
}
err.note("you have one or more functions named `main` not defined at the crate level");
err.help("either move the `main` function definitions or attach the `#[main]` attribute \
to one of them");
// There were some functions named `main` though. Try to give the user a hint.
format!("the main function must be defined at the crate level{}",
filename.as_ref().map(|f| format!(" (in `{}`)", f.display())).unwrap_or_default())
} else if let Some(filename) = filename {
format!("consider adding a `main` function to `{}`", filename.display())
} else {
String::from("consider adding a `main` function at the crate level")
};
let sp = tcx.hir().krate().span;
// The file may be empty, which leads to the diagnostic machinery not emitting this
// note. This is a relatively simple way to detect that case and emit a span-less
// note instead.
if let Ok(_) = tcx.sess.source_map().lookup_line(sp.lo()) {
err.set_span(sp);
err.span_label(sp, &note);
} else {
err.note(&note);
}
if tcx.sess.teach(&err.get_code().unwrap()) {
err.note("If you don't know the basics of Rust, you can go look to the Rust Book \
to get started: https://doc.rust-lang.org/book/");
}
err.emit();
}

pub fn find_entry_point(tcx: TyCtxt<'_>) -> Option<(DefId, EntryFnType)> {
tcx.entry_fn(LOCAL_CRATE)
}
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
Loading