Merge "Set the container field of aconfig flags" into main
diff --git a/tools/cargo_embargo/src/main.rs b/tools/cargo_embargo/src/main.rs
index fab1404..713bb8c 100644
--- a/tools/cargo_embargo/src/main.rs
+++ b/tools/cargo_embargo/src/main.rs
@@ -288,7 +288,7 @@
     }
 }
 
-/// Runs cargo_embargo with the given JSON configuration string.
+/// Runs cargo_embargo with the given JSON configuration file.
 fn run_embargo(args: &Args, config_filename: &Path) -> Result<()> {
     let cfg = Config::from_file(config_filename)?;
     let crates = make_all_crates(args, &cfg)?;
@@ -319,6 +319,18 @@
         }
     }
 
+    // If we were configured to run cargo, check whether we could have got away without it.
+    if cfg.variants.iter().any(|variant| variant.run_cargo) && package_out_files.is_empty() {
+        let mut cfg_no_cargo = cfg.clone();
+        for variant in &mut cfg_no_cargo.variants {
+            variant.run_cargo = false;
+        }
+        let crates_no_cargo = make_all_crates(args, &cfg_no_cargo)?;
+        if crates_no_cargo == crates {
+            eprintln!("Running cargo appears to be unnecessary for this crate, consider adding `\"run_cargo\": false` to your cargo_embargo.json.");
+        }
+    }
+
     write_all_bp(&cfg, crates, &package_out_files)
 }