Commit Graph

170 Commits

Author SHA1 Message Date
bors f88a8b71ce Auto merge of #114545 - fee1-dead-contrib:lower-impl-effect, r=oli-obk
correctly lower `impl const` to bind to host effect param

r? `@oli-obk`
2023-08-08 19:23:41 +00:00
Deadbeef 92f4c59e48 lower impl const to bind to host effect param 2023-08-06 13:34:53 +00:00
Nilstrieb 5706be1854 Improve spans for indexing expressions
Indexing is similar to method calls in having an arbitrary
left-hand-side and then something on the right, which is the main part
of the expression. Method calls already have a span for that right part,
but indexing does not. This means that long method chains that use
indexing have really bad spans, especially when the indexing panics and
that span in coverted into a panic location.

This does the same thing as method calls for the AST and HIR, storing an
extra span which is then put into the `fn_span` field in THIR.
2023-08-04 13:17:39 +02:00
León Orell Valerian Liehr 9213aec762
Lower generic const items to HIR 2023-07-28 22:21:40 +02:00
Maybe Waffle ccb71ff424 `hir`: Add `Become` expression kind 2023-06-26 08:56:32 +00:00
Camille GILLOT ca4d0d4c24 Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
Nilstrieb c63b6a437e Rip it out
My type ascription
Oh rip it out
Ah
If you think we live too much then
You can sacrifice diagnostics
Don't mix your garbage
Into my syntax
So many weird hacks keep diagnostics alive
Yet I don't even step outside
So many bad diagnostics keep tyasc alive
Yet tyasc doesn't even bother to survive!
2023-05-01 16:15:13 +08:00
DrMeepster 3206960ec6 minor tweaks 2023-04-21 02:14:04 -07:00
DrMeepster 511e457c4b offset_of 2023-04-21 02:14:02 -07:00
Nilstrieb 4b4948c2e3 Remove identity casts 2023-04-09 23:22:14 +02:00
Michael Goulet 8b592db27a Add `(..)` syntax for RTN 2023-03-28 01:14:28 +00:00
clubby789 9afffc5b61 Remove box expressions from HIR 2023-03-14 17:18:26 +00:00
clubby789 dd7df04e16 Remove uses of `box_syntax` in rustc and tools 2023-03-12 13:19:46 +00:00
Michael Goulet c0e58c3420 Add ErrorGuaranteed to HIR ExprKind::Err 2023-02-25 19:46:36 +00:00
Michael Goulet a772a6fc2a Add ErrorGuaranteed to HIR TyKind::Err 2023-02-25 19:46:36 +00:00
Maybe Waffle 4d75f61832 Use `Mutability::{is_mut, is_not}` 2023-01-30 12:26:26 +00:00
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