From 6a716202fbf15e3fbb10699e0d3d151bc859912e Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Fri, 7 Jan 2022 00:12:27 +0100 Subject: [PATCH 1/2] play around with doctests --- src/main.rs | 1 + .../workspace_root.hide-instantiations.txt | 59 ++++++++++ .../doctest/workspace_root.json | 103 ++++++++++++++++++ .../doctest/workspace_root.lcov.info | 16 +++ .../doctest/workspace_root.summary.txt | 6 + .../doctest/workspace_root.txt | 91 ++++++++++++++++ tests/fixtures/crates/doctest/Cargo.toml | 3 + tests/fixtures/crates/doctest/src/lib.rs | 27 +++++ tests/test.rs | 5 + 9 files changed, 311 insertions(+) create mode 100644 tests/fixtures/coverage-reports/doctest/workspace_root.hide-instantiations.txt create mode 100644 tests/fixtures/coverage-reports/doctest/workspace_root.json create mode 100644 tests/fixtures/coverage-reports/doctest/workspace_root.lcov.info create mode 100644 tests/fixtures/coverage-reports/doctest/workspace_root.summary.txt create mode 100644 tests/fixtures/coverage-reports/doctest/workspace_root.txt create mode 100644 tests/fixtures/crates/doctest/Cargo.toml create mode 100644 tests/fixtures/crates/doctest/src/lib.rs diff --git a/src/main.rs b/src/main.rs index 2817da71..50d4884c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -230,6 +230,7 @@ fn set_env(cx: &Context, target: &mut impl EnvTarget) { " -Z instrument-coverage -Z unstable-options --persist-doctests {}", cx.ws.doctests_dir )); + rustflags.push_str(&format!(" --remap-path-prefix {}/=", cx.ws.metadata.workspace_root)); if cfg!(windows) { rustdocflags.push_str(" -C codegen-units=1"); } diff --git a/tests/fixtures/coverage-reports/doctest/workspace_root.hide-instantiations.txt b/tests/fixtures/coverage-reports/doctest/workspace_root.hide-instantiations.txt new file mode 100644 index 00000000..845c2b67 --- /dev/null +++ b/tests/fixtures/coverage-reports/doctest/workspace_root.hide-instantiations.txt @@ -0,0 +1,59 @@ +/tmp/.tmp5LHkz7/src/lib.rs: + 1| 1|/// ``` + 2| 1|/// assert_eq!(crate1::generic_fn("doc", "doctest"), Ok("doctest")); + 3| 1|/// ``` + 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { + 5| 1| match s { + 6| 1| "unit" => Ok("unit-test"), + ^0 + 7| 1| "doc" => Ok("doctest"), + 8| 0| _ => Err(val), + 9| | } + 10| 1|} + 11| | + 12| 1|/// ``` + 13| 1|/// assert_eq!(crate1::non_generic_fn("doc"), "doctest"); + 14| 1|/// ``` + 15| |pub fn non_generic_fn(s: &str) -> &str { + 16| | match s { + 17| | "unit" => "unit-test", + 18| | "doc" => "doctest", + 19| | val => val, + 20| | } + 21| |} + 22| | + 23| |#[test] + 24| |fn unit_test() { + 25| | assert_eq!(generic_fn("unit", 1), Ok("unit-test")); + 26| | assert_eq!(non_generic_fn("unit"), "unit-test"); + 27| |} + +src/lib.rs: + 1| 1|/// ```/// ``` + 2| |/// assert_eq!(crate1::generic_fn("doc", "doctest"), Ok("doctest")); + 3| |/// ``` + 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { + 5| 1| match s { + 6| 1| "unit" => Ok("unit-test"), + 7| 0| "doc" => Ok("doctest"), + 8| 0| _ => Err(val), + 9| | } + 10| 1|} + 11| | + 12| |/// ``` + 13| |/// assert_eq!(crate1::non_generic_fn("doc"), "doctest"); + 14| |/// ``` + 15| 2|pub fn non_generic_fn(s: &str) -> &str { + 16| 2| match s { + 17| 2| "unit" => "unit-test", + ^1 + 18| 1| "doc" => "doctest", + 19| 0| val => val, + 20| | } + 21| 2|} + 22| | + 23| 1|#[test] + 24| 1|fn unit_test() { + 25| 1| assert_eq!(generic_fn("unit", 1), Ok("unit-test")); + 26| 1| assert_eq!(non_generic_fn("unit"), "unit-test"); + 27| 1|} \ No newline at end of file diff --git a/tests/fixtures/coverage-reports/doctest/workspace_root.json b/tests/fixtures/coverage-reports/doctest/workspace_root.json new file mode 100644 index 00000000..d01ca0ae --- /dev/null +++ b/tests/fixtures/coverage-reports/doctest/workspace_root.json @@ -0,0 +1,103 @@ +{ + "data": [ + { + "files": [ + { + "filename": "/tmp/.tmp49soab/src/lib.rs", + "summary": { + "branches": { + "count": 0, + "covered": 0, + "notcovered": 0, + "percent": 0.0 + }, + "functions": { + "count": 4, + "covered": 4, + "percent": 100.0 + }, + "instantiations": { + "count": 4, + "covered": 4, + "percent": 100.0 + }, + "lines": { + "count": 15, + "covered": 14, + "percent": 93.33333333333333 + }, + "regions": { + "count": 11, + "covered": 9, + "notcovered": 2, + "percent": 81.81818181818183 + } + } + }, + { + "filename": "src/lib.rs", + "summary": { + "branches": { + "count": 0, + "covered": 0, + "notcovered": 0, + "percent": 0.0 + }, + "functions": { + "count": 5, + "covered": 5, + "percent": 100.0 + }, + "instantiations": { + "count": 7, + "covered": 6, + "percent": 85.71428571428571 + }, + "lines": { + "count": 18, + "covered": 15, + "percent": 83.33333333333334 + }, + "regions": { + "count": 17, + "covered": 12, + "notcovered": 5, + "percent": 70.58823529411765 + } + } + } + ], + "totals": { + "branches": { + "count": 0, + "covered": 0, + "notcovered": 0, + "percent": 0 + }, + "functions": { + "count": 9, + "covered": 9, + "percent": 100 + }, + "instantiations": { + "count": 11, + "covered": 10, + "percent": 90.9090909090909 + }, + "lines": { + "count": 33, + "covered": 29, + "percent": 87.87878787878788 + }, + "regions": { + "count": 28, + "covered": 21, + "notcovered": 7, + "percent": 75 + } + } + } + ], + "type": "llvm.coverage.json.export", + "version": "2.0.1" +} \ No newline at end of file diff --git a/tests/fixtures/coverage-reports/doctest/workspace_root.lcov.info b/tests/fixtures/coverage-reports/doctest/workspace_root.lcov.info new file mode 100644 index 00000000..0e77bcb3 --- /dev/null +++ b/tests/fixtures/coverage-reports/doctest/workspace_root.lcov.info @@ -0,0 +1,16 @@ +SF:/tmp/.tmpQwD18k/src/lib.rs +FNF:4 +FNH:4 +BRF:0 +BRH:0 +LF:15 +LH:14 +end_of_record +SF:src/lib.rs +FNF:5 +FNH:5 +BRF:0 +BRH:0 +LF:18 +LH:15 +end_of_record \ No newline at end of file diff --git a/tests/fixtures/coverage-reports/doctest/workspace_root.summary.txt b/tests/fixtures/coverage-reports/doctest/workspace_root.summary.txt new file mode 100644 index 00000000..0a2641b6 --- /dev/null +++ b/tests/fixtures/coverage-reports/doctest/workspace_root.summary.txt @@ -0,0 +1,6 @@ +Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +/tmp/.tmp2e2Bx8/src/lib.rs 11 2 81.82% 4 0 100.00% 15 1 93.33% 0 0 - +src/lib.rs 17 5 70.59% 5 0 100.00% 18 3 83.33% 0 0 - +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +TOTAL 28 7 75.00% 9 0 100.00% 33 4 87.88% 0 0 - \ No newline at end of file diff --git a/tests/fixtures/coverage-reports/doctest/workspace_root.txt b/tests/fixtures/coverage-reports/doctest/workspace_root.txt new file mode 100644 index 00000000..42e23706 --- /dev/null +++ b/tests/fixtures/coverage-reports/doctest/workspace_root.txt @@ -0,0 +1,91 @@ +/tmp/.tmpzVh4uE/src/lib.rs: + 1| 1|/// ``` + 2| 1|/// assert_eq!(crate1::generic_fn("doc", "doctest"), Ok("doctest")); + 3| 1|/// ``` + 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { + 5| 1| match s { + 6| 1| "unit" => Ok("unit-test"), + ^0 + 7| 1| "doc" => Ok("doctest"), + 8| 0| _ => Err(val), + 9| | } + 10| 1|} + 11| | + 12| 1|/// ``` + 13| 1|/// assert_eq!(crate1::non_generic_fn("doc"), "doctest"); + 14| 1|/// ``` + 15| |pub fn non_generic_fn(s: &str) -> &str { + 16| | match s { + 17| | "unit" => "unit-test", + 18| | "doc" => "doctest", + 19| | val => val, + 20| | } + 21| |} + 22| | + 23| |#[test] + 24| |fn unit_test() { + 25| | assert_eq!(generic_fn("unit", 1), Ok("unit-test")); + 26| | assert_eq!(non_generic_fn("unit"), "unit-test"); + 27| |} + +src/lib.rs: + 1| 1|/// ```/// ``` + 2| |/// assert_eq!(crate1::generic_fn("doc", "doctest"), Ok("doctest")); + 3| |/// ``` + 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { + 5| 1| match s { + 6| 1| "unit" => Ok("unit-test"), + 7| 0| "doc" => Ok("doctest"), + 8| 0| _ => Err(val), + 9| | } + 10| 1|} + ------------------ + | crate1::generic_fn::: + | 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { + | 5| 1| match s { + | 6| 1| "unit" => Ok("unit-test"), + | 7| 0| "doc" => Ok("doctest"), + | 8| 0| _ => Err(val), + | 9| | } + | 10| 1|} + ------------------ + | Unexecuted instantiation: crate1::generic_fn::<_> + ------------------ + 11| | + 12| |/// ``` + 13| |/// assert_eq!(crate1::non_generic_fn("doc"), "doctest"); + 14| |/// ``` + 15| 2|pub fn non_generic_fn(s: &str) -> &str { + 16| 2| match s { + 17| 2| "unit" => "unit-test", + ^1 + 18| 1| "doc" => "doctest", + 19| 0| val => val, + 20| | } + 21| 2|} + ------------------ + | crate1::non_generic_fn: + | 15| 1|pub fn non_generic_fn(s: &str) -> &str { + | 16| 1| match s { + | 17| 1| "unit" => "unit-test", + | 18| 0| "doc" => "doctest", + | 19| 0| val => val, + | 20| | } + | 21| 1|} + ------------------ + | crate1::non_generic_fn: + | 15| 1|pub fn non_generic_fn(s: &str) -> &str { + | 16| 1| match s { + | 17| 1| "unit" => "unit-test", + | ^0 + | 18| 1| "doc" => "doctest", + | 19| 0| val => val, + | 20| | } + | 21| 1|} + ------------------ + 22| | + 23| 1|#[test] + 24| 1|fn unit_test() { + 25| 1| assert_eq!(generic_fn("unit", 1), Ok("unit-test")); + 26| 1| assert_eq!(non_generic_fn("unit"), "unit-test"); + 27| 1|} \ No newline at end of file diff --git a/tests/fixtures/crates/doctest/Cargo.toml b/tests/fixtures/crates/doctest/Cargo.toml new file mode 100644 index 00000000..6ad48092 --- /dev/null +++ b/tests/fixtures/crates/doctest/Cargo.toml @@ -0,0 +1,3 @@ +[package] +name = "crate1" +version = "0.0.0" diff --git a/tests/fixtures/crates/doctest/src/lib.rs b/tests/fixtures/crates/doctest/src/lib.rs new file mode 100644 index 00000000..75473862 --- /dev/null +++ b/tests/fixtures/crates/doctest/src/lib.rs @@ -0,0 +1,27 @@ +/// ``` +/// assert_eq!(crate1::generic_fn("doc", "doctest"), Ok("doctest")); +/// ``` +pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { + match s { + "unit" => Ok("unit-test"), + "doc" => Ok("doctest"), + _ => Err(val), + } +} + +/// ``` +/// assert_eq!(crate1::non_generic_fn("doc"), "doctest"); +/// ``` +pub fn non_generic_fn(s: &str) -> &str { + match s { + "unit" => "unit-test", + "doc" => "doctest", + val => val, + } +} + +#[test] +fn unit_test() { + assert_eq!(generic_fn("unit", 1), Ok("unit-test")); + assert_eq!(non_generic_fn("unit"), "unit-test"); +} diff --git a/tests/test.rs b/tests/test.rs index 074c7f2a..51e39c7d 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -58,6 +58,11 @@ fn virtual1() { run("virtual1", "exclude", &["--workspace", "--exclude", "member2"], &[]); } +#[test] +fn doctest() { + run("doctest", "workspace_root", &["--doctests"], &[]); +} + #[test] fn no_test() { // TODO: we should fix this: https://github.com/taiki-e/cargo-llvm-cov/issues/21 From 4a1de1e00f2188c34e5cd5916fcd6ea020793184 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Fri, 7 Jan 2022 13:15:46 +0100 Subject: [PATCH 2/2] make stuff work --- src/main.rs | 2 +- .../workspace_root.hide-instantiations.txt | 42 ++--------- .../doctest/workspace_root.json | 74 ++++++------------- .../doctest/workspace_root.lcov.info | 16 +--- .../doctest/workspace_root.summary.txt | 11 ++- .../doctest/workspace_root.txt | 58 +++++---------- 6 files changed, 56 insertions(+), 147 deletions(-) diff --git a/src/main.rs b/src/main.rs index 50d4884c..e7d7bec6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -230,7 +230,7 @@ fn set_env(cx: &Context, target: &mut impl EnvTarget) { " -Z instrument-coverage -Z unstable-options --persist-doctests {}", cx.ws.doctests_dir )); - rustflags.push_str(&format!(" --remap-path-prefix {}/=", cx.ws.metadata.workspace_root)); + rustdocflags.push_str(&format!(" --remap-path-prefix {}/=", cx.ws.metadata.workspace_root)); if cfg!(windows) { rustdocflags.push_str(" -C codegen-units=1"); } diff --git a/tests/fixtures/coverage-reports/doctest/workspace_root.hide-instantiations.txt b/tests/fixtures/coverage-reports/doctest/workspace_root.hide-instantiations.txt index 845c2b67..117f4f49 100644 --- a/tests/fixtures/coverage-reports/doctest/workspace_root.hide-instantiations.txt +++ b/tests/fixtures/coverage-reports/doctest/workspace_root.hide-instantiations.txt @@ -1,48 +1,18 @@ -/tmp/.tmp5LHkz7/src/lib.rs: - 1| 1|/// ``` + 1| 1|/// ```/// ``` 2| 1|/// assert_eq!(crate1::generic_fn("doc", "doctest"), Ok("doctest")); 3| 1|/// ``` - 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { - 5| 1| match s { - 6| 1| "unit" => Ok("unit-test"), - ^0 + 4| 2|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { + 5| 2| match s { + 6| 2| "unit" => Ok("unit-test"), + ^1 7| 1| "doc" => Ok("doctest"), 8| 0| _ => Err(val), 9| | } - 10| 1|} + 10| 2|} 11| | 12| 1|/// ``` 13| 1|/// assert_eq!(crate1::non_generic_fn("doc"), "doctest"); 14| 1|/// ``` - 15| |pub fn non_generic_fn(s: &str) -> &str { - 16| | match s { - 17| | "unit" => "unit-test", - 18| | "doc" => "doctest", - 19| | val => val, - 20| | } - 21| |} - 22| | - 23| |#[test] - 24| |fn unit_test() { - 25| | assert_eq!(generic_fn("unit", 1), Ok("unit-test")); - 26| | assert_eq!(non_generic_fn("unit"), "unit-test"); - 27| |} - -src/lib.rs: - 1| 1|/// ```/// ``` - 2| |/// assert_eq!(crate1::generic_fn("doc", "doctest"), Ok("doctest")); - 3| |/// ``` - 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { - 5| 1| match s { - 6| 1| "unit" => Ok("unit-test"), - 7| 0| "doc" => Ok("doctest"), - 8| 0| _ => Err(val), - 9| | } - 10| 1|} - 11| | - 12| |/// ``` - 13| |/// assert_eq!(crate1::non_generic_fn("doc"), "doctest"); - 14| |/// ``` 15| 2|pub fn non_generic_fn(s: &str) -> &str { 16| 2| match s { 17| 2| "unit" => "unit-test", diff --git a/tests/fixtures/coverage-reports/doctest/workspace_root.json b/tests/fixtures/coverage-reports/doctest/workspace_root.json index d01ca0ae..f4fcacfc 100644 --- a/tests/fixtures/coverage-reports/doctest/workspace_root.json +++ b/tests/fixtures/coverage-reports/doctest/workspace_root.json @@ -2,38 +2,6 @@ "data": [ { "files": [ - { - "filename": "/tmp/.tmp49soab/src/lib.rs", - "summary": { - "branches": { - "count": 0, - "covered": 0, - "notcovered": 0, - "percent": 0.0 - }, - "functions": { - "count": 4, - "covered": 4, - "percent": 100.0 - }, - "instantiations": { - "count": 4, - "covered": 4, - "percent": 100.0 - }, - "lines": { - "count": 15, - "covered": 14, - "percent": 93.33333333333333 - }, - "regions": { - "count": 11, - "covered": 9, - "notcovered": 2, - "percent": 81.81818181818183 - } - } - }, { "filename": "src/lib.rs", "summary": { @@ -44,25 +12,25 @@ "percent": 0.0 }, "functions": { - "count": 5, - "covered": 5, + "count": 8, + "covered": 8, "percent": 100.0 }, "instantiations": { - "count": 7, - "covered": 6, - "percent": 85.71428571428571 + "count": 11, + "covered": 10, + "percent": 90.9090909090909 }, "lines": { - "count": 18, - "covered": 15, - "percent": 83.33333333333334 + "count": 27, + "covered": 25, + "percent": 92.5925925925926 }, "regions": { - "count": 17, - "covered": 12, - "notcovered": 5, - "percent": 70.58823529411765 + "count": 22, + "covered": 18, + "notcovered": 4, + "percent": 81.81818181818183 } } } @@ -75,8 +43,8 @@ "percent": 0 }, "functions": { - "count": 9, - "covered": 9, + "count": 8, + "covered": 8, "percent": 100 }, "instantiations": { @@ -85,15 +53,15 @@ "percent": 90.9090909090909 }, "lines": { - "count": 33, - "covered": 29, - "percent": 87.87878787878788 + "count": 27, + "covered": 25, + "percent": 92.5925925925926 }, "regions": { - "count": 28, - "covered": 21, - "notcovered": 7, - "percent": 75 + "count": 22, + "covered": 18, + "notcovered": 4, + "percent": 81.81818181818183 } } } diff --git a/tests/fixtures/coverage-reports/doctest/workspace_root.lcov.info b/tests/fixtures/coverage-reports/doctest/workspace_root.lcov.info index 0e77bcb3..4dec27c2 100644 --- a/tests/fixtures/coverage-reports/doctest/workspace_root.lcov.info +++ b/tests/fixtures/coverage-reports/doctest/workspace_root.lcov.info @@ -1,16 +1,8 @@ -SF:/tmp/.tmpQwD18k/src/lib.rs -FNF:4 -FNH:4 -BRF:0 -BRH:0 -LF:15 -LH:14 -end_of_record SF:src/lib.rs -FNF:5 -FNH:5 +FNF:8 +FNH:8 BRF:0 BRH:0 -LF:18 -LH:15 +LF:27 +LH:25 end_of_record \ No newline at end of file diff --git a/tests/fixtures/coverage-reports/doctest/workspace_root.summary.txt b/tests/fixtures/coverage-reports/doctest/workspace_root.summary.txt index 0a2641b6..f2294bb7 100644 --- a/tests/fixtures/coverage-reports/doctest/workspace_root.summary.txt +++ b/tests/fixtures/coverage-reports/doctest/workspace_root.summary.txt @@ -1,6 +1,5 @@ -Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -/tmp/.tmp2e2Bx8/src/lib.rs 11 2 81.82% 4 0 100.00% 15 1 93.33% 0 0 - -src/lib.rs 17 5 70.59% 5 0 100.00% 18 3 83.33% 0 0 - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -TOTAL 28 7 75.00% 9 0 100.00% 33 4 87.88% 0 0 - \ No newline at end of file +Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +src/lib.rs 22 4 81.82% 8 0 100.00% 27 2 92.59% 0 0 - +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +TOTAL 22 4 81.82% 8 0 100.00% 27 2 92.59% 0 0 - \ No newline at end of file diff --git a/tests/fixtures/coverage-reports/doctest/workspace_root.txt b/tests/fixtures/coverage-reports/doctest/workspace_root.txt index 42e23706..d263c514 100644 --- a/tests/fixtures/coverage-reports/doctest/workspace_root.txt +++ b/tests/fixtures/coverage-reports/doctest/workspace_root.txt @@ -1,44 +1,14 @@ -/tmp/.tmpzVh4uE/src/lib.rs: - 1| 1|/// ``` + 1| 1|/// ```/// ``` 2| 1|/// assert_eq!(crate1::generic_fn("doc", "doctest"), Ok("doctest")); 3| 1|/// ``` - 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { - 5| 1| match s { - 6| 1| "unit" => Ok("unit-test"), - ^0 + 4| 2|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { + 5| 2| match s { + 6| 2| "unit" => Ok("unit-test"), + ^1 7| 1| "doc" => Ok("doctest"), 8| 0| _ => Err(val), 9| | } - 10| 1|} - 11| | - 12| 1|/// ``` - 13| 1|/// assert_eq!(crate1::non_generic_fn("doc"), "doctest"); - 14| 1|/// ``` - 15| |pub fn non_generic_fn(s: &str) -> &str { - 16| | match s { - 17| | "unit" => "unit-test", - 18| | "doc" => "doctest", - 19| | val => val, - 20| | } - 21| |} - 22| | - 23| |#[test] - 24| |fn unit_test() { - 25| | assert_eq!(generic_fn("unit", 1), Ok("unit-test")); - 26| | assert_eq!(non_generic_fn("unit"), "unit-test"); - 27| |} - -src/lib.rs: - 1| 1|/// ```/// ``` - 2| |/// assert_eq!(crate1::generic_fn("doc", "doctest"), Ok("doctest")); - 3| |/// ``` - 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { - 5| 1| match s { - 6| 1| "unit" => Ok("unit-test"), - 7| 0| "doc" => Ok("doctest"), - 8| 0| _ => Err(val), - 9| | } - 10| 1|} + 10| 2|} ------------------ | crate1::generic_fn::: | 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { @@ -50,11 +20,21 @@ src/lib.rs: | 10| 1|} ------------------ | Unexecuted instantiation: crate1::generic_fn::<_> + ------------------ + | crate1::generic_fn::<&str>: + | 4| 1|pub fn generic_fn(s: &str, val: T) -> Result<&str, T> { + | 5| 1| match s { + | 6| 1| "unit" => Ok("unit-test"), + | ^0 + | 7| 1| "doc" => Ok("doctest"), + | 8| 0| _ => Err(val), + | 9| | } + | 10| 1|} ------------------ 11| | - 12| |/// ``` - 13| |/// assert_eq!(crate1::non_generic_fn("doc"), "doctest"); - 14| |/// ``` + 12| 1|/// ``` + 13| 1|/// assert_eq!(crate1::non_generic_fn("doc"), "doctest"); + 14| 1|/// ``` 15| 2|pub fn non_generic_fn(s: &str) -> &str { 16| 2| match s { 17| 2| "unit" => "unit-test",