Commit graph

568 commits

Author SHA1 Message Date
Yuki Okushi 87e373e82f
Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011
Make `ExprKind::Closure` a struct variant.

Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`.

r? ``@Aaron1011``
2022-06-15 19:37:14 +09:00
Nicholas Nethercote abe45a9ffa Rename rustc_serialize::opaque::Encoder as MemEncoder.
This avoids the name clash with `rustc_serialize::Encoder` (a trait),
and allows lots qualifiers to be removed and imports to be simplified
(e.g. fewer `as` imports).

(This was previously merged as commit 5 in #94732 and then was reverted
in #97905 because of a perf regression caused by commit 4 in #94732.)
2022-06-14 14:52:01 +10:00
Camille GILLOT 3039cfeb6a Make ExprKind::Closure a struct variant. 2022-06-12 00:16:27 +02:00
bors 99930ac7f8 Auto merge of #95880 - cjgillot:def-ident-span, r=petrochenkov
Handle `def_ident_span` like `def_span`.

`def_ident_span` had an ad-hoc status in the compiler.

This PR refactors it to be a first-class citizen like `def_span`:
- it gets encoded in the main metadata loop, instead of the visitor;
- its implementation is updated to mirror the one of `def_span`.

We do not remove the `Option` in the return type, since some items do not have an ident, AnonConsts for instance.
2022-06-11 20:08:48 +00:00
Dylan DPC b7b5045364
Rollup merge of #97789 - ferrocene:pa-fix-issue-71363-test, r=cjgillot
Fix #71363's test by adding `-Z translate-remapped-path-to-local-path=no`

The test relies on `library/std/src/error.rs` not corresponding to a local path, but remapping might still find the related local file of a remapped path. To fix the test, this PR adds a new `-Z` flag to disable finding the corresponding local path of a remapped path.
2022-06-11 12:59:27 +02:00
bors c84594661c Auto merge of #97905 - nnethercote:revert-infallible-encoder, r=bjorn3
Revert part of #94372 to improve performance

#94732 was supposed to give small but widespread performance improvements, as judged from three per-merge performance runs. But the performance run that occurred after merging included a roughly equal number of improvements and regressions, for unclear reasons.

This PR is for a test run reverting those changes, to see what happens.

r? `@ghost`
2022-06-11 04:00:23 +00:00
Camille GILLOT 64b6c32b21 Assert def_ident_span presence. 2022-06-10 20:16:37 +02:00
Camille GILLOT 871993f7a1 Encode def_ident_span using the query. 2022-06-10 20:16:32 +02:00
Nicholas Nethercote 3186e311e5 Revert dc08bc51f2. 2022-06-10 11:58:29 +10:00
Nicholas Nethercote 7f51a1b976 Revert b983e42936. 2022-06-10 08:35:03 +10:00
Vadim Petrochenkov a8ee1f3a4f Stabilize the bundle native library modifier 2022-06-09 23:12:58 +04:00
Nicholas Nethercote b983e42936 Rename rustc_serialize::opaque::Encoder as MemEncoder.
This avoids the name clash with `rustc_serialize::Encoder` (a trait),
and allows lots qualifiers to be removed and imports to be simplified
(e.g. fewer `as` imports).
2022-06-08 09:50:44 +10:00
Nicholas Nethercote dc08bc51f2 Move finish out of the Encoder trait.
This simplifies things, but requires making `CacheEncoder` non-generic.
2022-06-08 09:21:05 +10:00
Nicholas Nethercote 1acbe7573d Use delayed error handling for Encodable and Encoder infallible.
There are two impls of the `Encoder` trait: `opaque::Encoder` and
`opaque::FileEncoder`. The former encodes into memory and is infallible, the
latter writes to file and is fallible.

Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a
bit verbose and has non-trivial cost, which is annoying given how rare failures
are (especially in the infallible `opaque::Encoder` case).

This commit changes how `Encoder` fallibility is handled. All the `emit_*`
methods are now infallible. `opaque::Encoder` requires no great changes for
this. `opaque::FileEncoder` now implements a delayed error handling strategy.
If a failure occurs, it records this via the `res` field, and all subsequent
encoding operations are skipped if `res` indicates an error has occurred. Once
encoding is complete, the new `finish` method is called, which returns a
`Result`. In other words, there is now a single `Result`-producing method
instead of many of them.

This has very little effect on how any file errors are reported if
`opaque::FileEncoder` has any failures.

Much of this commit is boring mechanical changes, removing `Result` return
values and `?` or `unwrap` from expressions. The more interesting parts are as
follows.
- serialize.rs: The `Encoder` trait gains an `Ok` associated type. The
  `into_inner` method is changed into `finish`, which returns
  `Result<Vec<u8>, !>`.
- opaque.rs: The `FileEncoder` adopts the delayed error handling
  strategy. Its `Ok` type is a `usize`, returning the number of bytes
  written, replacing previous uses of `FileEncoder::position`.
- Various methods that take an encoder now consume it, rather than being
  passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-06-08 07:01:26 +10:00
Nicholas Nethercote 582b9cbc45 Don't pass in a vector to Encoder::new.
It's not necessary.
2022-06-08 07:01:26 +10:00
Pietro Albini 410e2832e4
fix #71363 test by adding -Z translate-remapped-path-to-local-path=no
The test relies on library/std/src/error.rs not corresponding to a local
path, but remapping might still find the related local file of a
remapped path. To fix the test, this adds a new -Z flag to disable
finding the corresponding local path of a remapped path.
2022-06-06 11:54:01 +02:00
Jack Huey 410dcc9674 Fully stabilize NLL 2022-06-03 17:16:41 -04:00
bjorn3 7381ea019c Remove emit_unit
It doesn't do anything for all encoders
2022-06-03 17:02:14 +00:00
bors 5c780b98d1 Auto merge of #96964 - oli-obk:const_trait_mvp, r=compiler-errors
Replace `#[default_method_body_is_const]` with `#[const_trait]`

pulled out of #96077

related issues:  #67792 and #92158

cc `@fee1-dead`

This is groundwork to only allowing `impl const Trait` for traits that are marked with `#[const_trait]`. This is necessary to prevent adding a new default method from becoming a breaking change (as it could be a non-const fn).
2022-05-30 09:19:03 +00:00
Oli Scherer 4d390de4a3 Add a helper function for checking whether a default function in a trait can be treated as const 2022-05-30 08:52:25 +00:00
Deadbeef 257f06587c Remove #[default..] and add #[const_trait] 2022-05-30 08:52:24 +00:00
Michael Goulet 4638915940 Make TyCtxt implement Interner, make HashStable generic and move to rustc_type_ir 2022-05-28 12:16:05 -07:00
Michael Goulet f05a92d158 Remove some comments, inline interner fn 2022-05-28 11:38:22 -07:00
Michael Goulet a056a953f0 Initial fixes on top of type interner commit 2022-05-28 11:38:22 -07:00
bors f558990814 Auto merge of #97004 - nnethercote:proc-macro-tweaks, r=eddyb
Proc macro tweaks

Various improvements I spotted while looking through the proc macro code.

r? `@eddyb`
2022-05-27 06:09:45 +00:00
Nicholas Nethercote bc70d0db92 Rename ProcMacroDerive as DeriveProcMacro.
So it matches the existing `AttrProcMacro` and `BangProcMacro` types.
2022-05-27 15:58:35 +10:00
bors 4f68efad64 Auto merge of #96298 - petrochenkov:fromgen, r=estebank
libcore: Add `iter::from_generator` which is like `iter::from_fn`, but for coroutines instead of functions

An equally useful little helper.

I didn't follow any of the async-wg work, so I don't know why something like this wasn't added before.
2022-05-27 01:01:15 +00:00
Vadim Petrochenkov 5bf23f64cc libcore: Add iter::from_generator which is like iter::from_fn, but for coroutines instead of functions 2022-05-27 01:51:31 +03:00
bors b2c9872c6c Auto merge of #97386 - nnethercote:optimize-pos-adjustments, r=bjorn3
Optimize position adjustments

A small improvement.

r? `@bjorn3`
2022-05-26 22:01:19 +00:00
Nicholas Nethercote 2b91c40c19 Avoid adjusting file positions twice.
`imported_source_files` adjusts lots of file positions, and then calls
`new_imported_source_file`, which then adjust them all again. This
commit combines the two adjustments into one, for a small perf win.
2022-05-26 08:56:49 +10:00
Dylan DPC 006707834f
Rollup merge of #97328 - petrochenkov:nativice, r=michaelwoerister
rustc: Fix ICE in native library error reporting

Fixes https://github.com/rust-lang/rust/issues/97299
2022-05-25 17:37:20 +02:00
Dylan DPC 3c11bf3d2b
Rollup merge of #97384 - nnethercote:fix-metadata-stats, r=bjorn3
Fix metadata stats.

This commit:
- Counts some things that weren't being counted previously, and adds
  an assertion that ensure everything is counted.
- Reorders things so the `eprintln`s order matches the code order.
- Adds percentages, and makes clear that the zero bytes count is orthogonal to
  the other measurements.

Example of the new output:
```
55463779 metadata bytes, of which 18054531 bytes (32.6%) are zero
             preamble:       30 bytes ( 0.0%)
                  dep:        0 bytes ( 0.0%)
          lib feature:    17458 bytes ( 0.0%)
            lang item:      337 bytes ( 0.0%)
      diagnostic item:     1788 bytes ( 0.0%)
           native lib:        0 bytes ( 0.0%)
      foreign modules:     5113 bytes ( 0.0%)
       def-path table:   720180 bytes ( 1.3%)
               traits:      359 bytes ( 0.0%)
                impls:    64624 bytes ( 0.1%)
     incoherent_impls:      130 bytes ( 0.0%)
                  mir: 16137354 bytes (29.1%)
                 item: 23773099 bytes (42.9%)
interpret_alloc_index:      599 bytes ( 0.0%)
      proc-macro-data:        0 bytes ( 0.0%)
               tables: 10081135 bytes (18.2%)
 debugger visualizers:        0 bytes ( 0.0%)
     exported symbols:     5666 bytes ( 0.0%)
              hygiene:  1539390 bytes ( 2.8%)
      def-path hashes:  2752564 bytes ( 5.0%)
           source_map:   363540 bytes ( 0.7%)
                final:      413 bytes ( 0.0%)
```
r? `@bjorn3`
2022-05-25 10:48:31 +02:00
Nicholas Nethercote 9a926e5d6c Fix metadata stats.
This commit:
- Counts some things that weren't being counted previously, and adds
  an assertion that ensure everything is counted.
- Reorders things so the `eprintln`s order matches the code order.
- Adds percentages, and makes clear that the zero bytes count is orthogonal to
  the other measurements.

Example of the new output:
```
55463779 metadata bytes, of which 18054531 bytes (32.6%) are zero
             preamble:       30 bytes ( 0.0%)
                  dep:        0 bytes ( 0.0%)
          lib feature:    17458 bytes ( 0.0%)
            lang item:      337 bytes ( 0.0%)
      diagnostic item:     1788 bytes ( 0.0%)
           native lib:        0 bytes ( 0.0%)
      foreign modules:     5113 bytes ( 0.0%)
       def-path table:   720180 bytes ( 1.3%)
               traits:      359 bytes ( 0.0%)
                impls:    64624 bytes ( 0.1%)
     incoherent_impls:      130 bytes ( 0.0%)
                  mir: 16137354 bytes (29.1%)
                 item: 23773099 bytes (42.9%)
interpret_alloc_index:      599 bytes ( 0.0%)
      proc-macro-data:        0 bytes ( 0.0%)
               tables: 10081135 bytes (18.2%)
 debugger visualizers:        0 bytes ( 0.0%)
     exported symbols:     5666 bytes ( 0.0%)
              hygiene:  1539390 bytes ( 2.8%)
      def-path hashes:  2752564 bytes ( 5.0%)
           source_map:   363540 bytes ( 0.7%)
                final:      413 bytes ( 0.0%)
```
2022-05-25 16:36:43 +10:00
Michael Goulet d1a9a95517 Make Lazy not care about lifetimes until decode 2022-05-24 15:54:44 -07:00
Michael Goulet 2b5e592b7a Fix iterator implementation, add some inlines 2022-05-23 19:50:29 -07:00
Michael Goulet 14e5816f1b refine comments, disambiguate len for array and tables 2022-05-23 19:39:10 -07:00
Michael Goulet ca5e60b7fb split out the various responsibilities of Lazy 2022-05-23 19:39:10 -07:00
Vadim Petrochenkov c82a3706f7 rustc: Fix ICE in native library error reporting 2022-05-23 20:56:38 +03:00
bors 4f372b14de Auto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplett
Remove `crate` visibility modifier

FCP to remove this syntax is just about complete in #53120. Once it completes, this should be merged ASAP to avoid merge conflicts.

The first two commits remove usage of the feature in this repository, while the last removes the feature itself.
2022-05-21 06:38:49 +00:00
Jacob Pratt 49c82f31a8
Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
bors e6a4afc3af Auto merge of #95418 - cjgillot:more-disk, r=davidtwco
Cache more queries on disk

One of the principles of incremental compilation is to allow saving results on disk to avoid recomputing them.
This PR investigates persisting a lot of queries whose result are to be saved into metadata.
Some of the queries are cheap reads from HIR, but we may also want to get rid of these reads for incremental lowering.
2022-05-20 20:49:55 +00:00
bors c067287049 Auto merge of #97024 - lcnr:simplify_type-sus, r=<try>
`simplify_type` improvements and cursed docs

the existing `TreatParams` enum pretty much mixes everything up. Not sure why this looked right to me in #94057

This also includes two changes which impact perf:
- `ty::Projection` with inference vars shouldn't be treated as a rigid type, even if fully normalized
- `ty::Placeholder` only unifies with itself, so actually return `Some` for them

r? `@nikomatsakis`
2022-05-19 13:08:51 +00:00
Michael Woerister 6411fef3ab Properly apply path prefix remapping paths emitted into debuginfo. 2022-05-18 12:19:01 +02:00
Michael Woerister 583880b0ff Move logic for making potentially remapped paths absolute into helper method. 2022-05-18 11:42:43 +02:00
lcnr db19e2bd01 fix simplify_type 2022-05-18 09:00:30 +02:00
bors 735efc0c70 Auto merge of #97012 - oli-obk:🦀_intrinsics, r=davidtwco
Add a query for checking whether a function is an intrinsic.

work towards #93145

This will reduce churn when we add more ways to declare intrinsics

r? `@scottmcm`
2022-05-17 09:39:26 +00:00
bors 7355d971a9 Auto merge of #96825 - kckeiks:remove-item-like-visitor-trait, r=cjgillot
Retire `ItemLikeVisitor` trait

Issue #95004
cc `@cjgillot`
2022-05-17 06:51:45 +00:00
Oli Scherer 0a6b69106e Add a query for checking whether a function is an intrinsic. 2022-05-16 07:07:44 +00:00
Vadim Petrochenkov 4fa24bcb54 rustc: Stricter checking for #[link] attributes 2022-05-15 02:45:47 +03:00
Miguel Guarniz f975d05116 rename visit item-like methods
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00