-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
analyze: omit unused hypothetical lifetimes during rewriting (#1015)
This change removes hypothetical lifetimes for pointers that are rewritten into non-ref types, such as raw pointers or `Box<T>`. The `AdtMetadataTable` is computed normally at first so it can be used in borrowck, but once all pointer permissions have been determined, it's recomputed with an extra filter that skips creating hypothetical region params for pointers whose `type_desc::Ownership` is not `Imm`, `Cell`, or `Mut` (`&T`, `&Cell<T>`, or `&mut T`). For example: ```Rust struct Foo { p: *mut u8, #[c2rust_analyze_test::fixed_signature] q: *mut u8, } ``` Previously, `Foo` would be rewritten to have two new region parameters, one for `p` and one for `q`. But the region for `q` would unused: `q` is marked `FIXED`, so it's left as `*mut u8` rather than rewritten to a safe reference type. With this change, `Foo` is rewritten to have only one region parameter, the one for `p`. This avoids rustc errors about unused generic parameters in the rewritten code.
- Loading branch information
Showing
8 changed files
with
217 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ define_tests! { | |
offset1, | ||
offset2, | ||
ptrptr1, | ||
regions_fixed, | ||
statics, | ||
test_attrs, | ||
trivial, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.