diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bab677c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,72 @@ +on: + pull_request: + push: + branches: + - main + +name: continuous-integration + +env: + NUSHELL_CARGO_PROFILE: ci + NU_LOG_LEVEL: DEBUG + CLIPPY_OPTIONS: "-D warnings" + +jobs: + fmt-clippy: + strategy: + fail-fast: true + matrix: + # Pinning to Ubuntu 20.04 because building on newer Ubuntu versions causes linux-gnu + # builds to link against a too-new-for-many-Linux-installs glibc version. Consider + # revisiting this when 20.04 is closer to EOL (April 2025) + platform: [macos-latest, ubuntu-20.04, windows-latest] + feature: [default] + include: + - feature: default + flags: "" + + runs-on: ${{ matrix.platform }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup Rust toolchain and cache + uses: actions-rust-lang/setup-rust-toolchain@v1.5.0 + with: + rustflags: "" + + - name: cargo fmt + run: cargo fmt --all -- --check + + - name: Clippy + run: cargo clippy --workspace ${{ matrix.flags }} -- $CLIPPY_OPTIONS + + # In tests we don't have to deny unwrap + - name: Clippy of tests + run: cargo clippy --tests --workspace ${{ matrix.flags }} -- -D warnings + + tests: + strategy: + fail-fast: true + matrix: + platform: [macos-latest, ubuntu-20.04, windows-latest] + feature: [default] + include: + - feature: default + flags: "" + flags: + - # default + - --all-features + + runs-on: ${{ matrix.platform }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup Rust toolchain and cache + uses: actions-rust-lang/setup-rust-toolchain@v1.5.0 + with: + rustflags: "" + + - name: Tests + run: cargo test ${{ matrix.flags }} diff --git a/src/codegen.rs b/src/codegen.rs index 31af3c5..cf2cdc8 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -724,7 +724,7 @@ impl Codegen { for param in params { output.extend_from_slice(b", "); let variable_ty = self.compiler.get_variable(param.var_id).ty; - self.codegen_typename(variable_ty, &inference_vars, output); + self.codegen_typename(variable_ty, inference_vars, output); output.push(b' '); output.extend_from_slice(b"variable_"); output.extend_from_slice(param.var_id.0.to_string().as_bytes()); diff --git a/src/typechecker.rs b/src/typechecker.rs index 188b439..9b02d94 100644 --- a/src/typechecker.rs +++ b/src/typechecker.rs @@ -31,6 +31,7 @@ pub struct TypedField { pub where_defined: NodeId, } +#[allow(clippy::enum_variant_names)] #[derive(Debug, Clone, PartialEq)] pub enum Type { Unknown, @@ -368,6 +369,7 @@ impl Typechecker { } } + #[allow(clippy::too_many_arguments)] pub fn typecheck_fun_predecl( &mut self, name: NodeId, @@ -918,7 +920,7 @@ impl Typechecker { let mut base_classes = vec![base_class]; if let Some(base_base_classes) = self.compiler.base_classes.get(&base_class) { - base_classes.extend_from_slice(&base_base_classes); + base_classes.extend_from_slice(base_base_classes); } self.compiler.base_classes.insert(type_id, base_classes); @@ -1239,7 +1241,7 @@ impl Typechecker { &self, expected_type: TypeId, actual_type: TypeId, - local_inferences: &mut Vec, + local_inferences: &mut [TypeId], ) -> bool { let expected_type = self.compiler.resolve_type(expected_type, local_inferences); let expected_type = self.compiler.get_underlying_type_id(expected_type); @@ -2523,12 +2525,12 @@ impl Typechecker { let mut fields = fields.clone(); if let Some(base_classes) = self.compiler.base_classes.get(&type_id) { for type_id in base_classes { - match self.compiler.get_type(*type_id) { - Type::Struct { - fields: base_fields, - .. - } => fields.extend_from_slice(&base_fields), - _ => {} + if let Type::Struct { + fields: base_fields, + .. + } = self.compiler.get_type(*type_id) + { + fields.extend_from_slice(base_fields) } } } diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index ca92c1e..344b23a 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -81,7 +81,7 @@ fn test_example(test_name: &Path) -> TestResult { // Create it if it's not there let mut temp_dir = std::env::var("JUNE_TESTDIR") - .map(|dir| PathBuf::from(dir)) + .map(PathBuf::from) .unwrap_or_else(|_| std::env::temp_dir()); temp_dir.push("june_tests");