Skip to content

Commit 2daa404

Browse files
committed
Auto merge of #65009 - Centril:rollup-06g05xj, r=Centril
Rollup of 13 pull requests Successful merges: - #64581 (Fix unreachable_code warnings for try{} block ok-wrapped expressions) - #64850 (Remove inlines from DepNode code) - #64914 (regression test for 64453 borrow check error.) - #64922 (Use PlaceBuilder to avoid a lot of slice -> vec -> slice convertions) - #64948 (Improve sidebar styling to make its integration easier) - #64961 (Make comment about dummy type a bit more clear) - #64967 (Don't mark borrows of zero-sized arrays as indirectly mutable) - #64973 (Fix typo while setting `compile-flags` in test) - #64980 (Enable support for `IndirectlyMutableLocals` in `rustc_peek` ) - #64989 (Fix ICE #64964) - #64991 ([const-prop] Correctly handle locals that can't be propagated) - #64995 (Remove rustdoc warning) - #64997 (rustc book: nitpick SLP vectorization) Failed merges: r? @ghost
2 parents f2023ac + b961f96 commit 2daa404

File tree

31 files changed

+756
-258
lines changed

31 files changed

+756
-258
lines changed

src/doc/rustc/src/codegen-options/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ flag will turn that behavior off.
105105

106106
## no-vectorize-slp
107107

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

src/librustc/dep_graph/dep_node.rs

+18-22
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ macro_rules! define_dep_nodes {
114114

115115
impl DepKind {
116116
#[allow(unreachable_code)]
117-
#[inline]
118117
pub fn can_reconstruct_query_key<$tcx>(&self) -> bool {
119118
match *self {
120119
$(
@@ -150,7 +149,6 @@ macro_rules! define_dep_nodes {
150149
}
151150
}
152151

153-
#[inline(always)]
154152
pub fn is_eval_always(&self) -> bool {
155153
match *self {
156154
$(
@@ -199,7 +197,6 @@ macro_rules! define_dep_nodes {
199197

200198
impl DepNode {
201199
#[allow(unreachable_code, non_snake_case)]
202-
#[inline(always)]
203200
pub fn new<'tcx>(tcx: TyCtxt<'tcx>,
204201
dep: DepConstructor<'tcx>)
205202
-> DepNode
@@ -219,14 +216,16 @@ macro_rules! define_dep_nodes {
219216
hash
220217
};
221218

222-
if cfg!(debug_assertions) &&
223-
!dep_node.kind.can_reconstruct_query_key() &&
224-
(tcx.sess.opts.debugging_opts.incremental_info ||
225-
tcx.sess.opts.debugging_opts.query_dep_graph)
219+
#[cfg(debug_assertions)]
226220
{
227-
tcx.dep_graph.register_dep_node_debug_str(dep_node, || {
228-
arg.to_debug_str(tcx)
229-
});
221+
if !dep_node.kind.can_reconstruct_query_key() &&
222+
(tcx.sess.opts.debugging_opts.incremental_info ||
223+
tcx.sess.opts.debugging_opts.query_dep_graph)
224+
{
225+
tcx.dep_graph.register_dep_node_debug_str(dep_node, || {
226+
arg.to_debug_str(tcx)
227+
});
228+
}
230229
}
231230

232231
return dep_node;
@@ -242,14 +241,16 @@ macro_rules! define_dep_nodes {
242241
hash
243242
};
244243

245-
if cfg!(debug_assertions) &&
246-
!dep_node.kind.can_reconstruct_query_key() &&
247-
(tcx.sess.opts.debugging_opts.incremental_info ||
248-
tcx.sess.opts.debugging_opts.query_dep_graph)
244+
#[cfg(debug_assertions)]
249245
{
250-
tcx.dep_graph.register_dep_node_debug_str(dep_node, || {
251-
tupled_args.to_debug_str(tcx)
252-
});
246+
if !dep_node.kind.can_reconstruct_query_key() &&
247+
(tcx.sess.opts.debugging_opts.incremental_info ||
248+
tcx.sess.opts.debugging_opts.query_dep_graph)
249+
{
250+
tcx.dep_graph.register_dep_node_debug_str(dep_node, || {
251+
tupled_args.to_debug_str(tcx)
252+
});
253+
}
253254
}
254255

255256
return dep_node;
@@ -267,7 +268,6 @@ macro_rules! define_dep_nodes {
267268
/// Construct a DepNode from the given DepKind and DefPathHash. This
268269
/// method will assert that the given DepKind actually requires a
269270
/// single DefId/DefPathHash parameter.
270-
#[inline(always)]
271271
pub fn from_def_path_hash(kind: DepKind,
272272
def_path_hash: DefPathHash)
273273
-> DepNode {
@@ -281,7 +281,6 @@ macro_rules! define_dep_nodes {
281281
/// Creates a new, parameterless DepNode. This method will assert
282282
/// that the DepNode corresponding to the given DepKind actually
283283
/// does not require any parameters.
284-
#[inline(always)]
285284
pub fn new_no_params(kind: DepKind) -> DepNode {
286285
debug_assert!(!kind.has_params());
287286
DepNode {
@@ -300,7 +299,6 @@ macro_rules! define_dep_nodes {
300299
/// DepNode. Condition (2) might not be fulfilled if a DepNode
301300
/// refers to something from the previous compilation session that
302301
/// has been removed.
303-
#[inline]
304302
pub fn extract_def_id(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
305303
if self.kind.can_reconstruct_query_key() {
306304
let def_path_hash = DefPathHash(self.hash);
@@ -386,14 +384,12 @@ impl fmt::Debug for DepNode {
386384

387385

388386
impl DefPathHash {
389-
#[inline(always)]
390387
pub fn to_dep_node(self, kind: DepKind) -> DepNode {
391388
DepNode::from_def_path_hash(kind, self)
392389
}
393390
}
394391

395392
impl DefId {
396-
#[inline(always)]
397393
pub fn to_dep_node(self, tcx: TyCtxt<'_>, kind: DepKind) -> DepNode {
398394
DepNode::from_def_path_hash(kind, tcx.def_path_hash(self))
399395
}

src/librustc/hir/lowering/expr.rs

+27-10
Original file line numberDiff line numberDiff line change
@@ -392,32 +392,49 @@ impl LoweringContext<'_> {
392392
)
393393
}
394394

395+
/// Desugar `try { <stmts>; <expr> }` into `{ <stmts>; ::std::ops::Try::from_ok(<expr>) }`,
396+
/// `try { <stmts>; }` into `{ <stmts>; ::std::ops::Try::from_ok(()) }`
397+
/// and save the block id to use it as a break target for desugaring of the `?` operator.
395398
fn lower_expr_try_block(&mut self, body: &Block) -> hir::ExprKind {
396399
self.with_catch_scope(body.id, |this| {
397-
let unstable_span = this.mark_span_with_reason(
400+
let mut block = this.lower_block(body, true).into_inner();
401+
402+
let try_span = this.mark_span_with_reason(
398403
DesugaringKind::TryBlock,
399404
body.span,
400405
this.allow_try_trait.clone(),
401406
);
402-
let mut block = this.lower_block(body, true).into_inner();
403-
let tail = block.expr.take().map_or_else(
404-
|| this.expr_unit(this.sess.source_map().end_point(unstable_span)),
407+
408+
// Final expression of the block (if present) or `()` with span at the end of block
409+
let tail_expr = block.expr.take().map_or_else(
410+
|| this.expr_unit(this.sess.source_map().end_point(try_span)),
405411
|x: P<hir::Expr>| x.into_inner(),
406412
);
407-
block.expr = Some(this.wrap_in_try_constructor(sym::from_ok, tail, unstable_span));
413+
414+
let ok_wrapped_span = this.mark_span_with_reason(
415+
DesugaringKind::TryBlock,
416+
tail_expr.span,
417+
None
418+
);
419+
420+
// `::std::ops::Try::from_ok($tail_expr)`
421+
block.expr = Some(this.wrap_in_try_constructor(
422+
sym::from_ok, try_span, tail_expr, ok_wrapped_span));
423+
408424
hir::ExprKind::Block(P(block), None)
409425
})
410426
}
411427

412428
fn wrap_in_try_constructor(
413429
&mut self,
414430
method: Symbol,
415-
e: hir::Expr,
416-
unstable_span: Span,
431+
method_span: Span,
432+
expr: hir::Expr,
433+
overall_span: Span,
417434
) -> P<hir::Expr> {
418435
let path = &[sym::ops, sym::Try, method];
419-
let from_err = P(self.expr_std_path(unstable_span, path, None, ThinVec::new()));
420-
P(self.expr_call(e.span, from_err, hir_vec![e]))
436+
let constructor = P(self.expr_std_path(method_span, path, None, ThinVec::new()));
437+
P(self.expr_call(overall_span, constructor, hir_vec![expr]))
421438
}
422439

423440
fn lower_arm(&mut self, arm: &Arm) -> hir::Arm {
@@ -1244,7 +1261,7 @@ impl LoweringContext<'_> {
12441261
self.expr_call_std_path(try_span, from_path, hir_vec![err_expr])
12451262
};
12461263
let from_err_expr =
1247-
self.wrap_in_try_constructor(sym::from_error, from_expr, unstable_span);
1264+
self.wrap_in_try_constructor(sym::from_error, unstable_span, from_expr, try_span);
12481265
let thin_attrs = ThinVec::from(attrs);
12491266
let catch_scope = self.catch_scopes.last().map(|x| *x);
12501267
let ret_expr = if let Some(catch_node) = catch_scope {

src/librustc/hir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ pub struct Block {
861861
pub span: Span,
862862
/// If true, then there may exist `break 'a` values that aim to
863863
/// break out of this block early.
864-
/// Used by `'label: {}` blocks and by `catch` statements.
864+
/// Used by `'label: {}` blocks and by `try {}` blocks.
865865
pub targeted_by_break: bool,
866866
}
867867

src/librustc/ty/context.rs

+6
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ pub struct GeneratorInteriorTypeCause<'tcx> {
317317
pub scope_span: Option<Span>,
318318
}
319319

320+
BraceStructTypeFoldableImpl! {
321+
impl<'tcx> TypeFoldable<'tcx> for GeneratorInteriorTypeCause<'tcx> {
322+
ty, span, scope_span
323+
}
324+
}
325+
320326
#[derive(RustcEncodable, RustcDecodable, Debug)]
321327
pub struct TypeckTables<'tcx> {
322328
/// The HirId::owner all ItemLocalIds in this table are relative to.

src/librustc/ty/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,8 @@ impl<'tcx> rustc_serialize::UseSpecializedDecodable for Ty<'tcx> {}
600600
pub type CanonicalTy<'tcx> = Canonical<'tcx, Ty<'tcx>>;
601601

602602
extern {
603-
/// A dummy type used to force `List` to by unsized without requiring fat pointers.
603+
/// A dummy type used to force `List` to be unsized while not requiring references to it be wide
604+
/// pointers.
604605
type OpaqueListContents;
605606
}
606607

0 commit comments

Comments
 (0)