Skip to content

Commit e5d7b2c

Browse files
authored
Merge pull request #1498 from dtolnay/primitives
Generate indirect placement for shared structs containing primitives
2 parents dfecf55 + 1e10e24 commit e5d7b2c

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

Diff for: gen/src/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ mod names;
1414
mod namespace;
1515
mod nested;
1616
pub(super) mod out;
17-
mod primitive;
1817
mod write;
1918

2019
use self::cfg::UnsupportedCfgEvaluator;

Diff for: gen/src/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::gen::block::Block;
22
use crate::gen::nested::NamespaceEntries;
33
use crate::gen::out::OutFile;
4-
use crate::gen::primitive::{self, PrimitiveKind};
54
use crate::gen::{builtin, include, Opt};
65
use crate::syntax::atom::Atom::{self, *};
76
use crate::syntax::instantiate::{ImplKey, NamedImplKey};
87
use crate::syntax::map::UnorderedMap as Map;
8+
use crate::syntax::primitive::{self, PrimitiveKind};
99
use crate::syntax::set::UnorderedSet;
1010
use crate::syntax::symbol::{self, Symbol};
1111
use crate::syntax::trivial::{self, TrivialReason};

Diff for: syntax/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mod names;
1919
pub(crate) mod namespace;
2020
mod parse;
2121
mod pod;
22+
pub(crate) mod primitive;
2223
pub(crate) mod qualified;
2324
pub(crate) mod report;
2425
pub(crate) mod resolve;

Diff for: syntax/pod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::syntax::atom::Atom::{self, *};
2-
use crate::syntax::{derive, Trait, Type, Types};
2+
use crate::syntax::{primitive, Type, Types};
33

44
impl<'a> Types<'a> {
55
pub(crate) fn is_guaranteed_pod(&self, ty: &Type) -> bool {
@@ -13,11 +13,9 @@ impl<'a> Types<'a> {
1313
CxxString | RustString => false,
1414
}
1515
} else if let Some(strct) = self.structs.get(ident) {
16-
derive::contains(&strct.derives, Trait::Copy)
17-
|| strct
18-
.fields
19-
.iter()
20-
.all(|field| self.is_guaranteed_pod(&field.ty))
16+
strct.fields.iter().all(|field| {
17+
primitive::kind(&field.ty).is_none() && self.is_guaranteed_pod(&field.ty)
18+
})
2119
} else {
2220
self.enums.contains_key(ident)
2321
}
File renamed without changes.

0 commit comments

Comments
 (0)