Skip to content

Commit

Permalink
Add span field to trait for forc doc (FuelLabs#3090)
Browse files Browse the repository at this point in the history
  • Loading branch information
eureka-cpu authored Oct 21, 2022
1 parent 3de373d commit faf55cb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions sway-core/src/language/parsed/declaration/trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct TraitDeclaration {
pub methods: Vec<FunctionDeclaration>,
pub(crate) supertraits: Vec<Supertrait>,
pub visibility: Visibility,
pub span: Span,
}

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
Expand Down
3 changes: 2 additions & 1 deletion sway-core/src/language/ty/declaration/trait.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use derivative::Derivative;
use sway_types::Ident;
use sway_types::{Ident, Span};

use crate::{
declaration_engine::DeclarationId,
Expand All @@ -22,6 +22,7 @@ pub struct TyTraitDeclaration {
pub(crate) supertraits: Vec<parsed::Supertrait>,
pub visibility: Visibility,
pub attributes: transform::AttributesMap,
pub span: Span,
}

impl CopyTypes for TyTraitDeclaration {
Expand Down
2 changes: 2 additions & 0 deletions sway-core/src/semantic_analysis/ast_node/declaration/trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl ty::TyTraitDeclaration {
methods,
supertraits,
visibility,
span,
} = trait_decl;

if !is_upper_camel_case(name.as_str()) {
Expand Down Expand Up @@ -105,6 +106,7 @@ impl ty::TyTraitDeclaration {
supertraits,
visibility,
attributes,
span,
};
ok(typed_trait_decl, warnings, errors)
}
Expand Down
5 changes: 3 additions & 2 deletions sway-core/src/transform/to_parsed_lang/convert_parse_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ fn item_trait_to_trait_declaration(
item_trait: ItemTrait,
attributes: AttributesMap,
) -> Result<TraitDeclaration, ErrorEmitted> {
let name = item_trait.name;
let span = item_trait.span();
let type_parameters = generic_params_opt_to_type_parameters(
handler,
item_trait.generics,
Expand Down Expand Up @@ -445,13 +445,14 @@ fn item_trait_to_trait_declaration(
};
let visibility = pub_token_opt_to_visibility(item_trait.visibility);
Ok(TraitDeclaration {
name,
name: item_trait.name,
type_parameters,
interface_surface,
methods,
supertraits,
visibility,
attributes,
span,
})
}

Expand Down

0 comments on commit faf55cb

Please sign in to comment.