summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
AgeCommit message (Collapse)AuthorLines
2024-04-25ast: Generalize item kind visitingVadim Petrochenkov-1/+1
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
2024-04-24Auto merge of #122500 - petrochenkov:deleg, r=fmeasebors-42/+77
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-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-1/+15
And suggest adding the `#[coroutine]` to the closure
2024-04-24Add explicit syntax for coroutines instead of relying on closures having ↵Oli Scherer-1/+11
`yield` expressions
2024-04-23delegation: Support async, const, extern "ABI" and C-variadic functionsVadim Petrochenkov-42/+77
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-21Pass translation closure to add_to_diag_with() as referenceXiretza-1/+1
2024-04-18Rollup merge of #123935 - tstsrt:fix-115423, r=oli-obkJubilee-77/+117
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-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-18/+13
2024-04-17Rollup merge of #122813 - nnethercote:nicer-quals, r=compiler-errorsMatthias Krüger-27/+21
Qualifier tweaking Adding and removing qualifiers in some cases that make things nicer. Details in individual commits. r? `@compiler-errors`
2024-04-16Avoid lots of `hir::HirId{,Map,Set}` qualifiers.Nicholas Nethercote-27/+21
Because they're a bit redundant.
2024-04-15Use a path instead of an ident (and stop manually resolving)Michael Goulet-4/+7
2024-04-15Add hir::Node::PreciseCapturingNonLifetimeArgMichael Goulet-2/+23
2024-04-15Validation and other thingsMichael Goulet-5/+11
2024-04-15Lower and resolve precise captures in HIRMichael Goulet-16/+46
2024-04-15Use dedicated PreciseCapturingArg for representing what goes in use<>Michael Goulet-46/+43
2024-04-15Begin AST lowering for precise capturesMichael Goulet-29/+50
2024-04-15Parsing , pre-lowering support for precise capturesMichael Goulet-1/+2
2024-04-15Improve semantics of int_ty_max functionsninad-34/+26
2024-04-14Fix formattingninad-1/+3
2024-04-14Don't inline integer literals when out of rangeninad-77/+123
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+4
2024-04-08Thread pattern types through the HIROli Scherer-1/+1
2024-04-08Add pattern types to astOli Scherer-1/+4
2024-04-04hir: Use `ItemLocalId` in a couple more placesVadim Petrochenkov-6/+5
2024-04-03Auto merge of #123429 - matthiaskrgr:rollup-4emw4e9, r=matthiaskrgrbors-8/+8
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-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-8/+8
It is commonly used.
2024-04-03hir: Drop owner's own item-local id (zero) from parenting tablesVadim Petrochenkov-1/+3
2024-03-27Implement `mut ref`/`mut ref mut`Jules Bertholet-2/+2
2024-03-22Rename `hir::Node::Local` into `hir::Node::LetStmt`Guillaume Gomez-1/+1
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-4/+4
2024-03-22Auto merge of #122869 - matthiaskrgr:rollup-0navj4l, r=matthiaskrgrbors-2/+5
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-22Rollup merge of #121619 - RossSmyth:pfix_match, r=petrochenkovMatthias Krüger-2/+5
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-22Update (doc) commentsLeón Orell Valerian Liehr-5/+6
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-21Implement macro-based deref!() syntax for deref patternsMichael Goulet-0/+3
Stop using `box PAT` syntax for deref patterns, as it's misleading and also causes their semantics being tangled up.
2024-03-21Auto merge of #121587 - ShoyuVanilla:fix-issue-121267, r=TaKO8Kibors-27/+36
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-21Fix bad span for explicit lifetime suggestionShoyu Vanilla-27/+36
Move verbose logic to a function Minor renaming
2024-03-20Rename `hir::Let` into `hir::LetExpr`Guillaume Gomez-1/+1
2024-03-19The AssocOpaqueTy HIR node is not actually needed to differentiate from ↵Oli Scherer-1/+1
other hir nodes that were fed
2024-03-18do not eat nested exprs result in format args visitorRémy Rakic-2/+1
2024-03-16Rollup merge of #122564 - Bryanskiy:delegation-fixes, r=compiler-errorsLeón Orell Valerian Liehr-8/+6
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-16Delegation: fix ICE on duplicated associative itemsBryanskiy-8/+6
2024-03-15Auto merge of #122517 - petrochenkov:bodihash, r=oli-obkbors-17/+2
Fill in HIR hash for associated opaque types Fixes https://github.com/rust-lang/rust/issues/122508
2024-03-14Fill in HIR hash for associated opaque typesVadim Petrochenkov-17/+2
2024-03-14Rollup merge of #122487 - GuillaumeGomez:rename-stmtkind-local, r=oli-obkMatthias Krüger-3/+3
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-14Rename `hir::StmtKind::Local` into `hir::StmtKind::Let`Guillaume Gomez-2/+2
2024-03-14Rename `ast::StmtKind::Local` into `ast::StmtKind::Let`Guillaume Gomez-1/+1
2024-03-13Create some minimal HIR for associated opaque typesVadim Petrochenkov-0/+1
2024-03-12Change `DefKind::Static` to a struct variantOli Scherer-1/+1
2024-03-11Rename `AddToDiagnostic` as `Subdiagnostic`.Nicholas Nethercote-3/+3
To match `derive(Subdiagnostic)`. Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`.
2024-03-11Remove unused impls from some subdiagnostics.Nicholas Nethercote-2/+2