Skip to content
Permalink
Browse files

Auto merge of #64449 - Centril:rollup-ybq0h5v, r=Centril

Rollup of 17 pull requests

Successful merges:

 - #64116 (Fix minor typo in docs.)
 - #64290 (Provide a span if main function is not present in crate)
 - #64302 (Shrink `ObligationCauseCode`)
 - #64372 (use randSecure and randABytes)
 - #64374 (Box `DiagnosticBuilder`.)
 - #64375 (Fast path for vec.clear/truncate )
 - #64378 (Fix inconsistent link formatting.)
 - #64384 (Trim rustc-workspace-hack)
 - #64393 ( declare EnvKey before use to fix build error)
 - #64420 (Inline `mark_neighbours_as_waiting_from`.)
 - #64422 (Remove raw string literal quotes from error index descriptions)
 - #64423 (Add self to .mailmap)
 - #64424 (Fix false "never constructed" warnings for `Self::` variant paths)
 - #64425 (typo fix)
 - #64431 (fn ptr is structural match)
 - #64435 (codegen: use "_N" (like for other locals) instead of "argN", for argument names.)
 - #64439 (fix #64430, confusing `owned_box` error message in no_std build)

Failed merges:

r? @ghost
  • Loading branch information...
bors committed Sep 14, 2019
2 parents 4576668 + b5e2477 commit 2b757c6126b1e8dbcacf71a588182c859cc0b11c
Showing with 702 additions and 409 deletions.
  1. +1 −0 .mailmap
  2. +0 −4 Cargo.lock
  3. +17 −13 src/liballoc/vec.rs
  4. +1 −1 src/librustc/hir/mod.rs
  5. +15 −12 src/librustc/infer/error_reporting/mod.rs
  6. +5 −11 src/librustc/middle/dead.rs
  7. +44 −30 src/librustc/middle/entry.rs
  8. +2 −2 src/librustc/mir/interpret/value.rs
  9. +4 −0 src/librustc/traits/fulfill.rs
  10. +28 −13 src/librustc/traits/mod.rs
  11. +11 −9 src/librustc/traits/structural_impls.rs
  12. +3 −3 src/librustc/ty/context.rs
  13. +1 −1 src/librustc_codegen_llvm/abi.rs
  14. +5 −18 src/librustc_codegen_llvm/builder.rs
  15. +1 −1 src/librustc_codegen_llvm/intrinsic.rs
  16. +9 −9 src/librustc_codegen_ssa/mir/block.rs
  17. +17 −12 src/librustc_codegen_ssa/mir/mod.rs
  18. +1 −1 src/librustc_codegen_ssa/mir/operand.rs
  19. +2 −6 src/librustc_codegen_ssa/mir/place.rs
  20. +1 −1 src/librustc_codegen_ssa/mir/rvalue.rs
  21. +2 −3 src/librustc_codegen_ssa/traits/builder.rs
  22. +13 −4 src/librustc_data_structures/obligation_forest/mod.rs
  23. +1 −1 src/librustc_errors/annotate_snippet_emitter_writer.rs
  24. +46 −35 src/librustc_errors/diagnostic_builder.rs
  25. +1 −1 src/librustc_errors/emitter.rs
  26. +1 −1 src/librustc_mir/const_eval.rs
  27. +7 −1 src/librustc_mir/hair/pattern/mod.rs
  28. +13 −10 src/librustc_typeck/check/_match.rs
  29. +3 −3 src/librustc_typeck/check/closure.rs
  30. +1 −1 src/librustc_typeck/check/compare_method.rs
  31. +18 −23 src/librustc_typeck/check/expr.rs
  32. +4 −4 src/libstd/io/stdio.rs
  33. +1 −0 src/libstd/sys/vxworks/process/mod.rs
  34. +0 −2 src/libstd/sys/vxworks/process/process_common.rs
  35. +14 −7 src/libstd/sys/vxworks/rand.rs
  36. +7 −0 src/libsyntax/parse/mod.rs
  37. +1 −1 src/test/codegen/adjustments.rs
  38. +6 −6 src/test/codegen/fastcall-inreg.rs
  39. +14 −14 src/test/codegen/function-arguments.rs
  40. +5 −4 src/test/codegen/personality_lifetimes.rs
  41. +1 −1 src/test/codegen/refs.rs
  42. +1 −1 src/test/codegen/repeat-trusted-len.rs
  43. +17 −17 src/test/codegen/repr-transparent.rs
  44. +6 −6 src/test/codegen/scalar-pair-bool.rs
  45. +8 −8 src/test/codegen/union-abi.rs
  46. +2 −0 src/test/ui-fulldeps/hash-stable-is-unstable.rs
  47. +2 −7 src/test/ui-fulldeps/hash-stable-is-unstable.stderr
  48. +2 −0 src/test/ui/associated-type-bounds/inside-adt.rs
  49. +1 −6 src/test/ui/associated-type-bounds/inside-adt.stderr
  50. +4 −1 src/test/ui/conditional-compilation/cfg-attr-cfg-2.stderr
  51. +3 −1 src/test/ui/conditional-compilation/cfg-in-crate-1.stderr
  52. +9 −1 src/test/ui/continue-after-missing-main.stderr
  53. +5 −1 src/test/ui/elided-test.stderr
  54. +1 −1 src/test/ui/error-codes/E0138.stderr
  55. +1 −1 src/test/ui/error-codes/E0601.rs
  56. +3 −1 src/test/ui/error-codes/E0601.stderr
  57. +2 −0 src/test/ui/issues/issue-46101.rs
  58. +2 −7 src/test/ui/issues/issue-46101.stderr
  59. +1 −0 src/test/ui/issues/issue-49040.rs
  60. +5 −1 src/test/ui/issues/issue-49040.stderr
  61. +2 −0 src/test/ui/issues/issue-60057.rs
  62. +2 −7 src/test/ui/issues/issue-60057.stderr
  63. +14 −0 src/test/ui/issues/issue-64430.rs
  64. +12 −0 src/test/ui/issues/issue-64430.stderr
  65. +1 −1 src/test/ui/json-short.stderr
  66. +2 −0 src/test/ui/lifetime-before-type-params.rs
  67. +1 −6 src/test/ui/lifetime-before-type-params.stderr
  68. +21 −1 src/test/ui/lint/lint-dead-code-5.rs
  69. +1 −1 src/test/ui/lint/lint-dead-code-5.stderr
  70. +1 −0 src/test/ui/main-wrong-location.rs
  71. +13 −3 src/test/ui/main-wrong-location.stderr
  72. +3 −1 src/test/ui/missing/missing-main.stderr
  73. +1 −0 src/test/ui/parser-recovery-1.rs
  74. +14 −5 src/test/ui/parser-recovery-1.stderr
  75. +4 −1 src/test/ui/parser/issue-2354.rs
  76. +16 −4 src/test/ui/parser/issue-2354.stderr
  77. +2 −0 src/test/ui/parser/lex-bad-char-literals-2.rs
  78. +1 −6 src/test/ui/parser/lex-bad-char-literals-2.stderr
  79. +1 −1 src/test/ui/parser/unclosed-delimiter-in-dep.stderr
  80. +2 −0 src/test/ui/parser/unclosed_delim_mod.rs
  81. +2 −7 src/test/ui/parser/unclosed_delim_mod.stderr
  82. +2 −0 src/test/ui/resolve/visibility-indeterminate.rs
  83. +1 −6 src/test/ui/resolve/visibility-indeterminate.stderr
  84. +135 −0 src/test/ui/rfc1445/fn-ptr-is-structurally-matchable.rs
  85. +36 −0 src/test/ui/rfc1445/issue-63479-match-fnptr.rs
  86. +1 −0 src/test/ui/tool-attributes/diagnostic_item.rs
  87. +2 −7 src/test/ui/tool-attributes/diagnostic_item.stderr
  88. +2 −0 src/test/ui/type-alias-impl-trait/issue-60564.rs
  89. +1 −6 src/test/ui/type-alias-impl-trait/issue-60564.stderr
  90. +1 −0 src/test/ui/type/ascription/issue-34255-1.rs
  91. +2 −6 src/test/ui/type/ascription/issue-34255-1.stderr
  92. +1 −1 src/tools/error_index_generator/build.rs
  93. +0 −10 src/tools/rustc-workspace-hack/Cargo.toml
@@ -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>
@@ -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",
]

@@ -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;
}
}

@@ -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,
}
@@ -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};
@@ -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);
@@ -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 {
@@ -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"),
@@ -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",
},
@@ -237,10 +237,6 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {

fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
match expr.node {
hir::ExprKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) => {
let res = self.tables.qpath_res(qpath, expr.hir_id);
self.handle_res(res);
}
hir::ExprKind::MethodCall(..) => {
self.lookup_and_handle_method(expr.hir_id);
}
@@ -280,10 +276,6 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
let res = self.tables.qpath_res(path, pat.hir_id);
self.handle_field_pattern_match(pat, res, fields);
}
PatKind::Path(ref qpath) => {
let res = self.tables.qpath_res(qpath, pat.hir_id);
self.handle_res(res);
}
_ => ()
}

@@ -292,9 +284,11 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
self.in_pat = false;
}

fn visit_path(&mut self, path: &'tcx hir::Path, _: hir::HirId) {
self.handle_res(path.res);
intravisit::walk_path(self, path);
fn visit_qpath(&mut self, qpath: &'tcx hir::QPath,
id: hir::HirId, span: syntax_pos::Span) {
let res = self.tables.qpath_res(qpath, id);
self.handle_res(res);
intravisit::walk_qpath(self, qpath, id, span);
}

fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
@@ -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)> ,
}
@@ -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
@@ -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 => {
@@ -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();
@@ -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)
}
@@ -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> {
@@ -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> {
@@ -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> {
@@ -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,
}
}
@@ -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,
@@ -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

0 comments on commit 2b757c6

Please sign in to comment.
You can’t perform that action at this time.