about summary refs log tree commit diff
path: root/compiler/rustc_span/src/source_map.rs
AgeCommit message (Collapse)AuthorLines
2025-07-28use let chains in mir, resolve, targetKivooeo-4/+4
2025-05-05Take into-account `-Zremap-path-scope` when embedding filenamesUrgau-36/+44
2025-04-10add `span_extend_to_prev_char_before()` to `SourceMap`Makai-0/+18
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-29/+29
2024-11-24Auto merge of #132791 - tyilo:big-file-fail-fast, r=compiler-errorsbors-1/+10
rustc: Fail fast when compiling a source file larger than 4 GiB Currently if you try to compile a file that is larger than 4 GiB, `rustc` will first read the whole into memory before failing. If we can read the metadata of the file, we can fail before reading the file.
2024-11-23rustc: Fail fast when compiling a source file larger than 4 GiB - 1 BAsger Hautop Drewsen-1/+10
Fixes #132862
2024-11-08coverage: Restrict empty-span expansion to only cover `{` and `}`Zalathar-1/+1
2024-10-28fix clippy::clone_on_ref_ptr for compilerklensy-6/+6
2024-10-01add unstable support for outputting file checksums for use in cargoJacob Kiesel-2/+14
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+5
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-18Be more accurate about calculating `display_col` from a `BytePos`Esteban Küber-2/+0
No longer track "zero-width" chars in `SourceMap`, read directly from the line when calculating the `display_col` of a `BytePos`. Move `char_width` to `rustc_span` and use it from the emitter. This change allows the following to properly align in terminals (depending on the font, the replaced control codepoints are rendered as 1 or 2 width, on my terminal they are rendered as 1, on VSCode text they are rendered as 2): ``` error: this file contains an unclosed delimiter --> $DIR/issue-68629.rs:5:17 | LL | ␜␟ts␀![{i | -- unclosed delimiter | | | unclosed delimiter LL | ␀␀ fn rݻoa>rݻm | ^ ```
2024-05-22Remove `#[macro_use]` extern crate tracing` from `rustc_span`.Nicholas Nethercote-0/+1
Because explicit macro imports are better than implicit macro imports.
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-0/+1
2024-04-23Rollup merge of #123993 - compiler-errors:coroutine-obl, r=lcnrLeón Orell Valerian Liehr-1/+1
Do `check_coroutine_obligations` once per typeck root We only need to do `check_coroutine_obligations` once per typeck root, especially since the new solver can't really (easily) associate which obligations correspond to which coroutines. This requires us to move the checks for sized coroutine fields into `mir_coroutine_witnesses`, but that's fine imo. r? lcnr
2024-04-16Construct `SourceMap` at the same time as `SessionGlobals`.Nicholas Nethercote-8/+18
Currently `SourceMap` is constructed slightly later than `SessionGlobals`, and inserted. This commit changes things so they are done at the same time. Benefits: - `SessionGlobals::source_map` changes from `Lock<Option<Lrc<SourceMap>>>` to `Option<Lrc<SourceMap>>`. It's still optional, but mutability isn't required because it's initialized at construction. - `set_source_map` is removed, simplifying `run_compiler`, which is good because that's a critical function and it's nice to make it simpler. This requires moving things around a bit, so the necessary inputs are available when `SessionGlobals` is created, in particular the `loader` and `hash_kind`, which are no longer computed by `build_session`. These inputs are captured by the new `SourceMapInputs` type, which is threaded through various places.
2024-04-15redundant ::{self}Michael Goulet-1/+1
2024-04-12Rollup merge of #123204 - notriddle:notriddle/include-str-span, r=pnkfelixMatthias Krüger-3/+11
rustdoc: point at span in `include_str!`-ed md file Fixes #118549
2024-04-09Add a helper for extending a span to include any trailing whitespaceMichael Goulet-6/+9
2024-03-29rustdoc: point at span in `include_str!`-ed md fileMichael Howell-3/+11
2024-03-28Introduce `FileNameMapping::to_real_filename` and use it everywhereUrgau-0/+15
2024-01-17Use UnhashMap for a few more mapsMark Rousskov-2/+2
This avoids hashing data that's already hashed.
2024-01-15compiler: Lower fn call arg spans down to MIRMartin Nordholts-1/+1
To enable improved accuracy of diagnostics in upcoming commits.
2024-01-06rustc_span: Optimize syntax context comparisonsVadim Petrochenkov-3/+9
Including comparisons with root context
2023-12-19Unify SourceFile::name_hash and StableSourceFileIdMichael Woerister-48/+7
2023-12-10remove redundant importssurechen-4/+2
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-43/+7
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-10-17[RFC 3127 - Trim Paths]: Condition remapped filepath on remap scopesUrgau-8/+26
2023-09-12Fall back to an unoptimized implementation in read_binary_file if ↵Ben Kimock-2/+31
File::metadata lies
2023-09-07Use `Freeze` for `SourceFile.lines`John Kåre Alsaker-1/+1
2023-09-07Use `Freeze` for `SourceFile.external_src`John Kåre Alsaker-6/+6
2023-09-04Pass StableSourceFileId.Camille GILLOT-4/+4
2023-09-03Compute address space from previous file.Camille GILLOT-29/+9
2023-09-03Register the file while computing its start position.Camille GILLOT-38/+31
2023-09-03Use relative positions inside a SourceFile.Camille GILLOT-52/+20
2023-08-27Load include_bytes! directly into an LrcBen Kimock-4/+17
2023-08-06refactor on span_look_aheadyukang-9/+6
2023-06-29Use `partition_point` in `SourceMap::lookup_source_file_idx`.Nicholas Nethercote-5/+1
This makes it (a) a little simpler, and (b) more similar to `SourceFile::lookup_line`.
2023-06-10reword the message to suggest surrounding with parenthesesyukang-1/+4
2023-06-10take care module name for suggesting surround the struct literal in parenthesesyukang-0/+12
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-3/+3
2023-05-14Simplify find_width_of_character_at_span.Mara Bos-24/+7
2023-05-06correct literals for dyn thread safeSparrowLii-3/+5
2023-05-06introduce `DynSend` and `DynSync` auto traitSparrowLii-3/+3
2023-04-18Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillotbors-3/+3
Encode hashes as bytes, not varint In a few places, we store hashes as `u64` or `u128` and then apply `derive(Decodable, Encodable)` to the enclosing struct/enum. It is more efficient to encode hashes directly than try to apply some varint encoding. This PR adds two new types `Hash64` and `Hash128` which are produced by `StableHasher` and replace every use of storing a `u64` or `u128` that represents a hash. Distribution of the byte lengths of leb128 encodings, from `x build --stage 2` with `incremental = true` Before: ``` ( 1) 373418203 (53.7%, 53.7%): 1 ( 2) 196240113 (28.2%, 81.9%): 3 ( 3) 108157958 (15.6%, 97.5%): 2 ( 4) 17213120 ( 2.5%, 99.9%): 4 ( 5) 223614 ( 0.0%,100.0%): 9 ( 6) 216262 ( 0.0%,100.0%): 10 ( 7) 15447 ( 0.0%,100.0%): 5 ( 8) 3633 ( 0.0%,100.0%): 19 ( 9) 3030 ( 0.0%,100.0%): 8 ( 10) 1167 ( 0.0%,100.0%): 18 ( 11) 1032 ( 0.0%,100.0%): 7 ( 12) 1003 ( 0.0%,100.0%): 6 ( 13) 10 ( 0.0%,100.0%): 16 ( 14) 10 ( 0.0%,100.0%): 17 ( 15) 5 ( 0.0%,100.0%): 12 ( 16) 4 ( 0.0%,100.0%): 14 ``` After: ``` ( 1) 372939136 (53.7%, 53.7%): 1 ( 2) 196240140 (28.3%, 82.0%): 3 ( 3) 108014969 (15.6%, 97.5%): 2 ( 4) 17192375 ( 2.5%,100.0%): 4 ( 5) 435 ( 0.0%,100.0%): 5 ( 6) 83 ( 0.0%,100.0%): 18 ( 7) 79 ( 0.0%,100.0%): 10 ( 8) 50 ( 0.0%,100.0%): 9 ( 9) 6 ( 0.0%,100.0%): 19 ``` The remaining 9 or 10 and 18 or 19 are `u64` and `u128` respectively that have the high bits set. As far as I can tell these are coming primarily from `SwitchTargets`.
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-3/+3
2023-04-17Spelling - compilerJosh Soref-2/+2
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-16fix clippy::toplevel_ref_arg and ::manual_mapMatthias Krüger-3/+1
2023-04-09Box large enum variantsNilstrieb-4/+4
2023-03-15Implementing "<test_binary> --list --format json" #107307 #49359Partha P. Das-10/+21