Replace Rc with Lrc for shared data
This commit is contained in:
parent
878f5b0514
commit
b74e97cf42
86 changed files with 435 additions and 413 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
//! The main parser interface
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use ast::{self, CrateConfig};
|
||||
use codemap::{CodeMap, FilePathMapping};
|
||||
use syntax_pos::{self, Span, FileMap, NO_EXPANSION, FileName};
|
||||
|
@ -25,7 +26,6 @@ use std::cell::RefCell;
|
|||
use std::collections::HashSet;
|
||||
use std::iter;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
|
||||
pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a>>;
|
||||
|
@ -52,12 +52,12 @@ pub struct ParseSess {
|
|||
pub non_modrs_mods: RefCell<Vec<(ast::Ident, Span)>>,
|
||||
/// Used to determine and report recursive mod inclusions
|
||||
included_mod_stack: RefCell<Vec<PathBuf>>,
|
||||
code_map: Rc<CodeMap>,
|
||||
code_map: Lrc<CodeMap>,
|
||||
}
|
||||
|
||||
impl ParseSess {
|
||||
pub fn new(file_path_mapping: FilePathMapping) -> Self {
|
||||
let cm = Rc::new(CodeMap::new(file_path_mapping));
|
||||
let cm = Lrc::new(CodeMap::new(file_path_mapping));
|
||||
let handler = Handler::with_tty_emitter(ColorConfig::Auto,
|
||||
true,
|
||||
false,
|
||||
|
@ -65,7 +65,7 @@ impl ParseSess {
|
|||
ParseSess::with_span_handler(handler, cm)
|
||||
}
|
||||
|
||||
pub fn with_span_handler(handler: Handler, code_map: Rc<CodeMap>) -> ParseSess {
|
||||
pub fn with_span_handler(handler: Handler, code_map: Lrc<CodeMap>) -> ParseSess {
|
||||
ParseSess {
|
||||
span_diagnostic: handler,
|
||||
unstable_features: UnstableFeatures::from_environment(),
|
||||
|
@ -183,7 +183,7 @@ pub fn new_sub_parser_from_file<'a>(sess: &'a ParseSess,
|
|||
}
|
||||
|
||||
/// Given a filemap and config, return a parser
|
||||
pub fn filemap_to_parser(sess: & ParseSess, filemap: Rc<FileMap>, ) -> Parser {
|
||||
pub fn filemap_to_parser(sess: & ParseSess, filemap: Lrc<FileMap>) -> Parser {
|
||||
let end_pos = filemap.end_pos;
|
||||
let mut parser = stream_to_parser(sess, filemap_to_stream(sess, filemap, None));
|
||||
|
||||
|
@ -206,7 +206,7 @@ pub fn new_parser_from_tts(sess: &ParseSess, tts: Vec<TokenTree>) -> Parser {
|
|||
/// Given a session and a path and an optional span (for error reporting),
|
||||
/// add the path to the session's codemap and return the new filemap.
|
||||
fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
|
||||
-> Rc<FileMap> {
|
||||
-> Lrc<FileMap> {
|
||||
match sess.codemap().load_file(path) {
|
||||
Ok(filemap) => filemap,
|
||||
Err(e) => {
|
||||
|
@ -220,7 +220,7 @@ fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
|
|||
}
|
||||
|
||||
/// Given a filemap, produce a sequence of token-trees
|
||||
pub fn filemap_to_stream(sess: &ParseSess, filemap: Rc<FileMap>, override_span: Option<Span>)
|
||||
pub fn filemap_to_stream(sess: &ParseSess, filemap: Lrc<FileMap>, override_span: Option<Span>)
|
||||
-> TokenStream {
|
||||
let mut srdr = lexer::StringReader::new(sess, filemap);
|
||||
srdr.override_span = override_span;
|
||||
|
@ -422,7 +422,7 @@ pub fn lit_token(lit: token::Lit, suf: Option<Symbol>, diag: Option<(Span, &Hand
|
|||
(true, Some(LitKind::ByteStr(byte_str_lit(&i.as_str()))))
|
||||
}
|
||||
token::ByteStrRaw(i, _) => {
|
||||
(true, Some(LitKind::ByteStr(Rc::new(i.to_string().into_bytes()))))
|
||||
(true, Some(LitKind::ByteStr(Lrc::new(i.to_string().into_bytes()))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ pub fn byte_lit(lit: &str) -> (u8, usize) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn byte_str_lit(lit: &str) -> Rc<Vec<u8>> {
|
||||
pub fn byte_str_lit(lit: &str) -> Lrc<Vec<u8>> {
|
||||
let mut res = Vec::with_capacity(lit.len());
|
||||
|
||||
// FIXME #8372: This could be a for-loop if it didn't borrow the iterator
|
||||
|
@ -553,7 +553,7 @@ pub fn byte_str_lit(lit: &str) -> Rc<Vec<u8>> {
|
|||
}
|
||||
}
|
||||
|
||||
Rc::new(res)
|
||||
Lrc::new(res)
|
||||
}
|
||||
|
||||
pub fn integer_lit(s: &str, suffix: Option<Symbol>, diag: Option<(Span, &Handler)>)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue