sway/sway-parse
João Matos f117e855ea
Add #[abi_name(name = "foo")] attribute to rename ABI items. (#7057)
## Description

Add `#[abi_name(name = "foo")]` attribute to rename enum and struct ABI
items.

Here is example of how it can be used:

```sway
contract;

#[abi_name(name = "RenamedMyStruct")]
struct MyStruct {}

#[abi_name(name = "RenamedMyEnum")]
enum MyEnum {
  A: ()
}

abi MyAbi {
    fn my_struct() -> MyStruct;
    fn my_enum() -> MyEnum;
}

impl MyAbi for Contract {
  fn my_struct() -> MyStruct { MyStruct{} }
  fn my_enum() -> MyEnum { MyEnum::A }
}
```

Closes https://github.com/FuelLabs/sway/issues/5955.

## Remarks

The checking for ABI names is being done in the ABI generation phase,
which made it a requirement to change the interface of ABI checking to
return Results everywhere and passing Handler all the way down, so
emitted errors can be passed down to the driver for reporting.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: IGI-111 <igi-111@protonmail.com>
2025-07-17 20:12:36 -07:00
..
src Add #[abi_name(name = "foo")] attribute to rename ABI items. (#7057) 2025-07-17 20:12:36 -07:00
tests Add support for experimental features in the parsing phase (#7124) 2025-04-29 11:36:37 +12:00
Cargo.toml Add support for experimental features in the parsing phase (#7124) 2025-04-29 11:36:37 +12:00