-#![deny(fallible_impl_from)]
+#![deny(clippy::fallible_impl_from)]
// docs example
struct Foo(i32);
}
}
-
struct Valid(Vec<u8>);
impl<'a> From<&'a str> for Valid {
}
}
-
struct Invalid;
impl From<usize> for Invalid {
}
}
+struct Unreachable;
+
+impl From<String> for Unreachable {
+ fn from(s: String) -> Unreachable {
+ if s.is_empty() {
+ return Unreachable;
+ }
+ match s.chars().next() {
+ Some(_) => Unreachable,
+ None => unreachable!(), // do not lint the unreachable macro
+ }
+ }
+}
+
fn main() {}