Comments (9)
Yes it will, but the approach of "just" having your test call the const fn
at runtime will still work. So it seems to me like if coverage matters, you can keep obtaining coverage that way.
from rust.
@rustbot label +A-code-coverage
from rust.
Could you update the issue description to start by explaining the problem -- in the usual way, "here's my code, here's what I did, here's what happened, here's what should have happened"? Currently it starts by saying "the problem is hard" without saying what the problem is. I was confused for a while here. Of course there's no coverage instrumentation, it's compile-time code after all...
from rust.
Right, I was avoiding providing explicit code examples because I felt that it might get a bit too in the weeds, but I'll try and add one to make it a bit easier to understand.
from rust.
Updated the description with hopefully a better example. Keep in mind that as I said, I don't think that this feature is worth having now given my current example, but as more stuff gets stabilised for const evaluation, it feels like this would be more and more desired.
from rust.
const fn
can be called at compiletime and runtime, so I am not entirely sure why there would be code duplication.
To test the normalization code, I decided to create a bunch of sample spring states and compared their values in the test, but because I wanted to share them across tests, I constructed them in constants. This caused the normalization code to be entirely absent from code coverage, since it happened at compile time. Since the normalization after various operations isn't the same as the normalization in the constructor, the tests for those also didn't affect the constructor's code coverage.
There is another way to share them: write functions of type const fn f() -> T
. Then you can call these functions at runtime and will get coverage information.
Arguably that's still a work-around, but the overhead compared to using consts in your tests seems rather small.
from rust.
const fn
can be called at compiletime and runtime, so I am not entirely sure why there would be code duplication.There is another way to share them: write functions of type
const fn f() -> T
. Then you can call these functions at runtime and will get coverage information.Arguably that's still a work-around, but the overhead compared to using consts in your tests seems rather small.
Oh, like I said, I completely agree that this would mostly be overkill with the current state of const evaluation. It mostly just prompted the idea for me since I know that const eval will become substantially more advanced in the future.
from rust.
if it's not too much complexity in the mir interpreter, could the interpreter collect the coverage data during evaluation and then have it exposed at the use runtime sites of the constant? As long as most of the complexity is in the coverage logic and not the interpreter, that seems maintainable to me.
from rust.
Coverage instrumentation in miri in general feels like something that would be useful to have, although I'm not sure if that's already possible or not. Since the compiled code already links back to the original source, I would assume that the MIR also has access to the original source as well for storing that info.
from rust.
Related Issues (20)
- ICE(non_lifetime_binders): const bound params not handled correctly HOT 3
- diagnostics should prefer naming items through the extern prelude instead of doc-hidden type aliases
- async lambda with capture ICE HOT 4
- std::net::TcpStream::connect_timeout on vxworks HOT 4
- async lambda fails to copy a value that is Copy HOT 12
- nightly ICE when building flexstr in release mode HOT 6
- `hir::Body`'s documentation incorrectly suggests it doesn't contain parmaeter info for closures
- error: internal compiler error: compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs:486:17: cannot relate region: LUB('{erased}, '{erased}) HOT 12
- Help needed finding a test that changes behaviour when changing DefiningOpaqueTypes::No to Yes HOT 1
- Binary size creep on Fuchsia after commit 5ced3da HOT 6
- Type mismatch is incorrectly attributed in certain closures / async blocks
- ICE: Found unstable fingerprints for evaluate_obligation - computing whether enum is freeze - optimizing MIR
- Regression in `#[used]` attribute on Windows msvc HOT 16
- ICE in TaggedSerializer (serde) HOT 2
- missed optimization: coalesce PathBuf reallocation HOT 5
- `thread 'rustc' panicked at compiler/rustc_codegen_ssa/src/back/link.rs:2700:27: index out of bounds: the len is 41 but the index is 41` HOT 1
- Vxworks build error for current master branch. Need to update some source. HOT 8
- rustdoc: add link prefix which would allow overwriting explicit links with item links
- Left-padding using format! does not work when using a fmt::Display as the argument HOT 4
- ICE: Cannot Eq compare incompatible types *mut T/#0 and *const T/#0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.