Commit graph

8 commits

Author SHA1 Message Date
Igor Rončević
76268dcff7
Add support for experimental features in the parsing phase (#7124)
## Description

This PR brings support for experimental features to the parsing phase.
This is needed so that we can support use cases like, e.g., adding new
language keywords behind a feature flag.

A concrete example would be the `panic` keyword added in #7073. The
parsing of the `panic` token differs if it is interpreted as a keyword
(when the `error_type` experimental feature is active) or as a regular
identifier (when `error_type` is off).

Because `ExperimentalFeatures` are needed in the `Parse::parse(parser:
&mut Parser)` methods, the `Parser` got extended with the `experimental`
field.

The consequence of bringing the `ExperimentalFeatures` to the parsing
phase is, that `swayfmt` and `forc fmt` can also require an experimental
feature to be set, to properly parse a project. In those tools,
`ExperimentalFeatures` are passed as a field on the `Formatter`.

Note that this PR does not put the provided experimental flags into use.
The first concrete usage will be in #7073.

This PR is a prerequisite for #7073. 

## 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)
- [ ] 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.
2025-04-29 11:36:37 +12:00
Sophie Dankel
597ecfb6e0
chore: move dev dependencies to workspace (#6966)
## Description

Moves dev dependencies to the workspace Cargo.toml for consistent
versions in tests.

Inspired by https://github.com/FuelLabs/sway/pull/6955

## 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.
2025-02-28 11:44:11 +11:00
Kaya Gökalp
9c4a339dff
chore: remove unmaintained ansi_term in favor of ansiterm (#6696)
## Description

related to #2601.

Removes ansi_term dependency from sway crates. To remove the dependency
completely from dep tree we need a release of sway repo to get a new
version of forc_util and use it in forc_wallet as forc_wallet is
depending on `forc-util v0.47.0` which uses `ansi_term`. Once that is
done we can close #2601
2024-11-06 01:42:25 -08:00
Kaya Gökalp
16318d302e
chore: remove unmaintained difference in favor of similar (#6694)
## Description

closes #5421.

Removes unmaintained `difference` create used in swayfmt and uses
`similar` instead. Security wise this is not an important problem as the
dependency is only used as a dev-dependency. But the pr is a part of an
effort cleaning `RUSTSEC` issues mainly for housekeeping reasons of our
ever growing repo.
2024-11-05 11:13:35 +07:00
César D. Rodas
d3533713ca
Improve forc-fmt to format std lib and core (#5410)
## Description

Changes needed to build #5404 and #5405 

## Improvements
1. Use byte-offset instead of chars offset
2. Enhanced `asm` formatting

## Better output when tests fail


![image](9b884167-a242-4a81-8858-5eff7e9bb7c1)


## 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).
- [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: Cesar Rodas <cesar@Cesars-MacBook-Pro-2.local>
2023-12-21 23:57:27 +00:00
Sophie Dankel
985e055854
Fix forc-fmt panic when lexing fails (#5011)
## Description

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

Now instead of a panic, the user sees this: 

<img width="836" alt="image"
src="2da2e075-8a10-4ed4-8892-1c95cc42af63">

With debug logging they can see the compiler error, or they can simply
run the compiler.

## 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).
- [ ] 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.
2023-08-25 10:11:23 +00:00
JC
169ad0b145
Cleanup TOMLs (#4312)
Moves following `Cargo.toml` fields to workspace `Cargo.toml` so we
don't have to keep repeating ourselves:

- edition
- authors
- homepage
- license
- repository
2023-03-20 16:22:12 +00:00
bing
44aa2e2fc7
refactor(fmt): dedup fmt_test! macros (#4100)
## Description

closes #4098

This PR moves all test related macros into a new crate `test_macros`
(this includes `assert_eq_pretty!` from a previous PR (#3960). The
motivation for this is when working with unit tests for maybe an
expression, I realized that `fmt_test` is being re-implemented
everywhere.

We create 2 new macros `fmt_test_expr` and `fmt_test_item`, which are
now used in the tests, instead of creating a new local `fmt_test!` for
each AST type.

This cuts down quite a bit of LoC and boilerplate code, since for each
AST kind we were re-implementing `fmt_test!` in each `test.rs` file.

## 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).
- [ ] 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: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2023-02-18 13:51:36 +03:00