Skip to content

Commit 0e99f7c

Browse files
daxpeddaModProg
authored andcommitted
Account for unknown representations
1 parent 485927d commit 0e99f7c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/error.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,15 @@ impl Error {
213213
}
214214

215215
/// `repr` attribute that isn't a meta list.
216-
pub fn repr(span: Span) -> syn::Error {
216+
pub fn repr_parse(span: Span) -> syn::Error {
217217
syn::Error::new(span, "unable to parse `repr` attribute")
218218
}
219219

220+
/// Unknown `repr`.
221+
pub fn repr_unknown(span: Span) -> syn::Error {
222+
syn::Error::new(span, "found unknown representation")
223+
}
224+
220225
/// Unsupported default option if [`Default`] isn't implemented.
221226
pub fn default(span: Span) -> syn::Error {
222227
syn::Error::new(

src/item.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,12 @@ impl Discriminant {
133133
} else if let Some(repr) = Representation::parse(&ident) {
134134
has_repr = Some(repr);
135135
break;
136+
} else if ident != "Rust" && ident != "align" {
137+
return Err(Error::repr_unknown(ident.span()));
136138
}
137139
}
138140
} else {
139-
return Err(Error::repr(attr.span()));
141+
return Err(Error::repr_parse(attr.span()));
140142
}
141143
}
142144
}

0 commit comments

Comments
 (0)