Commit Graph

898 Commits

Author SHA1 Message Date
Rich Kadel
36c639a2ce Convenience funcs for some_option.unwrap_or(...)
This ensures consistent handling of default values for options that are
None if not specified on the command line.
2020-12-14 17:27:27 -08:00
LeSeulArtichaut
a72b739bf0 Remove unused TyEncoder::tcx required method 2020-12-14 23:33:47 +01:00
Rich Kadel
4f550f1f93 Improve warnings on incompatible options involving -Zinstrument-coverage
Adds checks for:

* `no_core` attribute
* explicitly-enabled `legacy` symbol mangling
* mir_opt_level > 1 (which enables inlining)

I removed code from the `Inline` MIR pass that forcibly disabled
inlining if `-Zinstrument-coverage` was set. The default `mir_opt_level`
does not enable inlining anyway. But if the level is explicitly set and
is greater than 1, I issue a warning.

The new warnings show up in tests, which is much better for diagnosing
potential option conflicts in these cases.
2020-12-14 12:55:46 -08:00
Aaron Hill
a332e2b38f
Account for gaps in def path table during decoding
When encoding a proc-macro crate, there may be gaps in the table (since
we only encode the crate root and proc-macro items). Account for this by
checking if the entry is present, rather than using `unwrap()`
2020-12-08 13:02:53 -05:00
Vadim Petrochenkov
908bf5a310 rustc_metadata: Remove some dead code 2020-12-03 00:05:24 +03:00
bors
4cbda829c0 Auto merge of #74967 - Aaron1011:feature/incr-def-path-table, r=pnkfelix
Implement lazy decoding of DefPathTable during incremental compilation

PR https://github.com/rust-lang/rust/pull/75813 implemented lazy decoding of the `DefPathTable` from crate metadata. However, it requires decoding the entire `DefPathTable` when incremental compilation is active, so that we can map a decoded `DefPathHash` to a `DefId` from an arbitrary crate.

This PR adds support for lazy decoding of dependency `DefPathTable`s when incremental compilation si active.

When we load the incremental cache and dep
graph, we need the ability to map a `DefPathHash` to a `DefId` in the
current compilation session (if the corresponding definition still
exists).

This is accomplished by storing the old `DefId` (that is, the `DefId`
from the previous compilation session) for each `DefPathHash` we need to
remap. Since a `DefPathHash` includes the owning crate, the old crate is
guaranteed to be the right one (if the definition still exists). We then
use the old `DefIndex` as an initial guess, which we validate by
comparing the expected and actual `DefPathHash`es. In most cases,
foreign crates will be completely unchanged, which means that we our
guess will be correct. If our guess is wrong, we fall back to decoding
the entire `DefPathTable` for the foreign crate. This still represents
an improvement over the status quo, since we can skip decoding the
entire `DefPathTable` for other crates (where all of our guesses were
correct).
2020-12-01 14:30:02 +00:00
Camille GILLOT
9dd32e177e Encode proc_macro directly.
Encode proc_macro name directly.

Do not store None values.
2020-11-27 20:39:49 +01:00
Camille GILLOT
60c3bbd844 Formatting. 2020-11-26 21:32:29 +01:00
Camille GILLOT
032f68d625 Remove ForeignMod struct. 2020-11-26 21:32:27 +01:00
Camille GILLOT
419a9186a4 Store ForeignItem in a side table. 2020-11-26 21:29:27 +01:00
Aaron Hill
e935d3832c
Lazy DefPath decoding for incremental compilation 2020-11-25 14:49:15 -05:00
varkor
cf32afcf48 Stabilise then 2020-11-22 13:45:14 +00:00
Hannah McLaughlin
d38dbcb19f Improve error message when we try to get_type on something that does not have a type 2020-11-18 21:20:51 +00:00
Dániel Buga
f0d0d87a20 Push to result vector instead of allocating
Co-authored-by: lcnr <bastian_kauschke@hotmail.de>
2020-11-13 11:19:25 +01:00
Dániel Buga
660d8a6550 Eliminate some temporary vectors & Remove unnecessary mark_attr_used 2020-11-13 11:19:23 +01:00
Nicholas-Baron
261ca04c92 Changed unwrap_or to unwrap_or_else in some places.
The discussion seems to have resolved that this lint is a bit "noisy" in
that applying it in all places would result in a reduction in
readability.

A few of the trivial functions (like `Path::new`) are fine to leave
outside of closures.

The general rule seems to be that anything that is obviously an
allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it
is a 0-sized allocation.
2020-11-10 20:07:47 -08:00
Vadim Petrochenkov
bf66988aa1 Collapse all uses of target.options.foo into target.foo
with an eye on merging `TargetOptions` into `Target`.

`TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.
2020-11-08 17:29:13 +03:00
bors
7b5a9e9cd2 Auto merge of #78448 - rylev:cache-foreign_modules, r=wesleywiser
foreign_modules query hash table lookups

When compiling a large monolithic crate we're seeing huge times in the `foreign_modules` query due to repeated iteration over foreign modules (in order to find a module by its id). This implements hash table lookups so that which massively reduces time spent in that query in this particular case. We'll need to see if the overhead of creating the hash table has a negative impact on performance in more normal compilation scenarios.

I'm working with `@wesleywiser` on this.
2020-11-03 04:27:27 +00:00
Joshua Nelson
bfecb18771 Fix some more clippy warnings 2020-10-30 10:12:56 -04:00
Tomasz Miąsko
2661a4edb9 Avoid BorrowMutError with RUSTC_LOG=debug
$ touch empty.rs
$ env RUSTC_LOG=debug rustc +stage1 --crate-type=lib empty.rs

Fails with a `BorrowMutError` because source map files are already
borrowed while `features_query` attempts to format a log message
containing a span.

Release the borrow before the query to avoid the issue.
2020-10-29 18:09:53 +01:00
Ryan Levick
81444b2049 Remove some cruft from foreign_modules refactor 2020-10-27 20:17:48 +01:00
Ryan Levick
69dc98161a Cache foreign_modules query 2020-10-27 16:21:55 +01:00
Aaron Hill
283053a742
Compute proper module parent during resolution
Fixes #75982

The direct parent of a module may not be a module
(e.g. `const _: () =  { #[path = "foo.rs"] mod foo; };`).

To find the parent of a module for purposes of resolution, we need to
walk up the tree until we hit a module or a crate root.
2020-10-24 14:28:13 -04:00
Vadim Petrochenkov
cee5521a03 Calculate visibilities once in resolve
Then use them through a query based on resolver outputs
2020-10-19 11:57:50 +03:00
est31
4fa5578774 Replace target.target with target and target.ptr_width with target.pointer_width
Preparation for a subsequent change that replaces
rustc_target::config::Config with its wrapped Target.

On its own, this commit breaks the build. I don't like making
build-breaking commits, but in this instance I believe that it
makes review easier, as the "real" changes of this PR can be
seen much more easily.

Result of running:

find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \;
find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \;
./x.py fmt
2020-10-15 12:02:24 +02:00
est31
215cd36e1c Remove unused code from remaining compiler crates 2020-10-14 04:14:32 +02:00
Dániel Buga
0d27b765a6 Take functions by value 2020-10-10 16:19:53 +02:00
Matthew Jasper
f958e6c246 Separate bounds and predicates for associated/opaque types 2020-10-06 11:19:29 +01:00
Matthew Jasper
d297147e62 Split bounds from predicates 2020-10-06 11:19:22 +01:00
Aaron Hill
8d11f90a16
Record expansion_that_defined into crate metadata
Fixes #77523

Now that hygiene serialization is implemented, we also need to record
`expansion_that_defined` so that we properly handle a foreign
`SyntaxContext`.
2020-10-05 16:01:19 -04:00
Vadim Petrochenkov
384eb2691f rustc_metadata: Do not forget to encode inherent impls for foreign types 2020-09-30 22:58:35 +03:00
bors
d902752866 Auto merge of #77118 - exrook:stability-generic-parameters-2, r=varkor
Stability annotations on generic parameters (take 2.5)

Rebase of #72314 + more tests

Implements rust-lang/wg-allocators#2.
2020-09-27 12:51:21 +00:00
Aaron Hill
b9653568a7
Encode less metadata for proc-macro crates
Currently, we serialize the same crate metadata for proc-macro crates as
we do for normal crates. This is quite wasteful - almost none of this
metadata is ever used, and much of it can't even be deserialized (if it
contains a foreign `CrateNum`).

This PR changes metadata encoding to skip encoding the majority of crate
metadata for proc-macro crates. Most of the `Lazy<[T]>` fields are left
completetly empty, while the non-lazy fields are left as-is.

Additionally, proc-macros now have a def span that does not include
their body. This was done for normal functions in #75465, but was missed
for proc-macros.

As a result of this PR, we should only ever encode local `CrateNum`s
when encoding proc-macro crates. I've added a specialized serialization
impl for `CrateNum` to assert this.
2020-09-26 12:26:27 -04:00
Jonas Schievink
6f3da3d53f
Rollup merge of #77121 - duckymirror:html-root-url, r=jyn514
Updated html_root_url for compiler crates

Closes #77103

r? @jyn514
2020-09-25 02:29:45 +02:00
Erik Hofmayer
138a2e5eaa /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
Erik Hofmayer
dd66ea2d3d Updated html_root_url for compiler crates 2020-09-23 21:14:43 +02:00
Dylan DPC
98e5ee7df0
Rollup merge of #76939 - lcnr:const-evaluatable-cont, r=oli-obk
emit errors during AbstractConst building

There changes are currently still untested, so I don't expect this to pass CI 😆

It seems to me like this is the direction we want to go in, though we didn't have too much of a discussion about this.

r? @oli-obk
2020-09-23 14:54:02 +02:00
Avi Dessauer
a7a2086053 Stability annotations on generic trait parameters 2020-09-22 21:53:48 -04:00
Aaron Hill
e734733a9e
Record tcx.def_span instead of item.span in crate metadata
This was missed in PR #75465. As a result, a few places have been using
the full body span of functions, instead of just the header span.
2020-09-21 15:10:16 -04:00
Bastian Kauschke
d4039c55c9 wip emit errors during AbstractConst building 2020-09-19 22:17:52 +02:00
Bastian Kauschke
30ff1ef3d0 support const_evaluatable_checked across crate boundaries 2020-09-18 17:11:34 +02:00
Matthias Krüger
fd9be8f7aa don't lazily evaulate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations) 2020-09-15 23:17:51 +02:00
bors
1eb00abf35 Auto merge of #76656 - jonas-schievink:fewer-unstable-metadata-queries, r=lcnr
Don't query stability data when `staged_api` is off

This data only needs to be encoded when `#![feature(staged_api)]` or `-Zforce-unstable-if-unmarked` is on. Running these queries takes measurable time on large crates with many items, so skip it when the unstable flags have not been enabled.
2020-09-14 00:26:43 +00:00
Aaron Hill
a67d248b13
Properly encode spans with a dummy location and non-root SyntaxContext
Previously, we would throw away the `SyntaxContext` of any span with a
dummy location during metadata encoding. This commit makes metadata Span
encoding consistent with incr-cache Span encoding - an 'invalid span'
tag is only used when it doesn't lose any information.
2020-09-12 23:26:17 -04:00
Jonas Schievink
a447c21afa Don't query unstable data when staged_api is off 2020-09-13 02:10:39 +02:00
Aaron Hill
c1011165e6
Attach TokenStream to ast::Visibility
A `Visibility` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
2020-09-10 17:33:06 -04:00
LeSeulArtichaut
3e14b684dd Change ty.kind to a method 2020-09-04 17:47:51 +02:00
mark
9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00