-
Couldn't load subscription status.
- Fork 400
initial implementation of wildcard provenence for tree borrows #4630
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
Open
royAmmerschuber
wants to merge
8
commits into
rust-lang:master
Choose a base branch
from
royAmmerschuber:pull-request/wildcard-provenance
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,839
−163
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fdf62f8
disable tree-borrows strict provenance requirement
royAmmerschuber 165a18a
respect idempotent foreign access optimization
royAmmerschuber 0d40e7b
fix formatting
royAmmerschuber e518de0
properly handle conflicted protected tags
royAmmerschuber 66aa932
smaller changes
royAmmerschuber fd2438b
improve comments
royAmmerschuber fd1f4f7
fix verify_consistency
royAmmerschuber adab680
fix formatting & improve error messages
royAmmerschuber 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
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 |
|---|---|---|
|
|
@@ -291,9 +291,10 @@ pub(super) struct TbError<'node> { | |
| pub conflicting_info: &'node NodeDebugInfo, | ||
| // What kind of access caused this error (read, write, reborrow, deallocation) | ||
| pub access_cause: AccessCause, | ||
| /// Which tag the access that caused this error was made through, i.e. | ||
| /// Which tag if any the access that caused this error was made through, i.e. | ||
| /// which tag was used to read/write/deallocate. | ||
| pub accessed_info: &'node NodeDebugInfo, | ||
| /// Not set on wildcard accesses. | ||
| pub accessed_info: Option<&'node NodeDebugInfo>, | ||
|
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. This needs an explanation of what |
||
| } | ||
|
|
||
| impl TbError<'_> { | ||
|
|
@@ -302,10 +303,12 @@ impl TbError<'_> { | |
| use TransitionError::*; | ||
| let cause = self.access_cause; | ||
| let accessed = self.accessed_info; | ||
| let accessed_str = | ||
| self.accessed_info.map(|v| format!("{v}")).unwrap_or_else(|| "wildcard".into()); | ||
| let conflicting = self.conflicting_info; | ||
| let accessed_is_conflicting = accessed.tag == conflicting.tag; | ||
| let accessed_is_conflicting = accessed.map(|a| a.tag == conflicting.tag).unwrap_or(false); | ||
| let title = format!( | ||
| "{cause} through {accessed} at {alloc_id:?}[{offset:#x}] is forbidden", | ||
| "{cause} through {accessed_str} at {alloc_id:?}[{offset:#x}] is forbidden", | ||
| alloc_id = self.alloc_id, | ||
| offset = self.error_offset | ||
| ); | ||
|
|
@@ -316,7 +319,7 @@ impl TbError<'_> { | |
| let mut details = Vec::new(); | ||
| if !accessed_is_conflicting { | ||
| details.push(format!( | ||
| "the accessed tag {accessed} is a child of the conflicting tag {conflicting}" | ||
| "the accessed tag {accessed_str} is a child of the conflicting tag {conflicting}" | ||
| )); | ||
| } | ||
| let access = cause.print_as_access(/* is_foreign */ false); | ||
|
|
@@ -330,7 +333,7 @@ impl TbError<'_> { | |
| let access = cause.print_as_access(/* is_foreign */ true); | ||
| let details = vec![ | ||
| format!( | ||
| "the accessed tag {accessed} is foreign to the {conflicting_tag_name} tag {conflicting} (i.e., it is not a child)" | ||
| "the accessed tag {accessed_str} is foreign to the {conflicting_tag_name} tag {conflicting} (i.e., it is not a child)" | ||
| ), | ||
| format!( | ||
| "this {access} would cause the {conflicting_tag_name} tag {conflicting} (currently {before_disabled}) to become Disabled" | ||
|
|
@@ -343,16 +346,18 @@ impl TbError<'_> { | |
| let conflicting_tag_name = "strongly protected"; | ||
| let details = vec![ | ||
| format!( | ||
| "the allocation of the accessed tag {accessed} also contains the {conflicting_tag_name} tag {conflicting}" | ||
| "the allocation of the accessed tag {accessed_str} also contains the {conflicting_tag_name} tag {conflicting}" | ||
| ), | ||
| format!("the {conflicting_tag_name} tag {conflicting} disallows deallocations"), | ||
| ]; | ||
| (title, details, conflicting_tag_name) | ||
| } | ||
| }; | ||
| let mut history = HistoryData::default(); | ||
| if !accessed_is_conflicting { | ||
| history.extend(self.accessed_info.history.forget(), "accessed", false); | ||
| if let Some(accessed_info) = self.accessed_info | ||
| && !accessed_is_conflicting | ||
| { | ||
| history.extend(accessed_info.history.forget(), "accessed", false); | ||
| } | ||
| history.extend( | ||
| self.conflicting_info.history.extract_relevant(self.error_offset, self.error_kind), | ||
|
|
@@ -362,6 +367,21 @@ impl TbError<'_> { | |
| err_machine_stop!(TerminationInfo::TreeBorrowsUb { title, details, history }) | ||
| } | ||
| } | ||
| /// Cannot access this allocation with wildcard provenance, as there are no | ||
| /// valid exposed references for this access kind. | ||
| pub fn no_valid_exposed_references_error<'tcx>( | ||
| alloc_id: AllocId, | ||
| offset: u64, | ||
| access_cause: AccessCause, | ||
| ) -> InterpErrorKind<'tcx> { | ||
| let title = | ||
| format!("{access_cause} through wildcard at {alloc_id:?}[{offset:#x}] is forbidden"); | ||
| let details = vec![format!( | ||
| "there are no exposed references who have {access_cause} permissions to this location" | ||
| )]; | ||
| let history = HistoryData::default(); | ||
| err_machine_stop!(TerminationInfo::TreeBorrowsUb { title, details, history }) | ||
| } | ||
|
|
||
| type S = &'static str; | ||
| /// Pretty-printing details | ||
|
|
@@ -625,8 +645,8 @@ impl DisplayRepr { | |
| let rperm = tree | ||
| .rperms | ||
| .iter_all() | ||
| .map(move |(_offset, perms)| { | ||
| let perm = perms.get(idx); | ||
| .map(move |(_offset, loc)| { | ||
| let perm = loc.perms.get(idx); | ||
| perm.cloned() | ||
| }) | ||
| .collect::<Vec<_>>(); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be something like
(if any)or, if any,.