about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/rustc/driver/driver.rs6
-rw-r--r--src/rustc/driver/rustc.rs2
-rw-r--r--src/rustc/driver/session.rs3
-rw-r--r--src/rustc/middle/trans/build.rs2
-rw-r--r--src/rustc/util/ppaux.rs12
-rw-r--r--src/rustdoc/astsrv.rs1
-rw-r--r--src/test/compile-fail/regions-scoping.rs41
7 files changed, 58 insertions, 9 deletions
diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs
index 20cd84d4078..178ea996ace 100644
--- a/src/rustc/driver/driver.rs
+++ b/src/rustc/driver/driver.rs
@@ -400,6 +400,7 @@ fn build_session_options(match: getopts::match,
     let sysroot_opt = getopts::opt_maybe_str(match, "sysroot");
     let target_opt = getopts::opt_maybe_str(match, "target");
     let mut no_asm_comments = getopts::opt_present(match, "no-asm-comments");
+    let debug_rustc = getopts::opt_present(match, "debug-rustc");
     alt output_type {
       // unless we're emitting huamn-readable assembly, omit comments.
       link::output_type_llvm_assembly | link::output_type_assembly {}
@@ -453,7 +454,8 @@ fn build_session_options(match: getopts::match,
           test: test,
           parse_only: parse_only,
           no_trans: no_trans,
-          no_asm_comments: no_asm_comments};
+          no_asm_comments: no_asm_comments,
+          debug_rustc: debug_rustc};
     ret sopts;
 }
 
@@ -531,7 +533,7 @@ fn opts() -> [getopts::opt] {
          optmulti("cfg"), optflag("test"),
          optflag("lib"), optflag("bin"), optflag("static"), optflag("gc"),
          optflag("no-asm-comments"),
-         optflag("enforce-mut-vars")];
+         optflag("debug-rustc")];
 }
 
 type output_filenames = @{out_filename: str, obj_filename:str};
diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs
index fd14c90f00a..216bda92fe8 100644
--- a/src/rustc/driver/rustc.rs
+++ b/src/rustc/driver/rustc.rs
@@ -63,6 +63,8 @@ Options:
                        (default: host triple)
                        (see http://sources.redhat.com/autobook/autobook/
                        autobook_17.html for detail)
+    --debug-rustc      enables different output that helps in debugging rustc,
+                       but may be less clear for normal use
 
     -W <foo>           enable warning <foo>
     -W no-<foo>        disable warning <foo>
diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs
index f452500d873..005c951c1c7 100644
--- a/src/rustc/driver/session.rs
+++ b/src/rustc/driver/session.rs
@@ -45,7 +45,8 @@ type options =
      test: bool,
      parse_only: bool,
      no_trans: bool,
-     no_asm_comments: bool};
+     no_asm_comments: bool,
+     debug_rustc: bool};
 
 type crate_metadata = {name: str, data: [u8]};
 
diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs
index 7b39f50777e..c3c816ca4b9 100644
--- a/src/rustc/middle/trans/build.rs
+++ b/src/rustc/middle/trans/build.rs
@@ -640,7 +640,7 @@ fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
 
 fn add_span_comment(bcx: block, sp: span, text: str) {
     let ccx = bcx.ccx();
-    if (!ccx.sess.opts.no_asm_comments) {
+    if !ccx.sess.opts.no_asm_comments {
         let s = text + " (" + codemap::span_to_str(sp, ccx.sess.codemap)
             + ")";
         log(debug, s);
diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs
index 6e5f19b1c60..95b5969169b 100644
--- a/src/rustc/util/ppaux.rs
+++ b/src/rustc/util/ppaux.rs
@@ -50,11 +50,13 @@ fn region_to_str(cx: ctxt, region: region) -> str {
       re_scope(node_id) { #fmt["&%s", re_scope_id_to_str(cx, node_id)] }
       re_bound(br) { bound_region_to_str(cx, br) }
       re_free(id, br) {
-        // For debugging, this version is sometimes helpful:
-        //  #fmt["{%d} %s", id, bound_region_to_str(cx, br)]
-
-        // But this version is what the user expects to see:
-        bound_region_to_str(cx, br)
+        if cx.sess.opts.debug_rustc {
+            // For debugging, this version is sometimes helpful:
+            #fmt["{%d} %s", id, bound_region_to_str(cx, br)]
+        } else {
+            // But this version is what the user expects to see:
+            bound_region_to_str(cx, br)
+        }
       }
 
       // These two should not be seen by end-users (very often, anyhow):
diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs
index d02302d5dc5..71716ea059e 100644
--- a/src/rustdoc/astsrv.rs
+++ b/src/rustdoc/astsrv.rs
@@ -148,6 +148,7 @@ fn build_session() -> (session::session, @mut bool) {
         parse_only: false,
         no_trans: false,
         no_asm_comments: false,
+        debug_rustc: false,
     };
 
     let codemap = codemap::new_codemap();
diff --git a/src/test/compile-fail/regions-scoping.rs b/src/test/compile-fail/regions-scoping.rs
new file mode 100644
index 00000000000..31a642c69fd
--- /dev/null
+++ b/src/test/compile-fail/regions-scoping.rs
@@ -0,0 +1,41 @@
+// xfail-test
+
+fn with<T>(t: T, f: fn(T)) { f(t) }
+
+fn nested(x: &x.int) {  // (1)
+    with(
+        fn&(x: &x.int, // Refers to the region `x` at (1)
+            y: &y.int, // A fresh region `y` (2)
+            z: fn(x: &x.int, // Refers to `x` at (1)
+                  y: &y.int, // Refers to `y` at (2)
+                  z: &z.int) -> &z.int) // A fresh region `z` (3)
+            -> &x.int {
+
+            if false { ret z(x, x, x); } //! ERROR mismatched types: expected `&y.int` but found `&x.int`
+            if false { ret z(x, x, y); } //! ERROR mismatched types: expected `&y.int` but found `&x.int`
+                                        //!^ ERROR mismatched types: expected `&x.int` but found `&y.int`
+            if false { ret z(x, y, x); }
+            if false { ret z(x, y, y); } //! ERROR mismatched types: expected `&x.int` but found `&y.int`
+            if false { ret z(y, x, x); } //! ERROR mismatched types: expected `&x.int` but found `&y.int`
+                                        //!^ ERROR mismatched types: expected `&y.int` but found `&x.int`
+            if false { ret z(y, x, y); } //! ERROR mismatched types: expected `&x.int` but found `&y.int`
+                                        //!^ ERROR mismatched types: expected `&y.int` but found `&x.int`
+                                       //!^^ ERROR mismatched types: expected `&x.int` but found `&y.int`
+            if false { ret z(y, y, x); } //! ERROR mismatched types: expected `&x.int` but found `&y.int`
+            if false { ret z(y, y, y); } //! ERROR mismatched types: expected `&x.int` but found `&y.int`
+                                        //!^ ERROR mismatched types: expected `&x.int` but found `&y.int`
+            fail;
+        }
+    ) {|f|
+
+        let a: &x.int = f(x, x) { |_x, _y, z| z };
+        let b: &x.int = f(x, a) { |_x, _y, z| z };
+        let c: &x.int = f(a, a) { |_x, _y, z| z };
+
+        let d: &x.int = f(x, x) { |_x, _y, z| z };
+        let e: &x.int = f(x, &a) { |_x, _y, z| z };
+        let f: &x.int = f(&a, &a) { |_x, _y, z| z };
+    }
+}
+
+fn main() {}
\ No newline at end of file