Skip to content

Commit 4c26d70

Browse files
committed
new debug flag, new test
1 parent 6b549f9 commit 4c26d70

File tree

7 files changed

+58
-9
lines changed

7 files changed

+58
-9
lines changed

src/rustc/driver/driver.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ fn build_session_options(match: getopts::match,
400400
let sysroot_opt = getopts::opt_maybe_str(match, "sysroot");
401401
let target_opt = getopts::opt_maybe_str(match, "target");
402402
let mut no_asm_comments = getopts::opt_present(match, "no-asm-comments");
403+
let debug_rustc = getopts::opt_present(match, "debug-rustc");
403404
alt output_type {
404405
// unless we're emitting huamn-readable assembly, omit comments.
405406
link::output_type_llvm_assembly | link::output_type_assembly {}
@@ -453,7 +454,8 @@ fn build_session_options(match: getopts::match,
453454
test: test,
454455
parse_only: parse_only,
455456
no_trans: no_trans,
456-
no_asm_comments: no_asm_comments};
457+
no_asm_comments: no_asm_comments,
458+
debug_rustc: debug_rustc};
457459
ret sopts;
458460
}
459461

@@ -531,7 +533,7 @@ fn opts() -> [getopts::opt] {
531533
optmulti("cfg"), optflag("test"),
532534
optflag("lib"), optflag("bin"), optflag("static"), optflag("gc"),
533535
optflag("no-asm-comments"),
534-
optflag("enforce-mut-vars")];
536+
optflag("debug-rustc")];
535537
}
536538

537539
type output_filenames = @{out_filename: str, obj_filename:str};

src/rustc/driver/rustc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Options:
6363
(default: host triple)
6464
(see http://sources.redhat.com/autobook/autobook/
6565
autobook_17.html for detail)
66+
--debug-rustc enables different output that helps in debugging rustc,
67+
but may be less clear for normal use
6668
6769
-W <foo> enable warning <foo>
6870
-W no-<foo> disable warning <foo>

src/rustc/driver/session.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ type options =
4545
test: bool,
4646
parse_only: bool,
4747
no_trans: bool,
48-
no_asm_comments: bool};
48+
no_asm_comments: bool,
49+
debug_rustc: bool};
4950

5051
type crate_metadata = {name: str, data: [u8]};
5152

src/rustc/middle/trans/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
640640

641641
fn add_span_comment(bcx: block, sp: span, text: str) {
642642
let ccx = bcx.ccx();
643-
if (!ccx.sess.opts.no_asm_comments) {
643+
if !ccx.sess.opts.no_asm_comments {
644644
let s = text + " (" + codemap::span_to_str(sp, ccx.sess.codemap)
645645
+ ")";
646646
log(debug, s);

src/rustc/util/ppaux.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ fn region_to_str(cx: ctxt, region: region) -> str {
5050
re_scope(node_id) { #fmt["&%s", re_scope_id_to_str(cx, node_id)] }
5151
re_bound(br) { bound_region_to_str(cx, br) }
5252
re_free(id, br) {
53-
// For debugging, this version is sometimes helpful:
54-
// #fmt["{%d} %s", id, bound_region_to_str(cx, br)]
55-
56-
// But this version is what the user expects to see:
57-
bound_region_to_str(cx, br)
53+
if cx.sess.opts.debug_rustc {
54+
// For debugging, this version is sometimes helpful:
55+
#fmt["{%d} %s", id, bound_region_to_str(cx, br)]
56+
} else {
57+
// But this version is what the user expects to see:
58+
bound_region_to_str(cx, br)
59+
}
5860
}
5961

6062
// These two should not be seen by end-users (very often, anyhow):

src/rustdoc/astsrv.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ fn build_session() -> (session::session, @mut bool) {
148148
parse_only: false,
149149
no_trans: false,
150150
no_asm_comments: false,
151+
debug_rustc: false,
151152
};
152153

153154
let codemap = codemap::new_codemap();
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// xfail-test
2+
3+
fn with<T>(t: T, f: fn(T)) { f(t) }
4+
5+
fn nested(x: &x.int) { // (1)
6+
with(
7+
fn&(x: &x.int, // Refers to the region `x` at (1)
8+
y: &y.int, // A fresh region `y` (2)
9+
z: fn(x: &x.int, // Refers to `x` at (1)
10+
y: &y.int, // Refers to `y` at (2)
11+
z: &z.int) -> &z.int) // A fresh region `z` (3)
12+
-> &x.int {
13+
14+
if false { ret z(x, x, x); } //! ERROR mismatched types: expected `&y.int` but found `&x.int`
15+
if false { ret z(x, x, y); } //! ERROR mismatched types: expected `&y.int` but found `&x.int`
16+
//!^ ERROR mismatched types: expected `&x.int` but found `&y.int`
17+
if false { ret z(x, y, x); }
18+
if false { ret z(x, y, y); } //! ERROR mismatched types: expected `&x.int` but found `&y.int`
19+
if false { ret z(y, x, x); } //! ERROR mismatched types: expected `&x.int` but found `&y.int`
20+
//!^ ERROR mismatched types: expected `&y.int` but found `&x.int`
21+
if false { ret z(y, x, y); } //! ERROR mismatched types: expected `&x.int` but found `&y.int`
22+
//!^ ERROR mismatched types: expected `&y.int` but found `&x.int`
23+
//!^^ ERROR mismatched types: expected `&x.int` but found `&y.int`
24+
if false { ret z(y, y, x); } //! ERROR mismatched types: expected `&x.int` but found `&y.int`
25+
if false { ret z(y, y, y); } //! ERROR mismatched types: expected `&x.int` but found `&y.int`
26+
//!^ ERROR mismatched types: expected `&x.int` but found `&y.int`
27+
fail;
28+
}
29+
) {|f|
30+
31+
let a: &x.int = f(x, x) { |_x, _y, z| z };
32+
let b: &x.int = f(x, a) { |_x, _y, z| z };
33+
let c: &x.int = f(a, a) { |_x, _y, z| z };
34+
35+
let d: &x.int = f(x, x) { |_x, _y, z| z };
36+
let e: &x.int = f(x, &a) { |_x, _y, z| z };
37+
let f: &x.int = f(&a, &a) { |_x, _y, z| z };
38+
}
39+
}
40+
41+
fn main() {}

0 commit comments

Comments
 (0)