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

Commit fed7a31

Browse files
authored
Merge pull request #1603 from dtolnay/error
Remove description() methods from Error trait impls
2 parents e4a2ba9 + 5ab73ef commit fed7a31

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

rls-analysis/src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -550,18 +550,15 @@ impl ::std::fmt::Display for Id {
550550
}
551551
}
552552

553-
impl ::std::error::Error for AError {
554-
fn description(&self) -> &str {
555-
match *self {
556-
AError::MutexPoison => "poison error in a mutex (usually a secondary error)",
557-
AError::Unclassified => "unknown error",
558-
}
559-
}
560-
}
553+
impl ::std::error::Error for AError {}
561554

562555
impl ::std::fmt::Display for AError {
563556
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
564-
write!(f, "{}", ::std::error::Error::description(self))
557+
let description = match self {
558+
AError::MutexPoison => "poison error in a mutex (usually a secondary error)",
559+
AError::Unclassified => "unknown error",
560+
};
561+
write!(f, "{}", description)
565562
}
566563
}
567564

rls-vfs/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub enum Error {
127127
InternalError(&'static str),
128128
}
129129

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

149149
impl Into<String> for Error {
150150
fn into(self) -> String {
151-
::std::error::Error::description(&self).to_owned()
151+
self.description().to_owned()
152152
}
153153
}
154154

@@ -166,7 +166,7 @@ impl fmt::Display for Error {
166166
| Error::FileNotCached
167167
| Error::NoUserDataForFile
168168
| Error::Io(..)
169-
| Error::BadFileKind => f.write_str(::std::error::Error::description(self)),
169+
| Error::BadFileKind => f.write_str(self.description()),
170170
}
171171
}
172172
}

rls/src/lsp_data.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,18 @@ pub enum UrlFileParseError {
2525
InvalidFilePath,
2626
}
2727

28-
impl Error for UrlFileParseError {
29-
fn description(&self) -> &str {
30-
match *self {
31-
UrlFileParseError::InvalidScheme => "URI scheme is not `file`",
32-
UrlFileParseError::InvalidFilePath => "Invalid file path in URI",
33-
}
34-
}
35-
}
28+
impl Error for UrlFileParseError {}
3629

3730
impl fmt::Display for UrlFileParseError
3831
where
3932
UrlFileParseError: Error,
4033
{
4134
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42-
write!(f, "{}", self.description())
35+
let description = match self {
36+
UrlFileParseError::InvalidScheme => "URI scheme is not `file`",
37+
UrlFileParseError::InvalidFilePath => "Invalid file path in URI",
38+
};
39+
write!(f, "{}", description)
4340
}
4441
}
4542

0 commit comments

Comments
 (0)