about summary refs log tree commit diff
path: root/compiler/rustc_macros/src
AgeCommit message (Collapse)AuthorLines
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-02-16Move ty::print methods to Drop-based scope guardsMark Rousskov-1/+3
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.
2022-01-03Rollup merge of #92011 - Aaron1011:decode-span, r=michaelwoeristerMatthias Krüger-11/+15
Use field span in `rustc_macros` when emitting decode call 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-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-12-15Remove `in_band_lifetimes` from `rustc_middle`Aaron Hill-0/+5
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-12Query modifierDeadbeef-0/+20
2021-12-02Rename TypeFolderFallible to FallibleTypeFolderAlan Egerton-1/+1
2021-12-02Reduce boilerplate around infallible foldersAlan Egerton-2/+2
2021-11-26Make `TypeFoldable` implementors short-circuit on errorLeSeulArtichaut-3/+3
Co-authored-by: Alan Egerton <eggyal@gmail.com>
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-11-07more clippy fixesMatthias Krüger-5/+3
2021-10-25Avoid a branch on key being local for queries that use the same local and ↵bjorn3-0/+23
extern providers
2021-10-23Do not require QueryCtxt for cache_on_disk.Camille GILLOT-2/+2
2021-10-23Build the query vtable directly.Camille GILLOT-24/+18
2021-10-21Do not depend on the stored value when trying to cache on disk.Camille GILLOT-14/+4
2021-10-15Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, ↵Matthias Krüger-7/+9
r=petrochenkov" The PR had some unforseen perf regressions that are not as easy to find. Revert the PR for now. This reverts commit 6ae8912a3e7d2c4c775024f58a7ba4b1aedc4073, reversing changes made to 86d6d2b7389fe1b339402c1798edae8b695fc9ef.
2021-10-10Apply clippy suggestionsClemens Wasser-9/+7
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-2/+2
Move ICH to rustc_query_system Based on https://github.com/rust-lang/rust/pull/89183 The StableHashingContext does not need to be in rustc_middle. This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-03Remove re-export.Camille GILLOT-2/+2
2021-10-02Prevent macro ambiguity errorsbjorn3-6/+6
The previous macro_rules! parsers failed when an additional modifier was added with ambiguity errors. The error is pretty unclear as to what exactly the cause here is, but this change simplifies the argument parsing code such that the error is avoided.
2021-09-13Use a separate interner type for UniqueTypeIdbjorn3-1/+1
Using symbol::Interner makes it very easy to mixup UniqueTypeId symbols with the global interner. In fact the Debug implementation of UniqueTypeId did exactly this. Using a separate interner type also avoids prefilling the interner with unused symbols and allow for optimizing the symbol interner for parallel access without negatively affecting the single threaded module codegen.
2021-09-11don't clone types that are Copy (clippy::clone_on_copy)Matthias Krüger-4/+4
2021-08-19Rollup merge of #86123 - Aaron1011:query-span, r=cjgillotGuillaume Gomez-48/+56
Preserve more spans in internal `rustc_queries!` macro We now preserve the span of the various query modifiers, and use the span of the query's name for the commas that we generate to separate the modifiers. This makes debugging issues with the internal query macro infrastructure much nicer - previously, we would get errors messages pointing at the entire call site (the `rustc_queries!` invocation), which isn't very useful. This should have no effect when compilation succeeds. A concrete example of an error message produced after this changed: ``` error: local ambiguity: multiple parsing options: built-in NTs tt ('modifiers') or 1 other option. --> /home/aaron/repos/rust/compiler/rustc_middle/src/query/mod.rs:23:11 | 12 | / rustc_queries! { 13 | | query trigger_delay_span_bug(key: DefId) -> () { 14 | | desc { "trigger a delay span bug" } 15 | | } ... | 23 | | query hir_crate(key: ()) -> &'tcx Crate<'tcx> { | | ^^^^^^^^^ ... | 1715 | | } 1716 | | } | |_- in this expansion of `rustc_query_append!` | ::: compiler/rustc_query_impl/src/lib.rs:51:1 | 51 | rustc_query_append! { [define_queries!][<'tcx>] } | ------------------------------------------------- in this macro invocation ``` The particular bug shown in this error message will be fixed in a separate PR.
2021-08-01bump bootstrap compiler to 1.55Pietro Albini-1/+0
2021-07-25clippy::useless_formatMatthias Krüger-1/+1
2021-07-18Move OnDiskCache to rustc_query_impl.Camille GILLOT-1/+1
2021-07-09Fix default_hash_types to use resolved pathCameron Steffen-1/+1
2021-06-18Lint for unused borrows as part of UNUSED_MUST_USEhi-rustin-2/+2
2021-06-07Preserve more spans in internal `rustc_queries!` macroAaron Hill-48/+56
We now preserve the span of the various query modifiers, and use the span of the query's name for the commas that we generate to separate the modifiers. This makes debugging issues with the internal query macro infrastructure much nicer - previously, we would get errors messages pointing at the entire call site (the `rustc_queries!` invocation), which isn't very useful. This should have no effect when compilation succeeds. A concrete example of an error message produced after this changed: ``` error: local ambiguity: multiple parsing options: built-in NTs tt ('modifiers') or 1 other option. --> /home/aaron/repos/rust/compiler/rustc_middle/src/query/mod.rs:23:11 | 12 | / rustc_queries! { 13 | | query trigger_delay_span_bug(key: DefId) -> () { 14 | | desc { "trigger a delay span bug" } 15 | | } ... | 23 | | query hir_crate(key: ()) -> &'tcx Crate<'tcx> { | | ^^^^^^^^^ ... | 1715 | | } 1716 | | } | |_- in this expansion of `rustc_query_append!` | ::: compiler/rustc_query_impl/src/lib.rs:51:1 | 51 | rustc_query_append! { [define_queries!][<'tcx>] } | ------------------------------------------------- in this macro invocation ``` The particular bug shown in this error message will be fixed in a separate PR.
2021-06-01Remove unused functions and arguments from rustc_serializebjorn3-10/+8
2021-03-26Use iter::zip in compiler/Josh Stone-1/+1
2021-03-11Add inlining.Camille GILLOT-0/+2
2021-02-24replaced some map_or with map_or_elseklensy-1/+1
2021-02-23replaced some unwrap_or with unwrap_or_elseklensy-5/+5
2021-02-19Move the query system to rustc_query_impl.Camille GILLOT-0/+3
2021-02-19Wrap QueryDescription into a macro.Camille GILLOT-4/+4
2021-02-19Make QueryEngine opaque to TyCtxt.Camille GILLOT-7/+5
2021-02-19Wrap TyCtxt inside a QueryCtxt for queries.Camille GILLOT-13/+13
2021-02-19Decouple the on-disk cache from the query engine.Camille GILLOT-2/+2
2021-02-08Switch query descriptions to just StringMark Rousskov-2/+2
In practice we never used the borrowed variant anyway.
2021-01-31Indent the code correctly again after removing the query categories.Julian Wollersberger-54/+52
2021-01-31Remove the remains of the query categories.Julian Wollersberger-23/+4
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-1/+1
2021-01-01rustc_serialize: specialize opaque encoding of some u8 sequencesTyson Nottingham-2/+2
2020-12-30Rollup merge of #80509 - matthiaskrgr:ptr_arg, r=varkorYuki Okushi-1/+1
where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)