Skip to content

Commit 7a57367

Browse files
committed
replace specialization with try_as_dyn
1 parent 51820ad commit 7a57367

File tree

5 files changed

+7
-36
lines changed

5 files changed

+7
-36
lines changed

partialdebug-derive/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn gen_field_as_debug_non_exhaustive(field: &Field) -> TokenStream2 {
5252
let name = &field.ident;
5353

5454
quote! {
55-
match ::partialdebug::specialization::AsDebug::as_debug(&self. #name) {
55+
match ::core::any::try_as_dyn::<_, dyn ::core::fmt::Debug>(&self. #name) {
5656
::core::option::Option::None => {
5757
__exhaustive = false;
5858
}
@@ -213,7 +213,7 @@ fn gen_field_as_debug_placeholder(
213213
quote! {
214214
.field(
215215
#name_arg
216-
match ::partialdebug::specialization::AsDebug::as_debug(&#field_handle){
216+
match ::core::any::try_as_dyn::<_, dyn ::core::fmt::Debug>(&#field_handle){
217217
::core::option::Option::None => &::partialdebug::Placeholder(#placeholder_string),
218218
::core::option::Option::Some(__field) => __field,
219219
},

src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
//! ### Caveats
8989
//!
9090
//! Trait detection for generic types requires specialization.
91-
//! To enable specialization based trait detection use a nightly compiler and enable the `unstable` feature.
91+
//! To enable specialization based trait detection, use a nightly compiler and enable the `unstable` feature.
9292
//!
9393
//! ```
9494
//! use partialdebug::placeholder::PartialDebug;
@@ -104,8 +104,7 @@
104104
105105
#![no_std]
106106
#![warn(missing_docs, trivial_casts, rust_2018_idioms)]
107-
#![cfg_attr(feature = "unstable", allow(incomplete_features))]
108-
#![cfg_attr(feature = "unstable", feature(specialization))]
107+
#![cfg_attr(feature = "unstable", feature(try_as_dyn))]
109108

110109
use core::fmt::{Debug, Formatter, Result};
111110

@@ -124,9 +123,6 @@ impl Debug for Placeholder {
124123

125124
#[cfg(any(not(feature = "unstable"), doc))]
126125
pub mod no_specialization;
127-
/// Trait detection logic using specialization
128-
#[cfg(feature = "unstable")]
129-
pub mod specialization;
130126

131127
/// The placeholder version of `PartialDebug`
132128
pub mod placeholder {

src/specialization.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/hygiene.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![no_implicit_prelude]
22
#![no_std]
33
#![allow(dead_code)]
4+
#![cfg_attr(feature = "unstable", feature(try_as_dyn))]
45

56
use ::partialdebug;
67

tests/placeholder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(feature = "unstable", feature(try_as_dyn))]
2+
13
mod partial {
24
use partialdebug::placeholder::PartialDebug;
35

0 commit comments

Comments
 (0)