Skip to content

Commit a611bbc

Browse files
committed
Rename hir::Label to hir::Destination
1 parent 56e519d commit a611bbc

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

src/librustc/cfg/construct.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,17 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
303303
self.add_unreachable_node()
304304
}
305305

306-
hir::ExprBreak(label, ref opt_expr) => {
306+
hir::ExprBreak(destination, ref opt_expr) => {
307307
let v = self.opt_expr(opt_expr, pred);
308-
let loop_scope = self.find_scope(expr, label);
308+
let loop_scope = self.find_scope(expr, destination);
309309
let b = self.add_ast_node(expr.id, &[v]);
310310
self.add_exiting_edge(expr, b,
311311
loop_scope, loop_scope.break_index);
312312
self.add_unreachable_node()
313313
}
314314

315-
hir::ExprAgain(label) => {
316-
let loop_scope = self.find_scope(expr, label);
315+
hir::ExprAgain(destination) => {
316+
let loop_scope = self.find_scope(expr, destination);
317317
let a = self.add_ast_node(expr.id, &[pred]);
318318
self.add_exiting_edge(expr, a,
319319
loop_scope, loop_scope.continue_index);
@@ -588,9 +588,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
588588

589589
fn find_scope(&self,
590590
expr: &hir::Expr,
591-
label: hir::Label) -> LoopScope {
591+
destination: hir::Destination) -> LoopScope {
592592

593-
match label.loop_id.into() {
593+
match destination.loop_id.into() {
594594
Ok(loop_id) => {
595595
for l in &self.loop_scopes {
596596
if l.loop_id == loop_id {

src/librustc/hir/lowering.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,19 @@ impl<'a> LoweringContext<'a> {
326326
o_id.map(|sp_ident| respan(sp_ident.span, sp_ident.node.name))
327327
}
328328

329-
fn lower_label(&mut self, label: Option<(NodeId, Spanned<Ident>)>) -> hir::Label {
330-
match label {
331-
Some((id, label_ident)) => hir::Label {
329+
fn lower_destination(&mut self, destination: Option<(NodeId, Spanned<Ident>)>)
330+
-> hir::Destination
331+
{
332+
match destination {
333+
Some((id, label_ident)) => hir::Destination {
332334
ident: Some(label_ident),
333335
loop_id: if let Def::Label(loop_id) = self.expect_full_def(id) {
334336
hir::LoopIdResult::Ok(loop_id)
335337
} else {
336338
hir::LoopIdResult::Err(hir::LoopIdError::UnresolvedLabel)
337339
}
338340
},
339-
None => hir::Label {
341+
None => hir::Destination {
340342
ident: None,
341343
loop_id: self.loop_scopes.last().map(|innermost_loop_id| Ok(*innermost_loop_id))
342344
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope)).into()
@@ -1729,12 +1731,12 @@ impl<'a> LoweringContext<'a> {
17291731
}
17301732
ExprKind::Break(opt_ident, ref opt_expr) => {
17311733
let label_result = if self.is_in_loop_condition && opt_ident.is_none() {
1732-
hir::Label {
1734+
hir::Destination {
17331735
ident: opt_ident,
17341736
loop_id: Err(hir::LoopIdError::UnlabeledCfInWhileCondition).into(),
17351737
}
17361738
} else {
1737-
self.lower_label(opt_ident.map(|ident| (e.id, ident)))
1739+
self.lower_destination(opt_ident.map(|ident| (e.id, ident)))
17381740
};
17391741
hir::ExprBreak(
17401742
label_result,
@@ -1743,13 +1745,13 @@ impl<'a> LoweringContext<'a> {
17431745
ExprKind::Continue(opt_ident) =>
17441746
hir::ExprAgain(
17451747
if self.is_in_loop_condition && opt_ident.is_none() {
1746-
hir::Label {
1748+
hir::Destination {
17471749
ident: opt_ident,
17481750
loop_id: Err(
17491751
hir::LoopIdError::UnlabeledCfInWhileCondition).into(),
17501752
}
17511753
} else {
1752-
self.lower_label(opt_ident.map( | ident| (e.id, ident)))
1754+
self.lower_destination(opt_ident.map( |ident| (e.id, ident)))
17531755
}),
17541756
ExprKind::Ret(ref e) => hir::ExprRet(e.as_ref().map(|x| P(self.lower_expr(x)))),
17551757
ExprKind::InlineAsm(ref asm) => {
@@ -2244,7 +2246,7 @@ impl<'a> LoweringContext<'a> {
22442246
}
22452247

22462248
fn expr_break(&mut self, span: Span, attrs: ThinVec<Attribute>) -> P<hir::Expr> {
2247-
let expr_break = hir::ExprBreak(self.lower_label(None), None);
2249+
let expr_break = hir::ExprBreak(self.lower_destination(None), None);
22482250
P(self.expr(span, expr_break, attrs))
22492251
}
22502252

src/librustc/hir/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -959,9 +959,9 @@ pub enum Expr_ {
959959
/// A referencing operation (`&a` or `&mut a`)
960960
ExprAddrOf(Mutability, P<Expr>),
961961
/// A `break`, with an optional label to break
962-
ExprBreak(Label, Option<P<Expr>>),
962+
ExprBreak(Destination, Option<P<Expr>>),
963963
/// A `continue`, with an optional label
964-
ExprAgain(Label),
964+
ExprAgain(Destination),
965965
/// A `return`, with an optional value to be returned
966966
ExprRet(Option<P<Expr>>),
967967

@@ -1073,7 +1073,7 @@ impl From<Result<NodeId, LoopIdError>> for LoopIdResult {
10731073
}
10741074

10751075
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
1076-
pub struct Label {
1076+
pub struct Destination {
10771077
// This is `Some(_)` iff there is an explicit user-specified `label
10781078
pub ident: Option<Spanned<Ident>>,
10791079

0 commit comments

Comments
 (0)