Commit Graph

115 Commits

Author SHA1 Message Date
Matthew Jasper cbcef3effc Rework `rustc_serialize`
- Move the type parameter from `encode` and `decode` methods to
  the trait.
- Remove `UseSpecialized(En|De)codable` traits.
- Remove blanket impls for references.
- Add `RefDecodable` trait to allow deserializing to arena-allocated
  references safely.
- Remove ability to (de)serialize HIR.
- Create proc-macros `(Ty)?(En|De)codable` to help implement these new
  traits.
2020-08-14 17:34:30 +01:00
Nicholas Nethercote e539dd65f8 Eliminate the `SessionGlobals` from `librustc_ast`.
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This
means they are accessed via the `Session`, rather than via TLS. A few
`Attr` methods and `librustc_ast` functions are now methods of
`Session`.

All of this required passing a `Session` to lots of functions that didn't
already have one. Some of these functions also had arguments removed, because
those arguments could be accessed directly via the `Session` argument.

`contains_feature_attr()` was dead, and is removed.

Some functions were moved from `librustc_ast` elsewhere because they now need
to access `Session`, which isn't available in that crate.
- `entry_point_type()` --> `librustc_builtin_macros`
- `global_allocator_spans()` --> `librustc_metadata`
- `is_proc_macro_attr()` --> `Session`
2020-08-08 12:03:42 +10:00
bors 3cfc7fe78e Auto merge of #75008 - eddyb:rmeta-indexed-trait-impls, r=nikomatsakis
rustc_metadata: track the simplified Self type for every trait impl.

For the `traits_impls_of` query, we index the impls by `fast_reject::SimplifiedType` (a "shallow type"), which allows some simple cases like `impl Trait<..> for Foo<..>` to be efficiently iterated over, by e.g. `for_each_relevant_impl`.

This PR encodes the `fast_reject::SimplifiedType` cross-crate to avoid needing to deserialize the `Self` type of every `impl` in order to simplify it - the simplification itself should be cheap, but the deserialization is less so.

We could go further from here and make loading the list of impls lazy, for a given simplified `Self` type, but that would have more complicated implications for performance, and this PR doesn't do anything in that regard.

r? @nikomatsakis cc @Mark-Simulacrum
2020-08-06 03:23:57 +00:00
David Wood 5f89f02c4e
mir: use `FiniteBitSet<u32>` in polymorphization
This commit changes polymorphization to return a `FiniteBitSet<u32>`
rather than a `FiniteBitSet<u64>` because most functions do not use
anywhere near sixty-four generic parameters so keeping a `u64` around is
unnecessary in most cases.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-04 18:30:53 +01:00
Yuki Okushi 595a2f5c6b
Rollup merge of #75054 - cjgillot:rename-depkind, r=petrochenkov
Rename rustc_middle::cstore::DepKind to CrateDepKind

It is ambiguous with DepGraph's own DepKind.
2020-08-03 01:05:27 +09:00
Camille GILLOT 4d4b8f2d41 Rename rustc_middle::cstore::DepKind to DependencyKind. 2020-08-02 16:21:46 +02:00
Eduard-Mihai Burtescu 6bf3a4bcd8 rustc_metadata: track the simplified Self type for every trait impl. 2020-08-01 16:14:22 +03:00
Mark Rousskov 13ad2322ca Cache non-exhaustive separately from attributes 2020-07-28 16:26:38 -04:00
mark 2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00
Aaron Hill f622f45afd
Share serialization optimization between incr and metadata 2020-07-26 18:37:03 -04:00
Aaron Hill 0caebfabe6
Hygiene serialization implementation 2020-07-26 18:37:02 -04:00
David Wood 4b99699c84
index: introduce and use `FiniteBitSet`
This commit introduces a `FiniteBitSet` type which replaces the manual
bit manipulation which was being performed in polymorphization.

Signed-off-by: David Wood <david@davidtw.co>
2020-07-20 19:35:37 +01:00
David Wood 5ce29d3d6f
metadata: record `unused_generic_params`
This commit records the results of `unused_generic_params` in crate
metadata, hopefully improving performance.

Signed-off-by: David Wood <david@davidtw.co>
2020-07-20 19:35:34 +01:00
Tamir Duberstein 62cf767a4a
Avoid "whitelist"
Other terms are more inclusive and precise.
2020-07-10 07:39:28 -04:00
Aaron Hill 334373324d
Serialize all foreign `SourceFile`s into proc-macro crate metadata
Normally, we encode a `Span` that references a foreign `SourceFile` by
encoding information about the foreign crate. When we decode this
`Span`, we lookup the foreign crate in order to decode the `SourceFile`.

However, this approach does not work for proc-macro crates. When we load
a proc-macro crate, we do not deserialzie any of its dependencies (since
a proc-macro crate can only export proc-macros). This means that we
cannot serialize a reference to an upstream crate, since the associated
metadata will not be available when we try to deserialize it.

This commit modifies foreign span handling so that we treat all foreign
`SourceFile`s as local `SourceFile`s when serializing a proc-macro.
All `SourceFile`s will be stored into the metadata of a proc-macro
crate, allowing us to cotinue to deserialize a proc-macro crate without
needing to load any of its dependencies.

Since the number of foreign `SourceFile`s that we load during a
compilation session may be very large, we only serialize a `SourceFile`
if we have also serialized a `Span` which requires it.
2020-06-29 21:45:42 -04:00
Aaron Hill 36ac08e264
Make `fn_arg_names` return `Ident` instead of symbol
Also, implement this query for the local crate, not just foreign crates.
2020-06-26 15:46:22 -04:00
Aaron Hill ad9972a20d
Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, r=nikomatsakis"
This reverts commit 372cb9b69c, reversing
changes made to 5c61a8dc34.
2020-06-22 12:46:29 -04:00
Matthew Jasper 8ea55f1a99 Cache decoded predicate shorthands 2020-06-21 10:18:01 +01:00
Ralf Jung 5431ef6530
Rollup merge of #72600 - Aaron1011:fix/anon-const-encoding, r=varkor
Properly encode AnonConst into crate metadata

Fixes #68104

Previous, we were encoding AnonConst as a regular Const, causing us to
treat them differently after being deserialized in another compilation
session.
2020-06-20 16:39:45 +02:00
bors ff4a2533a0 Auto merge of #73369 - RalfJung:rollup-hl8g9zf, r=RalfJung
Rollup of 10 pull requests

Successful merges:

 - #72707 (Use min_specialization in the remaining rustc crates)
 - #72740 (On recursive ADT, provide indirection structured suggestion)
 - #72879 (Miri: avoid tracking current location three times)
 - #72938 (Stabilize Option::zip)
 - #73086 (Rename "cyclone" to "apple-a7" per changes in upstream LLVM)
 - #73104 (Example about explicit mutex dropping)
 - #73139 (Add methods to go from a nul-terminated Vec<u8> to a CString)
 - #73296 (Remove vestigial CI job msvc-aux.)
 - #73304 (Revert heterogeneous SocketAddr PartialEq impls)
 - #73331 (extend network support for HermitCore)

Failed merges:

r? @ghost
2020-06-15 11:39:23 +00:00
Ralf Jung eef9356e39
Rollup merge of #72707 - matthewjasper:rustc_min_spec, r=oli-obk
Use min_specialization in the remaining rustc crates

This adds a lot of `transmute` calls to replace the unsound uses of specialization.
It's ugly, but at least it's honest about what's going on.

cc #71420, @RalfJung
2020-06-15 12:00:58 +02:00
bors d4ecf31efc Auto merge of #73367 - RalfJung:rollup-4ewvk9b, r=RalfJung
Rollup of 10 pull requests

Successful merges:

 - #71824 (Check for live drops in constants after drop elaboration)
 - #72389 (Explain move errors that occur due to method calls involving `self`)
 - #72556 (Fix trait alias inherent impl resolution)
 - #72584 (Stabilize vec::Drain::as_slice)
 - #72598 (Display information about captured variable in `FnMut` error)
 - #73336 (Group `Pattern::strip_*` method together)
 - #73341 (_match.rs: fix module doc comment)
 - #73342 (Fix iterator copied() documentation example code)
 - #73351 (Update E0446.md)
 - #73353 (structural_match: non-structural-match ty closures)

Failed merges:

r? @ghost
2020-06-15 08:09:38 +00:00
Aaron Hill 754da8849c
Make `fn_arg_names` return `Ident` instead of symbol
Also, implement this query for the local crate, not just foreign crates.
2020-06-11 17:40:39 -04:00
Matthew Jasper 4201fd273e Remove associated opaque types
They're unused now.
2020-06-11 16:24:01 +01:00
Matthew Jasper 88ea7e5234 Use min_specialization in the remaining rustc crates 2020-06-10 09:05:52 +01:00
Felix S. Klock II da09fd3db0 Split payload of FileName::Real to track both real and virutalized paths.
Such splits arise from metadata refs into libstd.

This way, we can (in a follow on commit) continue to emit the virtual name into
things like the like the StableSourceFileId that ends up in incremetnal build
artifacts, while still using the devirtualized file path when we want to access
the file.

Note that this commit is intended to be a refactoring; the actual fix to the bug
in question is in a follow-on commit.
2020-05-29 23:41:45 -04:00
Aaron Hill ebe5a916b0
Properly encode AnonConst into crate metadata
Fixes #68104

Previous, we were encoding AnonConst as a regular Const, causing us to
treat them differently after being deserialized in another compilation
session.
2020-05-26 01:48:45 -04:00
Dylan MacKenzie c282c1c654 Use `OnceCell` instead of `Once` 2020-05-22 13:31:02 -07:00
Vadim Petrochenkov ee7a35ab95 Rename some types describing native libraries
NativeLibrary(Kind) -> NativeLib(Kind)
NativeStatic -> StaticBundle
NativeStaticNobundle -> StaticNoBundle
NativeFramework -> Framework
NativeRawDylib -> RawDylib
NativeUnknown -> Unspecified
2020-05-20 21:53:19 +03:00
Camille GILLOT d4e143ed2f Remove ast::{Ident, Name} reexports. 2020-05-08 13:13:15 +02:00
Dylan MacKenzie 14a2c8d042 Decode qualifs from defaulted trait associated consts 2020-05-02 14:46:22 -07:00
Camille GILLOT bd61870606 Fix incremental compilation. 2020-04-28 11:38:32 +02:00
Camille GILLOT e56c400432 Use the query system to allocate. 2020-04-28 11:34:17 +02:00
Eduard-Mihai Burtescu d1db782dff Split out the `Generator` case from `DefKind::Closure`. 2020-04-24 13:31:37 -05:00
mark cff5b998e0 add a few more DefKinds
make Map::def_kind take LocalDefId

Co-Authored-By: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>

crates are DefKind::Mod
2020-04-24 13:31:36 -05:00
Dylan MacKenzie 8287842eb4 Use `Body` everywhere 2020-04-22 09:57:43 -07:00
Josh Stone 7b005c5fcb Dogfood more or_patterns in the compiler 2020-04-19 07:33:58 -07:00
Rustin-Liu b07e7fe047 Rename AssocKind::Method to AssocKind::Fn
Rename fn_has_self_argument to fn_has_self_parameter

Rename AssocItemKind::Method to AssocItemKind::Fn

Refine has_no_input_arg

Refine has_no_input_arg

Revert has_no_input_arg

Refine suggestion_descr

Move as_def_kind into AssocKind

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>

Fix tidy check issue

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
2020-04-14 07:12:07 +08:00
bors e82734e56b Auto merge of #70161 - cjgillot:query-arena, r=nikomatsakis
Allocate some query results on an arena

This avoids a cloning few `Lrc` and `Vec`s in the queries.
2020-04-11 15:31:54 +00:00
Camille GILLOT 81f0e90c62 Remove unneeded Lrc in query results. 2020-04-05 15:26:09 +02:00
Camille GILLOT 5e1ad0d1e4 Remove Arcs in queries. 2020-04-05 15:21:08 +02:00
Camille GILLOT 3c0edc895f Allocate query Vecs on the arena. 2020-04-05 15:02:00 +02:00
Linus Färnstrand fcf45999f7 Stop importing int/float modules in librustc_* 2020-04-05 11:22:01 +02:00
bors c53e4b3877 Auto merge of #70642 - eddyb:remap-sysroot-src, r=Mark-Simulacrum
Translate the virtual `/rustc/$hash` prefix back to a real directory.

Closes #53486 and fixes #53081, by undoing the remapping to `/rustc/$hash` on the fly, when appropriate (e.g. our testsuites, or user crates that depend on `libstd`), but not during the Rust build itself (as that could leak the absolute build directory into the artifacts, breaking deterministic builds).

Tested locally by setting `remap-debuginfo = true` in `config.toml`, which without these changes, was causing 56 tests to fail (see https://github.com/rust-lang/rust/issues/53081#issuecomment-606703215 for more details).

cc @Mark-Simulacrum @alexcrichton @ehuss
2020-04-03 01:22:39 +00:00
Mazdak Farrokhzad 791e872c53
Rollup merge of #70634 - Centril:import-directly, r=Mark-Simulacrum
Remove some reexports in `rustc_middle`

This will help get these imports out of the way of detecting the true dependencies in and out to `rustc_middle`, thereby helping future work towards https://github.com/rust-lang/rust/issues/65031.
2020-04-02 14:27:58 +02:00
Mazdak Farrokhzad 6daff1400a direct imports for langitem stuff 2020-04-02 13:40:43 +02:00
Eduard-Mihai Burtescu f5892c00ac Translate the virtual `/rustc/$hash` prefix back to a real directory. 2020-04-02 11:39:41 +03:00
Valentin Lazureanu dca3782c18 Renamed `PerDefTables` to `Tables` 2020-03-31 23:19:50 +00:00
Mazdak Farrokhzad 1ccb0b4a02 rustc -> rustc_middle part 3 (rustfmt) 2020-03-30 07:19:55 +02:00
Mazdak Farrokhzad 0cb9e36090 rustc -> rustc_middle part 2 2020-03-30 07:16:56 +02:00