@@ -18,41 +18,6 @@ use crate::{
1818 typecheck:: RitobinName ,
1919} ;
2020
21- pub trait SpannedExt {
22- fn with_span ( self , span : Span ) -> Spanned < Self >
23- where
24- Self : Sized ,
25- {
26- Spanned :: new ( self , span)
27- }
28- }
29- impl < T : Sized > SpannedExt for T { }
30-
31- #[ derive( Debug , Clone , Copy ) ]
32- pub struct Spanned < T > {
33- pub span : Span ,
34- pub inner : T ,
35- }
36-
37- impl < T > Spanned < T > {
38- pub fn new ( item : T , span : Span ) -> Self {
39- Self { inner : item, span }
40- }
41- }
42-
43- impl < T > Deref for Spanned < T > {
44- type Target = T ;
45-
46- fn deref ( & self ) -> & Self :: Target {
47- & self . inner
48- }
49- }
50- impl < T > DerefMut for Spanned < T > {
51- fn deref_mut ( & mut self ) -> & mut Self :: Target {
52- & mut self . inner
53- }
54- }
55-
5621#[ derive( Debug , Clone ) ]
5722pub enum ClassKind {
5823 Str ( String ) ,
@@ -61,12 +26,12 @@ pub enum ClassKind {
6126
6227#[ derive( Debug , Clone ) ]
6328pub struct IrEntry {
64- pub key : Spanned < PropertyValueEnum > ,
65- pub value : Spanned < PropertyValueEnum > ,
29+ pub key : PropertyValueEnum < Span > ,
30+ pub value : PropertyValueEnum < Span > ,
6631}
6732
6833#[ derive( Debug , Clone ) ]
69- pub struct IrListItem ( pub Spanned < PropertyValueEnum > ) ;
34+ pub struct IrListItem ( pub PropertyValueEnum < Span > ) ;
7035
7136#[ derive( Debug , Clone ) ]
7237pub enum IrItem {
@@ -94,19 +59,19 @@ impl IrItem {
9459 _ => None ,
9560 }
9661 }
97- pub fn value ( & self ) -> & Spanned < PropertyValueEnum > {
62+ pub fn value ( & self ) -> & PropertyValueEnum < Span > {
9863 match self {
9964 IrItem :: Entry ( i) => & i. value ,
10065 IrItem :: ListItem ( i) => & i. 0 ,
10166 }
10267 }
103- pub fn value_mut ( & mut self ) -> & mut Spanned < PropertyValueEnum > {
68+ pub fn value_mut ( & mut self ) -> & mut PropertyValueEnum < Span > {
10469 match self {
10570 IrItem :: Entry ( i) => & mut i. value ,
10671 IrItem :: ListItem ( i) => & mut i. 0 ,
10772 }
10873 }
109- pub fn into_value ( self ) -> Spanned < PropertyValueEnum > {
74+ pub fn into_value ( self ) -> PropertyValueEnum < Span > {
11075 match self {
11176 IrItem :: Entry ( i) => i. value ,
11277 IrItem :: ListItem ( i) => i. 0 ,
@@ -116,7 +81,7 @@ impl IrItem {
11681
11782pub struct TypeChecker < ' a > {
11883 ctx : Ctx < ' a > ,
119- pub root : IndexMap < String , Spanned < PropertyValueEnum > > ,
84+ pub root : IndexMap < String , PropertyValueEnum < Span > > ,
12085 // current: Option<(PropertyValueEnum, PropertyValueEnum)>,
12186 stack : Vec < ( u32 , IrItem ) > ,
12287 list_queue : Vec < IrListItem > ,
@@ -139,7 +104,7 @@ impl<'a> TypeChecker<'a> {
139104 pub fn into_parts (
140105 self ,
141106 ) -> (
142- IndexMap < String , Spanned < PropertyValueEnum > > ,
107+ IndexMap < String , PropertyValueEnum < Span > > ,
143108 Vec < DiagnosticWithSpan > ,
144109 ) {
145110 ( self . root , self . ctx . diagnostics )
@@ -476,7 +441,7 @@ pub fn resolve_value(
476441 ctx : & mut Ctx ,
477442 tree : & Cst ,
478443 kind_hint : Option < PropertyKind > ,
479- ) -> Result < Option < Spanned < PropertyValueEnum > > , Diagnostic > {
444+ ) -> Result < Option < PropertyValueEnum < Span > > , Diagnostic > {
480445 use PropertyKind as K ;
481446 use PropertyValueEnum as P ;
482447
@@ -783,19 +748,19 @@ fn populate_vec_or_color(
783748 target : & mut IrItem ,
784749 items : & mut Vec < IrListItem > ,
785750) -> Result < ( ) , MaybeSpanDiag > {
786- let resolve_f32 = |n : Spanned < PropertyValueEnum > | -> Result < f32 , MaybeSpanDiag > {
787- match n. inner {
788- PropertyValueEnum :: F32 ( values:: F32 { value : n, .. } ) => Ok ( n) ,
751+ let resolve_f32 = |n : PropertyValueEnum < Span > | -> Result < f32 , MaybeSpanDiag > {
752+ match n {
753+ PropertyValueEnum :: F32 ( values:: F32 { value : n, meta : span } ) => Ok ( n) ,
789754 _ => Err ( TypeMismatch {
790- span : n. span ,
755+ span : n. meta ( ) ,
791756 expected : RitoType :: simple ( PropertyKind :: F32 ) ,
792757 expected_span : None , // TODO: would be nice
793- got : RitoTypeOrVirtual :: RitoType ( RitoType :: simple ( n. inner . kind ( ) ) ) ,
758+ got : RitoTypeOrVirtual :: RitoType ( RitoType :: simple ( n. kind ( ) ) ) ,
794759 }
795760 . into ( ) ) ,
796761 }
797762 } ;
798- let resolve_u8 = |n : Spanned < PropertyValueEnum > | -> Result < u8 , MaybeSpanDiag > {
763+ let resolve_u8 = |n : PropertyValueEnum < Span > | -> Result < u8 , MaybeSpanDiag > {
799764 match n. inner {
800765 PropertyValueEnum :: U8 ( values:: U8 { value : n, .. } ) => Ok ( n) ,
801766 _ => Err ( TypeMismatch {
0 commit comments