move syntax::ext to new crate syntax_expand

This commit is contained in:
Mazdak Farrokhzad 2019-10-16 10:59:30 +02:00
parent d160a4e422
commit d420d719c4
113 changed files with 500 additions and 430 deletions

View file

@ -3112,6 +3112,7 @@ dependencies = [
"serialize",
"smallvec",
"syntax",
"syntax_expand",
"syntax_pos",
]
@ -3427,6 +3428,7 @@ dependencies = [
"rustc_target",
"serialize",
"syntax",
"syntax_expand",
"syntax_pos",
"tempfile",
]
@ -3559,6 +3561,7 @@ dependencies = [
"serialize",
"smallvec",
"syntax",
"syntax_expand",
"syntax_ext",
"syntax_pos",
"tempfile",
@ -3630,6 +3633,7 @@ dependencies = [
"smallvec",
"stable_deref_trait",
"syntax",
"syntax_expand",
"syntax_pos",
]
@ -3678,6 +3682,7 @@ dependencies = [
"rustc_index",
"rustc_target",
"syntax",
"syntax_expand",
"syntax_pos",
]
@ -3695,6 +3700,7 @@ dependencies = [
"rustc",
"rustc_metadata",
"syntax",
"syntax_expand",
"syntax_pos",
]
@ -3723,6 +3729,7 @@ dependencies = [
"rustc_metadata",
"smallvec",
"syntax",
"syntax_expand",
"syntax_pos",
]
@ -4336,6 +4343,25 @@ dependencies = [
"syntax_pos",
]
[[package]]
name = "syntax_expand"
version = "0.0.0"
dependencies = [
"bitflags",
"lazy_static 1.3.0",
"log",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_lexer",
"rustc_target",
"scoped-tls",
"serialize",
"smallvec",
"syntax",
"syntax_pos",
]
[[package]]
name = "syntax_ext"
version = "0.0.0"
@ -4347,6 +4373,7 @@ dependencies = [
"rustc_target",
"smallvec",
"syntax",
"syntax_expand",
"syntax_pos",
]

View file

@ -29,6 +29,7 @@ rustc_index = { path = "../librustc_index" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }
backtrace = "0.3.3"
parking_lot = "0.9"

View file

@ -6,7 +6,7 @@ use crate::ty;
use crate::util::nodemap::DefIdMap;
use syntax::ast;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax::ast::NodeId;
use syntax_pos::Span;
use rustc_macros::HashStable;

View file

@ -64,15 +64,15 @@ use syntax::ast;
use syntax::ptr::P as AstP;
use syntax::ast::*;
use syntax::errors;
use syntax::ext::base::SpecialDerives;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::base::SpecialDerives;
use syntax::print::pprust;
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::parse::token::{self, Nonterminal, Token};
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::sess::ParseSess;
use syntax::source_map::{respan, ExpnData, ExpnKind, DesugaringKind, Spanned};
use syntax::symbol::{kw, sym, Symbol};
use syntax::visit::{self, Visitor};
use syntax_pos::hygiene::ExpnId;
use syntax_pos::Span;
const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF;

View file

@ -18,7 +18,7 @@ use smallvec::SmallVec;
use syntax::attr;
use syntax::ast::*;
use syntax::visit::{self, Visitor};
use syntax::ext::base::SpecialDerives;
use syntax_expand::base::SpecialDerives;
use syntax::source_map::{respan, DesugaringKind, Spanned};
use syntax::symbol::{kw, sym};
use syntax_pos::Span;

View file

@ -2,7 +2,7 @@ use crate::hir::map::definitions::*;
use crate::hir::def_id::DefIndex;
use syntax::ast::*;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::hygiene::ExpnId;
use syntax::visit;
use syntax::symbol::{kw, sym};
use syntax::parse::token::{self, Token};

View file

@ -17,7 +17,7 @@ use std::borrow::Borrow;
use std::fmt::Write;
use std::hash::Hash;
use syntax::ast;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::hygiene::ExpnId;
use syntax::symbol::{Symbol, sym, InternedString};
use syntax_pos::{Span, DUMMY_SP};

View file

@ -20,7 +20,7 @@ use rustc_data_structures::svh::Svh;
use rustc_index::vec::IndexVec;
use syntax::ast::{self, Name, NodeId};
use syntax::source_map::Spanned;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax_pos::{Span, DUMMY_SP};
pub mod blocks;

View file

@ -13,7 +13,7 @@ use std::cell::RefCell;
use syntax::ast;
use syntax::source_map::SourceMap;
use syntax::ext::hygiene::SyntaxContext;
use syntax_expand::hygiene::SyntaxContext;
use syntax::symbol::Symbol;
use syntax::tokenstream::DelimSpan;
use syntax_pos::{Span, DUMMY_SP};

View file

@ -59,7 +59,7 @@ impl_stable_hash_for!(enum ::syntax::ast::AsmDialect {
Intel
});
impl_stable_hash_for!(enum ::syntax::ext::base::MacroKind {
impl_stable_hash_for!(enum ::syntax_expand::base::MacroKind {
Bang,
Attr,
Derive,

View file

@ -39,7 +39,7 @@ use syntax::ast;
use syntax::source_map::{MultiSpan, ExpnKind, DesugaringKind};
use syntax::early_buffered_lints::BufferedEarlyLintId;
use syntax::edition::Edition;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax::symbol::{Symbol, sym};
use syntax_pos::Span;

View file

@ -24,7 +24,7 @@ use errors::emitter::HumanReadableErrorType;
use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
use syntax::ast::{self, NodeId};
use syntax::edition::Edition;
use syntax::ext::allocator::AllocatorKind;
use syntax_expand::allocator::AllocatorKind;
use syntax::feature_gate::{self, AttributeType};
use syntax::json::JsonEmitter;
use syntax::source_map;

View file

@ -45,7 +45,7 @@ use std::{mem, ptr};
use std::ops::Range;
use syntax::ast::{self, Name, Ident, NodeId};
use syntax::attr;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::hygiene::ExpnId;
use syntax::symbol::{kw, sym, Symbol, InternedString};
use syntax_pos::Span;

View file

@ -3,7 +3,7 @@ use std::ffi::CString;
use crate::attributes;
use libc::c_uint;
use rustc::ty::TyCtxt;
use syntax::ext::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
use syntax_expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
use crate::ModuleLlvm;
use crate::llvm::{self, False, True};

View file

@ -39,6 +39,7 @@ extern crate rustc_driver as _;
#[macro_use] extern crate log;
extern crate syntax;
extern crate syntax_expand;
extern crate syntax_pos;
extern crate rustc_errors as errors;
@ -48,7 +49,7 @@ use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinModul
use rustc_codegen_ssa::CompiledModule;
use errors::{FatalError, Handler};
use rustc::dep_graph::WorkProduct;
use syntax::ext::allocator::AllocatorKind;
use syntax_expand::allocator::AllocatorKind;
use syntax_pos::symbol::InternedString;
pub use llvm_util::target_features;
use std::any::Any;

View file

@ -21,6 +21,7 @@ tempfile = "3.1"
rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }
rustc = { path = "../librustc" }
rustc_apfloat = { path = "../librustc_apfloat" }

View file

@ -14,7 +14,7 @@ use rustc::ty::query::Providers;
use rustc::ty::subst::SubstsRef;
use rustc::util::nodemap::{FxHashMap, DefIdMap};
use rustc_index::vec::IndexVec;
use syntax::ext::allocator::ALLOCATOR_METHODS;
use syntax_expand::allocator::ALLOCATOR_METHODS;
pub type ExportedSymbols = FxHashMap<
CrateNum,

View file

@ -27,7 +27,7 @@ use rustc_errors::{Handler, Level, FatalError, DiagnosticId, SourceMapperDyn};
use rustc_errors::emitter::{Emitter};
use rustc_target::spec::MergeFunctions;
use syntax::attr;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::hygiene::ExpnId;
use syntax_pos::symbol::{Symbol, sym};
use jobserver::{Client, Acquired};

View file

@ -9,7 +9,7 @@ use rustc::ty::TyCtxt;
use rustc_codegen_utils::codegen_backend::CodegenBackend;
use std::sync::Arc;
use std::sync::mpsc;
use syntax::ext::allocator::AllocatorKind;
use syntax_expand::allocator::AllocatorKind;
use syntax_pos::symbol::InternedString;
pub trait BackendTypes {

View file

@ -15,6 +15,7 @@ rayon = { version = "0.3.0", package = "rustc-rayon" }
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
syntax = { path = "../libsyntax" }
syntax_ext = { path = "../libsyntax_ext" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
rustc = { path = "../librustc" }

View file

@ -35,7 +35,7 @@ use rustc_traits;
use rustc_typeck as typeck;
use syntax::{self, ast, visit};
use syntax::early_buffered_lints::BufferedEarlyLint;
use syntax::ext::base::{NamedSyntaxExtension, ExtCtxt};
use syntax_expand::base::{NamedSyntaxExtension, ExtCtxt};
use syntax::mut_visit::MutVisitor;
use syntax::parse::{self, PResult};
use syntax::util::node_count::NodeCounter;
@ -397,12 +397,12 @@ fn configure_and_expand_inner<'a>(
// Create the config for macro expansion
let features = sess.features_untracked();
let cfg = syntax::ext::expand::ExpansionConfig {
let cfg = syntax_expand::expand::ExpansionConfig {
features: Some(&features),
recursion_limit: *sess.recursion_limit.get(),
trace_mac: sess.opts.debugging_opts.trace_macros,
should_test: sess.opts.test,
..syntax::ext::expand::ExpansionConfig::default(crate_name.to_string())
..syntax_expand::expand::ExpansionConfig::default(crate_name.to_string())
};
let mut ecx = ExtCtxt::new(&sess.parse_sess, cfg, &mut resolver);
@ -559,7 +559,7 @@ pub fn lower_to_hir(
// Discard hygiene data, which isn't required after lowering to HIR.
if !sess.opts.debugging_opts.keep_hygiene_data {
syntax::ext::hygiene::clear_syntax_context_map();
syntax_expand::hygiene::clear_syntax_context_map();
}
Ok(hir_forest)

View file

@ -22,4 +22,5 @@ rustc_index = { path = "../librustc_index" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
stable_deref_trait = "1.0.0"
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }

View file

@ -26,7 +26,7 @@ use std::{cmp, fs};
use syntax::ast;
use syntax::attr;
use syntax::ext::allocator::{global_allocator_spans, AllocatorKind};
use syntax_expand::allocator::{global_allocator_spans, AllocatorKind};
use syntax::symbol::{Symbol, sym};
use syntax::{span_err, span_fatal};
use syntax_pos::{Span, DUMMY_SP};

View file

@ -11,7 +11,7 @@ use rustc_index::vec::IndexVec;
use rustc::util::nodemap::FxHashMap;
use rustc_data_structures::sync::{Lrc, RwLock, Lock, MetadataRef, AtomicCell};
use syntax::ast;
use syntax::ext::base::SyntaxExtension;
use syntax_expand::base::SyntaxExtension;
use syntax_pos;
use proc_macro::bridge::client::ProcMacro;

View file

@ -32,11 +32,11 @@ use syntax::attr;
use syntax::ast::{self, Ident};
use syntax::source_map::{self, respan, Spanned};
use syntax::symbol::{Symbol, sym};
use syntax::ext::base::{MacroKind, SyntaxExtensionKind, SyntaxExtension};
use syntax_expand::base::{MacroKind, SyntaxExtensionKind, SyntaxExtension};
use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, symbol::{InternedString}};
use log::debug;
use proc_macro::bridge::client::ProcMacro;
use syntax::ext::proc_macro::{AttrProcMacro, ProcMacroDerive, BangProcMacro};
use syntax_expand::proc_macro::{AttrProcMacro, ProcMacroDerive, BangProcMacro};
crate struct DecodeContext<'a, 'tcx> {
opaque: opaque::Decoder<'a>,

View file

@ -31,7 +31,7 @@ use rustc_data_structures::sync::Lrc;
use std::u32;
use syntax::ast;
use syntax::attr;
use syntax::ext::proc_macro::is_proc_macro_attr;
use syntax_expand::proc_macro::is_proc_macro_attr;
use syntax::source_map::Spanned;
use syntax::symbol::{kw, sym, Ident, Symbol};
use syntax_pos::{self, FileName, SourceFile, Span};

View file

@ -13,6 +13,7 @@ log = "0.4"
rustc = { path = "../librustc" }
rustc_data_structures = { path = "../librustc_data_structures" }
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_target = { path = "../librustc_target" }

View file

@ -14,7 +14,7 @@ use rustc::session::Session;
use rustc_data_structures::fx::FxHashMap;
use syntax::ast::*;
use syntax::attr;
use syntax::ext::proc_macro::is_proc_macro_attr;
use syntax_expand::proc_macro::is_proc_macro_attr;
use syntax::feature_gate::is_builtin_attr;
use syntax::source_map::Spanned;
use syntax::symbol::{kw, sym};

View file

@ -14,4 +14,5 @@ doctest = false
rustc = { path = "../librustc" }
rustc_metadata = { path = "../librustc_metadata" }
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }

View file

@ -21,7 +21,7 @@
//! extern crate syntax_pos;
//!
//! use rustc_driver::plugin::Registry;
//! use syntax::ext::base::{ExtCtxt, MacResult};
//! use syntax_expand::base::{ExtCtxt, MacResult};
//! use syntax_pos::Span;
//! use syntax::tokenstream::TokenTree;
//!

View file

@ -4,8 +4,8 @@ use rustc::lint::{EarlyLintPassObject, LateLintPassObject, LintId, Lint};
use rustc::session::Session;
use rustc::util::nodemap::FxHashMap;
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind, NamedSyntaxExtension};
use syntax::ext::base::MacroExpanderFn;
use syntax_expand::base::{SyntaxExtension, SyntaxExtensionKind, NamedSyntaxExtension};
use syntax_expand::base::MacroExpanderFn;
use syntax::symbol::Symbol;
use syntax::ast;
use syntax::feature_gate::AttributeType;

View file

@ -14,6 +14,7 @@ doctest = false
bitflags = "1.0"
log = "0.4"
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
rustc = { path = "../librustc" }
arena = { path = "../libarena" }
errors = { path = "../librustc_errors", package = "rustc_errors" }

View file

@ -32,9 +32,9 @@ use syntax::attr;
use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId};
use syntax::ast::{MetaItemKind, StmtKind, TraitItem, TraitItemKind};
use syntax::ext::base::{MacroKind, SyntaxExtension};
use syntax::ext::expand::AstFragment;
use syntax::ext::hygiene::ExpnId;
use syntax_expand::base::{MacroKind, SyntaxExtension};
use syntax_expand::expand::AstFragment;
use syntax_expand::hygiene::ExpnId;
use syntax::feature_gate::is_builtin_attr;
use syntax::parse::token::{self, Token};
use syntax::print::pprust;

View file

@ -10,7 +10,7 @@ use rustc::session::Session;
use rustc::ty::{self, DefIdTree};
use rustc::util::nodemap::FxHashSet;
use syntax::ast::{self, Ident, Path};
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax::feature_gate::BUILTIN_ATTRIBUTES;
use syntax::source_map::SourceMap;
use syntax::struct_span_err;

View file

@ -13,7 +13,7 @@ use rustc::hir::PrimTy;
use rustc::session::config::nightly_options;
use rustc::util::nodemap::FxHashSet;
use syntax::ast::{self, Expr, ExprKind, Ident, NodeId, Path, Ty, TyKind};
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax::symbol::kw;
use syntax::util::lev_distance::find_best_match_for_name;
use syntax_pos::Span;

View file

@ -35,18 +35,16 @@ use rustc::span_bug;
use rustc_metadata::creader::CrateLoader;
use rustc_metadata::cstore::CStore;
use syntax::ext::hygiene::{ExpnId, Transparency, SyntaxContext};
use syntax_expand::hygiene::{ExpnId, Transparency, SyntaxContext};
use syntax_expand::base::{SyntaxExtension, MacroKind, SpecialDerives};
use syntax::{struct_span_err, unwrap_or};
use syntax::attr;
use syntax::ast::{self, Name, NodeId, Ident, FloatTy, IntTy, UintTy};
use syntax::ext::base::{SyntaxExtension, MacroKind, SpecialDerives};
use syntax::ast::{ItemKind, Path, CRATE_NODE_ID, Crate};
use syntax::print::pprust;
use syntax::symbol::{kw, sym};
use syntax::visit::{self, Visitor};
use syntax::attr;
use syntax::ast::{CRATE_NODE_ID, Crate};
use syntax::ast::{ItemKind, Path};
use syntax::{struct_span_err, unwrap_or};
use syntax::source_map::Spanned;
use syntax::visit::{self, Visitor};
use syntax_pos::{Span, DUMMY_SP};
use errors::{Applicability, DiagnosticBuilder};

View file

@ -14,11 +14,11 @@ use rustc::{ty, lint, span_bug};
use syntax::ast::{self, NodeId, Ident};
use syntax::attr::StabilityLevel;
use syntax::edition::Edition;
use syntax::ext::base::{self, InvocationRes, Indeterminate, SpecialDerives};
use syntax::ext::base::{MacroKind, SyntaxExtension};
use syntax::ext::expand::{AstFragment, AstFragmentKind, Invocation, InvocationKind};
use syntax::ext::hygiene::{self, ExpnId, ExpnData, ExpnKind};
use syntax::ext::compile_declarative_macro;
use syntax_expand::base::{self, InvocationRes, Indeterminate, SpecialDerives};
use syntax_expand::base::{MacroKind, SyntaxExtension};
use syntax_expand::expand::{AstFragment, AstFragmentKind, Invocation, InvocationKind};
use syntax_expand::hygiene::{self, ExpnId, ExpnData, ExpnKind};
use syntax_expand::compile_declarative_macro;
use syntax::feature_gate::{emit_feature_err, is_builtin_attr_name};
use syntax::feature_gate::GateIssue;
use syntax::print::pprust;

View file

@ -28,7 +28,7 @@ use rustc::util::nodemap::FxHashSet;
use rustc::{bug, span_bug};
use syntax::ast::{Ident, Name, NodeId, CRATE_NODE_ID};
use syntax::ext::hygiene::ExpnId;
use syntax_expand::hygiene::ExpnId;
use syntax::symbol::kw;
use syntax::util::lev_distance::find_best_match_for_name;
use syntax::{struct_span_err, unwrap_or};

View file

@ -3,7 +3,7 @@
use std::iter::once;
use syntax::ast;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax::symbol::sym;
use syntax_pos::Span;

View file

@ -28,7 +28,7 @@ use rustc::ty::layout::VariantIdx;
use rustc::util::nodemap::{FxHashMap, FxHashSet};
use syntax::ast::{self, AttrStyle, Ident};
use syntax::attr;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax::source_map::DUMMY_SP;
use syntax::symbol::{Symbol, kw, sym};
use syntax::symbol::InternedString;

View file

@ -4,7 +4,7 @@ pub use self::StructType::*;
use syntax::ast;
use syntax::ast::Name;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax_pos::{self, Span};
use rustc::hir;

View file

@ -1,7 +1,7 @@
//! Item types.
use std::fmt;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use crate::clean;
/// Item type. Corresponds to `clean::ItemEnum` variants.

View file

@ -45,11 +45,11 @@ use errors;
use serialize::json::{ToJson, Json, as_json};
use syntax::ast;
use syntax::edition::Edition;
use syntax::ext::base::MacroKind;
use syntax::feature_gate::UnstableFeatures;
use syntax::print::pprust;
use syntax::source_map::FileName;
use syntax::feature_gate::UnstableFeatures;
use syntax::symbol::{Symbol, sym};
use syntax_expand::base::MacroKind;
use rustc::hir::def_id::DefId;
use rustc::middle::privacy::AccessLevels;
use rustc::middle::stability;

View file

@ -34,6 +34,7 @@ extern crate rustc_typeck;
extern crate rustc_lexer;
extern crate serialize;
extern crate syntax;
extern crate syntax_expand;
extern crate syntax_pos;
extern crate test as testing;
#[macro_use] extern crate log;

View file

@ -7,7 +7,7 @@ use rustc::ty;
use rustc_resolve::ParentScope;
use syntax;
use syntax::ast::{self, Ident};
use syntax::ext::base::SyntaxExtensionKind;
use syntax_expand::base::SyntaxExtensionKind;
use syntax::feature_gate::UnstableFeatures;
use syntax::symbol::Symbol;
use syntax_pos::DUMMY_SP;

View file

@ -8,7 +8,7 @@ use rustc::middle::privacy::AccessLevel;
use rustc::util::nodemap::{FxHashSet, FxHashMap};
use rustc::ty::TyCtxt;
use syntax::ast;
use syntax::ext::base::MacroKind;
use syntax_expand::base::MacroKind;
use syntax::source_map::Spanned;
use syntax::symbol::sym;
use syntax_pos::{self, Span};

View file

@ -298,14 +298,14 @@ impl Attribute {
Ok(result)
}
crate fn parse_derive_paths<'a>(&self, sess: &'a ParseSess) -> PResult<'a, Vec<Path>> {
pub fn parse_derive_paths<'a>(&self, sess: &'a ParseSess) -> PResult<'a, Vec<Path>> {
if self.tokens.is_empty() {
return Ok(Vec::new());
}
self.parse(sess, |p| p.parse_derive_paths())
}
crate fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> {
pub fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> {
Ok(MetaItem {
path: self.path.clone(),
kind: self.parse(sess, |parser| parser.parse_meta_item_kind())?,

View file

@ -56,6 +56,7 @@ pub fn features(mut krate: ast::Crate, sess: &ParseSess, edition: Edition,
(krate, features)
}
#[macro_export]
macro_rules! configure {
($this:ident, $node:ident) => {
match $this.configure($node) {

View file

@ -56,7 +56,7 @@ macro_rules! gate_feature {
};
}
crate fn check_attribute(attr: &ast::Attribute, parse_sess: &ParseSess, features: &Features) {
pub fn check_attribute(attr: &ast::Attribute, parse_sess: &ParseSess, features: &Features) {
PostExpansionVisitor { parse_sess, features }.visit_attribute(attr)
}

View file

@ -58,8 +58,7 @@ pub use builtin_attrs::{
deprecated_attributes, is_builtin_attr, is_builtin_attr_name,
};
pub use check::{
check_crate, get_features, feature_err, emit_feature_err,
check_crate, check_attribute, get_features, feature_err, emit_feature_err,
Stability, GateIssue, UnstableFeatures,
EXPLAIN_STMT_ATTR_SYNTAX, EXPLAIN_UNSIZED_TUPLE_COERCION,
};
crate use check::check_attribute;

View file

@ -13,17 +13,12 @@
#![feature(crate_visibility_modifier)]
#![feature(label_break_value)]
#![feature(nll)]
#![feature(proc_macro_diagnostic)]
#![feature(proc_macro_internals)]
#![feature(proc_macro_span)]
#![feature(try_trait)]
#![feature(slice_patterns)]
#![feature(unicode_internals)]
#![recursion_limit="256"]
extern crate proc_macro;
pub use errors;
use rustc_data_structures::sync::Lock;
use rustc_index::bit_set::GrowableBitSet;
@ -34,26 +29,7 @@ use syntax_pos::edition::Edition;
#[cfg(test)]
mod tests;
const MACRO_ARGUMENTS: Option<&'static str> = Some("macro arguments");
// A variant of 'try!' that panics on an Err. This is used as a crutch on the
// way towards a non-panic!-prone parser. It should be used for fatal parsing
// errors; eventually we plan to convert all code using panictry to just use
// normal try.
#[macro_export]
macro_rules! panictry {
($e:expr) => ({
use std::result::Result::{Ok, Err};
use errors::FatalError;
match $e {
Ok(e) => e,
Err(mut e) => {
e.emit();
FatalError.raise()
}
}
})
}
pub const MACRO_ARGUMENTS: Option<&'static str> = Some("macro arguments");
// A variant of 'panictry!' that works on a Vec<Diagnostic> instead of a single DiagnosticBuilder.
macro_rules! panictry_buffer {
@ -157,19 +133,4 @@ pub mod print {
mod helpers;
}
pub mod ext {
mod placeholders;
mod proc_macro_server;
pub use syntax_pos::hygiene;
pub use mbe::macro_rules::compile_declarative_macro;
pub mod allocator;
pub mod base;
pub mod build;
pub mod expand;
pub mod proc_macro;
crate mod mbe;
}
pub mod early_buffered_lints;

View file

@ -212,7 +212,7 @@ impl Lit {
/// Attempts to recover an AST literal from semantic literal.
/// This function is used when the original token doesn't exist (e.g. the literal is created
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
crate fn from_lit_kind(kind: LitKind, span: Span) -> Lit {
pub fn from_lit_kind(kind: LitKind, span: Span) -> Lit {
Lit { token: kind.to_lit_token(), kind, span }
}

View file

@ -5,7 +5,7 @@ mod item;
mod module;
mod ty;
mod path;
crate use path::PathStyle;
pub use path::PathStyle;
mod stmt;
mod generics;
mod diagnostics;
@ -130,7 +130,7 @@ pub struct Parser<'a> {
/// Name of the root module this parser originated from. If `None`, then the
/// name is not known. This does not change while the parser is descending
/// into modules, and sub-parsers have new values for this name.
crate root_module_name: Option<String>,
pub root_module_name: Option<String>,
expected_tokens: Vec<TokenType>,
token_cursor: TokenCursor,
desugar_doc_comments: bool,
@ -148,7 +148,7 @@ pub struct Parser<'a> {
/// error.
pub(super) unclosed_delims: Vec<UnmatchedBrace>,
last_unexpected_token_span: Option<Span>,
crate last_type_ascription: Option<(Span, bool /* likely path typo */)>,
pub last_type_ascription: Option<(Span, bool /* likely path typo */)>,
/// If present, this `Parser` is not parsing Rust code but rather a macro call.
subparser_name: Option<&'static str>,
}
@ -330,7 +330,7 @@ enum TokenExpectType {
}
impl<'a> Parser<'a> {
crate fn new(
pub fn new(
sess: &'a ParseSess,
tokens: TokenStream,
directory: Option<Directory<'a>>,
@ -1003,7 +1003,7 @@ impl<'a> Parser<'a> {
}
}
crate fn process_potential_macro_variable(&mut self) {
pub fn process_potential_macro_variable(&mut self) {
self.token = match self.token.kind {
token::Dollar if self.token.span.from_expansion() &&
self.look_ahead(1, |t| t.is_ident()) => {
@ -1037,7 +1037,7 @@ impl<'a> Parser<'a> {
}
/// Parses a single token tree from the input.
crate fn parse_token_tree(&mut self) -> TokenTree {
pub fn parse_token_tree(&mut self) -> TokenTree {
match self.token.kind {
token::OpenDelim(..) => {
let frame = mem::replace(&mut self.token_cursor.frame,
@ -1099,7 +1099,7 @@ impl<'a> Parser<'a> {
/// If the following element can't be a tuple (i.e., it's a function definition), then
/// it's not a tuple struct field), and the contents within the parentheses isn't valid,
/// so emit a proper diagnostic.
crate fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
pub fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
maybe_whole!(self, NtVis, |x| x);
self.expected_tokens.push(TokenType::Keyword(kw::Crate));

View file

@ -170,7 +170,7 @@ impl RecoverQPath for Expr {
}
impl<'a> Parser<'a> {
crate fn fatal(&self, m: &str) -> DiagnosticBuilder<'a> {
pub fn fatal(&self, m: &str) -> DiagnosticBuilder<'a> {
self.span_fatal(self.token.span, m)
}
@ -190,11 +190,11 @@ impl<'a> Parser<'a> {
self.sess.span_diagnostic.span_err(sp, m)
}
crate fn struct_span_err<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> DiagnosticBuilder<'a> {
pub fn struct_span_err<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> DiagnosticBuilder<'a> {
self.sess.span_diagnostic.struct_span_err(sp, m)
}
crate fn span_bug<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> ! {
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> ! {
self.sess.span_diagnostic.span_bug(sp, m)
}

View file

@ -1233,7 +1233,7 @@ impl<'a> Parser<'a> {
}
/// Matches `'-' lit | lit` (cf. `ast_validation::AstValidator::check_expr_within_pat`).
crate fn parse_literal_maybe_minus(&mut self) -> PResult<'a, P<Expr>> {
pub fn parse_literal_maybe_minus(&mut self) -> PResult<'a, P<Expr>> {
maybe_whole_expr!(self);
let minus_lo = self.token.span;

View file

@ -674,7 +674,7 @@ impl<'a> Parser<'a> {
}
/// Parses an impl item.
crate fn parse_impl_item(&mut self, at_end: &mut bool) -> PResult<'a, ImplItem> {
pub fn parse_impl_item(&mut self, at_end: &mut bool) -> PResult<'a, ImplItem> {
maybe_whole!(self, NtImplItem, |x| x);
let attrs = self.parse_outer_attributes()?;
let mut unclosed_delims = vec![];
@ -850,7 +850,7 @@ impl<'a> Parser<'a> {
}
/// Parses the items in a trait declaration.
crate fn parse_trait_item(&mut self, at_end: &mut bool) -> PResult<'a, TraitItem> {
pub fn parse_trait_item(&mut self, at_end: &mut bool) -> PResult<'a, TraitItem> {
maybe_whole!(self, NtTraitItem, |x| x);
let attrs = self.parse_outer_attributes()?;
let mut unclosed_delims = vec![];
@ -1116,7 +1116,7 @@ impl<'a> Parser<'a> {
}
/// Parses a foreign item.
crate fn parse_foreign_item(&mut self, extern_sp: Span) -> PResult<'a, ForeignItem> {
pub fn parse_foreign_item(&mut self, extern_sp: Span) -> PResult<'a, ForeignItem> {
maybe_whole!(self, NtForeignItem, |ni| ni);
let attrs = self.parse_outer_attributes()?;

View file

@ -34,7 +34,7 @@ impl<'a> Parser<'a> {
/// Corresponds to `pat<no_top_alt>` in RFC 2535 and does not admit or-patterns
/// at the top level. Used when parsing the parameters of lambda expressions,
/// functions, function pointers, and `pat` macro fragments.
crate fn parse_pat(&mut self, expected: Expected) -> PResult<'a, P<Pat>> {
pub fn parse_pat(&mut self, expected: Expected) -> PResult<'a, P<Pat>> {
self.parse_pat_with_range_pat(true, expected)
}

View file

@ -13,7 +13,7 @@ use errors::{Applicability, pluralise};
/// Specifies how to parse a path.
#[derive(Copy, Clone, PartialEq)]
crate enum PathStyle {
pub enum PathStyle {
/// In some contexts, notably in expressions, paths with generic arguments are ambiguous
/// with something else. For example, in expressions `segment < ....` can be interpreted
/// as a comparison and `segment ( ....` can be interpreted as a function call.
@ -88,7 +88,7 @@ impl<'a> Parser<'a> {
/// `a::b::C::<D>` (with disambiguator)
/// `Fn(Args)` (without disambiguator)
/// `Fn::(Args)` (with disambiguator)
crate fn parse_path(&mut self, style: PathStyle) -> PResult<'a, Path> {
pub fn parse_path(&mut self, style: PathStyle) -> PResult<'a, Path> {
maybe_whole!(self, NtPath, |path| {
if style == PathStyle::Mod &&
path.segments.iter().any(|segment| segment.args.is_some()) {

View file

@ -19,7 +19,7 @@ use errors::Applicability;
impl<'a> Parser<'a> {
/// Parses a statement. This stops just before trailing semicolons on everything but items.
/// e.g., a `StmtKind::Semi` parses to a `StmtKind::Expr`, leaving the trailing `;` unconsumed.
crate fn parse_stmt(&mut self) -> PResult<'a, Option<Stmt>> {
pub fn parse_stmt(&mut self) -> PResult<'a, Option<Stmt>> {
Ok(self.parse_stmt_(true))
}
@ -299,7 +299,7 @@ impl<'a> Parser<'a> {
}
/// Parses a block. No inner attributes are allowed.
crate fn parse_block(&mut self) -> PResult<'a, P<Block>> {
pub fn parse_block(&mut self) -> PResult<'a, P<Block>> {
maybe_whole!(self, NtBlock, |x| x);
let lo = self.token.span;
@ -421,7 +421,7 @@ impl<'a> Parser<'a> {
}
/// Parses a statement, including the trailing semicolon.
crate fn parse_full_stmt(&mut self, macro_legacy_warnings: bool) -> PResult<'a, Option<Stmt>> {
pub fn parse_full_stmt(&mut self, macro_legacy_warnings: bool) -> PResult<'a, Option<Stmt>> {
// Skip looking for a trailing semicolon when we have an interpolated statement.
maybe_whole!(self, NtStmt, |x| Some(x));

View file

@ -433,13 +433,13 @@ impl<'a> Parser<'a> {
}
}
crate fn check_lifetime(&mut self) -> bool {
pub fn check_lifetime(&mut self) -> bool {
self.expected_tokens.push(TokenType::Lifetime);
self.token.is_lifetime()
}
/// Parses a single lifetime `'a` or panics.
crate fn expect_lifetime(&mut self) -> Lifetime {
pub fn expect_lifetime(&mut self) -> Lifetime {
if let Some(ident) = self.token.lifetime() {
let span = self.token.span;
self.bump();

View file

@ -285,7 +285,7 @@ impl TokenKind {
}
impl Token {
crate fn new(kind: TokenKind, span: Span) -> Self {
pub fn new(kind: TokenKind, span: Span) -> Self {
Token { kind, span }
}
@ -295,12 +295,12 @@ impl Token {
}
/// Recovers a `Token` from an `ast::Ident`. This creates a raw identifier if necessary.
crate fn from_ast_ident(ident: ast::Ident) -> Self {
pub fn from_ast_ident(ident: ast::Ident) -> Self {
Token::new(Ident(ident.name, ident.is_raw_guess()), ident.span)
}
/// Return this token by value and leave a dummy token in its place.
crate fn take(&mut self) -> Self {
pub fn take(&mut self) -> Self {
mem::replace(self, Token::dummy())
}
@ -321,7 +321,7 @@ impl Token {
}
/// Returns `true` if the token can appear at the start of an expression.
crate fn can_begin_expr(&self) -> bool {
pub fn can_begin_expr(&self) -> bool {
match self.kind {
Ident(name, is_raw) =>
ident_can_begin_expr(name, self.span, is_raw), // value name or keyword
@ -353,7 +353,7 @@ impl Token {
}
/// Returns `true` if the token can appear at the start of a type.
crate fn can_begin_type(&self) -> bool {
pub fn can_begin_type(&self) -> bool {
match self.kind {
Ident(name, is_raw) =>
ident_can_begin_type(name, self.span, is_raw), // type name or keyword
@ -396,7 +396,7 @@ impl Token {
}
/// Returns `true` if the token is any literal
crate fn is_lit(&self) -> bool {
pub fn is_lit(&self) -> bool {
match self.kind {
Literal(..) => true,
_ => false,
@ -412,7 +412,7 @@ impl Token {
/// Returns `true` if the token is any literal, a minus (which can prefix a literal,
/// for example a '-42', or one of the boolean idents).
crate fn can_begin_literal_or_bool(&self) -> bool {
pub fn can_begin_literal_or_bool(&self) -> bool {
match self.kind {
Literal(..) | BinOp(Minus) => true,
Ident(name, false) if name.is_bool_lit() => true,

View file

@ -156,7 +156,7 @@ use IsJoint::*;
impl TokenStream {
/// Given a `TokenStream` with a `Stream` of only two arguments, return a new `TokenStream`
/// separating the two arguments with a comma for diagnostic suggestions.
pub(crate) fn add_comma(&self) -> Option<(TokenStream, Span)> {
pub fn add_comma(&self) -> Option<(TokenStream, Span)> {
// Used to suggest if a user writes `foo!(a b);`
let mut suggestion = None;
let mut iter = self.0.iter().enumerate().peekable();

View file

@ -0,0 +1,26 @@
[package]
authors = ["The Rust Project Developers"]
name = "syntax_expand"
version = "0.0.0"
edition = "2018"
build = false
[lib]
name = "syntax_expand"
path = "lib.rs"
doctest = false
[dependencies]
bitflags = "1.0"
rustc_serialize = { path = "../libserialize", package = "serialize" }
log = "0.4"
scoped-tls = "1.0"
lazy_static = "1.0.0"
syntax_pos = { path = "../libsyntax_pos" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_index = { path = "../librustc_index" }
rustc_lexer = { path = "../librustc_lexer" }
rustc_target = { path = "../librustc_target" }
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
syntax = { path = "../libsyntax" }

View file

@ -1,5 +1,5 @@
use crate::{ast, attr, visit};
use crate::symbol::{sym, Symbol};
use syntax::{ast, attr, visit};
use syntax::symbol::{sym, Symbol};
use syntax_pos::Span;
#[derive(Clone, Copy)]

View file

@ -1,18 +1,19 @@
use crate::ast::{self, NodeId, Attribute, Name, PatKind};
use crate::attr::{self, HasAttrs, Stability, Deprecation};
use crate::source_map::SourceMap;
use crate::edition::Edition;
use crate::ext::expand::{self, AstFragment, Invocation};
use crate::ext::hygiene::ExpnId;
use crate::mut_visit::{self, MutVisitor};
use crate::parse::{self, parser, DirectoryOwnership};
use crate::parse::token;
use crate::ptr::P;
use crate::sess::ParseSess;
use crate::symbol::{kw, sym, Ident, Symbol};
use crate::{ThinVec, MACRO_ARGUMENTS};
use crate::tokenstream::{self, TokenStream};
use crate::visit::Visitor;
use crate::expand::{self, AstFragment, Invocation};
use crate::hygiene::ExpnId;
use syntax::ast::{self, NodeId, Attribute, Name, PatKind};
use syntax::attr::{self, HasAttrs, Stability, Deprecation};
use syntax::source_map::SourceMap;
use syntax::edition::Edition;
use syntax::mut_visit::{self, MutVisitor};
use syntax::parse::{self, parser, DirectoryOwnership};
use syntax::parse::token;
use syntax::ptr::P;
use syntax::sess::ParseSess;
use syntax::symbol::{kw, sym, Ident, Symbol};
use syntax::{ThinVec, MACRO_ARGUMENTS};
use syntax::tokenstream::{self, TokenStream};
use syntax::visit::Visitor;
use errors::{DiagnosticBuilder, DiagnosticId};
use smallvec::{smallvec, SmallVec};

View file

@ -1,10 +1,11 @@
use crate::ast::{self, Ident, Expr, BlockCheckMode, UnOp, PatKind};
use crate::attr;
use crate::source_map::{respan, Spanned};
use crate::ext::base::ExtCtxt;
use crate::ptr::P;
use crate::symbol::{kw, sym, Symbol};
use crate::ThinVec;
use crate::base::ExtCtxt;
use syntax::ast::{self, Ident, Expr, BlockCheckMode, UnOp, PatKind};
use syntax::attr;
use syntax::source_map::{respan, Spanned};
use syntax::ptr::P;
use syntax::symbol::{kw, sym, Symbol};
use syntax::ThinVec;
use syntax_pos::{Pos, Span};

View file

@ -1,24 +1,26 @@
use crate::ast::{self, AttrItem, Block, Ident, LitKind, NodeId, PatKind, Path};
use crate::ast::{MacStmtStyle, StmtKind, ItemKind};
use crate::attr::{self, HasAttrs};
use crate::source_map::respan;
use crate::config::StripUnconfigured;
use crate::ext::base::*;
use crate::ext::proc_macro::{collect_derives, MarkAttrs};
use crate::ext::hygiene::{ExpnId, SyntaxContext, ExpnData, ExpnKind};
use crate::ext::mbe::macro_rules::annotate_err_with_kind;
use crate::ext::placeholders::{placeholder, PlaceholderExpander};
use crate::feature_gate::{self, Features, GateIssue, is_builtin_attr, emit_feature_err};
use crate::mut_visit::*;
use crate::parse::{DirectoryOwnership, PResult};
use crate::parse::token;
use crate::parse::parser::Parser;
use crate::print::pprust;
use crate::ptr::P;
use crate::symbol::{sym, Symbol};
use crate::tokenstream::{TokenStream, TokenTree};
use crate::visit::Visitor;
use crate::util::map_in_place::MapInPlace;
use crate::base::*;
use crate::proc_macro::{collect_derives, MarkAttrs};
use crate::hygiene::{ExpnId, SyntaxContext, ExpnData, ExpnKind};
use crate::mbe::macro_rules::annotate_err_with_kind;
use crate::placeholders::{placeholder, PlaceholderExpander};
use syntax::ast::{self, AttrItem, Block, Ident, LitKind, NodeId, PatKind, Path};
use syntax::ast::{MacStmtStyle, StmtKind, ItemKind};
use syntax::attr::{self, HasAttrs};
use syntax::source_map::respan;
use syntax::configure;
use syntax::config::StripUnconfigured;
use syntax::feature_gate::{self, Features, GateIssue, is_builtin_attr, emit_feature_err};
use syntax::mut_visit::*;
use syntax::parse::{DirectoryOwnership, PResult};
use syntax::parse::token;
use syntax::parse::parser::Parser;
use syntax::print::pprust;
use syntax::ptr::P;
use syntax::symbol::{sym, Symbol};
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::visit::Visitor;
use syntax::util::map_in_place::MapInPlace;
use errors::{Applicability, FatalError};
use smallvec::{smallvec, SmallVec};
@ -116,8 +118,8 @@ macro_rules! ast_fragments {
}
}
impl<'a> MacResult for crate::ext::mbe::macro_rules::ParserAnyMacro<'a> {
$(fn $make_ast(self: Box<crate::ext::mbe::macro_rules::ParserAnyMacro<'a>>)
impl<'a> MacResult for crate::mbe::macro_rules::ParserAnyMacro<'a> {
$(fn $make_ast(self: Box<crate::mbe::macro_rules::ParserAnyMacro<'a>>)
-> Option<$AstTy> {
Some(self.make(AstFragmentKind::$Kind).$make_ast())
})*
@ -752,9 +754,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
span: Span,
) -> AstFragment {
let mut parser = self.cx.new_parser_from_tts(toks);
match parser.parse_ast_fragment(kind, false) {
match parse_ast_fragment(&mut parser, kind, false) {
Ok(fragment) => {
parser.ensure_complete_parse(path, kind.name(), span);
ensure_complete_parse(&mut parser, path, kind.name(), span);
fragment
}
Err(mut err) => {
@ -768,59 +770,61 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
}
}
impl<'a> Parser<'a> {
pub fn parse_ast_fragment(&mut self, kind: AstFragmentKind, macro_legacy_warnings: bool)
-> PResult<'a, AstFragment> {
pub fn parse_ast_fragment<'a>(
this: &mut Parser<'a>,
kind: AstFragmentKind,
macro_legacy_warnings: bool,
) -> PResult<'a, AstFragment> {
Ok(match kind {
AstFragmentKind::Items => {
let mut items = SmallVec::new();
while let Some(item) = self.parse_item()? {
while let Some(item) = this.parse_item()? {
items.push(item);
}
AstFragment::Items(items)
}
AstFragmentKind::TraitItems => {
let mut items = SmallVec::new();
while self.token != token::Eof {
items.push(self.parse_trait_item(&mut false)?);
while this.token != token::Eof {
items.push(this.parse_trait_item(&mut false)?);
}
AstFragment::TraitItems(items)
}
AstFragmentKind::ImplItems => {
let mut items = SmallVec::new();
while self.token != token::Eof {
items.push(self.parse_impl_item(&mut false)?);
while this.token != token::Eof {
items.push(this.parse_impl_item(&mut false)?);
}
AstFragment::ImplItems(items)
}
AstFragmentKind::ForeignItems => {
let mut items = SmallVec::new();
while self.token != token::Eof {
items.push(self.parse_foreign_item(DUMMY_SP)?);
while this.token != token::Eof {
items.push(this.parse_foreign_item(DUMMY_SP)?);
}
AstFragment::ForeignItems(items)
}
AstFragmentKind::Stmts => {
let mut stmts = SmallVec::new();
while self.token != token::Eof &&
while this.token != token::Eof &&
// won't make progress on a `}`
self.token != token::CloseDelim(token::Brace) {
if let Some(stmt) = self.parse_full_stmt(macro_legacy_warnings)? {
this.token != token::CloseDelim(token::Brace) {
if let Some(stmt) = this.parse_full_stmt(macro_legacy_warnings)? {
stmts.push(stmt);
}
}
AstFragment::Stmts(stmts)
}
AstFragmentKind::Expr => AstFragment::Expr(self.parse_expr()?),
AstFragmentKind::Expr => AstFragment::Expr(this.parse_expr()?),
AstFragmentKind::OptExpr => {
if self.token != token::Eof {
AstFragment::OptExpr(Some(self.parse_expr()?))
if this.token != token::Eof {
AstFragment::OptExpr(Some(this.parse_expr()?))
} else {
AstFragment::OptExpr(None)
}
},
AstFragmentKind::Ty => AstFragment::Ty(self.parse_ty()?),
AstFragmentKind::Pat => AstFragment::Pat(self.parse_pat(None)?),
AstFragmentKind::Ty => AstFragment::Ty(this.parse_ty()?),
AstFragmentKind::Pat => AstFragment::Pat(this.parse_pat(None)?),
AstFragmentKind::Arms
| AstFragmentKind::Fields
| AstFragmentKind::FieldPats
@ -830,26 +834,31 @@ impl<'a> Parser<'a> {
| AstFragmentKind::Variants
=> panic!("unexpected AST fragment kind"),
})
}
}
pub fn ensure_complete_parse(&mut self, macro_path: &Path, kind_name: &str, span: Span) {
if self.token != token::Eof {
pub fn ensure_complete_parse<'a>(
this: &mut Parser<'a>,
macro_path: &Path,
kind_name: &str,
span: Span,
) {
if this.token != token::Eof {
let msg = format!("macro expansion ignores token `{}` and any following",
self.this_token_to_string());
this.this_token_to_string());
// Avoid emitting backtrace info twice.
let def_site_span = self.token.span.with_ctxt(SyntaxContext::root());
let mut err = self.struct_span_err(def_site_span, &msg);
let def_site_span = this.token.span.with_ctxt(SyntaxContext::root());
let mut err = this.struct_span_err(def_site_span, &msg);
err.span_label(span, "caused by the macro expansion here");
let msg = format!(
"the usage of `{}!` is likely invalid in {} context",
pprust::path_to_string(&macro_path),
pprust::path_to_string(macro_path),
kind_name,
);
err.note(&msg);
let semi_span = self.sess.source_map().next_point(span);
let semi_span = this.sess.source_map().next_point(span);
let semi_full_span = semi_span.to(self.sess.source_map().next_point(semi_span));
match self.sess.source_map().span_to_snippet(semi_full_span) {
let semi_full_span = semi_span.to(this.sess.source_map().next_point(semi_span));
match this.sess.source_map().span_to_snippet(semi_full_span) {
Ok(ref snippet) if &snippet[..] != ";" && kind_name == "expression" => {
err.span_suggestion(
semi_span,
@ -862,7 +871,6 @@ impl<'a> Parser<'a> {
}
err.emit();
}
}
}
struct InvocationCollector<'a, 'b> {

View file

@ -0,0 +1,38 @@
#![feature(crate_visibility_modifier)]
#![feature(proc_macro_diagnostic)]
#![feature(proc_macro_internals)]
#![feature(proc_macro_span)]
extern crate proc_macro as pm;
// A variant of 'try!' that panics on an Err. This is used as a crutch on the
// way towards a non-panic!-prone parser. It should be used for fatal parsing
// errors; eventually we plan to convert all code using panictry to just use
// normal try.
#[macro_export]
macro_rules! panictry {
($e:expr) => ({
use std::result::Result::{Ok, Err};
use errors::FatalError;
match $e {
Ok(e) => e,
Err(mut e) => {
e.emit();
FatalError.raise()
}
}
})
}
mod placeholders;
mod proc_macro_server;
pub use syntax_pos::hygiene;
pub use mbe::macro_rules::compile_declarative_macro;
pub mod allocator;
pub mod base;
pub mod build;
pub mod expand;
pub mod proc_macro;
crate mod mbe;

View file

@ -9,9 +9,9 @@ crate mod macro_parser;
crate mod macro_rules;
crate mod quoted;
use crate::ast;
use crate::parse::token::{self, Token, TokenKind};
use crate::tokenstream::{DelimSpan};
use syntax::ast;
use syntax::parse::token::{self, Token, TokenKind};
use syntax::tokenstream::{DelimSpan};
use syntax_pos::{BytePos, Span};

View file

@ -104,13 +104,13 @@
//! Kleene operators under which a meta-variable is repeating is the concatenation of the stacks
//! stored when entering a macro definition starting from the state in which the meta-variable is
//! bound.
use crate::ast::NodeId;
use crate::early_buffered_lints::BufferedEarlyLintId;
use crate::ext::mbe::{KleeneToken, TokenTree};
use crate::parse::token::TokenKind;
use crate::parse::token::{DelimToken, Token};
use crate::sess::ParseSess;
use crate::symbol::{kw, sym};
use crate::mbe::{KleeneToken, TokenTree};
use syntax::ast::NodeId;
use syntax::early_buffered_lints::BufferedEarlyLintId;
use syntax::parse::token::{DelimToken, Token, TokenKind};
use syntax::sess::ParseSess;
use syntax::symbol::{kw, sym};
use rustc_data_structures::fx::FxHashMap;
use smallvec::SmallVec;

View file

@ -74,15 +74,16 @@ crate use NamedMatch::*;
crate use ParseResult::*;
use TokenTreeOrTokenTreeSlice::*;
use crate::ast::{Ident, Name};
use crate::ext::mbe::{self, TokenTree};
use crate::parse::{Directory, PResult};
use crate::parse::parser::{Parser, PathStyle};
use crate::parse::token::{self, DocComment, Nonterminal, Token};
use crate::print::pprust;
use crate::sess::ParseSess;
use crate::symbol::{kw, sym, Symbol};
use crate::tokenstream::{DelimSpan, TokenStream};
use crate::mbe::{self, TokenTree};
use syntax::ast::{Ident, Name};
use syntax::parse::{Directory, PResult};
use syntax::parse::parser::{Parser, PathStyle};
use syntax::parse::token::{self, DocComment, Nonterminal, Token};
use syntax::print::pprust;
use syntax::sess::ParseSess;
use syntax::symbol::{kw, sym, Symbol};
use syntax::tokenstream::{DelimSpan, TokenStream};
use errors::FatalError;
use smallvec::{smallvec, SmallVec};
@ -651,7 +652,7 @@ pub(super) fn parse(
directory,
recurse_into_modules,
true,
crate::MACRO_ARGUMENTS,
syntax::MACRO_ARGUMENTS,
);
// A queue of possible matcher positions. We initialize it with the matcher position in which

View file

@ -1,24 +1,25 @@
use crate::ast;
use crate::attr::{self, TransparencyError};
use crate::edition::Edition;
use crate::ext::base::{DummyResult, ExtCtxt, MacResult, TTMacroExpander};
use crate::ext::base::{SyntaxExtension, SyntaxExtensionKind};
use crate::ext::expand::{AstFragment, AstFragmentKind};
use crate::ext::mbe;
use crate::ext::mbe::macro_check;
use crate::ext::mbe::macro_parser::parse;
use crate::ext::mbe::macro_parser::{Error, Failure, Success};
use crate::ext::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedParseResult};
use crate::ext::mbe::transcribe::transcribe;
use crate::feature_gate::Features;
use crate::parse::parser::Parser;
use crate::parse::token::TokenKind::*;
use crate::parse::token::{self, NtTT, Token};
use crate::parse::Directory;
use crate::print::pprust;
use crate::sess::ParseSess;
use crate::symbol::{kw, sym, Symbol};
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
use crate::base::{DummyResult, ExtCtxt, MacResult, TTMacroExpander};
use crate::base::{SyntaxExtension, SyntaxExtensionKind};
use crate::expand::{AstFragment, AstFragmentKind, ensure_complete_parse, parse_ast_fragment};
use crate::mbe;
use crate::mbe::macro_check;
use crate::mbe::macro_parser::parse;
use crate::mbe::macro_parser::{Error, Failure, Success};
use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedParseResult};
use crate::mbe::transcribe::transcribe;
use syntax::ast;
use syntax::attr::{self, TransparencyError};
use syntax::edition::Edition;
use syntax::feature_gate::Features;
use syntax::parse::parser::Parser;
use syntax::parse::token::TokenKind::*;
use syntax::parse::token::{self, NtTT, Token};
use syntax::parse::Directory;
use syntax::print::pprust;
use syntax::sess::ParseSess;
use syntax::symbol::{kw, sym, Symbol};
use syntax::tokenstream::{DelimSpan, TokenStream};
use errors::{DiagnosticBuilder, FatalError};
use log::debug;
@ -66,7 +67,7 @@ crate fn annotate_err_with_kind(
impl<'a> ParserAnyMacro<'a> {
crate fn make(mut self: Box<ParserAnyMacro<'a>>, kind: AstFragmentKind) -> AstFragment {
let ParserAnyMacro { site_span, macro_ident, ref mut parser, arm_span } = *self;
let fragment = panictry!(parser.parse_ast_fragment(kind, true).map_err(|mut e| {
let fragment = panictry!(parse_ast_fragment(parser, kind, true).map_err(|mut e| {
if parser.token == token::Eof && e.message().ends_with(", found `<eof>`") {
if !e.span.is_dummy() {
// early end of macro arm (#52866)
@ -128,7 +129,7 @@ impl<'a> ParserAnyMacro<'a> {
// Make sure we don't have any tokens left to parse so we don't silently drop anything.
let path = ast::Path::from_ident(macro_ident.with_span_pos(site_span));
parser.ensure_complete_parse(&path, kind.name(), site_span);
ensure_complete_parse(parser, &path, kind.name(), site_span);
fragment
}
}
@ -189,7 +190,7 @@ fn generic_extension<'cx>(
_ => cx.span_bug(sp, "malformed macro lhs"),
};
match TokenTree::parse(cx, lhs_tt, arg.clone()) {
match parse_tt(cx, lhs_tt, arg.clone()) {
Success(named_matches) => {
let rhs = match rhses[i] {
// ignore delimiters
@ -265,7 +266,7 @@ fn generic_extension<'cx>(
mbe::TokenTree::Delimited(_, ref delim) => &delim.tts[..],
_ => continue,
};
match TokenTree::parse(cx, lhs_tt, arg.clone()) {
match parse_tt(cx, lhs_tt, arg.clone()) {
Success(_) => {
if comma_span.is_dummy() {
err.note("you might be missing a comma");
@ -1158,7 +1159,7 @@ fn is_legal_fragment_specifier(
fn quoted_tt_to_string(tt: &mbe::TokenTree) -> String {
match *tt {
mbe::TokenTree::Token(ref token) => crate::print::pprust::token_to_string(&token),
mbe::TokenTree::Token(ref token) => pprust::token_to_string(&token),
mbe::TokenTree::MetaVar(_, name) => format!("${}", name),
mbe::TokenTree::MetaVarDecl(_, name, kind) => format!("${}:{}", name, kind),
_ => panic!(
@ -1168,17 +1169,14 @@ fn quoted_tt_to_string(tt: &mbe::TokenTree) -> String {
}
}
impl TokenTree {
/// Use this token tree as a matcher to parse given tts.
fn parse(cx: &ExtCtxt<'_>, mtch: &[mbe::TokenTree], tts: TokenStream)
-> NamedParseResult {
/// Use this token tree as a matcher to parse given tts.
fn parse_tt(cx: &ExtCtxt<'_>, mtch: &[mbe::TokenTree], tts: TokenStream) -> NamedParseResult {
// `None` is because we're not interpolating
let directory = Directory {
path: Cow::from(cx.current_expansion.module.directory.as_path()),
ownership: cx.current_expansion.directory_ownership,
};
parse(cx.parse_sess(), tts, mtch, Some(directory), true)
}
}
/// Generates an appropriate parsing failure message. For EOF, this is "unexpected end...". For

View file

@ -1,11 +1,12 @@
use crate::ast;
use crate::ext::mbe::macro_parser;
use crate::ext::mbe::{TokenTree, KleeneOp, KleeneToken, SequenceRepetition, Delimited};
use crate::parse::token::{self, Token};
use crate::print::pprust;
use crate::sess::ParseSess;
use crate::symbol::kw;
use crate::tokenstream;
use crate::mbe::macro_parser;
use crate::mbe::{TokenTree, KleeneOp, KleeneToken, SequenceRepetition, Delimited};
use syntax::ast;
use syntax::parse::token::{self, Token};
use syntax::print::pprust;
use syntax::sess::ParseSess;
use syntax::symbol::kw;
use syntax::tokenstream;
use syntax_pos::Span;

View file

@ -1,10 +1,11 @@
use crate::ast::{Ident, Mac};
use crate::ext::base::ExtCtxt;
use crate::ext::mbe;
use crate::ext::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedMatch};
use crate::mut_visit::{self, MutVisitor};
use crate::parse::token::{self, NtTT, Token};
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint};
use crate::base::ExtCtxt;
use crate::mbe;
use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedMatch};
use syntax::ast::{Ident, Mac};
use syntax::mut_visit::{self, MutVisitor};
use syntax::parse::token::{self, NtTT, Token};
use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint};
use smallvec::{smallvec, SmallVec};

View file

@ -1,11 +1,12 @@
use crate::ast::{self, NodeId};
use crate::source_map::{DUMMY_SP, dummy_spanned};
use crate::ext::base::ExtCtxt;
use crate::ext::expand::{AstFragment, AstFragmentKind};
use crate::tokenstream::TokenStream;
use crate::mut_visit::*;
use crate::ptr::P;
use crate::ThinVec;
use crate::base::ExtCtxt;
use crate::expand::{AstFragment, AstFragmentKind};
use syntax::ast::{self, NodeId};
use syntax::source_map::{DUMMY_SP, dummy_spanned};
use syntax::tokenstream::TokenStream;
use syntax::mut_visit::*;
use syntax::ptr::P;
use syntax::ThinVec;
use smallvec::{smallvec, SmallVec};

View file

@ -1,22 +1,22 @@
use crate::ast::{self, ItemKind, Attribute, Mac};
use crate::attr::{mark_used, mark_known};
use crate::errors::{Applicability, FatalError};
use crate::ext::base::{self, *};
use crate::ext::proc_macro_server;
use crate::parse::{self, token};
use crate::symbol::sym;
use crate::tokenstream::{self, TokenStream};
use crate::visit::Visitor;
use crate::base::{self, *};
use crate::proc_macro_server;
use syntax::ast::{self, ItemKind, Attribute, Mac};
use syntax::attr::{mark_used, mark_known};
use syntax::errors::{Applicability, FatalError};
use syntax::parse::{self, token};
use syntax::symbol::sym;
use syntax::tokenstream::{self, TokenStream};
use syntax::visit::Visitor;
use rustc_data_structures::sync::Lrc;
use syntax_pos::{Span, DUMMY_SP};
const EXEC_STRATEGY: proc_macro::bridge::server::SameThread =
proc_macro::bridge::server::SameThread;
const EXEC_STRATEGY: pm::bridge::server::SameThread = pm::bridge::server::SameThread;
pub struct BangProcMacro {
pub client: proc_macro::bridge::client::Client<
fn(proc_macro::TokenStream) -> proc_macro::TokenStream,
pub client: pm::bridge::client::Client<
fn(pm::TokenStream) -> pm::TokenStream,
>,
}
@ -44,9 +44,7 @@ impl base::ProcMacro for BangProcMacro {
}
pub struct AttrProcMacro {
pub client: proc_macro::bridge::client::Client<
fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream,
>,
pub client: pm::bridge::client::Client<fn(pm::TokenStream, pm::TokenStream) -> pm::TokenStream>,
}
impl base::AttrProcMacro for AttrProcMacro {
@ -74,9 +72,7 @@ impl base::AttrProcMacro for AttrProcMacro {
}
pub struct ProcMacroDerive {
pub client: proc_macro::bridge::client::Client<
fn(proc_macro::TokenStream) -> proc_macro::TokenStream,
>,
pub client: pm::bridge::client::Client<fn(pm::TokenStream) -> pm::TokenStream>,
}
impl MultiItemModifier for ProcMacroDerive {

View file

@ -1,18 +1,19 @@
use crate::ast;
use crate::ext::base::ExtCtxt;
use crate::parse::{self, token};
use crate::parse::lexer::comments;
use crate::print::pprust;
use crate::sess::ParseSess;
use crate::tokenstream::{self, DelimSpan, IsJoint::*, TokenStream, TreeAndJoint};
use crate::base::ExtCtxt;
use syntax::ast;
use syntax::parse::{self, token};
use syntax::parse::lexer::comments;
use syntax::print::pprust;
use syntax::sess::ParseSess;
use syntax::tokenstream::{self, DelimSpan, IsJoint::*, TokenStream, TreeAndJoint};
use errors::Diagnostic;
use rustc_data_structures::sync::Lrc;
use syntax_pos::{BytePos, FileName, MultiSpan, Pos, SourceFile, Span};
use syntax_pos::symbol::{kw, sym, Symbol};
use proc_macro::{Delimiter, Level, LineColumn, Spacing};
use proc_macro::bridge::{server, TokenTree};
use pm::{Delimiter, Level, LineColumn, Spacing};
use pm::bridge::{server, TokenTree};
use std::{ascii, panic};
use std::ops::Bound;
@ -51,7 +52,7 @@ impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec<Self>)>
{
fn from_internal(((tree, is_joint), sess, stack): (TreeAndJoint, &ParseSess, &mut Vec<Self>))
-> Self {
use crate::parse::token::*;
use syntax::parse::token::*;
let joint = is_joint == Joint;
let Token { kind, span } = match tree {
@ -192,7 +193,7 @@ impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec<Self>)>
impl ToInternal<TokenStream> for TokenTree<Group, Punct, Ident, Literal> {
fn to_internal(self) -> TokenStream {
use crate::parse::token::*;
use syntax::parse::token::*;
let (ch, joint, span) = match self {
TokenTree::Punct(Punct { ch, joint, span }) => (ch, joint, span),

View file

@ -17,4 +17,5 @@ rustc_data_structures = { path = "../librustc_data_structures" }
rustc_target = { path = "../librustc_target" }
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
syntax = { path = "../libsyntax" }
syntax_expand = { path = "../libsyntax_expand" }
syntax_pos = { path = "../libsyntax_pos" }

View file

@ -7,7 +7,7 @@ use rustc_data_structures::thin_vec::ThinVec;
use errors::DiagnosticBuilder;
use syntax::ast;
use syntax::ext::base::{self, *};
use syntax_expand::base::{self, *};
use syntax::parse::token::{self, Token};
use syntax::ptr::P;
use syntax::symbol::{kw, sym, Symbol};

View file

@ -1,7 +1,7 @@
use errors::{Applicability, DiagnosticBuilder};
use syntax::ast::{self, *};
use syntax::ext::base::*;
use syntax_expand::base::*;
use syntax::parse::token::{self, TokenKind};
use syntax::parse::parser::Parser;
use syntax::print::pprust;

View file

@ -5,7 +5,7 @@
use errors::DiagnosticBuilder;
use syntax::ast;
use syntax::ext::base::{self, *};
use syntax_expand::base::{self, *};
use syntax::attr;
use syntax::tokenstream::TokenStream;
use syntax::parse::token;

View file

@ -2,9 +2,9 @@
use syntax::ast::{self, AttrItem, AttrStyle};
use syntax::attr::mk_attr;
use syntax::panictry;
use syntax::parse::{self, token};
use syntax::sess::ParseSess;
use syntax_expand::panictry;
use syntax_pos::FileName;
pub fn inject(mut krate: ast::Crate, parse_sess: &ParseSess, attrs: &[String]) -> ast::Crate {

View file

@ -1,6 +1,6 @@
// The compiler code necessary to support the compile_error! extension.
use syntax::ext::base::{self, *};
use syntax_expand::base::{self, *};
use syntax_pos::Span;
use syntax::tokenstream::TokenStream;

View file

@ -1,5 +1,5 @@
use syntax::ast;
use syntax::ext::base::{self, DummyResult};
use syntax_expand::base::{self, DummyResult};
use syntax::symbol::Symbol;
use syntax::tokenstream::TokenStream;

View file

@ -1,7 +1,7 @@
use rustc_data_structures::thin_vec::ThinVec;
use syntax::ast;
use syntax::ext::base::{self, *};
use syntax_expand::base::{self, *};
use syntax::parse::token::{self, Token};
use syntax::ptr::P;
use syntax_pos::Span;

View file

@ -3,7 +3,7 @@ use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;
use syntax::ast::MetaItem;
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax_expand::base::{Annotatable, ExtCtxt};
use syntax_pos::Span;
pub fn expand_deriving_copy(cx: &mut ExtCtxt<'_>,

View file

@ -3,7 +3,7 @@ use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;
use syntax::ast::{self, Expr, GenericArg, Generics, ItemKind, MetaItem, VariantData};
use syntax::ext::base::{Annotatable, ExtCtxt, SpecialDerives};
use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives};
use syntax::ptr::P;
use syntax::symbol::{kw, sym, Symbol};
use syntax_pos::Span;

View file

@ -3,7 +3,7 @@ use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;
use syntax::ast::{self, Ident, Expr, MetaItem, GenericArg};
use syntax::ext::base::{Annotatable, ExtCtxt, SpecialDerives};
use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives};
use syntax::ptr::P;
use syntax::symbol::{sym, Symbol};
use syntax_pos::Span;

View file

@ -3,7 +3,7 @@ use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;
use syntax::ast::{self, Expr, MetaItem};
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax_expand::base::{Annotatable, ExtCtxt};
use syntax::ptr::P;
use syntax::symbol::sym;
use syntax_pos::Span;

View file

@ -3,7 +3,7 @@ use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;
use syntax::ast::{BinOpKind, Expr, MetaItem};
use syntax::ext::base::{Annotatable, ExtCtxt, SpecialDerives};
use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives};
use syntax::ptr::P;
use syntax::symbol::sym;
use syntax_pos::Span;

View file

@ -5,7 +5,7 @@ use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;
use syntax::ast::{self, BinOpKind, Expr, MetaItem};
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax_expand::base::{Annotatable, ExtCtxt};
use syntax::ptr::P;
use syntax::symbol::{sym, Symbol};
use syntax_pos::Span;

View file

@ -6,7 +6,7 @@ use rustc_data_structures::thin_vec::ThinVec;
use syntax::ast::{self, Ident};
use syntax::ast::{Expr, MetaItem};
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax_expand::base::{Annotatable, ExtCtxt};
use syntax::ptr::P;
use syntax::symbol::sym;
use syntax_pos::{DUMMY_SP, Span};

View file

@ -6,7 +6,7 @@ use crate::deriving::generic::ty::*;
use syntax::ast;
use syntax::ast::{Expr, MetaItem, Mutability};
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax_expand::base::{Annotatable, ExtCtxt};
use syntax::ptr::P;
use syntax::symbol::Symbol;
use syntax_pos::Span;

View file

@ -3,7 +3,7 @@ use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;
use syntax::ast::{Expr, MetaItem};
use syntax::ext::base::{Annotatable, DummyResult, ExtCtxt};
use syntax_expand::base::{Annotatable, DummyResult, ExtCtxt};
use syntax::ptr::P;
use syntax::symbol::{kw, sym};
use syntax::span_err;

View file

@ -90,7 +90,7 @@ use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;
use syntax::ast::{Expr, ExprKind, MetaItem, Mutability};
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax_expand::base::{Annotatable, ExtCtxt};
use syntax::ptr::P;
use syntax::symbol::Symbol;
use syntax_pos::Span;

View file

@ -186,12 +186,12 @@ use rustc_target::spec::abi::Abi;
use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind};
use syntax::ast::{VariantData, GenericParamKind, GenericArg};
use syntax::attr;
use syntax::ext::base::{Annotatable, ExtCtxt, SpecialDerives};
use syntax::source_map::respan;
use syntax::util::map_in_place::MapInPlace;
use syntax::ptr::P;
use syntax::sess::ParseSess;
use syntax::symbol::{Symbol, kw, sym};
use syntax_expand::base::{Annotatable, ExtCtxt, SpecialDerives};
use syntax_pos::{Span};
use ty::{LifetimeBounds, Path, Ptr, PtrTy, Self_, Ty};

View file

@ -5,7 +5,7 @@ pub use PtrTy::*;
pub use Ty::*;
use syntax::ast::{self, Expr, GenericParamKind, Generics, Ident, SelfKind, GenericArg};
use syntax::ext::base::ExtCtxt;
use syntax_expand::base::ExtCtxt;
use syntax::source_map::{respan, DUMMY_SP};
use syntax::ptr::P;
use syntax_pos::Span;

View file

@ -3,7 +3,7 @@ use crate::deriving::generic::*;
use crate::deriving::generic::ty::*;
use syntax::ast::{Expr, MetaItem, Mutability};
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax_expand::base::{Annotatable, ExtCtxt};
use syntax::ptr::P;
use syntax::symbol::sym;
use syntax_pos::Span;

View file

@ -1,7 +1,7 @@
//! The compiler code necessary to implement the `#[derive]` extensions.
use syntax::ast::{self, MetaItem};
use syntax::ext::base::{Annotatable, ExtCtxt, MultiItemModifier};
use syntax_expand::base::{Annotatable, ExtCtxt, MultiItemModifier};
use syntax::ptr::P;
use syntax::symbol::{Symbol, sym};
use syntax_pos::Span;

View file

@ -4,7 +4,7 @@
//
use syntax::ast::{self, Ident, GenericArg};
use syntax::ext::base::{self, *};
use syntax_expand::base::{self, *};
use syntax::symbol::{kw, sym, Symbol};
use syntax_pos::Span;
use syntax::tokenstream::TokenStream;

Some files were not shown because too many files have changed in this diff Show more