Skip to content

Commit 25d6017

Browse files
committed
Don't consider references to nullary tag variants lvals in kind.rs
This allows us to express option::map with noncopyable type parameters, which makes sense, since the type params aren't being copied (none doesn't contain any).
1 parent b9bb58f commit 25d6017

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/comp/middle/kind.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,24 @@ fn maybe_copy(cx: ctx, ex: @expr) {
215215
check_copy_ex(cx, ex, true);
216216
}
217217

218+
fn is_nullary_variant(cx: ctx, ex: @expr) -> bool {
219+
alt ex.node {
220+
expr_path(_) {
221+
alt cx.tcx.def_map.get(ex.id) {
222+
def_variant(edid, vdid) {
223+
vec::len(ty::enum_variant_with_id(cx.tcx, edid, vdid).args) == 0u
224+
}
225+
_ { false }
226+
}
227+
}
228+
_ { false }
229+
}
230+
}
231+
218232
fn check_copy_ex(cx: ctx, ex: @expr, _warn: bool) {
219233
if ty::expr_is_lval(cx.method_map, ex) &&
220-
!cx.last_uses.contains_key(ex.id) {
234+
!cx.last_uses.contains_key(ex.id) &&
235+
!is_nullary_variant(cx, ex) {
221236
let ty = ty::expr_ty(cx.tcx, ex);
222237
check_copy(cx, ty, ex.span);
223238
// FIXME turn this on again once vector types are no longer unique.

0 commit comments

Comments
 (0)