about summary refs log tree commit diff
path: root/compiler/rustc_index/src/vec.rs
AgeCommit message (Collapse)AuthorLines
2025-02-28Allow the optimizer to elide bounds checks when enumerating ↵Jason Newcomb-0/+4
`IndexSlice`/`IndecVec`.
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-2/+2
2024-08-13Add and use `IndexVec::append`Josh Stone-0/+5
2024-07-29Reformat `use` declarations.Nicholas Nethercote-6/+4
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-15Fix feature gating on rustc_index to not use implicit featuresMichael Goulet-3/+3
2024-07-04Use `IndexVec` for coroutine local mappingLiu Dingming-0/+5
2024-03-06doc: Add better explanationorion GONZALEZ (contractor)-1/+18
2024-01-26Update compiler/rustc_index/src/vec.rsArdi-0/+1
Co-authored-by: Wesley Wiser <wwiser@gmail.com>
2024-01-10Fix some mistakes + new docardi-6/+5
2024-01-10Oh wellardi-15/+3
2024-01-10Document the struct and a few methodsardi-0/+19
2023-11-13Remove `IndexSlice::convert_index_type`.Nicholas Nethercote-4/+0
2023-04-24Decorative changes to `IndexVec`Maybe Waffle-13/+12
2023-04-24`const`-ify some `{IndexVec, IndexSlice}` methodsMaybe Waffle-2/+2
2023-04-24move index code aroundMaybe Waffle-65/+65
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-291/+3
2023-04-18Don't allocate it `IndexVec::remove`Maybe Waffle-1/+1
2023-04-17Make `IndexVec::ensure_contains_elem` return a reference to the elementMaybe Waffle-7/+8
2023-04-09Fix some clippy::complexityNilstrieb-7/+4
2023-04-06Auto merge of #109915 - scottmcm:layout-indexvec, r=oli-obkbors-0/+43
Use `FieldIdx` in `FieldsShape` Finally got to the main motivating example from https://github.com/rust-lang/compiler-team/issues/606 :)
2023-04-04Use `FieldIdx` in `FieldsShape`Scott McMurray-0/+43
Finally got to the main motivating example from the MCP :)
2023-04-03Doc-comment `IndexVec::from_elem` and use it in a few more placesScott McMurray-0/+11
2023-04-02Use `&IndexSlice` instead of `&IndexVec` where possibleScott McMurray-2/+40
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
2023-04-01Use `FieldIdx` in various things related to aggregatesScott McMurray-0/+6
Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
2023-03-30Add `IndexSlice` to go with `IndexVec`Scott McMurray-70/+160
Moves the methods that don't need full `IndexVec`-ness over to `IndexSlice`, and have `IndexVec` deref to `IndexSlice` so everything keeps working.
2023-03-29Rename `IndexVec::last` → `last_index`Scott McMurray-1/+1
As I've been trying to replace a `Vec` with an `IndexVec`, having `last` exist on both but returning very different types makes the transition a bit awkward -- the errors are later, where you get things like "there's no `ty` method on `mir::Field`" rather than a more localized error like "hey, there's no `last` on `IndexVec`". So I propose renaming `last` to `last_index` to help distinguish `Vec::last`, which returns an element, and `IndexVec::last_index`, which returns an index. (Similarly, `Iterator::last` also returns an element, not an index.)
2023-01-19Fix IndexVec::drain_enumeratedMichael Goulet-1/+6
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-1/+0
2022-11-24make rustc_target usable outside of rustchkalbasi-0/+5
2022-11-01Implement Idx for OwnerId.Camille GILLOT-0/+2
2022-08-12debuginfo: Change C++-like encoding for enums.Michael Woerister-1/+3
The updated encoding should be able to handle niche layouts where more than one variant has fields.
2022-07-21Edit `rustc_index::vec::IndexVec::pick3_mut` docspierwill-2/+6
Clarify when this method will panic. Also fix formatting for `pick2_mut`.
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-2/+2
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-05-13Cache more queries on disk.Camille GILLOT-6/+0
2022-02-24Convert `newtype_index` to a proc macroAaron Hill-455/+0
The `macro_rules!` implementation was becomng excessively complicated, and difficult to modify. The new proc macro implementation should make it much easier to add new features (e.g. skipping certain `#[derive]`s)
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-4/+4
`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.
2021-12-22Remove `PartialOrd` and `Ord` from `LocalDefId`pierwill-1/+1
Implement `Ord`, `PartialOrd` for SpanData
2021-11-13Generate documentation in rustc `rustc_index::newtype_index` macropierwill-1/+23
The macro now documents all generated items. Documentation notes possible panics and unsafety.
2021-10-23update cfg(bootstrap)Pietro Albini-6/+0
2021-10-15Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, ↵Matthias Krüger-4/+7
r=petrochenkov" The PR had some unforseen perf regressions that are not as easy to find. Revert the PR for now. This reverts commit 6ae8912a3e7d2c4c775024f58a7ba4b1aedc4073, reversing changes made to 86d6d2b7389fe1b339402c1798edae8b695fc9ef.
2021-10-11Rollup merge of #89643 - cjgillot:overlap, r=matthewjasperMatthias Krüger-0/+6
Fix inherent impl overlap check. The current implementation of the overlap check was slightly buggy, and unified the wrong connected component in the `ids.len() <= 1` case. This became visible in another PR which changed the iteration order of items. r? ``@matthewjasper`` since you reviewed the other PR.
2021-10-10Apply clippy suggestionsClemens Wasser-7/+4
2021-10-07Fix inherent impl overlap check.Camille GILLOT-0/+6
2021-10-04Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplettJubilee-2/+6
Stabilize `const_panic` Closes #51999 FCP completed in #89006 ```@rustbot``` label +A-const-eval +A-const-fn +T-lang cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04Stabilize `const_panic`Jacob Pratt-2/+6
2021-10-03Replace Fn impls with RPIT impls in rustc_indexbjorn3-44/+17
This is cleaner and removes an unstable feature usage
2021-09-22rustc_index: Add some map-like APIs to `IndexVec`Vadim Petrochenkov-0/+15
2021-05-31Use allow_internal_unstable more in rustc_indexbjorn3-1/+1
2021-05-26Unify feature flags as `step_trait`Jacob Pratt-1/+1
While stdlib implementations of the unchecked methods require unchecked math, there is no reason to gate it behind this for external users. The reasoning for a separate `step_trait_ext` feature is unclear, and as such has been merged as well.
2021-05-26Specialize implementationsJacob Pratt-0/+3
Implementations in stdlib are now optimized as they were before.