Skip to content

Commit b814b63

Browse files
committedJan 22, 2021
Auto merge of #81271 - m-ou-se:rollup-xv7gq3w, r=m-ou-se
Rollup of 10 pull requests Successful merges: - #80573 (Deny rustc::internal lints for rustdoc and clippy) - #81173 (Expand docs on Iterator::intersperse) - #81194 (Stabilize std::panic::panic_any.) - #81202 (Don't prefix 0x for each segments in `dbg!(Ipv6)`) - #81225 (Make 'docs' nullable in rustdoc-json output) - #81227 (Remove doctree::StructType) - #81233 (Document why not use concat! in dbg! macro) - #81236 (Gracefully handle loop labels missing leading `'` in different positions) - #81241 (Turn alloc's force_expr macro into a regular macro_rules.) - #81242 (Enforce statically that `MIN_NON_ZERO_CAP` is calculated at compile time) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents f2de221 + 9c2a577 commit b814b63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+681
-266
lines changed
 

‎compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use rustc_errors::struct_span_err;
1010
use rustc_hir as hir;
1111
use rustc_hir::def::Res;
1212
use rustc_session::parse::feature_err;
13-
use rustc_span::hygiene::ForLoopLoc;
1413
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
1514
use rustc_span::symbol::{sym, Ident, Symbol};
15+
use rustc_span::{hygiene::ForLoopLoc, DUMMY_SP};
1616
use rustc_target::asm;
1717
use std::collections::hash_map::Entry;
1818
use std::fmt::Write;
@@ -102,6 +102,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
102102
this.lower_block(body, false),
103103
opt_label,
104104
hir::LoopSource::Loop,
105+
DUMMY_SP,
105106
)
106107
}),
107108
ExprKind::TryBlock(ref body) => self.lower_expr_try_block(body),
@@ -453,7 +454,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
453454
self.expr_match(span, scrutinee, arena_vec![self; then_arm, else_arm], desugar);
454455

455456
// `[opt_ident]: loop { ... }`
456-
hir::ExprKind::Loop(self.block_expr(self.arena.alloc(match_expr)), opt_label, source)
457+
hir::ExprKind::Loop(
458+
self.block_expr(self.arena.alloc(match_expr)),
459+
opt_label,
460+
source,
461+
span.with_hi(cond.span.hi()),
462+
)
457463
}
458464

459465
/// Desugar `try { <stmts>; <expr> }` into `{ <stmts>; ::std::ops::Try::from_ok(<expr>) }`,
@@ -748,7 +754,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
748754
// loop { .. }
749755
let loop_expr = self.arena.alloc(hir::Expr {
750756
hir_id: loop_hir_id,
751-
kind: hir::ExprKind::Loop(loop_block, None, hir::LoopSource::Loop),
757+
kind: hir::ExprKind::Loop(loop_block, None, hir::LoopSource::Loop, span),
752758
span,
753759
attrs: ThinVec::new(),
754760
});
@@ -1709,7 +1715,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
17091715
);
17101716

17111717
// `[opt_ident]: loop { ... }`
1712-
let kind = hir::ExprKind::Loop(loop_block, opt_label, hir::LoopSource::ForLoop);
1718+
let kind = hir::ExprKind::Loop(
1719+
loop_block,
1720+
opt_label,
1721+
hir::LoopSource::ForLoop,
1722+
e.span.with_hi(orig_head_span.hi()),
1723+
);
17131724
let loop_expr = self.arena.alloc(hir::Expr {
17141725
hir_id: self.lower_node_id(e.id),
17151726
kind,

‎compiler/rustc_hir/src/hir.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,9 @@ pub enum ExprKind<'hir> {
16171617
/// A conditionless loop (can be exited with `break`, `continue`, or `return`).
16181618
///
16191619
/// I.e., `'label: loop { <block> }`.
1620-
Loop(&'hir Block<'hir>, Option<Label>, LoopSource),
1620+
///
1621+
/// The `Span` is the loop header (`for x in y`/`while let pat = expr`).
1622+
Loop(&'hir Block<'hir>, Option<Label>, LoopSource, Span),
16211623
/// A `match` block, with a source that indicates whether or not it is
16221624
/// the result of a desugaring, and if so, which kind.
16231625
Match(&'hir Expr<'hir>, &'hir [Arm<'hir>], MatchSource),

0 commit comments

Comments
 (0)