Include <cstddef> for size_t

This commit is contained in:
David Tolnay 2020-03-19 20:49:00 -07:00
parent a4dd952094
commit 30430f13c9
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
3 changed files with 9 additions and 3 deletions

View File

@ -30,6 +30,7 @@ fn find_line(line: &str) -> Option<usize> {
pub struct Includes {
custom: Vec<String>,
pub array: bool,
pub cstddef: bool,
pub cstdint: bool,
pub cstring: bool,
pub exception: bool,
@ -63,6 +64,9 @@ impl Display for Includes {
if self.array {
writeln!(f, "#include <array>")?;
}
if self.cstddef {
writeln!(f, "#include <cstddef>")?;
}
if self.cstdint {
writeln!(f, "#include <cstdint>")?;
}

View File

@ -91,10 +91,11 @@ fn write_includes(out: &mut OutFile, types: &Types) {
for ty in types {
match ty {
Type::Ident(ident) => match Atom::from(ident) {
Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(Usize) | Some(I8)
| Some(I16) | Some(I32) | Some(I64) | Some(Isize) => out.include.cstdint = true,
Some(U8) | Some(U16) | Some(U32) | Some(U64) | Some(I8) | Some(I16) | Some(I32)
| Some(I64) => out.include.cstdint = true,
Some(Usize) => out.include.cstddef = true,
Some(CxxString) => out.include.string = true,
Some(Bool) | Some(F32) | Some(F64) | Some(RustString) | None => {}
Some(Bool) | Some(Isize) | Some(F32) | Some(F64) | Some(RustString) | None => {}
},
Type::RustBox(_) => out.include.type_traits = true,
Type::UniquePtr(_) => out.include.memory = true,

View File

@ -1,5 +1,6 @@
#pragma once
#include <array>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <iosfwd>