Fail presubmit on warnings

Change-Id: I6b44b36d16b3285bb752810a98831e05e58d8c4e
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/qg/+/121010
Reviewed-by: Alexei Frolov <frolv@google.com>
Pigweed-Auto-Submit: Erik Gilling <konkers@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/qg-cli/src/main.rs b/qg-cli/src/main.rs
index b3b8d55..5b7d147 100644
--- a/qg-cli/src/main.rs
+++ b/qg-cli/src/main.rs
@@ -12,6 +12,9 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+// Allows presubmit to fail on warnings.
+#![cfg_attr(feature = "strict", deny(warnings))]
+
 mod hello;
 mod new;
 mod subcommands;
diff --git a/qg/Cargo.toml b/qg/Cargo.toml
index 75d2068..33cb61b 100644
--- a/qg/Cargo.toml
+++ b/qg/Cargo.toml
@@ -18,6 +18,7 @@
 [features]
 default = []
 python = ["dep:rustpython"]
+strict = []
 
 [dev-dependencies]
 tempfile = "3.3.0"
diff --git a/qg/src/lib.rs b/qg/src/lib.rs
index 2ec3aec..c4e64fb 100644
--- a/qg/src/lib.rs
+++ b/qg/src/lib.rs
@@ -12,6 +12,9 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+// Allows presubmit to fail on warnings.
+#![cfg_attr(feature = "strict", deny(warnings))]
+
 use std::path::{Path, PathBuf};
 
 pub mod project;
diff --git a/qg/src/project/file.rs b/qg/src/project/file.rs
index db34bd1..76e14c3 100644
--- a/qg/src/project/file.rs
+++ b/qg/src/project/file.rs
@@ -27,6 +27,8 @@
 }
 
 impl File {
+    // TODO(konkers): Remove once this is referenced.
+    #[allow(dead_code)]
     pub(super) fn new(path: impl AsRef<Path>) -> Self {
         Self {
             path: path.as_ref().to_path_buf(),
diff --git a/qg/src/py/mod.rs b/qg/src/py/mod.rs
index bb6671c..a75dddf 100644
--- a/qg/src/py/mod.rs
+++ b/qg/src/py/mod.rs
@@ -125,7 +125,8 @@
                 Ok(())
             },
             code,
-        );
+        )
+        .unwrap();
 
         assert_eq!(
             *lines.lock().unwrap(),
diff --git a/tools/presubmit.sh b/tools/presubmit.sh
index 56fac4a..ba47a29 100755
--- a/tools/presubmit.sh
+++ b/tools/presubmit.sh
@@ -36,13 +36,13 @@
   export PATH="$CIPD_DIR/install/bin:$CIPD_DIR/install:$PATH"
 fi
 
-FEATURES=python
+FEATURES=python,strict
 
 # Build and test in release mode to make tests execute faster.
 check cargo build --release --features ${FEATURES}
 check cargo test --release --features ${FEATURES}
 check cargo fmt --check
-check cargo clippy --features ${FEATURES} -- -D clippy::pedantic
+check cargo clippy --features ${FEATURES} -- -D clippy::pedantic -D warnings
 
 echo
 echo "All presubmit steps passed!"