@@ -64,8 +64,7 @@ impl Files {
6464 }
6565
6666 pub fn set_file_text ( & self , db : & mut dyn SourceDatabase , file_id : vfs:: FileId , text : & str ) {
67- let files = Arc :: clone ( & self . files ) ;
68- match files. entry ( file_id) {
67+ match self . files . entry ( file_id) {
6968 Entry :: Occupied ( mut occupied) => {
7069 occupied. get_mut ( ) . set_text ( db) . to ( Arc :: from ( text) ) ;
7170 }
@@ -83,8 +82,7 @@ impl Files {
8382 text : & str ,
8483 durability : Durability ,
8584 ) {
86- let files = Arc :: clone ( & self . files ) ;
87- match files. entry ( file_id) {
85+ match self . files . entry ( file_id) {
8886 Entry :: Occupied ( mut occupied) => {
8987 occupied. get_mut ( ) . set_text ( db) . with_durability ( durability) . to ( Arc :: from ( text) ) ;
9088 }
@@ -113,8 +111,7 @@ impl Files {
113111 source_root : Arc < SourceRoot > ,
114112 durability : Durability ,
115113 ) {
116- let source_roots = Arc :: clone ( & self . source_roots ) ;
117- match source_roots. entry ( source_root_id) {
114+ match self . source_roots . entry ( source_root_id) {
118115 Entry :: Occupied ( mut occupied) => {
119116 occupied. get_mut ( ) . set_source_root ( db) . with_durability ( durability) . to ( source_root) ;
120117 }
@@ -141,9 +138,7 @@ impl Files {
141138 source_root_id : SourceRootId ,
142139 durability : Durability ,
143140 ) {
144- let file_source_roots = Arc :: clone ( & self . file_source_roots ) ;
145- // let db = self;
146- match file_source_roots. entry ( id) {
141+ match self . file_source_roots . entry ( id) {
147142 Entry :: Occupied ( mut occupied) => {
148143 occupied
149144 . get_mut ( )
@@ -203,7 +198,8 @@ pub trait RootQueryDb: SourceDatabase + salsa::Database {
203198 fn parse ( & self , file_id : EditionedFileId ) -> Parse < ast:: SourceFile > ;
204199
205200 /// Returns the set of errors obtained from parsing the file including validation errors.
206- fn parse_errors ( & self , file_id : EditionedFileId ) -> Option < Arc < [ SyntaxError ] > > ;
201+ #[ salsa:: transparent]
202+ fn parse_errors ( & self , file_id : EditionedFileId ) -> Option < & [ SyntaxError ] > ;
207203
208204 #[ salsa:: transparent]
209205 fn toolchain_channel ( & self , krate : Crate ) -> Option < ReleaseChannel > ;
@@ -318,12 +314,16 @@ fn parse(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Parse<ast::SourceFil
318314 ast:: SourceFile :: parse ( & text, edition)
319315}
320316
321- fn parse_errors ( db : & dyn RootQueryDb , file_id : EditionedFileId ) -> Option < Arc < [ SyntaxError ] > > {
322- let errors = db. parse ( file_id) . errors ( ) ;
323- match & * errors {
324- [ ] => None ,
325- [ ..] => Some ( errors. into ( ) ) ,
317+ fn parse_errors ( db : & dyn RootQueryDb , file_id : EditionedFileId ) -> Option < & [ SyntaxError ] > {
318+ #[ salsa:: tracked( return_ref) ]
319+ fn parse_errors ( db : & dyn RootQueryDb , file_id : EditionedFileId ) -> Option < Box < [ SyntaxError ] > > {
320+ let errors = db. parse ( file_id) . errors ( ) ;
321+ match & * errors {
322+ [ ] => None ,
323+ [ ..] => Some ( errors. into ( ) ) ,
324+ }
326325 }
326+ parse_errors ( db, file_id) . as_ref ( ) . map ( |it| & * * it)
327327}
328328
329329fn source_root_crates ( db : & dyn RootQueryDb , id : SourceRootId ) -> Arc < [ Crate ] > {
0 commit comments