-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
208 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,19 +10,18 @@ jobs: | |
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- name: Test VM | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --manifest-path crates/dash_vm/Cargo.toml # no --all-features because jit | ||
run: cargo t -p dash_vm # no --all-features because jit | ||
|
||
- name: Test lints | ||
run: cargo t -p lints | ||
|
||
- name: Lints | ||
run: ./lints.sh | ||
|
||
- name: Benchmark VM | ||
run: eval $(cargo test --release --benches -p dash_vm |& grep -o -P 'target/release/deps/full-[^\)]+') --bench --output-format bencher | tee output.txt | ||
|
||
- name: Store output | ||
if: github.ref == 'refs/heads/master' | ||
uses: benchmark-action/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
cargo b -p lints | ||
RUSTC_WRAPPER="./target/debug/lints" cargo c -p dash-cli --all-features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "ui" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lints.rust] | ||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(dash_lints)'] } | ||
|
||
[dependencies] | ||
dash_vm = { path = "../../../crates/dash_vm" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#![cfg_attr(dash_lints, feature(register_tool))] | ||
#![cfg_attr(dash_lints, register_tool(dash_lints))] | ||
#![allow(path_statements, dead_code, clippy::no_effect)] | ||
|
||
use dash_vm::localscope::LocalScope; | ||
use dash_vm::value::Unrooted; | ||
use dash_vm::Vm; | ||
|
||
fn make_unrooted() -> Unrooted { | ||
todo!() | ||
} | ||
fn make_unrooted_res(_: &mut LocalScope<'_>) -> Result<Unrooted, Unrooted> { | ||
todo!() | ||
} | ||
fn transform_unrooted(_: &mut LocalScope<'_>, _: Unrooted) -> Unrooted { | ||
todo!() | ||
} | ||
fn use_vm(_: &mut Vm) {} | ||
fn use_scope(_: &mut LocalScope<'_>) {} | ||
#[cfg_attr(dash_lints, dash_lints::trusted_no_gc)] | ||
fn use_scope_ok(_: &mut LocalScope<'_>) {} | ||
|
||
fn with_vm(vm: &mut Vm, unrooted: Unrooted) { | ||
use_vm(vm); | ||
unrooted; // killed | ||
} | ||
|
||
fn with_scope(scope: &mut LocalScope<'_>, unrooted: Unrooted) { | ||
use_scope(scope); | ||
unrooted; // killed | ||
} | ||
|
||
fn kill_after_fn(scope: &mut LocalScope, u1: Unrooted, u2: Unrooted) { | ||
let v = transform_unrooted(scope, u1); | ||
u2; // killed | ||
v; // live | ||
} | ||
|
||
fn controlflow(scope: &mut LocalScope, cond: u8, u1: Unrooted) { | ||
match cond { | ||
0 => { | ||
use_scope(scope); | ||
} | ||
1 => { | ||
std::hint::black_box(()); | ||
} | ||
_ => { | ||
std::hint::black_box(()); | ||
} | ||
} // join = use | ||
|
||
u1; // killed | ||
} | ||
|
||
fn try_err(scope: &mut LocalScope<'_>) -> Result<(), Unrooted> { | ||
let u1 = make_unrooted_res(scope)?; | ||
let x = &u1; | ||
|
||
let u2 = make_unrooted_res(scope)?; | ||
x; // killed; | ||
u1; // killed | ||
u2; | ||
Ok(()) | ||
} | ||
|
||
fn attribute_works(scope: &mut LocalScope<'_>, unrooted: Unrooted) { | ||
use_scope_ok(scope); | ||
unrooted; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
error: use of unrooted value after mutable scope borrow | ||
--> lints/tests/ui/src/lib.rs:25:5 | ||
| | ||
25 | unrooted; // killed | ||
| ^^^^^^^^ | ||
| | ||
note: scope mutably borrowed here | ||
--> lints/tests/ui/src/lib.rs:24:5 | ||
| | ||
24 | use_vm(vm); | ||
| ^^^^^^^^^^ | ||
= note: `#[deny(missing_root)]` on by default | ||
|
||
error: use of unrooted value after mutable scope borrow | ||
--> lints/tests/ui/src/lib.rs:30:5 | ||
| | ||
30 | unrooted; // killed | ||
| ^^^^^^^^ | ||
| | ||
note: scope mutably borrowed here | ||
--> lints/tests/ui/src/lib.rs:29:5 | ||
| | ||
29 | use_scope(scope); | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: use of unrooted value after mutable scope borrow | ||
--> lints/tests/ui/src/lib.rs:35:5 | ||
| | ||
35 | u2; // killed | ||
| ^^ | ||
| | ||
note: scope mutably borrowed here | ||
--> lints/tests/ui/src/lib.rs:34:13 | ||
| | ||
34 | let v = transform_unrooted(scope, u1); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: use of unrooted value after mutable scope borrow | ||
--> lints/tests/ui/src/lib.rs:52:5 | ||
| | ||
52 | u1; // killed | ||
| ^^ | ||
| | ||
note: scope mutably borrowed here | ||
--> lints/tests/ui/src/lib.rs:42:13 | ||
| | ||
42 | use_scope(scope); | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: use of unrooted value after mutable scope borrow | ||
--> lints/tests/ui/src/lib.rs:60:5 | ||
| | ||
60 | x; // killed; | ||
| ^ | ||
| | ||
note: scope mutably borrowed here | ||
--> lints/tests/ui/src/lib.rs:59:14 | ||
| | ||
59 | let u2 = make_unrooted_res(scope)?; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: use of unrooted value after mutable scope borrow | ||
--> lints/tests/ui/src/lib.rs:61:5 | ||
| | ||
61 | u1; // killed | ||
| ^^ | ||
| | ||
note: scope mutably borrowed here | ||
--> lints/tests/ui/src/lib.rs:59:14 | ||
| | ||
59 | let u2 = make_unrooted_res(scope)?; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: could not compile `ui` (lib) due to 6 previous errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::error::Error; | ||
use std::process::Command; | ||
use std::{env, fs, io}; | ||
|
||
fn main() -> Result<(), Box<dyn Error>> { | ||
let command = Command::new("cargo") | ||
.current_dir("tests/ui") | ||
.arg("-q") | ||
.arg("c") | ||
.env("RUSTC_WRAPPER", "../../../target/debug/lints") | ||
.output()?; | ||
|
||
assert_eq!(command.stdout, b""); | ||
let now = std::str::from_utf8(&command.stderr).expect("cargo c never emits invalid utf8"); | ||
match fs::read_to_string("tests/ui/ui.stderr") { | ||
Ok(before) => { | ||
if before != now { | ||
if env::args().any(|arg| arg == "--bless") { | ||
fs::write("tests/ui/ui.stderr", now)?; | ||
} else { | ||
let diff = prettydiff::diff_lines(&before, now); | ||
println!("{diff}"); | ||
return Err("stderr has changed! rerun with --bless to update".into()); | ||
} | ||
} | ||
} | ||
Err(err) if err.kind() == io::ErrorKind::NotFound => { | ||
fs::write("tests/ui/ui.stderr", now)?; | ||
} | ||
Err(err) => return Err(err.into()), | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[toolchain] | ||
channel = "nightly-2024-09-05" | ||
components = ["clippy"] | ||
components = ["clippy", "rust-src", "rustc-dev", "llvm-tools-preview"] |