optimize non-capturing closure type

This commit is contained in:
Folkert 2021-11-24 23:14:53 +01:00
parent 7c2e8cd812
commit 3139e73cf9

View file

@ -1415,11 +1415,19 @@ fn constrain_closure_size(
)); ));
} }
// pick a more efficient representation if we don't actually capture anything
let closure_type = if tag_arguments.is_empty() {
Type::ClosureTag {
name,
ext: closure_ext_var,
}
} else {
let tag_name = TagName::Closure(name); let tag_name = TagName::Closure(name);
let closure_type = Type::TagUnion( Type::TagUnion(
vec![(tag_name, tag_arguments)], vec![(tag_name, tag_arguments)],
Box::new(Type::Variable(closure_ext_var)), Box::new(Type::Variable(closure_ext_var)),
); )
};
let finalizer = Eq( let finalizer = Eq(
Type::Variable(closure_var), Type::Variable(closure_var),