Skip to content
Open
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ jobs:
- uses: actions/checkout@v2
- name: Run tests
run: cargo test --verbose
- name: Run tests against miri
run: cargo miri test --verbose
- name: Check README.md is up to date
run: cargo install cargo-readme && cargo readme > README.md && git diff --quiet
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
target
Cargo.lock
287 changes: 287 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ repository = "https://github.com/jorendorff/atomicbox"
[dependencies]

[dev-dependencies]
compiletest_rs = "0.7.1"
trybuild = "1.0"
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "nightly-2025-04-20"
components = ["rust-src", "rustfmt", "miri"]
profile = "minimal"
2 changes: 0 additions & 2 deletions tests/compile-fail/send_rc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate atomicbox;

use atomicbox::AtomicBox;
use std::rc::Rc;

Expand Down
43 changes: 43 additions & 0 deletions tests/compile-fail/send_rc.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
error[E0277]: `Rc<&str>` cannot be sent between threads safely
--> tests/compile-fail/send_rc.rs:9:37
|
9 | let handle = std::thread::spawn(move || {
| __________________------------------_^
| | |
| | required by a bound introduced by this call
10 | | //~^ ERROR `Rc<&str>` cannot be sent between threads safely
11 | | let value = *abox.into_inner();
12 | | println!("Other thread: {:?}", value);
13 | | });
| |_____^ `Rc<&str>` cannot be sent between threads safely
|
= help: the trait `Send` is not implemented for `Rc<&str>`
= note: required for `Unique<Rc<&str>>` to implement `Send`
note: required because it appears within the type `Box<Rc<&str>>`
--> $RUST/alloc/src/boxed.rs
|
| pub struct Box<
| ^^^
note: required because it appears within the type `PhantomData<Box<Rc<&str>>>`
--> $RUST/core/src/marker.rs
|
| pub struct PhantomData<T: ?Sized>;
| ^^^^^^^^^^^
note: required because it appears within the type `AtomicBox<Rc<&str>>`
--> src/atomic_box.rs
|
| pub struct AtomicBox<T> {
| ^^^^^^^^^
note: required because it's used within this closure
--> tests/compile-fail/send_rc.rs:9:37
|
9 | let handle = std::thread::spawn(move || {
| ^^^^^^^
note: required by a bound in `spawn`
--> $RUST/std/src/thread/mod.rs
|
| pub fn spawn<F, T>(f: F) -> JoinHandle<T>
| ----- required by a bound in this function
...
| F: Send + 'static,
| ^^^^ required by this bound in `spawn`
25 changes: 3 additions & 22 deletions tests/compile_tests.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
#![allow(clippy::field_reassign_with_default)]

// Copied from <https://lib.rs/crates/compiletest_rs>.

extern crate compiletest_rs as compiletest;

use std::path::PathBuf;

fn run_mode(mode: &'static str) {
let mut config = compiletest::Config::default();

config.mode = mode.parse().expect("Invalid mode");
config.src_base = PathBuf::from(format!("tests/{}", mode));
config.target_rustcflags = Some("-L target/debug".to_string());
config.link_deps(); // Populate config.target_rustcflags with dependencies on the path
config.clean_rmeta(); // If your tests import the parent crate, this helps with E0464

compiletest::run_tests(&config);
}

#[test]
#[cfg_attr(not(miri), test)]
fn compile_test() {
run_mode("compile-fail");
let t = trybuild::TestCases::new();
t.compile_fail("tests/compile-fail/*.rs");
}