Skip to content

Commit 4d66af2

Browse files
committed
librustc: De-@mut the span handler
1 parent 7e1b535 commit 4d66af2

File tree

15 files changed

+38
-43
lines changed

15 files changed

+38
-43
lines changed

src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ pub fn build_session(sopts: @session::options, demitter: @diagnostic::Emitter)
883883
pub fn build_session_(sopts: @session::options,
884884
cm: @codemap::CodeMap,
885885
demitter: @diagnostic::Emitter,
886-
span_diagnostic_handler: @mut diagnostic::SpanHandler)
886+
span_diagnostic_handler: @diagnostic::SpanHandler)
887887
-> Session {
888888
let target_cfg = build_target_config(sopts, demitter);
889889
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,

src/librustc/driver/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub struct Session_ {
209209
// For a library crate, this is always none
210210
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
211211
entry_type: Cell<Option<EntryFnType>>,
212-
span_diagnostic: @mut diagnostic::SpanHandler,
212+
span_diagnostic: @diagnostic::SpanHandler,
213213
filesearch: @filesearch::FileSearch,
214214
building_library: Cell<bool>,
215215
working_dir: Path,
@@ -292,7 +292,7 @@ impl Session_ {
292292

293293
v
294294
}
295-
pub fn diagnostic(&self) -> @mut diagnostic::SpanHandler {
295+
pub fn diagnostic(&self) -> @diagnostic::SpanHandler {
296296
self.span_diagnostic
297297
}
298298
pub fn debugging_opt(&self, opt: uint) -> bool {

src/librustc/metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn dump_crates(crate_cache: &[cache_entry]) {
8686
}
8787

8888
fn warn_if_multiple_versions(e: &mut Env,
89-
diag: @mut SpanHandler,
89+
diag: @SpanHandler,
9090
crate_cache: &[cache_entry]) {
9191
if crate_cache.len() != 0u {
9292
let name = crate_cache[crate_cache.len() - 1].crateid.name.clone();

src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub type encode_inlined_item<'a> = 'a |ecx: &EncodeContext,
5757
ii: ast::inlined_item|;
5858

5959
pub struct EncodeParams<'a> {
60-
diag: @mut SpanHandler,
60+
diag: @SpanHandler,
6161
tcx: ty::ctxt,
6262
reexports2: middle::resolve::ExportMap2,
6363
item_symbols: &'a RefCell<HashMap<ast::NodeId, ~str>>,
@@ -83,7 +83,7 @@ struct Stats {
8383
}
8484

8585
pub struct EncodeContext<'a> {
86-
diag: @mut SpanHandler,
86+
diag: @SpanHandler,
8787
tcx: ty::ctxt,
8888
stats: @Stats,
8989
reexports2: middle::resolve::ExportMap2,

src/librustc/metadata/loader.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ impl Context {
231231
}
232232
}
233233

234-
pub fn note_crateid_attr(diag: @mut SpanHandler,
235-
crateid: &CrateId) {
234+
pub fn note_crateid_attr(diag: @SpanHandler, crateid: &CrateId) {
236235
diag.handler().note(format!("crate_id: {}", crateid.to_str()));
237236
}
238237

src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ macro_rules! mywrite( ($wr:expr, $($arg:tt)*) => (
3232
) )
3333

3434
pub struct ctxt {
35-
diag: @mut SpanHandler,
35+
diag: @SpanHandler,
3636
// Def -> str Callback:
3737
ds: extern "Rust" fn(DefId) -> ~str,
3838
// The type context.

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ pub type ctxt = @ctxt_;
267267
/// generates so that so that it can be reused and doesn't have to be redone
268268
/// later on.
269269
struct ctxt_ {
270-
diag: @mut syntax::diagnostic::SpanHandler,
270+
diag: @syntax::diagnostic::SpanHandler,
271271
interner: RefCell<HashMap<intern_key, ~t_box_>>,
272272
next_id: Cell<uint>,
273273
cstore: @metadata::cstore::CStore,

src/libsyntax/ast_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub type map = @mut HashMap<NodeId, ast_node>;
197197
pub struct Ctx {
198198
map: map,
199199
path: path,
200-
diag: @mut SpanHandler,
200+
diag: @SpanHandler,
201201
}
202202

203203
impl Ctx {
@@ -418,7 +418,7 @@ impl Visitor<()> for Ctx {
418418
}
419419
}
420420

421-
pub fn map_crate(diag: @mut SpanHandler, c: &Crate) -> map {
421+
pub fn map_crate(diag: @SpanHandler, c: &Crate) -> map {
422422
let cx = @mut Ctx {
423423
map: @mut HashMap::new(),
424424
path: ~[],
@@ -431,7 +431,7 @@ pub fn map_crate(diag: @mut SpanHandler, c: &Crate) -> map {
431431
// Used for items loaded from external crate that are being inlined into this
432432
// crate. The `path` should be the path to the item but should not include
433433
// the item itself.
434-
pub fn map_decoded_item(diag: @mut SpanHandler,
434+
pub fn map_decoded_item(diag: @SpanHandler,
435435
map: map,
436436
path: path,
437437
ii: &inlined_item) {

src/libsyntax/attr.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ pub fn find_stability<AM: AttrMetaMethods, It: Iterator<AM>>(mut metas: It) -> O
355355
None
356356
}
357357

358-
pub fn require_unique_names(diagnostic: @mut SpanHandler,
359-
metas: &[@MetaItem]) {
358+
pub fn require_unique_names(diagnostic: @SpanHandler, metas: &[@MetaItem]) {
360359
let mut set = HashSet::new();
361360
for meta in metas.iter() {
362361
let name = meta.name();
@@ -381,7 +380,7 @@ pub fn require_unique_names(diagnostic: @mut SpanHandler,
381380
* present (before fields, if any) with that type; reprensentation
382381
* optimizations which would remove it will not be done.
383382
*/
384-
pub fn find_repr_attr(diagnostic: @mut SpanHandler, attr: @ast::MetaItem, acc: ReprAttr)
383+
pub fn find_repr_attr(diagnostic: @SpanHandler, attr: @ast::MetaItem, acc: ReprAttr)
385384
-> ReprAttr {
386385
let mut acc = acc;
387386
match attr.node {

src/libsyntax/diagnostic.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,27 @@ pub struct SpanHandler {
3535
}
3636

3737
impl SpanHandler {
38-
pub fn span_fatal(@mut self, sp: Span, msg: &str) -> ! {
38+
pub fn span_fatal(@self, sp: Span, msg: &str) -> ! {
3939
self.handler.emit(Some((&*self.cm, sp)), msg, fatal);
4040
fail!();
4141
}
42-
pub fn span_err(@mut self, sp: Span, msg: &str) {
42+
pub fn span_err(@self, sp: Span, msg: &str) {
4343
self.handler.emit(Some((&*self.cm, sp)), msg, error);
4444
self.handler.bump_err_count();
4545
}
46-
pub fn span_warn(@mut self, sp: Span, msg: &str) {
46+
pub fn span_warn(@self, sp: Span, msg: &str) {
4747
self.handler.emit(Some((&*self.cm, sp)), msg, warning);
4848
}
49-
pub fn span_note(@mut self, sp: Span, msg: &str) {
49+
pub fn span_note(@self, sp: Span, msg: &str) {
5050
self.handler.emit(Some((&*self.cm, sp)), msg, note);
5151
}
52-
pub fn span_bug(@mut self, sp: Span, msg: &str) -> ! {
52+
pub fn span_bug(@self, sp: Span, msg: &str) -> ! {
5353
self.span_fatal(sp, ice_msg(msg));
5454
}
55-
pub fn span_unimpl(@mut self, sp: Span, msg: &str) -> ! {
55+
pub fn span_unimpl(@self, sp: Span, msg: &str) -> ! {
5656
self.span_bug(sp, ~"unimplemented " + msg);
5757
}
58-
pub fn handler(@mut self) -> @mut Handler {
58+
pub fn handler(@self) -> @mut Handler {
5959
self.handler
6060
}
6161
}
@@ -124,8 +124,8 @@ pub fn ice_msg(msg: &str) -> ~str {
124124
}
125125

126126
pub fn mk_span_handler(handler: @mut Handler, cm: @codemap::CodeMap)
127-
-> @mut SpanHandler {
128-
@mut SpanHandler {
127+
-> @SpanHandler {
128+
@SpanHandler {
129129
handler: handler,
130130
cm: cm,
131131
}
@@ -327,10 +327,7 @@ fn print_macro_backtrace(cm: &codemap::CodeMap, sp: Span) {
327327
}
328328
}
329329

330-
pub fn expect<T:Clone>(
331-
diag: @mut SpanHandler,
332-
opt: Option<T>,
333-
msg: || -> ~str)
330+
pub fn expect<T:Clone>(diag: @SpanHandler, opt: Option<T>, msg: || -> ~str)
334331
-> T {
335332
match opt {
336333
Some(ref t) => (*t).clone(),

src/libsyntax/ext/tt/transcribe.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct TtFrame {
3131
}
3232

3333
pub struct TtReader {
34-
sp_diag: @mut SpanHandler,
34+
sp_diag: @SpanHandler,
3535
// the unzipped tree:
3636
priv stack: RefCell<@mut TtFrame>,
3737
/* for MBE-style macro transcription */
@@ -46,10 +46,10 @@ pub struct TtReader {
4646
/** This can do Macro-By-Example transcription. On the other hand, if
4747
* `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and
4848
* should) be none. */
49-
pub fn new_tt_reader(sp_diag: @mut SpanHandler,
49+
pub fn new_tt_reader(sp_diag: @SpanHandler,
5050
interp: Option<HashMap<Ident,@named_match>>,
5151
src: ~[ast::token_tree])
52-
-> @TtReader {
52+
-> @TtReader {
5353
let r = @TtReader {
5454
sp_diag: sp_diag,
5555
stack: RefCell::new(@mut TtFrame {

src/libsyntax/parse/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub struct lit {
347347
// it appears this function is called only from pprust... that's
348348
// probably not a good thing.
349349
pub fn gather_comments_and_literals(span_diagnostic:
350-
@mut diagnostic::SpanHandler,
350+
@diagnostic::SpanHandler,
351351
path: @str,
352352
srdr: &mut io::Reader)
353353
-> (~[cmnt], ~[lit]) {

src/libsyntax/parse/lexer.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub trait reader {
2929
fn is_eof(@self) -> bool;
3030
fn next_token(@self) -> TokenAndSpan;
3131
fn fatal(@self, ~str) -> !;
32-
fn span_diag(@self) -> @mut SpanHandler;
32+
fn span_diag(@self) -> @SpanHandler;
3333
fn peek(@self) -> TokenAndSpan;
3434
fn dup(@self) -> @reader;
3535
}
@@ -41,7 +41,7 @@ pub struct TokenAndSpan {
4141
}
4242

4343
pub struct StringReader {
44-
span_diagnostic: @mut SpanHandler,
44+
span_diagnostic: @SpanHandler,
4545
src: @str,
4646
// The absolute offset within the codemap of the next character to read
4747
pos: Cell<BytePos>,
@@ -57,7 +57,7 @@ pub struct StringReader {
5757
peek_span: RefCell<Span>,
5858
}
5959

60-
pub fn new_string_reader(span_diagnostic: @mut SpanHandler,
60+
pub fn new_string_reader(span_diagnostic: @SpanHandler,
6161
filemap: @codemap::FileMap)
6262
-> @StringReader {
6363
let r = new_low_level_string_reader(span_diagnostic, filemap);
@@ -66,7 +66,7 @@ pub fn new_string_reader(span_diagnostic: @mut SpanHandler,
6666
}
6767

6868
/* For comments.rs, which hackily pokes into 'pos' and 'curr' */
69-
pub fn new_low_level_string_reader(span_diagnostic: @mut SpanHandler,
69+
pub fn new_low_level_string_reader(span_diagnostic: @SpanHandler,
7070
filemap: @codemap::FileMap)
7171
-> @StringReader {
7272
// Force the initial reader bump to start on a fresh line
@@ -121,7 +121,7 @@ impl reader for StringReader {
121121
fn fatal(@self, m: ~str) -> ! {
122122
self.span_diagnostic.span_fatal(self.peek_span.get(), m)
123123
}
124-
fn span_diag(@self) -> @mut SpanHandler { self.span_diagnostic }
124+
fn span_diag(@self) -> @SpanHandler { self.span_diagnostic }
125125
fn peek(@self) -> TokenAndSpan {
126126
// XXX(pcwalton): Bad copy!
127127
TokenAndSpan {
@@ -145,7 +145,7 @@ impl reader for TtReader {
145145
fn fatal(@self, m: ~str) -> ! {
146146
self.sp_diag.span_fatal(self.cur_span.get(), m);
147147
}
148-
fn span_diag(@self) -> @mut SpanHandler { self.sp_diag }
148+
fn span_diag(@self) -> @SpanHandler { self.sp_diag }
149149
fn peek(@self) -> TokenAndSpan {
150150
TokenAndSpan {
151151
tok: self.cur_tok.get(),

src/libsyntax/parse/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub mod obsolete;
4242
// info about a parsing session.
4343
pub struct ParseSess {
4444
cm: @codemap::CodeMap, // better be the same as the one in the reader!
45-
span_diagnostic: @mut SpanHandler, // better be the same as the one in the reader!
45+
span_diagnostic: @SpanHandler, // better be the same as the one in the reader!
4646
/// Used to determine and report recursive mod inclusions
4747
included_mod_stack: RefCell<~[Path]>,
4848
}
@@ -56,9 +56,9 @@ pub fn new_parse_sess(demitter: Option<@Emitter>) -> @ParseSess {
5656
}
5757
}
5858

59-
pub fn new_parse_sess_special_handler(sh: @mut SpanHandler,
59+
pub fn new_parse_sess_special_handler(sh: @SpanHandler,
6060
cm: @codemap::CodeMap)
61-
-> @ParseSess {
61+
-> @ParseSess {
6262
@ParseSess {
6363
cm: cm,
6464
span_diagnostic: sh,

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub static default_columns: uint = 78u;
118118
// copy forward.
119119
pub fn print_crate(cm: @CodeMap,
120120
intr: @ident_interner,
121-
span_diagnostic: @mut diagnostic::SpanHandler,
121+
span_diagnostic: @diagnostic::SpanHandler,
122122
crate: &ast::Crate,
123123
filename: @str,
124124
input: @mut io::Reader,

0 commit comments

Comments
 (0)