Move syntax::ext::hygiene
to syntax_pos::hygiene
.
This commit is contained in:
parent
07a34293fa
commit
1979f96549
8 changed files with 24 additions and 18 deletions
|
@ -92,7 +92,7 @@ impl<'a> DefCollector<'a> {
|
|||
fn visit_macro_invoc(&mut self, id: NodeId, const_expr: bool) {
|
||||
if let Some(ref mut visit) = self.visit_macro_invoc {
|
||||
visit(MacroInvocationData {
|
||||
mark: Mark::from_placeholder_id(id),
|
||||
mark: id.placeholder_to_mark(),
|
||||
const_expr: const_expr,
|
||||
def_index: self.parent_def.unwrap(),
|
||||
})
|
||||
|
|
|
@ -680,7 +680,7 @@ pub struct BuildReducedGraphVisitor<'a, 'b: 'a> {
|
|||
|
||||
impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||
fn visit_invoc(&mut self, id: ast::NodeId) -> &'b InvocationData<'b> {
|
||||
let mark = Mark::from_placeholder_id(id);
|
||||
let mark = id.placeholder_to_mark();
|
||||
self.resolver.current_module.unresolved_invocations.borrow_mut().insert(mark);
|
||||
let invocation = self.resolver.invocations[&mark];
|
||||
invocation.module.set(self.resolver.current_module);
|
||||
|
|
|
@ -20,7 +20,7 @@ pub use util::ThinVec;
|
|||
use syntax_pos::{mk_sp, BytePos, Span, DUMMY_SP, ExpnId};
|
||||
use codemap::{respan, Spanned};
|
||||
use abi::Abi;
|
||||
use ext::hygiene::SyntaxContext;
|
||||
use ext::hygiene::{Mark, SyntaxContext};
|
||||
use print::pprust;
|
||||
use ptr::P;
|
||||
use rustc_data_structures::indexed_vec;
|
||||
|
@ -256,6 +256,14 @@ impl NodeId {
|
|||
pub fn as_u32(&self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
|
||||
pub fn placeholder_from_mark(mark: Mark) -> Self {
|
||||
NodeId(mark.as_u32())
|
||||
}
|
||||
|
||||
pub fn placeholder_to_mark(self) -> Mark {
|
||||
Mark::from_u32(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for NodeId {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use ast::{self, Block, Ident, PatKind, Path};
|
||||
use ast::{self, Block, Ident, NodeId, PatKind, Path};
|
||||
use ast::{MacStmtStyle, StmtKind, ItemKind};
|
||||
use attr::{self, HasAttrs};
|
||||
use codemap::{ExpnInfo, NameAndSpan, MacroBang, MacroAttribute};
|
||||
|
@ -321,7 +321,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
while let Some(expansions) = expansions.pop() {
|
||||
for (mark, expansion) in expansions.into_iter().rev() {
|
||||
let derives = derives.remove(&mark).unwrap_or_else(Vec::new);
|
||||
placeholder_expander.add(mark.as_placeholder_id(), expansion, derives);
|
||||
placeholder_expander.add(NodeId::placeholder_from_mark(mark), expansion, derives);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -703,7 +703,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
|||
..self.cx.current_expansion.clone()
|
||||
},
|
||||
});
|
||||
placeholder(expansion_kind, mark.as_placeholder_id())
|
||||
placeholder(expansion_kind, NodeId::placeholder_from_mark(mark))
|
||||
}
|
||||
|
||||
fn collect_bang(&mut self, mac: ast::Mac, span: Span, kind: ExpansionKind) -> Expansion {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use ast;
|
||||
use ast::{self, NodeId};
|
||||
use codemap::{DUMMY_SP, dummy_spanned};
|
||||
use ext::base::ExtCtxt;
|
||||
use ext::expand::{Expansion, ExpansionKind};
|
||||
|
@ -88,7 +88,7 @@ impl<'a, 'b> PlaceholderExpander<'a, 'b> {
|
|||
let mut expansion = expansion.fold_with(self);
|
||||
if let Expansion::Items(mut items) = expansion {
|
||||
for derive in derives {
|
||||
match self.remove(derive.as_placeholder_id()) {
|
||||
match self.remove(NodeId::placeholder_from_mark(derive)) {
|
||||
Expansion::Items(derived_items) => items.extend(derived_items),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
|
@ -136,12 +136,12 @@ pub mod print {
|
|||
}
|
||||
|
||||
pub mod ext {
|
||||
pub use syntax_pos::hygiene;
|
||||
pub mod base;
|
||||
pub mod build;
|
||||
pub mod derive;
|
||||
pub mod expand;
|
||||
pub mod placeholders;
|
||||
pub mod hygiene;
|
||||
pub mod quote;
|
||||
pub mod source_util;
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
//! and definition contexts*. J. Funct. Program. 22, 2 (March 2012), 181-216.
|
||||
//! DOI=10.1017/S0956796812000093 http://dx.doi.org/10.1017/S0956796812000093
|
||||
|
||||
use ast::NodeId;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
|
@ -47,17 +46,13 @@ impl Mark {
|
|||
Mark(0)
|
||||
}
|
||||
|
||||
pub fn from_placeholder_id(id: NodeId) -> Self {
|
||||
Mark(id.as_u32())
|
||||
}
|
||||
|
||||
pub fn as_placeholder_id(self) -> NodeId {
|
||||
NodeId::from_u32(self.0)
|
||||
}
|
||||
|
||||
pub fn as_u32(self) -> u32 {
|
||||
self.0
|
||||
}
|
||||
|
||||
pub fn from_u32(raw: u32) -> Mark {
|
||||
Mark(raw)
|
||||
}
|
||||
}
|
||||
|
||||
struct HygieneData {
|
|
@ -23,6 +23,7 @@
|
|||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![deny(warnings)]
|
||||
|
||||
#![feature(const_fn)]
|
||||
#![feature(custom_attribute)]
|
||||
#![allow(unused_attributes)]
|
||||
#![feature(rustc_private)]
|
||||
|
@ -41,6 +42,8 @@ use serialize::{Encodable, Decodable, Encoder, Decoder};
|
|||
extern crate serialize;
|
||||
extern crate serialize as rustc_serialize; // used by deriving
|
||||
|
||||
pub mod hygiene;
|
||||
|
||||
pub type FileName = String;
|
||||
|
||||
/// Spans represent a region of code, used for error reporting. Positions in spans
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue