Commit Graph

154 Commits

Author SHA1 Message Date
Deadbeef 4fb10c0ce4 parse const closures 2023-01-12 02:28:37 +00:00
nils fd7a159710 Fix `uninlined_format_args` for some compiler crates
Convert all the crates that have had their diagnostic migration
completed (except save_analysis because that will be deleted soon and
apfloat because of the licensing problem).
2023-01-05 19:01:12 +01:00
Nilstrieb 9067e4417e Rename `Rptr` to `Ref` in AST and HIR
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already
as well.
2022-12-28 18:52:36 +01:00
Matthias Krüger de59844c98 more clippy::complexity fixes 2022-12-15 00:09:10 +01:00
bors 2cd2070af7 Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkov
Remove `token::Lit` from `ast::MetaItemLit`.

Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time.

r? `@petrochenkov`
2022-12-12 05:16:50 +00:00
Maybe Waffle 12ce0c2a89 Remove outdated syntax from trait alias pretty printing 2022-12-06 13:45:11 +00:00
Nicholas Nethercote 7e0c6dba0d Remove `LitKind::synthesize_token_lit`.
It has a single call site in the HIR pretty printer, where the resulting
token lit is immediately converted to a string.

This commit replaces `LitKind::synthesize_token_lit` with a `Display`
impl for `LitKind`, which can be used by the HIR pretty printer.
2022-12-05 16:33:24 +11:00
Matthias Krüger c89bff29e5
Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillot
Keep track of the start of the argument block of a closure

This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by #97417.

VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem.

r? `@cjgillot`
2022-12-03 17:37:41 +01:00
Nicholas Nethercote e658144586 Rename `LitKind::to_token_lit` as `LitKind::synthesize_token_lit`.
This makes it clearer that it's not a lossless conversion, which I find
helpful.
2022-12-02 10:23:44 +11:00
Vadim Petrochenkov 1f259ae679 rustc_hir: Change representation of import paths to support multiple resolutions 2022-12-01 18:51:05 +03:00
Sarthak Singh 8f705e2425 Keep track of the start of the argument block of a closure 2022-11-28 14:09:00 +05:30
bors 454784afba Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errors
Separate lifetime ident from lifetime resolution in HIR

Drive-by: change how suggested generic args are computed.
Fixes https://github.com/rust-lang/rust/issues/103815

I recommend reviewing commit-by-commit.
2022-11-27 14:30:19 +00:00
Maybe Waffle da40965300 Add `Mutability::{is_mut,is_not}` 2022-11-23 20:26:31 +00:00
Camille GILLOT fb7d25e978 Separate lifetime ident from resolution in HIR. 2022-11-23 19:33:06 +00:00
Camille GILLOT 9d20aca983 Store a LocalDefId in hir::Variant & hir::Field. 2022-11-13 14:06:51 +00:00
Camille GILLOT 290f0781b4 Store LocalDefId in hir::Closure. 2022-11-13 14:04:02 +00:00
Yutaro Ohno 7334526c38 pretty: fix to print some lifetimes on HIR pretty-print 2022-10-15 23:34:21 +09:00
Yuki Okushi 24424d0acb
Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki
rename `ImplItemKind::TyAlias` to `ImplItemKind::Type`

The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`.
2022-10-10 00:09:42 +09:00
Michael Goulet 70f3c79c50 ImplItemKind::TyAlias => ImplItemKind::Type 2022-10-09 07:09:57 +00:00
reez12g 9a4c5abe45 Remove from compiler/ crates 2022-09-29 16:49:04 +09:00
Nicholas Nethercote e67f39f8bc Introduce `DotDotPos`.
This shrinks `hir::Pat` from 88 to 72 bytes.
2022-09-08 15:25:50 +10:00
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
Takayuki Maeda 87c6da363f separate the receiver from arguments in HIR 2022-09-05 22:25:49 +09:00
Nicholas Nethercote ee244bf196 Remove dead code from `print_generic_args`. 2022-09-05 14:20:25 +10:00
Cameron Steffen 02ba216e3c Refactor and re-use BindingAnnotation 2022-09-02 12:55:05 -05:00
5225225 09ea9f0a87 Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01: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 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
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
Michael Goulet e182d12a84 Fix HIR pretty printing of let else 2022-08-12 02:47:57 +00:00
Michael Goulet 7a45a60418 use rustc_hir_pretty::qpath_to_string to avoid span_to_snippet when rendering path 2022-07-17 04:58:38 +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
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
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
KaDiWa 46ccde4408
clean up the borrowing in rustc_hir_pretty
a lot of the `&`s and `ref`s were redundant
2022-07-03 18:51:14 +02:00
Cameron Steffen ec82bc1996 Factor out hir::Node::Binding 2022-07-01 10:04:19 -05:00
Camille GILLOT 7437136f0e Use CreateParameter mode for closures too. 2022-06-21 21:13:43 +02:00
Camille GILLOT 3039cfeb6a Make `ExprKind::Closure` a struct variant. 2022-06-12 00:16:27 +02:00
Camille GILLOT a07290047e Compute lifetimes in scope at diagnostic time. 2022-06-04 15:28:15 +02:00
SparrowLii 5251a80c0a use hir::Let in hir::Guard 2022-05-09 20:35:58 +08: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
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
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