Skip to content

Commit 262b241

Browse files
authored
Rollup merge of rust-lang#58133 - taiki-e:libsyntax_ext-2018, r=Centril
libsyntax_ext => 2018 Transitions `libsyntax_ext` to Rust 2018; cc rust-lang#58099 r? @Centril
2 parents 281a26b + 94f121f commit 262b241

35 files changed

+269
-268
lines changed

src/libsyntax_ext/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
authors = ["The Rust Project Developers"]
33
name = "syntax_ext"
44
version = "0.0.0"
5+
edition = "2018"
56

67
[lib]
78
name = "syntax_ext"

src/libsyntax_ext/asm.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
// Inline assembly support.
22
//
3-
use self::State::*;
3+
use State::*;
44

55
use rustc_data_structures::thin_vec::ThinVec;
66

7-
use errors::DiagnosticBuilder;
7+
use crate::errors::DiagnosticBuilder;
8+
89
use syntax::ast;
9-
use syntax::ext::base;
10-
use syntax::ext::base::*;
10+
use syntax::ext::base::{self, *};
1111
use syntax::feature_gate;
1212
use syntax::parse::{self, token};
1313
use syntax::ptr::P;
1414
use syntax::symbol::Symbol;
1515
use syntax::ast::AsmDialect;
1616
use syntax_pos::Span;
1717
use syntax::tokenstream;
18+
use syntax::{span_err, struct_span_err};
1819

1920
enum State {
2021
Asm,
@@ -40,7 +41,7 @@ impl State {
4041

4142
const OPTIONS: &[&str] = &["volatile", "alignstack", "intel"];
4243

43-
pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
44+
pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt<'_>,
4445
sp: Span,
4546
tts: &[tokenstream::TokenTree])
4647
-> Box<dyn base::MacResult + 'cx> {

src/libsyntax_ext/assert.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use errors::DiagnosticBuilder;
1+
use crate::errors::DiagnosticBuilder;
2+
23
use syntax::ast::{self, *};
34
use syntax::source_map::Spanned;
45
use syntax::ext::base::*;
@@ -11,7 +12,7 @@ use syntax::tokenstream::{TokenStream, TokenTree};
1112
use syntax_pos::{Span, DUMMY_SP};
1213

1314
pub fn expand_assert<'cx>(
14-
cx: &'cx mut ExtCtxt,
15+
cx: &'cx mut ExtCtxt<'_>,
1516
sp: Span,
1617
tts: &[TokenTree],
1718
) -> Box<dyn MacResult + 'cx> {

src/libsyntax_ext/cfg.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
/// a literal `true` or `false` based on whether the given cfg matches the
33
/// current compilation environment.
44
5-
use errors::DiagnosticBuilder;
5+
use crate::errors::DiagnosticBuilder;
6+
67
use syntax::ast;
7-
use syntax::ext::base::*;
8-
use syntax::ext::base;
8+
use syntax::ext::base::{self, *};
99
use syntax::ext::build::AstBuilder;
1010
use syntax::attr;
1111
use syntax::tokenstream;
1212
use syntax::parse::token;
1313
use syntax_pos::Span;
1414

15-
pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
15+
pub fn expand_cfg<'cx>(cx: &mut ExtCtxt<'_>,
1616
sp: Span,
1717
tts: &[tokenstream::TokenTree])
1818
-> Box<dyn base::MacResult + 'static> {

src/libsyntax_ext/compile_error.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// The compiler code necessary to support the compile_error! extension.
22

3-
use syntax::ext::base::*;
4-
use syntax::ext::base;
3+
use syntax::ext::base::{self, *};
54
use syntax_pos::Span;
65
use syntax::tokenstream;
76

8-
pub fn expand_compile_error<'cx>(cx: &'cx mut ExtCtxt,
7+
pub fn expand_compile_error<'cx>(cx: &'cx mut ExtCtxt<'_>,
98
sp: Span,
109
tts: &[tokenstream::TokenTree])
1110
-> Box<dyn base::MacResult + 'cx> {

src/libsyntax_ext/concat.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ use syntax::ext::base;
33
use syntax::ext::build::AstBuilder;
44
use syntax::symbol::Symbol;
55
use syntax::tokenstream;
6-
use syntax_pos;
76

87
use std::string::String;
98

109
pub fn expand_syntax_ext(
11-
cx: &mut base::ExtCtxt,
10+
cx: &mut base::ExtCtxt<'_>,
1211
sp: syntax_pos::Span,
1312
tts: &[tokenstream::TokenTree],
1413
) -> Box<dyn base::MacResult + 'static> {

src/libsyntax_ext/concat_idents.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
use rustc_data_structures::thin_vec::ThinVec;
22

33
use syntax::ast;
4-
use syntax::ext::base::*;
5-
use syntax::ext::base;
4+
use syntax::ext::base::{self, *};
65
use syntax::feature_gate;
76
use syntax::parse::token;
87
use syntax::ptr::P;
98
use syntax_pos::Span;
109
use syntax_pos::symbol::Symbol;
1110
use syntax::tokenstream::TokenTree;
1211

13-
pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
12+
pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt<'_>,
1413
sp: Span,
1514
tts: &[TokenTree])
1615
-> Box<dyn base::MacResult + 'cx> {

src/libsyntax_ext/deriving/bounds.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
use deriving::path_std;
2-
use deriving::generic::*;
3-
use deriving::generic::ty::*;
1+
use crate::deriving::path_std;
2+
use crate::deriving::generic::*;
3+
use crate::deriving::generic::ty::*;
4+
45
use syntax::ast::MetaItem;
56
use syntax::ext::base::{Annotatable, ExtCtxt};
67
use syntax_pos::Span;
78

8-
pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt,
9+
pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt<'_>,
910
span: Span,
1011
_: &MetaItem,
1112
_: &Annotatable,
1213
_: &mut dyn FnMut(Annotatable)) {
1314
cx.span_err(span, "this unsafe trait should be implemented explicitly");
1415
}
1516

16-
pub fn expand_deriving_copy(cx: &mut ExtCtxt,
17+
pub fn expand_deriving_copy(cx: &mut ExtCtxt<'_>,
1718
span: Span,
1819
mitem: &MetaItem,
1920
item: &Annotatable,

src/libsyntax_ext/deriving/clone.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
use deriving::path_std;
2-
use deriving::generic::*;
3-
use deriving::generic::ty::*;
1+
use crate::deriving::path_std;
2+
use crate::deriving::generic::*;
3+
use crate::deriving::generic::ty::*;
44

5-
use syntax::ast::{self, Expr, Generics, ItemKind, MetaItem, VariantData};
6-
use syntax::ast::GenericArg;
5+
use syntax::ast::{self, Expr, GenericArg, Generics, ItemKind, MetaItem, VariantData};
76
use syntax::attr;
87
use syntax::ext::base::{Annotatable, ExtCtxt};
98
use syntax::ext::build::AstBuilder;
109
use syntax::ptr::P;
1110
use syntax::symbol::{Symbol, keywords};
1211
use syntax_pos::Span;
1312

14-
pub fn expand_deriving_clone(cx: &mut ExtCtxt,
13+
pub fn expand_deriving_clone(cx: &mut ExtCtxt<'_>,
1514
span: Span,
1615
mitem: &MetaItem,
1716
item: &Annotatable,
@@ -105,12 +104,12 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
105104
}
106105

107106
fn cs_clone_shallow(name: &str,
108-
cx: &mut ExtCtxt,
107+
cx: &mut ExtCtxt<'_>,
109108
trait_span: Span,
110-
substr: &Substructure,
109+
substr: &Substructure<'_>,
111110
is_union: bool)
112111
-> P<Expr> {
113-
fn assert_ty_bounds(cx: &mut ExtCtxt, stmts: &mut Vec<ast::Stmt>,
112+
fn assert_ty_bounds(cx: &mut ExtCtxt<'_>, stmts: &mut Vec<ast::Stmt>,
114113
ty: P<ast::Ty>, span: Span, helper_name: &str) {
115114
// Generate statement `let _: helper_name<ty>;`,
116115
// set the expn ID so we can use the unstable struct.
@@ -120,7 +119,7 @@ fn cs_clone_shallow(name: &str,
120119
vec![GenericArg::Type(ty)], vec![]);
121120
stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path)));
122121
}
123-
fn process_variant(cx: &mut ExtCtxt, stmts: &mut Vec<ast::Stmt>, variant: &VariantData) {
122+
fn process_variant(cx: &mut ExtCtxt<'_>, stmts: &mut Vec<ast::Stmt>, variant: &VariantData) {
124123
for field in variant.fields() {
125124
// let _: AssertParamIsClone<FieldTy>;
126125
assert_ty_bounds(cx, stmts, field.ty.clone(), field.span, "AssertParamIsClone");
@@ -151,14 +150,14 @@ fn cs_clone_shallow(name: &str,
151150
}
152151

153152
fn cs_clone(name: &str,
154-
cx: &mut ExtCtxt,
153+
cx: &mut ExtCtxt<'_>,
155154
trait_span: Span,
156-
substr: &Substructure)
155+
substr: &Substructure<'_>)
157156
-> P<Expr> {
158157
let ctor_path;
159158
let all_fields;
160159
let fn_path = cx.std_path(&["clone", "Clone", "clone"]);
161-
let subcall = |cx: &mut ExtCtxt, field: &FieldInfo| {
160+
let subcall = |cx: &mut ExtCtxt<'_>, field: &FieldInfo<'_>| {
162161
let args = vec![cx.expr_addr_of(field.span, field.self_.clone())];
163162
cx.expr_call_global(field.span, fn_path.clone(), args)
164163
};

src/libsyntax_ext/deriving/cmp/eq.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use deriving::path_std;
2-
use deriving::generic::*;
3-
use deriving::generic::ty::*;
1+
use crate::deriving::path_std;
2+
use crate::deriving::generic::*;
3+
use crate::deriving::generic::ty::*;
44

55
use syntax::ast::{self, Expr, MetaItem, GenericArg};
66
use syntax::ext::base::{Annotatable, ExtCtxt};
@@ -9,7 +9,7 @@ use syntax::ptr::P;
99
use syntax::symbol::Symbol;
1010
use syntax_pos::Span;
1111

12-
pub fn expand_deriving_eq(cx: &mut ExtCtxt,
12+
pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>,
1313
span: Span,
1414
mitem: &MetaItem,
1515
item: &Annotatable,
@@ -44,8 +44,11 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
4444
trait_def.expand_ext(cx, mitem, item, push, true)
4545
}
4646

47-
fn cs_total_eq_assert(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
48-
fn assert_ty_bounds(cx: &mut ExtCtxt, stmts: &mut Vec<ast::Stmt>,
47+
fn cs_total_eq_assert(cx: &mut ExtCtxt<'_>,
48+
trait_span: Span,
49+
substr: &Substructure<'_>)
50+
-> P<Expr> {
51+
fn assert_ty_bounds(cx: &mut ExtCtxt<'_>, stmts: &mut Vec<ast::Stmt>,
4952
ty: P<ast::Ty>, span: Span, helper_name: &str) {
5053
// Generate statement `let _: helper_name<ty>;`,
5154
// set the expn ID so we can use the unstable struct.
@@ -55,7 +58,9 @@ fn cs_total_eq_assert(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
5558
vec![GenericArg::Type(ty)], vec![]);
5659
stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path)));
5760
}
58-
fn process_variant(cx: &mut ExtCtxt, stmts: &mut Vec<ast::Stmt>, variant: &ast::VariantData) {
61+
fn process_variant(cx: &mut ExtCtxt<'_>,
62+
stmts: &mut Vec<ast::Stmt>,
63+
variant: &ast::VariantData) {
5964
for field in variant.fields() {
6065
// let _: AssertParamIsEq<FieldTy>;
6166
assert_ty_bounds(cx, stmts, field.ty.clone(), field.span, "AssertParamIsEq");

src/libsyntax_ext/deriving/cmp/ord.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use deriving::path_std;
2-
use deriving::generic::*;
3-
use deriving::generic::ty::*;
1+
use crate::deriving::path_std;
2+
use crate::deriving::generic::*;
3+
use crate::deriving::generic::ty::*;
44

55
use syntax::ast::{self, Expr, MetaItem};
66
use syntax::ext::base::{Annotatable, ExtCtxt};
@@ -9,7 +9,7 @@ use syntax::ptr::P;
99
use syntax::symbol::Symbol;
1010
use syntax_pos::Span;
1111

12-
pub fn expand_deriving_ord(cx: &mut ExtCtxt,
12+
pub fn expand_deriving_ord(cx: &mut ExtCtxt<'_>,
1313
span: Span,
1414
mitem: &MetaItem,
1515
item: &Annotatable,
@@ -44,7 +44,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
4444
}
4545

4646

47-
pub fn ordering_collapsed(cx: &mut ExtCtxt,
47+
pub fn ordering_collapsed(cx: &mut ExtCtxt<'_>,
4848
span: Span,
4949
self_arg_tags: &[ast::Ident])
5050
-> P<ast::Expr> {
@@ -53,7 +53,7 @@ pub fn ordering_collapsed(cx: &mut ExtCtxt,
5353
cx.expr_method_call(span, lft, cx.ident_of("cmp"), vec![rgt])
5454
}
5555

56-
pub fn cs_cmp(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
56+
pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
5757
let test_id = cx.ident_of("cmp").gensym();
5858
let equals_path = cx.path_global(span, cx.std_path(&["cmp", "Ordering", "Equal"]));
5959

src/libsyntax_ext/deriving/cmp/partial_eq.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use deriving::{path_local, path_std};
2-
use deriving::generic::*;
3-
use deriving::generic::ty::*;
1+
use crate::deriving::{path_local, path_std};
2+
use crate::deriving::generic::*;
3+
use crate::deriving::generic::ty::*;
44

55
use syntax::ast::{BinOpKind, Expr, MetaItem};
66
use syntax::ext::base::{Annotatable, ExtCtxt};
@@ -9,22 +9,22 @@ use syntax::ptr::P;
99
use syntax::symbol::Symbol;
1010
use syntax_pos::Span;
1111

12-
pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
12+
pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt<'_>,
1313
span: Span,
1414
mitem: &MetaItem,
1515
item: &Annotatable,
1616
push: &mut dyn FnMut(Annotatable)) {
1717
// structures are equal if all fields are equal, and non equal, if
1818
// any fields are not equal or if the enum variants are different
19-
fn cs_op(cx: &mut ExtCtxt,
19+
fn cs_op(cx: &mut ExtCtxt<'_>,
2020
span: Span,
21-
substr: &Substructure,
21+
substr: &Substructure<'_>,
2222
op: BinOpKind,
2323
combiner: BinOpKind,
2424
base: bool)
2525
-> P<Expr>
2626
{
27-
let op = |cx: &mut ExtCtxt, span: Span, self_f: P<Expr>, other_fs: &[P<Expr>]| {
27+
let op = |cx: &mut ExtCtxt<'_>, span: Span, self_f: P<Expr>, other_fs: &[P<Expr>]| {
2828
let other_f = match (other_fs.len(), other_fs.get(0)) {
2929
(1, Some(o_f)) => o_f,
3030
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`"),
@@ -53,10 +53,10 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
5353
substr)
5454
}
5555

56-
fn cs_eq(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
56+
fn cs_eq(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
5757
cs_op(cx, span, substr, BinOpKind::Eq, BinOpKind::And, true)
5858
}
59-
fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
59+
fn cs_ne(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
6060
cs_op(cx, span, substr, BinOpKind::Ne, BinOpKind::Or, false)
6161
}
6262

0 commit comments

Comments
 (0)