generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 142
Fix for duplicate vtable field names #188
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
avanhatt
merged 11 commits into
model-checking:main-152-2021-06-07
from
avanhatt:duplicate-vtable-names
Jun 9, 2021
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
44339cc
Use dyn trait name (+ function) in vtable field
avanhatt ca70d0d
Remove is_vtable_well_formed flag and turn on assert for unique compo…
avanhatt db057dd
Additional duplicate test with override
avanhatt 25c63d9
Use the instance for dyn trait object pretty names, too, which fixes …
avanhatt 6bec917
Fix import, remove stale dead code
avanhatt 2313681
fix typo
avanhatt b6b761c
Create std_lib_add_duplicate.rs
avanhatt e5f93e1
Add test for duplicates across crates
avanhatt 1acc648
More comment documentation of choices
avanhatt 25fa389
Cleanup: remove stale mut, unused var/imports
avanhatt 776f3e4
Better comments for multiple crate tests
avanhatt 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
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 |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| // This test uses a trait defined in a different crate (the standard library) | ||
| // and a test defined in the local crate. The goal is to test vtable resolution | ||
| // of duplicate names across different crates. | ||
| struct Counter { | ||
| count: usize, | ||
| } | ||
|
|
||
| // A custom impl for the standard library trait. | ||
| impl std::iter::Iterator for Counter { | ||
| type Item = usize; | ||
|
|
||
| fn next(&mut self) -> Option<Self::Item> { | ||
| // Increment our count. | ||
| self.count += 1; | ||
| Some(self.count) | ||
| } | ||
| } | ||
|
|
||
| // An impl for our local trait, with an indentical name to the standard library | ||
| trait Iterator { | ||
| fn next(&mut self) -> Option<usize>; | ||
| } | ||
|
|
||
| impl Iterator for Counter { | ||
| fn next(&mut self) -> Option<usize> { | ||
| Some(42) | ||
| } | ||
| } | ||
|
|
||
| trait Combined : Iterator + std::iter::Iterator<Item = usize> {} | ||
|
|
||
| impl Combined for Counter {} | ||
|
|
||
| fn std_count(c : &mut dyn std::iter::Iterator<Item = usize>) -> usize { | ||
| c.next().unwrap() | ||
| } | ||
|
|
||
| fn weird_count(c : &mut dyn Iterator) -> usize { | ||
| c.next().unwrap() | ||
| } | ||
|
|
||
| fn main() { | ||
| let counter : &mut Counter = &mut Counter { count: 0 }; | ||
| assert!(std_count(counter as &mut dyn std::iter::Iterator<Item = usize>) == 1); | ||
| assert!(weird_count(counter as &mut dyn Iterator) == 42); | ||
|
|
||
| let counter_combined = counter as &mut dyn Combined; | ||
| assert!(std::iter::Iterator::next(counter_combined).unwrap() == 2); | ||
| assert!(Iterator::next(counter_combined).unwrap() == 42); | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| // This test uses a trait defined in a different crate (the standard library) | ||
| // and a test defined in the local crate. The goal is to test vtable resolution | ||
| // of duplicate names across different crates. | ||
| struct Counter { | ||
| count: usize, | ||
| } | ||
|
|
||
| // A custom impl for the standard library trait. | ||
| impl std::iter::Iterator for Counter { | ||
| type Item = usize; | ||
|
|
||
| fn next(&mut self) -> Option<Self::Item> { | ||
| // Increment our count. | ||
| self.count += 1; | ||
| Some(self.count) | ||
| } | ||
| } | ||
|
|
||
| // An impl for our local trait, with an indentical name to the standard library | ||
| trait Iterator { | ||
| fn next(&mut self) -> Option<usize>; | ||
| } | ||
|
|
||
| impl Iterator for Counter { | ||
| fn next(&mut self) -> Option<usize> { | ||
| Some(42) | ||
| } | ||
| } | ||
|
|
||
| trait Combined : Iterator + std::iter::Iterator<Item = usize> {} | ||
|
|
||
| impl Combined for Counter {} | ||
|
|
||
| fn std_count(c : &mut dyn std::iter::Iterator<Item = usize>) -> usize { | ||
| c.next().unwrap() | ||
| } | ||
|
|
||
| fn weird_count(c : &mut dyn Iterator) -> usize { | ||
| c.next().unwrap() | ||
| } | ||
|
|
||
| fn main() { | ||
| let counter : &mut Counter = &mut Counter { count: 0 }; | ||
| assert!(std_count(counter as &mut dyn std::iter::Iterator<Item = usize>) == 0); // Should be 1 | ||
| assert!(weird_count(counter as &mut dyn Iterator) == 0); // Should be 42 | ||
|
|
||
| let counter_combined = counter as &mut dyn Combined; | ||
| assert!(std::iter::Iterator::next(counter_combined).unwrap() == 0); // Should be 2 | ||
| assert!(Iterator::next(counter_combined).unwrap() == 0); // Should be 42 | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.