Skip to content

Commit 9b094c0

Browse files
committed
new option to note where purity is req'd
1 parent 668285b commit 9b094c0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/rustc/driver/session.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const trace: uint = 128u;
3737
const no_rt: uint = 256u;
3838
const coherence: uint = 512u;
3939
const borrowck_stats: uint = 1024u;
40+
const borrowck_note_pure: uint = 2048;
4041

4142
fn debugging_opts_map() -> ~[(str, str, uint)] {
4243
~[("ppregions", "prettyprint regions with \
@@ -51,7 +52,9 @@ fn debugging_opts_map() -> ~[(str, str, uint)] {
5152
("trace", "emit trace logs", trace),
5253
("no-rt", "do not link to the runtime", no_rt),
5354
("coherence", "perform coherence checking", coherence),
54-
("borrowck-stats", "gather borrowck statistics", borrowck_stats)
55+
("borrowck-stats", "gather borrowck statistics", borrowck_stats),
56+
("borrowck-note-pure", "note where purity is req'd",
57+
borrowck_note_pure)
5558
]
5659
}
5760

@@ -168,6 +171,7 @@ impl session for session {
168171
fn trace() -> bool { self.debugging_opt(trace) }
169172
fn coherence() -> bool { self.debugging_opt(coherence) }
170173
fn borrowck_stats() -> bool { self.debugging_opt(borrowck_stats) }
174+
fn borrowck_note_pure() -> bool { self.debugging_opt(borrowck_note_pure) }
171175
}
172176

173177
/// Some reasonable defaults

src/rustc/middle/borrowck/gather_loans.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ impl methods for gather_loan_ctxt {
246246
some(scope_id) {
247247
self.req_maps.pure_map.insert(scope_id, e);
248248
self.bccx.req_pure_paths += 1;
249+
250+
if self.tcx().sess.borrowck_note_pure() {
251+
self.bccx.span_note(
252+
cmt.span,
253+
#fmt["purity required"]);
254+
}
249255
}
250256
none {
251257
// otherwise, fine, I give up.

0 commit comments

Comments
 (0)