librustc: De-@mut the span handler
This commit is contained in:
@@ -883,7 +883,7 @@ pub fn build_session(sopts: @session::options, demitter: @diagnostic::Emitter)
|
|||||||
pub fn build_session_(sopts: @session::options,
|
pub fn build_session_(sopts: @session::options,
|
||||||
cm: @codemap::CodeMap,
|
cm: @codemap::CodeMap,
|
||||||
demitter: @diagnostic::Emitter,
|
demitter: @diagnostic::Emitter,
|
||||||
span_diagnostic_handler: @mut diagnostic::SpanHandler)
|
span_diagnostic_handler: @diagnostic::SpanHandler)
|
||||||
-> Session {
|
-> Session {
|
||||||
let target_cfg = build_target_config(sopts, demitter);
|
let target_cfg = build_target_config(sopts, demitter);
|
||||||
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
|
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ pub struct Session_ {
|
|||||||
// For a library crate, this is always none
|
// For a library crate, this is always none
|
||||||
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
|
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
|
||||||
entry_type: Cell<Option<EntryFnType>>,
|
entry_type: Cell<Option<EntryFnType>>,
|
||||||
span_diagnostic: @mut diagnostic::SpanHandler,
|
span_diagnostic: @diagnostic::SpanHandler,
|
||||||
filesearch: @filesearch::FileSearch,
|
filesearch: @filesearch::FileSearch,
|
||||||
building_library: Cell<bool>,
|
building_library: Cell<bool>,
|
||||||
working_dir: Path,
|
working_dir: Path,
|
||||||
@@ -292,7 +292,7 @@ impl Session_ {
|
|||||||
|
|
||||||
v
|
v
|
||||||
}
|
}
|
||||||
pub fn diagnostic(&self) -> @mut diagnostic::SpanHandler {
|
pub fn diagnostic(&self) -> @diagnostic::SpanHandler {
|
||||||
self.span_diagnostic
|
self.span_diagnostic
|
||||||
}
|
}
|
||||||
pub fn debugging_opt(&self, opt: uint) -> bool {
|
pub fn debugging_opt(&self, opt: uint) -> bool {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ fn dump_crates(crate_cache: &[cache_entry]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn warn_if_multiple_versions(e: &mut Env,
|
fn warn_if_multiple_versions(e: &mut Env,
|
||||||
diag: @mut SpanHandler,
|
diag: @SpanHandler,
|
||||||
crate_cache: &[cache_entry]) {
|
crate_cache: &[cache_entry]) {
|
||||||
if crate_cache.len() != 0u {
|
if crate_cache.len() != 0u {
|
||||||
let name = crate_cache[crate_cache.len() - 1].crateid.name.clone();
|
let name = crate_cache[crate_cache.len() - 1].crateid.name.clone();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ pub type encode_inlined_item<'a> = 'a |ecx: &EncodeContext,
|
|||||||
ii: ast::inlined_item|;
|
ii: ast::inlined_item|;
|
||||||
|
|
||||||
pub struct EncodeParams<'a> {
|
pub struct EncodeParams<'a> {
|
||||||
diag: @mut SpanHandler,
|
diag: @SpanHandler,
|
||||||
tcx: ty::ctxt,
|
tcx: ty::ctxt,
|
||||||
reexports2: middle::resolve::ExportMap2,
|
reexports2: middle::resolve::ExportMap2,
|
||||||
item_symbols: &'a RefCell<HashMap<ast::NodeId, ~str>>,
|
item_symbols: &'a RefCell<HashMap<ast::NodeId, ~str>>,
|
||||||
@@ -83,7 +83,7 @@ struct Stats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct EncodeContext<'a> {
|
pub struct EncodeContext<'a> {
|
||||||
diag: @mut SpanHandler,
|
diag: @SpanHandler,
|
||||||
tcx: ty::ctxt,
|
tcx: ty::ctxt,
|
||||||
stats: @Stats,
|
stats: @Stats,
|
||||||
reexports2: middle::resolve::ExportMap2,
|
reexports2: middle::resolve::ExportMap2,
|
||||||
|
|||||||
@@ -231,8 +231,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn note_crateid_attr(diag: @mut SpanHandler,
|
pub fn note_crateid_attr(diag: @SpanHandler, crateid: &CrateId) {
|
||||||
crateid: &CrateId) {
|
|
||||||
diag.handler().note(format!("crate_id: {}", crateid.to_str()));
|
diag.handler().note(format!("crate_id: {}", crateid.to_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ macro_rules! mywrite( ($wr:expr, $($arg:tt)*) => (
|
|||||||
) )
|
) )
|
||||||
|
|
||||||
pub struct ctxt {
|
pub struct ctxt {
|
||||||
diag: @mut SpanHandler,
|
diag: @SpanHandler,
|
||||||
// Def -> str Callback:
|
// Def -> str Callback:
|
||||||
ds: extern "Rust" fn(DefId) -> ~str,
|
ds: extern "Rust" fn(DefId) -> ~str,
|
||||||
// The type context.
|
// The type context.
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ pub type ctxt = @ctxt_;
|
|||||||
/// generates so that so that it can be reused and doesn't have to be redone
|
/// generates so that so that it can be reused and doesn't have to be redone
|
||||||
/// later on.
|
/// later on.
|
||||||
struct ctxt_ {
|
struct ctxt_ {
|
||||||
diag: @mut syntax::diagnostic::SpanHandler,
|
diag: @syntax::diagnostic::SpanHandler,
|
||||||
interner: RefCell<HashMap<intern_key, ~t_box_>>,
|
interner: RefCell<HashMap<intern_key, ~t_box_>>,
|
||||||
next_id: Cell<uint>,
|
next_id: Cell<uint>,
|
||||||
cstore: @metadata::cstore::CStore,
|
cstore: @metadata::cstore::CStore,
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ pub type map = @mut HashMap<NodeId, ast_node>;
|
|||||||
pub struct Ctx {
|
pub struct Ctx {
|
||||||
map: map,
|
map: map,
|
||||||
path: path,
|
path: path,
|
||||||
diag: @mut SpanHandler,
|
diag: @SpanHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ctx {
|
impl Ctx {
|
||||||
@@ -418,7 +418,7 @@ impl Visitor<()> for Ctx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map_crate(diag: @mut SpanHandler, c: &Crate) -> map {
|
pub fn map_crate(diag: @SpanHandler, c: &Crate) -> map {
|
||||||
let cx = @mut Ctx {
|
let cx = @mut Ctx {
|
||||||
map: @mut HashMap::new(),
|
map: @mut HashMap::new(),
|
||||||
path: ~[],
|
path: ~[],
|
||||||
@@ -431,7 +431,7 @@ pub fn map_crate(diag: @mut SpanHandler, c: &Crate) -> map {
|
|||||||
// Used for items loaded from external crate that are being inlined into this
|
// Used for items loaded from external crate that are being inlined into this
|
||||||
// crate. The `path` should be the path to the item but should not include
|
// crate. The `path` should be the path to the item but should not include
|
||||||
// the item itself.
|
// the item itself.
|
||||||
pub fn map_decoded_item(diag: @mut SpanHandler,
|
pub fn map_decoded_item(diag: @SpanHandler,
|
||||||
map: map,
|
map: map,
|
||||||
path: path,
|
path: path,
|
||||||
ii: &inlined_item) {
|
ii: &inlined_item) {
|
||||||
|
|||||||
@@ -355,8 +355,7 @@ pub fn find_stability<AM: AttrMetaMethods, It: Iterator<AM>>(mut metas: It) -> O
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn require_unique_names(diagnostic: @mut SpanHandler,
|
pub fn require_unique_names(diagnostic: @SpanHandler, metas: &[@MetaItem]) {
|
||||||
metas: &[@MetaItem]) {
|
|
||||||
let mut set = HashSet::new();
|
let mut set = HashSet::new();
|
||||||
for meta in metas.iter() {
|
for meta in metas.iter() {
|
||||||
let name = meta.name();
|
let name = meta.name();
|
||||||
@@ -381,7 +380,7 @@ pub fn require_unique_names(diagnostic: @mut SpanHandler,
|
|||||||
* present (before fields, if any) with that type; reprensentation
|
* present (before fields, if any) with that type; reprensentation
|
||||||
* optimizations which would remove it will not be done.
|
* optimizations which would remove it will not be done.
|
||||||
*/
|
*/
|
||||||
pub fn find_repr_attr(diagnostic: @mut SpanHandler, attr: @ast::MetaItem, acc: ReprAttr)
|
pub fn find_repr_attr(diagnostic: @SpanHandler, attr: @ast::MetaItem, acc: ReprAttr)
|
||||||
-> ReprAttr {
|
-> ReprAttr {
|
||||||
let mut acc = acc;
|
let mut acc = acc;
|
||||||
match attr.node {
|
match attr.node {
|
||||||
|
|||||||
@@ -35,27 +35,27 @@ pub struct SpanHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SpanHandler {
|
impl SpanHandler {
|
||||||
pub fn span_fatal(@mut self, sp: Span, msg: &str) -> ! {
|
pub fn span_fatal(@self, sp: Span, msg: &str) -> ! {
|
||||||
self.handler.emit(Some((&*self.cm, sp)), msg, fatal);
|
self.handler.emit(Some((&*self.cm, sp)), msg, fatal);
|
||||||
fail!();
|
fail!();
|
||||||
}
|
}
|
||||||
pub fn span_err(@mut self, sp: Span, msg: &str) {
|
pub fn span_err(@self, sp: Span, msg: &str) {
|
||||||
self.handler.emit(Some((&*self.cm, sp)), msg, error);
|
self.handler.emit(Some((&*self.cm, sp)), msg, error);
|
||||||
self.handler.bump_err_count();
|
self.handler.bump_err_count();
|
||||||
}
|
}
|
||||||
pub fn span_warn(@mut self, sp: Span, msg: &str) {
|
pub fn span_warn(@self, sp: Span, msg: &str) {
|
||||||
self.handler.emit(Some((&*self.cm, sp)), msg, warning);
|
self.handler.emit(Some((&*self.cm, sp)), msg, warning);
|
||||||
}
|
}
|
||||||
pub fn span_note(@mut self, sp: Span, msg: &str) {
|
pub fn span_note(@self, sp: Span, msg: &str) {
|
||||||
self.handler.emit(Some((&*self.cm, sp)), msg, note);
|
self.handler.emit(Some((&*self.cm, sp)), msg, note);
|
||||||
}
|
}
|
||||||
pub fn span_bug(@mut self, sp: Span, msg: &str) -> ! {
|
pub fn span_bug(@self, sp: Span, msg: &str) -> ! {
|
||||||
self.span_fatal(sp, ice_msg(msg));
|
self.span_fatal(sp, ice_msg(msg));
|
||||||
}
|
}
|
||||||
pub fn span_unimpl(@mut self, sp: Span, msg: &str) -> ! {
|
pub fn span_unimpl(@self, sp: Span, msg: &str) -> ! {
|
||||||
self.span_bug(sp, ~"unimplemented " + msg);
|
self.span_bug(sp, ~"unimplemented " + msg);
|
||||||
}
|
}
|
||||||
pub fn handler(@mut self) -> @mut Handler {
|
pub fn handler(@self) -> @mut Handler {
|
||||||
self.handler
|
self.handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,8 +124,8 @@ pub fn ice_msg(msg: &str) -> ~str {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn mk_span_handler(handler: @mut Handler, cm: @codemap::CodeMap)
|
pub fn mk_span_handler(handler: @mut Handler, cm: @codemap::CodeMap)
|
||||||
-> @mut SpanHandler {
|
-> @SpanHandler {
|
||||||
@mut SpanHandler {
|
@SpanHandler {
|
||||||
handler: handler,
|
handler: handler,
|
||||||
cm: cm,
|
cm: cm,
|
||||||
}
|
}
|
||||||
@@ -327,10 +327,7 @@ fn print_macro_backtrace(cm: &codemap::CodeMap, sp: Span) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expect<T:Clone>(
|
pub fn expect<T:Clone>(diag: @SpanHandler, opt: Option<T>, msg: || -> ~str)
|
||||||
diag: @mut SpanHandler,
|
|
||||||
opt: Option<T>,
|
|
||||||
msg: || -> ~str)
|
|
||||||
-> T {
|
-> T {
|
||||||
match opt {
|
match opt {
|
||||||
Some(ref t) => (*t).clone(),
|
Some(ref t) => (*t).clone(),
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ struct TtFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct TtReader {
|
pub struct TtReader {
|
||||||
sp_diag: @mut SpanHandler,
|
sp_diag: @SpanHandler,
|
||||||
// the unzipped tree:
|
// the unzipped tree:
|
||||||
priv stack: RefCell<@mut TtFrame>,
|
priv stack: RefCell<@mut TtFrame>,
|
||||||
/* for MBE-style macro transcription */
|
/* for MBE-style macro transcription */
|
||||||
@@ -46,7 +46,7 @@ pub struct TtReader {
|
|||||||
/** This can do Macro-By-Example transcription. On the other hand, if
|
/** This can do Macro-By-Example transcription. On the other hand, if
|
||||||
* `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and
|
* `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and
|
||||||
* should) be none. */
|
* should) be none. */
|
||||||
pub fn new_tt_reader(sp_diag: @mut SpanHandler,
|
pub fn new_tt_reader(sp_diag: @SpanHandler,
|
||||||
interp: Option<HashMap<Ident,@named_match>>,
|
interp: Option<HashMap<Ident,@named_match>>,
|
||||||
src: ~[ast::token_tree])
|
src: ~[ast::token_tree])
|
||||||
-> @TtReader {
|
-> @TtReader {
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ pub struct lit {
|
|||||||
// it appears this function is called only from pprust... that's
|
// it appears this function is called only from pprust... that's
|
||||||
// probably not a good thing.
|
// probably not a good thing.
|
||||||
pub fn gather_comments_and_literals(span_diagnostic:
|
pub fn gather_comments_and_literals(span_diagnostic:
|
||||||
@mut diagnostic::SpanHandler,
|
@diagnostic::SpanHandler,
|
||||||
path: @str,
|
path: @str,
|
||||||
srdr: &mut io::Reader)
|
srdr: &mut io::Reader)
|
||||||
-> (~[cmnt], ~[lit]) {
|
-> (~[cmnt], ~[lit]) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ pub trait reader {
|
|||||||
fn is_eof(@self) -> bool;
|
fn is_eof(@self) -> bool;
|
||||||
fn next_token(@self) -> TokenAndSpan;
|
fn next_token(@self) -> TokenAndSpan;
|
||||||
fn fatal(@self, ~str) -> !;
|
fn fatal(@self, ~str) -> !;
|
||||||
fn span_diag(@self) -> @mut SpanHandler;
|
fn span_diag(@self) -> @SpanHandler;
|
||||||
fn peek(@self) -> TokenAndSpan;
|
fn peek(@self) -> TokenAndSpan;
|
||||||
fn dup(@self) -> @reader;
|
fn dup(@self) -> @reader;
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ pub struct TokenAndSpan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct StringReader {
|
pub struct StringReader {
|
||||||
span_diagnostic: @mut SpanHandler,
|
span_diagnostic: @SpanHandler,
|
||||||
src: @str,
|
src: @str,
|
||||||
// The absolute offset within the codemap of the next character to read
|
// The absolute offset within the codemap of the next character to read
|
||||||
pos: Cell<BytePos>,
|
pos: Cell<BytePos>,
|
||||||
@@ -57,7 +57,7 @@ pub struct StringReader {
|
|||||||
peek_span: RefCell<Span>,
|
peek_span: RefCell<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_string_reader(span_diagnostic: @mut SpanHandler,
|
pub fn new_string_reader(span_diagnostic: @SpanHandler,
|
||||||
filemap: @codemap::FileMap)
|
filemap: @codemap::FileMap)
|
||||||
-> @StringReader {
|
-> @StringReader {
|
||||||
let r = new_low_level_string_reader(span_diagnostic, filemap);
|
let r = new_low_level_string_reader(span_diagnostic, filemap);
|
||||||
@@ -66,7 +66,7 @@ pub fn new_string_reader(span_diagnostic: @mut SpanHandler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* For comments.rs, which hackily pokes into 'pos' and 'curr' */
|
/* For comments.rs, which hackily pokes into 'pos' and 'curr' */
|
||||||
pub fn new_low_level_string_reader(span_diagnostic: @mut SpanHandler,
|
pub fn new_low_level_string_reader(span_diagnostic: @SpanHandler,
|
||||||
filemap: @codemap::FileMap)
|
filemap: @codemap::FileMap)
|
||||||
-> @StringReader {
|
-> @StringReader {
|
||||||
// Force the initial reader bump to start on a fresh line
|
// Force the initial reader bump to start on a fresh line
|
||||||
@@ -121,7 +121,7 @@ impl reader for StringReader {
|
|||||||
fn fatal(@self, m: ~str) -> ! {
|
fn fatal(@self, m: ~str) -> ! {
|
||||||
self.span_diagnostic.span_fatal(self.peek_span.get(), m)
|
self.span_diagnostic.span_fatal(self.peek_span.get(), m)
|
||||||
}
|
}
|
||||||
fn span_diag(@self) -> @mut SpanHandler { self.span_diagnostic }
|
fn span_diag(@self) -> @SpanHandler { self.span_diagnostic }
|
||||||
fn peek(@self) -> TokenAndSpan {
|
fn peek(@self) -> TokenAndSpan {
|
||||||
// XXX(pcwalton): Bad copy!
|
// XXX(pcwalton): Bad copy!
|
||||||
TokenAndSpan {
|
TokenAndSpan {
|
||||||
@@ -145,7 +145,7 @@ impl reader for TtReader {
|
|||||||
fn fatal(@self, m: ~str) -> ! {
|
fn fatal(@self, m: ~str) -> ! {
|
||||||
self.sp_diag.span_fatal(self.cur_span.get(), m);
|
self.sp_diag.span_fatal(self.cur_span.get(), m);
|
||||||
}
|
}
|
||||||
fn span_diag(@self) -> @mut SpanHandler { self.sp_diag }
|
fn span_diag(@self) -> @SpanHandler { self.sp_diag }
|
||||||
fn peek(@self) -> TokenAndSpan {
|
fn peek(@self) -> TokenAndSpan {
|
||||||
TokenAndSpan {
|
TokenAndSpan {
|
||||||
tok: self.cur_tok.get(),
|
tok: self.cur_tok.get(),
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pub mod obsolete;
|
|||||||
// info about a parsing session.
|
// info about a parsing session.
|
||||||
pub struct ParseSess {
|
pub struct ParseSess {
|
||||||
cm: @codemap::CodeMap, // better be the same as the one in the reader!
|
cm: @codemap::CodeMap, // better be the same as the one in the reader!
|
||||||
span_diagnostic: @mut SpanHandler, // better be the same as the one in the reader!
|
span_diagnostic: @SpanHandler, // better be the same as the one in the reader!
|
||||||
/// Used to determine and report recursive mod inclusions
|
/// Used to determine and report recursive mod inclusions
|
||||||
included_mod_stack: RefCell<~[Path]>,
|
included_mod_stack: RefCell<~[Path]>,
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ pub fn new_parse_sess(demitter: Option<@Emitter>) -> @ParseSess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_parse_sess_special_handler(sh: @mut SpanHandler,
|
pub fn new_parse_sess_special_handler(sh: @SpanHandler,
|
||||||
cm: @codemap::CodeMap)
|
cm: @codemap::CodeMap)
|
||||||
-> @ParseSess {
|
-> @ParseSess {
|
||||||
@ParseSess {
|
@ParseSess {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ pub static default_columns: uint = 78u;
|
|||||||
// copy forward.
|
// copy forward.
|
||||||
pub fn print_crate(cm: @CodeMap,
|
pub fn print_crate(cm: @CodeMap,
|
||||||
intr: @ident_interner,
|
intr: @ident_interner,
|
||||||
span_diagnostic: @mut diagnostic::SpanHandler,
|
span_diagnostic: @diagnostic::SpanHandler,
|
||||||
crate: &ast::Crate,
|
crate: &ast::Crate,
|
||||||
filename: @str,
|
filename: @str,
|
||||||
input: @mut io::Reader,
|
input: @mut io::Reader,
|
||||||
|
|||||||
Reference in New Issue
Block a user