about summary refs log tree commit diff
path: root/compiler/rustc_serialize/src/serialize.rs
AgeCommit message (Collapse)AuthorLines
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-07-01Update `cfg(bootstrap)`Josh Stone-3/+3
2025-06-30Introduce `ByteSymbol`.Nicholas Nethercote-1/+23
It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once. The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`. `Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings. This change does slow down compilation of programs that use `include_bytes!` on large files, because the contents of those files are now interned (hashed). This makes `include_bytes!` more similar to `include_str!`, though `include_bytes!` contents still aren't escaped, and hashing is still much cheaper than escaping.
2025-06-16library/compiler: add `PointeeSized` boundsDavid Wood-2/+2
As core uses an extern type (`ptr::VTable`), the default `?Sized` to `MetaSized` migration isn't sufficient, and some code that previously accepted `VTable` needs relaxed to continue to accept extern types. Similarly, the compiler uses many extern types in `rustc_codegen_llvm` and in the `rustc_middle::ty::List` implementation (`OpaqueListContents`) some bounds must be relaxed to continue to accept these types. Unfortunately, due to the current inability to relax `Deref::Target`, some of the bounds in the standard library are forced to be stricter than they ideally would be.
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-0/+29
with rust-analyzer
2024-10-16Fix explicit_iter_loop in rustc_serializeMichal Piotrowski-8/+8
2024-10-08Fix needless_lifetimes in rustc_serializeMichal Piotrowski-3/+3
2024-07-29Reformat `use` declarations.Nicholas Nethercote-1/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-05-30Apply x clippy --fix and x fmtr0cky-1/+1
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-1/+1
2024-02-15Use generic `NonZero` internally.Markus Reiter-3/+4
2024-01-09Remove more needless leb128 coding for enum variantsMark Rousskov-18/+15
This removes emit_enum_variant and the emit_usize calls that resulted in. In libcore this eliminates 17% of leb128, taking us from 8964488 to 7383842 leb128's serialized.
2023-10-06Use `collect` to decode `Vec`.Nicholas Nethercote-23/+10
It's hyper-optimized, we don't need our own unsafe code here. This requires getting rid of all the `Allocator` stuff, which isn't needed anyway.
2023-10-06Streamline some `Encodable` impls.Nicholas Nethercote-6/+3
Making them consistent with similar impls.
2023-10-06Use `collect` for decoding more collection types.Nicholas Nethercote-40/+6
2023-10-06rustc_serialize: merge `collection_impls.rs` into `serialize.rs`.Nicholas Nethercote-0/+258
`serialize.rs` has the `Encodable`/`Decodable` impls for lots of basic types, including `Vec`. `collection_impls` has it for lots of collection types. The distinction isn't really meaningful, and it's simpler to have them all in a single file.
2023-05-04Reorder some `MemDecoder` methods.Nicholas Nethercote-2/+2
So they match the order in the `Decoder` trait.
2023-05-04Remove a low value comment.Nicholas Nethercote-4/+0
2023-04-28Add some provided methods to `Encoder`/`Decoder`.Nicholas Nethercote-8/+56
The methods for `i8`, `bool`, `char`, `str` are the same for all impls, because they layered on top of other methods.
2023-04-28Add a comment explaining the lack of `Decoder::read_enum_variant`.Nicholas Nethercote-0/+5
Because I was wondering about it, and this may save a future person from also wondering.
2023-04-23Rewrite MemDecoder around pointers not a sliceBen Kimock-0/+2
2023-04-06Remove f32 & f64 from MemDecoder/MemEncoderScott McMurray-6/+10
2023-02-25Emit the enum discriminant separately for the Encodable macroJohn Kåre Alsaker-12/+0
2023-02-20Remove old FIXME that no longer appliesDeadbeef-5/+0
it looks like Encodable was fallible at some point, but that was changed which means that this FIXME is no longer applicable
2022-08-25Adding support for rustc_serialize encode and decode for Box and Vec that ↵Ellen Arteca-11/+15
use a custom allocator
2022-08-21Replace most uses of `pointer::offset` with `add` and `sub`Maybe Waffle-1/+1
2022-06-16Move `finish` out of the `Encoder` trait.Nicholas Nethercote-9/+3
This simplifies things, but requires making `CacheEncoder` non-generic. (This was previously merged as commit 4 in #94732 and then was reverted in #97905 because it caused a perf regression.)
2022-06-10Revert dc08bc51f2c58a0f5f815a07f9bb3d671153b5a1.Nicholas Nethercote-3/+9
2022-06-08Move `finish` out of the `Encoder` trait.Nicholas Nethercote-9/+3
This simplifies things, but requires making `CacheEncoder` non-generic.
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-73/+83
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-03Remove emit_unitbjorn3-5/+4
It doesn't do anything for all encoders
2022-06-03Inline many methods of Encoderbjorn3-127/+16
They aren't overridden anyway
2022-06-03Remove all names from Encoderbjorn3-44/+17
They aren't used anymore now that the json format has been removed
2022-05-13Cache more queries on disk.Camille GILLOT-6/+9
2022-04-18Remove unused macro rulesest31-1/+0
2022-04-05errors: implement fallback diagnostic translationDavid Wood-0/+14
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-02-22Delete Decoder::read_unitMark Rousskov-6/+2
2022-02-22Provide copy-free access to raw Decoder bytesMark Rousskov-1/+1
2022-02-22Provide raw &str access from DecoderMark Rousskov-2/+2
2022-02-20Delete Decoder::read_mapMark Rousskov-8/+0
2022-02-20Delete Decoder::read_seqMark Rousskov-28/+18
2022-02-20Delete Decoder::read_enum_variantMark Rousskov-14/+5
2022-02-20Delete Decoder::read_map_elt_valMark Rousskov-8/+0
2022-02-20Delete Decoder::read_map_elt_keyMark Rousskov-8/+0
2022-02-20Delete Decoder::read_optionMark Rousskov-13/+5
2022-02-20Delete Decoder::read_seq_eltMark Rousskov-13/+2
2022-02-20Delete Decoder::read_tuple_argMark Rousskov-12/+1
2022-02-20Delete Decoder::read_tupleMark Rousskov-15/+3
2022-02-20Use count! macro in tuple length computationMark Rousskov-3/+2
2022-02-20Delete Decoder::read_struct_fieldMark Rousskov-8/+0