Stricter linting rule (#582)

This commit is contained in:
Yota Toyama
2026-09-26 01:34:38 +00:00
committed by GitHub
parent 4812241617
commit 82135e07a7
3 changed files with 74 additions and 62 deletions
+4
View File
@@ -28,3 +28,7 @@ dbg_macro = "deny"
missing_const_for_fn = "deny"
std_instead_of_alloc = "deny"
std_instead_of_core = "deny"
[lints.rust]
missing_docs = "deny"
warnings = "deny"
+65 -60
View File
@@ -1,71 +1,76 @@
//! A build script.
const LIB_ATOMIC_OPS_DIR: &str = "vendor/libatomic_ops";
const LIB_GC_DIR: &str = "vendor/bdwgc";
#[cfg(feature = "autotools")]
fn main() {
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
std::process::Command::new("sh")
.arg("-c")
.arg(format!("cd {dir} && ./autogen.sh"))
.output()
.unwrap();
cfg_select! {
feature = "cmake" => {
fn main() {
use cmake::Config;
use std::path::Path;
let libatomic_include_path = Path::new(LIB_ATOMIC_OPS_DIR)
.join("src")
.canonicalize()
.unwrap()
.display()
.to_string()
.replace(r"\\?\", "");
let dst = Config::new(LIB_GC_DIR)
.profile("Release")
.define("GC_BUILD_SHARED_LIBS", "FALSE")
.cflag(format!("-I{}", libatomic_include_path))
.build();
println!(
"cargo:rustc-link-search=native={}",
dst.join("lib").display()
);
println!("cargo:rustc-link-lib=static=gc");
}
}
feature = "autotools" => {
fn main() {
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
std::process::Command::new("sh")
.arg("-c")
.arg(format!("cd {dir} && ./autogen.sh"))
.output()
.unwrap();
}
let dst = autotools::Config::new(LIB_ATOMIC_OPS_DIR)
.cflag("-fPIC")
.build();
let dst = autotools::Config::new(LIB_ATOMIC_OPS_DIR)
.cflag("-fPIC")
.build();
println!(
"cargo:rustc-link-search=native={}",
dst.join("lib").display()
);
println!("cargo:rustc-link-lib=static=atomic_ops");
println!(
"cargo:rustc-link-search=native={}",
dst.join("lib").display()
);
println!("cargo:rustc-link-lib=static=atomic_ops");
let dst = autotools::Config::new(LIB_GC_DIR)
.cflag(format!(
// spell-checker: disable-next-line
"-I{} -L/lib/x86_64-linux-gnu -lpthread -fPIC",
dst.join("include").display()
))
.build();
let dst = autotools::Config::new(LIB_GC_DIR)
.cflag(format!(
// spell-checker: disable-next-line
"-I{} -L/lib/x86_64-linux-gnu -lpthread -fPIC",
dst.join("include").display()
))
.build();
println!(
"cargo:rustc-link-search=native={}",
dst.join("lib").display()
);
println!("cargo:rustc-link-lib=static=gc");
println!(
"cargo:rustc-link-search=native={}",
dst.join("lib").display()
);
println!("cargo:rustc-link-lib=static=gc");
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
std::process::Command::new("sh")
.arg("-c")
.arg(format!("cd {dir} && git clean -dfx"))
.output()
.unwrap();
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
std::process::Command::new("sh")
.arg("-c")
.arg(format!("cd {dir} && git clean -dfx"))
.output()
.unwrap();
}
}
}
}
#[cfg(feature = "cmake")]
fn main() {
use cmake::Config;
use std::path::Path;
let libatomic_include_path = Path::new(LIB_ATOMIC_OPS_DIR)
.join("src")
.canonicalize()
.unwrap()
.display()
.to_string()
.replace(r"\\?\", "");
let dst = Config::new(LIB_GC_DIR)
.profile("Release")
.define("GC_BUILD_SHARED_LIBS", "FALSE")
.cflag(format!("-I{}", libatomic_include_path))
.build();
println!(
"cargo:rustc-link-search=native={}",
dst.join("lib").display()
);
println!("cargo:rustc-link-lib=static=gc");
}
+5 -2
View File
@@ -3,8 +3,10 @@
mod error;
use core::alloc::{GlobalAlloc, Layout};
use core::ptr::null;
use core::{
alloc::{GlobalAlloc, Layout},
ptr::null,
};
use libc::{c_int, c_void, size_t};
const GC_SUCCESS: c_int = 0;
@@ -38,6 +40,7 @@ unsafe extern "C" {
) -> *mut c_void;
}
/// An allocator.
pub struct Allocator;
impl Allocator {