mirror of
https://gitee.com/openharmony/third_party_rust_proc-macro2
synced 2024-11-23 15:29:39 +00:00
4822d05db1
error: type parameter goes unused in function definition --> tests/marker.rs:10:34 | 10 | fn assert_implemented<T: $($marker +)+>() {} | ^^^^^^^^^^^^^^^^^^ ... 42 | assert_impl!(Delimiter is Send and Sync); | ---------------------------------------- in this macro invocation | = help: consider removing the parameter = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters = note: `-D clippy::extra-unused-type-parameters` implied by `-D clippy::all` = note: this error originates in the macro `assert_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error: type parameter goes unused in function definition --> tests/marker.rs:10:34 | 10 | fn assert_implemented<T: $($marker +)+>() {} | ^^^^^^^^^^^^^^^^^^ ... 43 | assert_impl!(Spacing is Send and Sync); | -------------------------------------- in this macro invocation | = help: consider removing the parameter = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters = note: this error originates in the macro `assert_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error: type parameter goes unused in function definition --> tests/marker.rs:10:34 | 10 | fn assert_implemented<T: $($marker +)+>() {} | ^^^^^^^^^^^^^^^^^^ ... 80 | / assert_unwind_safe! { 81 | | Delimiter 82 | | Group 83 | | Ident ... | 90 | | TokenTree 91 | | } | |_____- in this macro invocation | = help: consider removing the parameter = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters = note: this error originates in the macro `assert_impl` which comes from the expansion of the macro `assert_unwind_safe` (in Nightly builds, run with -Z macro-backtrace for more info)
101 lines
2.7 KiB
Rust
101 lines
2.7 KiB
Rust
#![allow(clippy::extra_unused_type_parameters)]
|
|
|
|
use proc_macro2::{
|
|
Delimiter, Group, Ident, LexError, Literal, Punct, Spacing, Span, TokenStream, TokenTree,
|
|
};
|
|
|
|
macro_rules! assert_impl {
|
|
($ty:ident is $($marker:ident) and +) => {
|
|
#[test]
|
|
#[allow(non_snake_case)]
|
|
fn $ty() {
|
|
fn assert_implemented<T: $($marker +)+>() {}
|
|
assert_implemented::<$ty>();
|
|
}
|
|
};
|
|
|
|
($ty:ident is not $($marker:ident) or +) => {
|
|
#[test]
|
|
#[allow(non_snake_case)]
|
|
fn $ty() {
|
|
$(
|
|
{
|
|
// Implemented for types that implement $marker.
|
|
trait IsNotImplemented {
|
|
fn assert_not_implemented() {}
|
|
}
|
|
impl<T: $marker> IsNotImplemented for T {}
|
|
|
|
// Implemented for the type being tested.
|
|
trait IsImplemented {
|
|
fn assert_not_implemented() {}
|
|
}
|
|
impl IsImplemented for $ty {}
|
|
|
|
// If $ty does not implement $marker, there is no ambiguity
|
|
// in the following trait method call.
|
|
<$ty>::assert_not_implemented();
|
|
}
|
|
)+
|
|
}
|
|
};
|
|
}
|
|
|
|
assert_impl!(Delimiter is Send and Sync);
|
|
assert_impl!(Spacing is Send and Sync);
|
|
|
|
assert_impl!(Group is not Send or Sync);
|
|
assert_impl!(Ident is not Send or Sync);
|
|
assert_impl!(LexError is not Send or Sync);
|
|
assert_impl!(Literal is not Send or Sync);
|
|
assert_impl!(Punct is not Send or Sync);
|
|
assert_impl!(Span is not Send or Sync);
|
|
assert_impl!(TokenStream is not Send or Sync);
|
|
assert_impl!(TokenTree is not Send or Sync);
|
|
|
|
#[cfg(procmacro2_semver_exempt)]
|
|
mod semver_exempt {
|
|
use proc_macro2::{LineColumn, SourceFile};
|
|
|
|
assert_impl!(LineColumn is Send and Sync);
|
|
|
|
assert_impl!(SourceFile is not Send or Sync);
|
|
}
|
|
|
|
#[cfg(not(no_libprocmacro_unwind_safe))]
|
|
mod unwind_safe {
|
|
use proc_macro2::{
|
|
Delimiter, Group, Ident, LexError, Literal, Punct, Spacing, Span, TokenStream, TokenTree,
|
|
};
|
|
#[cfg(procmacro2_semver_exempt)]
|
|
use proc_macro2::{LineColumn, SourceFile};
|
|
use std::panic::{RefUnwindSafe, UnwindSafe};
|
|
|
|
macro_rules! assert_unwind_safe {
|
|
($($types:ident)*) => {
|
|
$(
|
|
assert_impl!($types is UnwindSafe and RefUnwindSafe);
|
|
)*
|
|
};
|
|
}
|
|
|
|
assert_unwind_safe! {
|
|
Delimiter
|
|
Group
|
|
Ident
|
|
LexError
|
|
Literal
|
|
Punct
|
|
Spacing
|
|
Span
|
|
TokenStream
|
|
TokenTree
|
|
}
|
|
|
|
#[cfg(procmacro2_semver_exempt)]
|
|
assert_unwind_safe! {
|
|
LineColumn
|
|
SourceFile
|
|
}
|
|
}
|