-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Fix cargo release for Object::from_ref (#5867)
This PR should run all deep tests and pass before being merged, so that the test cargoreleasefailurefix.dfy passes ### Description This PR adds more black-boxing around a critical function so that the compiler won't optimize things away by for example moving the increment strong count and the assignments to `previous_strong_count`, which could have caused panicking; ### How has this been tested? All deep tests should pass, so that cargoreleasefailurefix.dfy is tested for each supported architecture <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
- Loading branch information
1 parent
7279e16
commit 30b94b3
Showing
3 changed files
with
68 additions
and
4 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
48 changes: 48 additions & 0 deletions
48
Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/cargoreleasefailure.dfy
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// NONUNIFORM: Rust-specific tests | ||
// RUN: %baredafny build --target=rs "%s" | ||
// If there is no '#[inline(never)]' in front of ::dafny_runtime::increment_strong_count | ||
// then the release will think it's safe to remove the strong count increment, resulting ins a segfault | ||
// RUN: "%S/cargoreleasefailure-rust/cargo" run --release | ||
|
||
module TraitModule { | ||
trait {:termination false} MyTrait { | ||
method DoThing ( input: int ) returns (output: int) | ||
} | ||
} | ||
|
||
module ImplModule { | ||
import TraitModule | ||
class MyImpl extends TraitModule.MyTrait { | ||
constructor(){} | ||
method DoThing ( input: int ) returns (output: int) | ||
{ | ||
return 1; | ||
} | ||
} | ||
} | ||
|
||
module WorkModule { | ||
import ImplModule | ||
import TraitModule | ||
|
||
method DoWork() { | ||
var worker := new ImplModule.MyImpl(); | ||
DoMoreWork(worker, 1); | ||
DoMoreWork(worker, 2); | ||
DoMoreWork(worker, 3); | ||
DoMoreWork(worker, 4); | ||
DoMoreWork(worker, 5); | ||
} | ||
|
||
method DoMoreWork(client : TraitModule.MyTrait, num : int) | ||
{ | ||
var _ := client.DoThing(num); | ||
} | ||
} | ||
|
||
module MainModule { | ||
import WorkModule | ||
method Main() { | ||
WorkModule.DoWork(); | ||
} | ||
} |