Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[red-knot] Improve symbol-lookup tracing (#14907)
## Summary When debugging, I frequently want to know which symbols are being looked up. `symbol_by_id` adds tracing information, but it only shows the `ScopedSymbolId`. Since `symbol_by_id` is only called from `symbol`, it seems reasonable to move the tracing call one level up from `symbol_by_id` to `symbol`, where we can also show the name of the symbol. **Before**: ``` 6 └─┐red_knot_python_semantic::types::infer::infer_expression_types{expression=Id(60de), file=/home/shark/tomllib_modified/_parser.py} 6 └─┐red_knot_python_semantic::types::symbol_by_id{symbol=ScopedSymbolId(33)} 6 ┌─┘ 6 └─┐red_knot_python_semantic::types::symbol_by_id{symbol=ScopedSymbolId(123)} 6 ┌─┘ 6 └─┐red_knot_python_semantic::types::symbol_by_id{symbol=ScopedSymbolId(54)} 6 ┌─┘ 6 └─┐red_knot_python_semantic::types::symbol_by_id{symbol=ScopedSymbolId(122)} 6 ┌─┘ 6 └─┐red_knot_python_semantic::types::symbol_by_id{symbol=ScopedSymbolId(165)} 6 ┌─┘ 6 ┌─┘ 6 └─┐red_knot_python_semantic::types::symbol_by_id{symbol=ScopedSymbolId(32)} 6 ┌─┘ 6 └─┐red_knot_python_semantic::types::symbol_by_id{symbol=ScopedSymbolId(232)} 6 ┌─┘ 6 ┌─┘ 6 ┌─┘ 6┌─┘ ``` **After**: ``` 5 └─┐red_knot_python_semantic::types::infer::infer_expression_types{expression=Id(60de), file=/home/shark/tomllib_modified/_parser.py} 5 └─┐red_knot_python_semantic::types::symbol{name="dict"} 5 ┌─┘ 5 └─┐red_knot_python_semantic::types::symbol{name="dict"} 5 ┌─┘ 5 └─┐red_knot_python_semantic::types::symbol{name="list"} 5 ┌─┘ 5 └─┐red_knot_python_semantic::types::symbol{name="list"} 5 ┌─┘ 5 └─┐red_knot_python_semantic::types::symbol{name="isinstance"} 5 ┌─┘ 5 └─┐red_knot_python_semantic::types::symbol{name="isinstance"} 5 ┌─┘ 5 ┌─┘ 5 └─┐red_knot_python_semantic::types::symbol{name="ValueError"} 5 ┌─┘ 5 └─┐red_knot_python_semantic::types::symbol{name="ValueError"} 5 ┌─┘ 5 ┌─┘ 5 ┌─┘ 5┌─┘ ``` ## Test Plan ``` cargo run --bin red_knot -- --current-directory path/to/tomllib -vvv ```
- Loading branch information