Replace Rc with Lrc for shared data

This commit is contained in:
John Kåre Alsaker
2018-02-27 17:11:14 +01:00
parent 878f5b0514
commit b74e97cf42
86 changed files with 435 additions and 413 deletions

View File

@@ -16,10 +16,10 @@ use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, CodeMapper, Diagno
use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
use styled_buffer::StyledBuffer;
use rustc_data_structures::sync::Lrc;
use std::borrow::Cow;
use std::io::prelude::*;
use std::io;
use std::rc::Rc;
use term;
use std::collections::{HashMap, HashSet};
use std::cmp::min;
@@ -106,7 +106,7 @@ impl ColorConfig {
pub struct EmitterWriter {
dst: Destination,
cm: Option<Rc<CodeMapper>>,
cm: Option<Lrc<CodeMapper>>,
short_message: bool,
teach: bool,
error_codes: HashSet<String>,
@@ -114,7 +114,7 @@ pub struct EmitterWriter {
}
struct FileWithAnnotatedLines {
file: Rc<FileMap>,
file: Lrc<FileMap>,
lines: Vec<Line>,
multiline_depth: usize,
}
@@ -148,7 +148,7 @@ impl Drop for EmitterWriter {
impl EmitterWriter {
pub fn stderr(color_config: ColorConfig,
code_map: Option<Rc<CodeMapper>>,
code_map: Option<Lrc<CodeMapper>>,
short_message: bool,
teach: bool)
-> EmitterWriter {
@@ -175,7 +175,7 @@ impl EmitterWriter {
}
pub fn new(dst: Box<Write + Send>,
code_map: Option<Rc<CodeMapper>>,
code_map: Option<Lrc<CodeMapper>>,
short_message: bool,
teach: bool)
-> EmitterWriter {
@@ -204,7 +204,7 @@ impl EmitterWriter {
fn preprocess_annotations(&mut self, msp: &MultiSpan) -> Vec<FileWithAnnotatedLines> {
fn add_annotation_to_file(file_vec: &mut Vec<FileWithAnnotatedLines>,
file: Rc<FileMap>,
file: Lrc<FileMap>,
line_index: usize,
ann: Annotation) {
@@ -336,7 +336,7 @@ impl EmitterWriter {
fn render_source_line(&self,
buffer: &mut StyledBuffer,
file: Rc<FileMap>,
file: Lrc<FileMap>,
line: &Line,
width_offset: usize,
code_offset: usize) -> Vec<(usize, Style)> {

View File

@@ -35,13 +35,13 @@ use self::Level::*;
use emitter::{Emitter, EmitterWriter};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::stable_hasher::StableHasher;
use std::borrow::Cow;
use std::cell::{RefCell, Cell};
use std::mem;
use std::rc::Rc;
use std::{error, fmt};
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
@@ -110,7 +110,7 @@ pub trait CodeMapper {
fn span_to_filename(&self, sp: Span) -> FileName;
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
fn call_span_if_macro(&self, sp: Span) -> Span;
fn ensure_filemap_source_present(&self, file_map: Rc<FileMap>) -> bool;
fn ensure_filemap_source_present(&self, file_map: Lrc<FileMap>) -> bool;
fn doctest_offset_line(&self, line: usize) -> usize;
}
@@ -287,7 +287,7 @@ impl Handler {
pub fn with_tty_emitter(color_config: ColorConfig,
can_emit_warnings: bool,
treat_err_as_bug: bool,
cm: Option<Rc<CodeMapper>>)
cm: Option<Lrc<CodeMapper>>)
-> Handler {
Handler::with_tty_emitter_and_flags(
color_config,
@@ -300,7 +300,7 @@ impl Handler {
}
pub fn with_tty_emitter_and_flags(color_config: ColorConfig,
cm: Option<Rc<CodeMapper>>,
cm: Option<Lrc<CodeMapper>>,
flags: HandlerFlags)
-> Handler {
let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false));