@@ -7,7 +7,7 @@ use either::Either;
77use intern:: Interned ;
88use mbe:: { syntax_node_to_token_tree, DelimiterKind , Punct } ;
99use smallvec:: { smallvec, SmallVec } ;
10- use span:: SyntaxContextId ;
10+ use span:: Span ;
1111use syntax:: { ast, match_ast, AstNode , AstToken , SmolStr , SyntaxNode } ;
1212use triomphe:: Arc ;
1313
@@ -53,7 +53,7 @@ impl RawAttrs {
5353 id,
5454 input : Some ( Interned :: new ( AttrInput :: Literal ( SmolStr :: new ( doc) ) ) ) ,
5555 path : Interned :: new ( ModPath :: from ( crate :: name!( doc) ) ) ,
56- ctxt : span_map. span_for_range ( comment. syntax ( ) . text_range ( ) ) . ctx ,
56+ span : span_map. span_for_range ( comment. syntax ( ) . text_range ( ) ) ,
5757 } ) ,
5858 } ) ;
5959 let entries: Arc < [ Attr ] > = Arc :: from_iter ( entries) ;
@@ -120,7 +120,7 @@ impl RawAttrs {
120120 let attrs =
121121 parts. enumerate ( ) . take ( 1 << AttrId :: CFG_ATTR_BITS ) . filter_map ( |( idx, attr) | {
122122 let tree = Subtree {
123- delimiter : tt:: Delimiter :: dummy_invisible ( ) ,
123+ delimiter : tt:: Delimiter :: invisible_spanned ( attr . first ( ) ? . first_span ( ) ) ,
124124 token_trees : attr. to_vec ( ) ,
125125 } ;
126126 Attr :: from_tt ( db, & tree, index. with_cfg_attr ( idx) )
@@ -177,7 +177,7 @@ pub struct Attr {
177177 pub id : AttrId ,
178178 pub path : Interned < ModPath > ,
179179 pub input : Option < Interned < AttrInput > > ,
180- pub ctxt : SyntaxContextId ,
180+ pub span : Span ,
181181}
182182
183183#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
@@ -206,19 +206,20 @@ impl Attr {
206206 id : AttrId ,
207207 ) -> Option < Attr > {
208208 let path = Interned :: new ( ModPath :: from_src ( db, ast. path ( ) ?, span_map) ?) ;
209+ let span = span_map. span_for_range ( ast. syntax ( ) . text_range ( ) ) ;
209210 let input = if let Some ( ast:: Expr :: Literal ( lit) ) = ast. expr ( ) {
210211 let value = match lit. kind ( ) {
211212 ast:: LiteralKind :: String ( string) => string. value ( ) ?. into ( ) ,
212213 _ => lit. syntax ( ) . first_token ( ) ?. text ( ) . trim_matches ( '"' ) . into ( ) ,
213214 } ;
214215 Some ( Interned :: new ( AttrInput :: Literal ( value) ) )
215216 } else if let Some ( tt) = ast. token_tree ( ) {
216- let tree = syntax_node_to_token_tree ( tt. syntax ( ) , span_map) ;
217+ let tree = syntax_node_to_token_tree ( tt. syntax ( ) , span_map, span ) ;
217218 Some ( Interned :: new ( AttrInput :: TokenTree ( Box :: new ( tree) ) ) )
218219 } else {
219220 None
220221 } ;
221- Some ( Attr { id, path, input, ctxt : span_map . span_for_range ( ast . syntax ( ) . text_range ( ) ) . ctx } )
222+ Some ( Attr { id, path, input, span } )
222223 }
223224
224225 fn from_tt ( db : & dyn ExpandDatabase , tt : & tt:: Subtree , id : AttrId ) -> Option < Attr > {
@@ -266,7 +267,7 @@ impl Attr {
266267 pub fn parse_path_comma_token_tree < ' a > (
267268 & ' a self ,
268269 db : & ' a dyn ExpandDatabase ,
269- ) -> Option < impl Iterator < Item = ( ModPath , SyntaxContextId ) > + ' a > {
270+ ) -> Option < impl Iterator < Item = ( ModPath , Span ) > + ' a > {
270271 let args = self . token_tree_value ( ) ?;
271272
272273 if args. delimiter . kind != DelimiterKind :: Parenthesis {
@@ -282,7 +283,7 @@ impl Attr {
282283 // FIXME: This is necessarily a hack. It'd be nice if we could avoid allocation
283284 // here or maybe just parse a mod path from a token tree directly
284285 let subtree = tt:: Subtree {
285- delimiter : tt:: Delimiter :: dummy_invisible ( ) ,
286+ delimiter : tt:: Delimiter :: invisible_spanned ( tts . first ( ) ? . first_span ( ) ) ,
286287 token_trees : tts. to_vec ( ) ,
287288 } ;
288289 let ( parse, span_map) =
@@ -294,7 +295,7 @@ impl Attr {
294295 return None ;
295296 }
296297 let path = meta. path ( ) ?;
297- let call_site = span_map. span_at ( path. syntax ( ) . text_range ( ) . start ( ) ) . ctx ;
298+ let call_site = span_map. span_at ( path. syntax ( ) . text_range ( ) . start ( ) ) ;
298299 Some ( (
299300 ModPath :: from_src ( db, path, SpanMapRef :: ExpansionSpanMap ( & span_map) ) ?,
300301 call_site,
0 commit comments