Skip to content

Commit b8ff53f

Browse files
committed
---
yaml --- r: 146298 b: refs/heads/try2 c: ac311ec h: refs/heads/master v: v3
1 parent 110b70a commit b8ff53f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 25f953437d2bc3983b03c0d17cf56de40acec45b
8+
refs/heads/try2: ac311ecaab5d5a92fa86e9b201971bf92bcfbf99
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/trans/adt.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,21 +221,21 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
221221
/// For use in lint or similar, where being sound but slightly incomplete is acceptable.
222222
pub fn is_ffi_safe(tcx: ty::ctxt, def_id: ast::DefId) -> bool {
223223
match ty::get(ty::lookup_item_type(tcx, def_id).ty).sty {
224-
ty::ty_enum(def_id, ref substs) => {
225-
let cases = get_cases(tcx, def_id, substs);
224+
ty::ty_enum(def_id, _) => {
225+
let variants = ty::enum_variants(tcx, def_id);
226226
// Univariant => like struct/tuple.
227-
if cases.len() <= 2 {
227+
if variants.len() <= 1 {
228228
return true;
229229
}
230230
let hint = ty::lookup_repr_hint(tcx, def_id);
231231
// Appropriate representation explicitly selected?
232232
if hint.is_ffi_safe() {
233233
return true;
234234
}
235-
// Conservative approximation of nullable pointers, for Option<~T> etc.
236-
if cases.len() == 2 && hint == attr::ReprAny &&
237-
(cases[0].tys.is_empty() && cases[1].find_ptr().is_some() ||
238-
cases[1].tys.is_empty() && cases[0].find_ptr().is_some()) {
235+
// Option<~T> and similar are used in FFI. Rather than try to resolve type parameters
236+
// and recognize this case exactly, this overapproximates -- assuming that if a
237+
// non-C-like enum is being used in FFI then the user knows what they're doing.
238+
if variants.iter().any(|vi| !vi.args.is_empty()) {
239239
return true;
240240
}
241241
false

0 commit comments

Comments
 (0)