@@ -15,7 +15,7 @@ use hir_expand::{name::Name, ExpandError, InFile};
1515use la_arena:: { Arena , ArenaMap , Idx , RawIdx } ;
1616use rustc_hash:: FxHashMap ;
1717use smallvec:: SmallVec ;
18- use span:: { Edition , MacroFileId } ;
18+ use span:: { Edition , MacroFileId , SyntaxContextData } ;
1919use syntax:: { ast, AstPtr , SyntaxNodePtr } ;
2020use triomphe:: Arc ;
2121use tt:: TextRange ;
@@ -37,15 +37,22 @@ use crate::{
3737
3838/// A wrapper around [`span::SyntaxContextId`] that is intended only for comparisons.
3939#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
40- pub struct HygieneId ( pub ( crate ) span:: SyntaxContextId ) ;
40+ pub struct HygieneId ( span:: SyntaxContextId ) ;
4141
4242impl HygieneId {
43- pub const ROOT : Self = Self ( span:: SyntaxContextId :: ROOT ) ;
43+ // The edition doesn't matter here, we only use this for comparisons and to lookup the macro.
44+ pub const ROOT : Self = Self ( span:: SyntaxContextId :: root ( Edition :: Edition2015 ) ) ;
4445
45- pub fn new ( ctx : span:: SyntaxContextId ) -> Self {
46+ pub fn new ( mut ctx : span:: SyntaxContextId ) -> Self {
47+ // See `Name` for why we're doing that.
48+ ctx. remove_root_edition ( ) ;
4649 Self ( ctx)
4750 }
4851
52+ pub ( crate ) fn lookup ( self , db : & dyn DefDatabase ) -> SyntaxContextData {
53+ db. lookup_intern_syntax_context ( self . 0 )
54+ }
55+
4956 pub ( crate ) fn is_root ( self ) -> bool {
5057 self . 0 . is_root ( )
5158 }
0 commit comments