Commit Graph

70 Commits

Author SHA1 Message Date
Matthias Krüger fd09f342f3 Rollup merge of #92011 - Aaron1011:decode-span, r=michaelwoerister
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).
2022-01-03 14:44:16 +01:00
Aaron Hill 44fdb98764 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-16 18:35:15 -05:00
Aaron Hill 070bf94a6f Remove in_band_lifetimes from rustc_middle
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-15 19:50:43 -05:00
Deadbeef 42963f4d50 Query modifier 2021-12-12 12:35:00 +08:00
Alan Egerton cf683e644f Rename TypeFolderFallible to FallibleTypeFolder 2021-12-02 16:14:18 +00:00
Alan Egerton bfc434b6d0 Reduce boilerplate around infallible folders 2021-12-02 16:14:16 +00:00
LeSeulArtichaut 6e3fa20b00 Make TypeFoldable implementors short-circuit on error
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26 07:17:59 +00:00
Mark Rousskov 3228603cce 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 5c454551da more clippy fixes 2021-11-07 16:59:05 +01:00
bjorn3 f5c3e83013 Avoid a branch on key being local for queries that use the same local and extern providers 2021-10-25 13:36:23 +02:00
Camille GILLOT 138e96b719 Do not require QueryCtxt for cache_on_disk. 2021-10-23 18:12:43 +02:00
Camille GILLOT 7c0920f5fb Build the query vtable directly. 2021-10-23 16:59:19 +02:00
Camille GILLOT 0a5666b838 Do not depend on the stored value when trying to cache on disk. 2021-10-21 20:00:45 +02:00
Matthias Krüger 4457014398 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 6ae8912a3e, reversing
changes made to 86d6d2b738.
2021-10-15 11:28:23 +02:00
Clemens Wasser 71dd0b928b Apply clippy suggestions 2021-10-10 15:38:19 +02:00
bors 55111d656f Auto merge of #89266 - cjgillot:session-ich, r=michaelwoerister
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-05 09:45:11 +00:00
Camille GILLOT 02025d86ac Remove re-export. 2021-10-03 16:08:54 +02:00
bjorn3 e2d3e09b9c Prevent macro ambiguity errors
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-10-02 13:00:19 -04:00
Mark Rousskov c746be2219 Migrate to 2021 2021-09-20 22:21:42 -04:00
bjorn3 8c7840e8cb Use a separate interner type for UniqueTypeId
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-13 14:42:06 +02:00
Matthias Krüger c1e96085d3 don't clone types that are Copy (clippy::clone_on_copy) 2021-09-11 10:18:56 +02:00
Guillaume Gomez def6393a8b Rollup merge of #86123 - Aaron1011:query-span, r=cjgillot
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-19 19:30:04 +02:00
bors b53a93db2d Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum
rfc3052 followup: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field, 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 for contributors, we may as well
remove it from crates in this repo.
2021-08-02 05:49:17 +00:00
Pietro Albini 24f9de5a44 bump bootstrap compiler to 1.55 2021-08-01 11:19:24 -04:00
Jade 3cf820e17d 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
Matthias Krüger 3fd8cbb404 clippy::useless_format 2021-07-25 12:26:03 +02:00
Camille GILLOT 81241cbf3a Move OnDiskCache to rustc_query_impl. 2021-07-18 11:14:07 +02:00
Cameron Steffen d6b0d0bf97 Fix default_hash_types to use resolved path 2021-07-09 09:10:45 -05:00
hi-rustin 88abd7d81d Lint for unused borrows as part of UNUSED_MUST_USE 2021-06-18 15:09:40 +08:00
Aaron Hill 34f116101f 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-06-07 19:41:43 -05:00
bjorn3 a2c4affe86 Remove unused functions and arguments from rustc_serialize 2021-06-01 19:29:11 +02:00
Josh Stone 72ebebe474 Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
Camille GILLOT 84bf599bac Add inlining. 2021-03-11 12:24:43 +01:00
klensy c75c4a579b replaced some map_or with map_or_else 2021-02-24 02:43:35 +03:00
klensy 5ff1be197e replaced some unwrap_or with unwrap_or_else 2021-02-23 23:56:04 +03:00
Camille GILLOT 4581d16bcb Move the query system to rustc_query_impl. 2021-02-19 17:51:58 +01:00
Camille GILLOT 8e5d613a11 Wrap QueryDescription into a macro. 2021-02-19 17:51:57 +01:00
Camille GILLOT 5d71b99690 Make QueryEngine opaque to TyCtxt. 2021-02-19 17:51:54 +01:00
Camille GILLOT 2db2776589 Wrap TyCtxt inside a QueryCtxt for queries. 2021-02-19 17:51:50 +01:00
Camille GILLOT dab9b89221 Decouple the on-disk cache from the query engine. 2021-02-19 17:51:50 +01:00
Mark Rousskov f564d7abba Switch query descriptions to just String
In practice we never used the borrowed variant anyway.
2021-02-08 17:20:41 -05:00
Julian Wollersberger 988d93c8a0 Indent the code correctly again after removing the query categories. 2021-01-31 21:40:03 +01:00
Julian Wollersberger 7bc09f78af Remove the remains of the query categories. 2021-01-31 21:37:17 +01:00
LingMan a56bffb4f9 Use Option::map_or instead of .map(..).unwrap_or(..) 2021-01-14 19:23:59 +01:00
Tyson Nottingham a4daa63a90 rustc_serialize: specialize opaque encoding of some u8 sequences 2021-01-01 22:49:14 -08:00
Yuki Okushi 41fa0dba27 Rollup merge of #80509 - matthiaskrgr:ptr_arg, r=varkor
where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)
2020-12-30 22:49:26 +09:00
Matthias Krüger bdc9291ed9 where possible, pass slices instead of &Vec or &String (clippy::ptr_arg) 2020-12-30 13:11:52 +01:00
Joshua Nelson e67f9d3105 Use desc as a doc-comment if none exist yet
- Replace {} with the stringified expr

  Giant thank you to `@danielhenrymantilla` for figuring out how to make
  this work ❤️

- Note that this is just an approximation and it would be better to add
  a doc-comment
2020-12-29 21:13:06 -05:00
Arlie Davis 2b2462e8b0 Stop using intermediate macros in definition of symbols
Currently, the rustc_macros::symbols macro generates two
`macro_rules!` macros as its output. These two macros are
used in rustc_span/src/symbol.rs.

This means that each Symbol that we define is represented
in the AST of rustc_symbols twice: once in the definition
of the `define_symbols!` macro (similarly for the
`keywords! macro), and once in the rustc_span::symbols
definition.

That would be OK if there were only a handful of symbols,
but currently we define over 1100 symbols. The definition
of the `define_symbols!` macro contains the expanded definition
of each symbol, so that's a lot of AST storage wasted on a
macro that is used exactly once.

This commit removes the `define_symbols` macro, and simply
allows the proc macro to directly generate the
`rustc_symbols::symbol::sym` module.

The benefit is mainly in reducing memory wasted during
compilation of rustc itself. It should also reduce memory used
by Rust Analyzer.

This commit also reduces the size of the AST for symbol
definitions, by moving two `#[allow(...)]` attributes from
the symbol constants to the `sym` module. This eliminates 2200+
attribute nodes.

This commit also eliminates the need for the `digits_array`
constant. There's no need to store an array of Symbol values
for digits. We can simply define a constant of the base value,
and add to that base value.
2020-12-17 15:20:45 -08:00
Arlie Davis 1a5b9b037e ./x.py fmt 2020-12-13 13:36:01 -08:00