When will Cargo recompile because included file changed?

I have a "build.rs" program which generates a file in OUT_DIR, the official place for generated files. The generated file has to be included in the source tree and compiled into the project. So I have a file in the project which contains only

include!(concat!(env!("OUT_DIR"), "/msgdefs.rs"));

This follows the directions in https://rust-lang.github.io/rust-bindgen/tutorial-4.html

Works fine. The question is, what tells Cargo when to recompile that file? If the included file changes, will it be recompiled? Or do I need to do something to make that happen? How does Cargo know?

I think you are looking for this section of the docs: https://doc.rust-lang.org/cargo/reference/build-scripts.html#change-detection

That tells when build.rs gets rerun. I'm asking when the included output from build.rs gets recompiled.

Ah, understood. That happens automatically. When rustc compiles a crate, it can produce a depinfo file -- a list of files which were used to compile the crate. Cargo then uses this file to check when the crate needs to be recompiled.

There's no such thing as recompiling a file -- a unit of compilation is a crate, which can consist of a number of files.

OK, so it's automatic and I don't need to worry about it. Thanks.