about summary refs log tree commit diff
path: root/compiler/rustc_span/src/def_id.rs
AgeCommit message (Collapse)AuthorLines
2023-11-28Remove a comment.Nicholas Nethercote-1/+0
It was merged by accident in a previous PR.
2023-11-22Replace `no_ord_impl` with `orderable`.Nicholas Nethercote-0/+2
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-22Replace `custom_encodable` with `encodable`.Nicholas Nethercote-2/+1
By default, `newtype_index!` types get a default `Encodable`/`Decodable` impl. You can opt out of this with `custom_encodable`. Opting out is the opposite to how Rust normally works with autogenerated (derived) impls. This commit inverts the behaviour, replacing `custom_encodable` with `encodable` which opts into the default `Encodable`/`Decodable` impl. Only 23 of the 59 `newtype_index!` occurrences need `encodable`. Even better, there were eight crates with a dependency on `rustc_serialize` just from unused default `Encodable`/`Decodable` impls. This commit removes that dependency from those eight crates.
2023-08-14Use `{Local}ModDefId` in many queriesNilstrieb-1/+1
2023-08-13Add typed `{Local}DefId` for modulesNilstrieb-0/+95
This allows for better type safety in the compiler and also improves the documentation for many things, making it clear that they expect modules.
2023-05-17Only depend on CFG_VERSION in rustc_interfacejyn-2/+7
this avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-18Add #[inline] to some new functionsBen Kimock-0/+1
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-20/+18
2023-03-21Eagerly intern and check CrateNum/StableCrateId collisionsOli Scherer-1/+5
2023-03-03Match unmatched backticks in comments in compiler/est31-1/+1
2023-02-16Replace some `then`s with some `then_some`sMaybe Waffle-1/+1
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-2/+2
2023-02-05rustc_metadata: Encode/decode `DefPathHash`es without an `Option`Vadim Petrochenkov-0/+6
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-1/+1
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-12-18A few small cleanups for `newtype_index`Nilstrieb-3/+2
Remove the `..` from the body, only a few invocations used it and it's inconsistent with rust syntax. Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18Make `#[debug_format]` an attribute in `newtype_index`Nilstrieb-2/+2
This removes the `custom` format functionality as its only user was trivially migrated to using a normal format. If a new use case for a custom formatting impl pops up, you can add it back.
2022-12-18Make `#[custom_encodable]` an attribute for `newtype_index`Nilstrieb-3/+2
Makes the syntax a little more rusty.
2022-12-08Rollup merge of #105423 - oli-obk:symbols, r=jackh726Matthias Krüger-3/+5
Use `Symbol` for the crate name instead of `String`/`str` It always got converted to a symbol anyway
2022-12-07Use `Symbol` for the crate name instead of `String`/`str`Oli Scherer-3/+5
2022-12-06Cleanup macro-expanded code in `rustc_type_ir`Maybe Waffle-1/+1
2022-11-25Prefer not accessing the private field of newtype_index typesOli Scherer-1/+1
2022-09-27Manually order `DefId` on 64-bit big-endianJosh Stone-1/+19
`DefId` uses different field orders on 64-bit big-endian vs. others, in order to optimize its `Hash` implementation. However, that also made it derive different lexical ordering for `PartialOrd` and `Ord`. That caused spurious differences wherever `DefId`s are sorted, like the candidate sources list in `report_method_error`. Now we manually implement `PartialOrd` and `Ord` on 64-bit big-endian to match the same lexical ordering as other targets, fixing at least one test, `src/test/ui/methods/method-ambig-two-traits-cross-crate.rs`.
2022-09-10rustc_error, rustc_private, rustc_ast: Switch to stable hash containersNiklas Jonsson-2/+7
2022-09-07rustc: Parameterize `ty::Visibility` over used IDVadim Petrochenkov-0/+6
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-8/+8
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-03Inline many methods of Encoderbjorn3-5/+2
They aren't overridden anyway
2022-06-03Remove all names from Encoderbjorn3-3/+3
They aren't used anymore now that the json format has been removed
2022-05-07Remove closures on `expect_local` to apply `#[track_caller]`Yuki Okushi-1/+6
2022-05-06Add `track_caller` to `DefId::expect_local()`Yuki Okushi-0/+1
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-2/+13
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-03-08add `#[rustc_pass_by_value]` to more typeslcnr-2/+3
2022-02-20Delete Decoder::read_struct_fieldMark Rousskov-4/+1
2022-02-20Delete Decoder::read_structMark Rousskov-2/+2
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-11/+9
`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-12Rename environment variable for overriding rustc versionpierwill-2/+2
2022-01-11Auto merge of #92012 - llogiq:repr-c-def-id, r=michaelwoeristerbors-1/+8
Make `DefId` `repr(C)`, optimize big-endian field order r? `@michaelwoerister`
2022-01-07Fix typo in `StableCrateId` docspierwill-2/+2
2022-01-04Make `DefId` `repr(C)`, optimize big-endian field orderAndre Bogus-1/+8
2021-12-30Add negative `impl` for `Ord`, `PartialOrd` on `LocalDefId`pierwill-5/+11
Add comment about why `LocalDefId` should not be `Ord` Also fix some formatting in the doc comment.
2021-12-22Remove `PartialOrd` and `Ord` from `LocalDefId`pierwill-1/+1
Implement `Ord`, `PartialOrd` for SpanData
2021-12-16Auto merge of #89836 - pierwill:fix-85142-crate-hash, r=wesleywiserbors-6/+21
Include rustc version in `rustc_span::StableCrateId` `rustc_span::def_id::StableCrateId` is a hash of various data about a crate during compilation. This PR includes the version of `rustc` in the input when computing this hash. From a cursory reading of [RFC 2603](https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html), this appears to be acceptable within that design. In order to pass the `mir-opt` and `ui` test suites, this adds new [normalization for hashes and symbol names in `compiletest`](https://github.com/rust-lang/rust/pull/89836/files#diff-03a0567fa80ca04ed5a55f9ac5c711b4f84659be2d0ac4a984196d581c04f76b). These are enabled by default, but we might prefer it to be configurable. In the UI tests, I had to truncate a significant amount of error annotations in v0 symbols (and maybe some legacy) in order to get the normalization to work correctly. (See https://github.com/rust-lang/rust/issues/90116.) Closes #85142.
2021-12-13Add run-make-fulldeps testpierwill-5/+14
Implement RUSTC_FORCE_INCR_COMP_ARTIFACT_HEADER Also makes minor docs edits.
2021-12-13Include rustc version in `rustc_span::StableCrateId`pierwill-5/+11
Normalize symbol hashes in compiletest. Remove DefId sorting
2021-12-10manually implement `Hash` for `DefId`Andre Bogus-5/+31
This also reorders the fields to reduce the assembly operations for hashing and changes two UI tests that depended on the former ordering because of hashmap iteration order.
2021-07-17Encode ExpnId using ExpnHash for incr. comp.Camille GILLOT-1/+1
2021-07-06Revert "Revert "Merge CrateDisambiguator into StableCrateId""bjorn3-8/+32
This reverts commit 8176ab8bc18fdd7d3c2cf7f720c51166364c33a3.
2021-06-11Sprinkle inline.Camille GILLOT-5/+6
2021-06-11Hash DefId in rustc_span.Camille GILLOT-3/+38
2021-06-07Auto merge of #85903 - bjorn3:rustc_serialize_cleanup, r=varkorbors-6/+6
Remove unused functions and arguments from rustc_serialize