Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allow-print-in-tests = true
20 changes: 0 additions & 20 deletions .github/features.ua

This file was deleted.

29 changes: 11 additions & 18 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,25 @@ jobs:
- uses: actions/checkout@v4
- name: Check formatting
run: cargo fmt --all --check
install_deps:
needs: check_formatting
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install depsAdd commentMore actions
- uses: actions/cache@v4
with:
path: target
key: build-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
build-${{ runner.os }}-
- name: Install deps
run: |
sudo apt-get update -y
sudo apt-get --fix-missing install -y
sudo apt-get install libasound2-dev libudev-dev pkg-config libx11-dev libjpeg-dev
- name: Install WASM target
run: rustup target add wasm32-unknown-unknown
sudo apt-get install libasound2-dev
- name: Run clippy
run: cargo clippy --no-deps --all-targets --workspace --all-features -- --deny=warnings
# Test the interpreter
test_bin:
needs: install_deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -66,13 +70,10 @@ jobs:
key: build-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
build-${{ runner.os }}-
- name: Check interpreter clippy lints
run: cargo clippy --no-deps
- name: Run interpreter tests
run: cargo test --lib
# Test the site
test_site:
needs: install_deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -86,7 +87,6 @@ jobs:
run: cargo test -p site
# Test ffi
test_ffi:
needs: install_deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -98,10 +98,3 @@ jobs:
build-${{ runner.os }}-
- name: Run site tests
run: cargo test -p tests_ffi
# check_features:
# needs: test_bin
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Check feature combinations
# run: cargo run ./.github/features.ua
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,18 @@ system = ["libffi?/system"]

[[bin]]
name = "uiua"
required-features = ["binary"]

[workspace]
members = ["site", "tests_ffi", "pad/editor", "parser"]

[workspace.lints.clippy]
print_stdout = "warn"
print_stderr = "allow"
dbg_macro = "warn"

[lints]
workspace = true

[profile.dev]
incremental = true
1 change: 1 addition & 0 deletions pad/editor/.clippy.toml
3 changes: 3 additions & 0 deletions pad/editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]

[lints]
workspace = true

[dependencies]
leptos = { version = "0.6.10", features = ["csr"] }
js-sys = "0.3.69"
Expand Down
1 change: 1 addition & 0 deletions parser/.clippy.toml
3 changes: 3 additions & 0 deletions parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ repository = "https://github.com/uiua-lang/uiua"
rust-version = "1.82.0"
version = "0.17.0-dev.1"

[lints]
workspace = true

[dependencies]
bytemuck = {version = "1.17", features = ["must_cast", "derive", "extern_crate_alloc"]}
colored = "2"
Expand Down
1 change: 1 addition & 0 deletions site/.clippy.toml
3 changes: 3 additions & 0 deletions site/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ edition = "2021"
name = "site"
version = "0.1.0"

[lints]
workspace = true

[dependencies]
base64 = "0.22.0"
comrak = "0.39.0"
Expand Down
1 change: 1 addition & 0 deletions src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,7 @@ impl Compiler {
let inputs = self.asm.inputs.clone();
self.emit_diagnostic_impl(Diagnostic::new(message.into(), span, kind, inputs));
}
#[allow(clippy::print_stdout)]
fn emit_diagnostic_impl(&mut self, diagnostic: Diagnostic) {
if self.print_diagnostics {
eprintln!("{}", diagnostic.report());
Expand Down
3 changes: 0 additions & 3 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use std::{
str::FromStr,
};

#[allow(missing_docs)]
pub const DEBUG: bool = false;

/// Data for how to send an argument type to `&ffi`
#[derive(Debug)]
pub struct FfiArg {
Expand Down
57 changes: 0 additions & 57 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,43 +356,11 @@ mod tests {
}
}

fn recurse_dirs(dir: &std::path::Path, f: &impl Fn(&std::path::Path)) {
for entry in std::fs::read_dir(dir).unwrap() {
let entry = entry.unwrap();
let path = entry.path();
if path.to_string_lossy().contains("target") {
continue;
}
if path.is_dir() {
recurse_dirs(&path, f);
} else {
f(&path);
}
}
}

#[test]
fn no_dbgs() {
recurse_dirs(std::path::Path::new("."), &|path| {
if path.extension().is_none_or(|ext| ext != "rs")
|| path.canonicalize().unwrap()
== std::path::Path::new(file!()).canonicalize().unwrap()
{
return;
}
let contents = std::fs::read_to_string(path).unwrap();
for line in contents.lines() {
if line.contains("dbg!") && !line.trim().starts_with("//") {
panic!("File {} contains a dbg! macro", path.display());
}
}
});
if crate::compile::invert::DEBUG {
panic!("compile::invert::DEBUG is true");
}
if crate::ffi::DEBUG {
panic!("ffi::DEBUG is true");
}
if crate::compile::optimize::DEBUG {
panic!("compile::optimize::DEBUG is true");
}
Expand All @@ -401,31 +369,6 @@ mod tests {
}
}

#[test]
fn no_printlns() {
recurse_dirs(std::path::Path::new("."), &|path| {
if path.extension().is_none_or(|ext| ext != "rs")
|| path.canonicalize().unwrap()
== std::path::Path::new(file!()).canonicalize().unwrap()
|| path
.components()
.any(|c| c.as_os_str() == "main.rs" || c.as_os_str() == "profile.rs")
{
return;
}
let contents = std::fs::read_to_string(path).unwrap();
for line in contents.lines() {
if line.contains("println!")
&& !(line.trim().starts_with("//")
|| line.contains("eprintln!")
|| line.contains("// Allow println"))
{
panic!("File {} contains a println! macro", path.display());
}
}
});
}

#[test]
fn external_bind_before() {
let mut comp = Compiler::new();
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::print_stdout)]
#[cfg(not(feature = "binary"))]
compile_error!("To compile the uiua interpreter binary, you must enable the `binary` feature flag");

Expand Down
4 changes: 2 additions & 2 deletions src/profile.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::print_stdout)]
#[macro_export]
#[doc(hidden)]
macro_rules! profile_function {
Expand Down Expand Up @@ -297,8 +298,7 @@ Life ← ↥∩=₃⟜+⊸(/+↻⊂A₂C₂)
}
}
println!(
"{:<26} | {:>7} {:>5} | {:>5} {:>5} |",
name, median_dur, media_dur_change, share, share_change
"{name:<26} | {median_dur:>7} {media_dur_change:>5} | {share:>5} {share_change:>5} |"
);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ impl Uiua {
take(&mut self.rt.reports)
}
/// Print all pending reports
#[allow(clippy::print_stdout)]
pub fn print_reports(&mut self) {
for report in self.take_reports() {
eprintln!("{report}");
Expand Down Expand Up @@ -790,6 +791,7 @@ impl Uiua {
Ok(())
}
};
#[allow(clippy::print_stdout)]
if self.rt.time_instrs {
let end_time = self.rt.backend.now();
let padding = self.rt.call_stack.len().saturating_sub(1) * 2;
Expand Down
3 changes: 3 additions & 0 deletions src/sys/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ impl SysBackend for NativeSys {
fn allow_thread_spawning(&self) -> bool {
true
}
#[allow(clippy::print_stdout)]
#[cfg(all(feature = "terminal_image", feature = "image"))]
fn show_image(&self, image: image::DynamicImage, _label: Option<&str>) -> Result<(), String> {
let (_width, _height) = if let Some((w, h)) = terminal_size() {
Expand Down Expand Up @@ -1279,6 +1280,7 @@ impl SysBackend for NativeSys {
NATIVE_SYS.git_paths.insert(url.to_string(), res.clone());
res
}
#[allow(clippy::print_stdout)]
fn breakpoint(&self, env: &Uiua) -> Result<bool, String> {
if !self.output_enabled() {
return Ok(true);
Expand All @@ -1299,6 +1301,7 @@ impl SysBackend for NativeSys {
}
}

#[allow(clippy::print_stdout)]
#[doc(hidden)]
pub fn print_stack(stack: &[Value], color: bool) {
#[cfg(feature = "window")]
Expand Down
1 change: 1 addition & 0 deletions tests_ffi/.clippy.toml
3 changes: 3 additions & 0 deletions tests_ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ version = "0.1.0"
crate-type = ["cdylib"]
name = "ffi_lib"

[lints]
workspace = true

[dependencies]
uiua.path = ".."