Skip to content

Commit

Permalink
Auto merge of #33179 - Manishearth:breaking-batch, r=Manishearth
Browse files Browse the repository at this point in the history
Batch up breaking libsyntax changes

Contains:

 - #33125
 - #33041
 - #33157

cc #31645
  • Loading branch information
bors committed Apr 24, 2016
2 parents 91aea5c + a31658d commit 1930483
Show file tree
Hide file tree
Showing 129 changed files with 885 additions and 911 deletions.
8 changes: 5 additions & 3 deletions src/etc/generate-keyword-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: -Z parse-only
// This file was auto-generated using 'src/etc/generate-keyword-tests.py %s'
fn main() {
let %s = "foo"; //~ error: ident
let %s = "foo"; //~ error: expected pattern, found keyword `%s`
}
"""

test_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), '../test/compile-fail')
os.path.join(os.path.dirname(__file__), '../test/parse-fail')
)

for kw in sys.argv[1:]:
Expand All @@ -53,7 +55,7 @@
os.chmod(test_file, stat.S_IWUSR)

with open(test_file, 'wt') as f:
f.write(template % (datetime.datetime.now().year, kw, kw))
f.write(template % (datetime.datetime.now().year, kw, kw, kw))

# mark file read-only
os.chmod(test_file, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
9 changes: 5 additions & 4 deletions src/librustc/hir/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use syntax::attr::ThinAttributesExt;
use hir;
use syntax::codemap::{respan, Span, Spanned};
use syntax::ptr::P;
use syntax::parse::token;
use syntax::parse::token::keywords;
use syntax::util::move_map::MoveMap;

pub trait Folder : Sized {
Expand Down Expand Up @@ -867,7 +867,7 @@ pub fn noop_fold_crate<T: Folder>(Crate { module, attrs, config, span,
let config = folder.fold_meta_items(config);

let crate_mod = folder.fold_item(hir::Item {
name: token::special_idents::invalid.name,
name: keywords::Invalid.name(),
attrs: attrs,
id: DUMMY_NODE_ID,
vis: hir::Public,
Expand Down Expand Up @@ -1060,10 +1060,11 @@ pub fn noop_fold_expr<T: Folder>(Expr { id, node, span, attrs }: Expr, folder: &
arms.move_map(|x| folder.fold_arm(x)),
source)
}
ExprClosure(capture_clause, decl, body) => {
ExprClosure(capture_clause, decl, body, fn_decl_span) => {
ExprClosure(capture_clause,
folder.fold_fn_decl(decl),
folder.fold_block(body))
folder.fold_block(body),
folder.new_span(fn_decl_span))
}
ExprBlock(blk) => ExprBlock(folder.fold_block(blk)),
ExprAssign(el, er) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
visitor.visit_expr(subexpression);
walk_list!(visitor, visit_arm, arms);
}
ExprClosure(_, ref function_declaration, ref body) => {
ExprClosure(_, ref function_declaration, ref body, _fn_decl_span) => {
visitor.visit_fn(FnKind::Closure(expression.attrs.as_attr_slice()),
function_declaration,
body,
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,11 +1260,12 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
arms.iter().map(|x| lower_arm(lctx, x)).collect(),
hir::MatchSource::Normal)
}
ExprKind::Closure(capture_clause, ref decl, ref body) => {
ExprKind::Closure(capture_clause, ref decl, ref body, fn_decl_span) => {
lctx.with_parent_def(e.id, || {
hir::ExprClosure(lower_capture_clause(lctx, capture_clause),
lower_fn_decl(lctx, decl),
lower_block(lctx, body))
lower_block(lctx, body),
fn_decl_span)
})
}
ExprKind::Block(ref blk) => hir::ExprBlock(lower_block(lctx, blk)),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl<'a> FnLikeNode<'a> {
}
}
map::NodeExpr(e) => match e.node {
ast::ExprClosure(_, ref decl, ref block) =>
ast::ExprClosure(_, ref decl, ref block, _fn_decl_span) =>
closure(ClosureParts::new(&decl,
&block,
e.id,
Expand Down
6 changes: 4 additions & 2 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,10 @@ pub enum Expr_ {
/// A `match` block, with a source that indicates whether or not it is
/// the result of a desugaring, and if so, which kind.
ExprMatch(P<Expr>, HirVec<Arm>, MatchSource),
/// A closure (for example, `move |a, b, c| {a + b + c}`)
ExprClosure(CaptureClause, P<FnDecl>, P<Block>),
/// A closure (for example, `move |a, b, c| {a + b + c}`).
///
/// The final span is the span of the argument block `|...|`
ExprClosure(CaptureClause, P<FnDecl>, P<Block>, Span),
/// A block (`{ ... }`)
ExprBlock(P<Block>),

Expand Down
10 changes: 4 additions & 6 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ use syntax::abi::Abi;
use syntax::ast;
use syntax::codemap::{self, CodeMap, BytePos, Spanned};
use syntax::errors;
use syntax::parse::token::{self, BinOpToken};
use syntax::parse::token::{self, keywords, BinOpToken};
use syntax::parse::lexer::comments;
use syntax::parse;
use syntax::print::pp::{self, break_offset, word, space, hardbreak};
use syntax::print::pp::{Breaks, eof};
use syntax::print::pp::Breaks::{Consistent, Inconsistent};
Expand Down Expand Up @@ -1392,7 +1391,7 @@ impl<'a> State<'a> {
}
self.bclose_(expr.span, indent_unit)?;
}
hir::ExprClosure(capture_clause, ref decl, ref body) => {
hir::ExprClosure(capture_clause, ref decl, ref body, _fn_decl_span) => {
self.print_capture_clause(capture_clause)?;

self.print_fn_block_args(&decl)?;
Expand Down Expand Up @@ -2209,9 +2208,8 @@ impl<'a> State<'a> {
hir::TyInfer if is_closure => self.print_pat(&input.pat)?,
_ => {
match input.pat.node {
PatKind::Ident(_, ref path1, _) if
path1.node.name ==
parse::token::special_idents::invalid.name => {
PatKind::Ident(_, ref path1, _)
if path1.node.name == keywords::Invalid.name() => {
// Do nothing.
}
_ => {
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
self.consume_expr(&count);
}

hir::ExprClosure(..) => {
self.walk_captures(expr)
hir::ExprClosure(_, _, _, fn_decl_span) => {
self.walk_captures(expr, fn_decl_span)
}

hir::ExprBox(ref base) => {
Expand Down Expand Up @@ -1142,7 +1142,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
}));
}

fn walk_captures(&mut self, closure_expr: &hir::Expr) {
fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
debug!("walk_captures({:?})", closure_expr);

self.tcx().with_freevars(closure_expr.id, |freevars| {
Expand All @@ -1152,7 +1152,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
closure_expr_id: closure_expr.id };
let upvar_capture = self.typer.upvar_capture(upvar_id).unwrap();
let cmt_var = return_if_err!(self.cat_captured_var(closure_expr.id,
closure_expr.span,
fn_decl_span,
freevar.def));
match upvar_capture {
ty::UpvarCapture::ByValue => {
Expand All @@ -1161,7 +1161,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
}
ty::UpvarCapture::ByRef(upvar_borrow) => {
self.delegate.borrow(closure_expr.id,
closure_expr.span,
fn_decl_span,
cmt_var,
upvar_borrow.region,
upvar_borrow.kind,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ use std::io;
use std::rc::Rc;
use syntax::ast::{self, NodeId};
use syntax::codemap::{BytePos, original_sp, Span};
use syntax::parse::token::special_idents;
use syntax::parse::token::keywords;
use syntax::ptr::P;

use hir::Expr;
Expand Down Expand Up @@ -948,7 +948,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
self.propagate_through_expr(&e, succ)
}

hir::ExprClosure(_, _, ref blk) => {
hir::ExprClosure(_, _, ref blk, _) => {
debug!("{} is an ExprClosure",
expr_to_string(expr));

Expand Down Expand Up @@ -1578,7 +1578,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let var = self.variable(p_id, sp);
// Ignore unused self.
let name = path1.node;
if name != special_idents::self_.name {
if name != keywords::SelfValue.name() {
if !self.warn_about_unused(sp, p_id, entry_ln, var) {
if self.live_on_entry(entry_ln, var).is_none() {
self.report_dead_assign(p_id, sp, var, true);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
};

match fn_expr.node {
hir::ExprClosure(_, _, ref body) => body.id,
hir::ExprClosure(_, _, ref body, _) => body.id,
_ => bug!()
}
};
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::fmt;
use std::mem::replace;
use syntax::ast;
use syntax::codemap::Span;
use syntax::parse::token::special_idents;
use syntax::parse::token::keywords;
use util::nodemap::NodeMap;

use hir;
Expand Down Expand Up @@ -245,7 +245,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
}

fn visit_lifetime(&mut self, lifetime_ref: &hir::Lifetime) {
if lifetime_ref.name == special_idents::static_lifetime.name {
if lifetime_ref.name == keywords::StaticLifetime.name() {
self.insert_lifetime(lifetime_ref, DefStaticRegion);
return;
}
Expand Down Expand Up @@ -672,9 +672,8 @@ impl<'a> LifetimeContext<'a> {
for i in 0..lifetimes.len() {
let lifetime_i = &lifetimes[i];

let special_idents = [special_idents::static_lifetime];
for lifetime in lifetimes {
if special_idents.iter().any(|&i| i.name == lifetime.lifetime.name) {
if lifetime.lifetime.name == keywords::StaticLifetime.name() {
span_err!(self.sess, lifetime.lifetime.span, E0262,
"invalid lifetime parameter name: `{}`", lifetime.lifetime.name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub struct ArgDecl<'tcx> {
/// and has to be collected from multiple actual arguments.
pub spread: bool,

/// Either special_idents::invalid or the name of a single-binding
/// Either keywords::Invalid or the name of a single-binding
/// pattern associated with this argument. Useful for debuginfo.
pub debug_name: Name
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use std::hash::{Hash, Hasher};
use std::rc::Rc;
use syntax::ast::{self, Name, NodeId};
use syntax::attr;
use syntax::parse::token::{self, special_idents};
use syntax::parse::token::{self, keywords};

use hir;

Expand Down Expand Up @@ -1069,7 +1069,7 @@ impl<'tcx> TyCtxt<'tcx> {
}

pub fn mk_self_type(&self) -> Ty<'tcx> {
self.mk_param(subst::SelfSpace, 0, special_idents::type_self.name)
self.mk_param(subst::SelfSpace, 0, keywords::SelfType.name())
}

pub fn mk_param_from_def(&self, def: &ty::TypeParameterDef) -> Ty<'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::ops;
use std::mem;
use syntax::abi;
use syntax::ast::{self, Name};
use syntax::parse::token::special_idents;
use syntax::parse::token::keywords;

use serialize::{Decodable, Decoder};

Expand Down Expand Up @@ -533,7 +533,7 @@ impl ParamTy {
}

pub fn for_self() -> ParamTy {
ParamTy::new(subst::SelfSpace, 0, special_idents::type_self.name)
ParamTy::new(subst::SelfSpace, 0, keywords::SelfType.name())
}

pub fn for_def(def: &ty::TypeParameterDef) -> ParamTy {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ pub fn closure_to_block(closure_id: ast::NodeId,
tcx: &TyCtxt) -> ast::NodeId {
match tcx.map.get(closure_id) {
hir_map::NodeExpr(expr) => match expr.node {
hir::ExprClosure(_, _, ref block) => {
hir::ExprClosure(_, _, ref block, _) => {
block.id
}
_ => {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc::hir::pat_util::pat_is_binding;
use std::ops::{Index, IndexMut};
use syntax::ast;
use syntax::codemap::Span;
use syntax::parse::token;
use syntax::parse::token::keywords;

pub struct Builder<'a, 'tcx: 'a> {
hir: Cx<'a, 'tcx>,
Expand Down Expand Up @@ -238,7 +238,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
ty::UpvarCapture::ByRef(..) => true
});
let mut decl = UpvarDecl {
debug_name: token::special_idents::invalid.name,
debug_name: keywords::Invalid.name(),
by_ref: by_ref
};
if let Some(hir::map::NodeLocal(pat)) = tcx.map.find(fv.def.var_id()) {
Expand Down Expand Up @@ -296,7 +296,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
self.schedule_drop(pattern.as_ref().map_or(ast_block.span, |pat| pat.span),
argument_extent, &lvalue, ty);

let mut name = token::special_idents::invalid.name;
let mut name = keywords::Invalid.name();
if let Some(pat) = pattern {
if let hir::PatKind::Ident(_, ref ident, _) = pat.node {
if pat_is_binding(&self.hir.tcx().def_map.borrow(), pat) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ fn convert_var<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
let body_id = match cx.tcx.map.find(closure_expr_id) {
Some(map::NodeExpr(expr)) => {
match expr.node {
hir::ExprClosure(_, _, ref body) => body.id,
hir::ExprClosure(_, _, ref body, _) => body.id,
_ => {
span_bug!(expr.span, "closure expr is not a closure expr");
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
hir::ExprLoop(ref b, _) => {
self.with_context(Loop, |v| v.visit_block(&b));
}
hir::ExprClosure(_, _, ref b) => {
hir::ExprClosure(_, _, ref b, _) => {
self.with_context(Closure, |v| v.visit_block(&b));
}
hir::ExprBreak(_) => self.require_loop("break", e.span),
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,14 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
!segment.parameters.bindings().is_empty()
});
if found_param {
self.session.span_err(path.span,
"type or lifetime parameter is found in import path");
self.session.span_err(path.span, "type or lifetime parameters in import path");
}

// Checking for special identifiers in path
// prevent `self` or `super` at beginning of global path
if path.global && path.segments.len() > 0 {
let first = path.segments[0].identifier.name;
if first == keywords::Super.to_name() || first == keywords::SelfValue.to_name() {
if first == keywords::Super.name() || first == keywords::SelfValue.name() {
self.session.add_lint(
lint::builtin::SUPER_OR_SELF_IN_GLOBAL_PATH, id, path.span,
format!("expected identifier, found keyword `{}`", first)
Expand Down
Loading

0 comments on commit 1930483

Please sign in to comment.