Don't generate union conversion functions for object variants.

This commit is contained in:
Josh Matthews 2017-05-26 12:40:50 -04:00
parent bbb5c8436e
commit e481e8934a

View file

@ -4313,10 +4313,14 @@ class CGUnionConversionStruct(CGThing):
returnType = "Result<Option<%s>, ()>" % templateVars["typeName"]
jsConversion = templateVars["jsConversion"]
# Any code to convert to Object is unused, since we're already converting
# from an Object value.
if t.name == 'Object':
return CGGeneric('')
return CGWrapper(
CGIndenter(jsConversion, 4),
# TryConvertToObject is unused, but not generating it while generating others is tricky.
pre="#[allow(dead_code)] unsafe fn TryConvertTo%s(cx: *mut JSContext, value: HandleValue) -> %s {\n"
pre="unsafe fn TryConvertTo%s(cx: *mut JSContext, value: HandleValue) -> %s {\n"
% (t.name, returnType),
post="\n}")