about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/delegation.rs
AgeCommit message (Collapse)AuthorLines
2025-07-13Remove hir::AssocItemKind.Camille GILLOT-15/+0
2025-07-13Delegation: self parameter must be named exactly `self`.Camille GILLOT-7/+33
2025-06-01Add `visit_id` to ast `Visitor`Deadbeef-7/+1
This helps with efforts to deduplicate the `MutVisitor` and the `Visitor` code. All users of `Visitor`'s methods that have extra `NodeId` as parameters really just want to visit the id on its own. Also includes some methods deduplicated and cleaned up as a result of this change.
2025-04-14Move `has_self` field to `hir::AssocKind::Fn`.Nicholas Nethercote-1/+1
`hir::AssocItem` currently has a boolean `fn_has_self_parameter` field, which is misplaced, because it's only relevant for associated fns, not for associated consts or types. This commit moves it (and renames it) to the `AssocKind::Fn` variant, where it belongs. This requires introducing a new C-style enum, `AssocTag`, which is like `AssocKind` but without the fields. This is because `AssocKind` values are passed to various functions like `find_by_ident_and_kind` to indicate what kind of associated item should be searched for, and having to specify `has_self` isn't relevant there. New methods: - Predicates `AssocItem::is_fn` and `AssocItem::is_method`. - `AssocItem::as_tag` which converts `AssocItem::kind` to `AssocTag`. Removed `find_by_name_and_kinds`, which is unused. `AssocItem::descr` can now distinguish between methods and associated functions, which slightly improves some error messages.
2025-04-10Avoid empty identifiers for delegate params and args.Nicholas Nethercote-7/+8
Instead use `argN`. The empty identifiers could flow to `Liveness::should_warn`, where they would trigger a bounds error. Fixes #139512.
2025-04-01Move `ast::Item::ident` into `ast::ItemKind`.Nicholas Nethercote-3/+5
`ast::Item` has an `ident` field. - It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, `Trait`, `TraitAlias`, `MacroDef`, `Delegation`. - It's always empty for these item kinds: `Use`, `ForeignMod`, `GlobalAsm`, `Impl`, `MacCall`, `DelegationMac`. There is a similar story for `AssocItemKind` and `ForeignItemKind`. Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out. The commit is large but it's mostly obvious plumbing work. Some notable things. - `ast::Item` got 8 bytes bigger. This could be avoided by boxing the fields within some of the `ast::ItemKind` variants (specifically: `Struct`, `Union`, `Enum`). I might do that in a follow-up; this commit is big enough already. - For the visitors: `FnKind` no longer needs an `ident` field because the `Fn` within how has one. - In the parser, the `ItemInfo` typedef is no longer needed. It was used in various places to return an `Ident` alongside an `ItemKind`, but now the `Ident` (if present) is within the `ItemKind`. - In a few places I renamed identifier variables called `name` (or `foo_name`) as `ident` (or `foo_ident`), to better match the type, and because `name` is normally used for `Symbol`s. It's confusing to see something like `foo_name.name`.
2025-03-25Avoid some more global stateOli Scherer-4/+12
2025-03-13Delegation: allow foreign fns `reuse`Bryanskiy-5/+10
2025-03-12Delegation: one more ICE fix for `MethodCall` generationBryanskiy-0/+1
2025-03-10Delegation: fix ICE with invalid MethodCall generationBryanskiy-14/+16
2025-02-09compiler: remove rustc_target::spec::abi reexportsJubilee Young-2/+2
2025-01-19Run `clippy --fix` for `unnecessary_map_or` lintYotam Ofek-1/+1
2025-01-15Treat safe target_feature functions as unsafe by defaultOli Scherer-2/+13
2025-01-14Add hir::HeaderSafety to make follow up commits simplerOli Scherer-2/+2
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-10-28Add duplicate lowering checkAdwin White-1/+1
2024-10-28Lower AST node id only onceAdwin White-2/+3
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-20Conditionally allow lowering RTN (..) in pathsMichael Goulet-1/+2
2024-09-02chore: Fix typos in 'compiler' (batch 1)Alexander Cyon-2/+2
2024-08-26Rename ParenthesizedGenericArgs to GenericArgsModeMichael Goulet-2/+2
2024-08-16Use FnSig instead of raw FnDecl for ForeignItemKind::FnMichael Goulet-1/+1
2024-08-07Use more slice patterns inside the compilerLeón Orell Valerian Liehr-2/+2
2024-07-29Delegation: support generics for delegation from free functionsBryanskiy-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-7/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-16Delegation: support coercion for target expressionBryanskiy-15/+69
2024-06-25Delegation: ast lowering refactorBryanskiy-58/+49
2024-06-10Delegation: fix ICE on recursive delegationBryanskiy-1/+3
2024-05-17Rename Unsafe to SafetySantiago Pastorino-2/+2
2024-04-23delegation: Support async, const, extern "ABI" and C-variadic functionsVadim Petrochenkov-41/+76
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-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-1/+1
2024-03-22Update (doc) commentsLeón Orell Valerian Liehr-3/+4
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-02-27Refactor `LoweringContext::get_delegation_sig_id`.Nicholas Nethercote-6/+2
I find the function much easier to read this way. Thanks to @kadiwa4 for the suggestion.
2024-02-23compiler: clippy::complexity fixesMatthias Krüger-1/+1
2024-02-07No need to take ImplTraitContext by refMichael Goulet-1/+1
2024-01-12Delegation implementation: step 1Bryanskiy-0/+348