This improves the trait coherence checks for impl self case, and
polishes a bit of the wording on the existing diagnostics.
We now enforce package-level check in impl-self type checking, which
means we now reject inherent impls for external nominal types
(struct/enum).
There is still is a specialized whitelist for `StorageKey` so current
code that uses this pattern keeps working.
## 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.
## Description
This PR enables `language/references` and `stdlib` tests that were
disabled because of the #6898. It also adjusts the `language/references`
tests to the change introduced in #7509, which changes unit to be a
zero-sized type.
## Checklist
- [x] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] 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)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] 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.
## Description
The final step before closing
https://github.com/FuelLabs/sway/issues/6860. The `const_generics`
feature flag will be fully removed in a separate PR.
## Checklist
- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] 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)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] 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).
- [ ] I have requested a review from the relevant team or maintainers.
---------
Co-authored-by: Igor Rončević <ironcev@hotmail.com>
## Description
This PR is the last of https://github.com/FuelLabs/sway/issues/6860
before we switch const generics on by default.
It is transforming all `todo` to ICE.
The vast majority here is probably unreachable, and if not, we can
implement them as we find how to trigger them.
## Checklist
- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] 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)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] 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).
- [ ] I have requested a review from the relevant team or maintainers.
## Description
This PR will improve https://github.com/FuelLabs/sway/pull/7501 by
fixing the size of `()`, which affects enums with all variants as
`unit`.
With units occupying one byte, their runtime memory representation ends
up being different from their encoding representation, which avoids
trivial encode/decode optimisation of some types.
Another benefit of this PR is that we do not need to generate anything
for `store` of zero bytes.
Unfortunately, we cannot remove the `load` instruction, as registers
will be uninitialized on their first usage. For that, we simply emit a
`MOVI`, zeroing the register. I cannot think of a case where this change
is a problem. We never promised any specific value for ZST, so zero
seems a good candidate.
A new test was created to facilitate checking of types sizes, layouts
and whether they can be trivially encoded/decoded or not. Especially
because this PR is changing the layout of types.
<img width="1629" height="799" alt="image"
src="https://github.com/user-attachments/assets/608c8094-55d3-44e1-8827-420a3249690a"
/>
In theory, this change will affect storage. But in reality, it is highly
unlikely that `unit` was being used directly on types being stored. The
only use case would be enums, but enums were not changed, as they were
already being treated differently.
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] 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.
- [ ] 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.
## Description
Continuation of https://github.com/FuelLabs/sway/pull/7494.
## Checklist
- [x] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] 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.
- [ ] 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.
## Description
This PR is continuation of https://github.com/FuelLabs/sway/pull/7483.
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] 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.
- [ ] 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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Blocks types with const generics in configurables and ABI method
args/returns via new `TypeId::has_const_generics`, and adds tests to
enforce errors.
>
> - **Type system**:
> - Add `TypeId::has_const_generics(engines)` to detect const generics
in nested types (`sway-core/src/type_system/id.rs`).
> - **Compiler/semantics**:
> - Enforce no const generics in configurables via
`TyConfigurableDecl::forbid_const_generics()` and invoke during type
check (`semantic_analysis/.../configurable.rs`, `.../declaration.rs`).
> - Enforce no const generics in ABI method parameters/returns using
`TypeId::has_const_generics` and remove ad-hoc checker
(`language/ty/declaration/abi.rs`).
> - **Tests**:
> - Extend `should_fail/unsupported_const_generics` to cover
configurables and ABI cases; update snapshot (`test/.../stdout.snap`).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
eb6159044d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: Igor Rončević <ironcev@hotmail.com>
## Summary
This PR completes the sway-side of migrating `forc-tracing` and
`forc-crypto` to the new [forc
monorepo](https://github.com/FuelLabs/forc), as outlined in [RFC
#49](https://github.com/FuelLabs/sway-rfcs/pull/49).
The corresponding forc repo PR:
https://github.com/FuelLabs/forc/pull/119
### Changes
- Remove `forc-tracing` crate from workspace (now uses crates.io
`0.71.1`)
- Remove `forc-crypto` crate from workspace
- Update CI to no longer build/package `forc-crypto` binary (it's now
built from forc repo)
- Update gh-pages workflow to install `forc-crypto` from forc repo for
documentation generation
### Distribution
Going forward, `forc-crypto` will be built and distributed from the forc
repo by:
- sway-nightly-binaries
- fuelup
- fuel.nix
### Documentation
For now, documentation for all tooling will continue to live in this
repo. The `gh-pages` workflow now pulls `forc-crypto` from the forc repo
rather than building it locally, so docs generation continues to work as
before.
## Description
This PR adds `--no-gas-limit` CLI option to `forc test`. The option
increases tx gas limit in `forc test` to `u64::MAX`, essentially
removing it.
The motivation for the change was the need to benchmark heavy gas
consuming algorithms. E.g., a brute force prime factorization of the
number 9223372021822390277 took 21_474_836_627 gas units.
The new `TestGasLimit` enum provides a `Limit(limit)` variant which is
currently unused, but added for future extensions, if we want to limit
the test gas to a particular value.
## Checklist
- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] 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)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] 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.