about summary refs log tree commit diff
path: root/compiler/rustc_span/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2022-07-14Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPCbors-1/+0
Rollup of 5 pull requests Successful merges: - #97720 (Always create elided lifetime parameters for functions) - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`) - #98705 (Implement `for<>` lifetime binder for closures) - #99126 (remove allow(rustc::potential_query_instability) in rustc_span) - #99139 (Give a better error when `x dist` fails for an optional tool) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-2/+2
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-13reduce scope of allow(rustc::potential_query_instability) in rustc_spanNiklas Jonsson-1/+0
2022-07-07Miscellaneous inlining improvementsTomasz Miąsko-0/+1
Add `#[inline]` to a few trivial non-generic methods from a perf report that otherwise wouldn't be candidates for inlining.
2022-06-19Use `Span::eq_ctxt` method instead of `.ctxt() == .ctxt()`Michael Goulet-0/+3
2022-06-14Rename rustc_serialize::opaque::Encoder as MemEncoder.Nicholas Nethercote-2/+2
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports). (This was previously merged as commit 5 in #94732 and then was reverted in #97905 because of a perf regression caused by commit 4 in #94732.)
2022-06-11Auto merge of #97980 - Dylan-DPC:rollup-l8exe4b, r=Dylan-DPCbors-1/+1
Rollup of 6 pull requests Successful merges: - #96868 (Stabilize explicit_generic_args_with_impl_trait) - #97703 (some additional `need_type_info.rs` cleanup) - #97812 (Suggest to swap a struct and a trait in trait impls) - #97958 (ExitStatus docs fixups) - #97967 (Mention `infer::Trace` methods on `infer::At` methods' docs) - #97972 (Update #[doc(html_playground_url)] documentation to mention what the request will be) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-06-11Rollup merge of #97812 - TaKO8Ki:suggest-to-swap-struct-and-trait, r=estebankDylan DPC-1/+1
Suggest to swap a struct and a trait in trait impls closes #89590
2022-06-10Revert b983e42936feab29f6333e9835913afc6b4a394e.Nicholas Nethercote-2/+2
2022-06-08Rename `rustc_serialize::opaque::Encoder` as `MemEncoder`.Nicholas Nethercote-2/+2
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports).
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-28/+24
There are two impls of the `Encoder` trait: `opaque::Encoder` and `opaque::FileEncoder`. The former encodes into memory and is infallible, the latter writes to file and is fallible. Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a bit verbose and has non-trivial cost, which is annoying given how rare failures are (especially in the infallible `opaque::Encoder` case). This commit changes how `Encoder` fallibility is handled. All the `emit_*` methods are now infallible. `opaque::Encoder` requires no great changes for this. `opaque::FileEncoder` now implements a delayed error handling strategy. If a failure occurs, it records this via the `res` field, and all subsequent encoding operations are skipped if `res` indicates an error has occurred. Once encoding is complete, the new `finish` method is called, which returns a `Result`. In other words, there is now a single `Result`-producing method instead of many of them. This has very little effect on how any file errors are reported if `opaque::FileEncoder` has any failures. Much of this commit is boring mechanical changes, removing `Result` return values and `?` or `unwrap` from expressions. The more interesting parts are as follows. - serialize.rs: The `Encoder` trait gains an `Ok` associated type. The `into_inner` method is changed into `finish`, which returns `Result<Vec<u8>, !>`. - opaque.rs: The `FileEncoder` adopts the delayed error handling strategy. Its `Ok` type is a `usize`, returning the number of bytes written, replacing previous uses of `FileEncoder::position`. - Various methods that take an encoder now consume it, rather than being passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-06-07suggest swapping a struct and a traitTakayuki Maeda-1/+1
fmt
2022-06-03Fully stabilize NLLJack Huey-1/+0
2022-06-03Inline many methods of Encoderbjorn3-80/+76
They aren't overridden anyway
2022-06-03Remove all names from Encoderbjorn3-22/+21
They aren't used anymore now that the json format has been removed
2022-06-02Address review comments.Nicholas Nethercote-38/+60
2022-06-01Lazify `SourceFile::lines`.Nicholas Nethercote-93/+170
`SourceFile::lines` is a big part of metadata. It's stored in a compressed form (a difference list) to save disk space. Decoding it is a big fraction of compile time for very small crates/programs. This commit introduces a new type `SourceFileLines` which has a `Lines` form and a `Diffs` form. The latter is used when the metadata is first read, and it is only decoded into the `Lines` form when line data is actually needed. This avoids the decoding cost for many files, especially in `std`. It's a performance win of up to 15% for tiny crates/programs where metadata decoding is a high part of compilation costs. A `Lock` is needed because the methods that access lines data (which can trigger decoding) take `&self` rather than `&mut self`. To allow for this, `SourceFile::lines` now takes a `FnMut` that operates on the lines slice rather than returning the lines slice.
2022-05-29Rollup merge of #97028 - ridwanabdillahi:pretty-printer, r=michaelwoeristerGuillaume Gomez-0/+1
Add support for embedding pretty printers via `#[debugger_visualizer]` attribute Initial support for [RFC 3191](https://github.com/rust-lang/rfcs/pull/3191) in PR https://github.com/rust-lang/rust/pull/91779 was scoped to supporting embedding NatVis files using a new attribute. This PR implements the pretty printer support as stated in the RFC mentioned above. This change includes embedding pretty printers in the `.debug_gdb_scripts` just as the pretty printers for rustc are embedded today. Also added additional tests for embedded pretty printers. Additionally cleaned up error checking so all error checking is done up front regardless of the current target. RFC: https://github.com/rust-lang/rfcs/pull/3191
2022-05-26Augment a comment.Nicholas Nethercote-1/+3
2022-05-24Add support for embedding pretty printers via the `#[debugger_visualizer]` ↵ridwanabdillahi-0/+1
attribute. Add tests for embedding pretty printers and update documentation. Ensure all error checking for `#[debugger_visualizer]` is done up front and not when the `debugger_visualizer` query is run. Clean up potential ODR violations when embedding pretty printers into the `__rustc_debug_gdb_scripts_section__` section. Respond to PR comments and update documentation.
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-1/+0
2022-05-18Properly apply path prefix remapping paths emitted into debuginfo.Michael Woerister-3/+3
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