Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [nightly, beta, stable, 1.56.0]
rust: [nightly, beta, stable, 1.65.0]
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
keywords = ["error", "error-handling", "derive"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/dtolnay/thiserror"
rust-version = "1.56"
rust-version = "1.65"

[dependencies]
thiserror-impl = { version = "=1.0.47", path = "impl" }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This library provides a convenient derive macro for the standard library's
thiserror = "1.0"
```

*Compiler support: requires rustc 1.56+*
*Compiler support: requires rustc 1.65+*

<br>

Expand Down
2 changes: 1 addition & 1 deletion impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Implementation detail of the `thiserror` crate"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/dtolnay/thiserror"
rust-version = "1.56"
rust-version = "1.65"

[lib]
proc-macro = true
Expand Down
30 changes: 17 additions & 13 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,41 @@ use std::fmt::Display;
use std::path::{self, Path, PathBuf};

#[doc(hidden)]
pub trait AsDisplay<'a> {
type Target: Display;
pub trait AsDisplay {
type Target<'a>: Display
where
Self: 'a;

fn as_display(&'a self) -> Self::Target;
fn as_display<'a>(&'a self) -> Self::Target<'a>;
}

impl<'a, T> AsDisplay<'a> for &T
impl<T> AsDisplay for &T
where
T: Display + 'a,
T: Display,
{
type Target = &'a T;
type Target<'a> = &'a T
where
Self: 'a;

fn as_display(&'a self) -> Self::Target {
fn as_display<'a>(&'a self) -> Self::Target<'a> {
*self
}
}

impl<'a> AsDisplay<'a> for Path {
type Target = path::Display<'a>;
impl AsDisplay for Path {
type Target<'a> = path::Display<'a>;

#[inline]
fn as_display(&'a self) -> Self::Target {
fn as_display<'a>(&'a self) -> Self::Target<'a> {
self.display()
}
}

impl<'a> AsDisplay<'a> for PathBuf {
type Target = path::Display<'a>;
impl AsDisplay for PathBuf {
type Target<'a> = path::Display<'a>;

#[inline]
fn as_display(&'a self) -> Self::Target {
fn as_display<'a>(&'a self) -> Self::Target<'a> {
self.display()
}
}
2 changes: 1 addition & 1 deletion tests/ui/no-display.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ error[E0599]: the method `as_display` exists for reference `&NoDisplay`, but its
|
= note: the following trait bounds were not satisfied:
`NoDisplay: std::fmt::Display`
which is required by `&NoDisplay: AsDisplay<'_>`
which is required by `&NoDisplay: AsDisplay`
note: the trait `std::fmt::Display` must be implemented
--> $RUST/core/src/fmt/mod.rs
|
Expand Down