coverage: Add a test showing the inconsistent handling of function signatures
This commit is contained in:
parent
249624b504
commit
dca42959bc
53
tests/coverage-map/fn_sig_into_try.cov-map
Normal file
53
tests/coverage-map/fn_sig_into_try.cov-map
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
Function name: fn_sig_into_try::a
|
||||||
|
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0a, 01, 04, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 0
|
||||||
|
Number of file 0 mappings: 1
|
||||||
|
- Code(Counter(0)) at (prev + 10, 1) to (start + 4, 2)
|
||||||
|
|
||||||
|
Function name: fn_sig_into_try::b
|
||||||
|
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 12, 05, 00, 0f, 00, 00, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 2
|
||||||
|
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
|
||||||
|
Number of file 0 mappings: 4
|
||||||
|
- Code(Counter(0)) at (prev + 18, 5) to (start + 0, 15)
|
||||||
|
- Code(Zero) at (prev + 0, 15) to (start + 0, 16)
|
||||||
|
- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12)
|
||||||
|
= (c0 - c1)
|
||||||
|
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
|
||||||
|
= (c1 + (c0 - c1))
|
||||||
|
|
||||||
|
Function name: fn_sig_into_try::c
|
||||||
|
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 18, 0d, 00, 17, 00, 00, 17, 00, 18, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 2
|
||||||
|
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
|
||||||
|
Number of file 0 mappings: 4
|
||||||
|
- Code(Counter(0)) at (prev + 24, 13) to (start + 0, 23)
|
||||||
|
- Code(Zero) at (prev + 0, 23) to (start + 0, 24)
|
||||||
|
- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12)
|
||||||
|
= (c0 - c1)
|
||||||
|
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
|
||||||
|
= (c1 + (c0 - c1))
|
||||||
|
|
||||||
|
Function name: fn_sig_into_try::d
|
||||||
|
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 1c, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 2
|
||||||
|
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
|
||||||
|
Number of file 0 mappings: 4
|
||||||
|
- Code(Counter(0)) at (prev + 28, 1) to (start + 3, 15)
|
||||||
|
- Code(Zero) at (prev + 3, 15) to (start + 0, 16)
|
||||||
|
- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12)
|
||||||
|
= (c0 - c1)
|
||||||
|
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
|
||||||
|
= (c1 + (c0 - c1))
|
||||||
|
|
41
tests/coverage-map/fn_sig_into_try.rs
Normal file
41
tests/coverage-map/fn_sig_into_try.rs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#![feature(coverage_attribute)]
|
||||||
|
// compile-flags: --edition=2021
|
||||||
|
|
||||||
|
// Regression test for inconsistent handling of function signature spans that
|
||||||
|
// are followed by code using the `?` operator.
|
||||||
|
//
|
||||||
|
// For each of these similar functions, the line containing the function
|
||||||
|
// signature should be handled in the same way.
|
||||||
|
|
||||||
|
fn a() -> Option<i32>
|
||||||
|
{
|
||||||
|
Some(7i32);
|
||||||
|
Some(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn b() -> Option<i32>
|
||||||
|
{
|
||||||
|
Some(7i32)?;
|
||||||
|
Some(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn c() -> Option<i32>
|
||||||
|
{
|
||||||
|
let _ = Some(7i32)?;
|
||||||
|
Some(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn d() -> Option<i32>
|
||||||
|
{
|
||||||
|
let _: () = ();
|
||||||
|
Some(7i32)?;
|
||||||
|
Some(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[coverage(off)]
|
||||||
|
fn main() {
|
||||||
|
a();
|
||||||
|
b();
|
||||||
|
c();
|
||||||
|
d();
|
||||||
|
}
|
45
tests/run-coverage/fn_sig_into_try.coverage
Normal file
45
tests/run-coverage/fn_sig_into_try.coverage
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
LL| |#![feature(coverage_attribute)]
|
||||||
|
LL| |// compile-flags: --edition=2021
|
||||||
|
LL| |
|
||||||
|
LL| |// Regression test for inconsistent handling of function signature spans that
|
||||||
|
LL| |// are followed by code using the `?` operator.
|
||||||
|
LL| |//
|
||||||
|
LL| |// For each of these similar functions, the line containing the function
|
||||||
|
LL| |// signature should be handled in the same way.
|
||||||
|
LL| |
|
||||||
|
LL| 1|fn a() -> Option<i32>
|
||||||
|
LL| 1|{
|
||||||
|
LL| 1| Some(7i32);
|
||||||
|
LL| 1| Some(0)
|
||||||
|
LL| 1|}
|
||||||
|
LL| |
|
||||||
|
LL| |fn b() -> Option<i32>
|
||||||
|
LL| |{
|
||||||
|
LL| 1| Some(7i32)?;
|
||||||
|
^0
|
||||||
|
LL| 1| Some(0)
|
||||||
|
LL| 1|}
|
||||||
|
LL| |
|
||||||
|
LL| |fn c() -> Option<i32>
|
||||||
|
LL| |{
|
||||||
|
LL| 1| let _ = Some(7i32)?;
|
||||||
|
^0
|
||||||
|
LL| 1| Some(0)
|
||||||
|
LL| 1|}
|
||||||
|
LL| |
|
||||||
|
LL| 1|fn d() -> Option<i32>
|
||||||
|
LL| 1|{
|
||||||
|
LL| 1| let _: () = ();
|
||||||
|
LL| 1| Some(7i32)?;
|
||||||
|
^0
|
||||||
|
LL| 1| Some(0)
|
||||||
|
LL| 1|}
|
||||||
|
LL| |
|
||||||
|
LL| |#[coverage(off)]
|
||||||
|
LL| |fn main() {
|
||||||
|
LL| | a();
|
||||||
|
LL| | b();
|
||||||
|
LL| | c();
|
||||||
|
LL| | d();
|
||||||
|
LL| |}
|
||||||
|
|
41
tests/run-coverage/fn_sig_into_try.rs
Normal file
41
tests/run-coverage/fn_sig_into_try.rs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#![feature(coverage_attribute)]
|
||||||
|
// compile-flags: --edition=2021
|
||||||
|
|
||||||
|
// Regression test for inconsistent handling of function signature spans that
|
||||||
|
// are followed by code using the `?` operator.
|
||||||
|
//
|
||||||
|
// For each of these similar functions, the line containing the function
|
||||||
|
// signature should be handled in the same way.
|
||||||
|
|
||||||
|
fn a() -> Option<i32>
|
||||||
|
{
|
||||||
|
Some(7i32);
|
||||||
|
Some(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn b() -> Option<i32>
|
||||||
|
{
|
||||||
|
Some(7i32)?;
|
||||||
|
Some(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn c() -> Option<i32>
|
||||||
|
{
|
||||||
|
let _ = Some(7i32)?;
|
||||||
|
Some(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn d() -> Option<i32>
|
||||||
|
{
|
||||||
|
let _: () = ();
|
||||||
|
Some(7i32)?;
|
||||||
|
Some(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[coverage(off)]
|
||||||
|
fn main() {
|
||||||
|
a();
|
||||||
|
b();
|
||||||
|
c();
|
||||||
|
d();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user