@@ -64,8 +64,7 @@ impl Files {
64
64
}
65
65
66
66
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) {
69
68
Entry :: Occupied ( mut occupied) => {
70
69
occupied. get_mut ( ) . set_text ( db) . to ( Arc :: from ( text) ) ;
71
70
}
@@ -83,8 +82,7 @@ impl Files {
83
82
text : & str ,
84
83
durability : Durability ,
85
84
) {
86
- let files = Arc :: clone ( & self . files ) ;
87
- match files. entry ( file_id) {
85
+ match self . files . entry ( file_id) {
88
86
Entry :: Occupied ( mut occupied) => {
89
87
occupied. get_mut ( ) . set_text ( db) . with_durability ( durability) . to ( Arc :: from ( text) ) ;
90
88
}
@@ -113,8 +111,7 @@ impl Files {
113
111
source_root : Arc < SourceRoot > ,
114
112
durability : Durability ,
115
113
) {
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) {
118
115
Entry :: Occupied ( mut occupied) => {
119
116
occupied. get_mut ( ) . set_source_root ( db) . with_durability ( durability) . to ( source_root) ;
120
117
}
@@ -141,9 +138,7 @@ impl Files {
141
138
source_root_id : SourceRootId ,
142
139
durability : Durability ,
143
140
) {
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) {
147
142
Entry :: Occupied ( mut occupied) => {
148
143
occupied
149
144
. get_mut ( )
@@ -203,7 +198,8 @@ pub trait RootQueryDb: SourceDatabase + salsa::Database {
203
198
fn parse ( & self , file_id : EditionedFileId ) -> Parse < ast:: SourceFile > ;
204
199
205
200
/// 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 ] > ;
207
203
208
204
#[ salsa:: transparent]
209
205
fn toolchain_channel ( & self , krate : Crate ) -> Option < ReleaseChannel > ;
@@ -318,12 +314,16 @@ fn parse(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Parse<ast::SourceFil
318
314
ast:: SourceFile :: parse ( & text, edition)
319
315
}
320
316
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
+ }
326
325
}
326
+ parse_errors ( db, file_id) . as_ref ( ) . map ( |it| & * * it)
327
327
}
328
328
329
329
fn source_root_crates ( db : & dyn RootQueryDb , id : SourceRootId ) -> Arc < [ Crate ] > {
0 commit comments