Skip to content

Commit

Permalink
Work around ridiculous rust-analyzer behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 17, 2023
1 parent 5ada5d5 commit 2d9425c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/aserror.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::error::Error;
use std::panic::UnwindSafe;

#[doc(hidden)]
pub trait AsDynError<'a>: Sealed {
fn as_dyn_error(&self) -> &(dyn Error + 'a);
}
Expand Down Expand Up @@ -40,6 +41,7 @@ impl<'a> AsDynError<'a> for dyn Error + Send + Sync + UnwindSafe + 'a {
}
}

#[doc(hidden)]
pub trait Sealed {}
impl<'a, T: Error + 'a> Sealed for T {}
impl<'a> Sealed for dyn Error + 'a {}
Expand Down
2 changes: 2 additions & 0 deletions src/display.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::fmt::Display;
use std::path::{self, Path, PathBuf};

#[doc(hidden)]
pub trait DisplayAsDisplay {
fn as_display(&self) -> Self;
}
Expand All @@ -11,6 +12,7 @@ impl<T: Display> DisplayAsDisplay for &T {
}
}

#[doc(hidden)]
pub trait PathAsDisplay {
fn as_display(&self) -> path::Display<'_>;
}
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,11 @@ pub use thiserror_impl::*;
// Not public API.
#[doc(hidden)]
pub mod __private {
#[doc(hidden)]
pub use crate::aserror::AsDynError;
#[doc(hidden)]
pub use crate::display::{DisplayAsDisplay, PathAsDisplay};
#[cfg(error_generic_member_access)]
#[doc(hidden)]
pub use crate::provide::ThiserrorProvide;
}
2 changes: 2 additions & 0 deletions src/provide.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::error::{Error, Request};

#[doc(hidden)]
pub trait ThiserrorProvide: Sealed {
fn thiserror_provide<'a>(&'a self, request: &mut Request<'a>);
}
Expand All @@ -14,5 +15,6 @@ where
}
}

#[doc(hidden)]
pub trait Sealed {}
impl<T: Error + ?Sized> Sealed for T {}

0 comments on commit 2d9425c

Please sign in to comment.