Skip to content

Commit 12c8ee0

Browse files
committed
Hide "non-exhaustive patterns" errors when crate fails to compile
Fixes #1125. error: expected item, found `"serde_json requires that either `std` (default) or `alloc` feature is enabled"` --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.115/src/features_check/error.rs:1:1 | 1 | "serde_json requires that either `std` (default) or `alloc` feature is enabled" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected item | = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> error[E0004]: non-exhaustive patterns: `Value::String(_)` not covered --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.115/src/value/de.rs:216:15 | 216 | match self { | ^^^^ pattern `Value::String(_)` not covered | note: `Value` defined here --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.115/src/value/mod.rs:116:10 | 116 | pub enum Value { | ^^^^^ ... 151 | String(String), | ------ not covered = note: the matched value is of type `Value` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | 223 ~ Value::Object(v) => visit_object(v, visitor), 224 ~ Value::String(_) => todo!(), | error[E0004]: non-exhaustive patterns: `Cow::Owned(_)` not covered --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.115/src/value/de.rs:1338:15 | 1338 | match self.value { | ^^^^^^^^^^ pattern `Cow::Owned(_)` not covered | note: `Cow<'_, str>` defined here --> /rustc/98aa3624be70462d6a25ed5544333e3df62f4c66/library/alloc/src/borrow.rs:180:1 ::: /rustc/98aa3624be70462d6a25ed5544333e3df62f4c66/library/alloc/src/borrow.rs:190:5 | = note: not covered = note: the matched value is of type `Cow<'_, str>` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | 1339 ~ Cow::Borrowed(string) => visitor.visit_borrowed_str(string), 1340 ~ Cow::Owned(_) => todo!(), | error[E0004]: non-exhaustive patterns: `&Value::Object(_)` not covered --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.115/src/value/ser.rs:17:15 | 17 | match self { | ^^^^ pattern `&Value::Object(_)` not covered | note: `Value` defined here --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.115/src/value/mod.rs:116:10 | 116 | pub enum Value { | ^^^^^ ... 175 | Object(Map<String, Value>), | ------ not covered = note: the matched value is of type `&Value` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | 22 ~ Value::Array(v) => v.serialize(serializer), 23 ~ &Value::Object(_) => todo!(), |
1 parent 051ce97 commit 12c8ee0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/value/de.rs

+4
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ impl<'de> serde::Deserializer<'de> for Value {
219219
Value::Number(n) => n.deserialize_any(visitor),
220220
#[cfg(any(feature = "std", feature = "alloc"))]
221221
Value::String(v) => visitor.visit_string(v),
222+
#[cfg(not(any(feature = "std", feature = "alloc")))]
223+
Value::String(_) => unreachable!(),
222224
Value::Array(v) => visit_array(v, visitor),
223225
Value::Object(v) => visit_object(v, visitor),
224226
}
@@ -1339,6 +1341,8 @@ impl<'de> de::Deserializer<'de> for BorrowedCowStrDeserializer<'de> {
13391341
Cow::Borrowed(string) => visitor.visit_borrowed_str(string),
13401342
#[cfg(any(feature = "std", feature = "alloc"))]
13411343
Cow::Owned(string) => visitor.visit_string(string),
1344+
#[cfg(not(any(feature = "std", feature = "alloc")))]
1345+
Cow::Owned(_) => unreachable!(),
13421346
}
13431347
}
13441348

src/value/ser.rs

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ impl Serialize for Value {
2929
}
3030
map.end()
3131
}
32+
#[cfg(not(any(feature = "std", feature = "alloc")))]
33+
Value::Object(_) => unreachable!(),
3234
}
3335
}
3436
}

0 commit comments

Comments
 (0)