<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fh="http://purl.org/syndication/history/1.0"><channel><title>Sourcier | Blog</title><description>Compact and efficient source file mapping and position tracking for Rust: register files once, pack every span into a single u64.</description><link>https://sourcier.vercel.app/</link><language>en</language><fh:complete/><atom:link rel="self" href="https://sourcier.vercel.app/blog/rss.xml"/><item><title>Packing source file IDs, lines, and columns into a single u64</title><link>https://sourcier.vercel.app/blog/welcome-to-sourcier/</link><guid isPermaLink="true">https://sourcier.vercel.app/blog/welcome-to-sourcier/</guid><pubDate>Sun, 15 Nov 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In compilers, linters, and macro expanders, every AST node and token carries a source span. When spans hold &lt;code dir=&quot;auto&quot;&gt;PathBuf&lt;/code&gt; clones or heap-allocated file names, memory usage climbs fast and passing locations across threads gets noisy.&lt;/p&gt;
&lt;p&gt;Sourcier (&lt;code dir=&quot;auto&quot;&gt;0.1&lt;/code&gt;) registers each source file once and packs the file ID, line, and column into a single &lt;code dir=&quot;auto&quot;&gt;Copy&lt;/code&gt; &lt;code dir=&quot;auto&quot;&gt;u64&lt;/code&gt;.&lt;/p&gt;
&lt;div&gt;&lt;h2 id=&quot;the-goal&quot;&gt;The Goal&lt;/h2&gt;&lt;/div&gt;
&lt;p&gt;We needed a lightweight source map for diagnostics-heavy Rust tools that hands out compact numeric file IDs, resolves 1-based line and column coordinates on demand, and lets spans sit inside AST nodes without lifetimes or heap allocations.&lt;/p&gt;
&lt;div&gt;&lt;h2 id=&quot;how-it-works&quot;&gt;How it works&lt;/h2&gt;&lt;/div&gt;
&lt;p&gt;A central source registry interns each file path and content buffer once, returning a compact &lt;code dir=&quot;auto&quot;&gt;FileId&lt;/code&gt;. Every &lt;code dir=&quot;auto&quot;&gt;Span&lt;/code&gt; bit-packs that ID alongside line and column offsets into one 64-bit integer.&lt;/p&gt;
&lt;div data-astro-cid-udrfwtvx=&quot;&quot;&gt;&lt;article data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;p data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;svg data-astro-cid-mhvouzvf=&quot;true&quot; aria-hidden=&quot;true&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;currentColor&quot; data-astro-cid-ib7v6bda=&quot;&quot;&gt;&lt;path fill-rule=&quot;evenodd&quot; d=&quot;M1.44 8.855v-.001l3.527-3.516c.34-.344.802-.541 1.285-.548h6.649l.947-.947c3.07-3.07 6.207-3.072 7.62-2.868a1.821 1.821 0 0 1 1.557 1.557c.204 1.413.203 4.55-2.868 7.62l-.946.946v6.649a1.845 1.845 0 0 1-.549 1.286l-3.516 3.528a1.844 1.844 0 0 1-3.11-.944l-.858-4.275-4.52-4.52-2.31-.463-1.964-.394A1.847 1.847 0 0 1 .98 10.693a1.843 1.843 0 0 1 .46-1.838Zm5.379 2.017-3.873-.776L6.32 6.733h4.638l-4.14 4.14Zm8.403-5.655c2.459-2.46 4.856-2.463 5.89-2.33.134 1.035.13 3.432-2.329 5.891l-6.71 6.71-3.561-3.56 6.71-6.711Zm-1.318 15.837-.776-3.873 4.14-4.14v4.639l-3.364 3.374Z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M9.318 18.345a.972.972 0 0 0-1.86-.561c-.482 1.435-1.687 2.204-2.934 2.619a8.22 8.22 0 0 1-1.23.302c.062-.365.157-.79.303-1.229.415-1.247 1.184-2.452 2.62-2.935a.971.971 0 1 0-.62-1.842c-.12.04-.236.084-.35.13-2.02.828-3.012 2.588-3.493 4.033a10.383 10.383 0 0 0-.51 2.845l-.001.016v.063c0 .536.434.972.97.972H2.24a7.21 7.21 0 0 0 .878-.065c.527-.063 1.248-.19 2.02-.447 1.445-.48 3.205-1.472 4.033-3.494a5.828 5.828 0 0 0 .147-.407Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;span data-astro-cid-mhvouzvf=&quot;&quot;&gt;64-Bit Packed Spans&lt;/span&gt;&lt;/p&gt;&lt;div data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;p&gt;File ID, line, and column fit inside one &lt;code dir=&quot;auto&quot;&gt;u64&lt;/code&gt; (&lt;code dir=&quot;auto&quot;&gt;Copy&lt;/code&gt;, &lt;code dir=&quot;auto&quot;&gt;Eq&lt;/code&gt;, &lt;code dir=&quot;auto&quot;&gt;Hash&lt;/code&gt;), adding zero heap allocations per AST node.&lt;/p&gt;&lt;/div&gt;&lt;/article&gt;&lt;article data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;p data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;svg data-astro-cid-mhvouzvf=&quot;true&quot; aria-hidden=&quot;true&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;currentColor&quot; data-astro-cid-ib7v6bda=&quot;&quot;&gt;&lt;path d=&quot;M17 22H5a3 3 0 0 1-3-3V9a3 3 0 0 1 3-3h1a4 4 0 0 1 7.3-2.18c.448.64.692 1.4.7 2.18h3a1 1 0 0 1 1 1v3a4 4 0 0 1 2.18 7.3A3.86 3.86 0 0 1 18 18v3a1 1 0 0 1-1 1ZM5 8a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h11v-3.18a1 1 0 0 1 1.33-.95 1.77 1.77 0 0 0 1.74-.23 2 2 0 0 0 .93-1.37 2 2 0 0 0-.48-1.59 1.89 1.89 0 0 0-2.17-.55 1 1 0 0 1-1.33-.95V8h-3.2a1 1 0 0 1-1-1.33 1.77 1.77 0 0 0-.23-1.74 1.939 1.939 0 0 0-3-.43A2 2 0 0 0 8 6c.002.23.046.456.13.67A1 1 0 0 1 7.18 8H5Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;span data-astro-cid-mhvouzvf=&quot;&quot;&gt;Single File Registration&lt;/span&gt;&lt;/p&gt;&lt;div data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;p&gt;Paths and source text are stored once in the source map rather than duplicated across tokens and diagnostics.&lt;/p&gt;&lt;/div&gt;&lt;/article&gt;&lt;article data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;p data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;svg data-astro-cid-mhvouzvf=&quot;true&quot; aria-hidden=&quot;true&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;currentColor&quot; data-astro-cid-ib7v6bda=&quot;&quot;&gt;&lt;path d=&quot;m21.32 9.55-1.89-.63.89-1.78A1 1 0 0 0 20.13 6L18 3.87a1 1 0 0 0-1.15-.19l-1.78.89-.63-1.89A1 1 0 0 0 13.5 2h-3a1 1 0 0 0-.95.68l-.63 1.89-1.78-.89A1 1 0 0 0 6 3.87L3.87 6a1 1 0 0 0-.19 1.15l.89 1.78-1.89.63a1 1 0 0 0-.68.94v3a1 1 0 0 0 .68.95l1.89.63-.89 1.78A1 1 0 0 0 3.87 18L6 20.13a1 1 0 0 0 1.15.19l1.78-.89.63 1.89a1 1 0 0 0 .95.68h3a1 1 0 0 0 .95-.68l.63-1.89 1.78.89a1 1 0 0 0 1.13-.19L20.13 18a1 1 0 0 0 .19-1.15l-.89-1.78 1.89-.63a1 1 0 0 0 .68-.94v-3a1 1 0 0 0-.68-.95ZM20 12.78l-1.2.4A2 2 0 0 0 17.64 16l.57 1.14-1.1 1.1-1.11-.6a2 2 0 0 0-2.79 1.16l-.4 1.2h-1.59l-.4-1.2A2 2 0 0 0 8 17.64l-1.14.57-1.1-1.1.6-1.11a2 2 0 0 0-1.16-2.82l-1.2-.4v-1.56l1.2-.4A2 2 0 0 0 6.36 8l-.57-1.11 1.1-1.1L8 6.36a2 2 0 0 0 2.82-1.16l.4-1.2h1.56l.4 1.2A2 2 0 0 0 16 6.36l1.14-.57 1.1 1.1-.6 1.11a2 2 0 0 0 1.16 2.79l1.2.4v1.59ZM12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8Zm0 6a2 2 0 1 1 0-4 2 2 0 0 1 0 4Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;span data-astro-cid-mhvouzvf=&quot;&quot;&gt;On-Demand Line Lookup&lt;/span&gt;&lt;/p&gt;&lt;div data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;p&gt;Byte offsets map back to 1-based line and column coordinates only when formatting an error message.&lt;/p&gt;&lt;/div&gt;&lt;/article&gt;&lt;article data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;p data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;svg data-astro-cid-mhvouzvf=&quot;true&quot; aria-hidden=&quot;true&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;currentColor&quot; data-astro-cid-ib7v6bda=&quot;&quot;&gt;&lt;path d=&quot;M18.71 7.21a1 1 0 0 0-1.42 0l-7.45 7.46-3.13-3.14A1.02 1.02 0 1 0 5.29 13l3.84 3.84a1.001 1.001 0 0 0 1.42 0l8.16-8.16a1 1 0 0 0 0-1.47Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;span data-astro-cid-mhvouzvf=&quot;&quot;&gt;Lifetime-Free ASTs&lt;/span&gt;&lt;/p&gt;&lt;div data-astro-cid-mhvouzvf=&quot;&quot;&gt;&lt;p&gt;Because spans are plain integers rather than &lt;code dir=&quot;auto&quot;&gt;&amp;#x26;str&lt;/code&gt; slices, syntax trees can move across threads and crates cleanly.&lt;/p&gt;&lt;/div&gt;&lt;/article&gt;&lt;/div&gt;
&lt;div&gt;&lt;h2 id=&quot;what-it-cost&quot;&gt;What it cost&lt;/h2&gt;&lt;/div&gt;
&lt;p&gt;Packing file IDs, lines, and columns into 64 bits means trading arbitrary integer width for fixed bit budgets. We had to define explicit bit widths for each field so standard source files pack without overflow while still catching out-of-range coordinates cleanly.&lt;/p&gt;
&lt;aside aria-label=&quot;Where this does not apply&quot;&gt;&lt;p aria-hidden=&quot;true&quot;&gt;Where this does not apply&lt;/p&gt;&lt;div&gt;&lt;p&gt;Because coordinates are bit-packed into a fixed &lt;code dir=&quot;auto&quot;&gt;u64&lt;/code&gt; layout, Sourcier is designed for normal source files rather than multi-gigabyte generated blobs with millions of lines in a single file. If your input exceeds the bit budget of a field, use full &lt;code dir=&quot;auto&quot;&gt;usize&lt;/code&gt; byte ranges instead.&lt;/p&gt;&lt;/div&gt;&lt;/aside&gt;
&lt;div&gt;&lt;h2 id=&quot;getting-started&quot;&gt;Getting started&lt;/h2&gt;&lt;/div&gt;
&lt;div&gt;&lt;figure&gt;&lt;figcaption&gt;&lt;/figcaption&gt;&lt;pre&gt;&lt;code&gt;&lt;div&gt;&lt;div&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;dependencies&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span&gt;sourcier = &lt;/span&gt;&lt;span&gt;&quot;0.1&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;&lt;/div&gt;
&lt;p&gt;Check the &lt;a href=&quot;https://sourcier.vercel.app/tutorials/getting-started/&quot;&gt;getting started tutorial&lt;/a&gt; and &lt;a href=&quot;https://sourcier.vercel.app/reference/api/&quot;&gt;API reference&lt;/a&gt; to register files and attach packed spans to your diagnostics.&lt;/p&gt;</content:encoded></item></channel></rss>