about summary refs log tree commit diff
path: root/compiler/rustc_macros/src/serialize.rs
AgeCommit message (Collapse)AuthorLines
2025-04-23Remove `synstructure::Structure::underscore_const` calls.Nicholas Nethercote-11/+1
The `synstructure` docs say "This method is a no-op, underscore consts are used by default now." The behaviour change occurred going from `synstructure` version 0.13.0 to 0.13.1.
2025-03-15Move codec module back into middleMichael Goulet-18/+8
2025-03-15Use {Decodable,Encodable}_NoContext in type_irMichael Goulet-6/+6
2025-02-08Rustfmtbjorn3-14/+20
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-20/+14
2024-08-29Add `warn(unreachable_pub)` to `rustc_metadata`.Nicholas Nethercote-6/+18
2024-08-29Add `warn(unreachable_pub)` to `rustc_macros`.Nicholas Nethercote-8/+8
2024-05-22Fix up whitespace in `compiler/rustc_macros/src/serialize.rs`.Nicholas Nethercote-8/+8
2024-02-17Make synstructure underscore_const(true) the defaultUrgau-1/+11
since otherwise it will trigger the non_local_definitions lint
2024-01-09u8 tags for smaller enumsMark Rousskov-6/+24
100% of the serialized enums during libcore compilation fit into the smaller tag, and this eliminates hitting the leb128 code for coding/decoding when we can statically guarantee that's not required. 30% of all leb128 integers serialized in libcore (12981183 total) come from the usize's removed here.
2023-12-31Avoid specialization for the Span Encodable and Decodable implsbjorn3-0/+16
2023-11-04Derive TyEncodable/TyDecodable implementations that are parameterized over ↵Michael Goulet-10/+20
interner
2023-08-18Make enum decoding errors more informative.Nicholas Nethercote-2/+2
By printing the actual value, as long as the expected range. I found this helpful when I encountered one of these errors.
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-1/+1
2023-02-25Emit the enum discriminant separately for the Encodable macroJohn Kåre Alsaker-17/+30
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-15/+7
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-14/+8
They aren't overridden anyway
2022-06-03Remove all names from Encoderbjorn3-22/+2
They aren't used anymore now that the json format has been removed
2022-05-28Make TyCtxt implement Interner, make HashStable generic and move to ↵Michael Goulet-2/+2
rustc_type_ir
2022-05-28Move things to rustc_type_irWilco Kusee-2/+2
2022-02-20Delete Decoder::read_enum_variantMark Rousskov-8/+4
2022-02-20Delete Decoder::read_struct_fieldMark Rousskov-19/+6
2022-02-20Delete Decoder::read_structMark Rousskov-9/+1
2022-02-20Delete read_enum_variant_argMark Rousskov-11/+12
2022-02-20Delete read_enum_variant namesMark Rousskov-8/+0
2022-02-20Delete Decoder::read_enumMark Rousskov-13/+8
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-13/+5
`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-16Use field span in `rustc_macros` when emitting decode callAaron Hill-11/+15
This will cause backtraces to point to the location of the field in the struct/enum, rather than the derive macro. This makes it clear which field was being decoded when the backtrace was captured (which is especially useful if there are multiple fields with the same type).
2021-11-22Avoid generating empty closures for fieldless enumsMark Rousskov-7/+18
For many enums, this avoids generating lots of tiny stubs that need to be codegen'd and then inlined and removed by LLVM.
2021-06-01Remove unused functions and arguments from rustc_serializebjorn3-10/+8
2021-01-01rustc_serialize: specialize opaque encoding of some u8 sequencesTyson Nottingham-2/+2
2020-08-30mv compiler to compiler/mark-0/+290