Skip to content

Commit 1a1e99c

Browse files
committed
Merge remote-tracking branch 'brson/codemap'
Conflicts: src/libsyntax/ext/source_util.rs
2 parents 428c58b + e621e68 commit 1a1e99c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+710
-518
lines changed

src/libfuzzer/fuzzer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn as_str(f: fn@(+x: io::Writer)) -> ~str {
225225
io::with_str_writer(f)
226226
}
227227

228-
fn check_variants_of_ast(crate: ast::crate, codemap: codemap::CodeMap,
228+
fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
229229
filename: &Path, cx: context) {
230230
let stolen = steal(crate, cx.mode);
231231
let extra_exprs = vec::filter(common_exprs(),
@@ -239,7 +239,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: codemap::CodeMap,
239239

240240
fn check_variants_T<T: Copy>(
241241
crate: ast::crate,
242-
codemap: codemap::CodeMap,
242+
codemap: @codemap::CodeMap,
243243
filename: &Path,
244244
thing_label: ~str,
245245
things: ~[T],

src/librustc/driver/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ fn pretty_print_input(sess: Session, cfg: ast::crate_cfg, input: input,
366366
ppm_expanded | ppm_normal => pprust::no_ann()
367367
};
368368
let is_expanded = upto != cu_parse;
369-
let src = codemap::get_filemap(sess.codemap, source_name(input)).src;
369+
let src = sess.codemap.get_filemap(source_name(input)).src;
370370
do io::with_str_reader(*src) |rdr| {
371371
pprust::print_crate(sess.codemap, sess.parse_sess.interner,
372372
sess.span_diagnostic, crate,
@@ -586,7 +586,7 @@ fn build_session_options(binary: ~str,
586586

587587
fn build_session(sopts: @session::options,
588588
demitter: diagnostic::emitter) -> Session {
589-
let codemap = codemap::new_codemap();
589+
let codemap = @codemap::CodeMap::new();
590590
let diagnostic_handler =
591591
diagnostic::mk_handler(Some(demitter));
592592
let span_diagnostic_handler =
@@ -595,7 +595,7 @@ fn build_session(sopts: @session::options,
595595
}
596596

597597
fn build_session_(sopts: @session::options,
598-
cm: codemap::CodeMap,
598+
cm: @codemap::CodeMap,
599599
demitter: diagnostic::emitter,
600600
span_diagnostic_handler: diagnostic::span_handler)
601601
-> Session {

src/librustc/driver/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ type Session_ = {targ_cfg: @config,
131131
opts: @options,
132132
cstore: metadata::cstore::CStore,
133133
parse_sess: parse_sess,
134-
codemap: codemap::CodeMap,
134+
codemap: @codemap::CodeMap,
135135
// For a library crate, this is always none
136136
mut main_fn: Option<(node_id, codemap::span)>,
137137
span_diagnostic: diagnostic::span_handler,

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Serializer,
557557
let add_to_index = |copy ebml_w| add_to_index_(item, ebml_w, index);
558558

559559
debug!("encoding info for item at %s",
560-
syntax::codemap::span_to_str(item.span, ecx.tcx.sess.codemap));
560+
ecx.tcx.sess.codemap.span_to_str(item.span));
561561

562562
match item.node {
563563
item_const(_, _) => {

src/librustc/middle/liveness.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ use std::map::HashMap;
9797
use syntax::{visit, ast_util};
9898
use syntax::print::pprust::{expr_to_str, block_to_str};
9999
use visit::vt;
100-
use syntax::codemap::{span, span_to_str};
100+
use syntax::codemap::span;
101101
use syntax::ast::*;
102102
use io::WriterUtil;
103103
use capture::{cap_move, cap_drop, cap_copy, cap_ref};
@@ -170,9 +170,9 @@ impl LiveNodeKind : cmp::Eq {
170170
fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {
171171
let cm = cx.sess.codemap;
172172
match lnk {
173-
FreeVarNode(s) => fmt!("Free var node [%s]", span_to_str(s, cm)),
174-
ExprNode(s) => fmt!("Expr node [%s]", span_to_str(s, cm)),
175-
VarDefNode(s) => fmt!("Var def node [%s]", span_to_str(s, cm)),
173+
FreeVarNode(s) => fmt!("Free var node [%s]", cm.span_to_str(s)),
174+
ExprNode(s) => fmt!("Expr node [%s]", cm.span_to_str(s)),
175+
VarDefNode(s) => fmt!("Var def node [%s]", cm.span_to_str(s)),
176176
ExitNode => ~"Exit node"
177177
}
178178
}

src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ fn trans_trace(bcx: block, sp_opt: Option<span>, trace_str: ~str) {
919919
let {V_filename, V_line} = match sp_opt {
920920
Some(sp) => {
921921
let sess = bcx.sess();
922-
let loc = codemap::lookup_char_pos(sess.parse_sess.cm, sp.lo);
922+
let loc = sess.parse_sess.cm.lookup_char_pos(sp.lo);
923923
{V_filename: C_cstr(bcx.ccx(), loc.file.name),
924924
V_line: loc.line as int}
925925
}

src/librustc/middle/trans/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
645645
fn add_span_comment(bcx: block, sp: span, text: ~str) {
646646
let ccx = bcx.ccx();
647647
if !ccx.sess.no_asm_comments() {
648-
let s = text + ~" (" + codemap::span_to_str(sp, ccx.sess.codemap)
648+
let s = text + ~" (" + ccx.sess.codemap.span_to_str(sp)
649649
+ ~")";
650650
log(debug, s);
651651
add_comment(bcx, s);

src/librustc/middle/trans/controlflow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ fn trans_fail_value(bcx: block, sp_opt: Option<span>, V_fail_str: ValueRef)
339339
let {V_filename, V_line} = match sp_opt {
340340
Some(sp) => {
341341
let sess = bcx.sess();
342-
let loc = codemap::lookup_char_pos(sess.parse_sess.cm, sp.lo);
342+
let loc = sess.parse_sess.cm.lookup_char_pos(sp.lo);
343343
{V_filename: C_cstr(bcx.ccx(), loc.file.name),
344344
V_line: loc.line as int}
345345
}
@@ -361,7 +361,7 @@ fn trans_fail_bounds_check(bcx: block, sp: span,
361361
let _icx = bcx.insn_ctxt("trans_fail_bounds_check");
362362
let ccx = bcx.ccx();
363363
364-
let loc = codemap::lookup_char_pos(bcx.sess().parse_sess.cm, sp.lo);
364+
let loc = bcx.sess().parse_sess.cm.lookup_char_pos(sp.lo);
365365
let line = C_int(ccx, loc.line as int);
366366
let filename_cstr = C_cstr(bcx.ccx(), loc.file.name);
367367
let filename = PointerCast(bcx, filename_cstr, T_ptr(T_i8()));

src/librustc/middle/trans/debuginfo.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use trans::build::B;
88
use middle::ty;
99
use syntax::{ast, codemap, ast_util, ast_map};
1010
use syntax::parse::token::ident_interner;
11-
use codemap::span;
11+
use codemap::{span, CharPos};
1212
use ast::Ty;
1313
use pat_util::*;
1414
use util::ppaux::ty_to_str;
@@ -112,7 +112,7 @@ type compile_unit_md = {name: ~str};
112112
type subprogram_md = {id: ast::node_id};
113113
type local_var_md = {id: ast::node_id};
114114
type tydesc_md = {hash: uint};
115-
type block_md = {start: codemap::loc, end: codemap::loc};
115+
type block_md = {start: codemap::Loc, end: codemap::Loc};
116116
type argument_md = {id: ast::node_id};
117117
type retval_md = {id: ast::node_id};
118118

@@ -229,8 +229,8 @@ fn create_file(cx: @crate_ctxt, full_path: ~str) -> @metadata<file_md> {
229229
return mdval;
230230
}
231231

232-
fn line_from_span(cm: codemap::CodeMap, sp: span) -> uint {
233-
codemap::lookup_char_pos(cm, sp.lo).line
232+
fn line_from_span(cm: @codemap::CodeMap, sp: span) -> uint {
233+
cm.lookup_char_pos(sp.lo).line
234234
}
235235

236236
fn create_block(cx: block) -> @metadata<block_md> {
@@ -244,9 +244,9 @@ fn create_block(cx: block) -> @metadata<block_md> {
244244
}
245245
let sp = cx.node_info.get().span;
246246

247-
let start = codemap::lookup_char_pos(cx.sess().codemap, sp.lo);
247+
let start = cx.sess().codemap.lookup_char_pos(sp.lo);
248248
let fname = start.file.name;
249-
let end = codemap::lookup_char_pos(cx.sess().codemap, sp.hi);
249+
let end = cx.sess().codemap.lookup_char_pos(sp.hi);
250250
let tg = LexicalBlockTag;
251251
/*alt cached_metadata::<@metadata<block_md>>(
252252
cache, tg,
@@ -266,8 +266,8 @@ fn create_block(cx: block) -> @metadata<block_md> {
266266
};
267267
let lldata = ~[lltag(tg),
268268
parent,
269-
lli32(start.line as int),
270-
lli32(start.col as int),
269+
lli32(start.line.to_int()),
270+
lli32(start.col.to_int()),
271271
file_node.node,
272272
lli32(unique_id)
273273
];
@@ -597,7 +597,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::Ty)
597597
}
598598

599599
fn filename_from_span(cx: @crate_ctxt, sp: codemap::span) -> ~str {
600-
codemap::lookup_char_pos(cx.sess.codemap, sp.lo).file.name
600+
cx.sess.codemap.lookup_char_pos(sp.lo).file.name
601601
}
602602

603603
fn create_var(type_tag: int, context: ValueRef, name: ~str, file: ValueRef,
@@ -629,8 +629,7 @@ fn create_local_var(bcx: block, local: @ast::local)
629629
// FIXME this should be handled (#2533)
630630
_ => fail ~"no single variable name for local"
631631
};
632-
let loc = codemap::lookup_char_pos(cx.sess.codemap,
633-
local.span.lo);
632+
let loc = cx.sess.codemap.lookup_char_pos(local.span.lo);
634633
let ty = node_id_type(bcx, local.node.id);
635634
let tymd = create_ty(cx, ty, local.node.ty);
636635
let filemd = create_file(cx, loc.file.name);
@@ -674,8 +673,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
674673
option::None => ()
675674
}
676675

677-
let loc = codemap::lookup_char_pos(cx.sess.codemap,
678-
sp.lo);
676+
let loc = cx.sess.codemap.lookup_char_pos(sp.lo);
679677
let ty = node_id_type(bcx, arg.id);
680678
let tymd = create_ty(cx, ty, arg.ty);
681679
let filemd = create_file(cx, loc.file.name);
@@ -714,9 +712,9 @@ fn update_source_pos(cx: block, s: span) {
714712
}
715713
let cm = cx.sess().codemap;
716714
let blockmd = create_block(cx);
717-
let loc = codemap::lookup_char_pos(cm, s.lo);
718-
let scopedata = ~[lli32(loc.line as int),
719-
lli32(loc.col as int),
715+
let loc = cm.lookup_char_pos(s.lo);
716+
let scopedata = ~[lli32(loc.line.to_int()),
717+
lli32(loc.col.to_int()),
720718
blockmd.node,
721719
llnull()];
722720
let dbgscope = llmdnode(scopedata);
@@ -731,7 +729,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
731729
log(debug, fcx.id);
732730

733731
let sp = fcx.span.get();
734-
log(debug, codemap::span_to_str(sp, cx.sess.codemap));
732+
log(debug, cx.sess.codemap.span_to_str(sp));
735733

736734
let (ident, ret_ty, id) = match cx.tcx.items.get(fcx.id) {
737735
ast_map::node_item(item, _) => {
@@ -773,8 +771,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
773771
option::None => ()
774772
}
775773

776-
let loc = codemap::lookup_char_pos(cx.sess.codemap,
777-
sp.lo);
774+
let loc = cx.sess.codemap.lookup_char_pos(sp.lo);
778775
let file_node = create_file(cx, loc.file.name).node;
779776
let ty_node = if cx.sess.opts.extra_debuginfo {
780777
match ret_ty.node {

src/librustc/middle/typeck/infer/region_inference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl RegionVarBindings {
507507
self.undo_log.push(AddVar(vid));
508508
}
509509
debug!("created new region variable %? with span %?",
510-
vid, codemap::span_to_str(span, self.tcx.sess.codemap));
510+
vid, self.tcx.sess.codemap.span_to_str(span));
511511
return vid;
512512
}
513513

src/librustc/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
193193
194194
// The 'diagnostics emitter'. Every error, warning, etc. should
195195
// go through this function.
196-
let demitter = fn@(cmsp: Option<(codemap::CodeMap, codemap::span)>,
196+
let demitter = fn@(cmsp: Option<(@codemap::CodeMap, codemap::span)>,
197197
msg: &str, lvl: diagnostic::level) {
198198
if lvl == diagnostic::fatal {
199199
comm::send(ch, fatal);

src/librustc/util/ppaux.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ fn explain_region_and_span(cx: ctxt, region: ty::Region)
105105
fn explain_span(cx: ctxt, heading: ~str, span: span)
106106
-> (~str, Option<span>)
107107
{
108-
let lo = codemap::lookup_char_pos_adj(cx.sess.codemap, span.lo);
109-
(fmt!("the %s at %u:%u", heading, lo.line, lo.col), Some(span))
108+
let lo = cx.sess.codemap.lookup_char_pos_adj(span.lo);
109+
(fmt!("the %s at %u:%u", heading,
110+
lo.line, lo.col.to_uint()), Some(span))
110111
}
111112
}
112113

@@ -131,29 +132,29 @@ fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str {
131132
match cx.items.find(node_id) {
132133
Some(ast_map::node_block(blk)) => {
133134
fmt!("<block at %s>",
134-
codemap::span_to_str(blk.span, cx.sess.codemap))
135+
cx.sess.codemap.span_to_str(blk.span))
135136
}
136137
Some(ast_map::node_expr(expr)) => {
137138
match expr.node {
138139
ast::expr_call(*) => {
139140
fmt!("<call at %s>",
140-
codemap::span_to_str(expr.span, cx.sess.codemap))
141+
cx.sess.codemap.span_to_str(expr.span))
141142
}
142143
ast::expr_match(*) => {
143144
fmt!("<alt at %s>",
144-
codemap::span_to_str(expr.span, cx.sess.codemap))
145+
cx.sess.codemap.span_to_str(expr.span))
145146
}
146147
ast::expr_assign_op(*) |
147148
ast::expr_field(*) |
148149
ast::expr_unary(*) |
149150
ast::expr_binary(*) |
150151
ast::expr_index(*) => {
151152
fmt!("<method at %s>",
152-
codemap::span_to_str(expr.span, cx.sess.codemap))
153+
cx.sess.codemap.span_to_str(expr.span))
153154
}
154155
_ => {
155156
fmt!("<expression at %s>",
156-
codemap::span_to_str(expr.span, cx.sess.codemap))
157+
cx.sess.codemap.span_to_str(expr.span))
157158
}
158159
}
159160
}

src/librustdoc/astsrv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn build_ctxt(sess: Session,
120120

121121
fn build_session() -> Session {
122122
let sopts: @options = basic_options();
123-
let codemap = codemap::new_codemap();
123+
let codemap = @codemap::CodeMap::new();
124124
let error_handlers = build_error_handlers(codemap);
125125
let {emitter, span_handler} = error_handlers;
126126

@@ -137,7 +137,7 @@ type ErrorHandlers = {
137137
// Build a custom error handler that will allow us to ignore non-fatal
138138
// errors
139139
fn build_error_handlers(
140-
codemap: codemap::CodeMap
140+
codemap: @codemap::CodeMap
141141
) -> ErrorHandlers {
142142

143143
type DiagnosticHandler = {
@@ -156,13 +156,13 @@ fn build_error_handlers(
156156
fn note(msg: &str) { self.inner.note(msg) }
157157
fn bug(msg: &str) -> ! { self.inner.bug(msg) }
158158
fn unimpl(msg: &str) -> ! { self.inner.unimpl(msg) }
159-
fn emit(cmsp: Option<(codemap::CodeMap, codemap::span)>,
159+
fn emit(cmsp: Option<(@codemap::CodeMap, codemap::span)>,
160160
msg: &str, lvl: diagnostic::level) {
161161
self.inner.emit(cmsp, msg, lvl)
162162
}
163163
}
164164

165-
let emitter = fn@(cmsp: Option<(codemap::CodeMap, codemap::span)>,
165+
let emitter = fn@(cmsp: Option<(@codemap::CodeMap, codemap::span)>,
166166
msg: &str, lvl: diagnostic::level) {
167167
diagnostic::emit(cmsp, msg, lvl);
168168
};

src/librustdoc/attr_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mod test {
3030

3131
let parse_sess = syntax::parse::new_parse_sess(None);
3232
let parser = parse::new_parser_from_source_str(
33-
parse_sess, ~[], ~"-", codemap::fss_none, @source);
33+
parse_sess, ~[], ~"-", codemap::FssNone, @source);
3434
3535
parser.parse_outer_attributes()
3636
}

src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::serialization::{Serializable,
44
Deserializable,
55
Serializer,
66
Deserializer};
7-
use codemap::{span, filename};
7+
use codemap::{span, FileName};
88
use parse::token;
99

1010
#[auto_serialize]

src/libsyntax/ast_util.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use codemap::span;
1+
use codemap::{span, BytePos};
22
use ast::*;
33

4-
pure fn spanned<T>(lo: uint, hi: uint, +t: T) -> spanned<T> {
4+
pure fn spanned<T>(+lo: BytePos, +hi: BytePos, +t: T) -> spanned<T> {
55
respan(mk_sp(lo, hi), move t)
66
}
77

@@ -14,12 +14,12 @@ pure fn dummy_spanned<T>(+t: T) -> spanned<T> {
1414
}
1515

1616
/* assuming that we're not in macro expansion */
17-
pure fn mk_sp(lo: uint, hi: uint) -> span {
18-
{lo: lo, hi: hi, expn_info: None}
17+
pure fn mk_sp(+lo: BytePos, +hi: BytePos) -> span {
18+
span {lo: lo, hi: hi, expn_info: None}
1919
}
2020

2121
// make this a const, once the compiler supports it
22-
pure fn dummy_sp() -> span { return mk_sp(0u, 0u); }
22+
pure fn dummy_sp() -> span { return mk_sp(BytePos(0), BytePos(0)); }
2323

2424

2525

src/libsyntax/attr.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use either::Either;
66
use diagnostic::span_handler;
77
use ast_util::{spanned, dummy_spanned};
88
use parse::comments::{doc_comment_style, strip_doc_comment_decoration};
9+
use codemap::BytePos;
910

1011
// Constructors
1112
export mk_name_value_item_str;
@@ -74,7 +75,8 @@ fn mk_attr(item: @ast::meta_item) -> ast::attribute {
7475
is_sugared_doc: false});
7576
}
7677

77-
fn mk_sugared_doc_attr(text: ~str, lo: uint, hi: uint) -> ast::attribute {
78+
fn mk_sugared_doc_attr(text: ~str,
79+
+lo: BytePos, +hi: BytePos) -> ast::attribute {
7880
let lit = spanned(lo, hi, ast::lit_str(@text));
7981
let attr = {
8082
style: doc_comment_style(text),

0 commit comments

Comments
 (0)