about summary refs log tree commit diff
path: root/src/librustc_trans
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-08-30 11:08:26 +0000
committerbors <bors@rust-lang.org>2017-08-30 11:08:26 +0000
commitca9cf3594ab25d2809ac576dfc9defb8e87b45b8 (patch)
treec9445d8732ffdea1b395e9e2c0da993574db2e0a /src/librustc_trans
parentc66e7fa8dee0b6b2b5439e2bd527ab66c9fbde13 (diff)
parenta0c32641fd8bff11b657bfb87d9ade5487d336ae (diff)
downloadrust-ca9cf3594ab25d2809ac576dfc9defb8e87b45b8.tar.gz
rust-ca9cf3594ab25d2809ac576dfc9defb8e87b45b8.zip
Auto merge of #43968 - petrochenkov:span2, r=michaelwoerister
Make fields of `Span` private

I actually tried to intern spans and benchmark the result<sup>*</sup>, and this was a prerequisite.
This kind of encapsulation will be a prerequisite for any other attempt to compress span's representation, so I decided to submit this change alone.

The issue https://github.com/rust-lang/rust/issues/43088 seems relevant, but it looks like `SpanId` won't be able to reuse this interface, unless the tables are global (like interner that I tried) and are not a part of HIR.
r? @michaelwoerister anyway

<sup>*</sup> Interning means 2-3 times more space is required for a single span, but duplicates are free. In practice it turned out that duplicates are not *that* common, so more memory was wasted by interning rather than saved.
Diffstat (limited to 'src/librustc_trans')
-rw-r--r--src/librustc_trans/base.rs2
-rw-r--r--src/librustc_trans/debuginfo/utils.rs2
-rw-r--r--src/librustc_trans/mir/block.rs2
-rw-r--r--src/librustc_trans/mir/mod.rs10
4 files changed, 8 insertions, 8 deletions
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs
index e4b090471d7..a6c6b0efcfa 100644
--- a/src/librustc_trans/base.rs
+++ b/src/librustc_trans/base.rs
@@ -1371,7 +1371,7 @@ fn assert_symbols_are_distinct<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trans_i
             // Deterministically select one of the spans for error reporting
             let span = match (span1, span2) {
                 (Some(span1), Some(span2)) => {
-                    Some(if span1.lo.0 > span2.lo.0 {
+                    Some(if span1.lo().0 > span2.lo().0 {
                         span1
                     } else {
                         span2
diff --git a/src/librustc_trans/debuginfo/utils.rs b/src/librustc_trans/debuginfo/utils.rs
index 6df509f34a4..7529139c05a 100644
--- a/src/librustc_trans/debuginfo/utils.rs
+++ b/src/librustc_trans/debuginfo/utils.rs
@@ -49,7 +49,7 @@ pub fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray {
 
 /// Return syntax_pos::Loc corresponding to the beginning of the span
 pub fn span_start(cx: &CrateContext, span: Span) -> syntax_pos::Loc {
-    cx.sess().codemap().lookup_char_pos(span.lo)
+    cx.sess().codemap().lookup_char_pos(span.lo())
 }
 
 pub fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u32) {
diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs
index 57709b18c3b..bba3b1fa5ba 100644
--- a/src/librustc_trans/mir/block.rs
+++ b/src/librustc_trans/mir/block.rs
@@ -330,7 +330,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
                 self.set_debug_loc(&bcx, terminator.source_info);
 
                 // Get the location information.
-                let loc = bcx.sess().codemap().lookup_char_pos(span.lo);
+                let loc = bcx.sess().codemap().lookup_char_pos(span.lo());
                 let filename = Symbol::intern(&loc.file.name).as_str();
                 let filename = C_str_slice(bcx.ccx, filename);
                 let line = C_u32(bcx.ccx, loc.line as u32);
diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs
index 53cecea3d01..5206ad74e20 100644
--- a/src/librustc_trans/mir/mod.rs
+++ b/src/librustc_trans/mir/mod.rs
@@ -129,23 +129,23 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
         // In order to have a good line stepping behavior in debugger, we overwrite debug
         // locations of macro expansions with that of the outermost expansion site
         // (unless the crate is being compiled with `-Z debug-macros`).
-        if source_info.span.ctxt == NO_EXPANSION ||
+        if source_info.span.ctxt() == NO_EXPANSION ||
            self.ccx.sess().opts.debugging_opts.debug_macros {
-            let scope = self.scope_metadata_for_loc(source_info.scope, source_info.span.lo);
+            let scope = self.scope_metadata_for_loc(source_info.scope, source_info.span.lo());
             (scope, source_info.span)
         } else {
             // Walk up the macro expansion chain until we reach a non-expanded span.
             // We also stop at the function body level because no line stepping can occur
             // at the level above that.
             let mut span = source_info.span;
-            while span.ctxt != NO_EXPANSION && span.ctxt != self.mir.span.ctxt {
-                if let Some(info) = span.ctxt.outer().expn_info() {
+            while span.ctxt() != NO_EXPANSION && span.ctxt() != self.mir.span.ctxt() {
+                if let Some(info) = span.ctxt().outer().expn_info() {
                     span = info.call_site;
                 } else {
                     break;
                 }
             }
-            let scope = self.scope_metadata_for_loc(source_info.scope, span.lo);
+            let scope = self.scope_metadata_for_loc(source_info.scope, span.lo());
             // Use span of the outermost expansion site, while keeping the original lexical scope.
             (scope, span)
         }