Commit Graph

545 Commits

Author SHA1 Message Date
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
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