Skip to content

Commit ea0dc92

Browse files
authored
Auto merge of #34424 - jseyfried:breaking_batch, r=Manishearth
Batch up libsyntax breaking changes Batch of the following syntax-[breaking-change] changes: - #34213: Add a variant `Macro` to `TraitItemKind` - #34368: Merge the variant `QPath` of `PatKind` into the variant `PatKind::Path` - #34385: Move `syntax::ast::TokenTree` into a new module `syntax::tokenstream` - #33943: - Remove the type parameter from `visit::Visitor` - Remove `attr::WithAttrs` -- use `attr::HasAttrs` instead. - Change `fold_tt`/`fold_tts` to take token trees by value and avoid wrapping token trees in `Rc`. - Remove the field `ctxt` of `ast::Mac_` - Remove inherent method `attrs()` of types -- use the method `attrs` of `HasAttrs` instead. - #34316: - Remove `ast::Decl`/`ast::DeclKind` and add variants `Local` and `Item` to `StmtKind`. - Move the node id for statements from the `StmtKind` variants to a field of `Stmt` (making `Stmt` a struct instead of an alias for `Spanned<StmtKind>`) - Rename `ast::ExprKind::Again` to `Continue`. - #34339: Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>` - Use `.into()` in convert between `Vec<Attribute>` and `ThinVec<Attribute>` - Use autoderef instead of `.as_attr_slice()` - #34436: Remove the optional expression from `ast::Block` and instead use a `StmtKind::Expr` at the end of the statement list. - #34403: Move errors into a separate crate (unlikely to cause breakage)
2 parents a0f572e + 360dcae commit ea0dc92

File tree

292 files changed

+3969
-3646
lines changed

Some content is hidden

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

292 files changed

+3969
-3646
lines changed

mk/crates.mk

+23-21
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ TARGET_CRATES := libc std term \
5757
panic_abort panic_unwind unwind
5858
RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
5959
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
60-
rustc_data_structures rustc_platform_intrinsics \
60+
rustc_data_structures rustc_platform_intrinsics rustc_errors \
6161
rustc_plugin rustc_metadata rustc_passes rustc_save_analysis \
6262
rustc_const_eval rustc_const_math rustc_incremental
63-
HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros \
63+
HOST_CRATES := syntax syntax_ext syntax_pos $(RUSTC_CRATES) rustdoc fmt_macros \
6464
flate arena graphviz rbml log serialize
6565
TOOLS := compiletest rustdoc rustc rustbook error_index_generator
6666

@@ -98,43 +98,45 @@ DEPS_serialize := std log
9898
DEPS_term := std
9999
DEPS_test := std getopts term native:rust_test_helpers
100100

101-
DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode
102-
DEPS_syntax_ext := syntax fmt_macros
101+
DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode rustc_errors syntax_pos
102+
DEPS_syntax_ext := syntax syntax_pos rustc_errors fmt_macros
103+
DEPS_syntax_pos := serialize
103104

104105
DEPS_rustc_const_math := std syntax log serialize
105106
DEPS_rustc_const_eval := rustc_const_math rustc syntax log serialize \
106-
rustc_back graphviz
107+
rustc_back graphviz syntax_pos
107108

108109
DEPS_rustc := syntax fmt_macros flate arena serialize getopts rbml \
109110
log graphviz rustc_llvm rustc_back rustc_data_structures\
110-
rustc_const_math
111+
rustc_const_math syntax_pos rustc_errors
111112
DEPS_rustc_back := std syntax flate log libc
112-
DEPS_rustc_borrowck := rustc log graphviz syntax rustc_mir
113+
DEPS_rustc_borrowck := rustc log graphviz syntax syntax_pos rustc_errors rustc_mir
113114
DEPS_rustc_data_structures := std log serialize
114115
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
115116
rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
116117
rustc_trans rustc_privacy rustc_lint rustc_plugin \
117118
rustc_metadata syntax_ext rustc_passes rustc_save_analysis rustc_const_eval \
118-
rustc_incremental
119-
DEPS_rustc_lint := rustc log syntax rustc_const_eval
119+
rustc_incremental syntax_pos rustc_errors
120+
DEPS_rustc_errors := log libc serialize syntax_pos
121+
DEPS_rustc_lint := rustc log syntax syntax_pos rustc_const_eval
120122
DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
121-
DEPS_rustc_metadata := rustc syntax rbml rustc_const_math
122-
DEPS_rustc_passes := syntax rustc core rustc_const_eval
123-
DEPS_rustc_mir := rustc syntax rustc_const_math rustc_const_eval rustc_bitflags
124-
DEPS_rustc_resolve := arena rustc log syntax
123+
DEPS_rustc_metadata := rustc syntax syntax_pos rustc_errors rbml rustc_const_math
124+
DEPS_rustc_passes := syntax syntax_pos rustc core rustc_const_eval rustc_errors
125+
DEPS_rustc_mir := rustc syntax syntax_pos rustc_const_math rustc_const_eval rustc_bitflags
126+
DEPS_rustc_resolve := arena rustc log syntax syntax_pos rustc_errors
125127
DEPS_rustc_platform_intrinsics := std
126-
DEPS_rustc_plugin := rustc rustc_metadata syntax
127-
DEPS_rustc_privacy := rustc log syntax
128+
DEPS_rustc_plugin := rustc rustc_metadata syntax syntax_pos rustc_errors
129+
DEPS_rustc_privacy := rustc log syntax syntax_pos
128130
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
129131
log syntax serialize rustc_llvm rustc_platform_intrinsics \
130-
rustc_const_math rustc_const_eval rustc_incremental
131-
DEPS_rustc_incremental := rbml rustc serialize rustc_data_structures
132-
DEPS_rustc_save_analysis := rustc log syntax serialize
133-
DEPS_rustc_typeck := rustc syntax rustc_platform_intrinsics rustc_const_math \
134-
rustc_const_eval
132+
rustc_const_math rustc_const_eval rustc_incremental rustc_errors syntax_pos
133+
DEPS_rustc_incremental := rbml rustc syntax_pos serialize rustc_data_structures
134+
DEPS_rustc_save_analysis := rustc log syntax syntax_pos serialize
135+
DEPS_rustc_typeck := rustc syntax syntax_pos rustc_platform_intrinsics rustc_const_math \
136+
rustc_const_eval rustc_errors
135137

136138
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
137-
test rustc_lint rustc_const_eval
139+
test rustc_lint rustc_const_eval syntax_pos
138140

139141

140142
TOOL_DEPS_compiletest := test getopts log serialize

src/doc/book/compiler-plugins.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ extern crate syntax;
4545
extern crate rustc;
4646
extern crate rustc_plugin;
4747
48-
use syntax::codemap::Span;
4948
use syntax::parse::token;
5049
use syntax::ast::TokenTree;
5150
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
5251
use syntax::ext::build::AstBuilder; // trait for expr_usize
52+
use syntax_pos::Span;
5353
use rustc_plugin::Registry;
5454
5555
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])

src/grammar/verify.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ use std::rc::Rc;
3232
use syntax::ast;
3333
use syntax::ast::Name;
3434
use syntax::codemap;
35-
use syntax::codemap::Pos;
3635
use syntax::parse::token::{self, BinOpToken, DelimToken, Lit, Token};
3736
use syntax::parse::lexer::TokenAndSpan;
37+
use syntax_pos::Pos;
3838

3939
fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
4040
fn id() -> token::Token {
@@ -233,10 +233,10 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>, surrogate_
233233
lo -= surrogate_pairs_pos.binary_search(&(lo as usize)).unwrap_or_else(|x| x) as u32;
234234
hi -= surrogate_pairs_pos.binary_search(&(hi as usize)).unwrap_or_else(|x| x) as u32;
235235

236-
let sp = codemap::Span {
237-
lo: codemap::BytePos(lo),
238-
hi: codemap::BytePos(hi),
239-
expn_id: codemap::NO_EXPANSION
236+
let sp = syntax_pos::Span {
237+
lo: syntax_pos::BytePos(lo),
238+
hi: syntax_pos::BytePos(hi),
239+
expn_id: syntax_pos::NO_EXPANSION
240240
};
241241

242242
TokenAndSpan {

src/librustc/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ rustc_back = { path = "../librustc_back" }
1919
rustc_bitflags = { path = "../librustc_bitflags" }
2020
rustc_const_math = { path = "../librustc_const_math" }
2121
rustc_data_structures = { path = "../librustc_data_structures" }
22+
rustc_errors = { path = "../librustc_errors" }
2223
rustc_llvm = { path = "../librustc_llvm" }
2324
serialize = { path = "../libserialize" }
2425
syntax = { path = "../libsyntax" }
26+
syntax_pos = { path = "../libsyntax_pos" }

src/librustc/hir/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'a> CheckAttrVisitor<'a> {
9595
}
9696
}
9797

98-
impl<'a, 'v> Visitor<'v> for CheckAttrVisitor<'a> {
98+
impl<'a> Visitor for CheckAttrVisitor<'a> {
9999
fn visit_item(&mut self, item: &ast::Item) {
100100
let target = Target::from_item(item);
101101
for attr in &item.attrs {

src/librustc/hir/fold.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
use hir::*;
1515
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, Attribute, Attribute_, MetaItem};
1616
use syntax::ast::MetaItemKind;
17-
use syntax::attr::ThinAttributesExt;
1817
use hir;
19-
use syntax::codemap::{respan, Span, Spanned};
18+
use syntax_pos::Span;
19+
use syntax::codemap::{respan, Spanned};
2020
use syntax::ptr::P;
2121
use syntax::parse::token::keywords;
2222
use syntax::util::move_map::MoveMap;
@@ -292,8 +292,11 @@ pub fn noop_fold_view_path<T: Folder>(view_path: P<ViewPath>, fld: &mut T) -> P<
292292
})
293293
}
294294

295-
pub fn fold_attrs<T: Folder>(attrs: HirVec<Attribute>, fld: &mut T) -> HirVec<Attribute> {
296-
attrs.move_flat_map(|x| fld.fold_attribute(x))
295+
pub fn fold_attrs<T, F>(attrs: T, fld: &mut F) -> T
296+
where T: Into<Vec<Attribute>> + From<Vec<Attribute>>,
297+
F: Folder,
298+
{
299+
attrs.into().move_flat_map(|x| fld.fold_attribute(x)).into()
297300
}
298301

299302
pub fn noop_fold_arm<T: Folder>(Arm { attrs, pats, guard, body }: Arm, fld: &mut T) -> Arm {
@@ -461,7 +464,7 @@ pub fn noop_fold_local<T: Folder>(l: P<Local>, fld: &mut T) -> P<Local> {
461464
pat: fld.fold_pat(pat),
462465
init: init.map(|e| fld.fold_expr(e)),
463466
span: fld.new_span(span),
464-
attrs: attrs.map_thin_attrs(|attrs| fold_attrs(attrs.into(), fld).into()),
467+
attrs: fold_attrs(attrs, fld),
465468
}
466469
})
467470
}
@@ -1078,7 +1081,7 @@ pub fn noop_fold_expr<T: Folder>(Expr { id, node, span, attrs }: Expr, folder: &
10781081
}
10791082
},
10801083
span: folder.new_span(span),
1081-
attrs: attrs.map_thin_attrs(|attrs| fold_attrs(attrs.into(), folder).into()),
1084+
attrs: fold_attrs(attrs, folder),
10821085
}
10831086
}
10841087

src/librustc/hir/intravisit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
2828
use syntax::abi::Abi;
2929
use syntax::ast::{NodeId, CRATE_NODE_ID, Name, Attribute};
30-
use syntax::attr::ThinAttributesExt;
31-
use syntax::codemap::{Span, Spanned};
30+
use syntax::codemap::Spanned;
31+
use syntax_pos::Span;
3232
use hir::*;
3333

3434
use std::cmp;
@@ -756,7 +756,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
756756
walk_list!(visitor, visit_arm, arms);
757757
}
758758
ExprClosure(_, ref function_declaration, ref body, _fn_decl_span) => {
759-
visitor.visit_fn(FnKind::Closure(expression.attrs.as_attr_slice()),
759+
visitor.visit_fn(FnKind::Closure(&expression.attrs),
760760
function_declaration,
761761
body,
762762
expression.span,

0 commit comments

Comments
 (0)