forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework trait/ABI/impl and constant related code. (FuelLabs#4140)
## Description This splits off the refactoring changes out of FuelLabs#4036 into two commits: [Rework trait/ABI/impl-related structures to be item-based.](FuelLabs@3a8d6ea) [Refactor constant items/decls to have an optional expression.](FuelLabs@3ec0903) No functional changes intended. ## 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.
- Loading branch information
Showing
60 changed files
with
1,343 additions
and
727 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
use crate::priv_prelude::*; | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum ItemImplItem { | ||
Fn(ItemFn), | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct ItemImpl { | ||
pub impl_token: ImplToken, | ||
pub generic_params_opt: Option<GenericParams>, | ||
pub trait_opt: Option<(PathType, ForToken)>, | ||
pub ty: Ty, | ||
pub where_clause_opt: Option<WhereClause>, | ||
pub contents: Braces<Vec<Annotated<ItemFn>>>, | ||
pub contents: Braces<Vec<Annotated<ItemImplItem>>>, | ||
} | ||
|
||
impl Spanned for ItemImpl { | ||
fn span(&self) -> Span { | ||
Span::join(self.impl_token.span(), self.contents.span()) | ||
} | ||
} | ||
|
||
impl Spanned for ItemImplItem { | ||
fn span(&self) -> Span { | ||
match self { | ||
ItemImplItem::Fn(fn_decl) => fn_decl.span(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.