Commit Graph

816 Commits

Author SHA1 Message Date
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
Santiago Pastorino cda2c04592
Explicitly gather lifetimes and definitions in RPIT 2022-08-04 11:26:51 -03:00
Santiago Pastorino 84a24a1b3c
Unroll while_capturing_lifetimes into lower_opaque_impl_trait 2022-08-04 11:26:51 -03:00
Santiago Pastorino 0f11a0cd24
Add captures flag to capture or not while lowering 2022-08-04 11:26:51 -03:00
Santiago Pastorino b14c9571fa
Make lower_generic_bound_predicate receive AST bounds instead of HIR bounds 2022-08-04 11:26:51 -03:00
Santiago Pastorino 5c23a2e5a6
Remove old docs on lower_async_fn_ret_ty 2022-08-04 11:26:50 -03:00
Camille GILLOT 110f0656cb Store associated item defaultness in impl_defaultness. 2022-08-01 21:38:16 +02:00
Camille GILLOT 10be0dd8df Replace LifetimeRes::Anonymous by LifetimeRes::Infer. 2022-07-26 19:00:31 +02:00
Camille GILLOT ab63591f00 Remove the distinction between LifetimeName::Implicit and LifetimeName::Underscore. 2022-07-26 19:00:31 +02:00
bors 6dbae3ad19 Auto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkov
Resolve function lifetime elision on the AST

~Based on https://github.com/rust-lang/rust/pull/97720~

Lifetime elision for functions is purely syntactic in nature, so can be resolved on the AST.
This PR replicates the elision logic and diagnostics on the AST, and replaces HIR-based resolution by a `delay_span_bug`.

This refactor allows for more consistent diagnostics, which don't have to guess the original code from HIR.

r? `@petrochenkov`
2022-07-25 20:02:55 +00:00
Camille GILLOT 3c5048d2ec Report elision failures on the AST. 2022-07-25 19:19:23 +02:00
Michael Woerister 88f6c6d8a0 Remove unused StableMap and StableSet types from rustc_data_structures 2022-07-20 13:11:39 +02:00
Matthias Krüger 4815f94c51
Rollup merge of #99401 - TaKO8Ki:avoid-symbol-to-&str-conversions, r=nnethercote
Avoid `Symbol` to `&str` conversions

`Symbol::as_str` is a slowish operation, so this patch removes some usages of it.
2022-07-19 13:30:46 +02:00
Takayuki Maeda a22934bea1 avoid `Symbol` to `&str` conversions 2022-07-18 14:25:34 +09:00
Caio 3266460749 Stabilize `let_chains` 2022-07-16 20:17:58 -03:00
Aaron Hill c7b31d0ac9
Correctly handle path stability for 'use tree' items
PR #5956 started checking the stability of path segments.
However, this was not applied to 'use tree' items
(e.g. 'use some::path::{ItemOne, ItemTwo}') due to the way
that we desugar these items in HIR lowering.

This PR modifies 'use tree' lowering to preserve resolution
information, which is needed by stability checking.
2022-07-15 17:47:14 -05:00
bors f1a8854f9b Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #97720 (Always create elided lifetime parameters for functions)
 - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`)
 - #98705 (Implement `for<>` lifetime binder for closures)
 - #99126 (remove allow(rustc::potential_query_instability) in rustc_span)
 - #99139 (Give a better error when `x dist` fails for an optional tool)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-14 11:00:30 +00:00
Dylan DPC e5a86d7358
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
Implement `for<>` lifetime binder for closures

This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following:

```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
//       ^^^^^^^^^^^--- new!
```

cc ``@Aaron1011`` ``@cjgillot``
2022-07-14 14:14:21 +05:30
Joshua Nelson 3c9765cff1 Rename `debugging_opts` to `unstable_opts`
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
Maybe Waffle df4fee9841 Add an indirection for closures in `hir::ExprKind`
This helps bring `hir::Expr` size down, `Closure` was the biggest
variant, especially after `for<>` additions.
2022-07-12 21:00:13 +04:00
Maybe Waffle c2dbd62c7c Lower closure binders to hir & properly check them 2022-07-12 21:00:03 +04:00
Maybe Waffle 40ae7b5b8e Parse closure binders
This is first step in implementing RFC 3216.
- Parse `for<'a>` before closures in ast
  - Error in lowering
- Add `closure_lifetime_binder` feature
2022-07-12 16:25:16 +04:00
Ding Xiang Fei 8e4a971084
extract method to read scrutinee conditionally 2022-07-11 23:20:38 +02:00
Ding Xiang Fei 1cd30e7b32
move else block into the `Local` struct 2022-07-11 23:20:37 +02:00
Ding Xiang Fei 6c529ded86
lower let-else in MIR instead 2022-07-11 23:20:36 +02:00
bors 38b72154de Auto merge of #98637 - cjgillot:bare-trait-anon-lt, r=petrochenkov
Create fresh lifetime parameters for bare fn trait too

The current code fails to account for the equivalence between `dyn FnMut(&mut u8)` and bare `FnMut(&mut u8)`, and treated them differently.

This PR introduces a special case for `Fn` traits, which are always fully resolved.

Fixes #98616
Fixes #98726
This will require a beta-backport, as beta contains that bug.

r? `@petrochenkov`
2022-07-11 17:09:37 +00:00
bors 0f573a0c54 Auto merge of #95573 - cjgillot:lower-query, r=michaelwoerister
Make lowering a query

Split from https://github.com/rust-lang/rust/pull/88186.

This PR refactors the relationship between lowering and the resolver outputs in order to make lowering itself a query.
In a first part, lowering is changed to avoid modifying resolver outputs, by maintaining its own data structures for creating new `NodeId`s and so.

Then, the `TyCtxt` is modified to allow creating new `LocalDefId`s from inside it. This is done by:
- enclosing `Definitions` in a lock, so as to allow modification;
- creating a query `register_def` whose purpose is to declare a `LocalDefId` to the query system.

See `TyCtxt::create_def` and `TyCtxt::iter_local_def_id` for more detailed explanations of the design.
2022-07-07 18:14:44 +00:00
bors e78e747f53 Auto merge of #98827 - aDotInTheVoid:suggest-extern-block, r=nagisa
Suggest using block for `extern "abi" fn` with no body

`@rustbot` modify labels: +A-diagnostics
2022-07-07 04:18:47 +00:00
Camille GILLOT 32a30cad03 Use DefIdTree instead of re-implementing it. 2022-07-06 23:30:00 +02:00
Camille GILLOT 8fc3deb1b4 Remove `sess` field from LoweringContext. 2022-07-06 23:15:57 +02:00
Camille GILLOT 74be945820 Expand comment in `with_hir_id_owner`. 2022-07-06 23:15:11 +02:00
Camille GILLOT 682f57656e Do not create a new NodeId when not used. 2022-07-06 23:10:36 +02:00
Camille GILLOT fb060fb774 Remove useless branch. 2022-07-06 23:09:29 +02:00
Camille GILLOT 250c71b85d Make AST lowering a query. 2022-07-06 23:04:55 +02:00
Nixon Enraght-Moony 18ca2946e0 ast: Add span to `Extern` 2022-07-02 23:30:03 +01:00
Camille GILLOT 21a12e8ab7 Handle fresh lifetimes on bare trait objects. 2022-07-02 09:21:55 +02:00
Cameron Steffen ec82bc1996 Factor out hir::Node::Binding 2022-07-01 10:04:19 -05:00
Nicholas Nethercote 7c40661ddb Update `smallvec` to 1.8.1.
This pulls in https://github.com/servo/rust-smallvec/pull/282, which
gives some small wins for rustc.
2022-06-27 08:48:55 +10:00
Camille GILLOT 7437136f0e Use CreateParameter mode for closures too. 2022-06-21 21:13:43 +02:00
Camille GILLOT 32af719b07 Always create parameters for functions-like types. 2022-06-21 21:13:41 +02:00
Camille GILLOT bc6a2c11ee Leave the responsibility to create `Fresh` lifetimes to lowering. 2022-06-19 22:32:43 +02:00
bors 3a8b0144c8 Auto merge of #98106 - cjgillot:split-definitions, r=michaelwoerister
Split up `Definitions` and `ResolverAstLowering`.

Split off https://github.com/rust-lang/rust/pull/95573

r? `@michaelwoerister`
2022-06-17 10:00:11 +00:00
Yuki Okushi bfc6c90115
Rollup merge of #98119 - EdwinRy:path-parenthesized-type-error, r=estebank
Refactor path segment parameter error

This PR attempts to rewrite the error handling for an unexpected parenthesised type parameters to:
- Use provided data instead of re-parsing the whole span
- Add a multipart suggestion to reflect on the changes with an underline
- Remove the unnecessary "if" nesting
2022-06-16 07:24:43 +09:00
Camille GILLOT ae5959f4ba Consume resolutions for lowering separately. 2022-06-15 19:42:43 +02:00
Camille GILLOT 8ffbd814af Update next_node_id. 2022-06-15 19:41:41 +02:00
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
EdwinRy 71a98e1a4e Refactor path segment parameter error 2022-06-15 02:50:34 +01:00
EdwinRy c8b411ebf1 rename function and remove return type 2022-06-15 01:06:40 +01:00
Camille GILLOT 34e4d72929 Separate `source_span` and `expn_that_defined` from `Definitions`. 2022-06-14 22:45:51 +02:00
Camille GILLOT b676edd641 Do not modify the resolver outputs. 2022-06-14 22:44:27 +02:00
Camille GILLOT 603746a35e Make ResolverAstLowering a struct. 2022-06-14 22:44:27 +02:00
Takayuki Maeda 77d6176e69 remove unnecessary `to_string` and `String::new` 2022-06-13 15:48:40 +09:00
Michael Goulet 5f7474e6dc Address comments 2022-06-11 16:38:48 -07:00
Michael Goulet 9c47afe9fa Handle empty where-clause better 2022-06-11 16:27:01 -07:00
Camille GILLOT 3039cfeb6a Make `ExprKind::Closure` a struct variant. 2022-06-12 00:16:27 +02:00
Santiago Pastorino 4ae69f8617
Extract lower_generic_and_bounds function 2022-06-07 18:29:07 -03:00
Santiago Pastorino 1e6ed67d37
Extract lower_generic_param_kind 2022-06-07 18:29:07 -03:00
Santiago Pastorino a22aad32eb
Instrument important fns in AST lowering 2022-06-07 18:29:06 -03:00
Camille GILLOT a07290047e Compute lifetimes in scope at diagnostic time. 2022-06-04 15:28:15 +02:00
bors c3384ea35c Auto merge of #97717 - matthiaskrgr:rollup-lalaii2, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #97446 (Make hir().get_generics and generics_of consistent.)
 - #97656 (Add a suggestion to replace parentheses with angle brackets on associated trait constraint)
 - #97692 (Add `#T-types/nominated` zulip notification)
 - #97696 (Do not ICE when failing to normalize during inlining.)
 - #97702 (Remove useless LocalDefId in ImplTraitContext::Universal.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-04 02:10:35 +00:00
bors f15370b4e4 Auto merge of #97670 - spastorino:simplify-universal-impl-trait-lowering2, r=Dylan-DPC
Make params be SmallVec as originally was

r? `@cjgillot`
It was originally a [`SmallVec`](https://github.com/rust-lang/rust/pull/97598/files#diff-0a61b538a3cec072c76fecae4635af6a12ec3256860029ac70549c2aa53ab394L1497), I've mistakenly changed it [here](https://github.com/rust-lang/rust/pull/97598/files#diff-0a61b538a3cec072c76fecae4635af6a12ec3256860029ac70549c2aa53ab394R1377) to a `Vec`
2022-06-03 23:29:30 +00:00
Matthias Krüger a88d94b072
Rollup merge of #97702 - cjgillot:no-universal-did, r=spastorino
Remove useless LocalDefId in ImplTraitContext::Universal.
2022-06-04 00:42:52 +02:00
Matthias Krüger 401be78f2c
Rollup merge of #97656 - EdwinRy:error_ast_low_type_contraint_parentheses, r=cjgillot
Add a suggestion to replace parentheses with angle brackets on associated trait constraint

This implements a requested suggestion FIXME in [`compiler/rustc_ast_lowering/src/lib.rs` ](9598b4b594/compiler/rustc_ast_lowering/src/lib.rs (L921))

The suggestion asks for the parentheses to either be replaced with angle brackets or removed completely depending on whether there are arguments provided within.

![image](https://user-images.githubusercontent.com/20026256/171770414-ab60bfe2-ae27-44b0-964d-9ffcc32a7475.png)

![image](https://user-images.githubusercontent.com/20026256/171770383-ca8a2766-b3aa-43e3-8ba4-ae18874886ce.png)

r? `@oli-obk`
2022-06-04 00:42:50 +02:00
Camille GILLOT 4120080d66 Remove useless LocalDefId in ImplTraitContext::Universal. 2022-06-03 20:17:12 +02:00
EdwinRy cd03fe18d8 Suggest replace parentheses with angle brackets 2022-06-03 16:48:59 +01:00
Camille GILLOT b1294e86bb Manipulate lifetimes by LocalDefId for region resolution. 2022-06-03 12:03:20 +02:00
bors 3a90bedb33 Auto merge of #96296 - cjgillot:remove-label-lt-shadow, r=petrochenkov
Remove label/lifetime shadowing warnings

This PR removes some pre-1.0 shadowing warnings for labels and lifetimes.

The current behaviour of the compiler is to warn
* labels that shadow unrelated labels in the same function --> removed
```rust
'a: loop {}
'a: loop {} // STOP WARNING
```

* labels that shadow enclosing labels --> kept, but only if shadowing is hygienic
```rust
'a: loop {
  'a: loop {} // KEEP WARNING
}
```

* labels that shadow lifetime --> removed
```rust
fn foo<'a>() {
  'a: loop {} // STOP WARNING
}
```

* lifetimes that shadow labels --> removed
```rust
'a: loop {
  let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>; // STOP WARNING
}
```

* lifetimes that shadow lifetimes --> kept
```rust
fn foo<'a>() {
  let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>; // KEEP WARNING
}
```

Closes https://github.com/rust-lang/rust/issues/31745.

-----

From `@petrochenkov` in https://github.com/rust-lang/rust/pull/95781#issuecomment-1105199014
> I think we should remove these silly checks entirely.
> They were introduced long time ago in case some new language features appear and require this space.
> Now we have another mechanism for such language changes - editions, and if "lifetimes in expressions" or something like that needs to be introduced it could be introduced as an edition change.
> However, there was no plans to introduce anything like for years, so it's unlikely that even the edition mechanism will be necessary.

r? rust-lang/lang
2022-06-03 07:27:09 +00:00
Camille GILLOT c75409d5e4 Do not lower generic lifetime params when AST resolution emitted an error. 2022-06-03 08:26:10 +02:00
Santiago Pastorino b051fcaefe
Make params be SmallVec as originally was 2022-06-02 23:42:49 -03:00
bors 42bcd41d4d Auto merge of #97598 - spastorino:simplify-universal-impl-trait-lowering, r=cjgillot
Simplify universal impl trait lowering

Closes #96644

r? `@cjgillot`
2022-06-02 21:37:38 +00:00
Santiago Pastorino 15a82d6917
Always assert that impl_trait_def|bounds are empty at start 2022-06-01 15:38:37 -03:00
Santiago Pastorino 67deaf9fea
instrument lower_fn_decl 2022-06-01 15:02:15 -03:00
Santiago Pastorino 2de2520e94
Split extend + inner chain into to extend calls 2022-06-01 14:48:14 -03:00
Santiago Pastorino b3bc438f56
Add debug_assert comment
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2022-06-01 14:43:16 -03:00
est31 0a24b9493b Remove #[rustc_box] attr during lowering 2022-06-01 02:44:12 +02:00
est31 cfc21deebd Add #[rustc_box]
This commit adds an alternative content boxing syntax,
and uses it inside alloc.

The usage inside the very performance relevant code in
liballoc is the only remaining relevant usage of box syntax
in the compiler (outside of tests, which are comparatively
easy to port).

box syntax was originally designed to be used by all Rust
developers. This introduces a replacement syntax more tailored
to only being used inside the Rust compiler, and with it,
lays the groundwork for eventually removing box syntax.
2022-06-01 02:28:34 +02:00
Santiago Pastorino 15f2b119b1
Fix lower_generics rustdocs 2022-05-31 17:40:50 -03:00
Santiago Pastorino 2ade55d908
Inline lower_generics_mut and remove GenericsCtor 2022-05-31 16:57:16 -03:00
Santiago Pastorino d327db9319
Remove ImplTraitContext::reborrow 2022-05-31 16:49:27 -03:00
Santiago Pastorino 208ffbbe86
derive Copy, Clone, PartialEq, Eq for ImplTraitContext 2022-05-31 16:47:53 -03:00
Santiago Pastorino bd3a097d64
Move lower_generics definition to item.rs 2022-05-31 15:33:51 -03:00
Santiago Pastorino d5ab8b2f5b
Rename add_implicit_generics to lower_generics 2022-05-31 15:32:05 -03:00
Santiago Pastorino e080298e35
Replace calls to lower_generics with calls to add_implicit_generics 2022-05-31 15:30:14 -03:00
Santiago Pastorino 190b4a7152
Add itctx: ImplTraitContext arg to add_implicit_generics 2022-05-31 14:55:49 -03:00
Santiago Pastorino 1a71103c93
Take and restore fields in with_hir_id_owner calls 2022-05-31 14:53:32 -03:00
Santiago Pastorino 3d6eae8cd2
Move defs and bounds from Universal to LoweringContext 2022-05-31 12:40:34 -03:00
Vadim Petrochenkov 8e8fb4f49e rustc_parse: Move AST -> TokenStream conversion logic to `rustc_ast` 2022-05-22 12:01:07 +03:00
Yuki Okushi 6ef4911b99
Rollup merge of #97236 - cjgillot:recover-lifetime-res, r=jackh726
Recover when resolution did not resolve lifetimes.

This can happen for items inside a foreign fn's body, which are not visited at all.

Fixes https://github.com/rust-lang/rust/issues/97193
Fixes https://github.com/rust-lang/rust/issues/97194
2022-05-22 11:53:07 +09:00
Camille GILLOT 075429f76b Recover when resolution did not resolve lifetimes. 2022-05-21 09:39:41 +02:00
Jacob Pratt 49c82f31a8
Remove `crate` visibility usage in compiler 2022-05-20 20:04:54 -04:00
bors 07ae142d77 Auto merge of #96863 - SparrowLii:let, r=michaelwoerister
use `hir::Let` in `hir::Guard::IfLet`

This PR fixes the FIXME about using `hir::Let` in `hir::Guard::IfLet`
2022-05-18 17:48:46 +00:00
SparrowLii 5251a80c0a use hir::Let in hir::Guard 2022-05-09 20:35:58 +08:00
bors ed3164baf0 Auto merge of #96770 - flip1995:fix-trait-type-in-bounds, r=cjgillot
Track if a where bound comes from a impl Trait desugar

With https://github.com/rust-lang/rust/pull/93803 `impl Trait` function arguments get desugared to hidden where bounds. However, Clippy needs to know if a bound was originally a `impl Trait` or an actual bound. This adds a field to the `WhereBoundPredicate` struct to keep track of this information during AST->HIR lowering.

r? `@cjgillot`

cc `@estebank` (as the reviewer of #93803)
2022-05-08 14:10:12 +00:00
flip1995 dd1ff405e3
Track if a where bound comes from a impl Trait desugar
With #93803 `impl Trait` function arguments get desugared to hidden
where bounds. However, Clippy needs to know if a bound was originally a
impl Trait or an actual bound. This adds a field to the
`WhereBoundPredicate` struct to keep track of this information during
HIR lowering.
2022-05-07 17:10:30 +02:00
bors 574830f573 Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors
Begin fixing all the broken doctests in `compiler/`

Begins to fix #95994.
All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are.
There are also a few that I marked `ignore` that could maybe be made to work but seem less important.
Each `ignore` has a rough "reason" for ignoring after it parentheses, with

- `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax"
- `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy.
- `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR.
- `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup.

Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful.

I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-07 06:30:29 +00:00
bors 4c60a0ea5b Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov
Overhaul `MacArgs`

Motivation:
- Clarify some code that I found hard to understand.
- Eliminate one use of three places where `TokenKind::Interpolated` values are created.

r? `@petrochenkov`
2022-05-04 21:16:28 +00:00
Nicholas Nethercote 99f5945f85 Overhaul `MacArgs::Eq`.
The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.
2022-05-05 07:06:12 +10:00
bors 1b2e0b60cc Auto merge of #95380 - compiler-errors:unit-destructure-assign, r=nikomatsakis
Fix unit struct/enum variant in destructuring assignment

See https://github.com/rust-lang/rfcs/blob/master/text/2909-destructuring-assignment.md#guide-level-explanation, "including **unit** and tuple structs"

Fixes #94319
2022-05-03 22:29:58 +00:00
Elliot Roberts 7907385999 fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
Scott McMurray e094ee5f10 Add `do yeet` expressions to allow experimentation in nightly
Using an obviously-placeholder syntax.  An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point.

But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
2022-04-30 17:40:27 -07:00
Camille GILLOT 74583852e8 Save colon span to suggest bounds. 2022-04-30 13:55:17 +02:00
Camille GILLOT 94449e6101 Store all generic bounds as where predicates. 2022-04-30 13:55:13 +02:00
Camille GILLOT 05b29f9a92 Inline WhereClause into Generics. 2022-04-30 13:51:49 +02:00
Camille GILLOT 71b4e2d852 Box HIR Generics and Impl. 2022-04-30 13:51:49 +02:00
Nicholas Nethercote cde25f8dbe Simplify `lower_mac_args`.
The `token` is always an interpolated non-terminal expression, and
always a literal in valid code. This commit simplifies the processing
accordingly, by directly extracting and using the literal.
2022-04-29 15:14:31 +10:00
Vadim Petrochenkov 2733ec1be3 rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter` 2022-04-28 10:04:29 +03:00
bors c95346b8ac Auto merge of #91557 - cjgillot:ast-lifetimes-named, r=petrochenkov
Perform lifetime resolution on the AST for lowering

Lifetime resolution is currently implemented several times. Once during lowering in order to introduce in-band lifetimes, and once in the resolve_lifetimes query. However, due to the global nature of lifetime resolution and how it interferes with hygiene, it is better suited on the AST.

This PR implements a first draft of lifetime resolution on the AST. For now, we specifically target named lifetimes and everything we need to remove lifetime resolution from lowering. Some diagnostics have already been ported, and sometimes made more precise using available hygiene information. Follow-up PRs will address in particular the resolution of anonymous lifetimes on the AST.

We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes.

r? `@petrochenkov`
2022-04-27 23:13:28 +00:00
Camille GILLOT 21b6d23890 Collect extra lifetime parameters during late resolution. 2022-04-27 22:03:26 +02:00
Camille GILLOT b590e3062c Refactor generic collection. 2022-04-27 22:03:19 +02:00
Camille GILLOT 6857a8d14e Create a specific struct for lifetime capture. 2022-04-27 22:03:12 +02:00
Camille GILLOT f901df3739 Handle TAIT. 2022-04-27 22:00:44 +02:00
Camille GILLOT f385f856cd Use LifetimeRes during lowering. 2022-04-27 22:00:15 +02:00
Camille GILLOT 4bbe078d92 Drop vis in Item. 2022-04-23 09:59:24 +02:00
Camille GILLOT a6e3124d2c Drop vis in ImplItem. 2022-04-23 09:57:00 +02:00
Camille GILLOT 2827007d32 Drop vis from ForeignItem. 2022-04-23 09:56:37 +02:00
Camille GILLOT a62680d108 Drop vis in FieldDef. 2022-04-23 09:56:15 +02:00
Camille GILLOT 10d10efb21 Stop visiting visibility. 2022-04-23 09:53:45 +02:00
Camille GILLOT a9e13fa553 Lint elided lifetimes in path on the AST. 2022-04-17 11:03:34 +02:00
Camille GILLOT fc9f25531a Report undeclared lifetimes on AST. 2022-04-17 11:03:34 +02:00
bors 080d5452e1 Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisa
Implement sym operands for global_asm!

Tracking issue: #93333

This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are:
- At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`.
- At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails).
  - `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`.
  - `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to.
- The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression.
- At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details.
  - On Mach-O, all symbols have a leading underscore.
  - On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall.
  - No mangling is needed on other platforms.

r? `@nagisa`
cc `@eddyb`
2022-04-16 04:46:01 +00:00
Dylan DPC bdbf0998f3
Rollup merge of #95194 - kckeiks:update-algo-in-find-use-placement, r=pnkfelix
remove find_use_placement

A more robust solution to finding where to place use suggestions was added in #94584.
The algorithm uses the AST to find the span for the suggestion so we pass this span
down to the HIR during lowering and use it instead of calling `find_use_placement`

Fixes #94941
2022-04-15 20:50:45 +02:00
Amanieu d'Antras dc345d8bff Reimplement lowering of sym operands for asm! so that it also works with global_asm! 2022-04-14 15:32:03 +01:00
Michael Goulet 17f5c4d255 Fix unit struct/enum variant in destructuring assignment 2022-04-06 19:28:27 -07:00
Michael Howell 6ece80fcb6 diagnostics: use correct span for const generics
Fixes #95616
2022-04-04 12:16:20 -07:00
Fausto 8c2353b6c1 remove find_use_placement
A more robust solution to finding where to place use suggestions was added.
The algorithm uses the AST to find the span for the suggestion so we pass this span
down to the HIR during lowering and use it.

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-03-31 17:20:03 -04:00
Camille GILLOT 6b099db18c Record item-likes in ItemLowerer. 2022-03-31 13:48:16 +02:00
Camille GILLOT e5d482eeca Create a new LoweringContext for each item-like. 2022-03-31 13:47:56 +02:00
Camille GILLOT 6e4fb2038a Make lowering pull-based. 2022-03-31 13:47:22 +02:00
Camille GILLOT 41902f2859 Implement with_parent_item_lifetime_defs on ItemLowerer. 2022-03-31 13:47:02 +02:00
Camille GILLOT dc8b6b4be4 Move lower_crate outside the LoweringContext. 2022-03-31 13:46:40 +02:00
Camille GILLOT 4b598d3f75 Stop emitting lints during lowering. 2022-03-31 13:46:06 +02:00
Camille GILLOT b29fa94d22 Remove mutability in ResolverAstLowering. 2022-03-31 13:24:33 +02:00
Dylan DPC 1c3657b20d
Rollup merge of #95011 - michaelwoerister:awaitee_field, r=tmandry
async: Give predictable name to binding generated from .await expressions.

This name makes it to debuginfo and allows debuggers to identify such bindings and their captured versions in suspended async fns.

This will be useful for async stack traces, as discussed in https://internals.rust-lang.org/t/async-debugging-logical-stack-traces-setting-goals-collecting-examples/15547.

I don't know if this needs some discussion by ````@rust-lang/compiler,```` e.g. about the name of the binding (`__awaitee`) or about the fact that this PR introduces a (soft) guarantee about a compiler generated name. Although, regarding the later, I think the same reasoning applies here as it does for debuginfo in general.

r? ````@tmandry````
2022-03-31 00:26:30 +02:00
Michael Woerister 78e27e2c7a async: Give predictable, reserved name to binding generated from .await expressions.
This name makes it to debuginfo and allows debuggers to identify such bindings and
their captured versions in suspended async fns.
2022-03-30 11:12:45 +02:00
Yuri Astrakhan 7e8201ae0a Spellchecking some comments
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30 01:39:38 -04:00
Dylan DPC 270a41c33e
Rollup merge of #94960 - codehorseman:master, r=oli-obk
Fix many spelling mistakes

Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-17 22:55:05 +01:00
mark bb8d4307eb rustc_error: make ErrorReported impossible to construct
There are a few places were we have to construct it, though, and a few
places that are more invasive to change. To do this, we create a
constructor with a long obvious name.
2022-03-16 10:35:24 -05:00
codehorseman 01dbfb3eb2 resolve the conflict in compiler/rustc_session/src/parse.rs
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-16 20:12:30 +08:00
bors 95561b336c Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuber
More robust fallback for `use` suggestion

Our old way to suggest where to add `use`s would first look for pre-existing `use`s in the relevant crate/module, and if there are *no* uses, it would fallback on trying to use another item as the basis for the suggestion.

But this was fragile, as illustrated in issue #87613

This PR instead identifies span of the first token after any inner attributes, and uses *that* as the fallback for the `use` suggestion.

Fix #87613
2022-03-15 03:56:33 +00:00
Camille GILLOT c8c691ff88 Update comments. 2022-03-13 23:13:58 +01:00
Camille GILLOT d3b7ea6c9e Identify anonymous lifetimes by their DefId in HIR. 2022-03-12 14:18:56 +01:00
Takayuki Maeda 51a53bf4df remove unnecessary `..` patterns 2022-03-07 02:18:36 +09:00
Jack Huey c920eb88b2 Fallback to other where clause if preferred is missing 2022-03-05 13:15:00 -05:00
Jack Huey c20b4f5584 Change syntax for TyAlias where clauses 2022-03-05 13:13:45 -05:00
Felix S. Klock II d37da1e332 Adjusted diagnostic output so that if there is no `use` in a item sequence,
then we just suggest the first legal position where you could inject a use.

To do this, I added `inject_use_span` field to `ModSpans`, and populate it in
parser (it is the span of the first token found after inner attributes, if any).
Then I rewrote the use-suggestion code to utilize it, and threw out some stuff
that is now unnecessary with this in place. (I think the result is easier to
understand.)

Then I added a test of issue 87613.
2022-03-03 18:58:37 -05:00
Felix S. Klock II b82795244e Associate multiple with a crate too. 2022-03-03 18:45:25 -05:00
Felix S. Klock II e9035f7bef refactor: prepare to associate multiple spans with a module. 2022-03-03 14:38:50 -05:00
cuishuang eb2b9441e7 compiler: fix some typos 2022-03-01 20:02:47 +08:00
bors d981633ed6 Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini
Bump bootstrap to 1.60

This bumps the bootstrap compiler to 1.60 and cleans up cfgs and Span's rustc_pass_by_value (enabled by the bootstrap bump).
2022-02-25 18:34:02 +00:00
Mark Rousskov 22c3a71de1 Switch bootstrap cfgs 2022-02-25 08:00:52 -05:00
Michael Goulet bb548a918a Remove in-band lifetimes 2022-02-24 18:50:33 -08:00
Vadim Petrochenkov 17b1afdbb2 resolve: Fix incorrect results of `opt_def_kind` query for some built-in macros
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
2022-02-24 22:54:36 +03:00
bors 8ebec97e09 Auto merge of #93438 - spastorino:node_id_to_hir_id_refactor, r=oli-obk
Node id to hir id refactor

Related to #89278

r? `@oli-obk`
2022-02-24 01:26:57 +00:00
Santiago Pastorino d82a7bc1b5
local_id is always != 0 at this point 2022-02-22 09:37:47 -03:00
Amanieu d'Antras fc41d4bf35 Take CodegenFnAttrs into account when validating asm! register operands
Checking of asm! register operands now properly takes function
attributes such as #[target_feature] and #[instruction_set] into
account.
2022-02-21 18:28:22 +00:00
Amanieu d'Antras 1ceb104851 On ARM, use relocation_model to detect whether r9 should be reserved
The previous approach of checking for the reserve-r9 target feature
didn't actually work because LLVM only sets this feature very late when
initializing the per-function subtarget.
2022-02-21 18:28:22 +00:00
Santiago Pastorino cbfa7cebee
Move trait_map to Lowering Context 2022-02-20 11:52:57 -03:00
Santiago Pastorino 7e2dd672da
Move local_id_to_def_id to Lowering Context 2022-02-20 11:47:49 -03:00
Santiago Pastorino a8d24742f8
Avoid call to lower_node_id when not needed 2022-02-20 10:17:29 -03:00
Camille GILLOT 04d5f41c97
Make node_id_to_hir_id owner-local. 2022-02-20 10:17:27 -03:00
Matthias Krüger f2d6770f77
Rollup merge of #94146 - est31:let_else, r=cjgillot
Adopt let else in more places

Continuation of #89933, #91018, #91481, #93046, #93590, #94011.

I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This is the biggest of these PRs and handles the changes outside of rustdoc, rustc_typeck, rustc_const_eval, rustc_trait_selection, which were handled in PRs #94139, #94142, #94143, #94144.
2022-02-20 00:37:34 +01:00
est31 2ef8af6619 Adopt let else in more places 2022-02-19 17:27:43 +01:00