Vadim Petrochenkov
5be9fdd636
ast: Generalize item kind visiting
...
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
2024-04-25 22:49:58 +03:00
bors
5557f8c9d0
Auto merge of #122500 - petrochenkov:deleg, r=fmease
...
delegation: Support renaming, and async, const, extern "ABI" and C-variadic functions
Also allow delegating to functions with opaque types (`impl Trait`).
The delegation item will refer to the original opaque type from the callee, fresh opaque type won't be created, which seems like a reasonable behavior.
(Such delegation items will cause query cycles when used in trait impls, but it can be fixed later.)
Part of https://github.com/rust-lang/rust/issues/118212 .
2024-04-24 11:57:35 +00:00
Oli Scherer
aef0f4024a
Error on using yield without also using #[coroutine] on the closure
...
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00
Oli Scherer
a589632dad
Add explicit syntax for coroutines instead of relying on closures having yield expressions
2024-04-24 07:54:21 +00:00
Vadim Petrochenkov
7b7c26f09b
delegation: Support async, const, extern "ABI" and C-variadic functions
...
Also allow `impl Trait` in delegated functions.
The delegation item will refer to the original opaque type from the callee, fresh opaque type won't be created.
2024-04-23 23:05:39 +03:00
Xiretza
5646b65cf5
Pass translation closure to add_to_diag_with() as reference
2024-04-21 07:45:03 +00:00
Jubilee
f174c310ae
Rollup merge of #123935 - tstsrt:fix-115423, r=oli-obk
...
Don't inline integer literals when they overflow - new attempt
Basically #116633 but I implemented the suggested changes.
Fixes #115423 . Fixes #116631 .
This is my first contribution to this repo so please let me know if I'm supposed to change something :)
2024-04-18 21:38:55 -07:00
Jules Bertholet
2a4624ddd1
Rename BindingAnnotation to BindingMode
2024-04-17 09:34:39 -04:00
Matthias Krüger
45940fe6d8
Rollup merge of #122813 - nnethercote:nicer-quals, r=compiler-errors
...
Qualifier tweaking
Adding and removing qualifiers in some cases that make things nicer. Details in individual commits.
r? `@compiler-errors`
2024-04-17 05:44:52 +02:00
Nicholas Nethercote
4b27cc8b7a
Avoid lots of hir::HirId{,Map,Set} qualifiers.
...
Because they're a bit redundant.
2024-04-16 16:29:15 +10:00
Michael Goulet
52c6b101ea
Use a path instead of an ident (and stop manually resolving)
2024-04-15 16:45:26 -04:00
Michael Goulet
02d7317af2
Add hir::Node::PreciseCapturingNonLifetimeArg
2024-04-15 16:45:25 -04:00
Michael Goulet
42ba57c013
Validation and other things
2024-04-15 16:45:01 -04:00
Michael Goulet
41cf87b71b
Lower and resolve precise captures in HIR
2024-04-15 16:45:01 -04:00
Michael Goulet
fc9e344874
Use dedicated PreciseCapturingArg for representing what goes in use<>
2024-04-15 16:45:01 -04:00
Michael Goulet
647b672f16
Begin AST lowering for precise captures
2024-04-15 16:45:01 -04:00
Michael Goulet
a076eae0d2
Parsing , pre-lowering support for precise captures
2024-04-15 16:45:01 -04:00
ninad
4c8d210ab8
Improve semantics of int_ty_max functions
2024-04-15 00:39:28 +05:30
ninad
757f5bb3dc
Fix formatting
2024-04-14 20:29:30 +05:30
ninad
857f5dd475
Don't inline integer literals when out of range
2024-04-14 20:17:44 +05:30
Oli Scherer
84acfe86de
Actually create ranged int types in the type system.
2024-04-08 12:02:19 +00:00
Oli Scherer
c4efc25bfa
Thread pattern types through the HIR
2024-04-08 12:00:07 +00:00
Oli Scherer
fc27a91880
Add pattern types to ast
2024-04-08 11:54:22 +00:00
Vadim Petrochenkov
17475de5de
hir: Use ItemLocalId in a couple more places
2024-04-04 14:43:49 +03:00
bors
4fd4797c26
Auto merge of #123429 - matthiaskrgr:rollup-4emw4e9, r=matthiaskrgr
...
Rollup of 8 pull requests
Successful merges:
- #121595 (Better reporting on generic argument mismatchs)
- #122619 (Fix some unsoundness with PassMode::Cast ABI)
- #122964 (Rename `expose_addr` to `expose_provenance`)
- #123291 (Move some tests)
- #123301 (pattern analysis: fix union handling)
- #123395 (More postfix match fixes)
- #123419 (rustc_index: Add a `ZERO` constant to index types)
- #123421 (Fix target name in NetBSD platform-support doc)
r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-03 20:19:51 +00:00
Vadim Petrochenkov
b40ea03f8a
rustc_index: Add a ZERO constant to index types
...
It is commonly used.
2024-04-03 19:06:22 +03:00
Vadim Petrochenkov
44b3602478
hir: Drop owner's own item-local id (zero) from parenting tables
2024-04-03 17:33:34 +03:00
Jules Bertholet
e0da13f25f
Implement mut ref/mut ref mut
2024-03-27 09:53:23 -04:00
Guillaume Gomez
e0d3439226
Rename hir::Node::Local into hir::Node::LetStmt
2024-03-22 20:48:36 +01:00
Guillaume Gomez
b376f49e30
Rename hir::Local into hir::LetStmt
2024-03-22 20:36:21 +01:00
bors
1447f9d38c
Auto merge of #122869 - matthiaskrgr:rollup-0navj4l, r=matthiaskrgr
...
Rollup of 9 pull requests
Successful merges:
- #121619 (Experimental feature postfix match)
- #122370 (Gracefully handle `AnonConst` in `diagnostic_hir_wf_check()`)
- #122537 (interpret/allocation: fix aliasing issue in interpreter and refactor getters a bit)
- #122542 (coverage: Clean up marker statements that aren't needed later)
- #122800 (Add `NonNull::<[T]>::is_empty`.)
- #122820 (Stop using `<DefId as Ord>` in various diagnostic situations)
- #122847 (Suggest `RUST_MIN_STACK` workaround on overflow)
- #122855 (Fix Itanium mangling usizes)
- #122863 (add more ice tests )
r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-22 12:29:42 +00:00
Matthias Krüger
783778c631
Rollup merge of #121619 - RossSmyth:pfix_match, r=petrochenkov
...
Experimental feature postfix match
This has a basic experimental implementation for the RFC postfix match (rust-lang/rfcs#3295, #121618 ). [Liaison is](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Postfix.20Match.20Liaison/near/423301844 ) ```@scottmcm``` with the lang team's [experimental feature gate process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md ).
This feature has had an RFC for a while, and there has been discussion on it for a while. It would probably be valuable to see it out in the field rather than continue discussing it. This feature also allows to see how popular postfix expressions like this are for the postfix macros RFC, as those will take more time to implement.
It is entirely implemented in the parser, so it should be relatively easy to remove if needed.
This PR is split in to 5 commits to ease review.
1. The implementation of the feature & gating.
2. Add a MatchKind field, fix uses, fix pretty.
3. Basic rustfmt impl, as rustfmt crashes upon seeing this syntax without a fix.
4. Add new MatchSource to HIR for Clippy & other HIR consumers
2024-03-22 11:36:58 +01:00
León Orell Valerian Liehr
82c2c8deb1
Update (doc) comments
...
Several (doc) comments were super outdated or didn't provide enough context.
Some doc comments shoved everything in a single paragraph without respecting
the fact that the first paragraph should be a single sentence because rustdoc
treats these as item descriptions / synopses on module pages.
2024-03-22 06:31:51 +01:00
Michael Goulet
2d633317f3
Implement macro-based deref!() syntax for deref patterns
...
Stop using `box PAT` syntax for deref patterns, as it's misleading and
also causes their semantics being tangled up.
2024-03-21 11:42:49 -04:00
bors
6e1f7b538a
Auto merge of #121587 - ShoyuVanilla:fix-issue-121267, r=TaKO8Ki
...
Fix bad span for explicit lifetime suggestions
Fixes #121267
Current explicit lifetime suggestions are not showing correct spans for some lifetimes - e.g. elided lifetime generic parameters;
This should be done correctly regarding elided lifetime kind like the following code
https://github.com/rust-lang/rust/blob/43fdd4916d19f4004e23d422b5547637ad67ab21/compiler/rustc_resolve/src/late/diagnostics.rs#L3015-L3044
2024-03-21 04:11:09 +00:00
Shoyu Vanilla
c270a42fea
Fix bad span for explicit lifetime suggestion
...
Move verbose logic to a function
Minor renaming
2024-03-21 10:31:04 +09:00
Guillaume Gomez
98e66553a6
Rename hir::Let into hir::LetExpr
2024-03-20 16:47:11 +01:00
Oli Scherer
bdb682eda6
The AssocOpaqueTy HIR node is not actually needed to differentiate from other hir nodes that were fed
2024-03-19 08:37:53 +00:00
Rémy Rakic
8beec62315
do not eat nested exprs result in format args visitor
2024-03-18 09:27:47 +00:00
León Orell Valerian Liehr
7b7a7fc891
Rollup merge of #122564 - Bryanskiy:delegation-fixes, r=compiler-errors
...
Delegation: fix ICE on duplicated associative items
Currently, functions delegation is only supported for delegation items with early resolved paths e.g. free functions and trait methods. During name resolution, information about function signatures is collected, including the number of parameters and whether there are self arguments. This information is then used when lowering from a delegation item into a regular function(`rustc_ast_lowering/src/delegation.rs`). The signature is usually inherited from path resolution id(`path_id`). However, in the case of trait impls `path_id` and `item_id` may be different:
```rust
trait Trait {
fn foo(&self) -> u32 { 0 }
}
struct S;
mod to_reuse {
use crate::S;
pub fn foo(_: &S) -> u32 { 0 }
}
impl Trait for S {
reuse to_reuse::foo { self }
//~^ The signature should be inherited from item id instead of resolution id
}
```
Let's now consider an example from [issue](https://github.com/rust-lang/rust/issues/119920 ). Due to duplicated associative elements partial resolution for one of them will not be recorded:
https://github.com/rust-lang/rust/blob/9023f908cfbe7a475f369717a61cb8eb865cfd25/compiler/rustc_resolve/src/late.rs#L3153-L3162
Which leads to an incorrect `is_in_trait_impl`
https://github.com/rust-lang/rust/blob/9023f908cfbe7a475f369717a61cb8eb865cfd25/compiler/rustc_ast_lowering/src/item.rs#L981-L986
Which leads to an incorrect id for signature inheritance
https://github.com/rust-lang/rust/blob/9023f908cfbe7a475f369717a61cb8eb865cfd25/compiler/rustc_ast_lowering/src/delegation.rs#L99-L105
Which lead to an ICE from original issue.
This patch fixes wrong `is_in_trait_impl` calculation.
fixes https://github.com/rust-lang/rust/issues/119920
2024-03-16 23:28:48 +01:00
Bryanskiy
b2ed9d0911
Delegation: fix ICE on duplicated associative items
2024-03-16 21:03:36 +03:00
bors
ee03c286cf
Auto merge of #122517 - petrochenkov:bodihash, r=oli-obk
...
Fill in HIR hash for associated opaque types
Fixes https://github.com/rust-lang/rust/issues/122508
2024-03-15 02:04:04 +00:00
Vadim Petrochenkov
ef5513f278
Fill in HIR hash for associated opaque types
2024-03-14 23:29:12 +03:00
Matthias Krüger
1f4aff7d2b
Rollup merge of #122487 - GuillaumeGomez:rename-stmtkind-local, r=oli-obk
...
Rename `StmtKind::Local` variant into `StmtKind::Let`
It comes from this [discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F ).
Starting point was:
> I often end up looking at [ExprKind::Let](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.ExprKind.html#variant.Let ) instead of Local because of the name. I think renaming it (both the `ExprKind` variant and the Let struct) to `LetPattern` or LetPat could improve the situation as I'm not sure I'm not the only one encountering this issue.
And then it evolved into:
> It's already `Expr::Let` instead of `StmtKind::Local`. Counterproposal: rename `StmtKind::Local` to `StmtKind::Let`.
The goal here is to clear this confusion.
r? `@oli-obk`
2024-03-14 20:00:21 +01:00
Guillaume Gomez
a4e0e50a3f
Rename hir::StmtKind::Local into hir::StmtKind::Let
2024-03-14 12:42:04 +01:00
Guillaume Gomez
ca9f0630a9
Rename ast::StmtKind::Local into ast::StmtKind::Let
2024-03-14 12:42:04 +01:00
Vadim Petrochenkov
b6312eb943
Create some minimal HIR for associated opaque types
2024-03-13 17:33:09 +03:00
Oli Scherer
9816915954
Change DefKind::Static to a struct variant
2024-03-12 05:53:46 +00:00
Nicholas Nethercote
541d7cc65c
Rename AddToDiagnostic as Subdiagnostic.
...
To match `derive(Subdiagnostic)`.
Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`.
2024-03-11 10:04:49 +11:00
Nicholas Nethercote
256d802233
Remove unused impls from some subdiagnostics.
2024-03-11 09:08:33 +11:00