Skip to content

Commit 1930483

Browse files
committed
Auto merge of #33179 - Manishearth:breaking-batch, r=Manishearth
Batch up breaking libsyntax changes Contains: - #33125 - #33041 - #33157 cc #31645
2 parents 91aea5c + a31658d commit 1930483

File tree

129 files changed

+885
-911
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+885
-911
lines changed

src/etc/generate-keyword-tests.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@
3434
// option. This file may not be copied, modified, or distributed
3535
// except according to those terms.
3636
37+
// compile-flags: -Z parse-only
38+
3739
// This file was auto-generated using 'src/etc/generate-keyword-tests.py %s'
3840
3941
fn main() {
40-
let %s = "foo"; //~ error: ident
42+
let %s = "foo"; //~ error: expected pattern, found keyword `%s`
4143
}
4244
"""
4345

4446
test_dir = os.path.abspath(
45-
os.path.join(os.path.dirname(__file__), '../test/compile-fail')
47+
os.path.join(os.path.dirname(__file__), '../test/parse-fail')
4648
)
4749

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

5557
with open(test_file, 'wt') as f:
56-
f.write(template % (datetime.datetime.now().year, kw, kw))
58+
f.write(template % (datetime.datetime.now().year, kw, kw, kw))
5759

5860
# mark file read-only
5961
os.chmod(test_file, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)

src/librustc/hir/fold.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use syntax::attr::ThinAttributesExt;
1818
use hir;
1919
use syntax::codemap::{respan, Span, Spanned};
2020
use syntax::ptr::P;
21-
use syntax::parse::token;
21+
use syntax::parse::token::keywords;
2222
use syntax::util::move_map::MoveMap;
2323

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

869869
let crate_mod = folder.fold_item(hir::Item {
870-
name: token::special_idents::invalid.name,
870+
name: keywords::Invalid.name(),
871871
attrs: attrs,
872872
id: DUMMY_NODE_ID,
873873
vis: hir::Public,
@@ -1060,10 +1060,11 @@ pub fn noop_fold_expr<T: Folder>(Expr { id, node, span, attrs }: Expr, folder: &
10601060
arms.move_map(|x| folder.fold_arm(x)),
10611061
source)
10621062
}
1063-
ExprClosure(capture_clause, decl, body) => {
1063+
ExprClosure(capture_clause, decl, body, fn_decl_span) => {
10641064
ExprClosure(capture_clause,
10651065
folder.fold_fn_decl(decl),
1066-
folder.fold_block(body))
1066+
folder.fold_block(body),
1067+
folder.new_span(fn_decl_span))
10671068
}
10681069
ExprBlock(blk) => ExprBlock(folder.fold_block(blk)),
10691070
ExprAssign(el, er) => {

src/librustc/hir/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
785785
visitor.visit_expr(subexpression);
786786
walk_list!(visitor, visit_arm, arms);
787787
}
788-
ExprClosure(_, ref function_declaration, ref body) => {
788+
ExprClosure(_, ref function_declaration, ref body, _fn_decl_span) => {
789789
visitor.visit_fn(FnKind::Closure(expression.attrs.as_attr_slice()),
790790
function_declaration,
791791
body,

src/librustc/hir/lowering.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1260,11 +1260,12 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
12601260
arms.iter().map(|x| lower_arm(lctx, x)).collect(),
12611261
hir::MatchSource::Normal)
12621262
}
1263-
ExprKind::Closure(capture_clause, ref decl, ref body) => {
1263+
ExprKind::Closure(capture_clause, ref decl, ref body, fn_decl_span) => {
12641264
lctx.with_parent_def(e.id, || {
12651265
hir::ExprClosure(lower_capture_clause(lctx, capture_clause),
12661266
lower_fn_decl(lctx, decl),
1267-
lower_block(lctx, body))
1267+
lower_block(lctx, body),
1268+
fn_decl_span)
12681269
})
12691270
}
12701271
ExprKind::Block(ref blk) => hir::ExprBlock(lower_block(lctx, blk)),

src/librustc/hir/map/blocks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'a> FnLikeNode<'a> {
250250
}
251251
}
252252
map::NodeExpr(e) => match e.node {
253-
ast::ExprClosure(_, ref decl, ref block) =>
253+
ast::ExprClosure(_, ref decl, ref block, _fn_decl_span) =>
254254
closure(ClosureParts::new(&decl,
255255
&block,
256256
e.id,

src/librustc/hir/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -949,8 +949,10 @@ pub enum Expr_ {
949949
/// A `match` block, with a source that indicates whether or not it is
950950
/// the result of a desugaring, and if so, which kind.
951951
ExprMatch(P<Expr>, HirVec<Arm>, MatchSource),
952-
/// A closure (for example, `move |a, b, c| {a + b + c}`)
953-
ExprClosure(CaptureClause, P<FnDecl>, P<Block>),
952+
/// A closure (for example, `move |a, b, c| {a + b + c}`).
953+
///
954+
/// The final span is the span of the argument block `|...|`
955+
ExprClosure(CaptureClause, P<FnDecl>, P<Block>, Span),
954956
/// A block (`{ ... }`)
955957
ExprBlock(P<Block>),
956958

src/librustc/hir/print.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ use syntax::abi::Abi;
1414
use syntax::ast;
1515
use syntax::codemap::{self, CodeMap, BytePos, Spanned};
1616
use syntax::errors;
17-
use syntax::parse::token::{self, BinOpToken};
17+
use syntax::parse::token::{self, keywords, BinOpToken};
1818
use syntax::parse::lexer::comments;
19-
use syntax::parse;
2019
use syntax::print::pp::{self, break_offset, word, space, hardbreak};
2120
use syntax::print::pp::{Breaks, eof};
2221
use syntax::print::pp::Breaks::{Consistent, Inconsistent};
@@ -1392,7 +1391,7 @@ impl<'a> State<'a> {
13921391
}
13931392
self.bclose_(expr.span, indent_unit)?;
13941393
}
1395-
hir::ExprClosure(capture_clause, ref decl, ref body) => {
1394+
hir::ExprClosure(capture_clause, ref decl, ref body, _fn_decl_span) => {
13961395
self.print_capture_clause(capture_clause)?;
13971396

13981397
self.print_fn_block_args(&decl)?;
@@ -2209,9 +2208,8 @@ impl<'a> State<'a> {
22092208
hir::TyInfer if is_closure => self.print_pat(&input.pat)?,
22102209
_ => {
22112210
match input.pat.node {
2212-
PatKind::Ident(_, ref path1, _) if
2213-
path1.node.name ==
2214-
parse::token::special_idents::invalid.name => {
2211+
PatKind::Ident(_, ref path1, _)
2212+
if path1.node.name == keywords::Invalid.name() => {
22152213
// Do nothing.
22162214
}
22172215
_ => {

src/librustc/middle/expr_use_visitor.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
537537
self.consume_expr(&count);
538538
}
539539

540-
hir::ExprClosure(..) => {
541-
self.walk_captures(expr)
540+
hir::ExprClosure(_, _, _, fn_decl_span) => {
541+
self.walk_captures(expr, fn_decl_span)
542542
}
543543

544544
hir::ExprBox(ref base) => {
@@ -1142,7 +1142,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
11421142
}));
11431143
}
11441144

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

11481148
self.tcx().with_freevars(closure_expr.id, |freevars| {
@@ -1152,7 +1152,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
11521152
closure_expr_id: closure_expr.id };
11531153
let upvar_capture = self.typer.upvar_capture(upvar_id).unwrap();
11541154
let cmt_var = return_if_err!(self.cat_captured_var(closure_expr.id,
1155-
closure_expr.span,
1155+
fn_decl_span,
11561156
freevar.def));
11571157
match upvar_capture {
11581158
ty::UpvarCapture::ByValue => {
@@ -1161,7 +1161,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
11611161
}
11621162
ty::UpvarCapture::ByRef(upvar_borrow) => {
11631163
self.delegate.borrow(closure_expr.id,
1164-
closure_expr.span,
1164+
fn_decl_span,
11651165
cmt_var,
11661166
upvar_borrow.region,
11671167
upvar_borrow.kind,

src/librustc/middle/liveness.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ use std::io;
125125
use std::rc::Rc;
126126
use syntax::ast::{self, NodeId};
127127
use syntax::codemap::{BytePos, original_sp, Span};
128-
use syntax::parse::token::special_idents;
128+
use syntax::parse::token::keywords;
129129
use syntax::ptr::P;
130130

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

951-
hir::ExprClosure(_, _, ref blk) => {
951+
hir::ExprClosure(_, _, ref blk, _) => {
952952
debug!("{} is an ExprClosure",
953953
expr_to_string(expr));
954954

@@ -1578,7 +1578,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
15781578
let var = self.variable(p_id, sp);
15791579
// Ignore unused self.
15801580
let name = path1.node;
1581-
if name != special_idents::self_.name {
1581+
if name != keywords::SelfValue.name() {
15821582
if !self.warn_about_unused(sp, p_id, entry_ln, var) {
15831583
if self.live_on_entry(entry_ln, var).is_none() {
15841584
self.report_dead_assign(p_id, sp, var, true);

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
728728
};
729729

730730
match fn_expr.node {
731-
hir::ExprClosure(_, _, ref body) => body.id,
731+
hir::ExprClosure(_, _, ref body, _) => body.id,
732732
_ => bug!()
733733
}
734734
};

src/librustc/middle/resolve_lifetime.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use std::fmt;
2929
use std::mem::replace;
3030
use syntax::ast;
3131
use syntax::codemap::Span;
32-
use syntax::parse::token::special_idents;
32+
use syntax::parse::token::keywords;
3333
use util::nodemap::NodeMap;
3434

3535
use hir;
@@ -245,7 +245,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
245245
}
246246

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

675-
let special_idents = [special_idents::static_lifetime];
676675
for lifetime in lifetimes {
677-
if special_idents.iter().any(|&i| i.name == lifetime.lifetime.name) {
676+
if lifetime.lifetime.name == keywords::StaticLifetime.name() {
678677
span_err!(self.sess, lifetime.lifetime.span, E0262,
679678
"invalid lifetime parameter name: `{}`", lifetime.lifetime.name);
680679
}

src/librustc/mir/repr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub struct ArgDecl<'tcx> {
200200
/// and has to be collected from multiple actual arguments.
201201
pub spread: bool,
202202

203-
/// Either special_idents::invalid or the name of a single-binding
203+
/// Either keywords::Invalid or the name of a single-binding
204204
/// pattern associated with this argument. Useful for debuginfo.
205205
pub debug_name: Name
206206
}

src/librustc/ty/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use std::hash::{Hash, Hasher};
4444
use std::rc::Rc;
4545
use syntax::ast::{self, Name, NodeId};
4646
use syntax::attr;
47-
use syntax::parse::token::{self, special_idents};
47+
use syntax::parse::token::{self, keywords};
4848

4949
use hir;
5050

@@ -1069,7 +1069,7 @@ impl<'tcx> TyCtxt<'tcx> {
10691069
}
10701070

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

10751075
pub fn mk_param_from_def(&self, def: &ty::TypeParameterDef) -> Ty<'tcx> {

src/librustc/ty/sty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::ops;
2424
use std::mem;
2525
use syntax::abi;
2626
use syntax::ast::{self, Name};
27-
use syntax::parse::token::special_idents;
27+
use syntax::parse::token::keywords;
2828

2929
use serialize::{Decodable, Decoder};
3030

@@ -533,7 +533,7 @@ impl ParamTy {
533533
}
534534

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

539539
pub fn for_def(def: &ty::TypeParameterDef) -> ParamTy {

src/librustc_borrowck/borrowck/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ pub fn closure_to_block(closure_id: ast::NodeId,
415415
tcx: &TyCtxt) -> ast::NodeId {
416416
match tcx.map.get(closure_id) {
417417
hir_map::NodeExpr(expr) => match expr.node {
418-
hir::ExprClosure(_, _, ref block) => {
418+
hir::ExprClosure(_, _, ref block, _) => {
419419
block.id
420420
}
421421
_ => {

src/librustc_mir/build/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc::hir::pat_util::pat_is_binding;
1818
use std::ops::{Index, IndexMut};
1919
use syntax::ast;
2020
use syntax::codemap::Span;
21-
use syntax::parse::token;
21+
use syntax::parse::token::keywords;
2222

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

299-
let mut name = token::special_idents::invalid.name;
299+
let mut name = keywords::Invalid.name();
300300
if let Some(pat) = pattern {
301301
if let hir::PatKind::Ident(_, ref ident, _) = pat.node {
302302
if pat_is_binding(&self.hir.tcx().def_map.borrow(), pat) {

src/librustc_mir/hair/cx/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ fn convert_var<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
725725
let body_id = match cx.tcx.map.find(closure_expr_id) {
726726
Some(map::NodeExpr(expr)) => {
727727
match expr.node {
728-
hir::ExprClosure(_, _, ref body) => body.id,
728+
hir::ExprClosure(_, _, ref body, _) => body.id,
729729
_ => {
730730
span_bug!(expr.span, "closure expr is not a closure expr");
731731
}

src/librustc_passes/loops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
4848
hir::ExprLoop(ref b, _) => {
4949
self.with_context(Loop, |v| v.visit_block(&b));
5050
}
51-
hir::ExprClosure(_, _, ref b) => {
51+
hir::ExprClosure(_, _, ref b, _) => {
5252
self.with_context(Closure, |v| v.visit_block(&b));
5353
}
5454
hir::ExprBreak(_) => self.require_loop("break", e.span),

src/librustc_resolve/build_reduced_graph.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,14 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
112112
!segment.parameters.bindings().is_empty()
113113
});
114114
if found_param {
115-
self.session.span_err(path.span,
116-
"type or lifetime parameter is found in import path");
115+
self.session.span_err(path.span, "type or lifetime parameters in import path");
117116
}
118117

119118
// Checking for special identifiers in path
120119
// prevent `self` or `super` at beginning of global path
121120
if path.global && path.segments.len() > 0 {
122121
let first = path.segments[0].identifier.name;
123-
if first == keywords::Super.to_name() || first == keywords::SelfValue.to_name() {
122+
if first == keywords::Super.name() || first == keywords::SelfValue.name() {
124123
self.session.add_lint(
125124
lint::builtin::SUPER_OR_SELF_IN_GLOBAL_PATH, id, path.span,
126125
format!("expected identifier, found keyword `{}`", first)

0 commit comments

Comments
 (0)