Skip to content

Commit 83ca50a

Browse files
committed
Stabilize ABI errors
Stabilize the `error_type` feature. Fixes #6765
1 parent b202843 commit 83ca50a

File tree

48 files changed

+63
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+63
-155
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,6 @@ jobs:
478478
run: cargo run --locked --release -p forc -- test --release --locked --path ./test/src/sdk-harness
479479
- name: Cargo Test sway-lib-std
480480
run: cargo test --locked --release --manifest-path ./test/src/sdk-harness/Cargo.toml -- --nocapture
481-
- name: Build All Tests - Experimental Feature 'error_type'
482-
run: cargo run --locked --release -p forc -- build --experimental error_type --release --locked --path ./test/src/sdk-harness
483-
- name: Cargo Test sway-lib-std - Experimental Feature 'error_type'
484-
run: cargo test --locked --release --manifest-path ./test/src/sdk-harness/Cargo.toml -- --nocapture
485481

486482
forc-run-benchmarks:
487483
runs-on: buildjet-4vcpu-ubuntu-2204
@@ -548,18 +544,10 @@ jobs:
548544
run: forc test --path sway-lib-std
549545
- name: Run Std Unit Tests (Release)
550546
run: forc test --release --path sway-lib-std
551-
- name: Run Std Unit Tests - Experimental feature 'error_type' (Debug)
552-
run: forc test --experimental error_type --path sway-lib-std
553-
- name: Run Std Unit Tests - Experimental feature 'error_type' (Release)
554-
run: forc test --release --experimental error_type --path sway-lib-std
555547
- name: Run In Language Unit Tests (Debug)
556548
run: forc test --path test/src/in_language_tests
557549
- name: Run In Language Unit Tests (Release)
558550
run: forc test --release --path test/src/in_language_tests
559-
- name: Run In Language Unit Tests - Experimental feature 'error_type' (Debug)
560-
run: forc test --experimental error_type --path test/src/in_language_tests
561-
- name: Run In Language Unit Tests - Experimental feature 'error_type' (Release)
562-
run: forc test --release --experimental error_type --path test/src/in_language_tests
563551

564552
forc-pkg-fuels-deps-check:
565553
runs-on: buildjet-4vcpu-ubuntu-2204

forc-pkg/src/pkg.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,8 +1775,7 @@ pub fn compile(
17751775

17761776
const ENCODING_V0: &str = "0";
17771777
const ENCODING_V1: &str = "1";
1778-
const SPEC_VERSION: &str = "1";
1779-
const SPEC_VERSION_ERROR_TYPE: &str = "1.1";
1778+
const SPEC_VERSION: &str = "1.1";
17801779

17811780
let mut program_abi = match pkg.target {
17821781
BuildTarget::Fuel => {
@@ -1798,11 +1797,7 @@ pub fn compile(
17981797
} else {
17991798
ENCODING_V0.into()
18001799
},
1801-
if experimental.error_type {
1802-
SPEC_VERSION_ERROR_TYPE.into()
1803-
} else {
1804-
SPEC_VERSION.into()
1805-
}
1800+
SPEC_VERSION.into()
18061801
),
18071802
Some(sway_build_config.clone()),
18081803
metrics

forc-plugins/forc-migrate/src/migrations/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,4 @@ fn assert_migration_steps_consistency(migration_steps: MigrationSteps) {
494494

495495
/// The list of the migration steps, grouped by the Sway feature that causes
496496
/// the breaking changes behind the migration steps.
497-
const MIGRATION_STEPS: MigrationSteps = &[(
498-
Feature::ErrorType,
499-
&[error_type::RENAME_EXISTING_PANIC_IDENTIFIERS_TO_R_PANIC_STEP],
500-
)];
497+
const MIGRATION_STEPS: MigrationSteps = &[];

sway-core/src/semantic_analysis/module.rs

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use sway_error::{
1313
handler::{ErrorEmitted, Handler},
1414
warning::{CompileWarning, Warning},
1515
};
16-
use sway_features::Feature;
1716
use sway_types::{BaseIdent, Named, SourceId, Span, Spanned};
1817

1918
use crate::{
@@ -27,7 +26,6 @@ use crate::{
2726
},
2827
query_engine::{ModuleCacheKey, TypedModuleInfo},
2928
semantic_analysis::*,
30-
transform::AttributeKind,
3129
BuildConfig, Engines, TypeInfo,
3230
};
3331

@@ -618,44 +616,18 @@ impl ty::TyModule {
618616

619617
// Always auto impl marker traits. If an explicit implementation exists, that will be
620618
// reported as an error when type-checking trait impls.
621-
if ctx.experimental.error_type {
622-
let mut ctx = MarkerTraitsAutoImplContext::new(&mut ctx);
623-
if let TyAstNodeContent::Declaration(TyDecl::EnumDecl(enum_decl)) = &node.content {
624-
let enum_decl = &*ctx.engines().de().get(&enum_decl.decl_id);
625-
626-
let enum_marker_trait_impl =
627-
ctx.generate_enum_marker_trait_impl(engines, enum_decl);
628-
generated.extend(enum_marker_trait_impl);
629-
630-
if check_is_valid_error_type_enum(handler, enum_decl).is_ok_and(|res| res) {
631-
let error_type_marker_trait_impl =
632-
ctx.generate_error_type_marker_trait_impl_for_enum(engines, enum_decl);
633-
generated.extend(error_type_marker_trait_impl);
634-
}
635-
}
636-
} else {
637-
// Check for usages of `error_type` and `error` attributes without the feature enabled.
638-
if let TyAstNodeContent::Declaration(TyDecl::EnumDecl(enum_decl)) = &node.content {
639-
let enum_decl = &*ctx.engines().de().get(&enum_decl.decl_id);
640-
for attr in enum_decl.attributes.of_kind(AttributeKind::ErrorType) {
641-
handler.emit_err(CompileError::FeatureIsDisabled {
642-
feature: Feature::ErrorType.name().to_string(),
643-
url: Feature::ErrorType.url().to_string(),
644-
span: attr.name.span(),
645-
});
646-
}
647-
648-
for attr in enum_decl
649-
.variants
650-
.iter()
651-
.flat_map(|variant| variant.attributes.of_kind(AttributeKind::Error))
652-
{
653-
handler.emit_err(CompileError::FeatureIsDisabled {
654-
feature: Feature::ErrorType.name().to_string(),
655-
url: Feature::ErrorType.url().to_string(),
656-
span: attr.name.span(),
657-
});
658-
}
619+
let mut ctx = MarkerTraitsAutoImplContext::new(&mut ctx);
620+
if let TyAstNodeContent::Declaration(TyDecl::EnumDecl(enum_decl)) = &node.content {
621+
let enum_decl = &*ctx.engines().de().get(&enum_decl.decl_id);
622+
623+
let enum_marker_trait_impl =
624+
ctx.generate_enum_marker_trait_impl(engines, enum_decl);
625+
generated.extend(enum_marker_trait_impl);
626+
627+
if check_is_valid_error_type_enum(handler, enum_decl).is_ok_and(|res| res) {
628+
let error_type_marker_trait_impl =
629+
ctx.generate_error_type_marker_trait_impl_for_enum(engines, enum_decl);
630+
generated.extend(error_type_marker_trait_impl);
659631
}
660632
}
661633

sway-features/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ features! {
169169
"https://github.com/FuelLabs/sway/issues/5727",
170170
references = true,
171171
"https://github.com/FuelLabs/sway/issues/5063",
172-
error_type = false,
173-
"https://github.com/FuelLabs/sway/issues/6765",
174172
const_generics = false,
175173
"https://github.com/FuelLabs/sway/issues/6860",
176174
}

sway-lib-std/src/marker.sw

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,17 @@ use ::codec::AbiEncode;
1515
/// - unit type `()`,
1616
/// - string slices,
1717
/// - and enums annotated with the `#[error_type]` attribute.
18-
#[cfg(experimental_error_type = true)]
1918
pub trait Error: AbiEncode {
2019
}
2120

2221
/// A marker for enum types.
23-
#[cfg(experimental_error_type = true)]
2422
pub trait Enum {
2523
}
2624

2725
// Marker traits cannot be explicitly implement in code, except in this module.
2826
// If a marker trait needs to be implemented for a built-in type, those implementation
2927
// will be provided here.
3028

31-
#[cfg(experimental_error_type = true)]
3229
impl Error for str {}
3330

34-
#[cfg(experimental_error_type = true)]
3531
impl Error for () {}

sway-lib-std/src/prelude.sw

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,5 @@ pub use ::raw_slice::*;
4949
pub use ::codec::*;
5050
use ::debug::*;
5151
pub use ::str::*;
52-
#[cfg(experimental_error_type = true)]
5352
pub use ::marker::*;
5453
pub use ::debug::*;

sway-parse/src/expr/mod.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -722,23 +722,21 @@ fn parse_atom(parser: &mut Parser, ctx: ParseExprCtx) -> ParseResult<Expr> {
722722
expr_opt: Some(expr),
723723
});
724724
}
725-
if parser.experimental.error_type {
726-
if let Some(panic_token) = parser.take() {
727-
if parser.is_empty()
728-
|| parser.peek::<CommaToken>().is_some()
729-
|| parser.peek::<SemicolonToken>().is_some()
730-
{
731-
return Ok(Expr::Panic {
732-
panic_token,
733-
expr_opt: None,
734-
});
735-
}
736-
let expr = parser.parse()?;
725+
if let Some(panic_token) = parser.take() {
726+
if parser.is_empty()
727+
|| parser.peek::<CommaToken>().is_some()
728+
|| parser.peek::<SemicolonToken>().is_some()
729+
{
737730
return Ok(Expr::Panic {
738731
panic_token,
739-
expr_opt: Some(expr),
732+
expr_opt: None,
740733
});
741734
}
735+
let expr = parser.parse()?;
736+
return Ok(Expr::Panic {
737+
panic_token,
738+
expr_opt: Some(expr),
739+
});
742740
}
743741
if let Some(if_expr) = parser.guarded_parse::<IfToken, _>()? {
744742
return Ok(Expr::If(if_expr));

sway-parse/src/keywords.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,5 @@ pub const RESERVED_KEYWORDS: phf::Set<&'static str> = phf::phf_set! {
192192
"continue",
193193
"configurable",
194194
"type",
195-
// TODO: Add `panic` to the list of reserved keywords,
196-
// once `error_type` feature is not experimental anymore.
197-
// "panic",
195+
"panic",
198196
};

sway-parse/src/parse.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ impl Parse for Ident {
146146
}
147147

148148
if !ident.is_raw_ident()
149-
&& (RESERVED_KEYWORDS.contains(ident_str)
150-
|| (parser.experimental.error_type && ident_str == PanicToken::AS_STR))
149+
&& (RESERVED_KEYWORDS.contains(ident_str) || ident_str == PanicToken::AS_STR)
151150
{
152151
return Err(parser.emit_error_with_span(
153152
ParseErrorKind::ReservedKeywordIdentifier,

test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-assert/src/prelude.sw

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ pub use ::raw_ptr::*;
1919
pub use ::raw_slice::*;
2020
pub use ::codec::*;
2121
pub use ::str::*;
22-
#[cfg(experimental_error_type = true)]
23-
pub use ::marker::*;
22+
pub use ::marker::*;

test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-conversions/src/prelude.sw

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ pub use ::raw_ptr::*;
3636
pub use ::raw_slice::*;
3737
pub use ::codec::*;
3838
pub use ::str::*;
39-
#[cfg(experimental_error_type = true)]
4039
pub use ::marker::*;

test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core/src/prelude.sw

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ pub use ::raw_ptr::*;
1212
pub use ::raw_slice::*;
1313
pub use ::codec::*;
1414
pub use ::str::*;
15-
#[cfg(experimental_error_type = true)]
1615
pub use ::marker::*;
1716
pub use ::debug::*;

test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-option-result/src/prelude.sw

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ pub use ::raw_ptr::*;
2121
pub use ::raw_slice::*;
2222
pub use ::codec::*;
2323
pub use ::str::*;
24-
#[cfg(experimental_error_type = true)]
2524
pub use ::marker::*;

test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-vec/src/prelude.sw

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ pub use ::raw_ptr::*;
2828
pub use ::raw_slice::*;
2929
pub use ::codec::*;
3030
pub use ::str::*;
31-
#[cfg(experimental_error_type = true)]
3231
pub use ::marker::*;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cmds = [
2-
"forc build --path {root} --release --experimental error_type",
32
"forc build --path {root} --release",
4-
]
3+
"forc build --path {root} --release",
4+
]

test/src/e2e_vm_tests/test_programs/should_fail/attributes_error_type_and_error/stdout.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: test/src/snapshot/mod.rs
33
---
4-
> forc build --path test/src/e2e_vm_tests/test_programs/should_fail/attributes_error_type_and_error --release --experimental error_type
4+
> forc build --path test/src/e2e_vm_tests/test_programs/should_fail/attributes_error_type_and_error --release
55
exit status: 1
66
output:
77
Building test/src/e2e_vm_tests/test_programs/should_fail/attributes_error_type_and_error
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cmds = ["forc build --path {root} --release --experimental error_type"]
1+
cmds = ["forc build --path {root} --release"]

test/src/e2e_vm_tests/test_programs/should_fail/attributes_invalid_args_values_types/stdout.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: test/src/snapshot/mod.rs
33
---
4-
> forc build --path test/src/e2e_vm_tests/test_programs/should_fail/attributes_invalid_args_values_types --release --experimental error_type
4+
> forc build --path test/src/e2e_vm_tests/test_programs/should_fail/attributes_invalid_args_values_types --release
55
exit status: 1
66
output:
77
Building test/src/e2e_vm_tests/test_programs/should_fail/attributes_invalid_args_values_types
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cmds = ["forc build --path {root} --experimental error_type"]
1+
cmds = ["forc build --path {root}"]

test/src/e2e_vm_tests/test_programs/should_fail/marker_trait_cannot_be_explicitly_implemented/stdout.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: test/src/snapshot/mod.rs
33
---
4-
> forc build --path test/src/e2e_vm_tests/test_programs/should_fail/marker_trait_cannot_be_explicitly_implemented --experimental error_type
4+
> forc build --path test/src/e2e_vm_tests/test_programs/should_fail/marker_trait_cannot_be_explicitly_implemented
55
exit status: 1
66
output:
77
Building test/src/e2e_vm_tests/test_programs/should_fail/marker_trait_cannot_be_explicitly_implemented

test/src/e2e_vm_tests/test_programs/should_fail/marker_trait_enum_not_implemented_for_non_enum/test.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
category = "fail"
2-
experimental = { error_type = true }
32

43
#check: $()error
54
#check: $()implements_enum(0u64);

test/src/e2e_vm_tests/test_programs/should_fail/marker_trait_error_not_implemented_for_non_error_types/test.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
category = "fail"
2-
experimental = { error_type = true }
32

43
#check: $()error
54
#check: $()implements_error(0u64);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cmds = ["forc build --path {root} --release --experimental error_type"]
1+
cmds = ["forc build --path {root} --release"]

test/src/e2e_vm_tests/test_programs/should_fail/reserved_identifiers/stdout.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
source: test/src/snapshot/mod.rs
33
---
4-
> forc build --path test/src/e2e_vm_tests/test_programs/should_fail/reserved_identifiers --release --experimental error_type
4+
> forc build --path test/src/e2e_vm_tests/test_programs/should_fail/reserved_identifiers --release
55
exit status: 1
66
output:
77
Building test/src/e2e_vm_tests/test_programs/should_fail/reserved_identifiers
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cmds = ["forc build --path {root} --release --experimental error_type"]
1+
cmds = ["forc build --path {root} --release"]

test/src/e2e_vm_tests/test_programs/should_pass/language/attributes_error_type_and_error/stdout.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
source: test/src/snapshot/mod.rs
33
assertion_line: 125
44
---
5-
> forc build --path test/src/e2e_vm_tests/test_programs/should_pass/language/attributes_error_type_and_error --release --experimental error_type
5+
> forc build --path test/src/e2e_vm_tests/test_programs/should_pass/language/attributes_error_type_and_error --release
66
exit status: 0
77
output:
88
Building test/src/e2e_vm_tests/test_programs/should_pass/language/attributes_error_type_and_error
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
category = "compile"
2-
experimental = { error_type = true }
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
category = "compile"
2-
experimental = { error_type = true }
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
cmds = [
2-
"forc build --path {root} --experimental error_type --ir initial | regex ' (v0 = call call|v0 = const|v1 = const|revert)'"
3-
]
2+
"forc build --path {root} --ir initial | regex ' (v0 = call call|v0 = const|v1 = const|revert)'"
3+
]

test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_const_eval_string_slices_not_in_bytecode/stdout.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
source: test/src/snapshot/mod.rs
33
assertion_line: 161
44
---
5-
> forc build --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_const_eval_string_slices_not_in_bytecode --experimental error_type --ir initial | regex ' (v0 = call call|v0 = const|v1 = const|revert)'
5+
> forc build --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_const_eval_string_slices_not_in_bytecode --ir initial | regex ' (v0 = call call|v0 = const|v1 = const|revert)'
66
v0 = call call_return_const_str_0_1(), !18
77
v1 = const u64 18446744069414584321
88
revert v1, !19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cmds = [
2-
"forc test --path {root} --experimental error_type --logs --raw-logs --dbgs --reverts passing_",
3-
"forc test --path {root} --experimental error_type",
4-
]
2+
"forc test --path {root} --logs --raw-logs --dbgs --reverts passing_",
3+
"forc test --path {root}",
4+
]

test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests/stdout.snap

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
source: test/src/snapshot/mod.rs
33
assertion_line: 162
44
---
5-
> forc test --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests --experimental error_type --logs --raw-logs --dbgs --reverts passing_
5+
> forc test --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests --logs --raw-logs --dbgs --reverts passing_
66
exit status: 0
77
output:
88
Building test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests
@@ -39,8 +39,7 @@ test result: OK. 2 passed; 0 failed; finished in ???
3939

4040
Finished in ???
4141

42-
> forc test --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests --experimental error_type
43-
exit status: 101
42+
> forc test --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests exit status: 101
4443
output:
4544
Building test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests
4645
Compiling library std (sway-lib-std)
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
category = "compile"
22
expected_warnings = 0
3-
experimental = { error_type = true, new_encoding = true }

0 commit comments

Comments
 (0)