1
Fork 0

librustc: Fix the issue with labels shadowing variable names by making

the leading quote part of the identifier for the purposes of hygiene.

This adopts @jbclements' solution to #14539.

I'm not sure if this is a breaking change or not.

Closes #12512.

[breaking-change]
This commit is contained in:
Patrick Walton 2014-06-10 13:54:13 -07:00 committed by Alex Crichton
parent e7f11f20e5
commit 2ed4734873
17 changed files with 159 additions and 89 deletions

View file

@ -85,6 +85,7 @@ pub trait AstBuilder {
typ: P<ast::Ty>,
ex: Gc<ast::Expr>)
-> Gc<ast::Stmt>;
fn stmt_item(&self, sp: Span, item: Gc<ast::Item>) -> Gc<ast::Stmt>;
// blocks
fn block(&self, span: Span, stmts: Vec<Gc<ast::Stmt>>,
@ -239,6 +240,14 @@ pub trait AstBuilder {
vi: Vec<ast::ViewItem>,
items: Vec<Gc<ast::Item>>) -> Gc<ast::Item>;
fn item_static(&self,
span: Span,
name: Ident,
ty: P<ast::Ty>,
mutbl: ast::Mutability,
expr: Gc<ast::Expr>)
-> Gc<ast::Item>;
fn item_ty_poly(&self,
span: Span,
name: Ident,
@ -484,11 +493,19 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
box(GC) respan(sp, ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID))
}
fn block(&self, span: Span, stmts: Vec<Gc<ast::Stmt>>,
expr: Option<Gc<Expr>>) -> P<ast::Block> {
fn block(&self,
span: Span,
stmts: Vec<Gc<ast::Stmt>>,
expr: Option<Gc<Expr>>)
-> P<ast::Block> {
self.block_all(span, Vec::new(), stmts, expr)
}
fn stmt_item(&self, sp: Span, item: Gc<ast::Item>) -> Gc<ast::Stmt> {
let decl = respan(sp, ast::DeclItem(item));
box(GC) respan(sp, ast::StmtDecl(box(GC) decl, ast::DUMMY_NODE_ID))
}
fn block_expr(&self, expr: Gc<ast::Expr>) -> P<ast::Block> {
self.block_all(expr.span, Vec::new(), Vec::new(), Some(expr))
}
@ -942,6 +959,16 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
)
}
fn item_static(&self,
span: Span,
name: Ident,
ty: P<ast::Ty>,
mutbl: ast::Mutability,
expr: Gc<ast::Expr>)
-> Gc<ast::Item> {
self.item(span, name, Vec::new(), ast::ItemStatic(ty, mutbl, expr))
}
fn item_ty_poly(&self, span: Span, name: Ident, ty: P<ast::Ty>,
generics: Generics) -> Gc<ast::Item> {
self.item(span, name, Vec::new(), ast::ItemTy(ty, generics))