Skip to content

Commit

Permalink
Auto merge of rust-lang#65009 - Centril:rollup-06g05xj, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 13 pull requests

Successful merges:

 - rust-lang#64581 (Fix unreachable_code warnings for try{} block ok-wrapped expressions)
 - rust-lang#64850 (Remove inlines from DepNode code)
 - rust-lang#64914 (regression test for 64453 borrow check error.)
 - rust-lang#64922 (Use PlaceBuilder to avoid a lot of slice -> vec -> slice convertions)
 - rust-lang#64948 (Improve sidebar styling to make its integration easier)
 - rust-lang#64961 (Make comment about dummy type a bit more clear)
 - rust-lang#64967 (Don't mark borrows of zero-sized arrays as indirectly mutable)
 - rust-lang#64973 (Fix typo while setting `compile-flags` in test)
 - rust-lang#64980 (Enable support for `IndirectlyMutableLocals` in `rustc_peek` )
 - rust-lang#64989 (Fix ICE rust-lang#64964)
 - rust-lang#64991 ([const-prop] Correctly handle locals that can't be propagated)
 - rust-lang#64995 (Remove rustdoc warning)
 - rust-lang#64997 (rustc book: nitpick SLP vectorization)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Oct 2, 2019
2 parents f2023ac + b961f96 commit 2daa404
Show file tree
Hide file tree
Showing 31 changed files with 756 additions and 258 deletions.
2 changes: 1 addition & 1 deletion src/doc/rustc/src/codegen-options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ flag will turn that behavior off.

## no-vectorize-slp

By default, `rustc` will attempt to vectorize loops using [superword-level
By default, `rustc` will attempt to vectorize code using [superword-level
parallelism](https://llvm.org/docs/Vectorizers.html#the-slp-vectorizer). This
flag will turn that behavior off.

Expand Down
40 changes: 18 additions & 22 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ macro_rules! define_dep_nodes {

impl DepKind {
#[allow(unreachable_code)]
#[inline]
pub fn can_reconstruct_query_key<$tcx>(&self) -> bool {
match *self {
$(
Expand Down Expand Up @@ -150,7 +149,6 @@ macro_rules! define_dep_nodes {
}
}

#[inline(always)]
pub fn is_eval_always(&self) -> bool {
match *self {
$(
Expand Down Expand Up @@ -199,7 +197,6 @@ macro_rules! define_dep_nodes {

impl DepNode {
#[allow(unreachable_code, non_snake_case)]
#[inline(always)]
pub fn new<'tcx>(tcx: TyCtxt<'tcx>,
dep: DepConstructor<'tcx>)
-> DepNode
Expand All @@ -219,14 +216,16 @@ macro_rules! define_dep_nodes {
hash
};

if cfg!(debug_assertions) &&
!dep_node.kind.can_reconstruct_query_key() &&
(tcx.sess.opts.debugging_opts.incremental_info ||
tcx.sess.opts.debugging_opts.query_dep_graph)
#[cfg(debug_assertions)]
{
tcx.dep_graph.register_dep_node_debug_str(dep_node, || {
arg.to_debug_str(tcx)
});
if !dep_node.kind.can_reconstruct_query_key() &&
(tcx.sess.opts.debugging_opts.incremental_info ||
tcx.sess.opts.debugging_opts.query_dep_graph)
{
tcx.dep_graph.register_dep_node_debug_str(dep_node, || {
arg.to_debug_str(tcx)
});
}
}

return dep_node;
Expand All @@ -242,14 +241,16 @@ macro_rules! define_dep_nodes {
hash
};

if cfg!(debug_assertions) &&
!dep_node.kind.can_reconstruct_query_key() &&
(tcx.sess.opts.debugging_opts.incremental_info ||
tcx.sess.opts.debugging_opts.query_dep_graph)
#[cfg(debug_assertions)]
{
tcx.dep_graph.register_dep_node_debug_str(dep_node, || {
tupled_args.to_debug_str(tcx)
});
if !dep_node.kind.can_reconstruct_query_key() &&
(tcx.sess.opts.debugging_opts.incremental_info ||
tcx.sess.opts.debugging_opts.query_dep_graph)
{
tcx.dep_graph.register_dep_node_debug_str(dep_node, || {
tupled_args.to_debug_str(tcx)
});
}
}

return dep_node;
Expand All @@ -267,7 +268,6 @@ macro_rules! define_dep_nodes {
/// Construct a DepNode from the given DepKind and DefPathHash. This
/// method will assert that the given DepKind actually requires a
/// single DefId/DefPathHash parameter.
#[inline(always)]
pub fn from_def_path_hash(kind: DepKind,
def_path_hash: DefPathHash)
-> DepNode {
Expand All @@ -281,7 +281,6 @@ macro_rules! define_dep_nodes {
/// Creates a new, parameterless DepNode. This method will assert
/// that the DepNode corresponding to the given DepKind actually
/// does not require any parameters.
#[inline(always)]
pub fn new_no_params(kind: DepKind) -> DepNode {
debug_assert!(!kind.has_params());
DepNode {
Expand All @@ -300,7 +299,6 @@ macro_rules! define_dep_nodes {
/// DepNode. Condition (2) might not be fulfilled if a DepNode
/// refers to something from the previous compilation session that
/// has been removed.
#[inline]
pub fn extract_def_id(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
if self.kind.can_reconstruct_query_key() {
let def_path_hash = DefPathHash(self.hash);
Expand Down Expand Up @@ -386,14 +384,12 @@ impl fmt::Debug for DepNode {


impl DefPathHash {
#[inline(always)]
pub fn to_dep_node(self, kind: DepKind) -> DepNode {
DepNode::from_def_path_hash(kind, self)
}
}

impl DefId {
#[inline(always)]
pub fn to_dep_node(self, tcx: TyCtxt<'_>, kind: DepKind) -> DepNode {
DepNode::from_def_path_hash(kind, tcx.def_path_hash(self))
}
Expand Down
37 changes: 27 additions & 10 deletions src/librustc/hir/lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,32 +392,49 @@ impl LoweringContext<'_> {
)
}

/// Desugar `try { <stmts>; <expr> }` into `{ <stmts>; ::std::ops::Try::from_ok(<expr>) }`,
/// `try { <stmts>; }` into `{ <stmts>; ::std::ops::Try::from_ok(()) }`
/// and save the block id to use it as a break target for desugaring of the `?` operator.
fn lower_expr_try_block(&mut self, body: &Block) -> hir::ExprKind {
self.with_catch_scope(body.id, |this| {
let unstable_span = this.mark_span_with_reason(
let mut block = this.lower_block(body, true).into_inner();

let try_span = this.mark_span_with_reason(
DesugaringKind::TryBlock,
body.span,
this.allow_try_trait.clone(),
);
let mut block = this.lower_block(body, true).into_inner();
let tail = block.expr.take().map_or_else(
|| this.expr_unit(this.sess.source_map().end_point(unstable_span)),

// Final expression of the block (if present) or `()` with span at the end of block
let tail_expr = block.expr.take().map_or_else(
|| this.expr_unit(this.sess.source_map().end_point(try_span)),
|x: P<hir::Expr>| x.into_inner(),
);
block.expr = Some(this.wrap_in_try_constructor(sym::from_ok, tail, unstable_span));

let ok_wrapped_span = this.mark_span_with_reason(
DesugaringKind::TryBlock,
tail_expr.span,
None
);

// `::std::ops::Try::from_ok($tail_expr)`
block.expr = Some(this.wrap_in_try_constructor(
sym::from_ok, try_span, tail_expr, ok_wrapped_span));

hir::ExprKind::Block(P(block), None)
})
}

fn wrap_in_try_constructor(
&mut self,
method: Symbol,
e: hir::Expr,
unstable_span: Span,
method_span: Span,
expr: hir::Expr,
overall_span: Span,
) -> P<hir::Expr> {
let path = &[sym::ops, sym::Try, method];
let from_err = P(self.expr_std_path(unstable_span, path, None, ThinVec::new()));
P(self.expr_call(e.span, from_err, hir_vec![e]))
let constructor = P(self.expr_std_path(method_span, path, None, ThinVec::new()));
P(self.expr_call(overall_span, constructor, hir_vec![expr]))
}

fn lower_arm(&mut self, arm: &Arm) -> hir::Arm {
Expand Down Expand Up @@ -1244,7 +1261,7 @@ impl LoweringContext<'_> {
self.expr_call_std_path(try_span, from_path, hir_vec![err_expr])
};
let from_err_expr =
self.wrap_in_try_constructor(sym::from_error, from_expr, unstable_span);
self.wrap_in_try_constructor(sym::from_error, unstable_span, from_expr, try_span);
let thin_attrs = ThinVec::from(attrs);
let catch_scope = self.catch_scopes.last().map(|x| *x);
let ret_expr = if let Some(catch_node) = catch_scope {
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 @@ -861,7 +861,7 @@ pub struct Block {
pub span: Span,
/// If true, then there may exist `break 'a` values that aim to
/// break out of this block early.
/// Used by `'label: {}` blocks and by `catch` statements.
/// Used by `'label: {}` blocks and by `try {}` blocks.
pub targeted_by_break: bool,
}

Expand Down
6 changes: 6 additions & 0 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ pub struct GeneratorInteriorTypeCause<'tcx> {
pub scope_span: Option<Span>,
}

BraceStructTypeFoldableImpl! {
impl<'tcx> TypeFoldable<'tcx> for GeneratorInteriorTypeCause<'tcx> {
ty, span, scope_span
}
}

#[derive(RustcEncodable, RustcDecodable, Debug)]
pub struct TypeckTables<'tcx> {
/// The HirId::owner all ItemLocalIds in this table are relative to.
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ impl<'tcx> rustc_serialize::UseSpecializedDecodable for Ty<'tcx> {}
pub type CanonicalTy<'tcx> = Canonical<'tcx, Ty<'tcx>>;

extern {
/// A dummy type used to force `List` to by unsized without requiring fat pointers.
/// A dummy type used to force `List` to be unsized while not requiring references to it be wide
/// pointers.
type OpaqueListContents;
}

Expand Down
Loading

0 comments on commit 2daa404

Please sign in to comment.