diff options
| author | bors <bors@rust-lang.org> | 2024-01-09 15:52:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-09 15:52:34 +0000 |
| commit | 51ac6de6f3226aac50259c3c71b678ef38cdab72 (patch) | |
| tree | 7bd00b11c8c566fa815a6511dacd014df7ea1e0d /compiler/rustc_codegen_gcc/example/std_example.rs | |
| parent | da6f7e2c7b64a0e3c3401ad754abbd7854d13e8a (diff) | |
| parent | ba952e65ffc09d49bb92dfe3beb4bd584c3e82e4 (diff) | |
| download | rust-51ac6de6f3226aac50259c3c71b678ef38cdab72.tar.gz rust-51ac6de6f3226aac50259c3c71b678ef38cdab72.zip | |
Auto merge of #16277 - roife:fix-issue16276, r=Veykril
Resolve panic in `generate_delegate_methods`
Fixes #16276
This PR addresses two issues:
1. When using `PathTransform`, it searches for the node corresponding to the `path` in the `source_scope` during `make::fn_`. Therefore, we need to perform the transform before `make::fn_` (similar to the problem in issue #15804). Otherwise, even though the tokens are the same, their offsets (i.e., `span`) differ, resulting in the error "Can't find CONST_ARG@xxx."
2. As mentioned in the first point, `PathTransform` searches for the node corresponding to the `path` in the `source_scope`. Thus, when transforming paths, we should update nodes from right to left (i.e., use **reverse of preorder** (right -> left -> root) instead of **postorder** (left -> right -> root)). Reasons are as follows:
In the red-green tree (rowan), we do not store absolute ranges but instead store the length of each node and dynamically calculate offsets (spans). Therefore, when modifying the left-side node (such as nodes are inserted or deleted), it causes all right-side nodes' spans to change. This, in turn, leads to PathTransform being unable to find nodes with the same paths (due to different spans), resulting in errors.
Diffstat (limited to 'compiler/rustc_codegen_gcc/example/std_example.rs')
0 files changed, 0 insertions, 0 deletions
