about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2015-09-26 00:03:10 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2015-09-26 17:11:01 +0200
commit08181d2a3bec3484dc7d0cc7a903922f9d2a302f (patch)
tree415720c023307321bff50cf33371b3b0a30ad0a7
parent6c2e3fbe909be15cbc3a0a981950acd99360bedb (diff)
Remove warning of duplicated error code
-rw-r--r--src/librustc/middle/check_const.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs
index c6ff38d0f09..b5901762e30 100644
--- a/src/librustc/middle/check_const.rs
+++ b/src/librustc/middle/check_const.rs
@@ -709,20 +709,26 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
             if !is_const {
                 v.add_qualif(ConstQualif::NOT_CONST);
                 if v.mode != Mode::Var {
+                    fn span_limited_call_error(tcx: &ty::ctxt, span: Span, s: &str) {
+                        span_err!(tcx.sess, span, E0015, "{}", s);
+                    }
+
                     // FIXME(#24111) Remove this check when const fn stabilizes
                     if let UnstableFeatures::Disallow = v.tcx.sess.opts.unstable_features {
-                        span_err!(v.tcx.sess, e.span, E0015,
-                                  "function calls in {}s are limited to \
-                                   struct and enum constructors", v.msg());
+                        span_limited_call_error(&v.tcx, e.span,
+                                                &format!("function calls in {}s are limited to \
+                                                          struct and enum constructors",
+                                                         v.msg()));
                         v.tcx.sess.span_note(e.span,
                                              "a limited form of compile-time function \
                                               evaluation is available on a nightly \
                                               compiler via `const fn`");
                     } else {
-                        span_err!(v.tcx.sess, e.span, E0015,
-                                  "function calls in {}s are limited to \
-                                   constant functions, \
-                                   struct and enum constructors", v.msg());
+                        span_limited_call_error(&v.tcx, e.span,
+                                                &format!("function calls in {}s are limited \
+                                                          to constant functions, \
+                                                          struct and enum constructors",
+                                                         v.msg()));
                     }
                 }
             }