-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coverage: Regression test for a span extraction inconsistency
- Loading branch information
Showing
3 changed files
with
93 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Function name: closure_unit_return::explicit_unit | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 07, 01, 01, 10, 01, 05, 05, 02, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Counter(0)) at (prev + 7, 1) to (start + 1, 16) | ||
- Code(Counter(0)) at (prev + 5, 5) to (start + 2, 2) | ||
|
||
Function name: closure_unit_return::explicit_unit::{closure#0} (unused) | ||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 08, 16, 02, 06] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Zero) at (prev + 8, 22) to (start + 2, 6) | ||
|
||
Function name: closure_unit_return::implicit_unit | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 10, 01, 01, 13, 01, 03, 06, 04, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Counter(0)) at (prev + 16, 1) to (start + 1, 19) | ||
- Code(Counter(0)) at (prev + 3, 6) to (start + 4, 2) | ||
|
||
Function name: closure_unit_return::implicit_unit::{closure#0} (unused) | ||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 11, 16, 02, 06] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Zero) at (prev + 17, 22) to (start + 2, 6) | ||
|
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,30 @@ | ||
LL| |#![feature(coverage_attribute)] | ||
LL| |// edition: 2021 | ||
LL| | | ||
LL| |// Regression test for an inconsistency between functions that return the value | ||
LL| |// of their trailing expression, and functions that implicitly return `()`. | ||
LL| | | ||
LL| 1|fn explicit_unit() { | ||
LL| 1| let closure = || { | ||
LL| 0| (); | ||
LL| 0| }; | ||
LL| | | ||
LL| 1| drop(closure); | ||
LL| 1| () // explicit return of trailing value | ||
LL| 1|} | ||
LL| | | ||
LL| 1|fn implicit_unit() { | ||
LL| 1| let closure = || { | ||
LL| 0| (); | ||
LL| 1| }; | ||
LL| 1| | ||
LL| 1| drop(closure); | ||
LL| 1| // implicit return of `()` | ||
LL| 1|} | ||
LL| | | ||
LL| |#[coverage(off)] | ||
LL| |fn main() { | ||
LL| | explicit_unit(); | ||
LL| | implicit_unit(); | ||
LL| |} | ||
|
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,29 @@ | ||
#![feature(coverage_attribute)] | ||
// edition: 2021 | ||
|
||
// Regression test for an inconsistency between functions that return the value | ||
// of their trailing expression, and functions that implicitly return `()`. | ||
|
||
fn explicit_unit() { | ||
let closure = || { | ||
(); | ||
}; | ||
|
||
drop(closure); | ||
() // explicit return of trailing value | ||
} | ||
|
||
fn implicit_unit() { | ||
let closure = || { | ||
(); | ||
}; | ||
|
||
drop(closure); | ||
// implicit return of `()` | ||
} | ||
|
||
#[coverage(off)] | ||
fn main() { | ||
explicit_unit(); | ||
implicit_unit(); | ||
} |