Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1603 from dtolnay/error
Browse files Browse the repository at this point in the history
Remove description() methods from Error trait impls
  • Loading branch information
Xanewok authored Dec 13, 2019
2 parents e4a2ba9 + 5ab73ef commit fed7a31
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
15 changes: 6 additions & 9 deletions rls-analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,18 +550,15 @@ impl ::std::fmt::Display for Id {
}
}

impl ::std::error::Error for AError {
fn description(&self) -> &str {
match *self {
AError::MutexPoison => "poison error in a mutex (usually a secondary error)",
AError::Unclassified => "unknown error",
}
}
}
impl ::std::error::Error for AError {}

impl ::std::fmt::Display for AError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "{}", ::std::error::Error::description(self))
let description = match self {
AError::MutexPoison => "poison error in a mutex (usually a secondary error)",
AError::Unclassified => "unknown error",
};
write!(f, "{}", description)
}
}

Expand Down
6 changes: 3 additions & 3 deletions rls-vfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub enum Error {
InternalError(&'static str),
}

impl ::std::error::Error for Error {
impl Error {
fn description(&self) -> &str {
match *self {
Error::OutOfSync(ref _path_buf) => "file out of sync with filesystem",
Expand All @@ -148,7 +148,7 @@ impl ::std::error::Error for Error {

impl Into<String> for Error {
fn into(self) -> String {
::std::error::Error::description(&self).to_owned()
self.description().to_owned()
}
}

Expand All @@ -166,7 +166,7 @@ impl fmt::Display for Error {
| Error::FileNotCached
| Error::NoUserDataForFile
| Error::Io(..)
| Error::BadFileKind => f.write_str(::std::error::Error::description(self)),
| Error::BadFileKind => f.write_str(self.description()),
}
}
}
Expand Down
15 changes: 6 additions & 9 deletions rls/src/lsp_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,18 @@ pub enum UrlFileParseError {
InvalidFilePath,
}

impl Error for UrlFileParseError {
fn description(&self) -> &str {
match *self {
UrlFileParseError::InvalidScheme => "URI scheme is not `file`",
UrlFileParseError::InvalidFilePath => "Invalid file path in URI",
}
}
}
impl Error for UrlFileParseError {}

impl fmt::Display for UrlFileParseError
where
UrlFileParseError: Error,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.description())
let description = match self {
UrlFileParseError::InvalidScheme => "URI scheme is not `file`",
UrlFileParseError::InvalidFilePath => "Invalid file path in URI",
};
write!(f, "{}", description)
}
}

Expand Down

0 comments on commit fed7a31

Please sign in to comment.