Commit Graph

73 Commits

Author SHA1 Message Date
David Wood a982f95a9e errors: implement fallback diagnostic translation
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-05 07:01:02 +01:00
Loïc BRANSTETT b8f49b28d4 Replace every Vec in Target(Options) with it's Cow equivalent 2022-04-03 21:29:57 +02:00
Loïc BRANSTETT df1bb91832 Replace every String in Target(Options) with Cow<'static, str> 2022-04-03 21:29:57 +02:00
Mark Rousskov 60a5b15a49 Delete Decoder::read_unit 2022-02-22 18:14:51 -05:00
Mark Rousskov 27ffce0072 Provide copy-free access to raw Decoder bytes 2022-02-22 18:11:59 -05:00
Mark Rousskov 8a211cf030 Provide raw &str access from Decoder 2022-02-22 18:05:51 -05:00
Mark Rousskov c38dd4c76e Delete Decoder::read_map 2022-02-20 18:58:23 -05:00
Mark Rousskov f849c067eb Delete Decoder::read_seq 2022-02-20 18:58:23 -05:00
Mark Rousskov 8670705d79 Delete Decoder::read_enum_variant 2022-02-20 18:58:23 -05:00
Mark Rousskov c14051b223 Delete Decoder::read_map_elt_val 2022-02-20 18:58:23 -05:00
Mark Rousskov 3dd769166d Delete Decoder::read_map_elt_key 2022-02-20 18:58:23 -05:00
Mark Rousskov 64713f1ed6 Delete Decoder::read_option 2022-02-20 18:58:23 -05:00
Mark Rousskov 370cb35c63 Delete Decoder::read_seq_elt 2022-02-20 18:58:22 -05:00
Mark Rousskov 8dffb20a08 Delete Decoder::read_tuple_arg 2022-02-20 18:58:22 -05:00
Mark Rousskov ccc6e5e38f Delete Decoder::read_tuple 2022-02-20 18:58:22 -05:00
Mark Rousskov a8e1914908 Use count! macro in tuple length computation 2022-02-20 18:58:22 -05:00
Mark Rousskov 68836a8cc8 Delete Decoder::read_struct_field 2022-02-20 18:58:22 -05:00
Mark Rousskov 61ecc6f0f6 Delete Decoder::read_struct 2022-02-20 18:58:22 -05:00
Mark Rousskov e711ac84d7 Delete read_enum_variant_arg 2022-02-20 18:58:22 -05:00
Mark Rousskov d57dd3b0d6 Delete read_enum_variant names 2022-02-20 18:58:22 -05:00
Mark Rousskov 83223a04a9 Delete Decoder::read_enum 2022-02-20 18:58:22 -05:00
Mark Rousskov 62e1ef2bc2 Remove support for JSON deserialization to Rust
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-20 18:58:21 -05:00
est31 3ceec03f0f Adopt let else in more places 2022-02-19 17:27:43 +01:00
Mark Rousskov 97c0a8d2c6 Drop json::from_reader
Performing UTF-8 decode outside the JSON module makes more sense in almost all cases.
2022-02-05 15:07:10 -05:00
bjorn3 d80f533a54 Remove two unnecessary transmutes from opaque Encoder and Decoder 2022-01-31 18:25:05 +01:00
bors ad283d0a18 Auto merge of #90842 - pierwill:localdefid-indexmap, r=wesleywiser
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-24 22:04:55 +00:00
pierwill 8bec6e4b5d Use an indexmap to avoid sorting LocalDefIds
Update `indexmap` to 1.8.0.

Bless test
2022-01-22 22:34:16 -06:00
Nicholas Nethercote 691f1163ef Address review comments. 2022-01-22 10:38:34 +11:00
Nicholas Nethercote 0eaf0ba783 Make Decodable and Decoder infallible.
`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-22 10:38:31 +11:00
Nicholas Nethercote 99d767a0ae Rename Decoder::read_nil and read_unit.
Because `()` is called "unit" and it makes it match
`Encoder::emit_unit`.
2022-01-22 10:22:24 +11:00
bors 22bd9627c8 Auto merge of #92604 - nnethercote:optimize-impl_read_unsigned_leb128, r=michaelwoerister
Optimize `impl_read_unsigned_leb128`

I see instruction count improvements of up to 3.5% locally with these changes, mostly on the smaller benchmarks.

r? `@michaelwoerister`
2022-01-15 07:27:30 +00:00
Nicholas Nethercote 766a378ce0 Unpeel the first iteration of the loop in impl_read_unsigned_leb128. 2022-01-07 13:36:26 +11:00
Nicholas Nethercote 7eb90a8336 Modify the buffer position directly when reading leb128 values.
It's a small but clear performance win.
2022-01-07 10:40:51 +11:00
Jakub Beránek 68f7a3fb7f Do not use LEB128 for encoding u16 and i16 2021-12-28 09:29:08 +01:00
bors a3f9d0c45f Auto merge of #91626 - klensy:json-less-alloc, r=petrochenkov
rustc_serialize: don't allocate `String`s as key for `BTreeMap`, when `str` is enough
2021-12-13 07:30:38 +00:00
klensy 2be16f0d3f don't allocate strings when str is enought for using as key 2021-12-07 12:54:35 +03:00
The 8472 1edb7ed7c9 avoid string validation in rustc_serialize, check a marker byte instead
since the serialization format isn't self-describing we need a way to detect
when encoder and decoder don't match up. but that doesn't have to
be utf8 validation for strings, which does cost a few % of performance.
Instead we can use a marker byte at the end to be reasonably
sure that we're dealing with a string and it wasn't overwritten in some
way.
2021-12-06 18:43:01 +01:00
Mark Rousskov a51dc27841 Avoid generating empty closures for fieldless enums
For many enums, this avoids generating lots of tiny stubs that need to be
codegen'd and then inlined and removed by LLVM.
2021-11-22 21:22:35 -05:00
Matthias Krüger 8fea779015 Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov"
The PR had some unforseen perf regressions that are not as easy to find.
Revert the PR for now.

This reverts commit f072bbde2e, reversing
changes made to d4e672d222.
2021-10-15 11:28:23 +02:00
Clemens Wasser 7284423f06 Apply clippy suggestions 2021-10-10 15:38:19 +02:00
Mark Rousskov f5a19f35c1 Migrate to 2021 2021-09-20 22:21:42 -04:00
Vadim Petrochenkov f5226fad80 rustc: Remove local variable IDs from Exports
Local variables can never be exported.
2021-09-10 23:41:48 +03:00
Frank Steffahn 36d1b13080 Fix more “a”/“an” typos 2021-08-22 16:35:29 +02:00
Frank Steffahn 54073448bd Fix typos “a”→“an” 2021-08-22 15:35:11 +02:00
est31 b39e3c6670 Remove box syntax from rustc_serialize 2021-08-18 09:25:26 +02:00
Jade c72215df19 rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
Adam Bratschi-Kaye 36dcbbd046 Emit warnings for unused fields in custom targets. 2021-06-17 21:48:02 +02:00
LeSeulArtichaut 94a5436865 Use the now available implementation of IntoIterator for arrays 2021-06-14 23:40:09 +02:00
bors 02946168cf Auto merge of #85903 - bjorn3:rustc_serialize_cleanup, r=varkor
Remove unused functions and arguments from rustc_serialize
2021-06-07 14:40:26 +00:00
bjorn3 3a118c890a Remove unused functions and arguments from rustc_serialize 2021-06-01 19:29:11 +02:00