Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[test] fns is not type checked when not testing #1748

Closed
nikomatsakis opened this issue Feb 3, 2012 · 5 comments
Closed

#[test] fns is not type checked when not testing #1748

nikomatsakis opened this issue Feb 3, 2012 · 5 comments
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc A-type-system Area: Type system E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@nikomatsakis
Copy link
Contributor

If you are not running --test, then #[test] functions are stripped out of the source. This is good, in one sense, but bad in another---the functions are not type checked! It is very easy for them to bitrot this way. I think they ought to stick around but not be translated; we can ensure that #[test] functions are not referenced from other functions in check_fn_usage, or whatever that pass is called.

@brson
Copy link
Contributor

brson commented Feb 3, 2012

Can we possibly just move the test compiler pass further down the pipeline?

@brson
Copy link
Contributor

brson commented Feb 3, 2012

There are also #[cfg(test)] functions as well, but it's harder to argue that those should be typechecked - should #[cfg(target_os = "win32")] functions be typechecked on linux?

@nikomatsakis
Copy link
Contributor Author

I would prefer to type check as much as we can. If we can type check win32 functions, I think we should! But if may turn out that there are cases where two variants are mutually exclusive...? I am thinking of some of the math stuff where it was conditionally compiled such that float == f32 sometimes and sometimes float == f64.

But personally there's nothing I hate more than thinking I have everything good and then finding out that it won't even build on windows... usually it runs after I fix the build error, but the build fails on some trivial thing.

@marijnh
Copy link
Contributor

marijnh commented Feb 3, 2012

Can't we just expect people to actually run their tests? Not typechecking is one form of bitrot, not passing is another. We don't want to run tests as part of a normal compilation.

@nikomatsakis
Copy link
Contributor Author

If we can't compile everything---which I guess we can't---then it's fine. I feel like it's annoying not to know whether tests will at least build, but @marijnh has a point. Anyway it's probably not worth the time to fix. I'll close it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc A-type-system Area: Type system E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants