diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-02-27 17:11:14 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-03-02 10:48:52 +0100 |
| commit | b74e97cf42e647d87d67a03c134a0494b6aaa811 (patch) | |
| tree | a66e948a4d31dd9681cb6984a3b1fb774bebae4a /src/libsyntax/ext | |
| parent | 878f5b05147480182ea4d8a855acc55bfeb16c22 (diff) | |
| download | rust-b74e97cf42e647d87d67a03c134a0494b6aaa811.tar.gz rust-b74e97cf42e647d87d67a03c134a0494b6aaa811.zip | |
Replace Rc with Lrc for shared data
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/quoted.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 7 |
6 files changed, 27 insertions, 24 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 520ec942e42..7b333270d04 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -28,6 +28,7 @@ use std::collections::HashMap; use std::iter; use std::path::PathBuf; use std::rc::Rc; +use rustc_data_structures::sync::Lrc; use std::default::Default; use tokenstream::{self, TokenStream}; @@ -615,15 +616,15 @@ pub trait Resolver { fn is_whitelisted_legacy_custom_derive(&self, name: Name) -> bool; fn visit_expansion(&mut self, mark: Mark, expansion: &Expansion, derives: &[Mark]); - fn add_builtin(&mut self, ident: ast::Ident, ext: Rc<SyntaxExtension>); + fn add_builtin(&mut self, ident: ast::Ident, ext: Lrc<SyntaxExtension>); fn resolve_imports(&mut self); // Resolves attribute and derive legacy macros from `#![plugin(..)]`. fn find_legacy_attr_invoc(&mut self, attrs: &mut Vec<Attribute>) -> Option<Attribute>; fn resolve_invoc(&mut self, invoc: &mut Invocation, scope: Mark, force: bool) - -> Result<Option<Rc<SyntaxExtension>>, Determinacy>; + -> Result<Option<Lrc<SyntaxExtension>>, Determinacy>; fn resolve_macro(&mut self, scope: Mark, path: &ast::Path, kind: MacroKind, force: bool) - -> Result<Rc<SyntaxExtension>, Determinacy>; + -> Result<Lrc<SyntaxExtension>, Determinacy>; fn check_unused_macros(&self); } @@ -642,16 +643,16 @@ impl Resolver for DummyResolver { fn is_whitelisted_legacy_custom_derive(&self, _name: Name) -> bool { false } fn visit_expansion(&mut self, _invoc: Mark, _expansion: &Expansion, _derives: &[Mark]) {} - fn add_builtin(&mut self, _ident: ast::Ident, _ext: Rc<SyntaxExtension>) {} + fn add_builtin(&mut self, _ident: ast::Ident, _ext: Lrc<SyntaxExtension>) {} fn resolve_imports(&mut self) {} fn find_legacy_attr_invoc(&mut self, _attrs: &mut Vec<Attribute>) -> Option<Attribute> { None } fn resolve_invoc(&mut self, _invoc: &mut Invocation, _scope: Mark, _force: bool) - -> Result<Option<Rc<SyntaxExtension>>, Determinacy> { + -> Result<Option<Lrc<SyntaxExtension>>, Determinacy> { Err(Determinacy::Determined) } fn resolve_macro(&mut self, _scope: Mark, _path: &ast::Path, _kind: MacroKind, - _force: bool) -> Result<Rc<SyntaxExtension>, Determinacy> { + _force: bool) -> Result<Lrc<SyntaxExtension>, Determinacy> { Err(Determinacy::Determined) } fn check_unused_macros(&self) {} diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index d4d9dfb01da..377f47a3ea5 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -305,7 +305,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let (expansion, new_invocations) = if let Some(ext) = ext { if let Some(ext) = ext { let dummy = invoc.expansion_kind.dummy(invoc.span()).unwrap(); - let expansion = self.expand_invoc(invoc, ext).unwrap_or(dummy); + let expansion = self.expand_invoc(invoc, &*ext).unwrap_or(dummy); self.collect_invocations(expansion, &[]) } else if let InvocationKind::Attr { attr: None, traits, item } = invoc.kind { if !item.derive_allowed() { @@ -437,7 +437,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } } - fn expand_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) -> Option<Expansion> { + fn expand_invoc(&mut self, invoc: Invocation, ext: &SyntaxExtension) -> Option<Expansion> { let result = match invoc.kind { InvocationKind::Bang { .. } => self.expand_bang_invoc(invoc, ext)?, InvocationKind::Attr { .. } => self.expand_attr_invoc(invoc, ext)?, @@ -463,7 +463,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { fn expand_attr_invoc(&mut self, invoc: Invocation, - ext: Rc<SyntaxExtension>) + ext: &SyntaxExtension) -> Option<Expansion> { let Invocation { expansion_kind: kind, .. } = invoc; let (attr, item) = match invoc.kind { @@ -521,7 +521,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { /// Expand a macro invocation. Returns the result of expansion. fn expand_bang_invoc(&mut self, invoc: Invocation, - ext: Rc<SyntaxExtension>) + ext: &SyntaxExtension) -> Option<Expansion> { let (mark, kind) = (invoc.expansion_data.mark, invoc.expansion_kind); let (mac, ident, span) = match invoc.kind { @@ -654,7 +654,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { /// Expand a derive invocation. Returns the result of expansion. fn expand_derive_invoc(&mut self, invoc: Invocation, - ext: Rc<SyntaxExtension>) + ext: &SyntaxExtension) -> Option<Expansion> { let Invocation { expansion_kind: kind, .. } = invoc; let (path, item) = match invoc.kind { diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index ec4e6ced1b2..d6dce63ea5e 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -24,7 +24,7 @@ use util::small_vector::SmallVector; use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; -use std::rc::Rc; +use rustc_data_structures::sync::Lrc; // These macros all relate to the file system; they either return // the column/row/filename of the expression, or they include @@ -184,7 +184,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::Toke // dependency information, but don't enter it's contents cx.codemap().new_filemap_and_lines(&file, ""); - base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Rc::new(bytes)))) + base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Lrc::new(bytes)))) } } } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 5254c751e6b..728b3e4076d 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -29,7 +29,8 @@ use tokenstream::{TokenStream, TokenTree}; use std::cell::RefCell; use std::collections::HashMap; use std::collections::hash_map::Entry; -use std::rc::Rc; + +use rustc_data_structures::sync::Lrc; pub struct ParserAnyMacro<'a> { parser: Parser<'a>, @@ -199,7 +200,7 @@ pub fn compile(sess: &ParseSess, features: &RefCell<Features>, def: &ast::Item) // ...quasiquoting this would be nice. // These spans won't matter, anyways let argument_gram = vec![ - quoted::TokenTree::Sequence(DUMMY_SP, Rc::new(quoted::SequenceRepetition { + quoted::TokenTree::Sequence(DUMMY_SP, Lrc::new(quoted::SequenceRepetition { tts: vec![ quoted::TokenTree::MetaVarDecl(DUMMY_SP, lhs_nm, ast::Ident::from_str("tt")), quoted::TokenTree::Token(DUMMY_SP, token::FatArrow), @@ -210,7 +211,7 @@ pub fn compile(sess: &ParseSess, features: &RefCell<Features>, def: &ast::Item) num_captures: 2, })), // to phase into semicolon-termination instead of semicolon-separation - quoted::TokenTree::Sequence(DUMMY_SP, Rc::new(quoted::SequenceRepetition { + quoted::TokenTree::Sequence(DUMMY_SP, Lrc::new(quoted::SequenceRepetition { tts: vec![quoted::TokenTree::Token(DUMMY_SP, token::Semi)], separator: None, op: quoted::KleeneOp::ZeroOrMore, diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 982b60b81e4..c9d7f78c2e3 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -19,7 +19,7 @@ use tokenstream; use std::cell::RefCell; use std::iter::Peekable; -use std::rc::Rc; +use rustc_data_structures::sync::Lrc; /// Contains the sub-token-trees of a "delimited" token tree, such as the contents of `(`. Note /// that the delimiter itself might be `NoDelim`. @@ -89,9 +89,9 @@ pub enum KleeneOp { #[derive(Debug, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] pub enum TokenTree { Token(Span, token::Token), - Delimited(Span, Rc<Delimited>), + Delimited(Span, Lrc<Delimited>), /// A kleene-style repetition sequence - Sequence(Span, Rc<SequenceRepetition>), + Sequence(Span, Lrc<SequenceRepetition>), /// E.g. `$var` MetaVar(Span, ast::Ident), /// E.g. `$var:expr`. This is only used in the left hand side of MBE macros. @@ -278,7 +278,7 @@ where let name_captures = macro_parser::count_names(&sequence); TokenTree::Sequence( span, - Rc::new(SequenceRepetition { + Lrc::new(SequenceRepetition { tts: sequence, separator, op, @@ -324,7 +324,7 @@ where // descend into the delimited set and further parse it. tokenstream::TokenTree::Delimited(span, delimited) => TokenTree::Delimited( span, - Rc::new(Delimited { + Lrc::new(Delimited { delim: delimited.delim, tts: parse(delimited.tts.into(), expect_matchers, sess, features, attrs), }), diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index d51b0d0ae3e..7883c4bbc16 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -20,6 +20,7 @@ use tokenstream::{TokenStream, TokenTree, Delimited}; use util::small_vector::SmallVector; use std::rc::Rc; +use rustc_data_structures::sync::Lrc; use std::mem; use std::ops::Add; use std::collections::HashMap; @@ -27,12 +28,12 @@ use std::collections::HashMap; // An iterator over the token trees in a delimited token tree (`{ ... }`) or a sequence (`$(...)`). enum Frame { Delimited { - forest: Rc<quoted::Delimited>, + forest: Lrc<quoted::Delimited>, idx: usize, span: Span, }, Sequence { - forest: Rc<quoted::SequenceRepetition>, + forest: Lrc<quoted::SequenceRepetition>, idx: usize, sep: Option<Token>, }, @@ -40,7 +41,7 @@ enum Frame { impl Frame { fn new(tts: Vec<quoted::TokenTree>) -> Frame { - let forest = Rc::new(quoted::Delimited { delim: token::NoDelim, tts: tts }); + let forest = Lrc::new(quoted::Delimited { delim: token::NoDelim, tts: tts }); Frame::Delimited { forest: forest, idx: 0, span: DUMMY_SP } } } |
