-
Notifications
You must be signed in to change notification settings - Fork 263
(c2rust-analyze
) Handle inline const
refs, including string literals
#886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f34a3c1
(`c2rust-analyze/tests`) Added more `string_literals.rs` tests to nar…
kkysen 96ad50c
(`c2rust-analyze/tests`) Split `string_literals` test cases in inline…
kkysen 2ba20fa
(`c2rust-analyze`) Handle local `const` refs (incl. `""`, `b""`) with…
kkysen 4ae78c8
(`c2rust-analyze`) Restrict `const_tys => const_ref_tys` to just `ty:…
kkysen bed143d
(`c2rust-analyze`) Add known perms for const refs before dataflow typ…
kkysen a196089
(`c2rust-analyze`) Move `fn const_perms` to `pub fn PermissionSet::fo…
kkysen de38cfc
(`c2rust-analyze`) Move and fully implement the post-typeck const ref…
kkysen 91bfa85
(`c2rust-analyze`) Ignore `UNIQUE` in checking const refs' perms post…
kkysen 7a64e58
(`c2rust-analyze`) Use `Self` in `PermissionSet::for_const`.
kkysen f48e239
(`c2rust-analyze`) Rename `PermissionSet::{for_const => for_const_ref…
kkysen e451ab0
(`c2rust-analyze`) Refactor out `PermissionSet::for_const_ref_ty` fro…
kkysen 8665bc2
(`c2rust-analyze`) Replace `AnalysisCtxt::const_ref_{tys: HashMap<Con…
kkysen 36cdf90
(`c2rust-analyze`) Refactor out `AnalysisCtxt::const_ref_tys() -> imp…
kkysen d4f269a
(`c2rust-analyze`) Refactor out `AnalysisCtxt::check_const_ref_perms`.
kkysen f14050b
(`c2rust-analyze`) Refactor out `AnalysisCtxt::const_ref_perms` (need…
kkysen 57dd358
Merge branch 'master' into kkysen/analyze-string-literals
kkysen 012c46f
(`c2rust-analyze`) Forgot to actually add the const ref `Location`s t…
kkysen 6c8f65c
(`c2rust-analyze`) Rewrite the `ConstantKind` check as a `match` not …
kkysen 6a06083
(`c2rust-analyze`) Error immediately rather than continue and later e…
kkysen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -525,6 +525,10 @@ pub fn visit<'tcx>( | |
equiv_constraints: Vec::new(), | ||
}; | ||
|
||
for (ptr, perms) in acx.const_ref_perms() { | ||
tc.constraints.add_all_perms(ptr, perms); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not add the constraints as you see consts in |
||
} | ||
|
||
for (bb, bb_data) in mir.basic_blocks().iter_enumerated() { | ||
for (i, stmt) in bb_data.statements.iter().enumerate() { | ||
tc.visit_statement( | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,9 +1,32 @@ | ||
pub fn inline_desugared_bstr() -> &'static [u8; 0] { | ||
&[] | ||
} | ||
|
||
const DESUGARED_BSTR: &'static [u8; 0] = &[]; | ||
|
||
#[cfg(any())] | ||
pub fn outline_desugared_bstr() -> &'static [u8; 0] { | ||
DESUGARED_BSTR | ||
} | ||
|
||
pub fn inline_bstr() -> &'static [u8; 0] { | ||
b"" | ||
} | ||
|
||
const BSTR: &'static [u8; 0] = b""; | ||
|
||
#[cfg(any())] | ||
pub fn str() { | ||
""; | ||
pub fn outline_bstr() -> &'static [u8; 0] { | ||
BSTR | ||
} | ||
|
||
pub fn inline_str() -> &'static str { | ||
"" | ||
} | ||
|
||
const STR: &'static str = ""; | ||
|
||
#[cfg(any())] | ||
pub fn bstr() { | ||
b""; | ||
pub fn outline_str() -> &'static str { | ||
STR | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.