Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uplink-dead-code limitations (bad for code coverage) #39293
Comments
This comment has been minimized.
This comment has been minimized.
|
One improvement for this that I can see would be monomorphising all of the methods and trait impls for a type when it's instantiated, rather than just the necessary methods. This would solve most of these problems, I think. |
This comment has been minimized.
This comment has been minimized.
|
@clarcharr I think that would be a great intermediary solution, because it would catch all the cases I currently have. Even though only doing this for methods and trait impls of instansiated types would not fix this fully, because generic functions and generic types that are never instansiated would still have this issue (but I think those are quite rare). @malbarbo I'm not sure about binary size, but because this would normally only be done for test builds I don't think it should be an issue for a first version. I have one possible optimization to avoid excessive blowing up of the binary though. There could be kept track of which methods are not monomorphised at all and only monomorphise them for one of the types that they could be monomorphised for. |
Mark-Simulacrum
added
the
T-compiler
label
Jun 22, 2017
This comment has been minimized.
This comment has been minimized.
|
Looks like the problem here is (in general) that we don't use the OTOH, dead code doesn't really need to be tested -- so perhaps this isn't really a problem. |
Mark-Simulacrum
added
the
C-feature-request
label
Jul 26, 2017
This comment has been minimized.
This comment has been minimized.
You maybe be writing a library and forget to test a generic function. It is dead code in the library but a client may use the (untested) function. |
malbarbo commentedJan 25, 2017
Consider a cargo project (
dead) with thissrc/lib.rsfile:Running
outputs
We can observe that that only
fun0and<() as Trait>::fun2is included (also checked withnmand runningkcov). Not includingfun1andTrait::fun2makes code coverage inflates (usingkcov).I can see that
fun1andTrait::fun2is not included because they need to be monomorphised. One partial solution would be to monomorphise the default methods implementations for every type that implements the trait, but I think this could blow the binary size and compilation time.Would it be possible to add this symbols without monomorphisation? Or maybe creating a monomorphised version that just panics? (Could all generic paramaters be set to
!?)