diff options
| author | Georg Brandl <georg@python.org> | 2016-05-02 18:22:03 +0200 |
|---|---|---|
| committer | Georg Brandl <g.brandl@fz-juelich.de> | 2016-05-24 14:22:14 +0200 |
| commit | 2e812e10f4ece10d90ae3315aba16b88c5e870eb (patch) | |
| tree | 1830b86f86bf0bee4561763cbe4b1a4f183e1a3d /src/libsyntax/ext | |
| parent | dd6e8d45e183861d44ed91a99f0a50403b2776a3 (diff) | |
| download | rust-2e812e10f4ece10d90ae3315aba16b88c5e870eb.tar.gz rust-2e812e10f4ece10d90ae3315aba16b88c5e870eb.zip | |
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).
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 14 |
1 files changed, 7 insertions, 7 deletions
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<T, F, G>(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<Block>, - opt_ident: Option<Ident>, - fld: &mut MacroExpander) -> (P<Block>, Option<Ident>) { + opt_ident: Option<SpannedIdent>, + fld: &mut MacroExpander) -> (P<Block>, Option<SpannedIdent>) { 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<Block>, // 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<Block>, 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) } |
