Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsyntax_ext => 2018 #58133

Merged
merged 1 commit into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/libsyntax_ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"]
name = "syntax_ext"
version = "0.0.0"
edition = "2018"

[lib]
name = "syntax_ext"
Expand Down
11 changes: 6 additions & 5 deletions src/libsyntax_ext/asm.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
// Inline assembly support.
//
use self::State::*;
use State::*;

use rustc_data_structures::thin_vec::ThinVec;

use errors::DiagnosticBuilder;
use crate::errors::DiagnosticBuilder;

use syntax::ast;
use syntax::ext::base;
use syntax::ext::base::*;
use syntax::ext::base::{self, *};
use syntax::feature_gate;
use syntax::parse::{self, token};
use syntax::ptr::P;
use syntax::symbol::Symbol;
use syntax::ast::AsmDialect;
use syntax_pos::Span;
use syntax::tokenstream;
use syntax::{span_err, struct_span_err};

enum State {
Asm,
Expand All @@ -40,7 +41,7 @@ impl State {

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

pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt<'_>,
sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<dyn base::MacResult + 'cx> {
Expand Down
5 changes: 3 additions & 2 deletions src/libsyntax_ext/assert.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use errors::DiagnosticBuilder;
use crate::errors::DiagnosticBuilder;

use syntax::ast::{self, *};
use syntax::source_map::Spanned;
use syntax::ext::base::*;
Expand All @@ -11,7 +12,7 @@ use syntax::tokenstream::{TokenStream, TokenTree};
use syntax_pos::{Span, DUMMY_SP};

pub fn expand_assert<'cx>(
cx: &'cx mut ExtCtxt,
cx: &'cx mut ExtCtxt<'_>,
sp: Span,
tts: &[TokenTree],
) -> Box<dyn MacResult + 'cx> {
Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax_ext/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
/// a literal `true` or `false` based on whether the given cfg matches the
/// current compilation environment.

use errors::DiagnosticBuilder;
use crate::errors::DiagnosticBuilder;

use syntax::ast;
use syntax::ext::base::*;
use syntax::ext::base;
use syntax::ext::base::{self, *};
use syntax::ext::build::AstBuilder;
use syntax::attr;
use syntax::tokenstream;
use syntax::parse::token;
use syntax_pos::Span;

pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
pub fn expand_cfg<'cx>(cx: &mut ExtCtxt<'_>,
sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<dyn base::MacResult + 'static> {
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax_ext/compile_error.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// The compiler code necessary to support the compile_error! extension.

use syntax::ext::base::*;
use syntax::ext::base;
use syntax::ext::base::{self, *};
use syntax_pos::Span;
use syntax::tokenstream;

pub fn expand_compile_error<'cx>(cx: &'cx mut ExtCtxt,
pub fn expand_compile_error<'cx>(cx: &'cx mut ExtCtxt<'_>,
sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<dyn base::MacResult + 'cx> {
Expand Down
3 changes: 1 addition & 2 deletions src/libsyntax_ext/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use syntax::ext::base;
use syntax::ext::build::AstBuilder;
use syntax::symbol::Symbol;
use syntax::tokenstream;
use syntax_pos;

use std::string::String;

pub fn expand_syntax_ext(
cx: &mut base::ExtCtxt,
cx: &mut base::ExtCtxt<'_>,
sp: syntax_pos::Span,
tts: &[tokenstream::TokenTree],
) -> Box<dyn base::MacResult + 'static> {
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax_ext/concat_idents.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use rustc_data_structures::thin_vec::ThinVec;

use syntax::ast;
use syntax::ext::base::*;
use syntax::ext::base;
use syntax::ext::base::{self, *};
use syntax::feature_gate;
use syntax::parse::token;
use syntax::ptr::P;
use syntax_pos::Span;
use syntax_pos::symbol::Symbol;
use syntax::tokenstream::TokenTree;

pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt<'_>,
sp: Span,
tts: &[TokenTree])
-> Box<dyn base::MacResult + 'cx> {
Expand Down
11 changes: 6 additions & 5 deletions src/libsyntax_ext/deriving/bounds.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
use deriving::path_std;
use deriving::generic::*;
use deriving::generic::ty::*;
use crate::deriving::path_std;
use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;

use syntax::ast::MetaItem;
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax_pos::Span;

pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt,
pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt<'_>,
span: Span,
_: &MetaItem,
_: &Annotatable,
_: &mut dyn FnMut(Annotatable)) {
cx.span_err(span, "this unsafe trait should be implemented explicitly");
}

pub fn expand_deriving_copy(cx: &mut ExtCtxt,
pub fn expand_deriving_copy(cx: &mut ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
Expand Down
25 changes: 12 additions & 13 deletions src/libsyntax_ext/deriving/clone.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
use deriving::path_std;
use deriving::generic::*;
use deriving::generic::ty::*;
use crate::deriving::path_std;
use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;

use syntax::ast::{self, Expr, Generics, ItemKind, MetaItem, VariantData};
use syntax::ast::GenericArg;
use syntax::ast::{self, Expr, GenericArg, Generics, ItemKind, MetaItem, VariantData};
use syntax::attr;
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax::ext::build::AstBuilder;
use syntax::ptr::P;
use syntax::symbol::{Symbol, keywords};
use syntax_pos::Span;

pub fn expand_deriving_clone(cx: &mut ExtCtxt,
pub fn expand_deriving_clone(cx: &mut ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
Expand Down Expand Up @@ -105,12 +104,12 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
}

fn cs_clone_shallow(name: &str,
cx: &mut ExtCtxt,
cx: &mut ExtCtxt<'_>,
trait_span: Span,
substr: &Substructure,
substr: &Substructure<'_>,
is_union: bool)
-> P<Expr> {
fn assert_ty_bounds(cx: &mut ExtCtxt, stmts: &mut Vec<ast::Stmt>,
fn assert_ty_bounds(cx: &mut ExtCtxt<'_>, stmts: &mut Vec<ast::Stmt>,
ty: P<ast::Ty>, span: Span, helper_name: &str) {
// Generate statement `let _: helper_name<ty>;`,
// set the expn ID so we can use the unstable struct.
Expand All @@ -120,7 +119,7 @@ fn cs_clone_shallow(name: &str,
vec![GenericArg::Type(ty)], vec![]);
stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path)));
}
fn process_variant(cx: &mut ExtCtxt, stmts: &mut Vec<ast::Stmt>, variant: &VariantData) {
fn process_variant(cx: &mut ExtCtxt<'_>, stmts: &mut Vec<ast::Stmt>, variant: &VariantData) {
for field in variant.fields() {
// let _: AssertParamIsClone<FieldTy>;
assert_ty_bounds(cx, stmts, field.ty.clone(), field.span, "AssertParamIsClone");
Expand Down Expand Up @@ -151,14 +150,14 @@ fn cs_clone_shallow(name: &str,
}

fn cs_clone(name: &str,
cx: &mut ExtCtxt,
cx: &mut ExtCtxt<'_>,
trait_span: Span,
substr: &Substructure)
substr: &Substructure<'_>)
-> P<Expr> {
let ctor_path;
let all_fields;
let fn_path = cx.std_path(&["clone", "Clone", "clone"]);
let subcall = |cx: &mut ExtCtxt, field: &FieldInfo| {
let subcall = |cx: &mut ExtCtxt<'_>, field: &FieldInfo<'_>| {
let args = vec![cx.expr_addr_of(field.span, field.self_.clone())];
cx.expr_call_global(field.span, fn_path.clone(), args)
};
Expand Down
19 changes: 12 additions & 7 deletions src/libsyntax_ext/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use deriving::path_std;
use deriving::generic::*;
use deriving::generic::ty::*;
use crate::deriving::path_std;
use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;

use syntax::ast::{self, Expr, MetaItem, GenericArg};
use syntax::ext::base::{Annotatable, ExtCtxt};
Expand All @@ -9,7 +9,7 @@ use syntax::ptr::P;
use syntax::symbol::Symbol;
use syntax_pos::Span;

pub fn expand_deriving_eq(cx: &mut ExtCtxt,
pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
Expand Down Expand Up @@ -44,8 +44,11 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
trait_def.expand_ext(cx, mitem, item, push, true)
}

fn cs_total_eq_assert(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
fn assert_ty_bounds(cx: &mut ExtCtxt, stmts: &mut Vec<ast::Stmt>,
fn cs_total_eq_assert(cx: &mut ExtCtxt<'_>,
trait_span: Span,
substr: &Substructure<'_>)
-> P<Expr> {
fn assert_ty_bounds(cx: &mut ExtCtxt<'_>, stmts: &mut Vec<ast::Stmt>,
ty: P<ast::Ty>, span: Span, helper_name: &str) {
// Generate statement `let _: helper_name<ty>;`,
// set the expn ID so we can use the unstable struct.
Expand All @@ -55,7 +58,9 @@ fn cs_total_eq_assert(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
vec![GenericArg::Type(ty)], vec![]);
stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path)));
}
fn process_variant(cx: &mut ExtCtxt, stmts: &mut Vec<ast::Stmt>, variant: &ast::VariantData) {
fn process_variant(cx: &mut ExtCtxt<'_>,
stmts: &mut Vec<ast::Stmt>,
variant: &ast::VariantData) {
for field in variant.fields() {
// let _: AssertParamIsEq<FieldTy>;
assert_ty_bounds(cx, stmts, field.ty.clone(), field.span, "AssertParamIsEq");
Expand Down
12 changes: 6 additions & 6 deletions src/libsyntax_ext/deriving/cmp/ord.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use deriving::path_std;
use deriving::generic::*;
use deriving::generic::ty::*;
use crate::deriving::path_std;
use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;

use syntax::ast::{self, Expr, MetaItem};
use syntax::ext::base::{Annotatable, ExtCtxt};
Expand All @@ -9,7 +9,7 @@ use syntax::ptr::P;
use syntax::symbol::Symbol;
use syntax_pos::Span;

pub fn expand_deriving_ord(cx: &mut ExtCtxt,
pub fn expand_deriving_ord(cx: &mut ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
Expand Down Expand Up @@ -44,7 +44,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
}


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

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

Expand Down
18 changes: 9 additions & 9 deletions src/libsyntax_ext/deriving/cmp/partial_eq.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use deriving::{path_local, path_std};
use deriving::generic::*;
use deriving::generic::ty::*;
use crate::deriving::{path_local, path_std};
use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;

use syntax::ast::{BinOpKind, Expr, MetaItem};
use syntax::ext::base::{Annotatable, ExtCtxt};
Expand All @@ -9,22 +9,22 @@ use syntax::ptr::P;
use syntax::symbol::Symbol;
use syntax_pos::Span;

pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt<'_>,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable)) {
// structures are equal if all fields are equal, and non equal, if
// any fields are not equal or if the enum variants are different
fn cs_op(cx: &mut ExtCtxt,
fn cs_op(cx: &mut ExtCtxt<'_>,
span: Span,
substr: &Substructure,
substr: &Substructure<'_>,
op: BinOpKind,
combiner: BinOpKind,
base: bool)
-> P<Expr>
{
let op = |cx: &mut ExtCtxt, span: Span, self_f: P<Expr>, other_fs: &[P<Expr>]| {
let op = |cx: &mut ExtCtxt<'_>, span: Span, self_f: P<Expr>, other_fs: &[P<Expr>]| {
let other_f = match (other_fs.len(), other_fs.get(0)) {
(1, Some(o_f)) => o_f,
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`"),
Expand Down Expand Up @@ -53,10 +53,10 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
substr)
}

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

Expand Down
Loading