Commit Graph

676 Commits

Author SHA1 Message Date
Oli Scherer
ee3c835018 Always import all tracing macros for the entire crate instead of piecemeal by module 2022-09-01 14:54:27 +00:00
Oli Scherer
d3b22c7267 Directly use the instrument macro instead of its full path 2022-09-01 14:53:46 +00:00
bors
eac6c33bc6 Auto merge of #100869 - nnethercote:replace-ThinVec, r=spastorino
Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec`

`rustc_data_structures::thin_vec::ThinVec` looks like this:
```
pub struct ThinVec<T>(Option<Box<Vec<T>>>);
```
It's just a zero word if the vector is empty, but requires two
allocations if it is non-empty. So it's only usable in cases where the
vector is empty most of the time.

This commit removes it in favour of `thin_vec::ThinVec`, which is also
word-sized, but stores the length and capacity in the same allocation as
the elements. It's good in a wider variety of situation, e.g. in enum
variants where the vector is usually/always non-empty.

The commit also:
- Sorts some `Cargo.toml` dependency lists, to make additions easier.
- Sorts some `use` item lists, to make additions easier.
- Changes `clean_trait_ref_with_bindings` to take a
  `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this
  avoid some unnecessary allocations.

r? `@spastorino`
2022-09-01 08:01:06 +00:00
bors
b32223fec1 Auto merge of #100707 - dzvon:fix-typo, r=davidtwco
Fix a bunch of typo

This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-09-01 05:39:58 +00:00
Dezhi Wu
b1430fb7ca Fix a bunch of typo
This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-08-31 18:24:55 +08:00
Matthias Krüger
78e5d05ea0
Rollup merge of #101049 - JeanCASPAR:remove-span_fatal-from-ast_lowering, r=davidtwco
Remove span fatal from ast lowering

Now the crate `rustc_ast_lowering` is fully migrated to `SessionDiagnostic`.

r? ``@davidtwco``
2022-08-31 07:57:59 +02:00
JeanCASPAR
79d4f09942
Change fatal diagnostic to an error.
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2022-08-30 14:26:09 +02:00
Nilstrieb
d1ef8180f9 Revert let_chains stabilization
This reverts commit 3266460749.

This is the revert against master, the beta revert was already done in #100538.
2022-08-29 19:34:11 +02:00
Nicholas Nethercote
b38106b6d8 Replace rustc_data_structures::thin_vec::ThinVec with thin_vec::ThinVec.
`rustc_data_structures::thin_vec::ThinVec` looks like this:
```
pub struct ThinVec<T>(Option<Box<Vec<T>>>);
```
It's just a zero word if the vector is empty, but requires two
allocations if it is non-empty. So it's only usable in cases where the
vector is empty most of the time.

This commit removes it in favour of `thin_vec::ThinVec`, which is also
word-sized, but stores the length and capacity in the same allocation as
the elements. It's good in a wider variety of situation, e.g. in enum
variants where the vector is usually/always non-empty.

The commit also:
- Sorts some `Cargo.toml` dependency lists, to make additions easier.
- Sorts some `use` item lists, to make additions easier.
- Changes `clean_trait_ref_with_bindings` to take a
  `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this
  avoid some unnecessary allocations.
2022-08-29 15:42:13 +10:00
Nicholas Nethercote
22379bd9db Use &'hir Mod everywhere.
For consistency, and because it makes HIR measurement simpler and more
accurate.
2022-08-29 06:35:14 +10:00
Nicholas Nethercote
a847d5e4ce Use &'hir Ty everywhere.
For consistency, and because it makes HIR measurement simpler and more
accurate.
2022-08-29 06:35:14 +10:00
Nicholas Nethercote
db35b685a7 Use &'hir Expr everywhere.
For consistency, and because it makes HIR measurement simpler and more
accurate.
2022-08-29 06:35:14 +10:00
Jean CASPAR
e89d4fcc7d remove span_fatal from ast_lowering 2022-08-27 09:15:55 +02:00
Michael Goulet
bc1d205e4c
Rollup merge of #100724 - JeanCASPAR:migrate-ast_lowering-to-session-diagnostic, r=davidtwco
Migrate ast lowering to session diagnostic

I migrated the whole rustc_ast_lowering crate to session diagnostic *except* the for the use of `span_fatal` at /compiler/rustc_ast_lowering/src/expr.rs#L1268 because `#[fatal(...)]` is not yet supported (see https://github.com/rust-lang/rust/pull/100694).
2022-08-26 15:56:21 -07:00
Nicholas Nethercote
6087dc2054 Remove the symbol from ast::LitKind::Err.
Because it's never used meaningfully.
2022-08-23 16:56:24 +10:00
Jean CASPAR
5fef1b865f Resolve conflicts 2022-08-22 19:34:19 +02:00
Jean CASPAR
9472df10d0 Changes made in response to feedback 2022-08-22 19:24:14 +02:00
Jean CASPAR
e701c72a63 Migrate all span_err(...) in ast_lowering to SessionDiagnostic 2022-08-22 19:21:41 +02:00
Jean CASPAR
5164966591 Migrate ast_lowering::pat to SessionDiagnostic 2022-08-22 19:21:41 +02:00
Jean CASPAR
d75fd91d50 Migrate ast_lowering::ast to SessionDiagnostic 2022-08-22 19:21:39 +02:00
Jean CASPAR
1382d307d3 Migrate ast_lowering::expr to SessionDiagnostic 2022-08-22 19:21:39 +02:00
Jean CASPAR
0043d10c71 Migrate ast_lowering::lib and ast_lowering::item to SessionDiagnostic 2022-08-22 19:19:59 +02:00
Jean CASPAR
73ae38bac1 Migrate ast_lowering::path to SessionDiagnostic 2022-08-22 19:19:58 +02:00
Nicholas Nethercote
619b8abaa6 Use AttrVec in more places.
In some places we use `Vec<Attribute>` and some places we use
`ThinVec<Attribute>` (a.k.a. `AttrVec`). This results in various points
where we have to convert between `Vec` and `ThinVec`.

This commit changes the places that use `Vec<Attribute>` to use
`AttrVec`. A lot of this is mechanical and boring, but there are
some interesting parts:
- It adds a few new methods to `ThinVec`.
- It implements `MapInPlace` for `ThinVec`, and introduces a macro to
  avoid the repetition of this trait for `Vec`, `SmallVec`, and
  `ThinVec`.

Overall, it makes the code a little nicer, and has little effect on
performance. But it is a precursor to removing
`rustc_data_structures::thin_vec::ThinVec` and replacing it with
`thin_vec::ThinVec`, which is implemented more efficiently.
2022-08-22 07:35:33 +10:00
Matthias Krüger
d5dca26a94
Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov
Clean up `LitKind`

r? ``@petrochenkov``
2022-08-17 12:32:49 +02:00
Dylan DPC
2e78db3858
Rollup merge of #100610 - nnethercote:ast-and-parser-tweaks, r=spastorino
Ast and parser tweaks

r? `@spastorino`
2022-08-16 18:16:13 +05:30
bors
14a459bf37 Auto merge of #100441 - nnethercote:shrink-ast-Attribute, r=petrochenkov
Shrink `ast::Attribute`.

r? `@ghost`
2022-08-16 07:54:22 +00:00
bors
8556e6620e Auto merge of #100611 - matthiaskrgr:rollup-rxj10ur, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #100338 (when there are 3 or more return statements in the loop)
 - #100384 (Add support for generating unique profraw files by default when using `-C instrument-coverage`)
 - #100460 (Update the minimum external LLVM to 13)
 - #100567 (Add missing closing quote)
 - #100590 (Suggest adding an array length if possible)
 - #100600 (Rename Machine memory hooks to suggest when they run)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-16 05:13:38 +00:00
Matthias Krüger
76dd1663d9
Rollup merge of #100590 - TaKO8Ki:suggest-adding-array-length, r=compiler-errors
Suggest adding an array length if possible

fixes #100448
2022-08-16 06:05:59 +02:00
Nicholas Nethercote
5d3cc1713a Rename some things related to literals.
- Rename `ast::Lit::token` as `ast::Lit::token_lit`, because its type is
  `token::Lit`, which is not a token. (This has been confusing me for a
  long time.)
  reasonable because we have an `ast::token::Lit` inside an `ast::Lit`.
- Rename `LitKind::{from,to}_lit_token` as
  `LitKind::{from,to}_token_lit`, to match the above change and
  `token::Lit`.
2022-08-16 13:41:34 +10:00
bors
ef9810a3e2 Auto merge of #100237 - cjgillot:no-special-hash-hir, r=nagisa
Remove manual implementations of HashStable for hir::Expr and hir::Ty.

We do not need to force hashing HIR bodies inside those nodes. The contents of bodies are not accessible from the `hir_owner` query which used `hash_without_bodies`. When the content of a body is required, the access is still done using `hir_owner_nodes`, which continues hashing HIR bodies.
2022-08-16 02:32:47 +00:00
Nicholas Nethercote
3e04fed6fa Remove {ast,hir}::WhereEqPredicate::id.
These fields are unused.
2022-08-16 12:13:23 +10:00
Nicholas Nethercote
85a6cd6a47 Shrink ast::Attribute. 2022-08-16 11:10:13 +10:00
Takayuki Maeda
4d1b5f0d99 suggest adding an array length if possible 2022-08-16 00:16:14 +09:00
bors
6ce76091c7 Auto merge of #96745 - ehuss:even-more-attribute-validation, r=cjgillot
Visit attributes in more places.

This adds 3 loosely related changes (I can split PRs if desired):

- Attribute checking on pattern struct fields.
- Attribute checking on struct expression fields.
- Lint level visiting on pattern struct fields, struct expression fields, and generic parameters.

There are still some lints which ignore lint levels in various positions. This is a consequence of how the lints themselves are implemented. For example, lint levels on associated consts don't work with `unused_braces`.
2022-08-15 05:50:54 +00:00
Mark Rousskov
154a09dd91 Adjust cfgs 2022-08-12 16:28:15 -04:00
Eric Huss
7b36047239 Make Node::ExprField a child of Node::Expr.
This was incorrectly inserting the ExprField as a sibling of the struct
expression.

This required adjusting various parts which were looking at parent node
of a field expression to find the struct.
2022-08-11 21:48:39 -07:00
Eric Huss
dcd5177fd4 Add visitors for PatField and ExprField.
This helps simplify the code. It also fixes it to use the correct parent
when lowering. One consequence is the `non_snake_case` lint needed
to change the way it looked for parent nodes in a struct pattern.

This also includes a small fix to use the correct `Target` for
expression field attribute validation.
2022-08-11 21:48:39 -07:00
Eric Huss
b651c1cebe Check attributes on struct expression fields.
Attributes on struct expression fields were not being checked for
validity. This adds the fields as HIR nodes so that `CheckAttrVisitor`
can visit those nodes to check their attributes.
2022-08-11 21:48:39 -07:00
Eric Huss
1b464c73b7 Check attributes on pattern fields.
Attributes on pattern struct fields were not being checked for validity.
This adds the fields as HIR nodes so that the `CheckAttrVisitor` can
visit those nodes to check their attributes.
2022-08-11 21:48:39 -07:00
Matthias Krüger
8237efc52d
Rollup merge of #100392 - nnethercote:simplify-visitors, r=cjgillot
Simplify visitors

By removing some unused arguments.

r? `@cjgillot`
2022-08-11 22:53:08 +02:00
Matthias Krüger
e221aafae6
Rollup merge of #100307 - nnethercote:fix-96847, r=cjgillot
Fix #96847

r? `@petrochenkov`
2022-08-11 22:53:05 +02:00
Nicholas Nethercote
ce78042a42 Avoid lowering a MacArgs::Eq twice.
Fixes #96847.
2022-08-11 21:06:40 +10:00
Nicholas Nethercote
232bd80130 Simplify rustc_ast::visit::Visitor::visit_poly_trait_ref.
It is passed an argument that is never used.
2022-08-11 11:10:01 +10:00
Nicholas Nethercote
8c5303898e Simplify rustc_hir::intravisit::Visitor::visit_variant_data.
It has four arguments that are never used. This avoids lots of argument
passing in functions that feed into `visit_variant_data`.
2022-08-11 10:54:01 +10:00
Camille GILLOT
9701845287 Do not consider method call receiver as an argument in AST. 2022-08-10 18:34:54 +02:00
Santiago Pastorino
750a04ea7f
Add docs for get_remapped_def_id 2022-08-09 16:39:02 -03:00
Santiago Pastorino
457ff7c56c
Iterate def_ids map backwards to try first the latest mappings (it's a stack) 2022-08-09 16:33:19 -03:00
Camille GILLOT
5d75ca5ef4 Remove unused hashing infra. 2022-08-07 17:51:55 +02:00
Camille GILLOT
f6af4efec5 Use start_point instead of next_point to point to elided lifetime ampersand. 2022-08-07 14:35:11 +02:00
Santiago Pastorino
4170d7390b
Fix typo 2022-08-04 15:13:47 -03:00
Santiago Pastorino
065e497630
Improve opt_local_def_id docs 2022-08-04 15:13:44 -03:00
Santiago Pastorino
bf1c7da147
Improve record_def_id_remap docs 2022-08-04 12:47:19 -03:00
Santiago Pastorino
ece52451f6
Do not collect lifetimes with Infer resolution 2022-08-04 12:40:00 -03:00
Santiago Pastorino
45991f9175
Use span_bug instead of panic 2022-08-04 12:07:03 -03:00
Santiago Pastorino
5e71659983
Add docs to record_elided_anchor 2022-08-04 11:27:02 -03:00
Santiago Pastorino
f8b1b2bdfb
Extract record_elided_anchor 2022-08-04 11:27:02 -03:00
Santiago Pastorino
9f10f589a7
Move new_remapping inside with_hir_id_owner 2022-08-04 11:27:02 -03:00
Santiago Pastorino
1ece866cf1
Add documentation for create_lifetime_defs 2022-08-04 11:27:02 -03:00
Santiago Pastorino
2f353d1f72
Add more debug calls 2022-08-04 11:27:01 -03:00
Santiago Pastorino
cab67404a4
Add documentation about lifetime args 2022-08-04 11:27:01 -03:00
Santiago Pastorino
a3bfdc77a7
Add documentation about lifetime_defs 2022-08-04 11:27:01 -03:00
Santiago Pastorino
9c7de6fb3c
Move hir_bounds after lifetime_defs 2022-08-04 11:27:01 -03:00
Santiago Pastorino
3f7db370ef
captures -> collected_lifetimes 2022-08-04 11:27:00 -03:00
Santiago Pastorino
12fa3393a5
Move lifetimes_in_bounds call to outside with_hir_id_owner block in lower_async_fn_ret_ty 2022-08-04 11:27:00 -03:00
Santiago Pastorino
4b9b5838ac
Move lifetimes_in_bounds call to outside with_hir_id_owner block in lower_opaque_impl_trait 2022-08-04 11:27:00 -03:00
Santiago Pastorino
76b518fc83
Document what collected_lifetimes vec containts 2022-08-04 11:27:00 -03:00
Santiago Pastorino
d85720a083
Document lower_opaque_impl_trait 2022-08-04 11:26:59 -03:00
Santiago Pastorino
6289d0eb53
with_lifetime_binder is now lower_lifetime_binder and doesn't need a closure 2022-08-04 11:26:59 -03:00
Santiago Pastorino
11e00f502a
Add comments on with_remapping 2022-08-04 11:26:59 -03:00
Santiago Pastorino
c946cdceb4
Document opt_local_def_id 2022-08-04 11:26:59 -03:00
Santiago Pastorino
966269a464
Document generics_def_id_map field and record/get methods on it 2022-08-04 11:26:58 -03:00
Santiago Pastorino
78585098b5
Add comments about lifetime collect and create lifetime defs for RPITs 2022-08-04 11:26:58 -03:00
Santiago Pastorino
40bcbed3c7
Avoid explicitly handling res when is not needed 2022-08-04 11:26:58 -03:00
Santiago Pastorino
cd3c388418
create_and_capture_lifetime_defs -> create_lifetime_defs 2022-08-04 11:26:57 -03:00
Santiago Pastorino
13800624de
Remove captured_lifetimes and LifetimeCaptureContext and make create_lifetime_defs return the captures 2022-08-04 11:26:57 -03:00
Santiago Pastorino
1d6cebfd6b
Implement def_id based remapping 2022-08-04 11:26:57 -03:00
Santiago Pastorino
f0db1d68e6
Remove local_def_id from captured_lifetimes 2022-08-04 11:26:57 -03:00
Santiago Pastorino
2d826e27c4
Capture things as Lifetime object to simplify things 2022-08-04 11:26:57 -03:00
Santiago Pastorino
f6b4dd1541
Create new_mapping local structure and avoid checking def_ids on captures 2022-08-04 11:26:56 -03:00
Santiago Pastorino
6c6a81e48e
Remove binders_to_ignore from LifetimeCaptureContext 2022-08-04 11:26:56 -03:00
Santiago Pastorino
95158fdf3a
No need to store parent_def_id in LifetimeCaptureContext 2022-08-04 11:26:56 -03:00
Santiago Pastorino
552f6b0f81
No need to check binders to ignore on new_named_lifetime_with_res's LifetimeRes::Fresh 2022-08-04 11:26:56 -03:00
Santiago Pastorino
6041ed0775
No need to check binders to ignore on new_named_lifetime_with_res's LifetimeRes::Param 2022-08-04 11:26:55 -03:00
Santiago Pastorino
d9e6364755
new_named_lifetime_with_res's LifetimeRes::Fresh should have created def_id already 2022-08-04 11:26:55 -03:00
Santiago Pastorino
3030ab3074
new_named_lifetime_with_res's LifetimeRes::Param should have created def_id already 2022-08-04 11:26:55 -03:00
Santiago Pastorino
14ea17858d
Fail if LifetimeRes is Infer when creating def ids for lifetimes copies 2022-08-04 11:26:55 -03:00
Santiago Pastorino
c390bda356
Record RPITs elided lifetimes in Rptr Tys 2022-08-04 11:26:55 -03:00
Santiago Pastorino
1802d45b12
Record RPITs elided lifetimes in path segments 2022-08-04 11:26:54 -03:00
Santiago Pastorino
81c4d2371a
Restructure visit_ty in a more clear way 2022-08-04 11:26:54 -03:00
Santiago Pastorino
05b989e16e
Skip lifetimes in binders when visiting 2022-08-04 11:26:54 -03:00
Santiago Pastorino
4f334f2b97
Move LifetimeCollectVisitor to rustc_ast_lowering 2022-08-04 11:26:54 -03:00
Santiago Pastorino
9f77688d17
Completely remove captures flag 2022-08-04 11:26:53 -03:00
Santiago Pastorino
20c88a2a30
Do not execute captures code when lowering lifetimes as GenericArg 2022-08-04 11:26:53 -03:00
Santiago Pastorino
9c0d9babd1
Do not execute captures code for async fns 2022-08-04 11:26:53 -03:00
Santiago Pastorino
5a184acfc6
There's no need to check binders_to_ignore using the old code anymore 2022-08-04 11:26:53 -03:00
Santiago Pastorino
19dcbd151b
Explicitly gather lifetimes and definitions for bare async fns 2022-08-04 11:26:52 -03:00
Santiago Pastorino
25825cd4fa
Extract create_and_capture_lifetime_defs function 2022-08-04 11:26:52 -03:00
Santiago Pastorino
fac763168f
Remove NEW_COLLECT_LIFETIMES env var 2022-08-04 11:26:52 -03:00
Santiago Pastorino
399609e841
Add debug! calls 2022-08-04 11:26:52 -03:00