summary refs log tree commit diff
path: root/compiler/rustc_span/src/lib.rs
AgeCommit message (Collapse)AuthorLines
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
2021-07-13Cache expansion hash.Camille GILLOT-8/+2
2021-07-13Move HashStable implementations.Camille GILLOT-60/+1
2021-07-10rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`Vadim Petrochenkov-4/+1
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
2021-07-08Inline implementation of lookup_lineTomasz Miąsko-16/+4
to simplify the implementation and avoid unnecessary conversions from `Option<usize>` to `isize` and back.
2021-07-08Rework SESSION_GLOBALS API to prevent overwriting itGuillaume Gomez-7/+53
2021-07-06Revert "Revert "Merge CrateDisambiguator into StableCrateId""bjorn3-2/+0
This reverts commit 8176ab8bc18fdd7d3c2cf7f720c51166364c33a3.
2021-06-11Hash DefId in rustc_span.Camille GILLOT-3/+2
2021-06-07Auto merge of #85903 - bjorn3:rustc_serialize_cleanup, r=varkorbors-33/+35
Remove unused functions and arguments from rustc_serialize
2021-06-07Revert "Merge CrateDisambiguator into StableCrateId"bjorn3-0/+2
This reverts commit d0ec85d3fb6d322496cb8f4bc1c21e19f23284ad.
2021-06-01Remove unused functions and arguments from rustc_serializebjorn3-33/+35
2021-05-31Remove unused feature gatesbjorn3-1/+0
2021-05-31Use allow_internal_unstable more in rustc_indexbjorn3-1/+0
2021-05-30Merge CrateDisambiguator into StableCrateIdbjorn3-2/+0
2021-05-26Specialize implementationsJacob Pratt-0/+1
Implementations in stdlib are now optimized as they were before.
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-55/+121
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation