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
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
21 changes: 10 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
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(RUSTC_USE_FEATURE)");
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 {
println!("cargo:rustc-cfg=RUSTC_USE_FEATURE");
}
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/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(RUSTC_USE_FEATURE, 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(RUSTC_USE_FEATURE, 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(RUSTC_USE_FEATURE, 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(RUSTC_USE_FEATURE, 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(RUSTC_USE_FEATURE)");

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=RUSTC_USE_FEATURE");
}
}
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(RUSTC_USE_FEATURE, 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(RUSTC_USE_FEATURE, feature(lint_reasons))]
#![cfg_attr(
all(
any(feature = "alloc", feature = "std"),
not(RUSTC_NEW_UNINIT_IS_STABLE)
),
all(any(feature = "alloc", feature = "std"), RUSTC_USE_FEATURE),
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(RUSTC_USE_FEATURE, 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(RUSTC_USE_FEATURE, 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(RUSTC_USE_FEATURE, feature(lint_reasons))]

use pin_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(RUSTC_USE_FEATURE, 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(RUSTC_USE_FEATURE, 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(RUSTC_USE_FEATURE, 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(RUSTC_USE_FEATURE, feature(lint_reasons))]

#[test]
#[cfg_attr(not(UI_TESTS), ignore)]
Expand Down
23 changes: 0 additions & 23 deletions tests/ui/compile-fail/pin_data/no_pin_on_phantompinned.stderr
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what's causing this change, perhaps just a new nightly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah saw it in CI today too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to fix this tomorrow on main directly.

Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,3 @@ error: The field `pin4` of type `PhantomPinned` only has an effect if it has the
|
9 | pin4: ::core::marker::PhantomPinned,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0425]: cannot find type `PhantomPinned` in this scope
--> tests/ui/compile-fail/pin_data/no_pin_on_phantompinned.rs:6:11
|
6 | pin1: PhantomPinned,
| ^^^^^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
1 + use std::marker::PhantomPinned;
|

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `marker`
--> tests/ui/compile-fail/pin_data/no_pin_on_phantompinned.rs:7:11
|
7 | pin2: marker::PhantomPinned,
| ^^^^^^ use of unresolved module or unlinked crate `marker`
|
= help: if you wanted to use a crate named `marker`, use `cargo add marker` to add it to your `Cargo.toml`
help: consider importing this module
|
1 + use std::marker;
|
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/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(RUSTC_USE_FEATURE, feature(lint_reasons))]

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

Expand Down