@@ -70,8 +70,7 @@ pub(crate) fn place_table<'db>(db: &'db dyn Db, scope: ScopeId<'db>) -> Arc<Plac
7070 let file = scope. file ( db) ;
7171 let _span = tracing:: trace_span!( "place_table" , scope=?scope. as_id( ) , ?file) . entered ( ) ;
7272 let index = semantic_index ( db, file) ;
73-
74- index. place_table ( scope. file_scope_id ( db) )
73+ Arc :: clone ( & index. place_tables [ scope. file_scope_id ( db) ] )
7574}
7675
7776/// Returns the set of modules that are imported anywhere in `file`.
@@ -100,8 +99,7 @@ pub(crate) fn use_def_map<'db>(db: &'db dyn Db, scope: ScopeId<'db>) -> Arc<UseD
10099 let file = scope. file ( db) ;
101100 let _span = tracing:: trace_span!( "use_def_map" , scope=?scope. as_id( ) , ?file) . entered ( ) ;
102101 let index = semantic_index ( db, file) ;
103-
104- index. use_def_map ( scope. file_scope_id ( db) )
102+ Arc :: clone ( & index. use_def_maps [ scope. file_scope_id ( db) ] )
105103}
106104
107105/// Returns all attribute assignments (and their method scope IDs) with a symbol name matching
@@ -252,17 +250,17 @@ impl<'db> SemanticIndex<'db> {
252250 /// Use the Salsa cached [`place_table()`] query if you only need the
253251 /// place table for a single scope.
254252 #[ track_caller]
255- pub ( super ) fn place_table ( & self , scope_id : FileScopeId ) -> Arc < PlaceTable > {
256- self . place_tables [ scope_id] . clone ( )
253+ pub ( super ) fn place_table ( & self , scope_id : FileScopeId ) -> & PlaceTable {
254+ & self . place_tables [ scope_id]
257255 }
258256
259257 /// Returns the use-def map for a specific scope.
260258 ///
261259 /// Use the Salsa cached [`use_def_map()`] query if you only need the
262260 /// use-def map for a single scope.
263261 #[ track_caller]
264- pub ( super ) fn use_def_map ( & self , scope_id : FileScopeId ) -> Arc < UseDefMap < ' _ > > {
265- self . use_def_maps [ scope_id] . clone ( )
262+ pub ( super ) fn use_def_map ( & self , scope_id : FileScopeId ) -> & UseDefMap < ' db > {
263+ & self . use_def_maps [ scope_id]
266264 }
267265
268266 #[ track_caller]
@@ -907,7 +905,7 @@ y = 2
907905 ) ;
908906
909907 let class_table = index. place_table ( class_scope_id) ;
910- assert_eq ! ( names( & class_table) , vec![ "x" ] ) ;
908+ assert_eq ! ( names( class_table) , vec![ "x" ] ) ;
911909
912910 let use_def = index. use_def_map ( class_scope_id) ;
913911 let binding = use_def
@@ -929,7 +927,7 @@ y = 2
929927 let index = semantic_index ( & db, file) ;
930928 let global_table = index. place_table ( FileScopeId :: global ( ) ) ;
931929
932- assert_eq ! ( names( & global_table) , vec![ "func" , "y" ] ) ;
930+ assert_eq ! ( names( global_table) , vec![ "func" , "y" ] ) ;
933931
934932 let [ ( function_scope_id, function_scope) ] = index
935933 . child_scopes ( FileScopeId :: global ( ) )
@@ -944,7 +942,7 @@ y = 2
944942 ) ;
945943
946944 let function_table = index. place_table ( function_scope_id) ;
947- assert_eq ! ( names( & function_table) , vec![ "x" ] ) ;
945+ assert_eq ! ( names( function_table) , vec![ "x" ] ) ;
948946
949947 let use_def = index. use_def_map ( function_scope_id) ;
950948 let binding = use_def
@@ -976,7 +974,7 @@ def f(a: str, /, b: str, c: int = 1, *args, d: int = 2, **kwargs):
976974
977975 let function_table = index. place_table ( function_scope_id) ;
978976 assert_eq ! (
979- names( & function_table) ,
977+ names( function_table) ,
980978 vec![ "a" , "b" , "c" , "d" , "args" , "kwargs" ] ,
981979 ) ;
982980
@@ -1021,7 +1019,7 @@ def f(a: str, /, b: str, c: int = 1, *args, d: int = 2, **kwargs):
10211019
10221020 let lambda_table = index. place_table ( lambda_scope_id) ;
10231021 assert_eq ! (
1024- names( & lambda_table) ,
1022+ names( lambda_table) ,
10251023 vec![ "a" , "b" , "c" , "d" , "args" , "kwargs" ] ,
10261024 ) ;
10271025
@@ -1062,7 +1060,7 @@ def f(a: str, /, b: str, c: int = 1, *args, d: int = 2, **kwargs):
10621060 let index = semantic_index ( & db, file) ;
10631061 let global_table = index. place_table ( FileScopeId :: global ( ) ) ;
10641062
1065- assert_eq ! ( names( & global_table) , vec![ "iter1" ] ) ;
1063+ assert_eq ! ( names( global_table) , vec![ "iter1" ] ) ;
10661064
10671065 let [ ( comprehension_scope_id, comprehension_scope) ] = index
10681066 . child_scopes ( FileScopeId :: global ( ) )
@@ -1081,7 +1079,7 @@ def f(a: str, /, b: str, c: int = 1, *args, d: int = 2, **kwargs):
10811079
10821080 let comprehension_symbol_table = index. place_table ( comprehension_scope_id) ;
10831081
1084- assert_eq ! ( names( & comprehension_symbol_table) , vec![ "x" , "y" ] ) ;
1082+ assert_eq ! ( names( comprehension_symbol_table) , vec![ "x" , "y" ] ) ;
10851083
10861084 let use_def = index. use_def_map ( comprehension_scope_id) ;
10871085 for name in [ "x" , "y" ] {
@@ -1159,7 +1157,7 @@ def f(a: str, /, b: str, c: int = 1, *args, d: int = 2, **kwargs):
11591157 let index = semantic_index ( & db, file) ;
11601158 let global_table = index. place_table ( FileScopeId :: global ( ) ) ;
11611159
1162- assert_eq ! ( names( & global_table) , vec![ "iter1" ] ) ;
1160+ assert_eq ! ( names( global_table) , vec![ "iter1" ] ) ;
11631161
11641162 let [ ( comprehension_scope_id, comprehension_scope) ] = index
11651163 . child_scopes ( FileScopeId :: global ( ) )
@@ -1178,7 +1176,7 @@ def f(a: str, /, b: str, c: int = 1, *args, d: int = 2, **kwargs):
11781176
11791177 let comprehension_symbol_table = index. place_table ( comprehension_scope_id) ;
11801178
1181- assert_eq ! ( names( & comprehension_symbol_table) , vec![ "y" , "iter2" ] ) ;
1179+ assert_eq ! ( names( comprehension_symbol_table) , vec![ "y" , "iter2" ] ) ;
11821180
11831181 let [ ( inner_comprehension_scope_id, inner_comprehension_scope) ] = index
11841182 . child_scopes ( comprehension_scope_id)
@@ -1197,7 +1195,7 @@ def f(a: str, /, b: str, c: int = 1, *args, d: int = 2, **kwargs):
11971195
11981196 let inner_comprehension_symbol_table = index. place_table ( inner_comprehension_scope_id) ;
11991197
1200- assert_eq ! ( names( & inner_comprehension_symbol_table) , vec![ "x" ] ) ;
1198+ assert_eq ! ( names( inner_comprehension_symbol_table) , vec![ "x" ] ) ;
12011199 }
12021200
12031201 #[ test]
@@ -1212,7 +1210,7 @@ with item1 as x, item2 as y:
12121210 let index = semantic_index ( & db, file) ;
12131211 let global_table = index. place_table ( FileScopeId :: global ( ) ) ;
12141212
1215- assert_eq ! ( names( & global_table) , vec![ "item1" , "x" , "item2" , "y" ] ) ;
1213+ assert_eq ! ( names( global_table) , vec![ "item1" , "x" , "item2" , "y" ] ) ;
12161214
12171215 let use_def = index. use_def_map ( FileScopeId :: global ( ) ) ;
12181216 for name in [ "x" , "y" ] {
@@ -1235,7 +1233,7 @@ with context() as (x, y):
12351233 let index = semantic_index ( & db, file) ;
12361234 let global_table = index. place_table ( FileScopeId :: global ( ) ) ;
12371235
1238- assert_eq ! ( names( & global_table) , vec![ "context" , "x" , "y" ] ) ;
1236+ assert_eq ! ( names( global_table) , vec![ "context" , "x" , "y" ] ) ;
12391237
12401238 let use_def = index. use_def_map ( FileScopeId :: global ( ) ) ;
12411239 for name in [ "x" , "y" ] {
@@ -1260,7 +1258,7 @@ def func():
12601258 let index = semantic_index ( & db, file) ;
12611259 let global_table = index. place_table ( FileScopeId :: global ( ) ) ;
12621260
1263- assert_eq ! ( names( & global_table) , vec![ "func" ] ) ;
1261+ assert_eq ! ( names( global_table) , vec![ "func" ] ) ;
12641262 let [
12651263 ( func_scope1_id, func_scope_1) ,
12661264 ( func_scope2_id, func_scope_2) ,
@@ -1285,8 +1283,8 @@ def func():
12851283
12861284 let func1_table = index. place_table ( func_scope1_id) ;
12871285 let func2_table = index. place_table ( func_scope2_id) ;
1288- assert_eq ! ( names( & func1_table) , vec![ "x" ] ) ;
1289- assert_eq ! ( names( & func2_table) , vec![ "y" ] ) ;
1286+ assert_eq ! ( names( func1_table) , vec![ "x" ] ) ;
1287+ assert_eq ! ( names( func2_table) , vec![ "y" ] ) ;
12901288
12911289 let use_def = index. use_def_map ( FileScopeId :: global ( ) ) ;
12921290 let binding = use_def
@@ -1308,7 +1306,7 @@ def func[T]():
13081306 let index = semantic_index ( & db, file) ;
13091307 let global_table = index. place_table ( FileScopeId :: global ( ) ) ;
13101308
1311- assert_eq ! ( names( & global_table) , vec![ "func" ] ) ;
1309+ assert_eq ! ( names( global_table) , vec![ "func" ] ) ;
13121310
13131311 let [ ( ann_scope_id, ann_scope) ] = index
13141312 . child_scopes ( FileScopeId :: global ( ) )
@@ -1323,7 +1321,7 @@ def func[T]():
13231321 "func"
13241322 ) ;
13251323 let ann_table = index. place_table ( ann_scope_id) ;
1326- assert_eq ! ( names( & ann_table) , vec![ "T" ] ) ;
1324+ assert_eq ! ( names( ann_table) , vec![ "T" ] ) ;
13271325
13281326 let [ ( func_scope_id, func_scope) ] =
13291327 index. child_scopes ( ann_scope_id) . collect :: < Vec < _ > > ( ) [ ..]
@@ -1336,7 +1334,7 @@ def func[T]():
13361334 "func"
13371335 ) ;
13381336 let func_table = index. place_table ( func_scope_id) ;
1339- assert_eq ! ( names( & func_table) , vec![ "x" ] ) ;
1337+ assert_eq ! ( names( func_table) , vec![ "x" ] ) ;
13401338 }
13411339
13421340 #[ test]
@@ -1352,7 +1350,7 @@ class C[T]:
13521350 let index = semantic_index ( & db, file) ;
13531351 let global_table = index. place_table ( FileScopeId :: global ( ) ) ;
13541352
1355- assert_eq ! ( names( & global_table) , vec![ "C" ] ) ;
1353+ assert_eq ! ( names( global_table) , vec![ "C" ] ) ;
13561354
13571355 let [ ( ann_scope_id, ann_scope) ] = index
13581356 . child_scopes ( FileScopeId :: global ( ) )
@@ -1364,7 +1362,7 @@ class C[T]:
13641362 assert_eq ! ( ann_scope. kind( ) , ScopeKind :: TypeParams ) ;
13651363 assert_eq ! ( ann_scope_id. to_scope_id( & db, file) . name( & db, & module) , "C" ) ;
13661364 let ann_table = index. place_table ( ann_scope_id) ;
1367- assert_eq ! ( names( & ann_table) , vec![ "T" ] ) ;
1365+ assert_eq ! ( names( ann_table) , vec![ "T" ] ) ;
13681366 assert ! (
13691367 ann_table
13701368 . symbol_by_name( "T" )
@@ -1383,7 +1381,7 @@ class C[T]:
13831381 class_scope_id. to_scope_id( & db, file) . name( & db, & module) ,
13841382 "C"
13851383 ) ;
1386- assert_eq ! ( names( & index. place_table( class_scope_id) ) , vec![ "x" ] ) ;
1384+ assert_eq ! ( names( index. place_table( class_scope_id) ) , vec![ "x" ] ) ;
13871385 }
13881386
13891387 #[ test]
0 commit comments