summary refs log tree commit diff
path: root/compiler/rustc_span/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2022-05-05Auto merge of #91779 - ridwanabdillahi:natvis, r=michaelwoeristerbors-0/+23
Add a new Rust attribute to support embedding debugger visualizers Implemented [this RFC](https://github.com/rust-lang/rfcs/pull/3191) to add support for embedding debugger visualizers into a PDB. Added a new attribute `#[debugger_visualizer]` and updated the `CrateMetadata` to store debugger visualizers for crate dependencies. RFC: https://github.com/rust-lang/rfcs/pull/3191
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-05-03Add support for a new attribute `#[debugger_visualizer]` to support ↵ridwanabdillahi-0/+23
embedding debugger visualizers into a generated PDB. Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries. Merge the queries for debugger visualizers into a single query. Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`. Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate. Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature. Respond to PR comments and minor cleanups.
2022-04-22extend `EventArgRecorder` into span-aware `SpannedEventArgRecorder`Rémy Rakic-0/+2
The self-profiler's `EventArgRecorder` is general-purpose in its ability to record Strings (and `rustc_span` depends on the crate its defined in, `rustc_data_structure`). Some generic activities could use recording locations where they happen in the user's code: to allow e.g. to track macro expansions and diagnose performance issues there. This adds a `SpannedEventArgRecorder` that can record an argument given as a span, rather than a String, since turning spans into Strings can be tricky if you're not happy with its default Debug output. This way the recorder can have a `record_arg_spanned` method which will do that.
2022-04-19incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it.Michael Woerister-2/+1
2022-04-15Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelixDylan DPC-0/+5
Create (unstable) 2024 edition [On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition. This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024. For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical. ````@rustbot```` label +T-lang +S-waiting-on-review Not sure on the relevant team, to be honest.
2022-04-13Use .extend(..) instead of push()-ing in loopMartin Gammelsæter-18/+12
A bit less readable but more compact, and maybe faster? We'll see.
2022-04-12Optimize line offset parsing in <SourceFile as Decodable>::decodeMartin Gammelsæter-11/+20
By inverting parsing loop, avoiding continually re-checking bytes_per_diff.
2022-04-05span: move `MultiSpan`David Wood-137/+0
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-02Create 2024 editionJacob Pratt-0/+5
2022-02-25Enable rustc_pass_by_value for SpanMark Rousskov-0/+1
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-20Delete Decoder::read_struct_fieldMark Rousskov-16/+13
2022-02-20Delete Decoder::read_structMark Rousskov-60/+55
2022-02-19Adopt let else in more placesest31-7/+4
2022-02-13Update `sha1`, `sha2`, and `md5` dependenciespierwill-1/+1
This removes the `cpuid-bool` dependency, which is deprecated, while adding `crypto-common` as a new dependency.
2022-02-12Remove SPAN_DEBUG globalbjorn3-26/+12
The only difference between the default and rustc_interface set version is that the default accesses the source map from SESSION_GLOBALS while the rustc_interface version accesses the source map from the global TyCtxt. SESSION_GLOBALS is always set while running the compiler while the global TyCtxt is not always set. If the global TyCtxt is set, it's source map is identical to the one in SESSION_GLOBALS
2022-02-01add a rustc::query_stability lintlcnr-0/+1
2022-01-27Rollup merge of #93363 - lcnr:pass-by-value, r=petrochenkovMatthias Krüger-12/+12
`#[rustc_pass_by_value]` cleanup
2022-01-27try apply `rustc_pass_by_value` to `Span`lcnr-12/+12
2022-01-26Introduce a limit to Levenshtein distance computationTomasz Miąsko-0/+1
Incorporate distance limit from `find_best_match_for_name` directly into Levenshtein distance computation. Use the string size difference as a lower bound on the distance and exit early when it exceeds the specified limit. After finding a candidate within a limit, lower the limit further to restrict the search space.
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-26/+26
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-05Adjust assert_default_hashing_controlsAaron Hill-0/+3
2022-01-05Ensure that `Fingerprint` caching respects hashing configurationAaron Hill-0/+2
Fixes #92266 In some `HashStable` impls, we use a cache to avoid re-computing the same `Fingerprint` from the same structure (e.g. an `AdtDef`). However, the `StableHashingContext` used can be configured to perform hashing in different ways (e.g. skipping `Span`s). This configuration information is not included in the cache key, which will cause an incorrect `Fingerprint` to be used if we hash the same structure with different `StableHashingContext` settings. To fix this, the configuration settings of `StableHashingContext` are split out into a separate `HashingControls` struct. This struct is used as part of the cache key, ensuring that our caches always produce the correct result for the given settings. With this in place, we now turn off `Span` hashing during the entire process of computing the hash included in legacy symbols. This current has no effect, but will matter when a future PR starts hashing more `Span`s that we currently skip.
2021-12-22Remove `PartialOrd` and `Ord` from `LocalDefId`pierwill-1/+31
Implement `Ord`, `PartialOrd` for SpanData
2021-12-09Remove redundant [..]sest31-2/+2
2021-12-05Rollup merge of #91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-seMatthias Krüger-1/+0
std: Stabilize the `thread_local_const_init` feature This commit is intended to follow the stabilization disposition of the FCP that has now finished in #84223. This stabilizes the ability to flag thread local initializers as `const` expressions which enables the macro to generate more efficient code for accessing it, notably removing runtime checks for initialization. More information can also be found in #84223 as well as the tests where the feature usage was removed in this PR. Closes #84223
2021-12-03Annotate `derive`d spans and move span suggestion codeEsteban Kuber-0/+10
* Annotate `derive`d spans from the user's code with the appropciate context * Add `Span::can_be_used_for_suggestion` to query if the underlying span at the users' code
2021-11-29std: Stabilize the `thread_local_const_init` featureAlex Crichton-1/+0
This commit is intended to follow the stabilization disposition of the FCP that has now finished in #84223. This stabilizes the ability to flag thread local initializers as `const` expressions which enables the macro to generate more efficient code for accessing it, notably removing runtime checks for initialization. More information can also be found in #84223 as well as the tests where the feature usage was removed in this PR. Closes #84223
2021-11-21Simplify for loop desugarCameron Steffen-1/+1
2021-11-15Fix `non-constant value` ICE (#90878)Nilstrieb-0/+1
This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const. I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong. Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE.
2021-11-07more clippy fixesMatthias Krüger-10/+5
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-15allow `potential_query_instability` everywherelcnr-0/+1
2021-09-22Rollup merge of #89046 - oli-obk:fix_oflo, r=estebankthe8472-6/+26
"Fix" an overflow in byte position math r? `@estebank` help! I fixed the ICE only to brick the diagnostic. I mean, it was wrong previously (using an already expanded macro span), but it is really bad now XD
2021-09-20Avoid the overflow with rustc+debugassertions in issue-44406Oli Scherer-6/+23
2021-09-20Add some more tracingOli Scherer-0/+3
2021-09-15Move the Lock into symbol::Internerbjorn3-2/+2
This makes it easier to make the symbol interner (near) lock free in case of concurrent accesses in the future.
2021-09-10Remove some span tracking.Camille GILLOT-6/+6
2021-09-10Rename decode to data_untracked.Camille GILLOT-2/+2
2021-09-10Track span dependency using a callback.Camille GILLOT-2/+3
2021-09-10Encode spans relative to their parent.Camille GILLOT-3/+17
2021-09-10Keep a parent LocalDefId in SpanData.Camille GILLOT-18/+43
2021-09-08Bump stage0 compiler to 1.56Mark Rousskov-1/+0
2021-09-03Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebankbors-10/+21
Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix. This PR fixes a regression (#87745) with `--remap-path-prefix` where the flag stopped causing diagnostic messages to be remapped as well. The regression was introduced in https://github.com/rust-lang/rust/pull/83813 where we erroneously assumed that remapping of diagnostic messages was not desired anymore (because #70642 partially undid that functionality with nobody objecting). The issue is fixed by making `--remap-path-prefix` remap diagnostic messages again, including for paths that have been remapped in upstream crates (e.g. the standard library). This means that "sysroot-localization" (implemented in #70642) is also disabled if `rustc` is invoked with `--remap-path-prefix`. The assumption is that once someone starts explicitly remapping paths they also don't want paths to their local Rust installation in their build output. In the future we might want to give more fine-grained control over this behavior via compiler flags (see https://github.com/rust-lang/rfcs/pull/3127 for a related RFC). For now this PR is intended as a regression fix. This PR is an alternative to https://github.com/rust-lang/rust/pull/88191, which makes diagnostic messages be remapped unconditionally. That approach, however, would effectively revert #70642. Fixes https://github.com/rust-lang/rust/issues/87745. cc `@cbeuw` r? `@ghost`
2021-08-31Pull Span::find_ancestor_inside loop into its own function.Mara Bos-0/+8
2021-08-27Path remapping: Make behavior of diagnostics output dependent on presence of ↵Michael Woerister-10/+21
--remap-path-prefix.
2021-08-25Use if-let guards in the codebaseLéo Lanteri Thauvin-0/+2
2021-08-15Remove `HashStable` impls for `FileName` and `RealFileName`Aaron Hill-2/+2
These impls were unused, and incorrectly hashed the local (non-remapped) path for `RealFileName::Remapped` (which would break reproducible builds if these impls were used).
2021-07-17Make the CrateNum part of the ExpnId.Camille GILLOT-1/+1