-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more thorough coverage tests for
#[coverage(..)]
in nested func…
…tions These tests reflect the current implementation behaviour, which is not necessarily the desired behaviour.
- Loading branch information
Showing
6 changed files
with
448 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,100 @@ | ||
Function name: <<<nested::MyOuter as nested::MyTrait>::trait_method::MyMiddle as nested::MyTrait>::trait_method::MyInner as nested::MyTrait>::trait_method (unused) | ||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 34, 15, 02, 16] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Zero) at (prev + 52, 21) to (start + 2, 22) | ||
|
||
Function name: <<<nested::MyOuter>::outer_method::MyMiddle>::middle_method::MyInner>::inner_method (unused) | ||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 1e, 15, 02, 16] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Zero) at (prev + 30, 21) to (start + 2, 22) | ||
|
||
Function name: <<nested::MyOuter as nested::MyTrait>::trait_method::MyMiddle as nested::MyTrait>::trait_method (unused) | ||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 31, 0d, 08, 0e] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Zero) at (prev + 49, 13) to (start + 8, 14) | ||
|
||
Function name: <<nested::MyOuter>::outer_method::MyMiddle>::middle_method (unused) | ||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 1b, 0d, 08, 0e] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Zero) at (prev + 27, 13) to (start + 8, 14) | ||
|
||
Function name: nested::closure_expr | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 3f, 01, 01, 0f, 01, 0b, 05, 01, 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 + 63, 1) to (start + 1, 15) | ||
- Code(Counter(0)) at (prev + 11, 5) to (start + 1, 2) | ||
|
||
Function name: nested::closure_expr::{closure#0}::{closure#0} (unused) | ||
Raw bytes (14): 0x[01, 01, 00, 02, 00, 42, 1a, 01, 17, 00, 04, 0d, 01, 0a] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Zero) at (prev + 66, 26) to (start + 1, 23) | ||
- Code(Zero) at (prev + 4, 13) to (start + 1, 10) | ||
|
||
Function name: nested::closure_expr::{closure#0}::{closure#0}::{closure#0} (unused) | ||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 43, 1d, 02, 0e] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Zero) at (prev + 67, 29) to (start + 2, 14) | ||
|
||
Function name: nested::closure_tail | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 4e, 01, 01, 0f, 01, 11, 05, 01, 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 + 78, 1) to (start + 1, 15) | ||
- Code(Counter(0)) at (prev + 17, 5) to (start + 1, 2) | ||
|
||
Function name: nested::closure_tail::{closure#0}::{closure#0} (unused) | ||
Raw bytes (14): 0x[01, 01, 00, 02, 00, 53, 14, 01, 1f, 00, 06, 15, 01, 12] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Zero) at (prev + 83, 20) to (start + 1, 31) | ||
- Code(Zero) at (prev + 6, 21) to (start + 1, 18) | ||
|
||
Function name: nested::closure_tail::{closure#0}::{closure#0}::{closure#0} (unused) | ||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 55, 1c, 02, 1a] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Zero) at (prev + 85, 28) to (start + 2, 26) | ||
|
||
Function name: nested::outer_fn::middle_fn (unused) | ||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 0c, 05, 05, 06] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Zero) at (prev + 12, 5) to (start + 5, 6) | ||
|
||
Function name: nested::outer_fn::middle_fn::inner_fn (unused) | ||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 0d, 09, 02, 0a] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Zero) at (prev + 13, 9) to (start + 2, 10) | ||
|
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,106 @@ | ||
LL| |#![feature(coverage_attribute, stmt_expr_attributes)] | ||
LL| |//@ edition: 2021 | ||
LL| | | ||
LL| |// Demonstrates the interaction between #[coverage(off)] and various kinds of | ||
LL| |// nested function. | ||
LL| | | ||
LL| |#[coverage(off)] | ||
LL| |fn do_stuff() {} | ||
LL| | | ||
LL| |#[coverage(off)] | ||
LL| |fn outer_fn() { | ||
LL| 0| fn middle_fn() { | ||
LL| 0| fn inner_fn() { | ||
LL| 0| do_stuff(); | ||
LL| 0| } | ||
LL| 0| do_stuff(); | ||
LL| 0| } | ||
LL| | do_stuff(); | ||
LL| |} | ||
LL| | | ||
LL| |struct MyOuter; | ||
LL| |impl MyOuter { | ||
LL| | #[coverage(off)] | ||
LL| | fn outer_method(&self) { | ||
LL| | struct MyMiddle; | ||
LL| | impl MyMiddle { | ||
LL| 0| fn middle_method(&self) { | ||
LL| 0| struct MyInner; | ||
LL| 0| impl MyInner { | ||
LL| 0| fn inner_method(&self) { | ||
LL| 0| do_stuff(); | ||
LL| 0| } | ||
LL| 0| } | ||
LL| 0| do_stuff(); | ||
LL| 0| } | ||
LL| | } | ||
LL| | do_stuff(); | ||
LL| | } | ||
LL| |} | ||
LL| | | ||
LL| |trait MyTrait { | ||
LL| | fn trait_method(&self); | ||
LL| |} | ||
LL| |impl MyTrait for MyOuter { | ||
LL| | #[coverage(off)] | ||
LL| | fn trait_method(&self) { | ||
LL| | struct MyMiddle; | ||
LL| | impl MyTrait for MyMiddle { | ||
LL| 0| fn trait_method(&self) { | ||
LL| 0| struct MyInner; | ||
LL| 0| impl MyTrait for MyInner { | ||
LL| 0| fn trait_method(&self) { | ||
LL| 0| do_stuff(); | ||
LL| 0| } | ||
LL| 0| } | ||
LL| 0| do_stuff(); | ||
LL| 0| } | ||
LL| | } | ||
LL| | do_stuff(); | ||
LL| | } | ||
LL| |} | ||
LL| | | ||
LL| 1|fn closure_expr() { | ||
LL| 1| let _outer = #[coverage(off)] | ||
LL| | || { | ||
LL| 0| let _middle = || { | ||
LL| 0| let _inner = || { | ||
LL| 0| do_stuff(); | ||
LL| 0| }; | ||
LL| 0| do_stuff(); | ||
LL| 0| }; | ||
LL| | do_stuff(); | ||
LL| | }; | ||
LL| 1| do_stuff(); | ||
LL| 1|} | ||
LL| | | ||
LL| |// This syntax is allowed, even without #![feature(stmt_expr_attributes)]. | ||
LL| 1|fn closure_tail() { | ||
LL| 1| let _outer = { | ||
LL| | #[coverage(off)] | ||
LL| | || { | ||
LL| | let _middle = { | ||
LL| 0| || { | ||
LL| 0| let _inner = { | ||
LL| 0| || { | ||
LL| 0| do_stuff(); | ||
LL| 0| } | ||
LL| | }; | ||
LL| 0| do_stuff(); | ||
LL| 0| } | ||
LL| | }; | ||
LL| | do_stuff(); | ||
LL| | } | ||
LL| | }; | ||
LL| 1| do_stuff(); | ||
LL| 1|} | ||
LL| | | ||
LL| |#[coverage(off)] | ||
LL| |fn main() { | ||
LL| | outer_fn(); | ||
LL| | MyOuter.outer_method(); | ||
LL| | MyOuter.trait_method(); | ||
LL| | closure_expr(); | ||
LL| | closure_tail(); | ||
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,105 @@ | ||
#![feature(coverage_attribute, stmt_expr_attributes)] | ||
//@ edition: 2021 | ||
|
||
// Demonstrates the interaction between #[coverage(off)] and various kinds of | ||
// nested function. | ||
|
||
#[coverage(off)] | ||
fn do_stuff() {} | ||
|
||
#[coverage(off)] | ||
fn outer_fn() { | ||
fn middle_fn() { | ||
fn inner_fn() { | ||
do_stuff(); | ||
} | ||
do_stuff(); | ||
} | ||
do_stuff(); | ||
} | ||
|
||
struct MyOuter; | ||
impl MyOuter { | ||
#[coverage(off)] | ||
fn outer_method(&self) { | ||
struct MyMiddle; | ||
impl MyMiddle { | ||
fn middle_method(&self) { | ||
struct MyInner; | ||
impl MyInner { | ||
fn inner_method(&self) { | ||
do_stuff(); | ||
} | ||
} | ||
do_stuff(); | ||
} | ||
} | ||
do_stuff(); | ||
} | ||
} | ||
|
||
trait MyTrait { | ||
fn trait_method(&self); | ||
} | ||
impl MyTrait for MyOuter { | ||
#[coverage(off)] | ||
fn trait_method(&self) { | ||
struct MyMiddle; | ||
impl MyTrait for MyMiddle { | ||
fn trait_method(&self) { | ||
struct MyInner; | ||
impl MyTrait for MyInner { | ||
fn trait_method(&self) { | ||
do_stuff(); | ||
} | ||
} | ||
do_stuff(); | ||
} | ||
} | ||
do_stuff(); | ||
} | ||
} | ||
|
||
fn closure_expr() { | ||
let _outer = #[coverage(off)] | ||
|| { | ||
let _middle = || { | ||
let _inner = || { | ||
do_stuff(); | ||
}; | ||
do_stuff(); | ||
}; | ||
do_stuff(); | ||
}; | ||
do_stuff(); | ||
} | ||
|
||
// This syntax is allowed, even without #![feature(stmt_expr_attributes)]. | ||
fn closure_tail() { | ||
let _outer = { | ||
#[coverage(off)] | ||
|| { | ||
let _middle = { | ||
|| { | ||
let _inner = { | ||
|| { | ||
do_stuff(); | ||
} | ||
}; | ||
do_stuff(); | ||
} | ||
}; | ||
do_stuff(); | ||
} | ||
}; | ||
do_stuff(); | ||
} | ||
|
||
#[coverage(off)] | ||
fn main() { | ||
outer_fn(); | ||
MyOuter.outer_method(); | ||
MyOuter.trait_method(); | ||
closure_expr(); | ||
closure_tail(); | ||
} |
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,32 @@ | ||
Function name: off_on_sandwich::dense_a::dense_b | ||
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 05, 07, 06] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Counter(0)) at (prev + 15, 5) to (start + 7, 6) | ||
|
||
Function name: off_on_sandwich::sparse_a::sparse_b | ||
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 05, 10, 06] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Counter(0)) at (prev + 29, 5) to (start + 16, 6) | ||
|
||
Function name: off_on_sandwich::sparse_a::sparse_b::sparse_c | ||
Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 09, 0b, 0a] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Counter(0)) at (prev + 33, 9) to (start + 11, 10) | ||
|
||
Function name: off_on_sandwich::sparse_a::sparse_b::sparse_c::sparse_d | ||
Raw bytes (9): 0x[01, 01, 00, 01, 01, 24, 0d, 07, 0e] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Counter(0)) at (prev + 36, 13) to (start + 7, 14) | ||
|
Oops, something went wrong.