parser: Don't panic when finding associated constants to a primitive.

We don't handle it, but no reason to panic.

Fixes #493
This commit is contained in:
Emilio Cobos Álvarez
2020-03-21 15:06:26 +01:00
parent 17d7aad7d0
commit c265a7562a
9 changed files with 50 additions and 4 deletions
+15 -4
View File
@@ -707,11 +707,22 @@ impl Parse {
return;
}
};
if ty.is_none() {
return;
}
let impl_path = ty.unwrap().get_root_path().unwrap();
let ty = match ty {
Some(ty) => ty,
None => return,
};
let impl_path = match ty.get_root_path() {
Some(p) => p,
None => {
warn!(
"Couldn't find path for {:?}, skipping associated constants",
ty
);
return;
}
};
for item in items.into_iter() {
if let syn::Visibility::Public(_) = item.vis {
@@ -0,0 +1,4 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@@ -0,0 +1,4 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@@ -0,0 +1,4 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <new>
@@ -0,0 +1,4 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@@ -0,0 +1,4 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@@ -0,0 +1,4 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@@ -0,0 +1,4 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
+7
View File
@@ -0,0 +1,7 @@
pub trait F {
const B: u8;
}
impl F for u16 {
const B: u8 = 3;
}