Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 6dd9867

Browse files
committed
Remove need for ErrorKind in links {}.
Closes #32.
1 parent fc8c53e commit 6dd9867

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@
135135
//! //
136136
//! // This section can be empty.
137137
//! links {
138-
//! ::rustup_dist::Error, rustup_dist::ErrorKind, Dist;
139-
//! ::rustup_utils::Error, rustup_utils::ErrorKind, Utils, #[cfg(unix)];
138+
//! ::rustup_dist::Error, Dist;
139+
//! ::rustup_utils::Error, Utils, #[cfg(unix)];
140140
//! }
141141
//!
142142
//! // Automatic conversions between this error chain and other
@@ -334,7 +334,7 @@ macro_rules! error_chain {
334334
}
335335

336336
links {
337-
$( $link_error_path:path, $link_kind_path:path, $link_variant:ident $(, #[$meta_links:meta])*; ) *
337+
$( $link_error_path:path, $link_variant:ident $(, #[$meta_links:meta])*; ) *
338338
}
339339

340340
foreign_links {
@@ -457,7 +457,7 @@ macro_rules! error_chain {
457457

458458
$(
459459
$(#[$meta_links])*
460-
$link_variant(e: $link_kind_path) {
460+
$link_variant(e: <$link_error_path as $crate::Error>::ErrorKind) {
461461
description(e.description())
462462
display("{}", e)
463463
}
@@ -477,8 +477,8 @@ macro_rules! error_chain {
477477

478478
$(
479479
$(#[$meta_links])*
480-
impl From<$link_kind_path> for $error_kind_name {
481-
fn from(e: $link_kind_path) -> Self {
480+
impl From<<$link_error_path as $crate::Error>::ErrorKind> for $error_kind_name {
481+
fn from(e: <$link_error_path as $crate::Error>::ErrorKind) -> Self {
482482
$error_kind_name::$link_variant(e)
483483
}
484484
}

tests/tests.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,19 @@ fn chain_err() {
166166
let _: Result<()> = Err("".into()).chain_err(|| "");
167167
}
168168

169+
#[test]
170+
fn links() {
171+
mod test {
172+
error_chain! {}
173+
}
174+
175+
error_chain! {
176+
links {
177+
test::Error, Test;
178+
}
179+
}
180+
}
181+
169182
#[cfg(test)]
170183
mod foreign_link_test {
171184

@@ -277,11 +290,11 @@ mod attributes_test {
277290

278291
error_chain! {
279292
types {
280-
Error, ErrorKind, ErrorChain, Result;
293+
Error, ErrorKind, Result;
281294
}
282295

283296
links {
284-
inner::Error, inner::ErrorKind, Inner, #[cfg(not(test))];
297+
inner::Error, Inner, #[cfg(not(test))];
285298
}
286299

287300
foreign_links {

0 commit comments

Comments
 (0)