]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/instrument_coverage.rs
Add extended error message for E0523
[rust.git] / tests / mir-opt / instrument_coverage.rs
1 // Test that `-C instrument-coverage` injects Coverage statements. The Coverage Counter statements
2 // are later converted into LLVM instrprof.increment intrinsics, during codegen.
3
4 // unit-test: InstrumentCoverage
5 // needs-profiler-support
6 // ignore-windows
7 // compile-flags: -C instrument-coverage --remap-path-prefix={{src-base}}=/the/src
8
9 // EMIT_MIR instrument_coverage.main.InstrumentCoverage.diff
10 // EMIT_MIR instrument_coverage.bar.InstrumentCoverage.diff
11 fn main() {
12     loop {
13         if bar() {
14             break;
15         }
16     }
17 }
18
19 #[inline(never)]
20 fn bar() -> bool {
21     true
22 }
23
24 // Note that the MIR with injected coverage intrinsics includes references to source locations,
25 // including the source file absolute path. Typically, MIR pretty print output with file
26 // references are safe because the file prefixes are substituted with `$DIR`, but in this case
27 // the file references are encoded as function arguments, with an `Operand` type representation
28 // (`Slice` `Allocation` interned byte array) that cannot be normalized by simple substitution.
29 //
30 // The first workaround is to use the `SourceMap`-supported `--remap-path-prefix` option; however,
31 // the implementation of the `--remap-path-prefix` option currently joins the new prefix and the
32 // remaining source path with an OS-specific path separator (`\` on Windows). This difference still
33 // shows up in the byte array representation of the path, causing Windows tests to fail to match
34 // blessed results baselined with a `/` path separator.
35 //
36 // Since this `mir-opt` test does not have any significant platform dependencies, other than the
37 // path separator differences, the final workaround is to disable testing on Windows.