blairfrandeen / 2022-AoC

Wherein I pretend I learned anythign at all about programming int he last year
0 stars 1 forks source link

Unused import warnings for test imports #1

Closed blairfrandeen closed 1 year ago

blairfrandeen commented 1 year ago

Each test module has the line

use super::*;

When running the code (cargo run 2022 2) I get one warning per module:

warning: unused import: `super::*`
  --> src/day_1.rs:42:9
   |
42 |     use super::*;
   |         ^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

All of the tests run without issue. If the use super::*; lines are removed from the modules, the errors are removed from the warnings, but the tests all fail:

error[E0425]: cannot find function `calculate_score` in this scope
   --> src/day_2.rs:143:20
    |
143 |         assert_eq!(calculate_score(&RPS::Scissors, GameResult::Draw), 6);
    |                    ^^^^^^^^^^^^^^^ not found in this scope
    |
help: consider importing this function
    |
128 |     use crate::day_2::calculate_score;

Specifying the individual functions as suggested above is tedious, and still results in warnings when running the code.

blairfrandeen commented 1 year ago

Check the Modules Cheat Sheet to see if the answer is in there

blairfrandeen commented 1 year ago

Checked my own cheat sheet, and there it is. Needed to add

#[cfg(test)]

above the test modules. Adding to template and closing