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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ macrotest = "1.0"
prettyplease = { version = "0.2.37", features = ["verbatim"] }

[lints.rust]
stable_features = "allow"
non_ascii_idents = "deny"
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(UI_TESTS)',
Expand Down
24 changes: 13 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
use rustc_version::{version, Version};
use rustc_version::{version_meta, Channel, Version};

fn main() {
println!("cargo::rustc-check-cfg=cfg(RUSTC_LINT_REASONS_IS_STABLE)");
println!("cargo::rustc-check-cfg=cfg(RUSTC_NEW_UNINIT_IS_STABLE)");
println!("cargo::rustc-check-cfg=cfg(USE_RUSTC_FEATURES)");
println!("cargo::rustc-check-cfg=cfg(CONFIG_RUSTC_HAS_UNSAFE_PINNED)");
if version().unwrap() >= Version::parse("1.81.0").unwrap()
|| version().unwrap() >= Version::parse("1.81.0-nightly").unwrap()
{
println!("cargo:rustc-cfg=RUSTC_LINT_REASONS_IS_STABLE");
}
if version().unwrap() >= Version::parse("1.82.0").unwrap() {
println!("cargo:rustc-cfg=RUSTC_NEW_UNINIT_IS_STABLE");

let meta = version_meta().unwrap();

let use_feature = meta.channel == Channel::Nightly || std::env::var("RUSTC_BOOTSTRAP").is_ok();
if use_feature {
// Use this cfg option to control whether we should enable features that are already stable
// in some new Rust versions, but are available as unstable features in older Rust versions
// that needs to be supported by the Linux kernel.
println!("cargo:rustc-cfg=USE_RUSTC_FEATURES");
}
if version().unwrap() >= Version::parse("1.89.0-nightly").unwrap() {

if meta.semver >= Version::parse("1.89.0-nightly").unwrap() && use_feature {
println!("cargo:rustc-cfg=CONFIG_RUSTC_HAS_UNSAFE_PINNED");
}
}
2 changes: 1 addition & 1 deletion examples/big_struct_in_place.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

use pin_init::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![allow(clippy::undocumented_unsafe_blocks)]
#![cfg_attr(feature = "alloc", feature(allocator_api))]
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

use core::{
cell::Cell,
Expand Down
2 changes: 1 addition & 1 deletion examples/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![allow(clippy::undocumented_unsafe_blocks)]
#![cfg_attr(feature = "alloc", feature(allocator_api))]
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]
#![allow(clippy::missing_safety_doc)]

use core::{
Expand Down
2 changes: 1 addition & 1 deletion examples/pthread_mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// inspired by <https://github.com/nbdd0121/pin-init/blob/trunk/examples/pthread_mutex.rs>
#![allow(clippy::undocumented_unsafe_blocks)]
#![cfg_attr(feature = "alloc", feature(allocator_api))]
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

#[cfg(not(windows))]
mod pthread_mtx {
Expand Down
2 changes: 1 addition & 1 deletion examples/static_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![allow(clippy::undocumented_unsafe_blocks)]
#![cfg_attr(feature = "alloc", feature(allocator_api))]
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]
#![allow(unused_imports)]

use core::{
Expand Down
1 change: 1 addition & 0 deletions internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ syn = { version = "2.0.86", features = ["full", "parsing", "visit-mut"] }
rustc_version = "0.4"

[lints.rust]
stable_features = "allow"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kernel)'] }
14 changes: 8 additions & 6 deletions internal/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use rustc_version::{version, Version};
use rustc_version::{version_meta, Channel};

fn main() {
println!("cargo::rustc-check-cfg=cfg(RUSTC_LINT_REASONS_IS_STABLE)");
if version().unwrap() >= Version::parse("1.81.0").unwrap()
|| version().unwrap() >= Version::parse("1.81.0-nightly").unwrap()
{
println!("cargo:rustc-cfg=RUSTC_LINT_REASONS_IS_STABLE");
println!("cargo::rustc-check-cfg=cfg(USE_RUSTC_FEATURES)");

let meta = version_meta().unwrap();

let use_feature = meta.channel == Channel::Nightly || std::env::var("RUSTC_BOOTSTRAP").is_ok();
if use_feature {
println!("cargo:rustc-cfg=USE_RUSTC_FEATURES");
}
}
2 changes: 1 addition & 1 deletion internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

//! `pin-init` proc macros.

#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]
// Documentation is done in the pin-init crate instead.
#![allow(missing_docs)]

Expand Down
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,9 @@
//! [`impl Init<T, E>`]: crate::Init
//! [Rust-for-Linux]: https://rust-for-linux.com/

#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]
#![cfg_attr(
all(
any(feature = "alloc", feature = "std"),
not(RUSTC_NEW_UNINIT_IS_STABLE)
),
all(any(feature = "alloc", feature = "std"), USE_RUSTC_FEATURES),
feature(new_uninit)
)]
#![forbid(missing_docs, unsafe_op_in_unsafe_fn)]
Expand Down
2 changes: 1 addition & 1 deletion tests/alloc_fail.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(feature = "alloc", feature(allocator_api))]
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

#[test]
#[cfg(feature = "alloc")]
Expand Down
2 changes: 1 addition & 1 deletion tests/cfgs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

use pin_init::{pin_data, pin_init, PinInit};

Expand Down
2 changes: 1 addition & 1 deletion tests/const-generic-default.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

use pin_init::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/default_error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(dead_code)]
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

use pin_init::{init, Init};

Expand Down
2 changes: 1 addition & 1 deletion tests/init-scope.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(dead_code)]
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

use pin_init::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/many_generics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]
#![allow(dead_code)]

use core::{marker::PhantomPinned, pin::Pin};
Expand Down
2 changes: 1 addition & 1 deletion tests/ring_buf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(clippy::undocumented_unsafe_blocks)]
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]
#![cfg_attr(feature = "alloc", feature(allocator_api))]

#[cfg(all(not(feature = "std"), feature = "alloc"))]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

#[test]
#[cfg_attr(not(UI_TESTS), ignore)]
Expand Down
1 change: 0 additions & 1 deletion tests/ui/expand/many_generics.expanded.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![allow(dead_code)]
use core::{marker::PhantomPinned, pin::Pin};
use pin_init::*;
Expand Down
2 changes: 1 addition & 1 deletion tests/underscore.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

use pin_init::{init, Init};

Expand Down
2 changes: 1 addition & 1 deletion tests/zeroing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
#![cfg_attr(USE_RUSTC_FEATURES, feature(lint_reasons))]

use core::{marker::PhantomPinned, ptr::addr_of_mut};

Expand Down