Skip to content

Commit

Permalink
Use -Clink-dead-code
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jun 9, 2021
1 parent b33976e commit 40fdbd8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn run(args: impl IntoIterator<Item = impl Into<OsString> + Clone>) -> Result<()
debug!(RUSTFLAGS = ?rustflags);
// --remap-path-prefix for Sometimes macros are displayed with abs path
rustflags.push(format!(
" -Zinstrument-coverage --remap-path-prefix {}/=",
" -Zinstrument-coverage -Clink-dead-code --remap-path-prefix {}/=",
cx.metadata.workspace_root
));

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/coverage-reports/no_test/no_test.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"data":[{"files":[{"filename":"src/lib.rs","summary":{"branches":{"count":0,"covered":0,"notcovered":0,"percent":0},"functions":{"count":3,"covered":3,"percent":100},"instantiations":{"count":3,"covered":3,"percent":100},"lines":{"count":3,"covered":3,"percent":100},"regions":{"count":3,"covered":3,"notcovered":0,"percent":100}}}],"totals":{"branches":{"count":0,"covered":0,"notcovered":0,"percent":0},"functions":{"count":3,"covered":3,"percent":100},"instantiations":{"count":3,"covered":3,"percent":100},"lines":{"count":3,"covered":3,"percent":100},"regions":{"count":3,"covered":3,"notcovered":0,"percent":100}}}],"type":"llvm.coverage.json.export","version":"2.0.1"}
{"data":[{"files":[{"filename":"src/lib.rs","summary":{"branches":{"count":0,"covered":0,"notcovered":0,"percent":0},"functions":{"count":3,"covered":3,"percent":100},"instantiations":{"count":3,"covered":3,"percent":100},"lines":{"count":3,"covered":3,"percent":100},"regions":{"count":3,"covered":3,"notcovered":0,"percent":100}}},{"filename":"src/module.rs","summary":{"branches":{"count":0,"covered":0,"notcovered":0,"percent":0},"functions":{"count":1,"covered":0,"percent":0},"instantiations":{"count":1,"covered":0,"percent":0},"lines":{"count":7,"covered":0,"percent":0},"regions":{"count":6,"covered":0,"notcovered":6,"percent":0}}}],"totals":{"branches":{"count":0,"covered":0,"notcovered":0,"percent":0},"functions":{"count":4,"covered":3,"percent":75},"instantiations":{"count":4,"covered":3,"percent":75},"lines":{"count":10,"covered":3,"percent":30},"regions":{"count":9,"covered":3,"notcovered":6,"percent":33.333333333333329}}}],"type":"llvm.coverage.json.export","version":"2.0.1"}
8 changes: 8 additions & 0 deletions tests/fixtures/coverage-reports/no_test/no_test.lcov.info
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ BRF:0
BFH:0
LF:3
LH:3
end_of_record
SF:src/module.rs
FNF:1
FNH:0
BRF:0
BFH:0
LF:7
LH:0
end_of_record
5 changes: 3 additions & 2 deletions tests/fixtures/coverage-reports/no_test/no_test.summary.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
src/lib.rs 3 0 100.00% 3 0 100.00% 3 0 100.00% 0 0 -
lib.rs 3 0 100.00% 3 0 100.00% 3 0 100.00% 0 0 -
module.rs 6 6 0.00% 1 1 0.00% 7 7 0.00% 0 0 -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL 3 0 100.00% 3 0 100.00% 3 0 100.00% 0 0 -
TOTAL 9 6 33.33% 4 1 75.00% 10 7 30.00% 0 0 -
13 changes: 12 additions & 1 deletion tests/fixtures/coverage-reports/no_test/no_test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
src/lib.rs:
1| 1|mod module;mod module;
2| |pub use module::*;
3| |
4| 1|#[test]
5| 1|fn f() {}
5| 1|fn f() {}

src/module.rs:
1| 0|pub fn match1(x: u32) {
2| 0| match x {
3| 0| 0 => {}
4| 0| 1 => {}
5| 0| 2 => {}
6| 0| _ => {}
7| | }
8| 0|}

0 comments on commit 40fdbd8

Please sign in to comment.