Skip to content

Commit

Permalink
Seal the private api Spanned trait
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 12, 2023
1 parent d8551a9 commit cd7c205
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/spanned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::ToTokens;
use proc_macro2::extra::DelimSpan;
use proc_macro2::{Span, TokenStream};

pub trait Spanned {
pub trait Spanned: private::Sealed {
fn __span(&self) -> Span;
}

Expand Down Expand Up @@ -48,3 +48,14 @@ fn join_spans(tokens: TokenStream) -> Span {
.and_then(|last| first.join(last))
.unwrap_or(first)
}

mod private {
use crate::ToTokens;
use proc_macro2::extra::DelimSpan;
use proc_macro2::Span;

pub trait Sealed {}
impl Sealed for Span {}
impl Sealed for DelimSpan {}
impl<T: ?Sized + ToTokens> Sealed for T {}
}

0 comments on commit cd7c205

Please sign in to comment.