about summary refs log tree commit diff
path: root/compiler/rustc_serialize
AgeCommit message (Collapse)AuthorLines
2022-08-21Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcmMatthias Krüger-1/+1
Replace most uses of `pointer::offset` with `add` and `sub` As PR title says, it replaces `pointer::offset` in compiler and standard library with `pointer::add` and `pointer::sub`. This generally makes code cleaner, easier to grasp and removes (or, well, hides) integer casts. This is generally trivially correct, `.offset(-constant)` is just `.sub(constant)`, `.offset(usized as isize)` is just `.add(usized)`, etc. However in some cases we need to be careful with signs of things. r? ````@scottmcm```` _split off from #100746_
2022-08-21Replace most uses of `pointer::offset` with `add` and `sub`Maybe Waffle-1/+1
2022-08-18Add diagnostic translation lints to crates that don't emit them5225225-0/+2
2022-07-17Upgrade indexmap and thorin-dwp to use hashbrown 0.12Josh Stone-1/+1
This removes the last dependencies on hashbrown 0.11.
2022-07-02use BufReader for counting zero bytesYoshiki Matsuda-0/+4
2022-06-27Update `smallvec` to 1.8.1.Nicholas Nethercote-1/+1
This pulls in https://github.com/servo/rust-smallvec/pull/282, which gives some small wins for rustc.
2022-06-16Move `finish` out of the `Encoder` trait.Nicholas Nethercote-28/+16
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-14Rename rustc_serialize::opaque::Encoder as MemEncoder.Nicholas Nethercote-30/+32
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports). (This was previously merged as commit 5 in #94732 and then was reverted in #97905 because of a perf regression caused by commit 4 in #94732.)
2022-06-10Revert dc08bc51f2c58a0f5f815a07f9bb3d671153b5a1.Nicholas Nethercote-16/+28
2022-06-10Revert b983e42936feab29f6333e9835913afc6b4a394e.Nicholas Nethercote-32/+30
2022-06-08Rename `rustc_serialize::opaque::Encoder` as `MemEncoder`.Nicholas Nethercote-30/+32
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports).
2022-06-08Move `finish` out of the `Encoder` trait.Nicholas Nethercote-28/+16
This simplifies things, but requires making `CacheEncoder` non-generic.
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-228/+249
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-08Don't pass in a vector to `Encoder::new`.Nicholas Nethercote-3/+3
It's not necessary.
2022-06-03Fully stabilize NLLJack Huey-1/+0
2022-06-03Remove emit_unitbjorn3-15/+4
It doesn't do anything for all encoders
2022-06-03Inline many methods of Encoderbjorn3-178/+59
They aren't overridden anyway
2022-06-03Remove all names from Encoderbjorn3-60/+33
They aren't used anymore now that the json format has been removed
2022-06-03Remove json support from rustc_serializebjorn3-3495/+0
2022-05-13Cache more queries on disk.Camille GILLOT-16/+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-04-03Replace every Vec in Target(Options) with it's Cow equivalentLoïc BRANSTETT-0/+9
2022-04-03Replace every `String` in Target(Options) with `Cow<'static, str>`Loïc BRANSTETT-0/+7
2022-02-22Delete Decoder::read_unitMark Rousskov-11/+2
2022-02-22Provide copy-free access to raw Decoder bytesMark Rousskov-14/+7
2022-02-22Provide raw &str access from DecoderMark Rousskov-5/+4
2022-02-20Delete Decoder::read_mapMark Rousskov-37/+26
2022-02-20Delete Decoder::read_seqMark Rousskov-54/+44
2022-02-20Delete Decoder::read_enum_variantMark Rousskov-14/+5
2022-02-20Delete Decoder::read_map_elt_valMark Rousskov-11/+3
2022-02-20Delete Decoder::read_map_elt_keyMark Rousskov-11/+3
2022-02-20Delete Decoder::read_optionMark Rousskov-13/+5
2022-02-20Delete Decoder::read_seq_eltMark Rousskov-19/+8
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
2022-02-20Delete Decoder::read_structMark Rousskov-8/+0
2022-02-20Delete read_enum_variant_argMark Rousskov-10/+2
2022-02-20Delete read_enum_variant namesMark Rousskov-3/+3
2022-02-20Delete Decoder::read_enumMark Rousskov-21/+8
2022-02-20Remove support for JSON deserialization to RustMark Rousskov-617/+15
This is no longer used by the compiler itself, and removing this support opens the door to massively simplifying the Decodable/Decoder API by dropping the self-describing deserialization support (necessary for JSON).
2022-02-19Adopt let else in more placesest31-3/+3
2022-02-05Drop json::from_readerMark Rousskov-22/+0
Performing UTF-8 decode outside the JSON module makes more sense in almost all cases.
2022-01-31Remove two unnecessary transmutes from opaque Encoder and Decoderbjorn3-4/+3
2022-01-24Auto merge of #90842 - pierwill:localdefid-indexmap, r=wesleywiserbors-1/+1
Use `indexmap` to avoid sorting `LocalDefId`s See discussion in https://github.com/rust-lang/rust/pull/90408#discussion_r745935459. Related to work on https://github.com/rust-lang/rust/issues/90317.
2022-01-22Use an `indexmap` to avoid sorting `LocalDefId`spierwill-1/+1
Update `indexmap` to 1.8.0. Bless test
2022-01-22Address review comments.Nicholas Nethercote-3/+1
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-410/+379
`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.