about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2016-08-06 15:01:21 +0300
committerGitHub <noreply@github.com>2016-08-06 15:01:21 +0300
commita7b7417c281e14122722c2fd0e7dbb2be6aabcd0 (patch)
tree623a79a63c43318f93423d720365ac41b58f88f3
parentc846c30584796f8a97b6a371f1872c63cc13770c (diff)
parent764d5cfafb30acbe3fdb45b6c98b4e694a303558 (diff)
downloadrust-a7b7417c281e14122722c2fd0e7dbb2be6aabcd0.tar.gz
rust-a7b7417c281e14122722c2fd0e7dbb2be6aabcd0.zip
Rollup merge of #35364 - kc1212:e0379, r=jonathandturner
Update E0379 to new format #35338

Fixes #35338, as part of #35233.

But this does not include the bonus. From my understanding a Span is defined by a `hi` and a `lo` position within some context. A naive way would be to mutate the span so that `hi` is 5 positions from `lo` which corresponds to the `const` keyword. But this methods feels a bit rigid. Is there another way to do this?

r? @jonathandturner
-rw-r--r--src/librustc_typeck/check/mod.rs4
-rw-r--r--src/test/compile-fail/const-fn-mismatch.rs4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index fde6f84a651..30b2f43153e 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -847,7 +847,9 @@ fn check_trait_fn_not_const<'a,'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
             // good
         }
         hir::Constness::Const => {
-            span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const");
+            struct_span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const")
+                .span_label(span, &format!("trait fns cannot be const"))
+                .emit()
         }
     }
 }
diff --git a/src/test/compile-fail/const-fn-mismatch.rs b/src/test/compile-fail/const-fn-mismatch.rs
index d813cf32954..92568b27f7c 100644
--- a/src/test/compile-fail/const-fn-mismatch.rs
+++ b/src/test/compile-fail/const-fn-mismatch.rs
@@ -20,7 +20,9 @@ trait Foo {
 }
 
 impl Foo for u32 {
-    const fn f() -> u32 { 22 } //~ ERROR E0379
+    const fn f() -> u32 { 22 }
+    //~^ ERROR E0379
+    //~| NOTE trait fns cannot be const
 }
 
 fn main() { }