From 2e812e10f4ece10d90ae3315aba16b88c5e870eb Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 2 May 2016 18:22:03 +0200 Subject: syntax/hir: give loop labels a span This makes the "shadowing labels" warning *not* print the entire loop as a span, but only the lifetime. Also makes #31719 go away, but does not fix its root cause (the span of the expanded loop is still wonky, but not used anymore). --- src/libsyntax/ext/expand.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index f243706eecb..96f4e0d3bdf 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -9,7 +9,7 @@ // except according to those terms. use ast::{Block, Crate, DeclKind, PatKind}; -use ast::{Local, Ident, Mac_, Name}; +use ast::{Local, Ident, Mac_, Name, SpannedIdent}; use ast::{MacStmtStyle, Mrk, Stmt, StmtKind, ItemKind}; use ast::TokenTree; use ast; @@ -277,12 +277,12 @@ fn expand_mac_invoc(mac: ast::Mac, /// body is in a block enclosed by loop head so the renaming of loop label /// must be propagated to the enclosed context. fn expand_loop_block(loop_block: P, - opt_ident: Option, - fld: &mut MacroExpander) -> (P, Option) { + opt_ident: Option, + fld: &mut MacroExpander) -> (P, Option) { match opt_ident { Some(label) => { - let new_label = fresh_name(label); - let rename = (label, new_label); + let new_label = fresh_name(label.node); + let rename = (label.node, new_label); // The rename *must not* be added to the pending list of current // syntax context otherwise an unrelated `break` or `continue` in @@ -290,7 +290,7 @@ fn expand_loop_block(loop_block: P, // and be renamed incorrectly. let mut rename_list = vec!(rename); let mut rename_fld = IdentRenamer{renames: &mut rename_list}; - let renamed_ident = rename_fld.fold_ident(label); + let renamed_ident = rename_fld.fold_ident(label.node); // The rename *must* be added to the enclosed syntax context for // `break` or `continue` to pick up because by definition they are @@ -300,7 +300,7 @@ fn expand_loop_block(loop_block: P, let expanded_block = expand_block_elts(loop_block, fld); fld.cx.syntax_env.pop_frame(); - (expanded_block, Some(renamed_ident)) + (expanded_block, Some(Spanned { node: renamed_ident, span: label.span })) } None => (fld.fold_block(loop_block), opt_ident) } -- cgit 1.4.1-3-g733a5