Commit Graph

136 Commits

Author SHA1 Message Date
bors 6c358c67d4 Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot
`BindingAnnotation` refactor

* `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`)
* `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)`
* Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}`

One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`.

I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.
2022-09-06 03:16:29 +00:00
bors b44197abb0 Auto merge of #101261 - TaKO8Ki:separate-receiver-from-arguments-in-hir, r=cjgillot
Separate the receiver from arguments in HIR

Related to #100232

cc `@cjgillot`
2022-09-05 16:21:40 +00:00
bors 2dc703fd6e Auto merge of #101228 - nnethercote:simplify-hir-PathSegment, r=petrochenkov
Simplify `hir::PathSegment`

r? `@petrochenkov`
2022-09-05 13:36:54 +00:00
Takayuki Maeda 87c6da363f separate the receiver from arguments in HIR 2022-09-05 22:25:49 +09:00
Dylan DPC 5d55009b79 Rollup merge of #101142 - nnethercote:improve-hir-stats, r=davidtwco
Improve HIR stats

#100398 improve the AST stats collection done by `-Zhir-stats`. This PR does the same for HIR stats collection.

r? `@davidtwco`
2022-09-05 14:15:51 +05:30
Nicholas Nethercote 08a00eb0da Address review comments. 2022-09-05 14:20:29 +10:00
Nicholas Nethercote bb0ae3c446 Make hir::PathSegment::hir_id non-optional. 2022-09-05 14:20:25 +10:00
Nicholas Nethercote 6d850d936b Make hir::PathSegment::res non-optional. 2022-09-05 14:20:25 +10:00
Cameron Steffen 02ba216e3c Refactor and re-use BindingAnnotation 2022-09-02 12:55:05 -05:00
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
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
Wonchul Lee 9b95eef6ea save_analysis: Migrate diagnostics 2022-08-24 06:50:16 +09:00
Camille GILLOT d7ea161b7e Remove DefId from AssocItemContainer. 2022-08-01 21:38:45 +02:00
Camille GILLOT 110f0656cb Store associated item defaultness in impl_defaultness. 2022-08-01 21:38:16 +02: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
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
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
Cameron Steffen ec82bc1996 Factor out hir::Node::Binding 2022-07-01 10:04:19 -05:00
Camille GILLOT 3039cfeb6a Make ExprKind::Closure a struct variant. 2022-06-12 00:16:27 +02:00
Jack Huey 410dcc9674 Fully stabilize NLL 2022-06-03 17:16:41 -04:00
Kelsey Gilbert 5fde765df0 [save-analysis] Reference the variant not enum at struct-literal construction.
Closes #96985
2022-05-12 16:34:02 -07:00
Vadim Petrochenkov 5b5964f569 rustc: Panic by default in DefIdTree::parent
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.
2022-05-02 01:56:50 +03: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 a6e3124d2c Drop vis in ImplItem. 2022-04-23 09:57:00 +02:00
Camille GILLOT a62680d108 Drop vis in FieldDef. 2022-04-23 09:56:15 +02:00
Camille GILLOT 4e8046f67a Stop pretty-printing HIR visibility. 2022-04-23 09:55:25 +02:00
Camille GILLOT 10d10efb21 Stop visiting visibility. 2022-04-23 09:53:45 +02: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
Dylan DPC 1b7d6dbd30 Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errors
Spellchecking compiler comments

This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-31 04:57:28 +02:00
Yuri Astrakhan 5160f8f843 Spellchecking compiler comments
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30 15:14:15 -04:00
Camille GILLOT 21a554caf6 Remember mutability in DefKind::Static.
This allows to compute the `BodyOwnerKind` from `DefKind` only, and
removes a direct dependency of some MIR queries onto HIR.

As a side effect, it also simplifies metadata, since we don't need 4
flavours of `EntryKind::*Static` any more.
2022-03-29 18:50:52 +02:00
Nicholas Nethercote ca5525d564 Improve AdtDef interning.
This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.
2022-03-11 13:31:24 +11:00
Mark Rousskov 22c3a71de1 Switch bootstrap cfgs 2022-02-25 08:00:52 -05: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 523a1b1d38 Auto merge of #94062 - Mark-Simulacrum:drop-print-cfg, r=oli-obk
Move ty::print methods to Drop-based scope guards

Primary goal is reducing codegen of the TLS access for each closure, which shaves ~3 seconds of bootstrap time over rustc as a whole.
2022-02-20 18:12:59 +00:00
est31 2ef8af6619 Adopt let else in more places 2022-02-19 17:27:43 +01:00
Mark Rousskov 9763486034 Move ty::print methods to Drop-based scope guards 2022-02-16 17:24:23 -05:00
Ellen e81e09a24e change to a struct variant 2022-02-12 11:23:53 +00:00
Frank Steffahn 7eff2feb62 Remove further usage of &hir::Map 2022-02-10 13:04:59 +01:00
est31 670f5c6ef3 More let_else adoptions 2022-02-02 17:11:01 +01:00
lcnr a1a30f7548 add a rustc::query_stability lint 2022-02-01 10:15:59 +01:00
Matthias Krüger 6749f32c33 Rollup merge of #90277 - pierwill:fix-70258-inference-terms, r=jackh726
Improve terminology around "after typeck"

Closes #70258.
2022-01-31 06:58:26 +01:00
Cameron Steffen b11733534d Remove a span from hir::ExprKind::MethodCall 2022-01-21 07:48:10 -06:00
Guillaume Gomez 2938be612d Correctly handle starts in block doc comments 2022-01-19 11:18:17 +01:00
Cameron Steffen 45db716902 Replace NestedVisitorMap with NestedFilter 2022-01-16 16:02:36 -06:00
Matthew Jasper d7595853a2 Add trait_item_def_id to AssocItem
This allows avoiding some lookups by name
2022-01-07 12:28:12 -08:00
lcnr a02bf76c96 review 2022-01-03 11:59:01 +01:00
lcnr e3f5cc6c38 implement generic_arg_infer for array lengths 2021-12-23 10:09:35 +01:00