about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/codec.rs
AgeCommit message (Collapse)AuthorLines
2022-02-22Delete Decoder::read_unitMark Rousskov-2/+0
2022-02-22Provide copy-free access to raw Decoder bytesMark Rousskov-3/+3
2022-02-15Overhaul `Const`.Nicholas Nethercote-2/+8
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-02-15Overhaul `RegionKind` and `Region`.Nicholas Nethercote-1/+6
Specifically, change `Region` from this: ``` pub type Region<'tcx> = &'tcx RegionKind; ``` to this: ``` pub struct Region<'tcx>(&'tcx Interned<RegionKind>); ``` This now matches `Ty` and `Predicate` more closely. Things to note - Regions have always been interned, but we haven't been using pointer-based `Eq` and `Hash`. This is now happening. - I chose to impl `Deref` for `Region` because it makes pattern matching a lot nicer, and `Region` can be viewed as just a smart wrapper for `RegionKind`. - Various methods are moved from `RegionKind` to `Region`. - There is a lot of tedious sigil changes. - A couple of types like `HighlightBuilder`, `RegionHighlightMode` now have a `'tcx` lifetime because they hold a `Ty<'tcx>`, so they can call `mk_region`. - A couple of test outputs change slightly, I'm not sure why, but the new outputs are a little better.
2022-02-09Ensure that queries only return Copy types.Camille GILLOT-0/+3
2022-01-22Address review comments.Nicholas Nethercote-1/+1
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-96/+84
`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-22Rename `Decoder::read_nil` and `read_unit`.Nicholas Nethercote-1/+1
Because `()` is called "unit" and it makes it match `Encoder::emit_unit`.
2021-12-20Auto merge of #91924 - Aaron1011:serialize-adt-def, r=michaelwoeristerbors-10/+4
Fully serialize AdtDef This avoids needing to invoke the `adt_def` query during the decoding of another query's result. Split out from https://github.com/rust-lang/rust/pull/91919 See https://github.com/rust-lang/rust/issues/91696#issuecomment-993043710
2021-12-15Run x.py fmtAaron Hill-1/+5
2021-12-15Remove `in_band_lifetimes` from `rustc_middle`Aaron Hill-1/+1
See #91867 This was mostly straightforward. In several places, I take advantage of the fact that lifetimes are non-hygenic: a macro declares the 'tcx' lifetime, which is then used in types passed in as macro arguments.
2021-12-15Cache adt_def query result on diskAaron Hill-2/+4
2021-12-15Fully serialize AdtDefAaron Hill-8/+0
This avoids needing to invoke the `adt_def` query during the decoding of another query's result.
2021-11-17Remove unnecessary lifetime argument from arena macros.Nicholas Nethercote-9/+9
Because it's always `'tcx`. In fact, some of them use a mixture of passed-in `$tcx` and hard-coded `'tcx`, so no other lifetime would even work. This makes the code easier to read.
2021-10-02Turn a module non-doc comment into a doc commentbjorn3-7/+7
2021-09-09rename mir -> thir around abstract constsEllen-2/+3
2021-08-30Remove unused arena macro argsbjorn3-3/+3
2021-08-22Fix typos “an”→“a” and a few different ones that appeared in the ↵Frank Steffahn-2/+2
same search
2021-07-25clippy::needless_question_markMatthias Krüger-1/+1
2021-06-09Encode CrateNum using the StableCrateId for incr. comp.Camille GILLOT-3/+1
2021-03-31Track bound varsJack Huey-11/+26
2021-03-31Add tcx lifetime to BinderJack Huey-7/+7
2021-03-27Remove (lots of) dead codeJoshua Nelson-2/+2
Found with https://github.com/est31/warnalyzer. Dubious changes: - Is anyone else using rustc_apfloat? I feel weird completely deleting x87 support. - Maybe some of the dead code in rustc_data_structures, in case someone wants to use it in the future? - Don't change rustc_serialize I plan to scrap most of the json module in the near future (see https://github.com/rust-lang/compiler-team/issues/418) and fixing the tests needed more work than I expected. TODO: check if any of the comments on the deleted code should be kept.
2021-03-25Allow for reading raw bytes from rustc_serialize::Decoder without unsafe code.Michael Woerister-2/+2
2021-03-19Move raw bytes handling to Encoder/Decoder.Camille GILLOT-0/+5
2021-03-12Intern valtree field vectorOli Scherer-0/+10
2021-02-17remove useless ?s (clippy::needless_question_marks)Matthias Krüger-5/+3
Example code: ``` fn opts() -> Option<String> { let s: Option<String> = Some(String::new()); Some(s?) // this can just be "s" } ```
2021-01-18Rollup merge of #81100 - lcnr:encode_with_shorthand, r=oli-obkAshley Mannix-3/+3
prevent potential bug in `encode_with_shorthand`. see https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Remove.20PredicateKind.20in.20favor.20of.20only.20Bin.E2.80.A6.20compiler-team.23397/near/223012169
2021-01-17Don't derive TyEncodable/TyDecodable for BinderJack Huey-8/+33
2021-01-17Impl EncodableWithShorthand for PredicateKindJack Huey-0/+31
2021-01-16Can't use EncodableWithShorthand for PredicateJack Huey-19/+2
2021-01-16Review changesJack Huey-4/+4
2021-01-16CleanupJack Huey-1/+1
2021-01-16Remove PredicateKindJack Huey-4/+4
2021-01-17prevent potential bug in `encode_with_shorthand`.Bastian Kauschke-3/+3
2021-01-11Serialize incr comp structures to file via fixed-size bufferTyson Nottingham-16/+0
Reduce a large memory spike that happens during serialization by writing the incr comp structures to file by way of a fixed-size buffer, rather than an unbounded vector. Effort was made to keep the instruction count close to that of the previous implementation. However, buffered writing to a file inherently has more overhead than writing to a vector, because each write may result in a handleable error. To reduce this overhead, arrangements are made so that each LEB128-encoded integer can be written to the buffer with only one capacity and error check. Higher-level optimizations in which entire composite structures can be written with one capacity and error check are possible, but would require much more work. The performance is mostly on par with the previous implementation, with small to moderate instruction count regressions. The memory reduction is significant, however, so it seems like a worth-while trade-off.
2020-12-17Auto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakisbors-3/+7
Move binder for dyn to each list item This essentially changes `ty::Binder<&'tcx List<ExistentialTraitRef>>` to `&'tcx List<ty::Binder<ExistentialTraitRef>>`. This is a first step in moving the `dyn Trait` representation closer to Chalk, which we've talked about in `@rust-lang/wg-traits.` r? `@nikomatsakis`
2020-12-14Remove unused `TyEncoder::tcx` required methodLeSeulArtichaut-1/+0
2020-12-11Move binder for dyn to each list itemJack Huey-3/+7
2020-12-03Combination of commitsRich Kadel-2/+4
Fixes multiple issue with counters, with simplification Includes a change to the implicit else span in ast_lowering, so coverage of the implicit else no longer spans the `then` block. Adds coverage for unused closures and async function bodies. Fixes: #78542 Adding unreachable regions for known MIR missing from coverage map Cleaned up PR commits, and removed link-dead-code requirement and tests Coverage no longer depends on Issue #76038 (`-C link-dead-code` is no longer needed or enforced, so MSVC can use the same tests as Linux and MacOS now) Restrict adding unreachable regions to covered files Improved the code that adds coverage for uncalled functions (with MIR but not-codegenned) to avoid generating coverage in files not already included in the files with covered functions. Resolved last known issue requiring --emit llvm-ir workaround Fixed bugs in how unreachable code spans were added.
2020-11-12Add type to `ConstKind::Placeholder`varkor-1/+1
2020-10-14Remove unused code from rustc_middleest31-8/+0
2020-09-18support const_evaluatable_checked across crate boundariesBastian Kauschke-0/+20
2020-09-04Change ty.kind to a methodLeSeulArtichaut-1/+3
2020-08-30mv compiler to compiler/mark-0/+456