about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-07-06 15:03:18 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-07-11 14:41:41 -0700
commit9b094c0baf4fa758c80fb9db8cc172f03789adbb (patch)
tree36752b48cf96841584bdc9e237c901fe5f511d95
parent668285b9c85bebc5d1a4e8d346e99b580420be8e (diff)
downloadrust-9b094c0baf4fa758c80fb9db8cc172f03789adbb.tar.gz
rust-9b094c0baf4fa758c80fb9db8cc172f03789adbb.zip
new option to note where purity is req'd
-rw-r--r--src/rustc/driver/session.rs6
-rw-r--r--src/rustc/middle/borrowck/gather_loans.rs6
2 files changed, 11 insertions, 1 deletions
diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs
index e8014b7b661..cffec613e60 100644
--- a/src/rustc/driver/session.rs
+++ b/src/rustc/driver/session.rs
@@ -37,6 +37,7 @@ const trace: uint = 128u;
 const no_rt: uint = 256u;
 const coherence: uint = 512u;
 const borrowck_stats: uint = 1024u;
+const borrowck_note_pure: uint = 2048;
 
 fn debugging_opts_map() -> ~[(str, str, uint)] {
     ~[("ppregions", "prettyprint regions with \
@@ -51,7 +52,9 @@ fn debugging_opts_map() -> ~[(str, str, uint)] {
      ("trace", "emit trace logs", trace),
      ("no-rt", "do not link to the runtime", no_rt),
      ("coherence", "perform coherence checking", coherence),
-     ("borrowck-stats", "gather borrowck statistics",  borrowck_stats)
+     ("borrowck-stats", "gather borrowck statistics",  borrowck_stats),
+     ("borrowck-note-pure", "note where purity is req'd",
+      borrowck_note_pure)
     ]
 }
 
@@ -168,6 +171,7 @@ impl session for session {
     fn trace() -> bool { self.debugging_opt(trace) }
     fn coherence() -> bool { self.debugging_opt(coherence) }
     fn borrowck_stats() -> bool { self.debugging_opt(borrowck_stats) }
+    fn borrowck_note_pure() -> bool { self.debugging_opt(borrowck_note_pure) }
 }
 
 /// Some reasonable defaults
diff --git a/src/rustc/middle/borrowck/gather_loans.rs b/src/rustc/middle/borrowck/gather_loans.rs
index b1f31c4fd14..6a4aa98db0a 100644
--- a/src/rustc/middle/borrowck/gather_loans.rs
+++ b/src/rustc/middle/borrowck/gather_loans.rs
@@ -246,6 +246,12 @@ impl methods for gather_loan_ctxt {
                   some(scope_id) {
                     self.req_maps.pure_map.insert(scope_id, e);
                     self.bccx.req_pure_paths += 1;
+
+                    if self.tcx().sess.borrowck_note_pure() {
+                        self.bccx.span_note(
+                            cmt.span,
+                            #fmt["purity required"]);
+                    }
                   }
                   none {
                     // otherwise, fine, I give up.