Skip to content

Commit 90eda24

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

File tree

51 files changed

+109
-253
lines changed

Some content is hidden

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

51 files changed

+109
-253
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+
]

0 commit comments

Comments
 (0)