We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 77b0d07 commit bd57b85Copy full SHA for bd57b85
compiler/rustc_builtin_macros/src/deriving/from.rs
@@ -28,12 +28,12 @@ pub(crate) fn expand_deriving_from(
28
};
29
30
// #[derive(From)] is currently usable only on structs with exactly one field.
31
- let field = match &item.kind {
32
- ItemKind::Struct(_, _, data) => match data.fields() {
33
- [field] => Some(field.clone()),
34
- _ => None,
35
- },
36
+ let field = if let ItemKind::Struct(_, _, data) = &item.kind
+ && let [field] = data.fields()
+ {
+ Some(field.clone())
+ } else {
+ None
37
38
39
let from_type = match &field {
0 commit comments