dtolnay/trybuild

Cargo check is not enough to detect build errors from monomorphization

Closed this issue · 2 comments

While using trybuild for this: https://github.com/golddranks/recycle_vec/blob/master/src/lib.rs#L153 I noticed that trybuild's default, cargo check is not enough to cause a build error. This is because of a static assert trick I'm using: https://github.com/golddranks/recycle_vec/blob/master/src/lib.rs#L79. The trick depends on monomorphisation, and cargo check doesn't go deep enough to encounter mismatches in monomorphisation.

I'm working around the problem by adding an empty test, t.pass("tests/force_build.rs");, which seems to force it to use cargo build. However, it would be nice if trybuild would do some of these:

  • Use cargo build by default
  • Retry with cargo build if cargo check fails to fail
  • Provide an option to force cargo build, documenting the shortcoming of cargo check.

I'm willing to send a PR once we have a decision of the desired functionality.

I would prefer not to support this in this crate. But it would be reasonable for someone else to maintain a more fully featured ui testing library that handles non-check errors better.

loyd commented

Hah, I faced the same problem while writing post-mono check tests.

@golddranks, thanks for discovering force_build.rs WA!