Skip to content

Modernize lazy-static infra #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 16, 2024
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
60 changes: 60 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Rust

on: [push, pull_request]

env:
CARGO_TERM_COLOR: always

permissions:
contents: read

jobs:
check:
name: "Tests"
runs-on: ubuntu-latest
strategy:
matrix:
channel:
- stable
- beta
- nightly

steps:
- name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

- name: Install Rust Toolchain
run: rustup default ${{ matrix.channel }}

- name: Install cargo-hack
run: cargo install cargo-hack

- name: Powerset
run: cargo hack test --feature-powerset --lib

miri:
name: "Miri"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Miri
run: |
rustup toolchain install nightly --component miri
cargo +nightly miri setup
- name: Default features
run: cargo +nightly miri test

embedded:
name: Build (embedded)
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

- name: Install Rust toolchain
run: |
rustup default nightly
rustup target add thumbv7em-none-eabi

- name: Default features
run: cargo build -Z avoid-dev-deps --features spin_no_std --target thumbv7em-none-eabi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ target
doc
Cargo.lock
.cargo
wip
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

14 changes: 3 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ documentation = "https://docs.rs/lazy_static"
repository = "https://github.com/rust-lang-nursery/lazy-static.rs"
keywords = ["macro", "lazy", "static"]
categories = [ "no-std", "rust-patterns", "memory-management" ]
exclude = ["/.travis.yml", "/appveyor.yml"]
exclude = [".github"]

[dependencies.spin]
version = "0.9.3"
version = "0.9.8"
default-features = false
features = ["once"]
optional = true
Expand All @@ -25,12 +25,4 @@ spin_no_std = ["spin"]

[dev-dependencies]
doc-comment = "0.3.1"

[badges]
appveyor = { repository = "rust-lang-nursery/lazy-static.rs" }
travis-ci = { repository = "rust-lang-nursery/lazy-static.rs" }

is-it-maintained-issue-resolution = { repository = "rust-lang-nursery/lazy-static.rs" }
is-it-maintained-open-issues = { repository = "rust-lang-nursery/lazy-static.rs" }

maintenance = { status = "passively-maintained" }
trybuild = "1"
61 changes: 0 additions & 61 deletions appveyor.yml

This file was deleted.

11 changes: 0 additions & 11 deletions compiletest/Cargo.toml

This file was deleted.

11 changes: 0 additions & 11 deletions compiletest/src/lib.rs

This file was deleted.

22 changes: 0 additions & 22 deletions compiletest/tests/compile-fail/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions compiletest/tests/compile-fail/incorrect_visibility_restriction.rs

This file was deleted.

11 changes: 0 additions & 11 deletions compiletest/tests/compile-fail/static_is_sized.rs

This file was deleted.

19 changes: 0 additions & 19 deletions compiletest/tests/compile_tests.rs

This file was deleted.

1 change: 1 addition & 0 deletions src/inline_lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use self::std::sync::Once;
#[allow(deprecated)]
pub use self::std::sync::ONCE_INIT;

#[allow(dead_code)] // Used in macros
pub struct Lazy<T: Sync>(Cell<MaybeUninit<T>>, Once);

impl<T: Sync> Lazy<T> {
Expand Down
8 changes: 8 additions & 0 deletions tests/compile_fail/incorrect_visibility_restriction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#[macro_use]
extern crate lazy_static;

lazy_static! {
pub(nonsense) static ref WRONG: () = ();
}

fn main() { }
10 changes: 10 additions & 0 deletions tests/compile_fail/incorrect_visibility_restriction.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error[E0704]: incorrect visibility restriction
--> tests/compile_fail/incorrect_visibility_restriction.rs:5:9
|
5 | pub(nonsense) static ref WRONG: () = ();
| ^^^^^^^^ help: make this visible only to module `nonsense` with `in`: `in nonsense`
|
= help: some possible visibility restrictions are:
`pub(crate)`: visible only on the current crate
`pub(super)`: visible only in the current module's parent
`pub(in path::to::module)`: visible only on the specified path
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[macro_use]
extern crate lazy_static_compiletest as lazy_static;
extern crate lazy_static;

mod outer {
pub mod inner {
Expand All @@ -10,5 +10,5 @@ mod outer {
}

fn main() {
assert_eq!(*outer::inner::FOO, ()); //~ ERROR static `FOO` is private
assert_eq!(*outer::inner::FOO, ());
}
14 changes: 14 additions & 0 deletions tests/compile_fail/static_is_private.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0603]: static `FOO` is private
--> tests/compile_fail/static_is_private.rs:13:31
|
13 | assert_eq!(*outer::inner::FOO, ());
| ^^^ private static
|
note: the static `FOO` is defined here
--> tests/compile_fail/static_is_private.rs:6:9
|
6 | / lazy_static! {
7 | | pub(in outer) static ref FOO: () = ();
8 | | }
| |_________^
= note: this error originates in the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)
9 changes: 9 additions & 0 deletions tests/compile_fail/static_is_sized.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[macro_use]
extern crate lazy_static;

lazy_static! {
pub static ref FOO: str = panic!();
}


fn main() { }
Loading
Loading