From a7c6cb73858a2659651bc0ff9dfd1cdb72239d32 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 8 Dec 2011 10:26:42 +0100 Subject: [PATCH] Consider variant constructors pure functions for the purpose of purity checking Closes #1269 --- src/comp/middle/typeck.rs | 5 +++-- src/comp/syntax/parse/lexer.rs | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index e8847b1ebbc9..614f2500cf58 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -1477,8 +1477,9 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity, } ast::pure_fn. { alt ccx.tcx.def_map.find(callee.id) { - some(ast::def_fn(_, ast::pure_fn.)) { ret; } - some(ast::def_native_fn(_, ast::pure_fn.)) { ret; } + some(ast::def_fn(_, ast::pure_fn.)) | + some(ast::def_native_fn(_, ast::pure_fn.)) | + some(ast::def_variant(_, _)) { ret; } _ { ccx.tcx.sess.span_err (sp, "pure function calls function not known to be pure"); diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs index aa35635f1787..bd841b940518 100644 --- a/src/comp/syntax/parse/lexer.rs +++ b/src/comp/syntax/parse/lexer.rs @@ -176,7 +176,6 @@ fn scan_exponent(rdr: reader) -> option::t { } fn scan_digits(rdr: reader, radix: uint) -> str { - radix; // FIXME work around issue #1265 let rslt = ""; while true { let c = rdr.curr();