]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #15705 : klutzy/rust/cross-ld-library, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 17 Jul 2014 15:36:23 +0000 (15:36 +0000)
committerbors <bors@rust-lang.org>
Thu, 17 Jul 2014 15:36:23 +0000 (15:36 +0000)
183 files changed:
src/compiletest/compiletest.rs
src/compiletest/runtest.rs
src/doc/guide.md
src/doc/intro.md
src/doc/tutorial.md
src/etc/lldb_batchmode.py
src/etc/lldb_rust_formatters.py [new file with mode: 0644]
src/etc/vim/doc/rust.txt
src/etc/vim/ftplugin/rust.vim
src/etc/vim/syntax/rust.vim
src/libcollections/treemap.rs
src/libcollections/vec.rs
src/libdebug/repr.rs
src/libgetopts/lib.rs
src/libglob/lib.rs
src/libgraphviz/lib.rs
src/libregex/parse.rs
src/libregex/re.rs
src/libregex/vm.rs
src/librustc/back/link.rs
src/librustc/driver/config.rs
src/librustc/metadata/csearch.rs
src/librustc/metadata/decoder.rs
src/librustc/metadata/encoder.rs
src/librustc/middle/astencode.rs
src/librustc/middle/borrowck/check_loans.rs
src/librustc/middle/borrowck/gather_loans/gather_moves.rs
src/librustc/middle/borrowck/gather_loans/lifetime.rs
src/librustc/middle/borrowck/gather_loans/move_error.rs
src/librustc/middle/borrowck/gather_loans/restrictions.rs
src/librustc/middle/dead.rs
src/librustc/middle/def.rs
src/librustc/middle/effect.rs
src/librustc/middle/kind.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/privacy.rs
src/librustc/middle/reachable.rs
src/librustc/middle/region.rs
src/librustc/middle/resolve.rs
src/librustc/middle/save/mod.rs
src/librustc/middle/subst.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/inline.rs
src/librustc/middle/trans/meth.rs
src/librustc/middle/trans/monomorphize.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/check/_match.rs
src/librustc/middle/typeck/check/method.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/collect.rs
src/librustc/middle/typeck/infer/combine.rs
src/librustc/middle/typeck/infer/error_reporting.rs
src/librustc/middle/typeck/infer/region_inference/mod.rs
src/librustc/middle/typeck/variance.rs
src/librustc/util/ppaux.rs
src/librustdoc/clean/mod.rs
src/librustdoc/html/format.rs
src/librustdoc/html/render.rs
src/librustdoc/lib.rs
src/librustdoc/markdown.rs
src/librustdoc/passes.rs
src/libserialize/json.rs
src/libstd/collections/hashmap.rs
src/libsync/mpmc_bounded_queue.rs
src/libsync/raw.rs
src/libsyntax/ast.rs
src/libsyntax/ast_map/blocks.rs
src/libsyntax/ast_util.rs
src/libsyntax/ext/deriving/generic/ty.rs
src/libsyntax/fold.rs
src/libsyntax/owned_slice.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/libsyntax/visit.rs
src/libterm/terminfo/parm.rs
src/libtest/lib.rs
src/libtest/stats.rs
src/libuuid/lib.rs
src/test/compile-fail-fulldeps/macro-crate-rlib.rs
src/test/compile-fail/borrowck-overloaded-index-2.rs [new file with mode: 0644]
src/test/compile-fail/borrowck-overloaded-index.rs
src/test/compile-fail/explicit-self-lifetime-mismatch.rs [new file with mode: 0644]
src/test/compile-fail/issue-5153.rs
src/test/compile-fail/lint-unused-mut-self.rs
src/test/compile-fail/object-pointer-types.rs
src/test/compile-fail/ufcs-explicit-self-bad.rs [new file with mode: 0644]
src/test/compile-fail/unsafe-destructor-check-crash.rs [new file with mode: 0644]
src/test/debuginfo/basic-types.rs
src/test/debuginfo/borrowed-basic.rs
src/test/debuginfo/borrowed-c-style-enum.rs
src/test/debuginfo/borrowed-enum.rs
src/test/debuginfo/borrowed-managed-basic.rs
src/test/debuginfo/borrowed-struct.rs
src/test/debuginfo/borrowed-tuple.rs
src/test/debuginfo/borrowed-unique-basic.rs
src/test/debuginfo/box.rs
src/test/debuginfo/boxed-struct.rs
src/test/debuginfo/by-value-non-immediate-argument.rs
src/test/debuginfo/by-value-self-argument-in-trait-impl.rs
src/test/debuginfo/c-style-enum-in-composite.rs
src/test/debuginfo/c-style-enum.rs
src/test/debuginfo/closure-in-generic-function.rs
src/test/debuginfo/destructured-fn-argument.rs
src/test/debuginfo/destructured-local.rs
src/test/debuginfo/evec-in-struct.rs
src/test/debuginfo/function-arg-initialization.rs
src/test/debuginfo/function-arguments.rs
src/test/debuginfo/function-prologue-stepping-no-split-stack.rs
src/test/debuginfo/function-prologue-stepping-regular.rs [new file with mode: 0644]
src/test/debuginfo/generic-function.rs
src/test/debuginfo/generic-functions-nested.rs
src/test/debuginfo/generic-method-on-generic-struct.rs
src/test/debuginfo/generic-struct.rs
src/test/debuginfo/generic-tuple-style-enum.rs
src/test/debuginfo/include_string.rs
src/test/debuginfo/lexical-scope-in-for-loop.rs
src/test/debuginfo/lexical-scope-in-if.rs
src/test/debuginfo/lexical-scope-in-match.rs
src/test/debuginfo/lexical-scope-in-stack-closure.rs
src/test/debuginfo/lexical-scope-in-unconditional-loop.rs
src/test/debuginfo/lexical-scope-in-unique-closure.rs
src/test/debuginfo/lexical-scope-in-while.rs
src/test/debuginfo/lexical-scope-with-macro.rs
src/test/debuginfo/lexical-scopes-in-block-expression.rs
src/test/debuginfo/limited-debuginfo.rs
src/test/debuginfo/managed-enum.rs
src/test/debuginfo/managed-pointer-within-unique-vec.rs
src/test/debuginfo/managed-pointer-within-unique.rs
src/test/debuginfo/method-on-enum.rs
src/test/debuginfo/method-on-generic-struct.rs
src/test/debuginfo/method-on-struct.rs
src/test/debuginfo/method-on-trait.rs
src/test/debuginfo/method-on-tuple-struct.rs
src/test/debuginfo/multiple-functions-equal-var-names.rs
src/test/debuginfo/multiple-functions.rs
src/test/debuginfo/name-shadowing-and-scope-nesting.rs
src/test/debuginfo/nil-enum.rs
src/test/debuginfo/option-like-enum.rs
src/test/debuginfo/packed-struct-with-destructor.rs
src/test/debuginfo/packed-struct.rs
src/test/debuginfo/recursive-enum.rs
src/test/debuginfo/recursive-struct.rs
src/test/debuginfo/self-in-default-method.rs
src/test/debuginfo/self-in-generic-default-method.rs
src/test/debuginfo/shadowed-argument.rs
src/test/debuginfo/shadowed-variable.rs
src/test/debuginfo/simd.rs
src/test/debuginfo/simple-lexical-scope.rs
src/test/debuginfo/simple-struct.rs
src/test/debuginfo/simple-tuple.rs
src/test/debuginfo/static-method-on-struct-and-enum.rs
src/test/debuginfo/struct-in-enum.rs
src/test/debuginfo/struct-in-struct.rs
src/test/debuginfo/struct-style-enum.rs
src/test/debuginfo/struct-with-destructor.rs
src/test/debuginfo/text-to-include-1.txt
src/test/debuginfo/text-to-include-2.txt
src/test/debuginfo/text-to-include-3.txt
src/test/debuginfo/trait-generic-static-default-method.rs
src/test/debuginfo/trait-pointers.rs
src/test/debuginfo/tuple-in-tuple.rs
src/test/debuginfo/tuple-struct.rs
src/test/debuginfo/tuple-style-enum.rs
src/test/debuginfo/unique-enum.rs
src/test/debuginfo/var-captured-in-nested-closure.rs
src/test/debuginfo/var-captured-in-sendable-closure.rs
src/test/debuginfo/var-captured-in-stack-closure.rs
src/test/debuginfo/vec-slices.rs
src/test/debuginfo/vec.rs
src/test/run-pass/autoderef-method-on-trait.rs
src/test/run-pass/autoderef-method-twice-but-not-thrice.rs
src/test/run-pass/autoderef-method-twice.rs
src/test/run-pass/autoderef-method.rs
src/test/run-pass/explicit-self-objects-uniq.rs
src/test/run-pass/explicit-self.rs
src/test/run-pass/issue-7320.rs
src/test/run-pass/objects-owned-object-owned-method.rs
src/test/run-pass/self-in-mut-slot-default-method.rs
src/test/run-pass/ufcs-explicit-self.rs [new file with mode: 0644]
src/test/run-pass/uniq-self-in-mut-slot.rs

index 4de66d8746fbea72f45206832e1ef93c56a2ba9e..583d9249b35476a72f59346dac2e8f544e94f1e5 100644 (file)
@@ -30,7 +30,7 @@
 use std::from_str::FromStr;
 use getopts::{optopt, optflag, reqopt};
 use common::Config;
-use common::{Pretty, DebugInfoGdb, Codegen};
+use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Codegen};
 use util::logv;
 use regex::Regex;
 
@@ -89,9 +89,9 @@ pub fn parse_config(args: Vec<String> ) -> Config {
           optflag("h", "help", "show this message"));
 
     assert!(!args.is_empty());
-    let argv0 = (*args.get(0)).clone();
+    let argv0 = args[0].clone();
     let args_ = args.tail();
-    if args.get(1).as_slice() == "-h" || args.get(1).as_slice() == "--help" {
+    if args[1].as_slice() == "-h" || args[1].as_slice() == "--help" {
         let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
         println!("{}", getopts::usage(message.as_slice(), groups.as_slice()));
         println!("");
@@ -116,7 +116,7 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
     }
 
     let filter = if !matches.free.is_empty() {
-        let s = matches.free.get(0).as_slice();
+        let s = matches.free[0].as_slice();
         match regex::Regex::new(s) {
             Ok(re) => Some(re),
             Err(e) => {
@@ -241,6 +241,16 @@ pub fn run_tests(config: &Config) {
         os::setenv("RUST_TEST_TASKS","1");
     }
 
+    match config.mode {
+        DebugInfoLldb => {
+            // Some older versions of LLDB seem to have problems with multiple
+            // instances running in parallel, so only run one test task at a
+            // time.
+            os::setenv("RUST_TEST_TASKS", "1");
+        }
+        _ => { /* proceed */ }
+    }
+
     let opts = test_opts(config);
     let tests = make_tests(config);
     // sadly osx needs some file descriptor limits raised for running tests in
index 0c325a0d65aef660e8f891bce0868885afc34b46..c3ac40e8f08d41d03238ec3ad3e0017203460e37 100644 (file)
@@ -167,7 +167,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
         let proc_res = print_source(config,
                                     props,
                                     testfile,
-                                    (*srcs.get(round)).to_string(),
+                                    srcs[round].to_string(),
                                     "normal");
 
         if !proc_res.status.success() {
@@ -187,9 +187,9 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
             let s = File::open(&filepath).read_to_end().unwrap();
             String::from_utf8(s).unwrap()
         }
-        None => { (*srcs.get(srcs.len() - 2u)).clone() }
+        None => { srcs[srcs.len() - 2u].clone() }
     };
-    let mut actual = (*srcs.get(srcs.len() - 1u)).clone();
+    let mut actual = srcs[srcs.len() - 1u].clone();
 
     if props.pp_exact.is_some() {
         // Now we have to care about line endings
@@ -209,7 +209,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
     if props.no_pretty_expanded { return }
 
     // additionally, run `--pretty expanded` and try to build it.
-    let proc_res = print_source(config, props, testfile, (*srcs.get(round)).clone(), "expanded");
+    let proc_res = print_source(config, props, testfile, srcs[round].clone(), "expanded");
     if !proc_res.status.success() {
         fatal_proc_rec("pretty-printing (expanded) failed", &proc_res);
     }
@@ -536,6 +536,16 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
     // We don't want to hang when calling `quit` while the process is still running
     let mut script_str = String::from_str("settings set auto-confirm true\n");
 
+    // Make LLDB emit its version, so we have it documented in the test output
+    script_str.push_str("version\n");
+
+    // Switch LLDB into "Rust mode"
+    script_str.push_str("command script import ./src/etc/lldb_rust_formatters.py\n");
+    script_str.push_str("type summary add --no-value ");
+    script_str.push_str("--python-function lldb_rust_formatters.print_val ");
+    script_str.push_str("-x \".*\" --category Rust\n");
+    script_str.push_str("type category enable Rust\n");
+
     // Set breakpoints on every line that contains the string "#break"
     for line in breakpoint_lines.iter() {
         script_str.push_str(format!("breakpoint set --line {}\n",
@@ -692,7 +702,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
             let mut rest = line.trim();
             let mut first = true;
             let mut failed = false;
-            for frag in check_fragments.get(i).iter() {
+            for frag in check_fragments[i].iter() {
                 let found = if first {
                     if rest.starts_with(frag.as_slice()) {
                         Some(0)
@@ -742,7 +752,7 @@ fn check_error_patterns(props: &TestProps,
     }
 
     let mut next_err_idx = 0u;
-    let mut next_err_pat = props.error_patterns.get(next_err_idx);
+    let mut next_err_pat = &props.error_patterns[next_err_idx];
     let mut done = false;
     let output_to_check = if props.check_stdout {
         format!("{}{}", proc_res.stdout, proc_res.stderr)
@@ -751,14 +761,14 @@ fn check_error_patterns(props: &TestProps,
     };
     for line in output_to_check.as_slice().lines() {
         if line.contains(next_err_pat.as_slice()) {
-            debug!("found error pattern {}", *next_err_pat);
+            debug!("found error pattern {}", next_err_pat);
             next_err_idx += 1u;
             if next_err_idx == props.error_patterns.len() {
                 debug!("found all error patterns");
                 done = true;
                 break;
             }
-            next_err_pat = props.error_patterns.get(next_err_idx);
+            next_err_pat = &props.error_patterns[next_err_idx];
         }
     }
     if done { return; }
@@ -837,13 +847,13 @@ fn prefix_matches( line : &str, prefix : &str ) -> bool {
     for line in proc_res.stderr.as_slice().lines() {
         let mut was_expected = false;
         for (i, ee) in expected_errors.iter().enumerate() {
-            if !*found_flags.get(i) {
+            if !found_flags[i] {
                 debug!("prefix={} ee.kind={} ee.msg={} line={}",
-                       prefixes.get(i).as_slice(),
+                       prefixes[i].as_slice(),
                        ee.kind,
                        ee.msg,
                        line);
-                if prefix_matches(line, prefixes.get(i).as_slice()) &&
+                if prefix_matches(line, prefixes[i].as_slice()) &&
                     line.contains(ee.kind.as_slice()) &&
                     line.contains(ee.msg.as_slice()) {
                     *found_flags.get_mut(i) = true;
@@ -867,7 +877,7 @@ fn prefix_matches( line : &str, prefix : &str ) -> bool {
 
     for (i, &flag) in found_flags.iter().enumerate() {
         if !flag {
-            let ee = expected_errors.get(i);
+            let ee = &expected_errors[i];
             fatal_proc_rec(format!("expected {} on line {} not found: {}",
                                   ee.kind, ee.line, ee.msg).as_slice(),
                           proc_res);
index 1f3aae90aa153604c796f2e89927b2455a41f28c..b05d0e8ea350e9fe07bdf40f096a250d7795e52a 100644 (file)
@@ -279,59 +279,12 @@ program doesn't have any dependencies, so we'll only be using the first part of
 its functionality. Eventually, we'll add more. Since we started off by using
 Cargo, it'll be easy to add later.
 
-Let's convert Hello World to Cargo. The first thing we need to do to begin using Cargo
-is to install Cargo. To do this, we need to build it from source. There are no binaries
-yet.
-
-First, let's go back to our projects directory. We don't want Cargo to
-live in our project!
-
-```{bash}
-$ cd ..
-```
-
-Next, we need these commands:
-
-```{bash}
-$ git clone --recursive https://github.com/rust-lang/cargo
-$ cd cargo
-$ make
-$ make install # may need sudo or admin permissions
-```
-
-The `--recursive` downloads Cargo's own dependencies. You can't use Cargo to
-fetch dependencies until you have Cargo installed! Also, you will need to have
-`git` installed. Much of the Rust world assumes `git` usage, so it's a good
-thing to have around. Please check out [the git
-documentation](http://git-scm.com/book/en/Getting-Started-Installing-Git) for
-more on installing `git`.
-
-We hope to give Cargo a binary installer, similar to Rust's own, so that
-this will not be necessary in the future.
-
-Let's see if that worked. Try this:
-
-```{bash}
-$ cargo
-Commands:
-  build          # compile the current project
-
-Options (for all commands):
-
--v, [--verbose]
--h, [--help]
-```
-
-If you see this output when you run `cargo`, congrats! Cargo is working. If
-not, please [open an issue](https://github.com/rust-lang/cargo/issues/new) or
-drop by the Rust IRC, and we can help you out.
-
-Let's move back into our `hello_world` directory now:
-
-```{bash}
-$ cd ..              # move back up into projects
-$ cd hello_world     # move into hello_world
-```
+Let's convert Hello World to Cargo. The first thing we need to do to begin
+using Cargo is to install Cargo. Luckily for us, the script we ran to install
+Rust includes Cargo by default. If you installed Rust some other way, you may
+want to [check the Cargo
+README](https://github.com/rust-lang/cargo#installing-cargo-from-nightlies)
+for specific instructions about installing it.
 
 To Cargo-ify our project, we need to do two things: Make a `Cargo.toml`
 configuration file, and put our source file in the right place. Let's
index e8928cb55056c519d65faa4d65d8c220eba5fd46..7dcf8486181ed2bf064136e0e5e3b5614b70ffa1 100644 (file)
@@ -205,7 +205,7 @@ fn main() {
 
     spawn(proc() {
         let numbers = rx.recv();
-        println!("{}", *numbers.get(0));
+        println!("{}", numbers[0]);
     })
 }
 ```
@@ -244,11 +244,11 @@ fn main() {
 
     spawn(proc() {
         let numbers = rx.recv();
-        println!("{}", numbers.get(0));
+        println!("{}", numbers[0]);
     });
 
     // Try to print a number from the original task
-    println!("{}", *numbers.get(0));
+    println!("{}", numbers[0]);
 }
 ```
 
@@ -256,7 +256,7 @@ The compiler will produce an error indicating that the value is no longer in sco
 
 ```text
 concurrency.rs:12:20: 12:27 error: use of moved value: 'numbers'
-concurrency.rs:12     println!("{}", numbers.get(0));
+concurrency.rs:12     println!("{}", numbers[0]);
                                      ^~~~~~~
 ```
 
@@ -276,7 +276,7 @@ fn main() {
 
         spawn(proc() {
             let numbers = rx.recv();
-            println!("{:d}", *numbers.get(num as uint));
+            println!("{:d}", numbers[num as uint]);
         })
     }
 }
@@ -309,7 +309,7 @@ fn main() {
 
         spawn(proc() {
             let numbers = rx.recv();
-            println!("{:d}", *numbers.get(num as uint));
+            println!("{:d}", (*numbers)[num as uint]);
         })
     }
 }
@@ -364,7 +364,7 @@ fn main() {
             // See: https://github.com/rust-lang/rust/issues/6515
             *numbers.get_mut(num as uint) = *numbers.get_mut(num as uint) + 1;
 
-            println!("{}", *numbers.get(num as uint));
+            println!("{}", (*numbers)[num as uint]);
 
             // When `numbers` goes out of scope the lock is dropped
         })
index 10f67876e508fc34137c20bbce97cf67fa9a17d3..e0f0bbd6c9f2ba02797b2edf8044afe8470c361b 100644 (file)
@@ -2427,7 +2427,7 @@ as in this version of `print_all` that copies elements.
 fn print_all<T: Printable + Clone>(printable_things: Vec<T>) {
     let mut i = 0;
     while i < printable_things.len() {
-        let copy_of_thing = printable_things.get(i).clone();
+        let copy_of_thing = printable_things[i].clone();
         copy_of_thing.print();
         i += 1;
     }
index 85bfc425b587d2e37022e4a0fd21433eeacf911e..06bd2a13d22cd827cdb67ea8db53e833bcdd6a9a 100644 (file)
@@ -31,9 +31,6 @@ import threading
 import re
 import atexit
 
-# Terminate the debugger
-atexit.register(lambda: lldb.SBDebugger.Terminate())
-
 # Set this to True for additional output
 DEBUG_OUTPUT = False
 
diff --git a/src/etc/lldb_rust_formatters.py b/src/etc/lldb_rust_formatters.py
new file mode 100644 (file)
index 0000000..aa22301
--- /dev/null
@@ -0,0 +1,232 @@
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+import lldb
+
+def print_val(val, internal_dict):
+  '''Prints the given value with Rust syntax'''
+  type_class = val.GetType().GetTypeClass()
+
+  if type_class == lldb.eTypeClassStruct:
+    return print_struct_val(val, internal_dict)
+
+  if type_class == lldb.eTypeClassUnion:
+    return print_enum_val(val, internal_dict)
+
+  if type_class == lldb.eTypeClassPointer:
+    return print_pointer_val(val, internal_dict)
+
+  if type_class == lldb.eTypeClassArray:
+    return print_fixed_size_vec_val(val, internal_dict)
+
+  return val.GetValue()
+
+
+#=--------------------------------------------------------------------------------------------------
+# Type-Specialized Printing Functions
+#=--------------------------------------------------------------------------------------------------
+
+def print_struct_val(val, internal_dict):
+  '''Prints a struct, tuple, or tuple struct value with Rust syntax'''
+  assert val.GetType().GetTypeClass() == lldb.eTypeClassStruct
+
+  if is_vec_slice(val):
+    return print_vec_slice_val(val, internal_dict)
+  else:
+    return print_struct_val_starting_from(0, val, internal_dict)
+
+def print_vec_slice_val(val, internal_dict):
+  output = "&["
+
+  length = val.GetChildAtIndex(1).GetValueAsUnsigned()
+
+  data_ptr_val = val.GetChildAtIndex(0)
+  data_ptr_type = data_ptr_val.GetType()
+  assert data_ptr_type.IsPointerType()
+
+  element_type = data_ptr_type.GetPointeeType()
+  element_type_size = element_type.GetByteSize()
+
+  start_address = data_ptr_val.GetValueAsUnsigned()
+
+  for i in range(length):
+    address = start_address + i * element_type_size
+    element_val = val.CreateValueFromAddress( val.GetName() + ("[%s]" % i), address, element_type )
+    output += print_val(element_val, internal_dict)
+
+    if i != length - 1:
+      output += ", "
+
+  output += "]"
+  return output
+
+def print_struct_val_starting_from(field_start_index, val, internal_dict):
+  '''
+  Prints a struct, tuple, or tuple struct value with Rust syntax.
+  Ignores any fields before field_start_index.
+  '''
+  assert val.GetType().GetTypeClass() == lldb.eTypeClassStruct
+
+  t = val.GetType()
+  has_field_names = type_has_field_names(t)
+  type_name = extract_type_name(t.GetName())
+  output = ""
+
+  if not type_name.startswith("("):
+    # this is a tuple, so don't print the type name
+    output += type_name
+
+  if has_field_names:
+    output += " { \n"
+  else:
+    output += "("
+
+  num_children = val.num_children
+
+  for child_index in range(field_start_index, num_children):
+    if has_field_names:
+      field_name = t.GetFieldAtIndex(child_index).GetName()
+      output += field_name + ": "
+
+    field_val = val.GetChildAtIndex(child_index)
+    output += print_val(field_val, internal_dict)
+
+    if child_index != num_children - 1:
+      output += ", "
+
+    if has_field_names:
+      output += "\n"
+
+  if has_field_names:
+    output += "}"
+  else:
+    output += ")"
+
+  return output
+
+
+def print_enum_val(val, internal_dict):
+  '''Prints an enum value with Rust syntax'''
+
+  assert val.GetType().GetTypeClass() == lldb.eTypeClassUnion
+
+  if val.num_children == 1:
+    first_variant_name = val.GetChildAtIndex(0).GetName()
+    if first_variant_name and first_variant_name.startswith("RUST$ENCODED$ENUM$"):
+      # Try to extract the
+
+      last_separator_index = first_variant_name.rfind("$")
+      if last_separator_index == -1:
+        return "<invalid enum encoding: %s>" % first_variant_name
+
+      second_last_separator_index = first_variant_name.rfind("$", 0, last_separator_index)
+      if second_last_separator_index == -1:
+        return "<invalid enum encoding: %s>" % first_variant_name
+
+      try:
+        disr_field_index = first_variant_name[second_last_separator_index + 1 :
+                                              last_separator_index]
+        disr_field_index = int(disr_field_index)
+      except:
+        return "<invalid enum encoding: %s>" % first_variant_name
+
+      disr_val = val.GetChildAtIndex(0).GetChildAtIndex(disr_field_index).GetValueAsUnsigned()
+
+      if disr_val == 0:
+        null_variant_name = first_variant_name[last_separator_index + 1:]
+        return null_variant_name
+      else:
+        return print_struct_val_starting_from(0, val.GetChildAtIndex(0), internal_dict)
+    else:
+      return print_struct_val_starting_from(0, val.GetChildAtIndex(0), internal_dict)
+
+  # extract the discriminator value by
+  disr_val = val.GetChildAtIndex(0).GetChildAtIndex(0)
+  disr_type = disr_val.GetType()
+
+  if disr_type.GetTypeClass() != lldb.eTypeClassEnumeration:
+    return "<Invalid enum value encountered: Discriminator is not an enum>"
+
+  variant_index = disr_val.GetValueAsUnsigned()
+  return print_struct_val_starting_from(1, val.GetChildAtIndex(variant_index), internal_dict)
+
+
+def print_pointer_val(val, internal_dict):
+  '''Prints a pointer value with Rust syntax'''
+  assert val.GetType().IsPointerType()
+  sigil = "&"
+  type_name = extract_type_name(val.GetType().GetName())
+  if type_name and type_name[0:1] in ["&", "~", "*"]:
+    sigil = type_name[0:1]
+
+  return sigil + hex(val.GetValueAsUnsigned()) #print_val(val.Dereference(), internal_dict)
+
+
+def print_fixed_size_vec_val(val, internal_dict):
+  assert val.GetType().GetTypeClass() == lldb.eTypeClassArray
+
+  output = "["
+
+  for i in range(val.num_children):
+    output += print_val(val.GetChildAtIndex(i), internal_dict)
+    if i != val.num_children - 1:
+      output += ", "
+
+  output += "]"
+  return output
+
+
+#=--------------------------------------------------------------------------------------------------
+# Helper Functions
+#=--------------------------------------------------------------------------------------------------
+
+unqualified_type_markers = frozenset(["(", "[", "&", "*"])
+
+def extract_type_name(qualified_type_name):
+  '''Extracts the type name from a fully qualified path'''
+  if qualified_type_name[0] in unqualified_type_markers:
+    return qualified_type_name
+
+  end_of_search = qualified_type_name.find("<")
+  if end_of_search < 0:
+    end_of_search = len(qualified_type_name)
+
+  index = qualified_type_name.rfind("::", 0, end_of_search)
+  if index < 0:
+    return qualified_type_name
+  else:
+    return qualified_type_name[index + 2:]
+
+
+def type_has_field_names(ty):
+  '''Returns true of this is a type with field names (struct, struct-like enum variant)'''
+  # This may also be an enum variant where the first field doesn't have a name but the rest has
+  if ty.GetNumberOfFields() > 1:
+    return ty.GetFieldAtIndex(1).GetName() != None
+  else:
+    return ty.GetFieldAtIndex(0).GetName() != None
+
+
+def is_vec_slice(val):
+  ty = val.GetType()
+  if ty.GetTypeClass() != lldb.eTypeClassStruct:
+    return False
+
+  if ty.GetNumberOfFields() != 2:
+    return False
+
+  if ty.GetFieldAtIndex(0).GetName() != "data_ptr":
+    return False
+
+  if ty.GetFieldAtIndex(1).GetName() != "length":
+    return False
+
+  type_name = extract_type_name(ty.GetName()).replace("&'static", "&").replace(" ", "")
+  return type_name.startswith("&[") and type_name.endswith("]")
index 96ed69db635294c1b572f7b270d57b8c24809456..80f8c3ca5e1eec90a5e0964d663f57b2ec73d5be 100644 (file)
@@ -1,7 +1,7 @@
 *rust.txt*      Filetype plugin for Rust
 
 ==============================================================================
-CONTENTS                                                                *rust*
+CONTENTS                                                      *rust* *ft-rust*
 
 1. Introduction                                                   |rust-intro|
 2. Settings                                                    |rust-settings|
@@ -53,6 +53,18 @@ g:rust_conceal_pub~
            let g:rust_conceal_pub = 1
 <
 
+                                                                 *g:rust_fold*
+g:rust_fold~
+       Set this option to turn on |folding|: >
+           let g:rust_fold = 1
+<
+       Value           Effect ~
+       0               No folding
+       1               Braced blocks are folded. All folds are open by
+                       default.
+       2               Braced blocks are folded. 'foldlevel' is left at the
+                       global value (all folds are closed by default).
+
                                                   *g:rust_bang_comment_leader*
 g:rust_bang_comment_leader~
        Set this option to 1 to preserve the leader on multi-line doc comments
index 16ed43415c3ef5a7231011a19081a49870e3d6e5..39edc1f9a20d754f880999235f63f1d1c35d1a92 100644 (file)
@@ -2,7 +2,7 @@
 " Description:  Vim syntax file for Rust
 " Maintainer:   Chris Morgan <me@chrismorgan.info>
 " Maintainer:   Kevin Ballard <kevin@sb.org>
-" Last Change:  May 27, 2014
+" Last Change:  Jul 07, 2014
 
 if exists("b:did_ftplugin")
        finish
@@ -35,7 +35,9 @@ silent! setlocal formatoptions+=j
 " otherwise it's better than nothing.
 setlocal smartindent nocindent
 
-setlocal tabstop=4 shiftwidth=4 expandtab
+setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
+
+setlocal textwidth=99
 
 " This includeexpr isn't perfect, but it's a good start
 setlocal includeexpr=substitute(v:fname,'::','/','g')
@@ -93,7 +95,8 @@ endif
 " Cleanup {{{1
 
 let b:undo_ftplugin = "
-               \setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd<
+               \ setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd<
+               \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth<
                \|if exists('b:rust_original_delimitMate_excluded_regions')
                  \|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions
                  \|unlet b:rust_original_delimitMate_excluded_regions
index 86df9cba4cdf5317b8a148f97dbde8b912a2607e..1b75538d2f71b04b24d6f32e17fbd5e3d7681edc 100644 (file)
@@ -3,7 +3,7 @@
 " Maintainer:   Patrick Walton <pcwalton@mozilla.com>
 " Maintainer:   Ben Blum <bblum@cs.cmu.edu>
 " Maintainer:   Chris Morgan <me@chrismorgan.info>
-" Last Change:  2014 Feb 27
+" Last Change:  July 06, 2014
 
 if version < 600
   syntax clear
@@ -11,6 +11,17 @@ elseif exists("b:current_syntax")
   finish
 endif
 
+" Fold settings {{{1
+
+if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
+  setlocal foldmethod=syntax
+  if g:rust_fold == 2
+    setlocal foldlevel<
+  else
+    setlocal foldlevel=99
+  endif
+endif
+
 " Syntax definitions {{{1
 " Basic keywords {{{2
 syn keyword   rustConditional match if else
@@ -213,8 +224,6 @@ syn keyword rustTodo contained TODO FIXME XXX NB NOTE
 " Trivial folding rules to begin with.
 " TODO: use the AST to make really good folding
 syn region rustFoldBraces start="{" end="}" transparent fold
-" If you wish to enable this, setlocal foldmethod=syntax
-" It's not enabled by default as it would drive some people mad.
 
 " Default highlighting {{{1
 hi def link rustDecNumber       rustNumber
index 3d4973373e26763fbfa756bd6b85ce7f5833f086..c2211d08bfab7a6f1c74c9f2c4476147e76011d2 100644 (file)
 //! An ordered map and set implemented as self-balancing binary search
 //! trees. The only requirement for the types is that the key implements
 //! `Ord`.
+//!
+//! ## Example
+//!
+//! ```{rust}
+//! use std::collections::TreeSet;
+//!
+//! let mut tree_set = TreeSet::new();
+//!
+//! tree_set.insert(2i);
+//! tree_set.insert(1i);
+//! tree_set.insert(3i);
+//!
+//! for i in tree_set.iter() {
+//!    println!("{}", i) // prints 1, then 2, then 3
+//! }
+//! ```
 
 use core::prelude::*;
 
@@ -587,6 +603,22 @@ fn next(&mut self) -> Option<&'a T> {
 /// A implementation of the `Set` trait on top of the `TreeMap` container. The
 /// only requirement is that the type of the elements contained ascribes to the
 /// `Ord` trait.
+///
+/// ## Example
+///
+/// ```{rust}
+/// use std::collections::TreeSet;
+///
+/// let mut tree_set = TreeSet::new();
+///
+/// tree_set.insert(2i);
+/// tree_set.insert(1i);
+/// tree_set.insert(3i);
+///
+/// for i in tree_set.iter() {
+///    println!("{}", i) // prints 1, then 2, then 3
+/// }
+/// ```
 #[deriving(Clone)]
 pub struct TreeSet<T> {
     map: TreeMap<T, ()>
index 1e96588dac5f896a9217b791228cac9533f0a52d..23c31ee9906416b16d89eaa0fc9ab5ed92938a93 100644 (file)
@@ -42,7 +42,7 @@
 /// vec.push(2i);
 ///
 /// assert_eq!(vec.len(), 2);
-/// assert_eq!(vec.get(0), &1);
+/// assert_eq!(vec[0], 1);
 ///
 /// assert_eq!(vec.pop(), Some(2));
 /// assert_eq!(vec.len(), 1);
@@ -363,6 +363,21 @@ fn clone_from(&mut self, other: &Vec<T>) {
     }
 }
 
+impl<T> Index<uint,T> for Vec<T> {
+    #[inline]
+    fn index<'a>(&'a self, index: &uint) -> &'a T {
+        self.get(*index)
+    }
+}
+
+// FIXME(#12825) Indexing will always try IndexMut first and that causes issues.
+/*impl<T> IndexMut<uint,T> for Vec<T> {
+    #[inline]
+    fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
+        self.get_mut(*index)
+    }
+}*/
+
 impl<T> FromIterator<T> for Vec<T> {
     #[inline]
     fn from_iter<I:Iterator<T>>(mut iterator: I) -> Vec<T> {
@@ -731,9 +746,12 @@ pub unsafe fn set_len(&mut self, len: uint) {
     /// # Example
     ///
     /// ```rust
+    /// #![allow(deprecated)]
+    ///
     /// let vec = vec!(1i, 2, 3);
     /// assert!(vec.get(1) == &2);
     /// ```
+    #[deprecated="prefer using indexing, e.g., vec[0]"]
     #[inline]
     pub fn get<'a>(&'a self, index: uint) -> &'a T {
         &self.as_slice()[index]
@@ -1847,6 +1865,19 @@ fn drop(&mut self) {
         v.truncate(0);
     }
 
+    #[test]
+    fn test_index() {
+        let vec = vec!(1i, 2, 3);
+        assert!(vec[1] == 2);
+    }
+
+    #[test]
+    #[should_fail]
+    fn test_index_out_of_bounds() {
+        let vec = vec!(1i, 2, 3);
+        let _ = vec[3];
+    }
+
     #[bench]
     fn bench_new(b: &mut Bencher) {
         b.iter(|| {
index 9755d54a1320591f506118285c8d8b288a1489ef..b72cc43b28c60c3485684c5875a64a1c9eac6184 100644 (file)
@@ -466,7 +466,7 @@ fn visit_enum_variant_field(&mut self,
                                 _offset: uint,
                                 inner: *const TyDesc)
                                 -> bool {
-        match *self.var_stk.get(self.var_stk.len() - 1) {
+        match self.var_stk[self.var_stk.len() - 1] {
             Matched => {
                 if i != 0 {
                     try!(self, self.writer.write(", ".as_bytes()));
@@ -484,7 +484,7 @@ fn visit_leave_enum_variant(&mut self, _variant: uint,
                                 _disr_val: Disr,
                                 n_fields: uint,
                                 _name: &str) -> bool {
-        match *self.var_stk.get(self.var_stk.len() - 1) {
+        match self.var_stk[self.var_stk.len() - 1] {
             Matched => {
                 if n_fields > 0 {
                     try!(self, self.writer.write([')' as u8]));
index eaec31a45f42180fab1f4cb3ae95ac19a0d00bcd..bf39fd566e52d200ea2ff367ca4796e7312f1575 100644 (file)
@@ -51,7 +51,7 @@
 //! fn main() {
 //!     let args: Vec<String> = os::args();
 //!
-//!     let program = args.get(0).clone();
+//!     let program = args[0].clone();
 //!
 //!     let opts = [
 //!         optopt("o", "", "set output file name", "NAME"),
@@ -67,7 +67,7 @@
 //!     }
 //!     let output = matches.opt_str("o");
 //!     let input = if !matches.free.is_empty() {
-//!         (*matches.free.get(0)).clone()
+//!         matches.free[0].clone()
 //!     } else {
 //!         print_usage(program.as_slice(), opts);
 //!         return;
@@ -275,7 +275,7 @@ pub fn long_to_short(&self) -> Opt {
 impl Matches {
     fn opt_vals(&self, nm: &str) -> Vec<Optval> {
         match find_opt(self.opts.as_slice(), Name::from_str(nm)) {
-            Some(id) => (*self.vals.get(id)).clone(),
+            Some(id) => self.vals[id].clone(),
             None => fail!("No option '{}' defined", nm)
         }
     }
@@ -285,7 +285,7 @@ fn opt_val(&self, nm: &str) -> Option<Optval> {
         if vals.is_empty() {
             None
         } else {
-            Some((*vals.get(0)).clone())
+            Some(vals[0].clone())
         }
     }
 
@@ -304,7 +304,7 @@ pub fn opts_present(&self, names: &[String]) -> bool {
         for nm in names.iter() {
             match find_opt(self.opts.as_slice(),
                            Name::from_str(nm.as_slice())) {
-                Some(id) if !self.vals.get(id).is_empty() => return true,
+                Some(id) if !self.vals[id].is_empty() => return true,
                 _ => (),
             };
         }
@@ -344,8 +344,8 @@ pub fn opt_str(&self, nm: &str) -> Option<String> {
         if vals.is_empty() {
             return None::<String>;
         }
-        match vals.get(0) {
-            &Val(ref s) => Some((*s).clone()),
+        match vals[0] {
+            Val(ref s) => Some((*s).clone()),
             _ => None
         }
     }
@@ -361,8 +361,8 @@ pub fn opt_default(&self, nm: &str, def: &str) -> Option<String> {
         if vals.is_empty() {
             return None;
         }
-        match vals.get(0) {
-            &Val(ref s) => Some((*s).clone()),
+        match vals[0] {
+            Val(ref s) => Some((*s).clone()),
             _ => Some(def.to_string())
         }
     }
@@ -560,8 +560,8 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
                     names = vec!(Long(tail.to_string()));
                 } else {
                     names =
-                        vec!(Long((*tail_eq.get(0)).to_string()));
-                    i_arg = Some((*tail_eq.get(1)).to_string());
+                        vec!(Long(tail_eq[0].to_string()));
+                    i_arg = Some(tail_eq[1].to_string());
                 }
             } else {
                 let mut j = 1;
@@ -583,7 +583,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
                       None => {
                         let arg_follows =
                             last_valid_opt_id.is_some() &&
-                            match opts.get(last_valid_opt_id.unwrap())
+                            match opts[last_valid_opt_id.unwrap()]
                               .hasarg {
 
                               Yes | Maybe => true,
@@ -609,7 +609,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
                   Some(id) => id,
                   None => return Err(UnrecognizedOption(nm.to_string()))
                 };
-                match opts.get(optid).hasarg {
+                match opts[optid].hasarg {
                   No => {
                     if !i_arg.is_none() {
                         return Err(UnexpectedArgument(nm.to_string()));
@@ -646,16 +646,16 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
     }
     i = 0u;
     while i < n_opts {
-        let n = vals.get(i).len();
-        let occ = opts.get(i).occur;
+        let n = vals[i].len();
+        let occ = opts[i].occur;
         if occ == Req {
             if n == 0 {
-                return Err(OptionMissing(opts.get(i).name.to_string()));
+                return Err(OptionMissing(opts[i].name.to_string()));
             }
         }
         if occ != Multi {
             if n > 1 {
-                return Err(OptionDuplicated(opts.get(i).name.to_string()));
+                return Err(OptionDuplicated(opts[i].name.to_string()));
             }
         }
         i += 1;
index c28eb51d59d442d42acfa5962886e50a5fd0bf7c..d539283f0a717a8b544d562bead76c06f636603f 100644 (file)
@@ -154,7 +154,7 @@ fn next(&mut self) -> Option<Path> {
                 if self.require_dir && !path.is_dir() { continue; }
                 return Some(path);
             }
-            let ref pattern = *self.dir_patterns.get(idx);
+            let ref pattern = self.dir_patterns[idx];
 
             if pattern.matches_with(match path.filename_str() {
                 // this ugly match needs to go here to avoid a borrowck error
@@ -250,21 +250,21 @@ pub fn new(pattern: &str) -> Pattern {
         let mut i = 0;
 
         while i < chars.len() {
-            match *chars.get(i) {
+            match chars[i] {
                 '?' => {
                     tokens.push(AnyChar);
                     i += 1;
                 }
                 '*' => {
                     // *, **, ***, ****, ... are all equivalent
-                    while i < chars.len() && *chars.get(i) == '*' {
+                    while i < chars.len() && chars[i] == '*' {
                         i += 1;
                     }
                     tokens.push(AnySequence);
                 }
                 '[' => {
 
-                    if i <= chars.len() - 4 && *chars.get(i + 1) == '!' {
+                    if i <= chars.len() - 4 && chars[i + 1] == '!' {
                         match chars.slice_from(i + 3).position_elem(&']') {
                             None => (),
                             Some(j) => {
@@ -276,7 +276,7 @@ pub fn new(pattern: &str) -> Pattern {
                             }
                         }
                     }
-                    else if i <= chars.len() - 3 && *chars.get(i + 1) != '!' {
+                    else if i <= chars.len() - 3 && chars[i + 1] != '!' {
                         match chars.slice_from(i + 2).position_elem(&']') {
                             None => (),
                             Some(j) => {
@@ -507,7 +507,7 @@ fn pattern_as_str(pattern: &Pattern) -> Option<String> {
                     // the current and parent directory respectively requires that
                     // the pattern has a leading dot, even if the `MatchOptions` field
                     // `require_literal_leading_dot` is not set.
-                    if pattern.tokens.len() > 0 && pattern.tokens.get(0) == &Char('.') {
+                    if pattern.tokens.len() > 0 && pattern.tokens[0] == Char('.') {
                         for &special in [".", ".."].iter() {
                             if pattern.matches_with(special, options) {
                                 add(todo, path.join(special));
index a3653fa9735901353a3cf331b895fc614e296e0f..24698d09f56e53d782556aa343b0fd0f7e823d11 100644 (file)
@@ -168,7 +168,7 @@ fn node_id(&'a self, n: &Nd) -> dot::Id<'a> {
         dot::Id::new(format!("N{}", n))
     }
     fn node_label<'a>(&'a self, n: &Nd) -> dot::LabelText<'a> {
-        dot::LabelStr(str::Slice(self.nodes.get(*n).as_slice()))
+        dot::LabelStr(str::Slice(self.nodes[*n].as_slice()))
     }
     fn edge_label<'a>(&'a self, _: &Ed) -> dot::LabelText<'a> {
         dot::LabelStr(str::Slice("&sube;"))
@@ -225,7 +225,7 @@ fn node_id(&'a self, n: &Nd<'a>) -> dot::Id<'a> {
     }
     fn node_label<'a>(&'a self, n: &Nd<'a>) -> dot::LabelText<'a> {
         let &(i, _) = n;
-        dot::LabelStr(str::Slice(self.nodes.get(i).as_slice()))
+        dot::LabelStr(str::Slice(self.nodes[i].as_slice()))
     }
     fn edge_label<'a>(&'a self, _: &Ed<'a>) -> dot::LabelText<'a> {
         dot::LabelStr(str::Slice("&sube;"))
@@ -238,8 +238,8 @@ fn nodes(&'a self) -> dot::Nodes<'a,Nd<'a>> {
     }
     fn edges(&'a self) -> dot::Edges<'a,Ed<'a>> {
         self.edges.iter()
-            .map(|&(i,j)|((i, self.nodes.get(i).as_slice()),
-                          (j, self.nodes.get(j).as_slice())))
+            .map(|&(i,j)|((i, self.nodes[i].as_slice()),
+                          (j, self.nodes[j].as_slice())))
             .collect()
     }
     fn source(&self, e: &Ed<'a>) -> Nd<'a> { let &(s,_) = e; s }
index 109d32f69b9678342caf8ea463325f0ad6d2b413..d53fed7aa80fc897ab39f9ab64c58d45b2ae5fe2 100644 (file)
@@ -235,7 +235,7 @@ fn parse(&mut self) -> Result<Ast, Error> {
                     // left paren, let's grab the old flags and see if we
                     // need a capture.
                     let (cap, cap_name, oldflags) = {
-                        let paren = self.stack.get(altfrom-1);
+                        let paren = &self.stack[altfrom-1];
                         (paren.capture(), paren.capture_name(), paren.flags())
                     };
                     try!(self.alternate(altfrom));
@@ -464,7 +464,7 @@ fn try_parse_ascii(&mut self) -> Option<Ast> {
                 Some(i) => i,
                 None => return None,
             };
-        if *self.chars.get(closer-1) != ':' {
+        if self.chars[closer-1] != ':' {
             return None
         }
         if closer - self.chari <= 3 {
@@ -519,7 +519,7 @@ fn parse_counted(&mut self) -> Result<(), Error> {
             max = Some(min);
         } else {
             let pieces: Vec<&str> = inner.as_slice().splitn(',', 1).collect();
-            let (smin, smax) = (*pieces.get(0), *pieces.get(1));
+            let (smin, smax) = (pieces[0], pieces[1]);
             if smin.len() == 0 {
                 return self.err("Max repetitions cannot be specified \
                                     without min repetitions.")
@@ -931,7 +931,7 @@ fn peek(&self, offset: uint) -> Option<char> {
         if self.chari + offset >= self.chars.len() {
             return None
         }
-        Some(*self.chars.get(self.chari + offset))
+        Some(self.chars[self.chari + offset])
     }
 
     fn peek_is(&self, offset: uint, is: char) -> bool {
@@ -939,7 +939,7 @@ fn peek_is(&self, offset: uint, is: char) -> bool {
     }
 
     fn cur(&self) -> char {
-        *self.chars.get(self.chari)
+        self.chars[self.chari]
     }
 
     fn slice(&self, start: uint, end: uint) -> String {
index 054cbb0fcd63dfa2c518f793bdeb3fd80f4599aa..8e4145b2a3198973b69ade6d83e8f6067323a78f 100644 (file)
@@ -207,7 +207,7 @@ pub fn is_match(&self, text: &str) -> bool {
     pub fn find(&self, text: &str) -> Option<(uint, uint)> {
         let caps = exec(self, Location, text);
         if has_match(&caps) {
-            Some((caps.get(0).unwrap(), caps.get(1).unwrap()))
+            Some((caps[0].unwrap(), caps[1].unwrap()))
         } else {
             None
         }
@@ -699,11 +699,11 @@ fn new(re: &Regex, search: &'t str, locs: CaptureLocs)
     /// original string matched.
     pub fn pos(&self, i: uint) -> Option<(uint, uint)> {
         let (s, e) = (i * 2, i * 2 + 1);
-        if e >= self.locs.len() || self.locs.get(s).is_none() {
+        if e >= self.locs.len() || self.locs[s].is_none() {
             // VM guarantees that each pair of locations are both Some or None.
             return None
         }
-        Some((self.locs.get(s).unwrap(), self.locs.get(e).unwrap()))
+        Some((self.locs[s].unwrap(), self.locs[e].unwrap()))
     }
 
     /// Returns the matched string for the capture group `i`.
@@ -851,7 +851,7 @@ fn next(&mut self) -> Option<Captures<'t>> {
             if !has_match(&caps) {
                 return None
             } else {
-                (caps.get(0).unwrap(), caps.get(1).unwrap())
+                (caps[0].unwrap(), caps[1].unwrap())
             };
 
         // Don't accept empty matches immediately following a match.
@@ -893,7 +893,7 @@ fn next(&mut self) -> Option<(uint, uint)> {
             if !has_match(&caps) {
                 return None
             } else {
-                (caps.get(0).unwrap(), caps.get(1).unwrap())
+                (caps[0].unwrap(), caps[1].unwrap())
             };
 
         // Don't accept empty matches immediately following a match.
@@ -922,5 +922,5 @@ fn exec_slice(re: &Regex, which: MatchKind,
 
 #[inline]
 fn has_match(caps: &CaptureLocs) -> bool {
-    caps.len() >= 2 && caps.get(0).is_some() && caps.get(1).is_some()
+    caps.len() >= 2 && caps[0].is_some() && caps[1].is_some()
 }
index 782078ced497b9d09cf139416bc9e226848d5619..b37000df02dbec436e2c862fbb26c711efbbca28 100644 (file)
@@ -123,7 +123,7 @@ fn run(&mut self) -> CaptureLocs {
         // Make sure multi-line mode isn't enabled for it, otherwise we can't
         // drop the initial .*?
         let prefix_anchor =
-            match *self.prog.insts.get(1) {
+            match self.prog.insts[1] {
                 EmptyBegin(flags) if flags & FLAG_MULTI == 0 => true,
                 _ => false,
             };
@@ -192,7 +192,7 @@ fn run(&mut self) -> CaptureLocs {
     fn step(&self, groups: &mut [Option<uint>], nlist: &mut Threads,
             caps: &mut [Option<uint>], pc: uint)
            -> StepState {
-        match *self.prog.insts.get(pc) {
+        match self.prog.insts[pc] {
             Match => {
                 match self.which {
                     Exists => {
@@ -259,7 +259,7 @@ fn add(&self, nlist: &mut Threads, pc: uint, groups: &mut [Option<uint>]) {
         //
         // We make a minor optimization by indicating that the state is "empty"
         // so that its capture groups are not filled in.
-        match *self.prog.insts.get(pc) {
+        match self.prog.insts[pc] {
             EmptyBegin(flags) => {
                 let multi = flags & FLAG_MULTI > 0;
                 nlist.add(pc, groups, true);
@@ -481,8 +481,8 @@ fn add(&mut self, pc: uint, groups: &[Option<uint>], empty: bool) {
 
     #[inline]
     fn contains(&self, pc: uint) -> bool {
-        let s = *self.sparse.get(pc);
-        s < self.size && self.queue.get(s).pc == pc
+        let s = self.sparse[pc];
+        s < self.size && self.queue[s].pc == pc
     }
 
     #[inline]
@@ -492,7 +492,7 @@ fn empty(&mut self) {
 
     #[inline]
     fn pc(&self, i: uint) -> uint {
-        self.queue.get(i).pc
+        self.queue[i].pc
     }
 
     #[inline]
index 6fa8a1530234e15b4f4f8392deb327be96b0c89e..9d2ed6adec54021635a72a7b7ed65836944f2953 100644 (file)
@@ -186,6 +186,22 @@ pub fn run_passes(sess: &Session,
                 }
             };
 
+            let code_model = match sess.opts.cg.code_model.as_slice() {
+                "default" => llvm::CodeModelDefault,
+                "small" => llvm::CodeModelSmall,
+                "kernel" => llvm::CodeModelKernel,
+                "medium" => llvm::CodeModelMedium,
+                "large" => llvm::CodeModelLarge,
+                _ => {
+                    sess.err(format!("{} is not a valid code model",
+                                     sess.opts
+                                         .cg
+                                         .code_model).as_slice());
+                    sess.abort_if_errors();
+                    return;
+                }
+            };
+
             let tm = sess.targ_cfg
                          .target_strs
                          .target_triple
@@ -195,7 +211,7 @@ pub fn run_passes(sess: &Session,
                     target_feature(sess).with_c_str(|features| {
                         llvm::LLVMRustCreateTargetMachine(
                             t, cpu, features,
-                            llvm::CodeModelDefault,
+                            code_model,
                             reloc_model,
                             opt_level,
                             true /* EnableSegstk */,
index 345877d9ab6c47beea8f81694eeccb00af7c462b..ee611293475f9011702f7196c5482d244e3b962a 100644 (file)
@@ -332,8 +332,12 @@ fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
         "prefer dynamic linking to static linking"),
     no_integrated_as: bool = (false, parse_bool,
         "use an external assembler rather than LLVM's integrated one"),
+    no_redzone: bool = (false, parse_bool,
+        "disable the use of the redzone"),
     relocation_model: String = ("pic".to_string(), parse_string,
          "choose the relocation model to use (llc -relocation-model for details)"),
+    code_model: String = ("default".to_string(), parse_string,
+         "choose the code model to use (llc -code-model for details)"),
     metadata: Vec<String> = (Vec::new(), parse_list,
          "metadata to mangle symbol names with"),
     extra_filename: String = ("".to_string(), parse_string,
index 5ab8eeeb36055c7242e3d192f66eb6cd4ccf6038..0adc8e915c679e2050e5f22f487ff27ad14ae549 100644 (file)
@@ -132,7 +132,8 @@ pub fn get_method(tcx: &ty::ctxt, def: ast::DefId) -> ty::Method {
 
 pub fn get_method_name_and_explicit_self(cstore: &cstore::CStore,
                                          def: ast::DefId)
-                                     -> (ast::Ident, ast::ExplicitSelf_)
+                                         -> (ast::Ident,
+                                             ty::ExplicitSelfCategory)
 {
     let cdata = cstore.get_crate_data(def.krate);
     decoder::get_method_name_and_explicit_self(cstore.intr.clone(), &*cdata, def.node)
index cc41223688ee0b9eab8f8ff7f3c6caaff54d262d..094e83d2a4770af150046c2aa7102df4ca28c3ad 100644 (file)
@@ -724,7 +724,7 @@ pub fn get_enum_variants(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId,
     }).collect()
 }
 
-fn get_explicit_self(item: ebml::Doc) -> ast::ExplicitSelf_ {
+fn get_explicit_self(item: ebml::Doc) -> ty::ExplicitSelfCategory {
     fn get_mutability(ch: u8) -> ast::Mutability {
         match ch as char {
             'i' => ast::MutImmutable,
@@ -738,12 +738,15 @@ fn get_mutability(ch: u8) -> ast::Mutability {
 
     let explicit_self_kind = string.as_bytes()[0];
     match explicit_self_kind as char {
-        's' => ast::SelfStatic,
-        'v' => ast::SelfValue(special_idents::self_),
-        '~' => ast::SelfUniq(special_idents::self_),
+        's' => ty::StaticExplicitSelfCategory,
+        'v' => ty::ByValueExplicitSelfCategory,
+        '~' => ty::ByBoxExplicitSelfCategory,
         // FIXME(#4846) expl. region
-        '&' => ast::SelfRegion(None, get_mutability(string.as_bytes()[1]),
-                               special_idents::self_),
+        '&' => {
+            ty::ByReferenceExplicitSelfCategory(
+                ty::ReEmpty,
+                get_mutability(string.as_bytes()[1]))
+        }
         _ => fail!("unknown self type code: `{}`", explicit_self_kind as char)
     }
 }
@@ -761,11 +764,11 @@ pub fn get_impl_methods(cdata: Cmd, impl_id: ast::NodeId) -> Vec<ast::DefId> {
     methods
 }
 
-pub fn get_method_name_and_explicit_self(
-    intr: Rc<IdentInterner>,
-    cdata: Cmd,
-    id: ast::NodeId) -> (ast::Ident, ast::ExplicitSelf_)
-{
+pub fn get_method_name_and_explicit_self(intr: Rc<IdentInterner>,
+                                         cdata: Cmd,
+                                         id: ast::NodeId)
+                                         -> (ast::Ident,
+                                             ty::ExplicitSelfCategory) {
     let method_doc = lookup_item(id, cdata.data());
     let name = item_name(&*intr, method_doc);
     let explicit_self = get_explicit_self(method_doc);
index 87333499ec3a2f2a10b1a2ce32abd8b770a5b4cd..3c9f32dcd2f85ca9c7a2499521f38afc53190e63 100644 (file)
@@ -43,6 +43,7 @@
 use syntax::ast_map;
 use syntax::ast_util::*;
 use syntax::ast_util;
+use syntax::ast_util::PostExpansionMethod;
 use syntax::attr;
 use syntax::attr::AttrMetaMethods;
 use syntax::diagnostic::SpanHandler;
@@ -401,7 +402,7 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
             for base_impl_did in implementations.borrow().iter() {
                 for &method_did in impl_methods.get(base_impl_did).iter() {
                     let m = ty::method(ecx.tcx, method_did);
-                    if m.explicit_self == ast::SelfStatic {
+                    if m.explicit_self == ty::StaticExplicitSelfCategory {
                         encode_reexported_static_method(ebml_w, exp, m.def_id, m.ident);
                     }
                 }
@@ -420,7 +421,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
     match ecx.tcx.trait_methods_cache.borrow().find(&exp.def_id) {
         Some(methods) => {
             for m in methods.iter() {
-                if m.explicit_self == ast::SelfStatic {
+                if m.explicit_self == ty::StaticExplicitSelfCategory {
                     encode_reexported_static_method(ebml_w, exp, m.def_id, m.ident);
                 }
             }
@@ -622,15 +623,22 @@ fn encode_visibility(ebml_w: &mut Encoder, visibility: Visibility) {
     ebml_w.end_tag();
 }
 
-fn encode_explicit_self(ebml_w: &mut Encoder, explicit_self: ast::ExplicitSelf_) {
+fn encode_explicit_self(ebml_w: &mut Encoder,
+                        explicit_self: &ty::ExplicitSelfCategory) {
     ebml_w.start_tag(tag_item_trait_method_explicit_self);
 
     // Encode the base self type.
-    match explicit_self {
-        SelfStatic   => { ebml_w.writer.write(&[ 's' as u8 ]); }
-        SelfValue(_) => { ebml_w.writer.write(&[ 'v' as u8 ]); }
-        SelfUniq(_)  => { ebml_w.writer.write(&[ '~' as u8 ]); }
-        SelfRegion(_, m, _) => {
+    match *explicit_self {
+        ty::StaticExplicitSelfCategory => {
+            ebml_w.writer.write(&[ 's' as u8 ]);
+        }
+        ty::ByValueExplicitSelfCategory => {
+            ebml_w.writer.write(&[ 'v' as u8 ]);
+        }
+        ty::ByBoxExplicitSelfCategory => {
+            ebml_w.writer.write(&[ '~' as u8 ]);
+        }
+        ty::ByReferenceExplicitSelfCategory(_, m) => {
             // FIXME(#4846) encode custom lifetime
             ebml_w.writer.write(&['&' as u8]);
             encode_mutability(ebml_w, m);
@@ -747,10 +755,10 @@ fn encode_method_ty_fields(ecx: &EncodeContext,
                               tag_item_method_tps);
     encode_method_fty(ecx, ebml_w, &method_ty.fty);
     encode_visibility(ebml_w, method_ty.vis);
-    encode_explicit_self(ebml_w, method_ty.explicit_self);
+    encode_explicit_self(ebml_w, &method_ty.explicit_self);
     let fn_style = method_ty.fty.fn_style;
     match method_ty.explicit_self {
-        ast::SelfStatic => {
+        ty::StaticExplicitSelfCategory => {
             encode_family(ebml_w, fn_style_static_method_family(fn_style));
         }
         _ => encode_family(ebml_w, style_fn_family(fn_style))
@@ -798,7 +806,7 @@ fn encode_info_for_method(ecx: &EncodeContext,
         } else {
             encode_symbol(ecx, ebml_w, m.def_id.node);
         }
-        encode_method_argument_names(ebml_w, method_fn_decl(&*ast_method));
+        encode_method_argument_names(ebml_w, &*ast_method.pe_fn_decl());
     }
 
     ebml_w.end_tag();
@@ -1205,7 +1213,7 @@ fn add_to_index(item: &Item, ebml_w: &Encoder,
             encode_path(ebml_w, path.clone().chain(Some(elem).move_iter()));
 
             match method_ty.explicit_self {
-                SelfStatic => {
+                ty::StaticExplicitSelfCategory => {
                     encode_family(ebml_w,
                                   fn_style_static_method_family(
                                       method_ty.fty.fn_style));
@@ -1232,7 +1240,7 @@ fn add_to_index(item: &Item, ebml_w: &Encoder,
                     encode_attributes(ebml_w, m.attrs.as_slice());
                     // If this is a static method, we've already encoded
                     // this.
-                    if method_ty.explicit_self != SelfStatic {
+                    if method_ty.explicit_self != ty::StaticExplicitSelfCategory {
                         // FIXME: I feel like there is something funny going on.
                         let pty = ty::lookup_item_type(tcx, method_def_id);
                         encode_bounds_and_type(ebml_w, ecx, &pty);
@@ -1240,7 +1248,7 @@ fn add_to_index(item: &Item, ebml_w: &Encoder,
                     encode_method_sort(ebml_w, 'p');
                     encode_inlined_item(ecx, ebml_w,
                                         IIMethodRef(def_id, true, &*m));
-                    encode_method_argument_names(ebml_w, method_fn_decl(m));
+                    encode_method_argument_names(ebml_w, m.pe_fn_decl());
                 }
             }
 
index d58023a48756f00ebc3f8facec0c9e2536003dd7..9240547874fd83291e82a6c50ce90b4ae9318300 100644 (file)
@@ -31,6 +31,7 @@
 use util::ppaux::ty_to_string;
 
 use syntax::{ast, ast_map, ast_util, codemap, fold};
+use syntax::ast_util::PostExpansionMethod;
 use syntax::codemap::Span;
 use syntax::fold::Folder;
 use syntax::parse::token;
@@ -136,7 +137,7 @@ pub fn decode_inlined_item(cdata: &cstore::crate_metadata,
         let ident = match ii {
             ast::IIItem(i) => i.ident,
             ast::IIForeign(i) => i.ident,
-            ast::IIMethod(_, _, m) => ast_util::method_ident(&*m),
+            ast::IIMethod(_, _, m) => m.pe_ident(),
         };
         debug!("Fn named: {}", token::get_ident(ident));
         debug!("< Decoded inlined fn: {}::{}",
index db8ab8c83fbdc78ae18f20bdb60d96bb08ae431a..cfec67bf3a395e422d7c07d5dc8e44f62fd2db21 100644 (file)
@@ -734,7 +734,8 @@ fn mark_variable_as_used_mut(this: &CheckLoanCtxt,
                     mc::cat_static_item |
                     mc::cat_copied_upvar(..) |
                     mc::cat_deref(_, _, mc::UnsafePtr(..)) |
-                    mc::cat_deref(_, _, mc::BorrowedPtr(..)) => {
+                    mc::cat_deref(_, _, mc::BorrowedPtr(..)) |
+                    mc::cat_deref(_, _, mc::Implicit(..)) => {
                         assert_eq!(cmt.mutbl, mc::McDeclared);
                         return;
                     }
index de77fa602c9b406a0bf85a4e8c58b04bb72b7975..322471f30294f06c70e8e7275ca293fc91dce57b 100644 (file)
@@ -131,6 +131,7 @@ fn check_and_get_illegal_move_origin(bccx: &BorrowckCtxt,
                                      cmt: &mc::cmt) -> Option<mc::cmt> {
     match cmt.cat {
         mc::cat_deref(_, _, mc::BorrowedPtr(..)) |
+        mc::cat_deref(_, _, mc::Implicit(..)) |
         mc::cat_deref(_, _, mc::GcPtr) |
         mc::cat_deref(_, _, mc::UnsafePtr(..)) |
         mc::cat_upvar(..) | mc::cat_static_item |
index dc8567af9edad9fb9727a8639815791ca6d86479..0785538cc76abba674fa9095bf8d84cddb4106dc 100644 (file)
@@ -72,6 +72,7 @@ fn check(&self, cmt: &mc::cmt, discr_scope: Option<ast::NodeId>) -> R {
             mc::cat_arg(..) |                           // L-Local
             mc::cat_upvar(..) |
             mc::cat_deref(_, _, mc::BorrowedPtr(..)) |  // L-Deref-Borrowed
+            mc::cat_deref(_, _, mc::Implicit(..)) |
             mc::cat_deref(_, _, mc::UnsafePtr(..)) => {
                 self.check_scope(self.scope(cmt))
             }
@@ -180,7 +181,8 @@ fn scope(&self, cmt: &mc::cmt) -> ty::Region {
             mc::cat_deref(_, _, mc::UnsafePtr(..)) => {
                 ty::ReStatic
             }
-            mc::cat_deref(_, _, mc::BorrowedPtr(_, r)) => {
+            mc::cat_deref(_, _, mc::BorrowedPtr(_, r)) |
+            mc::cat_deref(_, _, mc::Implicit(_, r)) => {
                 r
             }
             mc::cat_downcast(ref cmt) |
index 9876e12d5ccac539efb1d03ff7ba34ae4ad00cb8..10f051f004f19b41018e036d4e63c983353ff066 100644 (file)
@@ -113,6 +113,7 @@ fn append_to_grouped_errors(grouped_errors: &mut Vec<GroupedMoveErrors>,
 fn report_cannot_move_out_of(bccx: &BorrowckCtxt, move_from: mc::cmt) {
     match move_from.cat {
         mc::cat_deref(_, _, mc::BorrowedPtr(..)) |
+        mc::cat_deref(_, _, mc::Implicit(..)) |
         mc::cat_deref(_, _, mc::GcPtr) |
         mc::cat_deref(_, _, mc::UnsafePtr(..)) |
         mc::cat_upvar(..) | mc::cat_static_item |
index d131b6f7eda29895a49ec774d8705d7bdd9b538a..48399cb0b7e02f1fbd54c2445b5929a1c5c9f424 100644 (file)
@@ -122,7 +122,9 @@ fn restrict(&self,
             }
 
             mc::cat_deref(cmt_base, _, mc::BorrowedPtr(ty::ImmBorrow, lt)) |
-            mc::cat_deref(cmt_base, _, mc::BorrowedPtr(ty::UniqueImmBorrow, lt)) => {
+            mc::cat_deref(cmt_base, _, mc::BorrowedPtr(ty::UniqueImmBorrow, lt)) |
+            mc::cat_deref(cmt_base, _, mc::Implicit(ty::ImmBorrow, lt)) |
+            mc::cat_deref(cmt_base, _, mc::Implicit(ty::UniqueImmBorrow, lt)) => {
                 // R-Deref-Imm-Borrowed
                 if !self.bccx.is_subregion_of(self.loan_region, lt) {
                     self.bccx.report(
@@ -137,7 +139,8 @@ fn restrict(&self,
                 Safe
             }
 
-            mc::cat_deref(cmt_base, _, pk @ mc::BorrowedPtr(ty::MutBorrow, lt)) => {
+            mc::cat_deref(cmt_base, _, pk @ mc::BorrowedPtr(ty::MutBorrow, lt)) |
+            mc::cat_deref(cmt_base, _, pk @ mc::Implicit(ty::MutBorrow, lt)) => {
                 // R-Deref-Mut-Borrowed
                 if !self.bccx.is_subregion_of(self.loan_region, lt) {
                     self.bccx.report(
index d84c62f744edc21b4c49f1be1c03ce6f1ba6d4fc..8f01ee0564d19635e218d920b1d63486a1fe0910 100644 (file)
@@ -22,8 +22,7 @@
 use std::collections::HashSet;
 use syntax::ast;
 use syntax::ast_map;
-use syntax::ast_util;
-use syntax::ast_util::{local_def, is_local};
+use syntax::ast_util::{local_def, is_local, PostExpansionMethod};
 use syntax::attr::AttrMetaMethods;
 use syntax::attr;
 use syntax::codemap;
@@ -213,7 +212,7 @@ fn visit_node(&mut self, node: &ast_map::Node) {
                 visit::walk_trait_method(self, &*trait_method, ctxt);
             }
             ast_map::NodeMethod(method) => {
-                visit::walk_block(self, ast_util::method_body(&*method), ctxt);
+                visit::walk_block(self, method.pe_body(), ctxt);
             }
             ast_map::NodeForeignItem(foreign_item) => {
                 visit::walk_foreign_item(self, &*foreign_item, ctxt);
@@ -521,8 +520,7 @@ fn visit_struct_field(&mut self, field: &ast::StructField, _: ()) {
     // Overwrite so that we don't warn the trait method itself.
     fn visit_trait_method(&mut self, trait_method: &ast::TraitMethod, _: ()) {
         match *trait_method {
-            ast::Provided(ref method) => visit::walk_block(self,
-                                                           ast_util::method_body(&**method), ()),
+            ast::Provided(ref method) => visit::walk_block(self, method.pe_body(), ()),
             ast::Required(_) => ()
         }
     }
index 7ee8b33b1fa6713e6b0a597f1809d841ff027f35..914cf451ebe29380878c029370b34a4f2547e5ae 100644 (file)
@@ -14,7 +14,7 @@
 
 use std::gc::Gc;
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Def {
     DefFn(ast::DefId, ast::FnStyle),
     DefStaticMethod(/* method */ ast::DefId, MethodProvenance, ast::FnStyle),
@@ -51,7 +51,7 @@ pub enum Def {
     DefMethod(ast::DefId /* method */, Option<ast::DefId> /* trait */),
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum MethodProvenance {
     FromTrait(ast::DefId),
     FromImpl(ast::DefId),
index 415135a2d048f04ff4bb8ec38207b35fa03d7279..fed2f91ce098601ccb5f6b5e3d7dfd141f3a7acc 100644 (file)
@@ -17,7 +17,7 @@
 use util::ppaux;
 
 use syntax::ast;
-use syntax::ast_util;
+use syntax::ast_util::PostExpansionMethod;
 use syntax::codemap::Span;
 use syntax::visit;
 use syntax::visit::Visitor;
@@ -95,7 +95,7 @@ fn visit_fn(&mut self, fn_kind: &visit::FnKind, fn_decl: &ast::FnDecl,
             visit::FkItemFn(_, _, fn_style, _) =>
                 (true, fn_style == ast::UnsafeFn),
             visit::FkMethod(_, _, method) =>
-                (true, ast_util::method_fn_style(method) == ast::UnsafeFn),
+                (true, method.pe_fn_style() == ast::UnsafeFn),
             _ => (false, false),
         };
 
index d432ced5226cee32781cfffea24c12d9eedfa8d8..4f7cb742d8f86dca5cb3d2081459cf93d7f9fdf8 100644 (file)
@@ -87,7 +87,8 @@ fn check_struct_safe_for_destructor(cx: &mut Context,
                                     span: Span,
                                     struct_did: DefId) {
     let struct_tpt = ty::lookup_item_type(cx.tcx, struct_did);
-    if !struct_tpt.generics.has_type_params(subst::TypeSpace) {
+    if !struct_tpt.generics.has_type_params(subst::TypeSpace)
+      && !struct_tpt.generics.has_region_params(subst::TypeSpace) {
         let struct_ty = ty::mk_struct(cx.tcx, struct_did,
                                       subst::Substs::empty());
         if !ty::type_is_sendable(cx.tcx, struct_ty) {
@@ -121,7 +122,7 @@ fn check_impl_of_trait(cx: &mut Context, it: &Item, trait_ref: &TraitRef, self_t
 
     // If this trait has builtin-kind supertraits, meet them.
     let self_ty: ty::t = ty::node_id_to_type(cx.tcx, it.id);
-    debug!("checking impl with self type {:?}", ty::get(self_ty).sty);
+    debug!("checking impl with self type {}", ty::get(self_ty).sty);
     check_builtin_bounds(cx, self_ty, trait_def.bounds, |missing| {
         cx.tcx.sess.span_err(self_type.span,
             format!("the type `{}', which does not fulfill `{}`, cannot implement this \
index 33ab2ed3632405adaa0fa90286535f4ae84cb4fa..e928704b0ccf6d170ffb36815a529269aab1e153 100644 (file)
@@ -106,7 +106,8 @@ pub enum PointerKind {
     OwnedPtr,
     GcPtr,
     BorrowedPtr(ty::BorrowKind, ty::Region),
-    UnsafePtr(ast::Mutability),
+    Implicit(ty::BorrowKind, ty::Region),     // Implicit deref of a borrowed ptr.
+    UnsafePtr(ast::Mutability)
 }
 
 // We use the term "interior" to mean "something reachable from the
@@ -293,7 +294,7 @@ pub fn from_pointer_kind(base_mutbl: MutabilityCategory,
             OwnedPtr => {
                 base_mutbl.inherit()
             }
-            BorrowedPtr(borrow_kind, _) => {
+            BorrowedPtr(borrow_kind, _) | Implicit(borrow_kind, _) => {
                 MutabilityCategory::from_borrow_kind(borrow_kind)
             }
             GcPtr => {
@@ -422,7 +423,7 @@ pub fn cat_expr_autoderefd(&self,
                                -> McResult<cmt> {
         let mut cmt = if_ok!(self.cat_expr_unadjusted(expr));
         for deref in range(1u, autoderefs + 1) {
-            cmt = self.cat_deref(expr, cmt, deref);
+            cmt = self.cat_deref(expr, cmt, deref, false);
         }
         return Ok(cmt);
     }
@@ -434,7 +435,7 @@ pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult<cmt> {
         match expr.node {
           ast::ExprUnary(ast::UnDeref, ref e_base) => {
             let base_cmt = if_ok!(self.cat_expr(&**e_base));
-            Ok(self.cat_deref(expr, base_cmt, 0))
+            Ok(self.cat_deref(expr, base_cmt, 0, false))
           }
 
           ast::ExprField(ref base, f_name, _) => {
@@ -443,8 +444,22 @@ pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult<cmt> {
           }
 
           ast::ExprIndex(ref base, _) => {
-            let base_cmt = if_ok!(self.cat_expr(&**base));
-            Ok(self.cat_index(expr, base_cmt, 0))
+            let method_call = typeck::MethodCall::expr(expr.id());
+            match self.typer.node_method_ty(method_call) {
+                Some(method_ty) => {
+                    // If this is an index implemented by a method call, then it will
+                    // include an implicit deref of the result.
+                    let ret_ty = ty::ty_fn_ret(method_ty);
+                    Ok(self.cat_deref(expr,
+                                      self.cat_rvalue_node(expr.id(),
+                                                           expr.span(),
+                                                           ret_ty), 1, true))
+                }
+                None => {
+                    let base_cmt = if_ok!(self.cat_expr(&**base));
+                    Ok(self.cat_index(expr, base_cmt, 0))
+                }
+            }
           }
 
           ast::ExprPath(_) => {
@@ -687,13 +702,14 @@ pub fn cat_field<N:ast_node>(&self,
     }
 
     pub fn cat_deref_obj<N:ast_node>(&self, node: &N, base_cmt: cmt) -> cmt {
-        self.cat_deref_common(node, base_cmt, 0, ty::mk_nil())
+        self.cat_deref_common(node, base_cmt, 0, ty::mk_nil(), false)
     }
 
     fn cat_deref<N:ast_node>(&self,
                              node: &N,
                              base_cmt: cmt,
-                             deref_cnt: uint)
+                             deref_cnt: uint,
+                             implicit: bool)
                              -> cmt {
         let adjustment = match self.typer.adjustments().borrow().find(&node.id()) {
             Some(&ty::AutoObject(..)) => typeck::AutoObject,
@@ -717,7 +733,7 @@ fn cat_deref<N:ast_node>(&self,
             None => base_cmt
         };
         match ty::deref(base_cmt.ty, true) {
-            Some(mt) => self.cat_deref_common(node, base_cmt, deref_cnt, mt.ty),
+            Some(mt) => self.cat_deref_common(node, base_cmt, deref_cnt, mt.ty, implicit),
             None => {
                 self.tcx().sess.span_bug(
                     node.span(),
@@ -731,10 +747,20 @@ fn cat_deref_common<N:ast_node>(&self,
                                     node: &N,
                                     base_cmt: cmt,
                                     deref_cnt: uint,
-                                    deref_ty: ty::t)
+                                    deref_ty: ty::t,
+                                    implicit: bool)
                                     -> cmt {
         let (m, cat) = match deref_kind(self.tcx(), base_cmt.ty) {
             deref_ptr(ptr) => {
+                let ptr = if implicit {
+                    match ptr {
+                        BorrowedPtr(bk, r) => Implicit(bk, r),
+                        _ => self.tcx().sess.span_bug(node.span(),
+                            "Implicit deref of non-borrowed pointer")
+                    }
+                } else {
+                    ptr
+                };
                 // for unique ptrs, we inherit mutability from the
                 // owning reference.
                 (MutabilityCategory::from_pointer_kind(base_cmt.mutbl, ptr),
@@ -1073,7 +1099,7 @@ pub fn cat_pattern(&self,
 
           ast::PatBox(ref subpat) | ast::PatRegion(ref subpat) => {
             // @p1, ~p1
-            let subcmt = self.cat_deref(pat, cmt, 0);
+            let subcmt = self.cat_deref(pat, cmt, 0, false);
             if_ok!(self.cat_pattern(subcmt, &**subpat, op));
           }
 
@@ -1129,6 +1155,9 @@ pub fn cmt_to_string(&self, cmt: &cmt_) -> String {
                   }
                   _ => {
                       match pk {
+                          Implicit(..) => {
+                            "dereference (dereference is implicit, due to indexing)".to_string()
+                          }
                           OwnedPtr | GcPtr => format!("dereference of `{}`", ptr_sigil(pk)),
                           _ => format!("dereference of `{}`-pointer", ptr_sigil(pk))
                       }
@@ -1188,6 +1217,7 @@ pub fn guarantor(&self) -> cmt {
             cat_deref(_, _, UnsafePtr(..)) |
             cat_deref(_, _, GcPtr(..)) |
             cat_deref(_, _, BorrowedPtr(..)) |
+            cat_deref(_, _, Implicit(..)) |
             cat_upvar(..) => {
                 Rc::new((*self).clone())
             }
@@ -1212,7 +1242,9 @@ pub fn freely_aliasable(&self, ctxt: &ty::ctxt) -> Option<AliasableReason> {
 
         match self.cat {
             cat_deref(ref b, _, BorrowedPtr(ty::MutBorrow, _)) |
+            cat_deref(ref b, _, Implicit(ty::MutBorrow, _)) |
             cat_deref(ref b, _, BorrowedPtr(ty::UniqueImmBorrow, _)) |
+            cat_deref(ref b, _, Implicit(ty::UniqueImmBorrow, _)) |
             cat_downcast(ref b) |
             cat_deref(ref b, _, OwnedPtr) |
             cat_interior(ref b, _) |
@@ -1252,7 +1284,8 @@ pub fn freely_aliasable(&self, ctxt: &ty::ctxt) -> Option<AliasableReason> {
                 Some(AliasableManaged)
             }
 
-            cat_deref(_, _, BorrowedPtr(ty::ImmBorrow, _)) => {
+            cat_deref(_, _, BorrowedPtr(ty::ImmBorrow, _)) |
+            cat_deref(_, _, Implicit(ty::ImmBorrow, _)) => {
                 Some(AliasableBorrowed)
             }
         }
@@ -1300,9 +1333,12 @@ pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
     match ptr {
         OwnedPtr => "Box",
         GcPtr => "Gc",
-        BorrowedPtr(ty::ImmBorrow, _) => "&",
-        BorrowedPtr(ty::MutBorrow, _) => "&mut",
-        BorrowedPtr(ty::UniqueImmBorrow, _) => "&unique",
+        BorrowedPtr(ty::ImmBorrow, _) |
+        Implicit(ty::ImmBorrow, _) => "&",
+        BorrowedPtr(ty::MutBorrow, _) |
+        Implicit(ty::MutBorrow, _) => "&mut",
+        BorrowedPtr(ty::UniqueImmBorrow, _) |
+        Implicit(ty::UniqueImmBorrow, _) => "&unique",
         UnsafePtr(_) => "*"
     }
 }
index 580e7b2db57c294a772070b04eba0189916541db..74ca13a082135b3e6a2f6a3138fccd804d866964 100644 (file)
@@ -26,8 +26,7 @@
 
 use syntax::ast;
 use syntax::ast_map;
-use syntax::ast_util;
-use syntax::ast_util::{is_local, local_def};
+use syntax::ast_util::{is_local, local_def, PostExpansionMethod};
 use syntax::attr;
 use syntax::codemap::Span;
 use syntax::parse::token;
@@ -264,10 +263,10 @@ fn visit_item(&mut self, item: &ast::Item, _: ()) {
 
                 if public_ty || public_trait {
                     for method in methods.iter() {
-                        let meth_public = match ast_util::method_explicit_self(&**method).node {
+                        let meth_public = match method.pe_explicit_self().node {
                             ast::SelfStatic => public_ty,
                             _ => true,
-                        } && ast_util::method_vis(&**method) == ast::Public;
+                        } && method.pe_vis() == ast::Public;
                         if meth_public || tr.is_some() {
                             self.exported_items.insert(method.id);
                         }
@@ -457,8 +456,8 @@ fn def_privacy(&self, did: ast::DefId) -> PrivacyResult {
                     let imp = self.tcx.map.get_parent_did(closest_private_id);
                     match ty::impl_trait_ref(self.tcx, imp) {
                         Some(..) => return Allowable,
-                        _ if ast_util::method_vis(&**m) == ast::Public => return Allowable,
-                        _ => ast_util::method_vis(&**m)
+                        _ if m.pe_vis() == ast::Public => return Allowable,
+                        _ => m.pe_vis()
                     }
                 }
                 Some(ast_map::NodeTraitMethod(_)) => {
@@ -1079,7 +1078,7 @@ fn check_sane_privacy(&self, item: &ast::Item) {
                                 "visibility qualifiers have no effect on trait \
                                  impls");
                 for m in methods.iter() {
-                    check_inherited(m.span, ast_util::method_vis(&**m), "");
+                    check_inherited(m.span, m.pe_vis(), "");
                 }
             }
 
@@ -1111,7 +1110,7 @@ fn check_sane_privacy(&self, item: &ast::Item) {
                 for m in methods.iter() {
                     match *m {
                         ast::Provided(ref m) => {
-                            check_inherited(m.span, ast_util::method_vis(&**m),
+                            check_inherited(m.span, m.pe_vis(),
                                             "unnecessary visibility");
                         }
                         ast::Required(ref m) => {
@@ -1149,7 +1148,7 @@ fn check_inherited(tcx: &ty::ctxt, sp: Span, vis: ast::Visibility) {
         match item.node {
             ast::ItemImpl(_, _, _, ref methods) => {
                 for m in methods.iter() {
-                    check_inherited(tcx, m.span, ast_util::method_vis(&**m));
+                    check_inherited(tcx, m.span, m.pe_vis());
                 }
             }
             ast::ItemForeignMod(ref fm) => {
@@ -1175,7 +1174,7 @@ fn check_inherited(tcx: &ty::ctxt, sp: Span, vis: ast::Visibility) {
                     match *m {
                         ast::Required(..) => {}
                         ast::Provided(ref m) => check_inherited(tcx, m.span,
-                                                                ast_util::method_vis(&**m)),
+                                                                m.pe_vis()),
                     }
                 }
             }
@@ -1345,7 +1344,7 @@ fn visit_item(&mut self, item: &ast::Item, _: ()) {
                     // methods will be visible as `Public::foo`.
                     let mut found_pub_static = false;
                     for method in methods.iter() {
-                        if ast_util::method_explicit_self(&**method).node == ast::SelfStatic &&
+                        if method.pe_explicit_self().node == ast::SelfStatic &&
                             self.exported_items.contains(&method.id) {
                             found_pub_static = true;
                             visit::walk_method_helper(self, &**method, ());
index d9324574da73f78a4afd9de153ac5c026831c1b3..b228a82bdf7b1bf7fd39ded7367dc2bf9ce0989d 100644 (file)
@@ -26,7 +26,7 @@
 use syntax::abi;
 use syntax::ast;
 use syntax::ast_map;
-use syntax::ast_util::is_local;
+use syntax::ast_util::{is_local, PostExpansionMethod};
 use syntax::ast_util;
 use syntax::attr::{InlineAlways, InlineHint, InlineNever, InlineNone};
 use syntax::attr;
@@ -68,7 +68,7 @@ fn item_might_be_inlined(item: &ast::Item) -> bool {
 fn method_might_be_inlined(tcx: &ty::ctxt, method: &ast::Method,
                            impl_src: ast::DefId) -> bool {
     if attributes_specify_inlining(method.attrs.as_slice()) ||
-        generics_require_inlining(ast_util::method_generics(&*method)) {
+        generics_require_inlining(method.pe_generics()) {
         return true
     }
     if is_local(impl_src) {
@@ -200,7 +200,7 @@ fn def_id_represents_local_inlined_item(&self, def_id: ast::DefId) -> bool {
                 }
             }
             Some(ast_map::NodeMethod(method)) => {
-                if generics_require_inlining(ast_util::method_generics(&*method)) ||
+                if generics_require_inlining(method.pe_generics()) ||
                         attributes_specify_inlining(method.attrs.as_slice()) {
                     true
                 } else {
@@ -316,14 +316,14 @@ fn propagate_node(&mut self, node: &ast_map::Node,
                         // Keep going, nothing to get exported
                     }
                     ast::Provided(ref method) => {
-                        visit::walk_block(self, ast_util::method_body(&**method), ())
+                        visit::walk_block(self, method.pe_body(), ())
                     }
                 }
             }
             ast_map::NodeMethod(method) => {
                 let did = self.tcx.map.get_parent_did(search_item);
                 if method_might_be_inlined(self.tcx, &*method, did) {
-                    visit::walk_block(self, ast_util::method_body(&*method), ())
+                    visit::walk_block(self, method.pe_body(), ())
                 }
             }
             // Nothing to recurse on for these
index df4d3b7efe432ea6ffada1db2c3bac9569f4bc8e..822a43f2619dc4496ff7d0fa68b4d3b1d519e553 100644 (file)
@@ -314,6 +314,16 @@ pub fn is_subregion_of(&self,
                     self.sub_free_region(sub_fr, super_fr)
                 }
 
+                (ty::ReEarlyBound(param_id_a, param_space_a, index_a, _),
+                 ty::ReEarlyBound(param_id_b, param_space_b, index_b, _)) => {
+                    // This case is used only to make sure that explicitly-
+                    // specified `Self` types match the real self type in
+                    // implementations.
+                    param_id_a == param_id_b &&
+                        param_space_a == param_space_b &&
+                        index_a == index_b
+                }
+
                 _ => {
                     false
                 }
index 6c6ac81b985303ba6b3dd38eb8a67bf8841953e5..f00d7c36f53339efd8f75796bd27cee7f27ae3ce 100644 (file)
 #![allow(non_camel_case_types)]
 
 use driver::session::Session;
+use lint;
 use metadata::csearch;
 use metadata::decoder::{DefLike, DlDef, DlField, DlImpl};
 use middle::def::*;
 use middle::lang_items::LanguageItems;
 use middle::pat_util::pat_bindings;
 use middle::subst::{ParamSpace, FnSpace, TypeSpace};
-use lint;
+use middle::ty::{ExplicitSelfCategory, StaticExplicitSelfCategory};
 use util::nodemap::{NodeMap, DefIdSet, FnvHashMap};
 
 use syntax::ast::*;
 use syntax::ast;
-use syntax::ast_util;
-use syntax::ast_util::{local_def};
+use syntax::ast_util::{local_def, PostExpansionMethod};
 use syntax::ast_util::{walk_pat, trait_method_to_ty_method};
 use syntax::ext::mtwt;
 use syntax::parse::token::special_names;
@@ -288,6 +288,24 @@ enum ModulePrefixResult {
     PrefixFound(Rc<Module>, uint)
 }
 
+#[deriving(Clone, Eq, PartialEq)]
+enum MethodIsStaticFlag {
+    MethodIsNotStatic,
+    MethodIsStatic,
+}
+
+impl MethodIsStaticFlag {
+    fn from_explicit_self_category(explicit_self_category:
+                                   ExplicitSelfCategory)
+                                   -> MethodIsStaticFlag {
+        if explicit_self_category == StaticExplicitSelfCategory {
+            MethodIsStatic
+        } else {
+            MethodIsNotStatic
+        }
+    }
+}
+
 #[deriving(PartialEq)]
 enum NameSearchType {
     /// We're doing a name search in order to resolve a `use` directive.
@@ -806,7 +824,8 @@ struct Resolver<'a> {
 
     graph_root: NameBindings,
 
-    method_map: RefCell<FnvHashMap<(Name, DefId), ast::ExplicitSelf_>>,
+    method_map: RefCell<FnvHashMap<(Name, DefId), MethodIsStaticFlag>>,
+
     structs: FnvHashMap<DefId, Vec<Name>>,
 
     // The number of imports that are currently unresolved.
@@ -1299,20 +1318,20 @@ fn build_reduced_graph_for_item(&mut self,
                         // For each method...
                         for method in methods.iter() {
                             // Add the method to the module.
-                            let ident = ast_util::method_ident(&**method);
+                            let ident = method.pe_ident();
                             let method_name_bindings =
                                 self.add_child(ident,
                                                new_parent.clone(),
                                                ForbidDuplicateValues,
                                                method.span);
-                            let def = match ast_util::method_explicit_self(&**method).node {
+                            let def = match method.pe_explicit_self().node {
                                 SelfStatic => {
                                     // Static methods become
                                     // `def_static_method`s.
                                     DefStaticMethod(local_def(method.id),
                                                       FromImpl(local_def(
                                                         item.id)),
-                                                    ast_util::method_fn_style(&**method))
+                                                      method.pe_fn_style())
                                 }
                                 _ => {
                                     // Non-static methods become
@@ -1321,7 +1340,7 @@ fn build_reduced_graph_for_item(&mut self,
                                 }
                             };
 
-                            let is_public = ast_util::method_vis(&**method) == ast::Public;
+                            let is_public = method.pe_vis() == ast::Public;
                             method_name_bindings.define_value(def,
                                                               method.span,
                                                               is_public);
@@ -1362,17 +1381,19 @@ fn build_reduced_graph_for_item(&mut self,
                     let ident = ty_m.ident;
 
                     // Add it as a name in the trait module.
-                    let def = match ty_m.explicit_self.node {
+                    let (def, static_flag) = match ty_m.explicit_self.node {
                         SelfStatic => {
                             // Static methods become `def_static_method`s.
-                            DefStaticMethod(local_def(ty_m.id),
+                            (DefStaticMethod(local_def(ty_m.id),
                                               FromTrait(local_def(item.id)),
-                                              ty_m.fn_style)
+                                              ty_m.fn_style),
+                             MethodIsStatic)
                         }
                         _ => {
                             // Non-static methods become `def_method`s.
-                            DefMethod(local_def(ty_m.id),
-                                       Some(local_def(item.id)))
+                            (DefMethod(local_def(ty_m.id),
+                                       Some(local_def(item.id))),
+                             MethodIsNotStatic)
                         }
                     };
 
@@ -1383,8 +1404,9 @@ fn build_reduced_graph_for_item(&mut self,
                                        ty_m.span);
                     method_name_bindings.define_value(def, ty_m.span, true);
 
-                    self.method_map.borrow_mut().insert((ident.name, def_id),
-                                                        ty_m.explicit_self.node);
+                    self.method_map
+                        .borrow_mut()
+                        .insert((ident.name, def_id), static_flag);
                 }
 
                 name_bindings.define_type(DefTrait(def_id), sp, is_public);
@@ -1671,7 +1693,11 @@ fn handle_external_def(&mut self,
                           trait method '{}'",
                          token::get_ident(method_name));
 
-                  self.method_map.borrow_mut().insert((method_name.name, def_id), explicit_self);
+                  self.method_map
+                      .borrow_mut()
+                      .insert((method_name.name, def_id),
+                              MethodIsStaticFlag::from_explicit_self_category(
+                                  explicit_self));
 
                   if is_exported {
                       self.external_exports.insert(method_def_id);
@@ -3679,6 +3705,13 @@ fn resolve_item(&mut self, item: &Item) {
                                     this.resolve_type(&*argument.ty);
                                 }
 
+                                match ty_m.explicit_self.node {
+                                    SelfExplicit(ref typ, _) => {
+                                        this.resolve_type(*typ)
+                                    }
+                                    _ => {}
+                                }
+
                                 this.resolve_type(&*ty_m.decl.output);
                             });
                           }
@@ -4004,15 +4037,21 @@ fn resolve_struct(&mut self,
     fn resolve_method(&mut self,
                       rib_kind: RibKind,
                       method: &Method) {
-        let method_generics = ast_util::method_generics(method);
+        let method_generics = method.pe_generics();
         let type_parameters = HasTypeParameters(method_generics,
                                                 FnSpace,
                                                 method.id,
                                                 rib_kind);
 
-        self.resolve_function(rib_kind, Some(ast_util::method_fn_decl(method)),
+        match method.pe_explicit_self().node {
+            SelfExplicit(ref typ, _) => self.resolve_type(*typ),
+            _ => {}
+        }
+
+        self.resolve_function(rib_kind,
+                              Some(method.pe_fn_decl()),
                               type_parameters,
-                              ast_util::method_body(method));
+                              method.pe_body());
     }
 
     fn with_current_self_type<T>(&mut self, self_type: &Ty, f: |&mut Resolver| -> T) -> T {
@@ -4083,7 +4122,7 @@ fn resolve_implementation(&mut self,
     fn check_trait_method(&self, method: &Method) {
         // If there is a TraitRef in scope for an impl, then the method must be in the trait.
         for &(did, ref trait_ref) in self.current_trait_ref.iter() {
-            let method_name = ast_util::method_ident(method).name;
+            let method_name = method.pe_ident().name;
 
             if self.method_map.borrow().find(&(method_name, did)).is_none() {
                 let path_str = self.path_idents_to_string(&trait_ref.path);
@@ -4767,7 +4806,7 @@ fn resolve_module_relative_path(&mut self,
                 match containing_module.def_id.get() {
                     Some(def_id) => {
                         match self.method_map.borrow().find(&(ident.name, def_id)) {
-                            Some(x) if *x == SelfStatic => (),
+                            Some(&MethodIsStatic) => (),
                             None => (),
                             _ => {
                                 debug!("containing module was a trait or impl \
@@ -5039,7 +5078,7 @@ fn get_module(this: &mut Resolver, span: Span, ident_path: &[ast::Ident])
                 let path_str = self.path_idents_to_string(&trait_ref.path);
 
                 match method_map.find(&(name, did)) {
-                    Some(&SelfStatic) => return StaticTraitMethod(path_str),
+                    Some(&MethodIsStatic) => return StaticTraitMethod(path_str),
                     Some(_) => return TraitMethod,
                     None => {}
                 }
index a492b4ab9525e193ef67e9dced2af4aa342d8db7..9ae2a4c62cd546b022ec93109f49e83bda55fceb 100644 (file)
@@ -43,6 +43,7 @@
 
 use syntax::ast;
 use syntax::ast_util;
+use syntax::ast_util::PostExpansionMethod;
 use syntax::ast::{NodeId,DefId};
 use syntax::ast_map::NodeItem;
 use syntax::attr;
@@ -333,7 +334,7 @@ fn process_method(&mut self, method: &ast::Method, e:DxrVisitorEnv) {
             },
         };
 
-        qualname.push_str(get_ident(ast_util::method_ident(&*method)).get());
+        qualname.push_str(get_ident(method.pe_ident()).get());
         let qualname = qualname.as_slice();
 
         // record the decl for this def (if it has one)
@@ -349,18 +350,17 @@ fn process_method(&mut self, method: &ast::Method, e:DxrVisitorEnv) {
                             decl_id,
                             scope_id);
 
-        let m_decl = ast_util::method_fn_decl(&*method);
-        self.process_formals(&m_decl.inputs, qualname, e);
+        self.process_formals(&method.pe_fn_decl().inputs, qualname, e);
 
         // walk arg and return types
-        for arg in m_decl.inputs.iter() {
+        for arg in method.pe_fn_decl().inputs.iter() {
             self.visit_ty(&*arg.ty, e);
         }
-        self.visit_ty(m_decl.output, e);
+        self.visit_ty(method.pe_fn_decl().output, e);
         // walk the fn body
-        self.visit_block(ast_util::method_body(&*method), DxrVisitorEnv::new_nested(method.id));
+        self.visit_block(method.pe_body(), DxrVisitorEnv::new_nested(method.id));
 
-        self.process_generic_params(ast_util::method_generics(&*method),
+        self.process_generic_params(method.pe_generics(),
                                     method.span,
                                     qualname,
                                     method.id,
index 4684bd3532ec13ebb9daedfbb227b958c0da7031..5c2a70a46fdc8c95e8c712182cb5e07997f97526 100644 (file)
@@ -15,6 +15,7 @@
 use middle::ty_fold::{TypeFoldable, TypeFolder};
 use util::ppaux::Repr;
 
+use std::fmt;
 use std::mem;
 use std::raw;
 use std::slice::{Items, MutItems};
@@ -83,7 +84,7 @@ fn get_mut<'a>(&'a mut self, index: uint) -> Option<&'a mut T> {
  * space* (which indices where the parameter is defined; see
  * `ParamSpace`).
  */
-#[deriving(Clone, PartialEq, Eq, Hash)]
+#[deriving(Clone, PartialEq, Eq, Hash, Show)]
 pub struct Substs {
     pub types: VecPerParamSpace<ty::t>,
     pub regions: RegionSubsts,
@@ -93,7 +94,7 @@ pub struct Substs {
  * Represents the values to use when substituting lifetime parameters.
  * If the value is `ErasedRegions`, then this subst is occurring during
  * trans, and all region parameters will be replaced with `ty::ReStatic`. */
-#[deriving(Clone, PartialEq, Eq, Hash)]
+#[deriving(Clone, PartialEq, Eq, Hash, Show)]
 pub enum RegionSubsts {
     ErasedRegions,
     NonerasedRegions(VecPerParamSpace<ty::Region>)
@@ -275,6 +276,17 @@ pub struct VecPerParamSpace<T> {
     content: Vec<T>,
 }
 
+impl<T:fmt::Show> fmt::Show for VecPerParamSpace<T> {
+    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+        try!(write!(fmt, "VecPerParamSpace {{"));
+        for space in ParamSpace::all().iter() {
+            try!(write!(fmt, "{}: {}, ", *space, self.get_slice(*space)));
+        }
+        try!(write!(fmt, "}}"));
+        Ok(())
+    }
+}
+
 impl<T:Clone> VecPerParamSpace<T> {
     pub fn push_all(&mut self, space: ParamSpace, values: &[T]) {
         // FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n).
@@ -558,10 +570,22 @@ fn fold_region(&mut self, r: ty::Region) -> ty::Region {
         // the specialized routine
         // `middle::typeck::check::regionmanip::replace_late_regions_in_fn_sig()`.
         match r {
-            ty::ReEarlyBound(_, space, i, _) => {
+            ty::ReEarlyBound(_, space, i, region_name) => {
                 match self.substs.regions {
                     ErasedRegions => ty::ReStatic,
-                    NonerasedRegions(ref regions) => *regions.get(space, i),
+                    NonerasedRegions(ref regions) =>
+                        match regions.opt_get(space, i) {
+                            Some(t) => *t,
+                            None => {
+                                let span = self.span.unwrap_or(DUMMY_SP);
+                                self.tcx().sess.span_bug(
+                                    span,
+                                    format!("Type parameter out of range \
+                                     when substituting in region {} (root type={})",
+                                    region_name.as_str(),
+                                    self.root_ty.repr(self.tcx())).as_slice());
+                            }
+                        }
                 }
             }
             _ => r
index 6bcc9b9b745b7f5e438842de8b7bbcb9774c4a6e..3ca188cf2813afbdcae39d8e35cda3dd7aa235a7 100644 (file)
@@ -193,6 +193,14 @@ fn decl_fn(ccx: &CrateContext, name: &str, cc: llvm::CallConv,
         _ => {}
     }
 
+    if ccx.tcx.sess.opts.cg.no_redzone {
+        unsafe {
+            llvm::LLVMAddFunctionAttribute(llfn,
+                                           llvm::FunctionIndex as c_uint,
+                                           llvm::NoRedZoneAttribute as uint64_t)
+        }
+    }
+
     llvm::SetFunctionCallConv(llfn, cc);
     // Function addresses in Rust are never significant, allowing functions to be merged.
     llvm::SetUnnamedAddr(llfn, true);
index 6e81c10c4a0a91a80e5a871b742c36f1e7adcb25..49b6f02356091ce2acafcb286008b60d4a0198e4 100644 (file)
@@ -207,6 +207,7 @@ struct List {
 use syntax::util::interner::Interner;
 use syntax::codemap::{Span, Pos};
 use syntax::{abi, ast, codemap, ast_util, ast_map};
+use syntax::ast_util::PostExpansionMethod;
 use syntax::owned_slice::OwnedSlice;
 use syntax::parse::token;
 use syntax::parse::token::special_idents;
@@ -1138,10 +1139,10 @@ pub fn create_function_debug_context(cx: &CrateContext,
             }
         }
         ast_map::NodeMethod(ref method) => {
-            (ast_util::method_ident(&**method),
-             ast_util::method_fn_decl(&**method),
-             ast_util::method_generics(&**method),
-             ast_util::method_body(&**method),
+            (method.pe_ident(),
+             method.pe_fn_decl(),
+             method.pe_generics(),
+             method.pe_body(),
              method.span,
              true)
         }
@@ -1167,10 +1168,10 @@ pub fn create_function_debug_context(cx: &CrateContext,
         ast_map::NodeTraitMethod(ref trait_method) => {
             match **trait_method {
                 ast::Provided(ref method) => {
-                    (ast_util::method_ident(&**method),
-                     ast_util::method_fn_decl(&**method),
-                     ast_util::method_generics(&**method),
-                     ast_util::method_body(&**method),
+                    (method.pe_ident(),
+                     method.pe_fn_decl(),
+                     method.pe_generics(),
+                     method.pe_body(),
                      method.span,
                      true)
                 }
index d64eeb727e733bdc6820a4c77c8336911a47d9eb..bf39f3a6aa385842d1d2a838aafe61dcbffa9648 100644 (file)
@@ -16,7 +16,7 @@
 use middle::ty;
 
 use syntax::ast;
-use syntax::ast_util::local_def;
+use syntax::ast_util::{local_def, PostExpansionMethod};
 use syntax::ast_util;
 
 pub fn maybe_instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
@@ -128,12 +128,11 @@ pub fn maybe_instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
             let impl_tpt = ty::lookup_item_type(ccx.tcx(), impl_did);
             let unparameterized =
                 impl_tpt.generics.types.is_empty() &&
-                ast_util::method_generics(&*mth).ty_params.is_empty();
+                mth.pe_generics().ty_params.is_empty();
 
           if unparameterized {
               let llfn = get_item_val(ccx, mth.id);
-              trans_fn(ccx, ast_util::method_fn_decl(&*mth),
-                       ast_util::method_body(&*mth), llfn,
+                trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), llfn,
                        &param_substs::empty(), mth.id, []);
           }
           local_def(mth.id)
index 092a524e48a1898476d7c283cbfa92cb20735415..53f0645cb87026321b4a7c78dfa96a16e5b13725 100644 (file)
@@ -37,7 +37,8 @@
 use std::gc::Gc;
 use syntax::abi::Rust;
 use syntax::parse::token;
-use syntax::{ast, ast_map, visit, ast_util};
+use syntax::{ast, ast_map, visit};
+use syntax::ast_util::PostExpansionMethod;
 
 /**
 The main "translation" pass for methods.  Generates code
@@ -65,10 +66,9 @@ pub fn trans_impl(ccx: &CrateContext,
         return;
     }
     for method in methods.iter() {
-        if ast_util::method_generics(&**method).ty_params.len() == 0u {
+        if method.pe_generics().ty_params.len() == 0u {
             let llfn = get_item_val(ccx, method.id);
-            trans_fn(ccx, ast_util::method_fn_decl(&**method),
-                     ast_util::method_body(&**method),
+            trans_fn(ccx, method.pe_fn_decl(), method.pe_body(),
                      llfn, &param_substs::empty(), method.id, []);
         } else {
             let mut v = TransItemVisitor{ ccx: ccx };
@@ -160,7 +160,7 @@ pub fn trans_static_method_callee(bcx: &Block,
             ast_map::NodeTraitMethod(method) => {
                 let ident = match *method {
                     ast::Required(ref m) => m.ident,
-                    ast::Provided(ref m) => ast_util::method_ident(&**m)
+                    ast::Provided(ref m) => m.pe_ident()
                 };
                 ident.name
             }
@@ -502,15 +502,12 @@ fn emit_vtable_methods(bcx: &Block,
                                                        ExprId(0),
                                                        substs.clone(),
                                                        vtables.clone());
-            match m.explicit_self {
-                ast::SelfValue(_) => {
-                    fn_ref = trans_unboxing_shim(bcx,
-                                                 fn_ref,
-                                                 &*m,
-                                                 m_id,
-                                                 substs.clone());
-                },
-                _ => {}
+            if m.explicit_self == ty::ByValueExplicitSelfCategory {
+                fn_ref = trans_unboxing_shim(bcx,
+                                             fn_ref,
+                                             &*m,
+                                             m_id,
+                                             substs.clone());
             }
             fn_ref
         }
index 7687e82654a9201e3e891927116951e53d08745e..6ff6c4741c77c87763a26dd7037be321db638825 100644 (file)
@@ -25,8 +25,7 @@
 use syntax::abi;
 use syntax::ast;
 use syntax::ast_map;
-use syntax::ast_util;
-use syntax::ast_util::local_def;
+use syntax::ast_util::{local_def, PostExpansionMethod};
 use std::hash::{sip, Hash};
 
 pub fn monomorphic_fn(ccx: &CrateContext,
@@ -182,8 +181,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
         ast_map::NodeMethod(mth) => {
             let d = mk_lldecl();
             set_llvm_fn_attrs(mth.attrs.as_slice(), d);
-            trans_fn(ccx, ast_util::method_fn_decl(&*mth),
-                     ast_util::method_body(&*mth), d, &psubsts, mth.id, []);
+            trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d, &psubsts, mth.id, []);
             d
         }
         ast_map::NodeTraitMethod(method) => {
@@ -191,8 +189,8 @@ pub fn monomorphic_fn(ccx: &CrateContext,
                 ast::Provided(mth) => {
                     let d = mk_lldecl();
                     set_llvm_fn_attrs(mth.attrs.as_slice(), d);
-                    trans_fn(ccx, ast_util::method_fn_decl(&*mth),
-                             ast_util::method_body(&*mth), d, &psubsts, mth.id, []);
+                    trans_fn(ccx, &*mth.pe_fn_decl(), &*mth.pe_body(), d,
+                             &psubsts, mth.id, []);
                     d
                 }
                 _ => {
index eee53b79763be9b023825311b25d24963bf5bdfe..cfafe99090d58d99bb627b5115d581813f8948ec 100644 (file)
@@ -85,7 +85,7 @@ pub struct Method {
     pub ident: ast::Ident,
     pub generics: ty::Generics,
     pub fty: BareFnTy,
-    pub explicit_self: ast::ExplicitSelf_,
+    pub explicit_self: ExplicitSelfCategory,
     pub vis: ast::Visibility,
     pub def_id: ast::DefId,
     pub container: MethodContainer,
@@ -98,7 +98,7 @@ impl Method {
     pub fn new(ident: ast::Ident,
                generics: ty::Generics,
                fty: BareFnTy,
-               explicit_self: ast::ExplicitSelf_,
+               explicit_self: ExplicitSelfCategory,
                vis: ast::Visibility,
                def_id: ast::DefId,
                container: MethodContainer,
@@ -124,7 +124,7 @@ pub fn container_id(&self) -> ast::DefId {
     }
 }
 
-#[deriving(Clone, PartialEq, Eq, Hash)]
+#[deriving(Clone, PartialEq, Eq, Hash, Show)]
 pub struct mt {
     pub ty: t,
     pub mutbl: ast::Mutability,
@@ -138,7 +138,7 @@ pub enum TraitStore {
     RegionTraitStore(Region, ast::Mutability),
 }
 
-#[deriving(Clone)]
+#[deriving(Clone, Show)]
 pub struct field_ty {
     pub name: Name,
     pub id: DefId,
@@ -311,6 +311,9 @@ pub struct ctxt {
     /// (inferred) variance.
     pub item_variance_map: RefCell<DefIdMap<Rc<ItemVariances>>>,
 
+    /// True if the variance has been computed yet; false otherwise.
+    pub variance_computed: Cell<bool>,
+
     /// A mapping from the def ID of an enum or struct type to the def ID
     /// of the method that implements its destructor. If the type is not
     /// present in this map, it does not have a destructor. This map is
@@ -394,6 +397,7 @@ pub enum tbox_flag {
 
 pub type t_box = &'static t_box_;
 
+#[deriving(Show)]
 pub struct t_box_ {
     pub sty: sty,
     pub id: uint,
@@ -436,14 +440,14 @@ pub fn type_needs_infer(t: t) -> bool {
 }
 pub fn type_id(t: t) -> uint { get(t).id }
 
-#[deriving(Clone, PartialEq, Eq, Hash)]
+#[deriving(Clone, PartialEq, Eq, Hash, Show)]
 pub struct BareFnTy {
     pub fn_style: ast::FnStyle,
     pub abi: abi::Abi,
     pub sig: FnSig,
 }
 
-#[deriving(Clone, PartialEq, Eq, Hash)]
+#[deriving(Clone, PartialEq, Eq, Hash, Show)]
 pub struct ClosureTy {
     pub fn_style: ast::FnStyle,
     pub onceness: ast::Onceness,
@@ -472,7 +476,7 @@ pub struct FnSig {
     pub variadic: bool
 }
 
-#[deriving(Clone, PartialEq, Eq, Hash)]
+#[deriving(Clone, PartialEq, Eq, Hash, Show)]
 pub struct ParamTy {
     pub space: subst::ParamSpace,
     pub idx: uint,
@@ -712,7 +716,7 @@ macro_rules! def_prim_ty(
 
 // NB: If you change this, you'll probably want to change the corresponding
 // AST structure in libsyntax/ast.rs as well.
-#[deriving(Clone, PartialEq, Eq, Hash)]
+#[deriving(Clone, PartialEq, Eq, Hash, Show)]
 pub enum sty {
     ty_nil,
     ty_bot,
@@ -741,14 +745,14 @@ pub enum sty {
             // on non-useful type error messages)
 }
 
-#[deriving(Clone, PartialEq, Eq, Hash)]
+#[deriving(Clone, PartialEq, Eq, Hash, Show)]
 pub struct TyTrait {
     pub def_id: DefId,
     pub substs: Substs,
     pub bounds: BuiltinBounds
 }
 
-#[deriving(PartialEq, Eq, Hash)]
+#[deriving(PartialEq, Eq, Hash, Show)]
 pub struct TraitRef {
     pub def_id: DefId,
     pub substs: Substs,
@@ -808,7 +812,7 @@ pub enum type_err {
     terr_variadic_mismatch(expected_found<bool>)
 }
 
-#[deriving(PartialEq, Eq, Hash)]
+#[deriving(PartialEq, Eq, Hash, Show)]
 pub struct ParamBounds {
     pub builtin_bounds: BuiltinBounds,
     pub trait_bounds: Vec<Rc<TraitRef>>
@@ -948,7 +952,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-#[deriving(Clone)]
+#[deriving(Clone, Show)]
 pub struct TypeParameterDef {
     pub ident: ast::Ident,
     pub def_id: ast::DefId,
@@ -958,7 +962,7 @@ pub struct TypeParameterDef {
     pub default: Option<ty::t>
 }
 
-#[deriving(Encodable, Decodable, Clone)]
+#[deriving(Encodable, Decodable, Clone, Show)]
 pub struct RegionParameterDef {
     pub name: ast::Name,
     pub def_id: ast::DefId,
@@ -968,7 +972,7 @@ pub struct RegionParameterDef {
 
 /// Information about the type/lifetime parameters associated with an
 /// item or method. Analogous to ast::Generics.
-#[deriving(Clone)]
+#[deriving(Clone, Show)]
 pub struct Generics {
     pub types: VecPerParamSpace<TypeParameterDef>,
     pub regions: VecPerParamSpace<RegionParameterDef>,
@@ -983,6 +987,10 @@ pub fn empty() -> Generics {
     pub fn has_type_params(&self, space: subst::ParamSpace) -> bool {
         !self.types.is_empty_in(space)
     }
+
+    pub fn has_region_params(&self, space: subst::ParamSpace) -> bool {
+        !self.regions.is_empty_in(space)
+    }
 }
 
 /// When type checking, we use the `ParameterEnvironment` to track
@@ -1014,7 +1022,7 @@ pub struct ParameterEnvironment {
 /// - `generics`: the set of type parameters and their bounds
 /// - `ty`: the base types, which may reference the parameters defined
 ///   in `generics`
-#[deriving(Clone)]
+#[deriving(Clone, Show)]
 pub struct Polytype {
     pub generics: Generics,
     pub ty: t
@@ -1050,6 +1058,7 @@ pub fn mk_ctxt(s: Session,
     ctxt {
         named_region_map: named_region_map,
         item_variance_map: RefCell::new(DefIdMap::new()),
+        variance_computed: Cell::new(false),
         interner: RefCell::new(FnvHashMap::new()),
         next_id: Cell::new(primitives::LAST_PRIMITIVE_ID),
         sess: s,
@@ -4762,3 +4771,13 @@ fn upvar_borrow(&self, upvar_id: ty::UpvarId) -> ty::UpvarBorrow {
         self.upvar_borrow_map.borrow().get_copy(&upvar_id)
     }
 }
+
+/// The category of explicit self.
+#[deriving(Clone, Eq, PartialEq)]
+pub enum ExplicitSelfCategory {
+    StaticExplicitSelfCategory,
+    ByValueExplicitSelfCategory,
+    ByReferenceExplicitSelfCategory(Region, ast::Mutability),
+    ByBoxExplicitSelfCategory,
+}
+
index 90331d8f43430c2e3531b870e4724508c6df06d7..09557c94aa62a7812561fe0564a9550761645418 100644 (file)
 use middle::const_eval;
 use middle::def;
 use middle::lang_items::FnMutTraitLangItem;
-use rl = middle::resolve_lifetime;
 use middle::subst::{FnSpace, TypeSpace, SelfSpace, Subst, Substs};
 use middle::ty;
-use middle::typeck::TypeAndSubsts;
-use middle::typeck::lookup_def_tcx;
+use middle::ty_fold::TypeFolder;
 use middle::typeck::rscope::RegionScope;
-use middle::typeck::rscope;
+use middle::typeck::{TypeAndSubsts, infer, lookup_def_tcx, rscope};
+use middle::typeck;
+use rl = middle::resolve_lifetime;
 use util::ppaux::Repr;
 
 use std::rc::Rc;
@@ -141,7 +141,7 @@ pub fn opt_ast_region_to_region<AC:AstConv,RS:RegionScope>(
         }
     };
 
-    debug!("opt_ast_region_to_region(opt_lifetime={:?}) yields {}",
+    debug!("opt_ast_region_to_region(opt_lifetime={}) yields {}",
             opt_lifetime.as_ref().map(|e| lifetime_to_string(e)),
             r.repr(this.tcx()));
 
@@ -504,6 +504,7 @@ pub fn ast_ty_to_builtin_ty<AC:AstConv,
     }
 }
 
+#[deriving(Show)]
 enum PointerTy {
     Box,
     RPtr(ty::Region),
@@ -565,7 +566,7 @@ fn mk_pointer<AC:AstConv,
               constr: |ty::t| -> ty::t)
               -> ty::t {
     let tcx = this.tcx();
-    debug!("mk_pointer(ptr_ty={:?})", ptr_ty);
+    debug!("mk_pointer(ptr_ty={})", ptr_ty);
 
     match a_seq_ty.ty.node {
         ast::TyVec(ref ty) => {
@@ -899,58 +900,73 @@ pub fn ty_of_arg<AC: AstConv, RS: RegionScope>(this: &AC, rscope: &RS, a: &ast::
     }
 }
 
-struct SelfInfo {
+struct SelfInfo<'a> {
     untransformed_self_ty: ty::t,
-    explicit_self: ast::ExplicitSelf
+    explicit_self: ast::ExplicitSelf,
 }
 
 pub fn ty_of_method<AC:AstConv>(
-    this: &AC,
-    id: ast::NodeId,
-    fn_style: ast::FnStyle,
-    untransformed_self_ty: ty::t,
-    explicit_self: ast::ExplicitSelf,
-    decl: &ast::FnDecl)
-    -> ty::BareFnTy
-{
-    ty_of_method_or_bare_fn(this, id, fn_style, abi::Rust, Some(SelfInfo {
+                    this: &AC,
+                    id: ast::NodeId,
+                    fn_style: ast::FnStyle,
+                    untransformed_self_ty: ty::t,
+                    explicit_self: ast::ExplicitSelf,
+                    decl: &ast::FnDecl)
+                    -> (ty::BareFnTy, ty::ExplicitSelfCategory) {
+    let self_info = Some(SelfInfo {
         untransformed_self_ty: untransformed_self_ty,
-        explicit_self: explicit_self
-    }), decl)
+        explicit_self: explicit_self,
+    });
+    let (bare_fn_ty, optional_explicit_self_category) =
+        ty_of_method_or_bare_fn(this,
+                                id,
+                                fn_style,
+                                abi::Rust,
+                                self_info,
+                                decl);
+    (bare_fn_ty, optional_explicit_self_category.unwrap())
 }
 
 pub fn ty_of_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId,
                                  fn_style: ast::FnStyle, abi: abi::Abi,
                                  decl: &ast::FnDecl) -> ty::BareFnTy {
-    ty_of_method_or_bare_fn(this, id, fn_style, abi, None, decl)
+    let (bare_fn_ty, _) =
+        ty_of_method_or_bare_fn(this, id, fn_style, abi, None, decl);
+    bare_fn_ty
 }
 
-fn ty_of_method_or_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId,
-                                       fn_style: ast::FnStyle, abi: abi::Abi,
-                                       opt_self_info: Option<SelfInfo>,
-                                       decl: &ast::FnDecl) -> ty::BareFnTy {
+fn ty_of_method_or_bare_fn<AC:AstConv>(
+                           this: &AC,
+                           id: ast::NodeId,
+                           fn_style: ast::FnStyle,
+                           abi: abi::Abi,
+                           opt_self_info: Option<SelfInfo>,
+                           decl: &ast::FnDecl)
+                           -> (ty::BareFnTy,
+                               Option<ty::ExplicitSelfCategory>) {
     debug!("ty_of_method_or_bare_fn");
 
     // new region names that appear inside of the fn decl are bound to
     // that function type
     let rb = rscope::BindingRscope::new(id);
 
+    let mut explicit_self_category_result = None;
     let self_ty = opt_self_info.and_then(|self_info| {
-        match self_info.explicit_self.node {
-            ast::SelfStatic => None,
-            ast::SelfValue(_) => {
+        // Figure out and record the explicit self category.
+        let explicit_self_category =
+            determine_explicit_self_category(this, &rb, &self_info);
+        explicit_self_category_result = Some(explicit_self_category);
+        match explicit_self_category {
+            ty::StaticExplicitSelfCategory => None,
+            ty::ByValueExplicitSelfCategory => {
                 Some(self_info.untransformed_self_ty)
             }
-            ast::SelfRegion(ref lifetime, mutability, _) => {
-                let region =
-                    opt_ast_region_to_region(this, &rb,
-                                             self_info.explicit_self.span,
-                                             lifetime);
+            ty::ByReferenceExplicitSelfCategory(region, mutability) => {
                 Some(ty::mk_rptr(this.tcx(), region,
                                  ty::mt {ty: self_info.untransformed_self_ty,
                                          mutbl: mutability}))
             }
-            ast::SelfUniq(_) => {
+            ty::ByBoxExplicitSelfCategory => {
                 Some(ty::mk_uniq(this.tcx(), self_info.untransformed_self_ty))
             }
         }
@@ -971,7 +987,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId,
         _ => ast_ty_to_ty(this, &rb, &*decl.output)
     };
 
-    return ty::BareFnTy {
+    (ty::BareFnTy {
         fn_style: fn_style,
         abi: abi,
         sig: ty::FnSig {
@@ -980,7 +996,83 @@ fn ty_of_method_or_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId,
             output: output_ty,
             variadic: decl.variadic
         }
-    };
+    }, explicit_self_category_result)
+}
+
+fn determine_explicit_self_category<AC:AstConv,
+                                    RS:RegionScope>(
+                                    this: &AC,
+                                    rscope: &RS,
+                                    self_info: &SelfInfo)
+                                    -> ty::ExplicitSelfCategory {
+    match self_info.explicit_self.node {
+        ast::SelfStatic => ty::StaticExplicitSelfCategory,
+        ast::SelfValue(_) => ty::ByValueExplicitSelfCategory,
+        ast::SelfRegion(ref lifetime, mutability, _) => {
+            let region =
+                opt_ast_region_to_region(this,
+                                         rscope,
+                                         self_info.explicit_self.span,
+                                         lifetime);
+            ty::ByReferenceExplicitSelfCategory(region, mutability)
+        }
+        ast::SelfUniq(_) => ty::ByBoxExplicitSelfCategory,
+        ast::SelfExplicit(ast_type, _) => {
+            let explicit_type = ast_ty_to_ty(this, rscope, ast_type);
+
+            {
+                let inference_context = infer::new_infer_ctxt(this.tcx());
+                let expected_self = self_info.untransformed_self_ty;
+                let actual_self = explicit_type;
+                let result = infer::mk_eqty(
+                    &inference_context,
+                    false,
+                    infer::Misc(self_info.explicit_self.span),
+                    expected_self,
+                    actual_self);
+                match result {
+                    Ok(_) => {
+                        inference_context.resolve_regions_and_report_errors();
+                        return ty::ByValueExplicitSelfCategory
+                    }
+                    Err(_) => {}
+                }
+            }
+
+            match ty::get(explicit_type).sty {
+                ty::ty_rptr(region, tm) => {
+                    typeck::require_same_types(
+                        this.tcx(),
+                        None,
+                        false,
+                        self_info.explicit_self.span,
+                        self_info.untransformed_self_ty,
+                        tm.ty,
+                        || "not a valid type for `self`".to_owned());
+                    return ty::ByReferenceExplicitSelfCategory(region,
+                                                               tm.mutbl)
+                }
+                ty::ty_uniq(typ) => {
+                    typeck::require_same_types(
+                        this.tcx(),
+                        None,
+                        false,
+                        self_info.explicit_self.span,
+                        self_info.untransformed_self_ty,
+                        typ,
+                        || "not a valid type for `self`".to_owned());
+                    return ty::ByBoxExplicitSelfCategory
+                }
+                _ => {
+                    this.tcx()
+                        .sess
+                        .span_err(self_info.explicit_self.span,
+                                  "not a valid type for `self`");
+                    return ty::ByValueExplicitSelfCategory
+                }
+            }
+        }
+    }
 }
 
 pub fn ty_of_closure<AC:AstConv>(
@@ -1097,3 +1189,4 @@ fn conv_builtin_bounds(tcx: &ty::ctxt,
         (&None, ty::UniqTraitStore) => ty::empty_builtin_bounds(),
     }
 }
+
index 170f850328eb0af81c9f99ace31072750d47c500..be01643e22a583e6a547a267d6e0451077f3a033 100644 (file)
@@ -507,14 +507,20 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
             ty::ty_struct(cid, ref substs) => {
                 // Verify that the pattern named the right structure.
                 let item_did = tcx.def_map.borrow().get(&pat.id).def_id();
-                let struct_did =
-                    ty::ty_to_def_id(
-                        ty::lookup_item_type(tcx, item_did).ty).unwrap();
-                if struct_did != cid {
-                    span_err!(tcx.sess, pat.span, E0032,
-                        "`{}` does not name the structure `{}`",
-                        pprust::path_to_string(path),
-                        fcx.infcx().ty_to_string(expected));
+                match ty::ty_to_def_id(ty::lookup_item_type(tcx, item_did).ty) {
+                    Some(struct_did) if struct_did != cid => {
+                        span_err!(tcx.sess, path.span, E0032,
+                                  "`{}` does not name the structure `{}`",
+                                  pprust::path_to_string(path),
+                                  fcx.infcx().ty_to_string(expected));
+                    },
+                    Some(_) => {},
+                    None => {
+                        tcx.sess.span_bug(
+                            path.span,
+                            format!("This shouldn't happen: failed to lookup structure. \
+                                item_did = {}", item_did).as_slice())
+                    },
                 }
 
                 check_struct_pat(pcx, pat.id, pat.span, expected, path,
index 4787837093844233fd86e2b65361cd293be94862..e12fae4f9501e00ea4f325437d6c6b0ba6b7e110 100644 (file)
@@ -100,9 +100,7 @@ trait `ToString` imported, and I call `to_string()` on a value of type `T`,
 
 use std::collections::HashSet;
 use std::rc::Rc;
-use syntax::ast::{DefId, SelfValue, SelfRegion};
-use syntax::ast::{SelfUniq, SelfStatic};
-use syntax::ast::{MutMutable, MutImmutable};
+use syntax::ast::{DefId, MutImmutable, MutMutable};
 use syntax::ast;
 use syntax::codemap::Span;
 use syntax::parse::token;
@@ -267,15 +265,15 @@ fn construct_transformed_self_ty_for_object(
     obj_substs.types.pop(subst::SelfSpace).unwrap();
 
     match method_ty.explicit_self {
-        ast::SelfStatic => {
+        StaticExplicitSelfCategory => {
             tcx.sess.span_bug(span, "static method for object type receiver");
         }
-        ast::SelfValue(_) => {
+        ByValueExplicitSelfCategory => {
             let tr = ty::mk_trait(tcx, trait_def_id, obj_substs,
                                   ty::empty_builtin_bounds());
             ty::mk_uniq(tcx, tr)
         }
-        ast::SelfRegion(..) | ast::SelfUniq(..) => {
+        ByReferenceExplicitSelfCategory(..) | ByBoxExplicitSelfCategory => {
             let transformed_self_ty = *method_ty.fty.sig.inputs.get(0);
             match ty::get(transformed_self_ty).sty {
                 ty::ty_rptr(r, mt) => { // must be SelfRegion
@@ -618,7 +616,7 @@ fn push_inherent_candidates_from_bounds_inner(&mut self,
 
             let trait_methods = ty::trait_methods(tcx, bound_trait_ref.def_id);
             match trait_methods.iter().position(|m| {
-                m.explicit_self != ast::SelfStatic &&
+                m.explicit_self != ty::StaticExplicitSelfCategory &&
                 m.ident.name == self.m_name }) {
                 Some(pos) => {
                     let method = trait_methods.get(pos).clone();
@@ -1023,7 +1021,10 @@ fn consider_candidates(&self, rcvr_ty: ty::t,
 
         if self.report_statics == ReportStaticMethods {
             // lookup should only be called with ReportStaticMethods if a regular lookup failed
-            assert!(relevant_candidates.iter().all(|c| c.method_ty.explicit_self == SelfStatic));
+            assert!(relevant_candidates.iter()
+                                       .all(|c| {
+                c.method_ty.explicit_self == ty::StaticExplicitSelfCategory
+            }));
 
             self.tcx().sess.fileline_note(self.span,
                                 "found defined static methods, maybe a `self` is missing?");
@@ -1100,7 +1101,8 @@ fn confirm_candidate(&self, rcvr_ty: ty::t, candidate: &Candidate)
         self.enforce_drop_trait_limitations(candidate);
 
         // static methods should never have gotten this far:
-        assert!(candidate.method_ty.explicit_self != SelfStatic);
+        assert!(candidate.method_ty.explicit_self !=
+                ty::StaticExplicitSelfCategory);
 
         // Determine the values for the generic parameters of the method.
         // If they were not explicitly supplied, just construct fresh
@@ -1217,12 +1219,16 @@ fn enforce_object_limitations(&self, candidate: &Candidate) {
         }
 
         match candidate.method_ty.explicit_self {
-            ast::SelfStatic => { // reason (a) above
-                span_err!(self.tcx().sess, self.span, E0037,
-                    "cannot call a method without a receiver through an object");
+            ty::StaticExplicitSelfCategory => { // reason (a) above
+                self.tcx().sess.span_err(
+                    self.span,
+                    "cannot call a method without a receiver \
+                     through an object");
             }
 
-            ast::SelfValue(_) | ast::SelfRegion(..) | ast::SelfUniq(_) => {}
+            ty::ByValueExplicitSelfCategory |
+            ty::ByReferenceExplicitSelfCategory(..) |
+            ty::ByBoxExplicitSelfCategory => {}
         }
 
         // reason (a) above
@@ -1284,12 +1290,12 @@ fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
                self.ty_to_string(rcvr_ty), candidate.repr(self.tcx()));
 
         return match candidate.method_ty.explicit_self {
-            SelfStatic => {
+            StaticExplicitSelfCategory => {
                 debug!("(is relevant?) explicit self is static");
                 self.report_statics == ReportStaticMethods
             }
 
-            SelfValue(_) => {
+            ByValueExplicitSelfCategory => {
                 debug!("(is relevant?) explicit self is by-value");
                 match ty::get(rcvr_ty).sty {
                     ty::ty_uniq(typ) => {
@@ -1312,7 +1318,7 @@ fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
                 }
             }
 
-            SelfRegion(_, m, _) => {
+            ByReferenceExplicitSelfCategory(_, m) => {
                 debug!("(is relevant?) explicit self is a region");
                 match ty::get(rcvr_ty).sty {
                     ty::ty_rptr(_, mt) => {
@@ -1332,7 +1338,7 @@ fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
                 }
             }
 
-            SelfUniq(_) => {
+            ByBoxExplicitSelfCategory => {
                 debug!("(is relevant?) explicit self is a unique pointer");
                 match ty::get(rcvr_ty).sty {
                     ty::ty_uniq(typ) => {
@@ -1480,3 +1486,6 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
         }
     }
 }
+
+
+
index 7441f89ac8a607a95b750ffafd175706aa43bf27..4f07f1121b7ceb0aa888648ebce7e56693fbd9f1 100644 (file)
 use syntax::ast::{Provided, Required};
 use syntax::ast;
 use syntax::ast_map;
-use syntax::ast_util::local_def;
+use syntax::ast_util::{local_def, PostExpansionMethod};
 use syntax::ast_util;
 use syntax::attr;
 use syntax::codemap::Span;
@@ -757,16 +757,14 @@ fn check_method_body(ccx: &CrateCtxt,
     let method_def_id = local_def(method.id);
     let method_ty = ty::method(ccx.tcx, method_def_id);
     let method_generics = &method_ty.generics;
-    let m_body = ast_util::method_body(&*method);
 
     let param_env = ty::construct_parameter_environment(ccx.tcx,
                                                         method_generics,
-                                                        m_body.id);
+                                                        method.pe_body().id);
 
     let fty = ty::node_id_to_type(ccx.tcx, method.id);
 
-    check_bare_fn(ccx, ast_util::method_fn_decl(&*method),
-                  m_body, method.id, fty, param_env);
+    check_bare_fn(ccx, method.pe_fn_decl(), method.pe_body(), method.id, fty, param_env);
 }
 
 fn check_impl_methods_against_trait(ccx: &CrateCtxt,
@@ -794,7 +792,7 @@ fn check_impl_methods_against_trait(ccx: &CrateCtxt,
                 compare_impl_method(ccx.tcx,
                                     &*impl_method_ty,
                                     impl_method.span,
-                                    ast_util::method_body(&**impl_method).id,
+                                    impl_method.pe_body().id,
                                     &**trait_method_ty,
                                     &impl_trait_ref.substs);
             }
@@ -817,7 +815,7 @@ fn check_impl_methods_against_trait(ccx: &CrateCtxt,
     for trait_method in trait_methods.iter() {
         let is_implemented =
             impl_methods.iter().any(
-                |m| ast_util::method_ident(&**m).name == trait_method.ident.name);
+                |m| m.pe_ident().name == trait_method.ident.name);
         let is_provided =
             provided_methods.iter().any(
                 |m| m.ident.name == trait_method.ident.name);
@@ -864,19 +862,26 @@ fn compare_impl_method(tcx: &ty::ctxt,
     // inscrutable, particularly for cases where one method has no
     // self.
     match (&trait_m.explicit_self, &impl_m.explicit_self) {
-        (&ast::SelfStatic, &ast::SelfStatic) => {}
-        (&ast::SelfStatic, _) => {
-            span_err!(tcx.sess, impl_m_span, E0047,
-                "method `{}` has a `{}` declaration in the impl, but not in the trait",
-                token::get_ident(trait_m.ident),
-                pprust::explicit_self_to_string(impl_m.explicit_self));
+        (&ty::StaticExplicitSelfCategory,
+         &ty::StaticExplicitSelfCategory) => {}
+        (&ty::StaticExplicitSelfCategory, _) => {
+            tcx.sess.span_err(
+                impl_m_span,
+                format!("method `{}` has a `{}` declaration in the impl, \
+                        but not in the trait",
+                        token::get_ident(trait_m.ident),
+                        ppaux::explicit_self_category_to_str(
+                            &impl_m.explicit_self)).as_slice());
             return;
         }
-        (_, &ast::SelfStatic) => {
-            span_err!(tcx.sess, impl_m_span, E0048,
-                "method `{}` has a `{}` declaration in the trait, but not in the impl",
-                token::get_ident(trait_m.ident),
-                pprust::explicit_self_to_string(trait_m.explicit_self));
+        (_, &ty::StaticExplicitSelfCategory) => {
+            tcx.sess.span_err(
+                impl_m_span,
+                format!("method `{}` has a `{}` declaration in the trait, \
+                        but not in the impl",
+                        token::get_ident(trait_m.ident),
+                        ppaux::explicit_self_category_to_str(
+                            &trait_m.explicit_self)).as_slice());
             return;
         }
         _ => {
@@ -4789,3 +4794,4 @@ fn param(ccx: &CrateCtxt, n: uint) -> ty::t {
             });
     }
 }
+
index 924934e4bcdc5e34eac00cc6af2f3b450e597988..180dac53828052fb11ed63cf0053327ab78e39f8 100644 (file)
@@ -1219,7 +1219,8 @@ fn link_region(rcx: &Rcx,
                kind.repr(rcx.tcx()),
                cmt_borrowed.repr(rcx.tcx()));
         match cmt_borrowed.cat.clone() {
-            mc::cat_deref(base, _, mc::BorrowedPtr(_, r_borrowed)) => {
+            mc::cat_deref(base, _, mc::BorrowedPtr(_, r_borrowed)) |
+            mc::cat_deref(base, _, mc::Implicit(_, r_borrowed)) => {
                 // References to an upvar `x` are translated to
                 // `*x`, since that is what happens in the
                 // underlying machine.  We detect such references
@@ -1340,7 +1341,8 @@ fn adjust_upvar_borrow_kind_for_mut(rcx: &Rcx,
                 continue;
             }
 
-            mc::cat_deref(base, _, mc::BorrowedPtr(..)) => {
+            mc::cat_deref(base, _, mc::BorrowedPtr(..)) |
+            mc::cat_deref(base, _, mc::Implicit(..)) => {
                 match base.cat {
                     mc::cat_upvar(ref upvar_id, _) => {
                         // if this is an implicit deref of an
@@ -1394,7 +1396,8 @@ fn adjust_upvar_borrow_kind_for_unique(rcx: &Rcx, cmt: mc::cmt) {
                 continue;
             }
 
-            mc::cat_deref(base, _, mc::BorrowedPtr(..)) => {
+            mc::cat_deref(base, _, mc::BorrowedPtr(..)) |
+            mc::cat_deref(base, _, mc::Implicit(..)) => {
                 match base.cat {
                     mc::cat_upvar(ref upvar_id, _) => {
                         // if this is an implicit deref of an
index 9f08dc2c924839df6f62db371a154ca097300d08..eea26fbcfc73fc5e736526694e552243d77c0e34 100644 (file)
 use middle::ty::{ImplContainer, MethodContainer, TraitContainer};
 use middle::ty::{Polytype};
 use middle::ty;
+use middle::ty_fold::TypeFolder;
 use middle::typeck::astconv::{AstConv, ty_of_arg};
 use middle::typeck::astconv::{ast_ty_to_ty};
 use middle::typeck::astconv;
+use middle::typeck::infer;
 use middle::typeck::rscope::*;
 use middle::typeck::{CrateCtxt, lookup_def_tcx, no_params, write_ty_to_tcx};
+use middle::typeck;
 use util::ppaux;
 use util::ppaux::Repr;
 
@@ -57,8 +60,7 @@
 use syntax::ast::{TraitTyParamBound, UnboxedFnTyParamBound};
 use syntax::ast;
 use syntax::ast_map;
-use syntax::ast_util;
-use syntax::ast_util::{local_def, method_ident, split_trait_methods};
+use syntax::ast_util::{local_def, split_trait_methods, PostExpansionMethod};
 use syntax::codemap::Span;
 use syntax::codemap;
 use syntax::owned_slice::OwnedSlice;
@@ -214,15 +216,13 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
                             &ast::Provided(ref m) => {
                                 ty_method_of_trait_method(
                                     ccx, trait_id, &trait_def.generics,
-                                    &m.id, &ast_util::method_ident(&**m),
-                                    ast_util::method_explicit_self(&**m),
-                                    ast_util::method_generics(&**m),
-                                    &ast_util::method_fn_style(&**m),
-                                    ast_util::method_fn_decl(&**m))
+                                    &m.id, &m.pe_ident(), m.pe_explicit_self(),
+                                    m.pe_generics(), &m.pe_fn_style(), m.pe_fn_decl())
                             }
                         });
 
-                        if ty_method.explicit_self == ast::SelfStatic {
+                        if ty_method.explicit_self ==
+                                ty::StaticExplicitSelfCategory {
                             make_static_method_ty(ccx, &*ty_method);
                         }
 
@@ -270,18 +270,26 @@ fn ty_method_of_trait_method(this: &CrateCtxt,
                                  m_fn_style: &ast::FnStyle,
                                  m_decl: &ast::FnDecl) -> ty::Method
     {
-        let trait_self_ty = ty::mk_self_type(this.tcx, local_def(trait_id));
-        let fty = astconv::ty_of_method(this, *m_id, *m_fn_style, trait_self_ty,
-                                        *m_explicit_self, m_decl);
-        let ty_generics =
-            ty_generics_for_fn_or_method(this,
-                                         m_generics,
-                                         (*trait_generics).clone());
+        let trait_self_ty = ty::mk_param(this.tcx,
+                                         subst::SelfSpace,
+                                         0,
+                                         local_def(trait_id));
+        let ty_generics = ty_generics_for_fn_or_method(
+            this,
+            m_generics,
+            (*trait_generics).clone());
+        let (fty, explicit_self_category) =
+            astconv::ty_of_method(this,
+                                  *m_id,
+                                  *m_fn_style,
+                                  trait_self_ty,
+                                  *m_explicit_self,
+                                  m_decl);
         ty::Method::new(
             *m_ident,
             ty_generics,
             fty,
-            m_explicit_self.node,
+            explicit_self_category,
             // assume public, because this is only invoked on trait methods
             ast::Public,
             local_def(*m_id),
@@ -334,7 +342,7 @@ fn convert_methods(ccx: &CrateCtxt,
     let tcx = ccx.tcx;
     let mut seen_methods = HashSet::new();
     for m in ms.iter() {
-        if !seen_methods.insert(ast_util::method_ident(&**m).repr(tcx)) {
+        if !seen_methods.insert(m.pe_ident().repr(ccx.tcx)) {
             tcx.sess.span_err(m.span, "duplicate method in trait impl");
         }
 
@@ -346,9 +354,9 @@ fn convert_methods(ccx: &CrateCtxt,
                                        rcvr_visibility));
         let fty = ty::mk_bare_fn(tcx, mty.fty.clone());
         debug!("method {} (id {}) has type {}",
-                method_ident(&**m).repr(tcx),
+                m.pe_ident().repr(ccx.tcx),
                 m.id,
-                fty.repr(tcx));
+                fty.repr(ccx.tcx));
         tcx.tcache.borrow_mut().insert(
             local_def(m.id),
             Polytype {
@@ -369,24 +377,27 @@ fn ty_of_method(ccx: &CrateCtxt,
                     rcvr_visibility: ast::Visibility)
                     -> ty::Method
     {
-        let fty = astconv::ty_of_method(ccx, m.id, ast_util::method_fn_style(&*m),
-                                        untransformed_rcvr_ty,
-                                        *ast_util::method_explicit_self(&*m),
-                                        ast_util::method_fn_decl(&*m));
+        let (fty, explicit_self_category) =
+            astconv::ty_of_method(ccx,
+                                  m.id,
+                                  m.pe_fn_style(),
+                                  untransformed_rcvr_ty,
+                                  *m.pe_explicit_self(),
+                                  m.pe_fn_decl());
 
         // if the method specifies a visibility, use that, otherwise
         // inherit the visibility from the impl (so `foo` in `pub impl
         // { fn foo(); }` is public, but private in `priv impl { fn
         // foo(); }`).
-        let method_vis = ast_util::method_vis(&*m).inherit_from(rcvr_visibility);
+        let method_vis = m.pe_vis().inherit_from(rcvr_visibility);
 
         let m_ty_generics =
-            ty_generics_for_fn_or_method(ccx, ast_util::method_generics(&*m),
+            ty_generics_for_fn_or_method(ccx, m.pe_generics(),
                                          (*rcvr_ty_generics).clone());
-        ty::Method::new(ast_util::method_ident(&*m),
+        ty::Method::new(m.pe_ident(),
                         m_ty_generics,
                         fty,
-                        ast_util::method_explicit_self(&*m).node,
+                        explicit_self_category,
                         method_vis,
                         local_def(m.id),
                         container,
@@ -455,6 +466,13 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) {
                 it.vis
             };
 
+            for method in ms.iter() {
+                check_method_self_type(ccx,
+                                       &BindingRscope::new(method.id),
+                                       selfty,
+                                       method.pe_explicit_self())
+            }
+
             convert_methods(ccx,
                             ImplContainer(local_def(it.id)),
                             ms.as_slice(),
@@ -469,6 +487,28 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) {
         ast::ItemTrait(_, _, _, ref trait_methods) => {
             let trait_def = trait_def_of_item(ccx, it);
 
+            for trait_method in trait_methods.iter() {
+                let self_type = ty::mk_param(ccx.tcx,
+                                             subst::SelfSpace,
+                                             0,
+                                             local_def(it.id));
+                match *trait_method {
+                    ast::Required(ref type_method) => {
+                        let rscope = BindingRscope::new(type_method.id);
+                        check_method_self_type(ccx,
+                                               &rscope,
+                                               self_type,
+                                               &type_method.explicit_self)
+                    }
+                    ast::Provided(ref method) => {
+                        check_method_self_type(ccx,
+                                               &BindingRscope::new(method.id),
+                                               self_type,
+                                               method.pe_explicit_self())
+                    }
+                }
+            }
+
             // Run convert_methods on the provided methods.
             let (_, provided_methods) =
                 split_trait_methods(trait_methods.as_slice());
@@ -1018,16 +1058,17 @@ fn ty_generics(ccx: &CrateCtxt,
     let mut result = base_generics;
 
     for (i, l) in lifetimes.iter().enumerate() {
-        result.regions.push(space,
-                            ty::RegionParameterDef { name: l.name,
-                                                     space: space,
-                                                     index: i,
-                                                     def_id: local_def(l.id) });
+        let def = ty::RegionParameterDef { name: l.name,
+                                           space: space,
+                                           index: i,
+                                           def_id: local_def(l.id) };
+        debug!("ty_generics: def for region param: {}", def);
+        result.regions.push(space, def);
     }
 
     for (i, param) in types.iter().enumerate() {
         let def = get_or_create_type_parameter_def(ccx, space, param, i);
-        debug!("def for param: {}", def.repr(ccx.tcx));
+        debug!("ty_generics: def for type param: {}", def.repr(ccx.tcx));
         result.types.push(space, def);
     }
 
@@ -1244,3 +1285,36 @@ pub fn mk_item_substs(ccx: &CrateCtxt,
 
     subst::Substs::new(types, regions)
 }
+
+/// Verifies that the explicit self type of a method matches the impl or
+/// trait.
+fn check_method_self_type<RS:RegionScope>(
+                          crate_context: &CrateCtxt,
+                          rs: &RS,
+                          required_type: ty::t,
+                          explicit_self: &ast::ExplicitSelf) {
+    match explicit_self.node {
+        ast::SelfExplicit(ref ast_type, _) => {
+            let typ = crate_context.to_ty(rs, *ast_type);
+            let base_type = match ty::get(typ).sty {
+                ty::ty_rptr(_, tm) => tm.ty,
+                ty::ty_uniq(typ) => typ,
+                _ => typ,
+            };
+            let infcx = infer::new_infer_ctxt(crate_context.tcx);
+            drop(typeck::require_same_types(crate_context.tcx,
+                                            Some(&infcx),
+                                            false,
+                                            explicit_self.span,
+                                            base_type,
+                                            required_type,
+                                            || {
+                format!("mismatched self type: expected `{}`",
+                        ppaux::ty_to_string(crate_context.tcx, required_type))
+            }));
+            infcx.resolve_regions_and_report_errors();
+        }
+        _ => {}
+    }
+}
+
index 1e33b1d5d0ebd5368044a1a6c51a5c273a95ed64..c3de120a0c393755a01f570f2eb0f00ccd7fffb5 100644 (file)
@@ -111,7 +111,11 @@ fn substs(&self,
               b_subst: &subst::Substs)
               -> cres<subst::Substs>
     {
-        let variances = ty::item_variances(self.infcx().tcx, item_def_id);
+        let variances = if self.infcx().tcx.variance_computed.get() {
+            Some(ty::item_variances(self.infcx().tcx, item_def_id))
+        } else {
+            None
+        };
         let mut substs = subst::Substs::empty();
 
         for &space in subst::ParamSpace::all().iter() {
@@ -121,7 +125,18 @@ fn substs(&self,
 
             let a_regions = a_subst.regions().get_slice(space);
             let b_regions = b_subst.regions().get_slice(space);
-            let r_variances = variances.regions.get_slice(space);
+
+            let mut invariance = Vec::new();
+            let r_variances = match variances {
+                Some(ref variances) => variances.regions.get_slice(space),
+                None => {
+                    for _ in a_regions.iter() {
+                        invariance.push(ty::Invariant);
+                    }
+                    invariance.as_slice()
+                }
+            };
+
             let regions = if_ok!(relate_region_params(self,
                                                       item_def_id,
                                                       r_variances,
index bdd6d96f394a29131e357e47eeb9adf6aff022c7..8be1700b635b4fccb251b5302b2cd29b0a197f81 100644 (file)
@@ -84,7 +84,7 @@
 use syntax::ast;
 use syntax::ast_map;
 use syntax::ast_util;
-use syntax::ast_util::name_to_dummy_lifetime;
+use syntax::ast_util::{name_to_dummy_lifetime, PostExpansionMethod};
 use syntax::owned_slice::OwnedSlice;
 use syntax::codemap;
 use syntax::parse::token;
@@ -700,11 +700,8 @@ fn give_suggestion(&self, same_regions: &[SameRegions]) {
                     }
                 }
                 ast_map::NodeMethod(ref m) => {
-                    Some((ast_util::method_fn_decl(&**m),
-                          ast_util::method_generics(&**m),
-                          ast_util::method_fn_style(&**m),
-                          ast_util::method_ident(&**m),
-                          Some(ast_util::method_explicit_self(&**m).node), m.span))
+                    Some((m.pe_fn_decl(), m.pe_generics(), m.pe_fn_style(),
+                          m.pe_ident(), Some(m.pe_explicit_self().node), m.span))
                 },
                 _ => None
             },
@@ -1455,7 +1452,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
                 _ => None
             },
             ast_map::NodeMethod(m) => {
-                taken.push_all(ast_util::method_generics(&*m).lifetimes.as_slice());
+                taken.push_all(m.pe_generics().lifetimes.as_slice());
                 Some(m.id)
             },
             _ => None
index 757b715ec930080f204472e119b953706d5a0f1f..d17553e9c39b39b30e6801f46ff2b795765719c0 100644 (file)
 
 use middle::ty;
 use middle::ty::{BoundRegion, FreeRegion, Region, RegionVid};
-use middle::ty::{ReEmpty, ReStatic, ReInfer, ReFree, ReEarlyBound,
-                 ReLateBound};
-use middle::ty::{ReScope, ReVar, ReSkolemized, BrFresh};
+use middle::ty::{ReEmpty, ReStatic, ReInfer, ReFree, ReEarlyBound};
+use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh};
 use middle::typeck::infer::cres;
 use middle::typeck::infer::{RegionVariableOrigin, SubregionOrigin, TypeTrace};
 use middle::typeck::infer;
 use middle::graph;
 use middle::graph::{Direction, NodeIndex};
 use util::common::indenter;
-use util::ppaux::{Repr};
+use util::ppaux::Repr;
 
 use std::cell::{Cell, RefCell};
 use std::uint;
@@ -246,7 +245,7 @@ pub fn new_region_var(&self, origin: RegionVariableOrigin) -> RegionVid {
         if self.in_snapshot() {
             self.undo_log.borrow_mut().push(AddVar(vid));
         }
-        debug!("created new region variable {:?} with origin {:?}",
+        debug!("created new region variable {} with origin {}",
                vid, origin.repr(self.tcx));
         return vid;
     }
@@ -318,6 +317,11 @@ pub fn make_subregion(&self,
                origin.repr(self.tcx));
 
         match (sub, sup) {
+          (ReEarlyBound(..), ReEarlyBound(..)) => {
+            // This case is used only to make sure that explicitly-specified
+            // `Self` types match the real self type in implementations.
+            self.add_constraint(ConstrainRegSubReg(sub, sup), origin);
+          }
           (ReEarlyBound(..), _) |
           (ReLateBound(..), _) |
           (_, ReEarlyBound(..)) |
index 8b5d16620b0f5898d02a5f0b89bdea289b6a34c2..a65aa0423a6d0a20d3790726a7ffaf04e237a74f 100644 (file)
@@ -214,6 +214,7 @@ pub fn infer_variance(tcx: &ty::ctxt,
     let terms_cx = determine_parameters_to_be_inferred(tcx, &mut arena, krate);
     let constraints_cx = add_constraints_from_crate(terms_cx, krate);
     solve_constraints(constraints_cx);
+    tcx.variance_computed.set(true);
 }
 
 /**************************************************************************
index 6526943955c92860c3c9500ed1719666fab0a937..e37bef98e4404a334fbd4ef7d55115a9448935cc 100644 (file)
@@ -14,7 +14,7 @@
 use middle::subst::{VecPerParamSpace,Subst};
 use middle::ty::{ReSkolemized, ReVar};
 use middle::ty::{BoundRegion, BrAnon, BrNamed};
-use middle::ty::{BrFresh, ctxt};
+use middle::ty::{ReEarlyBound, BrFresh, ctxt};
 use middle::ty::{mt, t, ParamTy};
 use middle::ty::{ReFree, ReScope, ReInfer, ReStatic, Region, ReEmpty};
 use middle::ty::{ty_bool, ty_char, ty_bot, ty_box, ty_struct, ty_enum};
@@ -130,9 +130,13 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
 
       ReEmpty => { ("the empty lifetime".to_string(), None) }
 
+      ReEarlyBound(_, _, _, name) => {
+        (format!("{}", token::get_name(name)), None)
+      }
+
       // I believe these cases should not occur (except when debugging,
       // perhaps)
-      ty::ReInfer(_) | ty::ReEarlyBound(..) | ty::ReLateBound(..) => {
+      ty::ReInfer(_) | ty::ReLateBound(..) => {
         (format!("lifetime {:?}", region), None)
       }
     };
@@ -421,6 +425,19 @@ fn push_sig_to_string(cx: &ctxt,
     }
 }
 
+pub fn explicit_self_category_to_str(category: &ty::ExplicitSelfCategory)
+                                     -> &'static str {
+    match *category {
+        ty::StaticExplicitSelfCategory => "static",
+        ty::ByValueExplicitSelfCategory => "self",
+        ty::ByReferenceExplicitSelfCategory(_, ast::MutMutable) => {
+            "&mut self"
+        }
+        ty::ByReferenceExplicitSelfCategory(_, ast::MutImmutable) => "&self",
+        ty::ByBoxExplicitSelfCategory => "Box<self>",
+    }
+}
+
 pub fn parameterized(cx: &ctxt,
                      base: &str,
                      substs: &subst::Substs,
@@ -1083,3 +1100,10 @@ fn repr(&self, tcx: &ctxt) -> String {
         }
     }
 }
+
+impl Repr for ty::ExplicitSelfCategory {
+    fn repr(&self, _: &ctxt) -> String {
+        explicit_self_category_to_str(self).to_string()
+    }
+}
+
index 2e3bb2eef7d9df7b77f14a9f1895854ad0bcc5d9..c94759d7d7e8deef96b7bb838cb44c55d753b4fe 100644 (file)
@@ -14,6 +14,7 @@
 use syntax;
 use syntax::ast;
 use syntax::ast_util;
+use syntax::ast_util::PostExpansionMethod;
 use syntax::attr;
 use syntax::attr::{AttributeMethods, AttrMetaMethods};
 use syntax::codemap::Pos;
@@ -393,7 +394,7 @@ fn clean(&self) -> Item {
     }
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub enum Attribute {
     Word(String),
     List(String, Vec<Attribute> ),
@@ -446,7 +447,7 @@ fn value_str(&self) -> Option<InternedString> { (**self).value_str() }
     fn meta_item_list<'a>(&'a self) -> Option<&'a [Gc<ast::MetaItem>]> { None }
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub struct TyParam {
     pub name: String,
     pub did: ast::DefId,
@@ -478,7 +479,7 @@ fn clean(&self) -> TyParam {
     }
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub enum TyParamBound {
     RegionBound,
     TraitBound(Type)
@@ -637,7 +638,7 @@ fn clean(&self) -> Option<Lifetime> {
 }
 
 // maybe use a Generic enum and use ~[Generic]?
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub struct Generics {
     pub lifetimes: Vec<Lifetime>,
     pub type_params: Vec<TyParam>,
@@ -695,30 +696,30 @@ pub struct Method {
 
 impl Clean<Item> for ast::Method {
     fn clean(&self) -> Item {
-        let fn_decl = ast_util::method_fn_decl(self);
-        let inputs = match ast_util::method_explicit_self(self).node {
-            ast::SelfStatic => fn_decl.inputs.as_slice(),
-            _ => fn_decl.inputs.slice_from(1)
+        let all_inputs = &self.pe_fn_decl().inputs;
+        let inputs = match self.pe_explicit_self().node {
+            ast::SelfStatic => all_inputs.as_slice(),
+            _ => all_inputs.slice_from(1)
         };
         let decl = FnDecl {
             inputs: Arguments {
                 values: inputs.iter().map(|x| x.clean()).collect(),
             },
-            output: (fn_decl.output.clean()),
-            cf: fn_decl.cf.clean(),
+            output: (self.pe_fn_decl().output.clean()),
+            cf: self.pe_fn_decl().cf.clean(),
             attrs: Vec::new()
         };
         Item {
-            name: Some(ast_util::method_ident(self).clean()),
+            name: Some(self.pe_ident().clean()),
             attrs: self.attrs.clean().move_iter().collect(),
             source: self.span.clean(),
             def_id: ast_util::local_def(self.id),
-            visibility: ast_util::method_vis(self).clean(),
+            visibility: self.pe_vis().clean(),
             stability: get_stability(ast_util::local_def(self.id)),
             inner: MethodItem(Method {
-                generics: ast_util::method_generics(self).clean(),
-                self_: ast_util::method_explicit_self(self).node.clean(),
-                fn_style: ast_util::method_fn_style(self).clone(),
+                generics: self.pe_generics().clean(),
+                self_: self.pe_explicit_self().node.clean(),
+                fn_style: self.pe_fn_style().clone(),
                 decl: decl,
             }),
         }
@@ -770,6 +771,7 @@ pub enum SelfTy {
     SelfValue,
     SelfBorrowed(Option<Lifetime>, Mutability),
     SelfOwned,
+    SelfExplicit(Type),
 }
 
 impl Clean<SelfTy> for ast::ExplicitSelf_ {
@@ -778,7 +780,10 @@ fn clean(&self) -> SelfTy {
             ast::SelfStatic => SelfStatic,
             ast::SelfValue(_) => SelfValue,
             ast::SelfUniq(_) => SelfOwned,
-            ast::SelfRegion(lt, mt, _) => SelfBorrowed(lt.clean(), mt.clean()),
+            ast::SelfRegion(lt, mt, _) => {
+                SelfBorrowed(lt.clean(), mt.clean())
+            }
+            ast::SelfExplicit(typ, _) => SelfExplicit(typ.clean()),
         }
     }
 }
@@ -808,7 +813,7 @@ fn clean(&self) -> Item {
     }
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub struct ClosureDecl {
     pub lifetimes: Vec<Lifetime>,
     pub decl: FnDecl,
@@ -832,7 +837,7 @@ fn clean(&self) -> ClosureDecl {
     }
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub struct FnDecl {
     pub inputs: Arguments,
     pub output: Type,
@@ -840,7 +845,7 @@ pub struct FnDecl {
     pub attrs: Vec<Attribute>,
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub struct Arguments {
     pub values: Vec<Argument>,
 }
@@ -887,7 +892,7 @@ fn clean(&self) -> FnDecl {
     }
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub struct Argument {
     pub type_: Type,
     pub name: String,
@@ -904,7 +909,7 @@ fn clean(&self) -> Argument {
     }
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub enum RetStyle {
     NoReturn,
     Return
@@ -990,22 +995,28 @@ impl Clean<Item> for ty::Method {
     fn clean(&self) -> Item {
         let cx = get_cx();
         let (self_, sig) = match self.explicit_self {
-            ast::SelfStatic => (ast::SelfStatic.clean(), self.fty.sig.clone()),
+            ty::StaticExplicitSelfCategory => (ast::SelfStatic.clean(), self.fty.sig.clone()),
             s => {
                 let sig = ty::FnSig {
                     inputs: Vec::from_slice(self.fty.sig.inputs.slice_from(1)),
                     ..self.fty.sig.clone()
                 };
                 let s = match s {
-                    ast::SelfRegion(..) => {
-                        match ty::get(*self.fty.sig.inputs.get(0)).sty {
+                    ty::ByReferenceExplicitSelfCategory(..) => {
+                        match ty::get(self.fty.sig.inputs[0]).sty {
                             ty::ty_rptr(r, mt) => {
                                 SelfBorrowed(r.clean(), mt.mutbl.clean())
                             }
-                            _ => s.clean(),
+                            _ => {
+                                // FIXME(pcwalton): This is wrong.
+                                SelfStatic
+                            }
                         }
                     }
-                    s => s.clean(),
+                    _ => {
+                        // FIXME(pcwalton): This is wrong.
+                        SelfStatic
+                    }
                 };
                 (s, sig)
             }
@@ -1031,7 +1042,7 @@ fn clean(&self) -> Item {
 /// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original
 /// type out of the AST/ty::ctxt given one of these, if more information is needed. Most importantly
 /// it does not preserve mutability or boxes.
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub enum Type {
     /// structs/enums/traits (anything that'd be an ast::TyPath)
     ResolvedPath {
@@ -1549,7 +1560,7 @@ fn clean(&self) -> Span {
     }
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub struct Path {
     pub global: bool,
     pub segments: Vec<PathSegment>,
@@ -1564,7 +1575,7 @@ fn clean(&self) -> Path {
     }
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub struct PathSegment {
     pub name: String,
     pub lifetimes: Vec<Lifetime>,
@@ -1630,7 +1641,7 @@ fn clean(&self) -> Item {
     }
 }
 
-#[deriving(Clone, Encodable, Decodable)]
+#[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub struct BareFunctionDecl {
     pub fn_style: ast::FnStyle,
     pub generics: Generics,
index c549469dcdeaaa19e90ef72caec2f9d438ebf4ea..d0f9b37cc4ce403a7b7dd8421ebb43caa74377c6 100644 (file)
@@ -210,7 +210,7 @@ fn path(w: &mut fmt::Formatter, path: &clean::Path, print_all: bool,
     let loc = current_location_key.get().unwrap();
     let cache = cache_key.get().unwrap();
     let abs_root = root(&**cache, loc.as_slice());
-    let rel_root = match path.segments.get(0).name.as_slice() {
+    let rel_root = match path.segments[0].name.as_slice() {
         "self" => Some("./".to_string()),
         _ => None,
     };
@@ -500,6 +500,9 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 args.push_str(format!("&amp;{}self",
                                       MutableSpace(mtbl)).as_slice());
             }
+            clean::SelfExplicit(ref typ) => {
+                args.push_str(format!("self: {}", *typ).as_slice());
+            }
         }
         for (i, input) in d.inputs.values.iter().enumerate() {
             if i > 0 || args.len() > 0 { args.push_str(", "); }
index 244fada5b9adad07787661991342c9ff2d337020..eed058878e0820f9c41f1ffb51803e58710588fd 100644 (file)
@@ -551,7 +551,7 @@ fn collect(path: &Path, krate: &str,
         }
         mydst.push(format!("{}.{}.js",
                            remote_item_type.to_static_str(),
-                           *remote_path.get(remote_path.len() - 1)));
+                           remote_path[remote_path.len() - 1]));
         let all_implementors = try!(collect(&mydst, krate.name.as_slice(),
                                             "implementors"));
 
index 2cbac090835edf95b730f2e353cbfc4d3008196c..245dc9a0a34e5cbef07bb60834c86814109357f0 100644 (file)
@@ -167,7 +167,7 @@ pub fn main_args(args: &[String]) -> int {
         println!("only one input file may be specified");
         return 1;
     }
-    let input = matches.free.get(0).as_slice();
+    let input = matches.free[0].as_slice();
 
     let libs = matches.opt_strs("L").iter().map(|s| Path::new(s.as_slice())).collect();
 
index da271be4768e3de393d2a22389a4db620cd7a360..f9bc59888ae3b9704f09668929799afc3b24403c 100644 (file)
@@ -75,7 +75,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
                          "invalid markdown file: expecting initial line with `% ...TITLE...`");
         return 5;
     }
-    let title = metadata.get(0).as_slice();
+    let title = metadata[0].as_slice();
 
     reset_headers();
 
index 5145a4f254eea0d8c97482cc87bf4bf5989a1684..cc5bc5cb7c170de7265e18f3ab14bc8ad234e937 100644 (file)
@@ -339,7 +339,7 @@ pub fn unindent(s: &str) -> String {
     });
 
     if lines.len() >= 1 {
-        let mut unindented = vec![ lines.get(0).trim().to_string() ];
+        let mut unindented = vec![ lines[0].trim().to_string() ];
         unindented.push_all(lines.tail().iter().map(|&line| {
             if line.is_whitespace() {
                 line.to_string()
index f7301abef51f23b485b8c79f279df477edf8bc8b..e28c51d517ea3488775f09ca7dac7f98de5931f1 100644 (file)
 
 ## Using Autoserialization
 
-Create a struct called TestStruct1 and serialize and deserialize it to and from JSON
-using the serialization API, using the derived serialization code.
+Create a struct called `TestStruct` and serialize and deserialize it to and from JSON using the
+serialization API, using the derived serialization code.
 
 ```rust
 extern crate serialize;
 use serialize::json;
 
-#[deriving(Decodable, Encodable)] //generate Decodable, Encodable impl.
-pub struct TestStruct1  {
+// Automatically generate `Decodable` and `Encodable` trait implementations
+#[deriving(Decodable, Encodable)]
+pub struct TestStruct  {
     data_int: u8,
     data_str: String,
     data_vector: Vec<u8>,
 }
 
 fn main() {
-    let object = TestStruct1
-         {data_int: 1, data_str:"toto".to_string(), data_vector:vec![2,3,4,5]};
+    let object = TestStruct {
+        data_int: 1,
+        data_str: "toto".to_string(),
+        data_vector: vec![2,3,4,5],
+    };
 
     // Serialize using `json::encode`
     let encoded = json::encode(&object);
 
     // Deserialize using `json::decode`
-    let decoded: TestStruct1 = json::decode(encoded.as_slice()).unwrap();
+    let decoded: TestStruct = json::decode(encoded.as_slice()).unwrap();
 }
 ```
 
-## Using `ToJson`
+## Using the `ToJson` trait
+
+The examples above use the `ToJson` trait to generate the JSON string, which required
+for custom mappings.
+
+### Simple example of `ToJson` usage
+
+```rust
+extern crate serialize;
+use serialize::json::ToJson;
+use serialize::json;
+
+// A custom data structure
+struct ComplexNum {
+    a: f64,
+    b: f64,
+}
+
+// JSON value representation
+impl ToJson for ComplexNum {
+    fn to_json(&self) -> json::Json {
+        json::String(format!("{}+{}i", self.a, self.b))
+    }
+}
 
-This example uses the `ToJson` trait to generate the JSON string.
+// Only generate `Encodable` trait implementation
+#[deriving(Encodable)]
+pub struct ComplexNumRecord {
+    uid: u8,
+    dsc: String,
+    val: json::Json,
+}
+
+fn main() {
+    let num = ComplexNum { a: 0.0001, b: 12.539 };
+    let data: String = json::encode(&ComplexNumRecord{
+        uid: 1,
+        dsc: "test".to_string(),
+        val: num.to_json(),
+    });
+    println!("data: {}", data);
+    // data: {"uid":1,"dsc":"test","val":"0.0001+12.539j"};
+}
+```
+
+### Verbose example of `ToJson` usage
 
 ```rust
+extern crate serialize;
 use std::collections::TreeMap;
 use serialize::json::ToJson;
 use serialize::json;
 
+// Only generate `Decodable` trait implementation
 #[deriving(Decodable)]
-pub struct TestStruct {
+pub struct TestStruct {
     data_int: u8,
     data_str: String,
     data_vector: Vec<u8>,
 }
 
-impl ToJson for TestStruct1 {
-    fn to_json( &self ) -> json::Json {
+// Specify encoding method manually
+impl ToJson for TestStruct {
+    fn to_json(&self) -> json::Json {
         let mut d = TreeMap::new();
+        // All standard types implement `to_json()`, so use it
         d.insert("data_int".to_string(), self.data_int.to_json());
         d.insert("data_str".to_string(), self.data_str.to_json());
         d.insert("data_vector".to_string(), self.data_vector.to_json());
@@ -128,12 +179,16 @@ fn to_json( &self ) -> json::Json {
 
 fn main() {
     // Serialize using `ToJson`
-    let test2 = TestStruct1 {data_int: 1, data_str:"toto".to_string(), data_vector:vec![2,3,4,5]};
-    let tjson: json::Json = test2.to_json();
-    let json_str: String = tjson.to_string();
+    let input_data = TestStruct {
+        data_int: 1,
+        data_str: "toto".to_string(),
+        data_vector: vec![2,3,4,5],
+    };
+    let json_obj: json::Json = input_data.to_json();
+    let json_str: String = json_obj.to_string();
 
     // Deserialize like before
-    let decoded: TestStruct1 = json::decode(json_str.as_slice()).unwrap();
+    let decoded: TestStruct = json::decode(json_str.as_slice()).unwrap();
 }
 ```
 
@@ -1015,7 +1070,7 @@ pub fn is_empty(&self) -> bool { self.stack.is_empty() }
     /// lower indices are at the bottom of the stack while higher indices are
     /// at the top.
     pub fn get<'l>(&'l self, idx: uint) -> StackElement<'l> {
-        match *self.stack.get(idx) {
+        match self.stack[idx] {
             InternalIndex(i) => { Index(i) }
             InternalKey(start, size) => {
                 Key(str::from_utf8(
index 098e87243b69cfe8d75824de5e7cc91e744f0748..9a53c941377e44be6bc29810d392bdc92711825e 100644 (file)
@@ -1484,6 +1484,36 @@ fn extend<T: Iterator<(K, V)>>(&mut self, mut iter: T) {
 /// An implementation of a hash set using the underlying representation of a
 /// HashMap where the value is (). As with the `HashMap` type, a `HashSet`
 /// requires that the elements implement the `Eq` and `Hash` traits.
+///
+/// # Example
+///
+/// ```rust
+/// use std::collections::HashSet;
+///
+/// // Type inference lets us omit an explicit type signature (which
+/// // would be `HashSet<&str>` in this example).
+/// let mut books = HashSet::new();
+///
+/// // Add some books.
+/// books.insert("A Dance With Dragons");
+/// books.insert("To Kill a Mockingbird");
+/// books.insert("The Odyssey");
+/// books.insert("The Great Gatsby");
+///
+/// // Check for a specific one.
+/// if !books.contains(&("The Winds of Winter")) {
+///     println!("We have {} books, but The Winds of Winter ain't one.",
+///              books.len());
+/// }
+///
+/// // Remove a book.
+/// books.remove(&"The Odyssey");
+///
+/// // Iterate over everything.
+/// for book in books.iter() {
+///     println!("{}", *book);
+/// }
+/// ```
 #[deriving(Clone)]
 pub struct HashSet<T, H = RandomSipHasher> {
     map: HashMap<T, (), H>
@@ -1527,6 +1557,13 @@ fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
 
 impl<T: Hash + Eq> HashSet<T, RandomSipHasher> {
     /// Create an empty HashSet
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// # use std::collections::HashSet;
+    /// let mut set: HashSet<int> = HashSet::new();
+    /// ```
     #[inline]
     pub fn new() -> HashSet<T, RandomSipHasher> {
         HashSet::with_capacity(INITIAL_CAPACITY)
@@ -1534,6 +1571,13 @@ pub fn new() -> HashSet<T, RandomSipHasher> {
 
     /// Create an empty HashSet with space for at least `n` elements in
     /// the hash table.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// # use std::collections::HashSet;
+    /// let mut set: HashSet<int> = HashSet::with_capacity(10);
+    /// ```
     #[inline]
     pub fn with_capacity(capacity: uint) -> HashSet<T, RandomSipHasher> {
         HashSet { map: HashMap::with_capacity(capacity) }
@@ -1563,6 +1607,14 @@ pub fn with_capacity_and_hasher(capacity: uint, hasher: H) -> HashSet<T, H> {
     }
 
     /// Reserve space for at least `n` elements in the hash table.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// # use std::collections::HashSet;
+    /// let mut set: HashSet<int> = HashSet::new();
+    /// set.reserve(10);
+    /// ```
     pub fn reserve(&mut self, n: uint) {
         self.map.reserve(n)
     }
@@ -1575,6 +1627,20 @@ pub fn contains_equiv<Q: Hash<S> + Equiv<T>>(&self, value: &Q) -> bool {
 
     /// An iterator visiting all elements in arbitrary order.
     /// Iterator element type is &'a T.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// # use std::collections::HashSet;
+    /// let mut set = HashSet::new();
+    /// set.insert("a");
+    /// set.insert("b");
+    ///
+    /// // Will print in an arbitrary order.
+    /// for x in set.iter() {
+    ///     println!("{}", x);
+    /// }
+    /// ```
     pub fn iter<'a>(&'a self) -> SetItems<'a, T> {
         self.map.keys()
     }
@@ -1582,11 +1648,49 @@ pub fn iter<'a>(&'a self) -> SetItems<'a, T> {
     /// Creates a consuming iterator, that is, one that moves each value out
     /// of the set in arbitrary order. The set cannot be used after calling
     /// this.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// # use std::collections::HashSet;
+    /// let mut set = HashSet::new();
+    /// set.insert("a".to_string());
+    /// set.insert("b".to_string());
+    ///
+    /// // Not possible to collect to a Vec<String> with a regular `.iter()`.
+    /// let v: Vec<String> = set.move_iter().collect();
+    ///
+    /// // Will print in an arbitrary order.
+    /// for x in v.iter() {
+    ///     println!("{}", x);
+    /// }
+    /// ```
     pub fn move_iter(self) -> SetMoveItems<T> {
         self.map.move_iter().map(|(k, _)| k)
     }
 
-    /// Visit the values representing the difference
+    /// Visit the values representing the difference.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// # use std::collections::HashSet;
+    /// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
+    /// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
+    ///
+    /// // Can be seen as `a - b`.
+    /// for x in a.difference(&b) {
+    ///     println!("{}", x); // Print 1
+    /// }
+    ///
+    /// let diff: HashSet<int> = a.difference(&b).map(|&x| x).collect();
+    /// assert_eq!(diff, [1i].iter().map(|&x| x).collect());
+    ///
+    /// // Note that difference is not symmetric,
+    /// // and `b - a` means something else:
+    /// let diff: HashSet<int> = b.difference(&a).map(|&x| x).collect();
+    /// assert_eq!(diff, [4i].iter().map(|&x| x).collect());
+    /// ```
     pub fn difference<'a>(&'a self, other: &'a HashSet<T, H>) -> SetAlgebraItems<'a, T, H> {
         Repeat::new(other).zip(self.iter())
             .filter_map(|(other, elt)| {
@@ -1594,13 +1698,48 @@ pub fn difference<'a>(&'a self, other: &'a HashSet<T, H>) -> SetAlgebraItems<'a,
             })
     }
 
-    /// Visit the values representing the symmetric difference
+    /// Visit the values representing the symmetric difference.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// # use std::collections::HashSet;
+    /// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
+    /// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
+    ///
+    /// // Print 1, 4 in arbitrary order.
+    /// for x in a.symmetric_difference(&b) {
+    ///     println!("{}", x);
+    /// }
+    ///
+    /// let diff1: HashSet<int> = a.symmetric_difference(&b).map(|&x| x).collect();
+    /// let diff2: HashSet<int> = b.symmetric_difference(&a).map(|&x| x).collect();
+    ///
+    /// assert_eq!(diff1, diff2);
+    /// assert_eq!(diff1, [1i, 4].iter().map(|&x| x).collect());
+    /// ```
     pub fn symmetric_difference<'a>(&'a self, other: &'a HashSet<T, H>)
         -> Chain<SetAlgebraItems<'a, T, H>, SetAlgebraItems<'a, T, H>> {
         self.difference(other).chain(other.difference(self))
     }
 
-    /// Visit the values representing the intersection
+    /// Visit the values representing the intersection.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// # use std::collections::HashSet;
+    /// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
+    /// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
+    ///
+    /// // Print 2, 3 in arbitrary order.
+    /// for x in a.intersection(&b) {
+    ///     println!("{}", x);
+    /// }
+    ///
+    /// let diff: HashSet<int> = a.intersection(&b).map(|&x| x).collect();
+    /// assert_eq!(diff, [2i, 3].iter().map(|&x| x).collect());
+    /// ```
     pub fn intersection<'a>(&'a self, other: &'a HashSet<T, H>)
         -> SetAlgebraItems<'a, T, H> {
         Repeat::new(other).zip(self.iter())
@@ -1609,7 +1748,23 @@ pub fn intersection<'a>(&'a self, other: &'a HashSet<T, H>)
             })
     }
 
-    /// Visit the values representing the union
+    /// Visit the values representing the union.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// # use std::collections::HashSet;
+    /// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
+    /// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
+    ///
+    /// // Print 1, 2, 3, 4 in arbitrary order.
+    /// for x in a.union(&b) {
+    ///     println!("{}", x);
+    /// }
+    ///
+    /// let diff: HashSet<int> = a.union(&b).map(|&x| x).collect();
+    /// assert_eq!(diff, [1i, 2, 3, 4].iter().map(|&x| x).collect());
+    /// ```
     pub fn union<'a>(&'a self, other: &'a HashSet<T, H>)
         -> Chain<SetItems<'a, T>, SetAlgebraItems<'a, T, H>> {
         self.iter().chain(other.difference(self))
index b700d57bc033df1b2323fad022fdd15d75619a45..7343838f19e6156d536ca764de216964b0df4a20 100644 (file)
@@ -90,7 +90,7 @@ fn push(&self, value: T) -> bool {
         let mask = self.mask;
         let mut pos = self.enqueue_pos.load(Relaxed);
         loop {
-            let node = self.buffer.get(pos & mask);
+            let node = &self.buffer[pos & mask];
             let seq = unsafe { (*node.get()).sequence.load(Acquire) };
             let diff: int = seq as int - pos as int;
 
@@ -118,7 +118,7 @@ fn pop(&self) -> Option<T> {
         let mask = self.mask;
         let mut pos = self.dequeue_pos.load(Relaxed);
         loop {
-            let node = self.buffer.get(pos & mask);
+            let node = &self.buffer[pos & mask];
             let seq = unsafe { (*node.get()).sequence.load(Acquire) };
             let diff: int = seq as int - (pos + 1) as int;
             if diff == 0 {
index 26cc0b2c6a23cd772889819cfad701cd48c523e3..d056566bb9a97908a61b134f1fe80cabe1c802c0 100644 (file)
@@ -243,7 +243,7 @@ pub fn wait_on(&self, condvar_id: uint) {
                     }
                     // Create waiter nobe, and enqueue ourself to
                     // be woken up by a signaller.
-                    wait_end = Some(state.blocked.get(condvar_id).wait_end());
+                    wait_end = Some(state.blocked[condvar_id].wait_end());
                 } else {
                     out_of_bounds = Some(state.blocked.len());
                 }
@@ -281,7 +281,7 @@ pub fn signal_on(&self, condvar_id: uint) -> bool {
             let mut result = false;
             self.sem.with(|state| {
                 if condvar_id < state.blocked.len() {
-                    result = state.blocked.get(condvar_id).signal();
+                    result = state.blocked[condvar_id].signal();
                 } else {
                     out_of_bounds = Some(state.blocked.len());
                 }
index c7154da494f7161ce2fd38627f0dfb56fb95aa9d..d9f14bfa15661da7b5d59db64208a77c992b580e 100644 (file)
@@ -152,7 +152,7 @@ fn decode(d: &mut D) -> Result<Ident, E> {
 /// Function name (not all functions have names)
 pub type FnIdent = Option<Ident>;
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Lifetime {
     pub id: NodeId,
     pub span: Span,
@@ -162,7 +162,7 @@ pub struct Lifetime {
 /// A "Path" is essentially Rust's notion of a name; for instance:
 /// std::cmp::PartialEq  .  It's represented as a sequence of identifiers,
 /// along with a bunch of supporting information.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Path {
     pub span: Span,
     /// A `::foo` path, is relative to the crate root rather than current
@@ -174,7 +174,7 @@ pub struct Path {
 
 /// A segment of a path: an identifier, an optional lifetime, and a set of
 /// types.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct PathSegment {
     /// The identifier portion of this path segment.
     pub identifier: Ident,
@@ -208,7 +208,7 @@ pub struct DefId {
 /// typeck::collect::compute_bounds matches these against
 /// the "special" built-in traits (see middle::lang_items) and
 /// detects Copy, Send and Share.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum TyParamBound {
     TraitTyParamBound(TraitRef),
     StaticRegionTyParamBound,
@@ -216,7 +216,7 @@ pub enum TyParamBound {
     OtherRegionTyParamBound(Span) // FIXME -- just here until work for #5723 lands
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct TyParam {
     pub ident: Ident,
     pub id: NodeId,
@@ -228,7 +228,7 @@ pub struct TyParam {
 
 /// Represents lifetimes and type parameters attached to a declaration
 /// of a function, enum, trait, etc.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Generics {
     pub lifetimes: Vec<Lifetime>,
     pub ty_params: OwnedSlice<TyParam>,
@@ -250,7 +250,7 @@ pub fn is_type_parameterized(&self) -> bool {
 /// used to drive conditional compilation
 pub type CrateConfig = Vec<Gc<MetaItem>> ;
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Crate {
     pub module: Mod,
     pub attrs: Vec<Attribute>,
@@ -261,7 +261,7 @@ pub struct Crate {
 
 pub type MetaItem = Spanned<MetaItem_>;
 
-#[deriving(Clone, Encodable, Decodable, Eq, Hash)]
+#[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)]
 pub enum MetaItem_ {
     MetaWord(InternedString),
     MetaList(InternedString, Vec<Gc<MetaItem>>),
@@ -293,7 +293,7 @@ fn eq(&self, other: &MetaItem_) -> bool {
     }
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Block {
     pub view_items: Vec<ViewItem>,
     pub stmts: Vec<Gc<Stmt>>,
@@ -303,26 +303,26 @@ pub struct Block {
     pub span: Span,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Pat {
     pub id: NodeId,
     pub node: Pat_,
     pub span: Span,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct FieldPat {
     pub ident: Ident,
     pub pat: Gc<Pat>,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum BindingMode {
     BindByRef(Mutability),
     BindByValue(Mutability),
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Pat_ {
     PatWild,
     PatWildMulti,
@@ -354,7 +354,7 @@ pub enum Mutability {
     MutImmutable,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum ExprVstore {
     /// ~[1, 2, 3, 4]
     ExprVstoreUniq,
@@ -364,7 +364,7 @@ pub enum ExprVstore {
     ExprVstoreMutSlice,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum BinOp {
     BiAdd,
     BiSub,
@@ -386,7 +386,7 @@ pub enum BinOp {
     BiGt,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum UnOp {
     UnBox,
     UnUniq,
@@ -397,7 +397,7 @@ pub enum UnOp {
 
 pub type Stmt = Spanned<Stmt_>;
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Stmt_ {
     /// Could be an item or a local (let) binding:
     StmtDecl(Gc<Decl>, NodeId),
@@ -414,7 +414,7 @@ pub enum Stmt_ {
 
 /// Where a local declaration came from: either a true `let ... =
 /// ...;`, or one desugared from the pattern of a for loop.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum LocalSource {
     LocalLet,
     LocalFor,
@@ -423,7 +423,7 @@ pub enum LocalSource {
 // FIXME (pending discussion of #1697, #2178...): local should really be
 // a refinement on pat.
 /// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Local {
     pub ty: P<Ty>,
     pub pat: Gc<Pat>,
@@ -435,7 +435,7 @@ pub struct Local {
 
 pub type Decl = Spanned<Decl_>;
 
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Decl_ {
     /// A local (let) binding:
     DeclLocal(Gc<Local>),
@@ -444,7 +444,7 @@ pub enum Decl_ {
 }
 
 /// represents one arm of a 'match'
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Arm {
     pub attrs: Vec<Attribute>,
     pub pats: Vec<Gc<Pat>>,
@@ -452,7 +452,7 @@ pub struct Arm {
     pub body: Gc<Expr>,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Field {
     pub ident: SpannedIdent,
     pub expr: Gc<Expr>,
@@ -461,26 +461,26 @@ pub struct Field {
 
 pub type SpannedIdent = Spanned<Ident>;
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum BlockCheckMode {
     DefaultBlock,
     UnsafeBlock(UnsafeSource),
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum UnsafeSource {
     CompilerGenerated,
     UserProvided,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Expr {
     pub id: NodeId,
     pub node: Expr_,
     pub span: Span,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Expr_ {
     ExprVstore(Gc<Expr>, ExprVstore),
     /// First expr is the place; second expr is the value.
@@ -547,7 +547,7 @@ pub enum Expr_ {
 /// makes any real sense. You could write them elsewhere but nothing
 /// else knows what to do with them, so you'll probably get a syntax
 /// error.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 #[doc="For macro invocations; parsing is delegated to the macro"]
 pub enum TokenTree {
     /// A single token
@@ -621,7 +621,7 @@ pub enum TokenTree {
 // macro system. Congratulations.
 pub type Matcher = Spanned<Matcher_>;
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Matcher_ {
     /// Match one token
     MatchTok(::parse::token::Token),
@@ -638,7 +638,7 @@ pub enum Matcher_ {
 /// is being invoked, and the vector of token-trees contains the source
 /// of the macro invocation.
 /// There's only one flavor, now, so this could presumably be simplified.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Mac_ {
     // NB: the additional ident for a macro_rules-style macro is actually
     // stored in the enclosing item. Oog.
@@ -670,13 +670,13 @@ pub enum Lit_ {
 
 // NB: If you change this, you'll probably want to change the corresponding
 // type structure in middle/ty.rs as well.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct MutTy {
     pub ty: P<Ty>,
     pub mutbl: Mutability,
 }
 
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct TypeField {
     pub ident: Ident,
     pub mt: MutTy,
@@ -685,7 +685,7 @@ pub struct TypeField {
 
 /// Represents a required method in a trait declaration,
 /// one without a default implementation
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct TypeMethod {
     pub ident: Ident,
     pub attrs: Vec<Attribute>,
@@ -702,7 +702,7 @@ pub struct TypeMethod {
 /// a default implementation A trait method is either required (meaning it
 /// doesn't have an implementation, just a signature) or provided (meaning it
 /// has a default implementation).
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum TraitMethod {
     Required(TypeMethod),
     Provided(Gc<Method>),
@@ -779,7 +779,7 @@ pub fn suffix_len(&self) -> uint {
 }
 
 // NB PartialEq method appears below.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Ty {
     pub id: NodeId,
     pub node: Ty_,
@@ -787,7 +787,7 @@ pub struct Ty {
 }
 
 /// Not represented directly in the AST, referred to by name through a ty_path.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum PrimTy {
     TyInt(IntTy),
     TyUint(UintTy),
@@ -813,7 +813,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 /// Represents the type of a closure
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct ClosureTy {
     pub lifetimes: Vec<Lifetime>,
     pub fn_style: FnStyle,
@@ -826,7 +826,7 @@ pub struct ClosureTy {
     pub bounds: Option<OwnedSlice<TyParamBound>>,
 }
 
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct BareFnTy {
     pub fn_style: FnStyle,
     pub abi: Abi,
@@ -834,12 +834,12 @@ pub struct BareFnTy {
     pub decl: P<FnDecl>
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct UnboxedFnTy {
     pub decl: P<FnDecl>,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Ty_ {
     TyNil,
     TyBot, /* bottom type */
@@ -863,13 +863,13 @@ pub enum Ty_ {
     TyInfer,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum AsmDialect {
     AsmAtt,
     AsmIntel
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct InlineAsm {
     pub asm: InternedString,
     pub asm_str_style: StrStyle,
@@ -882,7 +882,7 @@ pub struct InlineAsm {
 }
 
 /// represents an argument in a function header
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Arg {
     pub ty: P<Ty>,
     pub pat: Gc<Pat>,
@@ -910,7 +910,7 @@ pub fn new_self(span: Span, mutability: Mutability, self_ident: Ident) -> Arg {
 }
 
 /// represents the header (not the body) of a function declaration
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct FnDecl {
     pub inputs: Vec<Arg>,
     pub output: P<Ty>,
@@ -935,7 +935,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum RetStyle {
     /// Functions with return type ! that always
     /// raise an error or exit (i.e. never return to the caller)
@@ -945,21 +945,23 @@ pub enum RetStyle {
 }
 
 /// Represents the kind of 'self' associated with a method
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum ExplicitSelf_ {
     /// No self
     SelfStatic,
-    /// `self
+    /// `self`
     SelfValue(Ident),
     /// `&'lt self`, `&'lt mut self`
     SelfRegion(Option<Lifetime>, Mutability, Ident),
     /// `~self`
-    SelfUniq(Ident)
+    SelfUniq(Ident),
+    /// `self: TYPE`
+    SelfExplicit(P<Ty>, Ident),
 }
 
 pub type ExplicitSelf = Spanned<ExplicitSelf_>;
 
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Method {
     pub attrs: Vec<Attribute>,
     pub id: NodeId,
@@ -967,7 +969,7 @@ pub struct Method {
     pub node: Method_
 }
 
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Method_ {
     /// Represents a method declaration
     MethDecl(Ident, Generics, ExplicitSelf, FnStyle, P<FnDecl>, P<Block>, Visibility),
@@ -975,7 +977,7 @@ pub enum Method_ {
     MethMac(Mac),
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Mod {
     /// A span from the first token past `{` to the last token until `}`.
     /// For `mod foo;`, the inner span ranges from the first token
@@ -985,31 +987,31 @@ pub struct Mod {
     pub items: Vec<Gc<Item>>,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct ForeignMod {
     pub abi: Abi,
     pub view_items: Vec<ViewItem>,
     pub items: Vec<Gc<ForeignItem>>,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct VariantArg {
     pub ty: P<Ty>,
     pub id: NodeId,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum VariantKind {
     TupleVariantKind(Vec<VariantArg>),
     StructVariantKind(Gc<StructDef>),
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct EnumDef {
     pub variants: Vec<P<Variant>>,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Variant_ {
     pub name: Ident,
     pub attrs: Vec<Attribute>,
@@ -1021,7 +1023,7 @@ pub struct Variant_ {
 
 pub type Variant = Spanned<Variant_>;
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct PathListIdent_ {
     pub name: Ident,
     pub id: NodeId,
@@ -1031,7 +1033,7 @@ pub struct PathListIdent_ {
 
 pub type ViewPath = Spanned<ViewPath_>;
 
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum ViewPath_ {
 
     /// `quux = foo::bar::baz`
@@ -1048,7 +1050,7 @@ pub enum ViewPath_ {
     ViewPathList(Path, Vec<PathListIdent> , NodeId)
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct ViewItem {
     pub node: ViewItem_,
     pub attrs: Vec<Attribute>,
@@ -1056,7 +1058,7 @@ pub struct ViewItem {
     pub span: Span,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum ViewItem_ {
     /// Ident: name used to refer to this crate in the code
     /// optional (InternedString,StrStyle): if present, this is a location
@@ -1072,17 +1074,17 @@ pub enum ViewItem_ {
 /// Distinguishes between Attributes that decorate items and Attributes that
 /// are contained as statements within items. These two cases need to be
 /// distinguished for pretty-printing.
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum AttrStyle {
     AttrOuter,
     AttrInner,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct AttrId(pub uint);
 
 /// Doc-comments are promoted to attributes that have is_sugared_doc = true
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Attribute_ {
     pub id: AttrId,
     pub style: AttrStyle,
@@ -1096,13 +1098,13 @@ pub struct Attribute_ {
 /// that the ref_id is for. The impl_id maps to the "self type" of this impl.
 /// If this impl is an ItemImpl, the impl_id is redundant (it could be the
 /// same as the impl's node id).
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash,   Show)]
 pub struct TraitRef {
     pub path: Path,
     pub ref_id: NodeId,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Visibility {
     Public,
     Inherited,
@@ -1117,7 +1119,7 @@ pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility {
     }
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct StructField_ {
     pub kind: StructFieldKind,
     pub id: NodeId,
@@ -1136,7 +1138,7 @@ pub fn ident(&self) -> Option<Ident> {
 
 pub type StructField = Spanned<StructField_>;
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum StructFieldKind {
     NamedField(Ident, Visibility),
     /// Element of a tuple-like struct
@@ -1152,7 +1154,7 @@ pub fn is_unnamed(&self) -> bool {
     }
 }
 
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct StructDef {
     /// Fields, not including ctor
     pub fields: Vec<StructField>,
@@ -1169,7 +1171,7 @@ pub struct StructDef {
   FIXME (#3300): Should allow items to be anonymous. Right now
   we just use dummy names for anon items.
  */
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct Item {
     pub ident: Ident,
     pub attrs: Vec<Attribute>,
@@ -1179,7 +1181,7 @@ pub struct Item {
     pub span: Span,
 }
 
-#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum Item_ {
     ItemStatic(P<Ty>, Mutability, Gc<Expr>),
     ItemFn(P<FnDecl>, FnStyle, Abi, Generics, P<Block>),
@@ -1202,7 +1204,7 @@ pub enum Item_ {
     ItemMac(Mac),
 }
 
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub struct ForeignItem {
     pub ident: Ident,
     pub attrs: Vec<Attribute>,
@@ -1212,7 +1214,7 @@ pub struct ForeignItem {
     pub vis: Visibility,
 }
 
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum ForeignItem_ {
     ForeignItemFn(P<FnDecl>, Generics),
     ForeignItemStatic(P<Ty>, /* is_mutbl */ bool),
@@ -1221,7 +1223,7 @@ pub enum ForeignItem_ {
 /// The data we save and restore about an inlined item or method.  This is not
 /// part of the AST that we parse from a file, but it becomes part of the tree
 /// that we trans.
-#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
 pub enum InlinedItem {
     IIItem(Gc<Item>),
     IIMethod(DefId /* impl id */, bool /* is provided */, Gc<Method>),
index 1280b884f117a05a2c0819e98c764d95cd29516d..a522f80554327f89a297c2c6107c821923cad6bb 100644 (file)
@@ -26,7 +26,7 @@
 use ast;
 use ast_map::{Node};
 use ast_map;
-use ast_util;
+use ast_util::PostExpansionMethod;
 use codemap::Span;
 use visit;
 
@@ -152,13 +152,13 @@ pub fn to_fn_parts<'a>(&'a self) -> FnParts<'a> {
 
     pub fn body<'a>(&'a self) -> P<Block> {
         self.handle(|i: ItemFnParts|     i.body,
-                    |m: &'a ast::Method| ast_util::method_body(m),
+                    |m: &'a ast::Method| m.pe_body(),
                     |c: ClosureParts|    c.body)
     }
 
     pub fn decl<'a>(&'a self) -> P<FnDecl> {
         self.handle(|i: ItemFnParts|     i.decl,
-                    |m: &'a ast::Method| ast_util::method_fn_decl(m),
+                    |m: &'a ast::Method| m.pe_fn_decl(),
                     |c: ClosureParts|    c.decl)
     }
 
@@ -182,7 +182,7 @@ pub fn kind<'a>(&'a self) -> visit::FnKind<'a> {
             visit::FkFnBlock
         };
         let method = |m: &'a ast::Method| {
-            visit::FkMethod(ast_util::method_ident(m), ast_util::method_generics(m), m)
+            visit::FkMethod(m.pe_ident(), m.pe_generics(), m)
         };
         self.handle(item, method, closure)
     }
index a18d8a81ef47f7655b9cfb55a99d9656374ae54c..5431a3db16ecb24a437f29161f47ff15fab16232 100644 (file)
@@ -742,16 +742,48 @@ pub fn static_has_significant_address(mutbl: ast::Mutability,
     inline == InlineNever || inline == InlineNone
 }
 
-
 /// Macro invocations are guaranteed not to occur after expansion is complete.
-/// extracting fields of a method requires a dynamic check to make sure that it's
-/// not a macro invocation, though this check is guaranteed to succeed, assuming
+/// Extracting fields of a method requires a dynamic check to make sure that it's
+/// not a macro invocation. This check is guaranteed to succeed, assuming
 /// that the invocations are indeed gone.
-macro_rules! method_field_extractor {
-    ($fn_name:ident, $field_ty:ty, $field_pat:pat, $result:ident) => {
-        /// Returns the ident of a Method. To be used after expansion is complete
-        pub fn $fn_name<'a>(method: &'a ast::Method) -> $field_ty {
-            match method.node {
+pub trait PostExpansionMethod {
+    fn pe_ident(&self) -> ast::Ident;
+    fn pe_generics<'a>(&'a self) -> &'a ast::Generics;
+    fn pe_explicit_self<'a>(&'a self) -> &'a ast::ExplicitSelf;
+    fn pe_fn_style(&self) -> ast::FnStyle;
+    fn pe_fn_decl(&self) -> P<ast::FnDecl>;
+    fn pe_body(&self) -> P<ast::Block>;
+    fn pe_vis(&self) -> ast::Visibility;
+}
+
+
+/// can't use the standard cfg(stage0) tricks here, because the error occurs in
+/// parsing, before cfg gets a chance to save the day. (yes, interleaved parsing
+/// / expansion / configuring would solve this problem...)
+
+// NOTE: remove after next snapshot
+/// to be more specific: after a snapshot, swap out the "PRE" stuff, and
+// swap in the "POST" stuff.
+
+/// PRE
+macro_rules! mf_method_body{
+    ($slf:ident, $field_pat:pat, $result:ident) => {
+        match $slf.node {
+            $field_pat => $result,
+                MethMac(_) => {
+                    fail!("expected an AST without macro invocations");
+                }
+        }
+    }
+}
+
+/// POST
+/*
+#[cfg(not(stage0))]
+macro_rules! mf_method{
+    ($meth_name:ident, $field_ty:ty, $field_pat:pat, $result:ident) => {
+        fn $meth_name<'a>(&'a self) -> $field_ty {
+            match self.node {
                 $field_pat => $result,
                 MethMac(_) => {
                     fail!("expected an AST without macro invocations");
@@ -759,20 +791,49 @@ pub fn $fn_name<'a>(method: &'a ast::Method) -> $field_ty {
             }
         }
     }
+}*/
+
+
+// PRE
+impl PostExpansionMethod for Method {
+    fn pe_ident(&self) -> ast::Ident {
+        mf_method_body!(self,MethDecl(ident,_,_,_,_,_,_),ident)
+    }
+    fn pe_generics<'a>(&'a self) -> &'a ast::Generics {
+        mf_method_body!(self,MethDecl(_,ref generics,_,_,_,_,_),generics)
+    }
+    fn pe_explicit_self<'a>(&'a self) -> &'a ast::ExplicitSelf {
+        mf_method_body!(self,MethDecl(_,_,ref explicit_self,_,_,_,_),explicit_self)
+    }
+    fn pe_fn_style(&self) -> ast::FnStyle{
+        mf_method_body!(self,MethDecl(_,_,_,fn_style,_,_,_),fn_style)
+    }
+    fn pe_fn_decl(&self) -> P<ast::FnDecl> {
+        mf_method_body!(self,MethDecl(_,_,_,_,decl,_,_),decl)
+    }
+    fn pe_body(&self) -> P<ast::Block> {
+        mf_method_body!(self,MethDecl(_,_,_,_,_,body,_),body)
+    }
+    fn pe_vis(&self) -> ast::Visibility {
+        mf_method_body!(self,MethDecl(_,_,_,_,_,_,vis),vis)
+    }
 }
 
-// Note: this is unhygienic in the lifetime 'a. In order to fix this, we'd have to
-// add :lifetime as a macro argument type, so that the 'a could be supplied by the macro
-// invocation.
-pub method_field_extractor!(method_ident,ast::Ident,MethDecl(ident,_,_,_,_,_,_),ident)
-pub method_field_extractor!(method_generics,&'a ast::Generics,
-                            MethDecl(_,ref generics,_,_,_,_,_),generics)
-pub method_field_extractor!(method_explicit_self,&'a ast::ExplicitSelf,
-                            MethDecl(_,_,ref explicit_self,_,_,_,_),explicit_self)
-pub method_field_extractor!(method_fn_style,ast::FnStyle,MethDecl(_,_,_,fn_style,_,_,_),fn_style)
-pub method_field_extractor!(method_fn_decl,P<ast::FnDecl>,MethDecl(_,_,_,_,decl,_,_),decl)
-pub method_field_extractor!(method_body,P<ast::Block>,MethDecl(_,_,_,_,_,body,_),body)
-pub method_field_extractor!(method_vis,ast::Visibility,MethDecl(_,_,_,_,_,_,vis),vis)
+// POST
+/*
+#[cfg(not(stage0))]
+impl PostExpansionMethod for Method {
+    mf_method!(pe_ident,ast::Ident,MethDecl(ident,_,_,_,_,_,_),ident)
+    mf_method!(pe_generics,&'a ast::Generics,
+               MethDecl(_,ref generics,_,_,_,_,_),generics)
+    mf_method!(pe_explicit_self,&'a ast::ExplicitSelf,
+               MethDecl(_,_,ref explicit_self,_,_,_,_),explicit_self)
+    mf_method!(pe_fn_style,ast::FnStyle,MethDecl(_,_,_,fn_style,_,_,_),fn_style)
+    mf_method!(pe_fn_decl,P<ast::FnDecl>,MethDecl(_,_,_,_,decl,_,_),decl)
+    mf_method!(pe_body,P<ast::Block>,MethDecl(_,_,_,_,_,body,_),body)
+    mf_method!(pe_vis,ast::Visibility,MethDecl(_,_,_,_,_,_,vis),vis)
+}
+*/
 
 #[cfg(test)]
 mod test {
@@ -799,4 +860,3 @@ fn ident_to_segment(id : &Ident) -> PathSegment {
                 .iter().map(ident_to_segment).collect::<Vec<PathSegment>>().as_slice()));
     }
 }
-
index f6a39d7b2e6c1b6dda6c57356f7de62592c1a98e..06eb92e1b271b1c1e333f7639be97b84a124aa02 100644 (file)
@@ -25,8 +25,6 @@
 
 /// The types of pointers
 pub enum PtrTy<'a> {
-    /// ~
-    Send,
     /// &'lifetime mut
     Borrowed(Option<&'a str>, ast::Mutability),
 }
@@ -138,9 +136,6 @@ pub fn to_ty(&self,
             Ptr(ref ty, ref ptr) => {
                 let raw_ty = ty.to_ty(cx, span, self_ty, self_generics);
                 match *ptr {
-                    Send => {
-                        cx.ty_uniq(span, raw_ty)
-                    }
                     Borrowed(ref lt, mutbl) => {
                         let lt = mk_lifetime(cx, span, lt);
                         cx.ty_rptr(span, raw_ty, lt, mutbl)
@@ -260,7 +255,6 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>)
             let self_ty = respan(
                 span,
                 match *ptr {
-                    Send => ast::SelfUniq(special_idents::self_),
                     Borrowed(ref lt, mutbl) => {
                         let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s).name));
                         ast::SelfRegion(lt, mutbl, special_idents::self_)
index fd786192cb48c181745bf1ed0a7b7022ec9b2440..87c762af2e5bd63244c988c3215977108925b8e6 100644 (file)
@@ -344,6 +344,7 @@ fn fold_explicit_self_(&mut self, es: &ExplicitSelf_) -> ExplicitSelf_ {
             SelfRegion(ref lifetime, m, id) => {
                 SelfRegion(fold_opt_lifetime(lifetime, self), m, id)
             }
+            SelfExplicit(ref typ, id) => SelfExplicit(self.fold_ty(*typ), id),
         }
     }
 
index 530ea013112386f1203d00135452273cc9ad4008..7eb6709919aaf082198e5a3d1778d75b0eb9ea89 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use std::fmt;
 use std::default::Default;
 use std::hash;
 use std::{mem, raw, ptr, slice};
@@ -22,6 +23,17 @@ pub struct OwnedSlice<T> {
     len: uint,
 }
 
+impl<T:fmt::Show> fmt::Show for OwnedSlice<T> {
+    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+        try!("OwnedSlice {{".fmt(fmt));
+        for i in self.iter() {
+            try!(i.fmt(fmt));
+        }
+        try!("}}".fmt(fmt));
+        Ok(())
+    }
+}
+
 #[unsafe_destructor]
 impl<T> Drop for OwnedSlice<T> {
     fn drop(&mut self) {
index e0c94dffb5cae342603ddb9cf1fcdc6e9e9dc777..bdfd928cfbcd8a5e22abaa9b66883f08fbb34195 100644 (file)
@@ -45,7 +45,7 @@
 use ast::{StmtExpr, StmtSemi, StmtMac, StructDef, StructField};
 use ast::{StructVariantKind, BiSub};
 use ast::StrStyle;
-use ast::{SelfRegion, SelfStatic, SelfUniq, SelfValue};
+use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfUniq, SelfValue};
 use ast::{TokenTree, TraitMethod, TraitRef, TTDelim, TTSeq, TTTok};
 use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot, TyBox};
 use ast::{TypeField, TyFixedLengthVec, TyClosure, TyProc, TyBareFn};
@@ -3843,7 +3843,15 @@ fn maybe_parse_borrowed_explicit_self(this: &mut Parser)
                 }
             }
             token::IDENT(..) if self.is_self_ident() => {
-                SelfValue(self.expect_self_ident())
+                let self_ident = self.expect_self_ident();
+
+                // Determine whether this is the fully explicit form, `self:
+                // TYPE`.
+                if self.eat(&token::COLON) {
+                    SelfExplicit(self.parse_ty(false), self_ident)
+                } else {
+                    SelfValue(self_ident)
+                }
             }
             token::BINOP(token::STAR) => {
                 // Possibly "*self" or "*mut self" -- not supported. Try to avoid
@@ -3851,7 +3859,9 @@ fn maybe_parse_borrowed_explicit_self(this: &mut Parser)
                 self.bump();
                 let _mutability = if Parser::token_is_mutability(&self.token) {
                     self.parse_mutability()
-                } else { MutImmutable };
+                } else {
+                    MutImmutable
+                };
                 if self.is_self_ident() {
                     let span = self.span;
                     self.span_err(span, "cannot pass self by unsafe pointer");
@@ -3863,7 +3873,15 @@ fn maybe_parse_borrowed_explicit_self(this: &mut Parser)
             _ if Parser::token_is_mutability(&self.token) &&
                     self.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) => {
                 mutbl_self = self.parse_mutability();
-                SelfValue(self.expect_self_ident())
+                let self_ident = self.expect_self_ident();
+
+                // Determine whether this is the fully explicit form, `self:
+                // TYPE`.
+                if self.eat(&token::COLON) {
+                    SelfExplicit(self.parse_ty(false), self_ident)
+                } else {
+                    SelfValue(self_ident)
+                }
             }
             _ if Parser::token_is_mutability(&self.token) &&
                     self.look_ahead(1, |t| *t == token::TILDE) &&
@@ -3914,8 +3932,8 @@ macro_rules! parse_remaining_arguments {
             }
             SelfValue(id) => parse_remaining_arguments!(id),
             SelfRegion(_,_,id) => parse_remaining_arguments!(id),
-            SelfUniq(id) => parse_remaining_arguments!(id)
-
+            SelfUniq(id) => parse_remaining_arguments!(id),
+            SelfExplicit(_,id) => parse_remaining_arguments!(id),
         };
 
 
index d524622f8ecf59ad9a36eb22badd0ff88f4dd504..428a15cb8cf746bc86a495dcaab509dd0d4e9799 100644 (file)
@@ -1859,6 +1859,11 @@ fn print_explicit_self(&mut self,
                 try!(self.print_mutability(m));
                 try!(word(&mut self.s, "self"));
             }
+            ast::SelfExplicit(ref typ, _) => {
+                try!(word(&mut self.s, "self"));
+                try!(self.word_space(":"));
+                try!(self.print_type(*typ));
+            }
         }
         return Ok(true);
     }
index 795f19d0cfb06170050fea6da1206a8e09390189..6760d7a3932055bb7ae77de9c69431ab2149c46c 100644 (file)
@@ -215,6 +215,7 @@ pub fn walk_explicit_self<E: Clone, V: Visitor<E>>(visitor: &mut V,
         SelfRegion(ref lifetime, _, _) => {
             visitor.visit_opt_lifetime_ref(explicit_self.span, lifetime, env)
         }
+        SelfExplicit(ref typ, _) => visitor.visit_ty(*typ, env.clone()),
     }
 }
 
index 139f1113aaf9434fa3454cd3a5e85e458a306acf..db76e78d1617c89b065bd2436bf68dba90f30670 100644 (file)
@@ -512,13 +512,13 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
             assert!(!s.is_empty(), "string conversion produced empty result");
             match op {
                 FormatDigit => {
-                    if flags.space && !(*s.get(0) == '-' as u8 ||
-                                        *s.get(0) == '+' as u8) {
+                    if flags.space && !(s[0] == '-' as u8 ||
+                                        s[0] == '+' as u8) {
                         s.unshift(' ' as u8);
                     }
                 }
                 FormatOctal => {
-                    if flags.alternate && *s.get(0) != '0' as u8 {
+                    if flags.alternate && s[0] != '0' as u8 {
                         s.unshift('0' as u8);
                     }
                 }
index a857bc7535d9c3250061f2f376dede132923c088..15c5fa6b75a5ab6492b6f36681e2d25eb32feab9 100644 (file)
@@ -373,7 +373,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
     if matches.opt_present("h") { usage(args[0].as_slice()); return None; }
 
     let filter = if matches.free.len() > 0 {
-        let s = matches.free.get(0).as_slice();
+        let s = matches.free[0].as_slice();
         match Regex::new(s) {
             Ok(re) => Some(re),
             Err(e) => return Some(Err(format!("could not parse /{}/: {}", s, e)))
index 51696521165325596e99ad4df8464255dc3699ba..d8f628e2196f5780197e445dea9d45ac852c0420 100644 (file)
@@ -175,7 +175,7 @@ fn sum(self) -> T {
             // This inner loop applies `hi`/`lo` summation to each
             // partial so that the list of partial sums remains exact.
             for i in range(0, partials.len()) {
-                let mut y = *partials.get(i);
+                let mut y = partials[i];
                 if num::abs(x) < num::abs(y) {
                     mem::swap(&mut x, &mut y);
                 }
index 233743175b503f748a19c41251febe8dcf2e1474..aa13ae82e76d9758000a36c3daed2a11272c13c9 100644 (file)
@@ -398,8 +398,8 @@ pub fn parse_string(us: &str) -> Result<Uuid, ParseError> {
         match group_lens.len() {
             // Single group, no hyphens
             1 => {
-                if *group_lens.get(0) != 32 {
-                    return Err(ErrorInvalidLength(*group_lens.get(0)));
+                if group_lens[0] != 32 {
+                    return Err(ErrorInvalidLength(group_lens[0]));
                 }
             },
             // Five groups, hyphens in between each
index 625245d9f2d2bb75ccad6c84a53239fee88f4b15..d4f286f20e8f70d5f58f1bdf460fdd3055ea126f 100644 (file)
@@ -12,6 +12,7 @@
 // ignore-stage1
 // ignore-tidy-linelength
 // ignore-android
+// ignore-cross-compile gives a different error message
 
 #![feature(phase)]
 #[phase(plugin)] extern crate rlib_crate_test;
diff --git a/src/test/compile-fail/borrowck-overloaded-index-2.rs b/src/test/compile-fail/borrowck-overloaded-index-2.rs
new file mode 100644 (file)
index 0000000..1e3144a
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct MyVec<T> {
+    data: Vec<T>,
+}
+
+impl<T> Index<uint, T> for MyVec<T> {
+    fn index<'a>(&'a self, &i: &uint) -> &'a T {
+        self.data.get(i)
+    }
+}
+
+fn main() {
+    let v = MyVec { data: vec!(box 1i, box 2, box 3) };
+    let good = &v[0]; // Shouldn't fail here
+    let bad = v[0];
+    //~^ ERROR cannot move out of dereference (dereference is implicit, due to indexing)
+}
index d34aa1cd9cbd3d031e7e9d9c2fd791c7730afaf4..0422f6381dc3d0fe61c2604d49f4d3d7eff977c0 100644 (file)
@@ -58,7 +58,7 @@ fn main() {
         x: 1,
     };
     s[2] = 20;
-    //~^ ERROR cannot assign to immutable indexed content
+    //~^ ERROR cannot assign to immutable dereference (dereference is implicit, due to indexing)
 }
 
 
diff --git a/src/test/compile-fail/explicit-self-lifetime-mismatch.rs b/src/test/compile-fail/explicit-self-lifetime-mismatch.rs
new file mode 100644 (file)
index 0000000..285792e
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct Foo<'a,'b> {
+    x: &'a int,
+    y: &'b int,
+}
+
+impl<'a,'b> Foo<'a,'b> {
+    // The number of errors is related to the way invariance works.
+    fn bar(self: Foo<'b,'a>) {}
+    //~^ ERROR mismatched types: expected `Foo<'a,'b>` but found `Foo<'b,'a>`
+    //~^^ ERROR mismatched types: expected `Foo<'a,'b>` but found `Foo<'b,'a>`
+    //~^^^ ERROR mismatched types: expected `Foo<'b,'a>` but found `Foo<'a,'b>`
+    //~^^^^ ERROR mismatched types: expected `Foo<'b,'a>` but found `Foo<'a,'b>`
+}
+
+fn main() {}
+
index f8c1a91464271c58f81621e9e74822d317e61efc..57a158d2438dd98ab5b9efb0cf08fccc0b57d848 100644 (file)
 // error-pattern: type `&Foo` does not implement any method in scope named `foo`
 
 trait Foo {
-    fn foo(~self);
+    fn foo(self: Box<Self>);
 }
 
 impl Foo for int {
-    fn foo(~self) { }
+    fn foo(self: Box<int>) { }
 }
 
 fn main() {
index 84c484a91e2c4f4f78cc7180efff3a956c353a79..fc19a1ba06f9b2324435ba2faa2d7d36cb2c38d3 100644 (file)
@@ -16,7 +16,7 @@
 struct Foo;
 impl Foo {
     fn foo(mut self) {} //~ ERROR: variable does not need to be mutable
-    fn bar(mut ~self) {} //~ ERROR: variable does not need to be mutable
+    fn bar(mut self: Box<Foo>) {} //~ ERROR: variable does not need to be mutable
 }
 
 fn main() {}
index 8868ddd4dfa302f8ac20f6533314fc1c12d95b81..84e7f98a40dc2229bd04fa6b7a6efcd1f8b7ecb8 100644 (file)
@@ -13,7 +13,7 @@ trait Foo {
     fn borrowed(&self);
     fn borrowed_mut(&mut self);
 
-    fn owned(~self);
+    fn owned(self: Box<Self>);
 }
 
 fn borrowed_receiver(x: &Foo) {
diff --git a/src/test/compile-fail/ufcs-explicit-self-bad.rs b/src/test/compile-fail/ufcs-explicit-self-bad.rs
new file mode 100644 (file)
index 0000000..e5bad7e
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::owned::Box;
+
+struct Foo {
+    f: int,
+}
+
+impl Foo {
+    fn foo(self: int, x: int) -> int {  //~ ERROR mismatched self type
+//~^ ERROR not a valid type for `self`
+        self.f + x
+    }
+}
+
+struct Bar<T> {
+    f: T,
+}
+
+impl<T> Bar<T> {
+    fn foo(self: Bar<int>, x: int) -> int { //~ ERROR mismatched self type
+//~^ ERROR not a valid type for `self`
+        x
+    }
+    fn bar(self: &Bar<uint>, x: int) -> int {   //~ ERROR mismatched self type
+//~^ ERROR not a valid type for `self`
+        x
+    }
+}
+
+fn main() {
+    let foo = box Foo {
+        f: 1,
+    };
+    println!("{}", foo.foo(2));
+    let bar = box Bar {
+        f: 1,
+    };
+    println!("{} {}", bar.foo(2), bar.bar(2));
+}
+
diff --git a/src/test/compile-fail/unsafe-destructor-check-crash.rs b/src/test/compile-fail/unsafe-destructor-check-crash.rs
new file mode 100644 (file)
index 0000000..af67558
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+
+// Regression test for issue #15557
+
+#![allow(dead_code)]
+struct AReg1<'a>(&'a u32);
+
+impl<'a> Drop for AReg1<'a> {
+//~^ ERROR: cannot implement a destructor on a structure with type parameters
+  fn drop(&mut self) {}
+}
+
+fn main() {}
index ae554cafb507c4ac4ff3bd61d5fdc8c6ed8af3e0..67f77014c9fa98ac3d1a3be2612add364097aff0 100644 (file)
@@ -17,6 +17,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print f64
 // gdb-check:$14 = 3.5
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+// lldb-command:print b
+// lldb-check:[...]$0 = false
+// lldb-command:print i
+// lldb-check:[...]$1 = -1
+
+// NOTE: LLDB does not support 32bit chars
+// d ebugger:print (uint)(c)
+// c heck:$3 = 97
+
+// lldb-command:print i8
+// lldb-check:[...]$2 = 'D'
+// lldb-command:print i16
+// lldb-check:[...]$3 = -16
+// lldb-command:print i32
+// lldb-check:[...]$4 = -32
+// lldb-command:print i64
+// lldb-check:[...]$5 = -64
+// lldb-command:print u
+// lldb-check:[...]$6 = 1
+// lldb-command:print u8
+// lldb-check:[...]$7 = 'd'
+// lldb-command:print u16
+// lldb-check:[...]$8 = 16
+// lldb-command:print u32
+// lldb-check:[...]$9 = 32
+// lldb-command:print u64
+// lldb-check:[...]$10 = 64
+// lldb-command:print f32
+// lldb-check:[...]$11 = 2.5
+// lldb-command:print f64
+// lldb-check:[...]$12 = 3.5
+
 #![allow(unused_variable)]
 
 fn main() {
@@ -66,7 +105,7 @@ fn main() {
     let u64: u64 = 64;
     let f32: f32 = 2.5;
     let f64: f64 = 3.5;
-    _zzz();
+    _zzz(); // #break
 }
 
 fn _zzz() {()}
index d511e5ed20f8ec49a22d7c070240c1596a344c03..84610b3c740517985ccc26b59eeafb29be0fa468 100644 (file)
@@ -14,6 +14,9 @@
 // its numerical value.
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print *f64_ref
 // gdb-check:$14 = 3.5
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+// lldb-command:print *bool_ref
+// lldb-check:[...]$0 = true
+
+// lldb-command:print *int_ref
+// lldb-check:[...]$1 = -1
+
+// NOTE: lldb doesn't support 32bit chars at the moment
+// d ebugger:print *char_ref
+// c heck:[...]$x = 97
+
+// lldb-command:print *i8_ref
+// lldb-check:[...]$2 = 'D'
+
+// lldb-command:print *i16_ref
+// lldb-check:[...]$3 = -16
+
+// lldb-command:print *i32_ref
+// lldb-check:[...]$4 = -32
+
+// lldb-command:print *i64_ref
+// lldb-check:[...]$5 = -64
+
+// lldb-command:print *uint_ref
+// lldb-check:[...]$6 = 1
+
+// lldb-command:print *u8_ref
+// lldb-check:[...]$7 = 'd'
+
+// lldb-command:print *u16_ref
+// lldb-check:[...]$8 = 16
+
+// lldb-command:print *u32_ref
+// lldb-check:[...]$9 = 32
+
+// lldb-command:print *u64_ref
+// lldb-check:[...]$10 = 64
+
+// lldb-command:print *f32_ref
+// lldb-check:[...]$11 = 2.5
+
+// lldb-command:print *f64_ref
+// lldb-check:[...]$12 = 3.5
+
 #![allow(unused_variable)]
 
 fn main() {
@@ -103,7 +153,8 @@ fn main() {
 
     let f64_val: f64 = 3.5;
     let f64_ref: &f64 = &f64_val;
-    zzz();
+
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 9ab7e0701cc99c261d7c15abefaaa279ca3d3f9a..2270cfb6d215da80f8a18958cccb3a1d13cd163f 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print *the_c_ref
 // gdb-check:$3 = TheC
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *the_a_ref
+// lldb-check:[...]$0 = TheA
+
+// lldb-command:print *the_b_ref
+// lldb-check:[...]$1 = TheB
+
+// lldb-command:print *the_c_ref
+// lldb-check:[...]$2 = TheC
+
 #![allow(unused_variable)]
 
 enum ABC { TheA, TheB, TheC }
@@ -38,7 +55,7 @@ fn main() {
     let the_c = TheC;
     let the_c_ref: &ABC = &the_c;
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index a377d68a33d8cbd9502a69848d8f1ab36714baae..b6f5096c726a5ec172cea6d922e298b6f7c0ffd8 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print *univariant_ref
 // gdb-check:$3 = {{4820353753753434}}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *the_a_ref
+// lldb-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
+// lldb-command:print *the_b_ref
+// lldb-check:[...]$1 = TheB(0, 286331153, 286331153)
+// lldb-command:print *univariant_ref
+// lldb-check:[...]$2 = TheOnlyCase(4820353753753434)
+
 #![allow(unused_variable)]
 #![feature(struct_variant)]
 
@@ -59,7 +74,7 @@ fn main() {
     let univariant = TheOnlyCase(4820353753753434);
     let univariant_ref: &Univariant = &univariant;
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 0f81e530fdd36a25454501547896ed47a594d54d..82e44b46d3c8c10e183851b0cf6c2b7883475c8f 100644 (file)
@@ -16,6 +16,9 @@
 // its numerical value.
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print *f64_ref
 // gdb-check:$14 = 3.5
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:type format add -f decimal char
+// lldb-command:type format add -f decimal 'unsigned char'
+// lldb-command:run
+
+// lldb-command:print *bool_ref
+// lldb-check:[...]$0 = true
+
+// lldb-command:print *int_ref
+// lldb-check:[...]$1 = -1
+
+// LLDB can't handle 32bit chars yet
+// d ebugger:print *char_ref
+// c heck:[...]$x = 97
+
+// lldb-command:print *i8_ref
+// lldb-check:[...]$2 = 68
+
+// lldb-command:print *i16_ref
+// lldb-check:[...]$3 = -16
+
+// lldb-command:print *i32_ref
+// lldb-check:[...]$4 = -32
+
+// lldb-command:print *i64_ref
+// lldb-check:[...]$5 = -64
+
+// lldb-command:print *uint_ref
+// lldb-check:[...]$6 = 1
+
+// lldb-command:print *u8_ref
+// lldb-check:[...]$7 = 100
+
+// lldb-command:print *u16_ref
+// lldb-check:[...]$8 = 16
+
+// lldb-command:print *u32_ref
+// lldb-check:[...]$9 = 32
+
+// lldb-command:print *u64_ref
+// lldb-check:[...]$10 = 64
+
+// lldb-command:print *f32_ref
+// lldb-check:[...]$11 = 2.5
+
+// lldb-command:print *f64_ref
+// lldb-check:[...]$12 = 3.5
+
 #![allow(unused_variable)]
 
 use std::gc::{Gc, GC};
@@ -107,7 +160,8 @@ fn main() {
 
     let f64_box: Gc<f64> = box(GC) 3.5;
     let f64_ref: &f64 = f64_box;
-    zzz();
+
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 98b66098862b519c0a41c2d46a53022b11ebbaa3..5ad0fe89d2cdfefd7916d0fd6e2de4ed0f22a2b1 100644 (file)
@@ -9,8 +9,10 @@
 // except according to those terms.
 
 // ignore-android: FIXME(#10381)
-
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print *unique_val_interior_ref_2
 // gdb-check:$10 = 26.5
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *stack_val_ref
+// lldb-check:[...]$0 = SomeStruct { x: 10, y: 23.5 }
+
+// lldb-command:print *stack_val_interior_ref_1
+// lldb-check:[...]$1 = 10
+
+// lldb-command:print *stack_val_interior_ref_2
+// lldb-check:[...]$2 = 23.5
+
+// lldb-command:print *ref_to_unnamed
+// lldb-check:[...]$3 = SomeStruct { x: 11, y: 24.5 }
+
+// lldb-command:print *managed_val_ref
+// lldb-check:[...]$4 = SomeStruct { x: 12, y: 25.5 }
+
+// lldb-command:print *managed_val_interior_ref_1
+// lldb-check:[...]$5 = 12
+
+// lldb-command:print *managed_val_interior_ref_2
+// lldb-check:[...]$6 = 25.5
+
+// lldb-command:print *unique_val_ref
+// lldb-check:[...]$7 = SomeStruct { x: 13, y: 26.5 }
+
+// lldb-command:print *unique_val_interior_ref_1
+// lldb-check:[...]$8 = 13
+
+// lldb-command:print *unique_val_interior_ref_2
+// lldb-check:[...]$9 = 26.5
+
 #![feature(managed_boxes)]
 #![allow(unused_variable)]
 
@@ -72,7 +109,7 @@ fn main() {
     let unique_val_interior_ref_1: &int = &unique_val.x;
     let unique_val_interior_ref_2: &f64 = &unique_val.y;
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index b88161e4a0b30a5d39a7f7a775101cb8812a74b0..5c20c7471ec26a012f64cc7455109fb4100527ac 100644 (file)
@@ -13,6 +13,9 @@
 #![feature(managed_boxes)]
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print *unique_val_ref
 // gdb-check:$4 = {-17, -22}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *stack_val_ref
+// lldb-check:[...]$0 = (-14, -19)
+
+// lldb-command:print *ref_to_unnamed
+// lldb-check:[...]$1 = (-15, -20)
+
+// lldb-command:print *managed_val_ref
+// lldb-check:[...]$2 = (-16, -21)
+
+// lldb-command:print *unique_val_ref
+// lldb-check:[...]$3 = (-17, -22)
+
+
 #![allow(unused_variable)]
 
 use std::gc::{Gc, GC};
@@ -44,7 +65,7 @@ fn main() {
     let unique_val: Box<(i16, f32)> = box() (-17, -22f32);
     let unique_val_ref: &(i16, f32) = unique_val;
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 6e8fa62ed26c864c7a88933944a1d34af353866c..821c85fdcf3a06e54415014cdc1e9e3bc45d313a 100644 (file)
@@ -14,6 +14,9 @@
 // its numerical value.
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print *f64_ref
 // gdb-check:$14 = 3.5
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:type format add -f decimal char
+// lldb-command:type format add -f decimal 'unsigned char'
+// lldb-command:run
+
+// lldb-command:print *bool_ref
+// lldb-check:[...]$0 = true
+
+// lldb-command:print *int_ref
+// lldb-check:[...]$1 = -1
+
+// d ebugger:print *char_ref
+// c heck:[...]$3 = 97
+
+// lldb-command:print *i8_ref
+// lldb-check:[...]$2 = 68
+
+// lldb-command:print *i16_ref
+// lldb-check:[...]$3 = -16
+
+// lldb-command:print *i32_ref
+// lldb-check:[...]$4 = -32
+
+// lldb-command:print *i64_ref
+// lldb-check:[...]$5 = -64
+
+// lldb-command:print *uint_ref
+// lldb-check:[...]$6 = 1
+
+// lldb-command:print *u8_ref
+// lldb-check:[...]$7 = 100
+
+// lldb-command:print *u16_ref
+// lldb-check:[...]$8 = 16
+
+// lldb-command:print *u32_ref
+// lldb-check:[...]$9 = 32
+
+// lldb-command:print *u64_ref
+// lldb-check:[...]$10 = 64
+
+// lldb-command:print *f32_ref
+// lldb-check:[...]$11 = 2.5
+
+// lldb-command:print *f64_ref
+// lldb-check:[...]$12 = 3.5
+
 #![allow(unused_variable)]
 
 
@@ -104,7 +156,8 @@ fn main() {
 
     let f64_box: Box<f64> = box 3.5;
     let f64_ref: &f64 = f64_box;
-    zzz();
+
+    zzz(); // #break
 }
 
 fn zzz() {()}
index dcfe1804510ad59364b060b30591a10f29731a75..5b799b25bbfc4dc287b3fe4f3714da46358be990 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print d->val
 // gdb-check:$4 = false
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+// lldb-command:print *a
+// lldb-check:[...]$0 = 1
+// lldb-command:print *b
+// lldb-check:[...]$1 = (2, 3.5)
+// lldb-command:print c->val
+// lldb-check:[...]$2 = 4
+// lldb-command:print d->val
+// lldb-check:[...]$3 = false
+
 #![feature(managed_boxes)]
 #![allow(unused_variable)]
 
@@ -34,7 +50,8 @@ fn main() {
     let b = box() (2i, 3.5f64);
     let c = box(GC) 4i;
     let d = box(GC) false;
-    _zzz();
+
+    zzz(); // #break
 }
 
-fn _zzz() {()}
+fn zzz() { () }
index f583016b93f392220d409b3a84be45af545d651c..0e958545fb3c09105c6cf068a7ab4b4c39685a0d 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print managed_dtor->val
 // gdb-check:$4 = {x = 33, y = 333, z = 3333, w = 33333}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *unique
+// lldb-check:[...]$0 = StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 }
+
+// lldb-command:print managed->val
+// lldb-check:[...]$1 = StructWithSomePadding { x: 88, y: 888, z: 8888, w: 88888 }
+
+// lldb-command:print *unique_dtor
+// lldb-check:[...]$2 = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 }
+
+// lldb-command:print managed_dtor->val
+// lldb-check:[...]$3 = StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 }
+
 #![feature(managed_boxes)]
 #![allow(unused_variable)]
 
@@ -58,7 +78,7 @@ fn main() {
     let unique_dtor = box StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 };
     let managed_dtor = box(GC) StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 };
 
-    zzz();
+    zzz(); // #break
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 873e062352107bd214305c18a230d9e6422fd19a..2e1c4c79af0b336887a6f964fd5f84ba3122f535 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$7 = {{Case1, x = 0, y = 8970181431921507452}, {Case1, 0, 2088533116, 2088533116}}
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print s
+// lldb-check:[...]$0 = Struct { a: 1, b: 2.5 }
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$1 = Struct { a: 3, b: 4.5 }
+// lldb-command:print y
+// lldb-check:[...]$2 = 5
+// lldb-command:print z
+// lldb-check:[...]$3 = 6.5
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$4 = (7, 8, 9.5, 10.5)
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$5 = Newtype(11.5, 12.5, 13, 14)
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$6 = Case1 { x: 0, y: 8970181431921507452 }
+// lldb-command:continue
+
 #![feature(struct_variant)]
 
 #[deriving(Clone)]
@@ -58,21 +90,21 @@ struct StructStruct {
 }
 
 fn fun(s: Struct) {
-    zzz();
+    zzz(); // #break
 }
 
 fn fun_fun(StructStruct { a: x, b: Struct { a: y, b: z } }: StructStruct) {
-    zzz();
+    zzz(); // #break
 }
 
 fn tup(a: (int, uint, f64, f64)) {
-    zzz();
+    zzz(); // #break
 }
 
 struct Newtype(f64, f64, int, uint);
 
 fn new_type(a: Newtype) {
-    zzz();
+    zzz(); // #break
 }
 
 // The first element is to ensure proper alignment, irrespective of the machines word size. Since
@@ -84,7 +116,7 @@ enum Enum {
 }
 
 fn by_val_enum(x: Enum) {
-    zzz();
+    zzz(); // #break
 }
 
 fn main() {
@@ -100,4 +132,4 @@ fn main() {
     by_val_enum(Case1 { x: 0, y: 8970181431921507452 });
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 0da2d44d5ae50061e80eb558f142fc5d9dfc6ba2..4d6064c185b4c97cf15abec9ce5d982dea313623 100644 (file)
@@ -13,6 +13,9 @@
 #![feature(managed_boxes)]
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$4 = 8888
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print self
+// lldb-check:[...]$0 = 1111
+// lldb-command:continue
+
+// lldb-command:print self
+// lldb-check:[...]$1 = Struct { x: 2222, y: 3333 }
+// lldb-command:continue
+
+// lldb-command:print self
+// lldb-check:[...]$2 = (4444.5, 5555, 6666, 7777.5)
+// lldb-command:continue
+
+// lldb-command:print self->val
+// lldb-check:[...]$3 = 8888
+// lldb-command:continue
+
 use std::gc::{Gc, GC};
 
 trait Trait {
@@ -44,7 +68,7 @@ trait Trait {
 
 impl Trait for int {
     fn method(self) -> int {
-        zzz();
+        zzz(); // #break
         self
     }
 }
@@ -56,21 +80,21 @@ struct Struct {
 
 impl Trait for Struct {
     fn method(self) -> Struct {
-        zzz();
+        zzz(); // #break
         self
     }
 }
 
 impl Trait for (f64, int, int, f64) {
     fn method(self) -> (f64, int, int, f64) {
-        zzz();
+        zzz(); // #break
         self
     }
 }
 
 impl Trait for Gc<int> {
     fn method(self) -> Gc<int> {
-        zzz();
+        zzz(); // #break
         self
     }
 }
@@ -82,4 +106,4 @@ fn main() {
     let _ = (box(GC) 8888).method();
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 3e76bf1987b98b487369f973ffd55589185af11e..f73517282907f87f4614ba5f6ce122a5f8157e9a 100644 (file)
@@ -8,9 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-tidy-linelength
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print struct_with_drop
 // gdb-check:$7 = {{a = OneHundred, b = Vienna}, 9}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print tuple_interior_padding
+// lldb-check:[...]$0 = (0, OneHundred)
+
+// lldb-command:print tuple_padding_at_end
+// lldb-check:[...]$1 = ((1, OneThousand), 2)
+// lldb-command:print tuple_different_enums
+// lldb-check:[...]$2 = (OneThousand, MountainView, OneMillion, Vienna)
+
+// lldb-command:print padded_struct
+// lldb-check:[...]$3 = PaddedStruct { a: 3, b: OneMillion, c: 4, d: Toronto, e: 5 }
+
+// lldb-command:print packed_struct
+// lldb-check:[...]$4 = PackedStruct { a: 6, b: OneHundred, c: 7, d: Vienna, e: 8 }
+
+// lldb-command:print non_padded_struct
+// lldb-check:[...]$5 = NonPaddedStruct { a: OneMillion, b: MountainView, c: OneThousand, d: Toronto }
+
+// lldb-command:print struct_with_drop
+// lldb-check:[...]$6 = (StructWithDrop { a: OneHundred, b: Vienna }, 9)
+
 #![allow(unused_variable)]
 
 enum AnEnum {
@@ -115,7 +144,7 @@ fn main() {
 
     let struct_with_drop = (StructWithDrop { a: OneHundred, b: Vienna }, 9_i64);
 
-    zzz();
+    zzz(); // #break
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 19f8398f1a94b594918ba41b06def6bc7a1f0287..da30363f271d07bf878657746d4329fe30c981c1 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 
 // gdb-command:print 'c-style-enum::SINGLE_VARIANT'
 // gdb-command:print 'c-style-enum::MANUAL_THREE'
 // gdb-check:$18 = OneMillion
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print auto_one
+// lldb-check:[...]$0 = One
+
+// lldb-command:print auto_two
+// lldb-check:[...]$1 = Two
+
+// lldb-command:print auto_three
+// lldb-check:[...]$2 = Three
+
+// lldb-command:print manual_one_hundred
+// lldb-check:[...]$3 = OneHundred
+
+// lldb-command:print manual_one_thousand
+// lldb-check:[...]$4 = OneThousand
+
+// lldb-command:print manual_one_million
+// lldb-check:[...]$5 = OneMillion
+
+// lldb-command:print single_variant
+// lldb-check:[...]$6 = TheOnlyVariant
+
 #![allow(unused_variable)]
 #![allow(dead_code)]
 
@@ -120,11 +149,11 @@ fn main() {
         MANUAL_THREE = OneMillion;
     };
 
-    zzz();
+    zzz(); // #break
 
     let a = SINGLE_VARIANT;
     let a = unsafe { AUTO_ONE };
     let a = unsafe { MANUAL_ONE };
 }
 
-fn zzz() {()}
+fn zzz() { () }
index cc241040f2bd28335f178778a57a4fa77efdc34c..67601221e7a46debb0990b80d20b1efe2fb835f7 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$4 = 110
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print x
+// lldb-check:[...]$0 = 0.5
+// lldb-command:print y
+// lldb-check:[...]$1 = 10
+// lldb-command:continue
+
+// lldb-command:print *x
+// lldb-check:[...]$2 = 29
+// lldb-command:print *y
+// lldb-check:[...]$3 = 110
+// lldb-command:continue
+
 fn some_generic_fun<T1, T2>(a: T1, b: T2) -> (T2, T1) {
 
     let closure = |x, y| {
-        zzz();
+        zzz(); // #break
         (y, x)
     };
 
@@ -43,4 +63,4 @@ fn main() {
     some_generic_fun(&29i, box 110i);
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 697703034f6e3735337e2e62d836ee966f401954..48d14a46c83f1d136846300a9c075009e2eaa8e1 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$49 = 62
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+// lldb-command:run
+
+// lldb-command:print a
+// lldb-check:[...]$0 = 1
+// lldb-command:print b
+// lldb-check:[...]$1 = false
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$2 = 2
+// lldb-command:print b
+// lldb-check:[...]$3 = 3
+// lldb-command:print c
+// lldb-check:[...]$4 = 4
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$5 = 5
+// lldb-command:print b
+// lldb-check:[...]$6 = (6, 7)
+// lldb-command:continue
+
+// lldb-command:print h
+// lldb-check:[...]$7 = 8
+// lldb-command:print i
+// lldb-check:[...]$8 = Struct { a: 9, b: 10 }
+// lldb-command:print j
+// lldb-check:[...]$9 = 11
+// lldb-command:continue
+
+// lldb-command:print k
+// lldb-check:[...]$10 = 12
+// lldb-command:print l
+// lldb-check:[...]$11 = 13
+// lldb-command:continue
+
+// lldb-command:print m
+// lldb-check:[...]$12 = 14
+// lldb-command:print n
+// lldb-check:[...]$13 = 16
+// lldb-command:continue
+
+// lldb-command:print o
+// lldb-check:[...]$14 = 18
+// lldb-command:continue
+
+// lldb-command:print p
+// lldb-check:[...]$15 = 19
+// lldb-command:print q
+// lldb-check:[...]$16 = 20
+// lldb-command:print r
+// lldb-check:[...]$17 = Struct { a: 21, b: 22 }
+// lldb-command:continue
+
+// lldb-command:print s
+// lldb-check:[...]$18 = 24
+// lldb-command:print t
+// lldb-check:[...]$19 = 23
+// lldb-command:continue
+
+// lldb-command:print u
+// lldb-check:[...]$20 = 25
+// lldb-command:print v
+// lldb-check:[...]$21 = 26
+// lldb-command:print w
+// lldb-check:[...]$22 = 27
+// lldb-command:print x
+// lldb-check:[...]$23 = 28
+// lldb-command:print y
+// lldb-check:[...]$24 = 29
+// lldb-command:print z
+// lldb-check:[...]$25 = 30
+// lldb-command:print ae
+// lldb-check:[...]$26 = 31
+// lldb-command:print oe
+// lldb-check:[...]$27 = 32
+// lldb-command:print ue
+// lldb-check:[...]$28 = 33
+// lldb-command:continue
+
+// lldb-command:print aa
+// lldb-check:[...]$29 = (34, 35)
+// lldb-command:continue
+
+// lldb-command:print bb
+// lldb-check:[...]$30 = (36, 37)
+// lldb-command:continue
+
+// lldb-command:print cc
+// lldb-check:[...]$31 = 38
+// lldb-command:continue
+
+// lldb-command:print dd
+// lldb-check:[...]$32 = (40, 41, 42)
+// lldb-command:continue
+
+// lldb-command:print *ee
+// lldb-check:[...]$33 = (43, 44, 45)
+// lldb-command:continue
+
+// lldb-command:print *ff
+// lldb-check:[...]$34 = 46
+// lldb-command:print gg
+// lldb-check:[...]$35 = (47, 48)
+// lldb-command:continue
+
+// lldb-command:print *hh
+// lldb-check:[...]$36 = 50
+// lldb-command:continue
+
+// lldb-command:print ii
+// lldb-check:[...]$37 = 51
+// lldb-command:continue
+
+// lldb-command:print *jj
+// lldb-check:[...]$38 = 52
+// lldb-command:continue
+
+// lldb-command:print kk
+// lldb-check:[...]$39 = 53
+// lldb-command:print ll
+// lldb-check:[...]$40 = 54
+// lldb-command:continue
+
+// lldb-command:print mm
+// lldb-check:[...]$41 = 55
+// lldb-command:print *nn
+// lldb-check:[...]$42 = 56
+// lldb-command:continue
+
+// lldb-command:print oo
+// lldb-check:[...]$43 = 57
+// lldb-command:print pp
+// lldb-check:[...]$44 = 58
+// lldb-command:print qq
+// lldb-check:[...]$45 = 59
+// lldb-command:continue
+
+// lldb-command:print rr
+// lldb-check:[...]$46 = 60
+// lldb-command:print ss
+// lldb-check:[...]$47 = 61
+// lldb-command:print tt
+// lldb-check:[...]$48 = 62
+// lldb-command:continue
+
 #![allow(unused_variable)]
 
 
@@ -197,93 +348,93 @@ enum Univariant {
 
 
 fn simple_tuple((a, b): (int, bool)) {
-    zzz();
+    zzz(); // #break
 }
 
 fn nested_tuple((a, (b, c)): (int, (u16, u16))) {
-    zzz();
+    zzz(); // #break
 }
 
 fn destructure_only_first_level((a, b): (int, (u32, u32))) {
-    zzz();
+    zzz(); // #break
 }
 
 fn struct_as_tuple_element((h, i, j): (i16, Struct, i16)) {
-    zzz();
+    zzz(); // #break
 }
 
 fn struct_pattern(Struct { a: k, b: l }: Struct) {
-    zzz();
+    zzz(); // #break
 }
 
 fn ignored_tuple_element((m, _, n): (int, u16, i32)) {
-    zzz();
+    zzz(); // #break
 }
 
 fn ignored_struct_field(Struct { b: o, .. }: Struct) {
-    zzz();
+    zzz(); // #break
 }
 
 fn one_struct_destructured_one_not((Struct { a: p, b: q }, r): (Struct, Struct)) {
-    zzz();
+    zzz(); // #break
 }
 
 fn different_order_of_struct_fields(Struct { b: s, a: t }: Struct ) {
-    zzz();
+    zzz(); // #break
 }
 
 fn complex_nesting(((u,   v  ), ((w,   (x,   Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue ):
                    ((i16, i32), ((i64, (i32, Struct,             )), Struct                 ), u16))
 {
-    zzz();
+    zzz(); // #break
 }
 
 fn managed_box(&aa: &(int, int)) {
-    zzz();
+    zzz(); // #break
 }
 
 fn borrowed_pointer(&bb: &(int, int)) {
-    zzz();
+    zzz(); // #break
 }
 
 fn contained_borrowed_pointer((&cc, _): (&int, int)) {
-    zzz();
+    zzz(); // #break
 }
 
 fn unique_pointer(box dd: Box<(int, int, int)>) {
-    zzz();
+    zzz(); // #break
 }
 
 fn ref_binding(ref ee: (int, int, int)) {
-    zzz();
+    zzz(); // #break
 }
 
 fn ref_binding_in_tuple((ref ff, gg): (int, (int, int))) {
-    zzz();
+    zzz(); // #break
 }
 
 fn ref_binding_in_struct(Struct { b: ref hh, .. }: Struct) {
-    zzz();
+    zzz(); // #break
 }
 
 fn univariant_enum(Unit(ii): Univariant) {
-    zzz();
+    zzz(); // #break
 }
 
 fn univariant_enum_with_ref_binding(Unit(ref jj): Univariant) {
-    zzz();
+    zzz(); // #break
 }
 
 fn tuple_struct(TupleStruct(kk, ll): TupleStruct) {
-    zzz();
+    zzz(); // #break
 }
 
 fn tuple_struct_with_ref_binding(TupleStruct(mm, ref nn): TupleStruct) {
-    zzz();
+    zzz(); // #break
 }
 
 fn multiple_arguments((oo, pp): (int, int), qq : int) {
-    zzz();
+    zzz(); // #break
 }
 
 fn main() {
@@ -311,11 +462,10 @@ fn main() {
     multiple_arguments((57, 58), 59);
 
     fn nested_function(rr: int, (ss, tt): (int, int)) {
-        zzz();
+        zzz(); // #break
     }
 
     nested_function(60, (61, 62));
 }
 
-
-fn zzz() {()}
+fn zzz() { () }
index d91d98f43050ff94d0aaff74378feb050e739dbf..837a6dc062227632972db27d1cfc08476b7ac537 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print *nn
 // gdb-check:$43 = 56
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print a
+// lldb-check:[...]$0 = 1
+// lldb-command:print b
+// lldb-check:[...]$1 = false
+
+// lldb-command:print c
+// lldb-check:[...]$2 = 2
+// lldb-command:print d
+// lldb-check:[...]$3 = 3
+// lldb-command:print e
+// lldb-check:[...]$4 = 4
+
+// lldb-command:print f
+// lldb-check:[...]$5 = 5
+// lldb-command:print g
+// lldb-check:[...]$6 = (6, 7)
+
+// lldb-command:print h
+// lldb-check:[...]$7 = 8
+// lldb-command:print i
+// lldb-check:[...]$8 = Struct { a: 9, b: 10 }
+// lldb-command:print j
+// lldb-check:[...]$9 = 11
+
+// lldb-command:print k
+// lldb-check:[...]$10 = 12
+// lldb-command:print l
+// lldb-check:[...]$11 = 13
+
+// lldb-command:print m
+// lldb-check:[...]$12 = 14
+// lldb-command:print n
+// lldb-check:[...]$13 = 16
+
+// lldb-command:print o
+// lldb-check:[...]$14 = 18
+
+// lldb-command:print p
+// lldb-check:[...]$15 = 19
+// lldb-command:print q
+// lldb-check:[...]$16 = 20
+// lldb-command:print r
+// lldb-check:[...]$17 = Struct { a: 21, b: 22 }
+
+// lldb-command:print s
+// lldb-check:[...]$18 = 24
+// lldb-command:print t
+// lldb-check:[...]$19 = 23
+
+// lldb-command:print u
+// lldb-check:[...]$20 = 25
+// lldb-command:print v
+// lldb-check:[...]$21 = 26
+// lldb-command:print w
+// lldb-check:[...]$22 = 27
+// lldb-command:print x
+// lldb-check:[...]$23 = 28
+// lldb-command:print y
+// lldb-check:[...]$24 = 29
+// lldb-command:print z
+// lldb-check:[...]$25 = 30
+// lldb-command:print ae
+// lldb-check:[...]$26 = 31
+// lldb-command:print oe
+// lldb-check:[...]$27 = 32
+// lldb-command:print ue
+// lldb-check:[...]$28 = 33
+
+// lldb-command:print aa
+// lldb-check:[...]$29 = (34, 35)
+
+// lldb-command:print bb
+// lldb-check:[...]$30 = (36, 37)
+
+// lldb-command:print cc
+// lldb-check:[...]$31 = 38
+
+// lldb-command:print dd
+// lldb-check:[...]$32 = (40, 41, 42)
+
+// lldb-command:print *ee
+// lldb-check:[...]$33 = (43, 44, 45)
+
+// lldb-command:print *ff
+// lldb-check:[...]$34 = 46
+
+// lldb-command:print gg
+// lldb-check:[...]$35 = (47, 48)
+
+// lldb-command:print *hh
+// lldb-check:[...]$36 = 50
+
+// lldb-command:print ii
+// lldb-check:[...]$37 = 51
+
+// lldb-command:print *jj
+// lldb-check:[...]$38 = 52
+
+// lldb-command:print kk
+// lldb-check:[...]$39 = 53
+
+// lldb-command:print ll
+// lldb-check:[...]$40 = 54
+
+// lldb-command:print mm
+// lldb-check:[...]$41 = 55
+
+// lldb-command:print *nn
+// lldb-check:[...]$42 = 56
+
+
 #![allow(unused_variable)]
 
 struct Struct {
@@ -204,7 +323,7 @@ fn main() {
     // tuple struct with ref binding
     let &TupleStruct(mm, ref nn) = &TupleStruct(55.0, 56);
 
-    zzz();
+    zzz(); // #break
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 913038c44be26f0ea1aea82a6b0ed19668cae29a..b5ce865a4aaa2a4f37b4a6bc7c1cc9e0f48e0cb1 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print struct_padded_at_end
 // gdb-check:$5 = {x = {22, 23}, y = {24, 25}}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print no_padding1
+// lldb-check:[...]$0 = NoPadding1 { x: [0, 1, 2], y: -3, z: [4.5, 5.5] }
+// lldb-command:print no_padding2
+// lldb-check:[...]$1 = NoPadding2 { x: [6, 7, 8], y: [[9, 10], [11, 12]] }
+
+// lldb-command:print struct_internal_padding
+// lldb-check:[...]$2 = StructInternalPadding { x: [13, 14], y: [15, 16] }
+
+// lldb-command:print single_vec
+// lldb-check:[...]$3 = SingleVec { x: [17, 18, 19, 20, 21] }
+
+// lldb-command:print struct_padded_at_end
+// lldb-check:[...]$4 = StructPaddedAtEnd { x: [22, 23], y: [24, 25] }
+
 #![allow(unused_variable)]
 
 struct NoPadding1 {
@@ -84,7 +106,7 @@ fn main() {
         y: [24, 25]
     };
 
-    zzz();
+    zzz(); // #break
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 535efa0b84efc8ce90c9f9da3852530f021db2b4..640e04cf71c11f1f72e3491bd1f8dbe3309fd774 100644 (file)
 
 // compile-flags:-g
 // gdb-command:set print pretty off
-// gdb-command:break function-arg-initialization.rs:139
-// gdb-command:break function-arg-initialization.rs:154
-// gdb-command:break function-arg-initialization.rs:158
-// gdb-command:break function-arg-initialization.rs:162
-// gdb-command:break function-arg-initialization.rs:166
-// gdb-command:break function-arg-initialization.rs:170
-// gdb-command:break function-arg-initialization.rs:174
-// gdb-command:break function-arg-initialization.rs:178
-// gdb-command:break function-arg-initialization.rs:182
-// gdb-command:break function-arg-initialization.rs:190
-// gdb-command:break function-arg-initialization.rs:197
-
+// gdb-command:break function-arg-initialization.rs:243
+// gdb-command:break function-arg-initialization.rs:258
+// gdb-command:break function-arg-initialization.rs:262
+// gdb-command:break function-arg-initialization.rs:266
+// gdb-command:break function-arg-initialization.rs:270
+// gdb-command:break function-arg-initialization.rs:274
+// gdb-command:break function-arg-initialization.rs:278
+// gdb-command:break function-arg-initialization.rs:282
+// gdb-command:break function-arg-initialization.rs:286
+// gdb-command:break function-arg-initialization.rs:294
+// gdb-command:break function-arg-initialization.rs:301
+
+// === GDB TESTS ===================================================================================
 
 // gdb-command:run
 
 // gdb-check:$32 = 45
 // gdb-command:continue
 
-#![allow(unused_variable)]
 
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// IMMEDIATE ARGS
+// lldb-command:print a
+// lldb-check:[...]$0 = 1
+// lldb-command:print b
+// lldb-check:[...]$1 = true
+// lldb-command:print c
+// lldb-check:[...]$2 = 2.5
+// lldb-command:continue
+
+// NON IMMEDIATE ARGS
+// lldb-command:print a
+// lldb-check:[...]$3 = BigStruct { a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10 }
+// lldb-command:print b
+// lldb-check:[...]$4 = BigStruct { a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18 }
+// lldb-command:continue
+
+// BINDING
+// lldb-command:print a
+// lldb-check:[...]$5 = 19
+// lldb-command:print b
+// lldb-check:[...]$6 = 20
+// lldb-command:print c
+// lldb-check:[...]$7 = 21.5
+// lldb-command:continue
+
+// ASSIGNMENT
+// lldb-command:print a
+// lldb-check:[...]$8 = 22
+// lldb-command:print b
+// lldb-check:[...]$9 = 23
+// lldb-command:print c
+// lldb-check:[...]$10 = 24.5
+// lldb-command:continue
+
+// FUNCTION CALL
+// lldb-command:print x
+// lldb-check:[...]$11 = 25
+// lldb-command:print y
+// lldb-check:[...]$12 = 26
+// lldb-command:print z
+// lldb-check:[...]$13 = 27.5
+// lldb-command:continue
+
+// EXPR
+// lldb-command:print x
+// lldb-check:[...]$14 = 28
+// lldb-command:print y
+// lldb-check:[...]$15 = 29
+// lldb-command:print z
+// lldb-check:[...]$16 = 30.5
+// lldb-command:continue
+
+// RETURN EXPR
+// lldb-command:print x
+// lldb-check:[...]$17 = 31
+// lldb-command:print y
+// lldb-check:[...]$18 = 32
+// lldb-command:print z
+// lldb-check:[...]$19 = 33.5
+// lldb-command:continue
+
+// ARITHMETIC EXPR
+// lldb-command:print x
+// lldb-check:[...]$20 = 34
+// lldb-command:print y
+// lldb-check:[...]$21 = 35
+// lldb-command:print z
+// lldb-check:[...]$22 = 36.5
+// lldb-command:continue
+
+// IF EXPR
+// lldb-command:print x
+// lldb-check:[...]$23 = 37
+// lldb-command:print y
+// lldb-check:[...]$24 = 38
+// lldb-command:print z
+// lldb-check:[...]$25 = 39.5
+// lldb-command:continue
+
+// WHILE EXPR
+// lldb-command:print x
+// lldb-check:[...]$26 = 40
+// lldb-command:print y
+// lldb-check:[...]$27 = 41
+// lldb-command:print z
+// lldb-check:[...]$28 = 42
+// lldb-command:continue
+
+// LOOP EXPR
+// lldb-command:print x
+// lldb-check:[...]$29 = 43
+// lldb-command:print y
+// lldb-check:[...]$30 = 44
+// lldb-command:print z
+// lldb-check:[...]$31 = 45
+// lldb-command:continue
+
+
+
+#![allow(unused_variable)]
 
 
 
 fn immediate_args(a: int, b: bool, c: f64) {
-    ()
+    () // #break
 }
 
 struct BigStruct {
@@ -151,35 +255,35 @@ struct BigStruct {
 }
 
 fn non_immediate_args(a: BigStruct, b: BigStruct) {
-    ()
+    () // #break
 }
 
 fn binding(a: i64, b: u64, c: f64) {
-    let x = 0i;
+    let x = 0i; // #break
 }
 
 fn assignment(mut a: u64, b: u64, c: f64) {
-    a = b;
+    a = b; // #break
 }
 
 fn function_call(x: u64, y: u64, z: f64) {
-    std::io::stdio::print("Hi!")
+    std::io::stdio::print("Hi!") // #break
 }
 
 fn identifier(x: u64, y: u64, z: f64) -> u64 {
-    x
+    x // #break
 }
 
 fn return_expr(x: u64, y: u64, z: f64) -> u64 {
-    return x;
+    return x; // #break
 }
 
 fn arithmetic_expr(x: u64, y: u64, z: f64) -> u64 {
-    x + y
+    x + y // #break
 }
 
 fn if_expr(x: u64, y: u64, z: f64) -> u64 {
-    if x + y < 1000 {
+    if x + y < 1000 { // #break
         x
     } else {
         y
@@ -187,14 +291,14 @@ fn if_expr(x: u64, y: u64, z: f64) -> u64 {
 }
 
 fn while_expr(mut x: u64, y: u64, z: u64) -> u64 {
-    while x + y < 1000 {
+    while x + y > 1000 { // #break
         x += z
     }
     return x;
 }
 
 fn loop_expr(mut x: u64, y: u64, z: u64) -> u64 {
-    loop {
+    loop { // #break
         x += z;
 
         if x + y > 1000 {
index e65b9a2519d60259bd3e27e335e9b53cdb6920e9..69bd5ae1d6c30af43d4eca3bea296775ffd151e4 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print b
 // gdb-check:$4 = 3000
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print x
+// lldb-check:[...]$0 = 111102
+// lldb-command:print y
+// lldb-check:[...]$1 = true
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$2 = 2000
+// lldb-command:print b
+// lldb-check:[...]$3 = 3000
+// lldb-command:continue
+
 fn main() {
 
     fun(111102, true);
     nested(2000, 3000);
 
     fn nested(a: i32, b: i64) -> (i32, i64) {
-        zzz();
+        zzz(); // #break
         (a, b)
     }
 }
 
 fn fun(x: int, y: bool) -> (int, bool) {
-    zzz();
+    zzz(); // #break
 
     (x, y)
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 0160a6f1879dbe3706d2d4db0cf67f161d7b6157..05e2c5eb6c7ca84ad916494998331a4039479d7a 100644 (file)
 // beginning of a function. Functions with the #[no_split_stack] attribute have the same prologue as
 // regular C functions compiled with GCC or Clang and therefore are better handled by GDB. As a
 // consequence, and as opposed to regular Rust functions, we can set the breakpoints via the
-// function name (and don't have to fall back on using line numbers).
+// function name (and don't have to fall back on using line numbers). For LLDB this shouldn't make
+// a difference because it can handle both cases.
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak immediate_args
 // gdb-command:rbreak binding
 // gdb-check:$32 = 45
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:breakpoint set --name immediate_args
+// lldb-command:breakpoint set --name non_immediate_args
+// lldb-command:breakpoint set --name binding
+// lldb-command:breakpoint set --name assignment
+// lldb-command:breakpoint set --name function_call
+// lldb-command:breakpoint set --name identifier
+// lldb-command:breakpoint set --name return_expr
+// lldb-command:breakpoint set --name arithmetic_expr
+// lldb-command:breakpoint set --name if_expr
+// lldb-command:breakpoint set --name while_expr
+// lldb-command:breakpoint set --name loop_expr
+// lldb-command:run
+
+// IMMEDIATE ARGS
+// lldb-command:print a
+// lldb-check:[...]$0 = 1
+// lldb-command:print b
+// lldb-check:[...]$1 = true
+// lldb-command:print c
+// lldb-check:[...]$2 = 2.5
+// lldb-command:continue
+
+// NON IMMEDIATE ARGS
+// lldb-command:print a
+// lldb-check:[...]$3 = BigStruct { a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10 }
+// lldb-command:print b
+// lldb-check:[...]$4 = BigStruct { a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18 }
+// lldb-command:continue
+
+// BINDING
+// lldb-command:print a
+// lldb-check:[...]$5 = 19
+// lldb-command:print b
+// lldb-check:[...]$6 = 20
+// lldb-command:print c
+// lldb-check:[...]$7 = 21.5
+// lldb-command:continue
+
+// ASSIGNMENT
+// lldb-command:print a
+// lldb-check:[...]$8 = 22
+// lldb-command:print b
+// lldb-check:[...]$9 = 23
+// lldb-command:print c
+// lldb-check:[...]$10 = 24.5
+// lldb-command:continue
+
+// FUNCTION CALL
+// lldb-command:print x
+// lldb-check:[...]$11 = 25
+// lldb-command:print y
+// lldb-check:[...]$12 = 26
+// lldb-command:print z
+// lldb-check:[...]$13 = 27.5
+// lldb-command:continue
+
+// EXPR
+// lldb-command:print x
+// lldb-check:[...]$14 = 28
+// lldb-command:print y
+// lldb-check:[...]$15 = 29
+// lldb-command:print z
+// lldb-check:[...]$16 = 30.5
+// lldb-command:continue
+
+// RETURN EXPR
+// lldb-command:print x
+// lldb-check:[...]$17 = 31
+// lldb-command:print y
+// lldb-check:[...]$18 = 32
+// lldb-command:print z
+// lldb-check:[...]$19 = 33.5
+// lldb-command:continue
+
+// ARITHMETIC EXPR
+// lldb-command:print x
+// lldb-check:[...]$20 = 34
+// lldb-command:print y
+// lldb-check:[...]$21 = 35
+// lldb-command:print z
+// lldb-check:[...]$22 = 36.5
+// lldb-command:continue
+
+// IF EXPR
+// lldb-command:print x
+// lldb-check:[...]$23 = 37
+// lldb-command:print y
+// lldb-check:[...]$24 = 38
+// lldb-command:print z
+// lldb-check:[...]$25 = 39.5
+// lldb-command:continue
+
+// WHILE EXPR
+// lldb-command:print x
+// lldb-check:[...]$26 = 40
+// lldb-command:print y
+// lldb-check:[...]$27 = 41
+// lldb-command:print z
+// lldb-check:[...]$28 = 42
+// lldb-command:continue
+
+// LOOP EXPR
+// lldb-command:print x
+// lldb-check:[...]$29 = 43
+// lldb-command:print y
+// lldb-check:[...]$30 = 44
+// lldb-command:print z
+// lldb-check:[...]$31 = 45
+// lldb-command:continue
+
 #![allow(unused_variable)]
 
 #[no_split_stack]
diff --git a/src/test/debuginfo/function-prologue-stepping-regular.rs b/src/test/debuginfo/function-prologue-stepping-regular.rs
new file mode 100644 (file)
index 0000000..7cb9c6b
--- /dev/null
@@ -0,0 +1,232 @@
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test case checks if function arguments already have the correct value when breaking at the
+// beginning of a function.
+
+// ignore-gdb
+// compile-flags:-g
+
+// lldb-command:breakpoint set --name immediate_args
+// lldb-command:breakpoint set --name non_immediate_args
+// lldb-command:breakpoint set --name binding
+// lldb-command:breakpoint set --name assignment
+// lldb-command:breakpoint set --name function_call
+// lldb-command:breakpoint set --name identifier
+// lldb-command:breakpoint set --name return_expr
+// lldb-command:breakpoint set --name arithmetic_expr
+// lldb-command:breakpoint set --name if_expr
+// lldb-command:breakpoint set --name while_expr
+// lldb-command:breakpoint set --name loop_expr
+// lldb-command:run
+
+// IMMEDIATE ARGS
+// lldb-command:print a
+// lldb-check:[...]$0 = 1
+// lldb-command:print b
+// lldb-check:[...]$1 = true
+// lldb-command:print c
+// lldb-check:[...]$2 = 2.5
+// lldb-command:continue
+
+// NON IMMEDIATE ARGS
+// lldb-command:print a
+// lldb-check:[...]$3 = BigStruct { a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10 }
+// lldb-command:print b
+// lldb-check:[...]$4 = BigStruct { a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18 }
+// lldb-command:continue
+
+// BINDING
+// lldb-command:print a
+// lldb-check:[...]$5 = 19
+// lldb-command:print b
+// lldb-check:[...]$6 = 20
+// lldb-command:print c
+// lldb-check:[...]$7 = 21.5
+// lldb-command:continue
+
+// ASSIGNMENT
+// lldb-command:print a
+// lldb-check:[...]$8 = 22
+// lldb-command:print b
+// lldb-check:[...]$9 = 23
+// lldb-command:print c
+// lldb-check:[...]$10 = 24.5
+// lldb-command:continue
+
+// FUNCTION CALL
+// lldb-command:print x
+// lldb-check:[...]$11 = 25
+// lldb-command:print y
+// lldb-check:[...]$12 = 26
+// lldb-command:print z
+// lldb-check:[...]$13 = 27.5
+// lldb-command:continue
+
+// EXPR
+// lldb-command:print x
+// lldb-check:[...]$14 = 28
+// lldb-command:print y
+// lldb-check:[...]$15 = 29
+// lldb-command:print z
+// lldb-check:[...]$16 = 30.5
+// lldb-command:continue
+
+// RETURN EXPR
+// lldb-command:print x
+// lldb-check:[...]$17 = 31
+// lldb-command:print y
+// lldb-check:[...]$18 = 32
+// lldb-command:print z
+// lldb-check:[...]$19 = 33.5
+// lldb-command:continue
+
+// ARITHMETIC EXPR
+// lldb-command:print x
+// lldb-check:[...]$20 = 34
+// lldb-command:print y
+// lldb-check:[...]$21 = 35
+// lldb-command:print z
+// lldb-check:[...]$22 = 36.5
+// lldb-command:continue
+
+// IF EXPR
+// lldb-command:print x
+// lldb-check:[...]$23 = 37
+// lldb-command:print y
+// lldb-check:[...]$24 = 38
+// lldb-command:print z
+// lldb-check:[...]$25 = 39.5
+// lldb-command:continue
+
+// WHILE EXPR
+// lldb-command:print x
+// lldb-check:[...]$26 = 40
+// lldb-command:print y
+// lldb-check:[...]$27 = 41
+// lldb-command:print z
+// lldb-check:[...]$28 = 42
+// lldb-command:continue
+
+// LOOP EXPR
+// lldb-command:print x
+// lldb-check:[...]$29 = 43
+// lldb-command:print y
+// lldb-check:[...]$30 = 44
+// lldb-command:print z
+// lldb-check:[...]$31 = 45
+// lldb-command:continue
+
+#![allow(unused_variable)]
+
+fn immediate_args(a: int, b: bool, c: f64) {
+    ()
+}
+
+struct BigStruct {
+    a: u64,
+    b: u64,
+    c: u64,
+    d: u64,
+    e: u64,
+    f: u64,
+    g: u64,
+    h: u64
+}
+
+fn non_immediate_args(a: BigStruct, b: BigStruct) {
+    ()
+}
+
+fn binding(a: i64, b: u64, c: f64) {
+    let x = 0i;
+}
+
+fn assignment(mut a: u64, b: u64, c: f64) {
+    a = b;
+}
+
+fn function_call(x: u64, y: u64, z: f64) {
+    std::io::stdio::print("Hi!")
+}
+
+fn identifier(x: u64, y: u64, z: f64) -> u64 {
+    x
+}
+
+fn return_expr(x: u64, y: u64, z: f64) -> u64 {
+    return x;
+}
+
+fn arithmetic_expr(x: u64, y: u64, z: f64) -> u64 {
+    x + y
+}
+
+fn if_expr(x: u64, y: u64, z: f64) -> u64 {
+    if x + y < 1000 {
+        x
+    } else {
+        y
+    }
+}
+
+fn while_expr(mut x: u64, y: u64, z: u64) -> u64 {
+    while x + y < 1000 {
+        x += z
+    }
+    return x;
+}
+
+fn loop_expr(mut x: u64, y: u64, z: u64) -> u64 {
+    loop {
+        x += z;
+
+        if x + y > 1000 {
+            return x;
+        }
+    }
+}
+
+fn main() {
+    immediate_args(1, true, 2.5);
+
+    non_immediate_args(
+        BigStruct {
+            a: 3,
+            b: 4,
+            c: 5,
+            d: 6,
+            e: 7,
+            f: 8,
+            g: 9,
+            h: 10
+        },
+        BigStruct {
+            a: 11,
+            b: 12,
+            c: 13,
+            d: 14,
+            e: 15,
+            f: 16,
+            g: 17,
+            h: 18
+        }
+    );
+
+    binding(19, 20, 21.5);
+    assignment(22, 23, 24.5);
+    function_call(25, 26, 27.5);
+    identifier(28, 29, 30.5);
+    return_expr(31, 32, 33.5);
+    arithmetic_expr(34, 35, 36.5);
+    if_expr(37, 38, 39.5);
+    while_expr(40, 41, 42);
+    loop_expr(43, 44, 45);
+}
index 1777c168d9b9a49989252854e0be1ada323e98a1..c3996929e7c79ae748b0451c977c2893eea7ebeb 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$9 = {{5, {a = 6, b = 7.5}}, {{a = 6, b = 7.5}, 5}}
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *t0
+// lldb-check:[...]$0 = 1
+// lldb-command:print *t1
+// lldb-check:[...]$1 = 2.5
+// lldb-command:print ret
+// lldb-check:[...]$2 = ((1, 2.5), (2.5, 1))
+// lldb-command:continue
+
+// lldb-command:print *t0
+// lldb-check:[...]$3 = 3.5
+// lldb-command:print *t1
+// lldb-check:[...]$4 = 4
+// lldb-command:print ret
+// lldb-check:[...]$5 = ((3.5, 4), (4, 3.5))
+// lldb-command:continue
+
+// lldb-command:print *t0
+// lldb-check:[...]$6 = 5
+// lldb-command:print *t1
+// lldb-check:[...]$7 = Struct { a: 6, b: 7.5 }
+// lldb-command:print ret
+// lldb-check:[...]$8 = ((5, Struct { a: 6, b: 7.5 }), (Struct { a: 6, b: 7.5 }, 5))
+// lldb-command:continue
+
+
 #[deriving(Clone)]
 struct Struct {
     a: int,
@@ -49,7 +82,7 @@ struct Struct {
 
 fn dup_tup<T0: Clone, T1: Clone>(t0: &T0, t1: &T1) -> ((T0, T1), (T1, T0)) {
     let ret = ((t0.clone(), t1.clone()), (t1.clone(), t0.clone()));
-    zzz();
+    zzz(); // #break
     ret
 }
 
index 1805405dc1ef5d16522e13edf6f1e711e2a175ee..2546c2c233954b881f39a20d582e626d1b83cc51 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$8 = 2.5
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print x
+// lldb-check:[...]$0 = -1
+// lldb-command:print y
+// lldb-check:[...]$1 = 1
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$2 = -1
+// lldb-command:print y
+// lldb-check:[...]$3 = 2.5
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$4 = -2.5
+// lldb-command:print y
+// lldb-check:[...]$5 = 1
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$6 = -2.5
+// lldb-command:print y
+// lldb-check:[...]$7 = 2.5
+// lldb-command:continue
+
 fn outer<TA: Clone>(a: TA) {
     inner(a.clone(), 1i);
     inner(a.clone(), 2.5f64);
 
     fn inner<TX, TY>(x: TX, y: TY) {
-        zzz();
+        zzz(); // #break
     }
 }
 
@@ -56,4 +88,4 @@ fn main() {
     outer(-2.5f64);
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 9ed1c0175a91b50cea50abee50f17e385f74e7b1..2e43dcdeb498efe9599b35386b922dd65ad09696 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
@@ -20,8 +23,8 @@
 // gdb-check:$1 = {x = {8888, -8888}}
 // gdb-command:print arg1
 // gdb-check:$2 = -1
-// gdb-command:print/d arg2
-// gdb-check:$3 = -2
+// gdb-command:print arg2
+// gdb-check:$3 = 2
 // gdb-command:continue
 
 // STACK BY VAL
 // gdb-check:$15 = -10.5
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// STACK BY REF
+// lldb-command:print *self
+// lldb-check:[...]$0 = Struct<(u32, i32)> { x: (8888, -8888) }
+// lldb-command:print arg1
+// lldb-check:[...]$1 = -1
+// lldb-command:print arg2
+// lldb-check:[...]$2 = 2
+// lldb-command:continue
+
+// STACK BY VAL
+// lldb-command:print self
+// lldb-check:[...]$3 = Struct<(u32, i32)> { x: (8888, -8888) }
+// lldb-command:print arg1
+// lldb-check:[...]$4 = -3
+// lldb-command:print arg2
+// lldb-check:[...]$5 = -4
+// lldb-command:continue
+
+// OWNED BY REF
+// lldb-command:print *self
+// lldb-check:[...]$6 = Struct<f64> { x: 1234.5 }
+// lldb-command:print arg1
+// lldb-check:[...]$7 = -5
+// lldb-command:print arg2
+// lldb-check:[...]$8 = -6
+// lldb-command:continue
+
+// OWNED BY VAL
+// lldb-command:print self
+// lldb-check:[...]$9 = Struct<f64> { x: 1234.5 }
+// lldb-command:print arg1
+// lldb-check:[...]$10 = -7
+// lldb-command:print arg2
+// lldb-check:[...]$11 = -8
+// lldb-command:continue
+
+// OWNED MOVED
+// lldb-command:print *self
+// lldb-check:[...]$12 = Struct<f64> { x: 1234.5 }
+// lldb-command:print arg1
+// lldb-check:[...]$13 = -9
+// lldb-command:print arg2
+// lldb-check:[...]$14 = -10.5
+// lldb-command:continue
+
+
 struct Struct<T> {
     x: T
 }
@@ -71,24 +125,24 @@ struct Struct<T> {
 impl<T1> Struct<T1> {
 
     fn self_by_ref<T2>(&self, arg1: int, arg2: T2) -> int {
-        zzz();
+        zzz(); // #break
         arg1
     }
 
     fn self_by_val<T2>(self, arg1: int, arg2: T2) -> int {
-        zzz();
+        zzz(); // #break
         arg1
     }
 
-    fn self_owned<T2>(~self, arg1: int, arg2: T2) -> int {
-        zzz();
+    fn self_owned<T2>(self: Box<Struct<T1>>, arg1: int, arg2: T2) -> int {
+        zzz(); // #break
         arg1
     }
 }
 
 fn main() {
     let stack = Struct { x: (8888_u32, -8888_i32) };
-    let _ = stack.self_by_ref(-1, -2_i8);
+    let _ = stack.self_by_ref(-1, 2_u16);
     let _ = stack.self_by_val(-3, -4_i16);
 
     let owned = box Struct { x: 1234.5f64 };
index a2c5a0973fca4f2f6bd25c6fc6301393331a7d8c..65ccb1314add3647c50eed75f2f989c6128737f8 100644 (file)
@@ -8,9 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-tidy-linelength
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-command:print float_int_float
 // gdb-check:$4 = {key = 6.5, value = {key = 7, value = 8.5}}
 
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print int_int
+// lldb-check:[...]$0 = AGenericStruct<int, int> { key: 0, value: 1 }
+// lldb-command:print int_float
+// lldb-check:[...]$1 = AGenericStruct<int, f64> { key: 2, value: 3.5 }
+// lldb-command:print float_int
+// lldb-check:[...]$2 = AGenericStruct<f64, int> { key: 4.5, value: 5 }
+
+// lldb-command:print float_int_float
+// lldb-check:[...]$3 = AGenericStruct<f64, generic-struct::AGenericStruct<int, f64>> { key: 6.5, value: AGenericStruct<int, f64> { key: 7, value: 8.5 } }
+
 struct AGenericStruct<TKey, TValue> {
     key: TKey,
     value: TValue
@@ -39,7 +57,7 @@ fn main() {
         value: AGenericStruct { key: 7i, value: 8.5f64 },
     };
 
-    zzz();
+    zzz(); // #break
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 07f7546068ca9f7fc12125638e26c221b1c20e0a..8638ae3b49d890c58bfb5571ed3ad73c323c8063 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print union on
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-check:$4 = {{-1}}
 
 
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print case1
+// lldb-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868)
+
+// lldb-command:print case2
+// lldb-check:[...]$1 = Case2(0, 286331153, 286331153)
+
+// lldb-command:print case3
+// lldb-check:[...]$2 = Case3(0, 6438275382588823897)
+
+// lldb-command:print univariant
+// lldb-check:[...]$3 = TheOnlyCase(-1)
+
+
 // NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be
 // substituted with something of size `xx` bits and the same alignment as an integer type of the
 // same size.
@@ -73,7 +93,7 @@ fn main() {
 
     let univariant = TheOnlyCase(-1_i64);
 
-    zzz();
+    zzz(); // #break
 }
 
-fn zzz() {()}
+fn zzz() { () }
index 977e304a32ec235dc6c4b67b901b0931adfa6c1c..ed9767c78f3f609e415e6504caacf32ac2f11bad 100644 (file)
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print string1.length
-// gdb-check:$1 = 49
+// gdb-check:$1 = 48
 // gdb-command:print string2.length
 // gdb-check:$2 = 49
 // gdb-command:print string3.length
-// gdb-check:$3 = 49
+// gdb-check:$3 = 50
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print string1.length
+// lldb-check:[...]$0 = 48
+// lldb-command:print string2.length
+// lldb-check:[...]$1 = 49
+// lldb-command:print string3.length
+// lldb-check:[...]$2 = 50
+
+// lldb-command:continue
+
 #![allow(unused_variable)]
 
 // This test case makes sure that debug info does not ICE when include_str is
@@ -31,7 +45,8 @@ fn main() {
     let string1 = include_str!("text-to-include-1.txt");
     let string2 = include_str!("text-to-include-2.txt");
     let string3 = include_str!("text-to-include-3.txt");
-    zzz();
+
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 0fb823a74cc72c11ba27d7c2e828bc60b27b71c2..13cae3252d804e90762baf4c0cdce002d090ca60 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$7 = 1000000
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// FIRST ITERATION
+// lldb-command:print x
+// lldb-check:[...]$0 = 1
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$1 = -1
+// lldb-command:continue
+
+// SECOND ITERATION
+// lldb-command:print x
+// lldb-check:[...]$2 = 2
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$3 = -2
+// lldb-command:continue
+
+// THIRD ITERATION
+// lldb-command:print x
+// lldb-check:[...]$4 = 3
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$5 = -3
+// lldb-command:continue
+
+// AFTER LOOP
+// lldb-command:print x
+// lldb-check:[...]$6 = 1000000
+// lldb-command:continue
+
 fn main() {
 
     let range = [1i, 2, 3];
@@ -60,16 +100,16 @@ fn main() {
     let x = 1000000i; // wan meeeljen doollaars!
 
     for &x in range.iter() {
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let x = -1i * x;
 
-        zzz();
+        zzz(); // #break
         sentinel();
     }
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index 6018e62af0078db154ffa225d47e02f3b1355deb..ce30886c7d375aa4aa1cc3eaac0f164708d657fe 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$16 = -1
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// BEFORE if
+// lldb-command:print x
+// lldb-check:[...]$0 = 999
+// lldb-command:print y
+// lldb-check:[...]$1 = -1
+// lldb-command:continue
+
+// AT BEGINNING of 'then' block
+// lldb-command:print x
+// lldb-check:[...]$2 = 999
+// lldb-command:print y
+// lldb-check:[...]$3 = -1
+// lldb-command:continue
+
+// AFTER 1st redeclaration of 'x'
+// lldb-command:print x
+// lldb-check:[...]$4 = 1001
+// lldb-command:print y
+// lldb-check:[...]$5 = -1
+// lldb-command:continue
+
+// AFTER 2st redeclaration of 'x'
+// lldb-command:print x
+// lldb-check:[...]$6 = 1002
+// lldb-command:print y
+// lldb-check:[...]$7 = 1003
+// lldb-command:continue
+
+// AFTER 1st if expression
+// lldb-command:print x
+// lldb-check:[...]$8 = 999
+// lldb-command:print y
+// lldb-check:[...]$9 = -1
+// lldb-command:continue
+
+// BEGINNING of else branch
+// lldb-command:print x
+// lldb-check:[...]$10 = 999
+// lldb-command:print y
+// lldb-check:[...]$11 = -1
+// lldb-command:continue
+
+// BEGINNING of else branch
+// lldb-command:print x
+// lldb-check:[...]$12 = 1004
+// lldb-command:print y
+// lldb-check:[...]$13 = 1005
+// lldb-command:continue
+
+// BEGINNING of else branch
+// lldb-command:print x
+// lldb-check:[...]$14 = 999
+// lldb-command:print y
+// lldb-check:[...]$15 = -1
+// lldb-command:continue
+
+
 fn main() {
 
     let x = 999i;
     let y = -1i;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     if x < 1000 {
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let x = 1001i;
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let x = 1002i;
         let y = 1003i;
-        zzz();
+        zzz(); // #break
         sentinel();
     } else {
         unreachable!();
     }
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     if x > 1000 {
         unreachable!();
     } else {
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let x = 1004i;
         let y = 1005i;
-        zzz();
+        zzz(); // #break
         sentinel();
     }
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index 7bec677e4b1005b9e379aa2e69f06011c6967121..78e9b278e53a9c1c701157b6d20341eefd327528 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$18 = 232
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print shadowed
+// lldb-check:[...]$0 = 231
+// lldb-command:print not_shadowed
+// lldb-check:[...]$1 = 232
+// lldb-command:continue
+
+// lldb-command:print shadowed
+// lldb-check:[...]$2 = 233
+// lldb-command:print not_shadowed
+// lldb-check:[...]$3 = 232
+// lldb-command:print local_to_arm
+// lldb-check:[...]$4 = 234
+// lldb-command:continue
+
+// lldb-command:print shadowed
+// lldb-check:[...]$5 = 236
+// lldb-command:print not_shadowed
+// lldb-check:[...]$6 = 232
+// lldb-command:continue
+
+// lldb-command:print shadowed
+// lldb-check:[...]$7 = 237
+// lldb-command:print not_shadowed
+// lldb-check:[...]$8 = 232
+// lldb-command:print local_to_arm
+// lldb-check:[...]$9 = 238
+// lldb-command:continue
+
+// lldb-command:print shadowed
+// lldb-check:[...]$10 = 239
+// lldb-command:print not_shadowed
+// lldb-check:[...]$11 = 232
+// lldb-command:continue
+
+// lldb-command:print shadowed
+// lldb-check:[...]$12 = 241
+// lldb-command:print not_shadowed
+// lldb-check:[...]$13 = 232
+// lldb-command:continue
+
+// lldb-command:print shadowed
+// lldb-check:[...]$14 = 243
+// lldb-command:print *local_to_arm
+// lldb-check:[...]$15 = 244
+// lldb-command:continue
+
+// lldb-command:print shadowed
+// lldb-check:[...]$16 = 231
+// lldb-command:print not_shadowed
+// lldb-check:[...]$17 = 232
+// lldb-command:continue
+
+
 struct Struct {
     x: int,
     y: int
@@ -84,13 +145,13 @@ fn main() {
     let shadowed = 231i;
     let not_shadowed = 232i;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     match (233i, 234i) {
         (shadowed, local_to_arm) => {
 
-            zzz();
+            zzz(); // #break
             sentinel();
         }
     }
@@ -99,7 +160,7 @@ fn main() {
         // with literal
         (235, shadowed) => {
 
-            zzz();
+            zzz(); // #break
             sentinel();
         }
         _ => {}
@@ -108,7 +169,7 @@ fn main() {
     match (Struct { x: 237, y: 238 }) {
         Struct { x: shadowed, y: local_to_arm } => {
 
-            zzz();
+            zzz(); // #break
             sentinel();
         }
     }
@@ -117,7 +178,7 @@ fn main() {
         // ignored field
         Struct { x: shadowed, .. } => {
 
-            zzz();
+            zzz(); // #break
             sentinel();
         }
     }
@@ -126,7 +187,7 @@ fn main() {
         // with literal
         Struct { x: shadowed, y: 242 } => {
 
-            zzz();
+            zzz(); // #break
             sentinel();
         }
         _ => {}
@@ -135,12 +196,12 @@ fn main() {
     match (243i, 244i) {
         (shadowed, ref local_to_arm) => {
 
-            zzz();
+            zzz(); // #break
             sentinel();
         }
     }
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index 0168eaa86c2d1d90d2647113c21a688717e49b07..aca6cc06abddb6f55d48bce5eec64e1d16bdf3e7 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$6 = false
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print x
+// lldb-check:[...]$0 = false
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$1 = false
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$2 = 1000
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$3 = 2.5
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$4 = true
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$5 = false
+// lldb-command:continue
+
 fn main() {
 
     let x = false;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     let stack_closure: |int| = |x| {
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let x = 2.5f64;
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let x = true;
 
-        zzz();
+        zzz(); // #break
         sentinel();
     };
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     stack_closure(1000);
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index 48edd7ae12a096f4bdcd81659626c6948e510feb..3096dfbd2a6e201c357bbd4c611108beb864223b 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$13 = 2
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// FIRST ITERATION
+// lldb-command:print x
+// lldb-check:[...]$0 = 0
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$1 = 1
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$2 = 101
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$3 = 101
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$4 = -987
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$5 = 101
+// lldb-command:continue
+
+
+// SECOND ITERATION
+// lldb-command:print x
+// lldb-check:[...]$6 = 1
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$7 = 2
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$8 = 102
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$9 = 102
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$10 = -987
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$11 = 102
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$12 = 2
+// lldb-command:continue
+
 fn main() {
 
     let mut x = 0i;
@@ -91,35 +154,35 @@ fn main() {
             break;
         }
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         x += 1;
-        zzz();
+        zzz(); // #break
         sentinel();
 
         // Shadow x
         let x = x + 100;
-        zzz();
+        zzz(); // #break
         sentinel();
 
         // open scope within loop's top level scope
         {
-            zzz();
+            zzz(); // #break
             sentinel();
 
             let x = -987i;
 
-            zzz();
+            zzz(); // #break
             sentinel();
         }
 
         // Check that we get the x before the inner scope again
-        zzz();
+        zzz(); // #break
         sentinel();
     }
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index ce3b2a530e2c297f38096d3ab075944c6a8777c3..590b7238c123a0a5f0e1f9e500c127d0c9ecfe2a 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$6 = false
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print x
+// lldb-check:[...]$0 = false
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$1 = false
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$2 = 1000
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$3 = 2.5
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$4 = true
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$5 = false
+// lldb-command:continue
+
 fn main() {
 
     let x = false;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     let unique_closure: proc(int) = proc(x) {
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let x = 2.5f64;
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let x = true;
 
-        zzz();
+        zzz(); // #break
         sentinel();
     };
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     unique_closure(1000);
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index d726eb6581eb2cd9778903ae570f65d29ea3fb81..b211c11128a7ce9f680aa9832bdf531683fe01c3 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$13 = 2
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// FIRST ITERATION
+// lldb-command:print x
+// lldb-check:[...]$0 = 0
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$1 = 1
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$2 = 101
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$3 = 101
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$4 = -987
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$5 = 101
+// lldb-command:continue
+
+
+// SECOND ITERATION
+// lldb-command:print x
+// lldb-check:[...]$6 = 1
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$7 = 2
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$8 = 102
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$9 = 102
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$10 = -987
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$11 = 102
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$12 = 2
+// lldb-command:continue
+
+
 fn main() {
 
     let mut x = 0i;
 
     while x < 2 {
-        zzz();
+        zzz(); // #break
         sentinel();
 
         x += 1;
-        zzz();
+        zzz(); // #break
         sentinel();
 
         // Shadow x
         let x = x + 100;
-        zzz();
+        zzz(); // #break
         sentinel();
 
         // open scope within loop's top level scope
         {
-            zzz();
+            zzz(); // #break
             sentinel();
 
             let x = -987i;
 
-            zzz();
+            zzz(); // #break
             sentinel();
         }
 
         // Check that we get the x before the inner scope again
-        zzz();
+        zzz(); // #break
         sentinel();
     }
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index e55271239d488bbf88fadb09e10ba0aaa7450242..27070dd867d0e40458ff6d3812271cc77820fb4d 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$15 = 400
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print a
+// lldb-check:[...]$0 = 10
+// lldb-command:print b
+// lldb-check:[...]$1 = 34
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$2 = 890242
+// lldb-command:print b
+// lldb-check:[...]$3 = 34
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$4 = 10
+// lldb-command:print b
+// lldb-check:[...]$5 = 34
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$6 = 102
+// lldb-command:print b
+// lldb-check:[...]$7 = 34
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$8 = 110
+// lldb-command:print b
+// lldb-check:[...]$9 = 34
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$10 = 10
+// lldb-command:print b
+// lldb-check:[...]$11 = 34
+// lldb-command:continue
+
+// lldb-command:print a
+// lldb-check:[...]$12 = 10
+// lldb-command:print b
+// lldb-check:[...]$13 = 34
+// lldb-command:print c
+// lldb-check:[...]$14 = 400
+// lldb-command:continue
+
+
 #![feature(macro_rules)]
 
 macro_rules! trivial(
@@ -78,7 +131,7 @@ macro_rules! no_new_scope(
 macro_rules! new_scope(
     () => ({
         let a = 890242i;
-        zzz();
+        zzz(); // #break
         sentinel();
     })
 )
@@ -87,12 +140,12 @@ macro_rules! shadow_within_macro(
     ($e1:expr) => ({
         let a = $e1 + 2;
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let a = $e1 + 10;
 
-        zzz();
+        zzz(); // #break
         sentinel();
     })
 )
@@ -108,22 +161,22 @@ fn main() {
     let a = trivial!(10i);
     let b = no_new_scope!(33i);
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     new_scope!();
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     shadow_within_macro!(100i);
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     let c = dup_expr!(10i * 20);
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index 2a9969dc6e90310e42fd6466dd2bec61a365dbab..b5f9622e79a7bd977aaab5e63ee4c0e41bca8f8a 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$57 = 10
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// STRUCT EXPRESSION
+// lldb-command:print val
+// lldb-check:[...]$0 = -1
+// lldb-command:print ten
+// lldb-check:[...]$1 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$2 = 11
+// lldb-command:print ten
+// lldb-check:[...]$3 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$4 = -1
+// lldb-command:print ten
+// lldb-check:[...]$5 = 10
+// lldb-command:continue
+
+// FUNCTION CALL
+// lldb-command:print val
+// lldb-check:[...]$6 = -1
+// lldb-command:print ten
+// lldb-check:[...]$7 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$8 = 12
+// lldb-command:print ten
+// lldb-check:[...]$9 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$10 = -1
+// lldb-command:print ten
+// lldb-check:[...]$11 = 10
+// lldb-command:continue
+
+// TUPLE EXPRESSION
+// lldb-command:print val
+// lldb-check:[...]$12 = -1
+// lldb-command:print ten
+// lldb-check:[...]$13 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$14 = 13
+// lldb-command:print ten
+// lldb-check:[...]$15 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$16 = -1
+// lldb-command:print ten
+// lldb-check:[...]$17 = 10
+// lldb-command:continue
+
+// VEC EXPRESSION
+// lldb-command:print val
+// lldb-check:[...]$18 = -1
+// lldb-command:print ten
+// lldb-check:[...]$19 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$20 = 14
+// lldb-command:print ten
+// lldb-check:[...]$21 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$22 = -1
+// lldb-command:print ten
+// lldb-check:[...]$23 = 10
+// lldb-command:continue
+
+// REPEAT VEC EXPRESSION
+// lldb-command:print val
+// lldb-check:[...]$24 = -1
+// lldb-command:print ten
+// lldb-check:[...]$25 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$26 = 15
+// lldb-command:print ten
+// lldb-check:[...]$27 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$28 = -1
+// lldb-command:print ten
+// lldb-check:[...]$29 = 10
+// lldb-command:continue
+
+// ASSIGNMENT EXPRESSION
+// lldb-command:print val
+// lldb-check:[...]$30 = -1
+// lldb-command:print ten
+// lldb-check:[...]$31 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$32 = 16
+// lldb-command:print ten
+// lldb-check:[...]$33 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$34 = -1
+// lldb-command:print ten
+// lldb-check:[...]$35 = 10
+// lldb-command:continue
+
+
+// ARITHMETIC EXPRESSION
+// lldb-command:print val
+// lldb-check:[...]$36 = -1
+// lldb-command:print ten
+// lldb-check:[...]$37 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$38 = 17
+// lldb-command:print ten
+// lldb-check:[...]$39 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$40 = -1
+// lldb-command:print ten
+// lldb-check:[...]$41 = 10
+// lldb-command:continue
+
+// INDEX EXPRESSION
+// lldb-command:print val
+// lldb-check:[...]$42 = -1
+// lldb-command:print ten
+// lldb-check:[...]$43 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$44 = 18
+// lldb-command:print ten
+// lldb-check:[...]$45 = 10
+// lldb-command:continue
+
+// lldb-command:print val
+// lldb-check:[...]$46 = -1
+// lldb-command:print ten
+// lldb-check:[...]$47 = 10
+// lldb-command:continue
+
 #![allow(unused_variable)]
 #![allow(dead_assignment)]
 
@@ -233,13 +394,13 @@ fn main() {
     // surrounded by struct expression
     let point = Point {
         x: {
-            zzz();
+            zzz(); // #break
             sentinel();
 
             let val = ten + 1;
             unsafe {MUT_INT = 1;};
 
-            zzz();
+            zzz(); // #break
             sentinel();
 
             val
@@ -247,129 +408,129 @@ fn main() {
         y: 10
     };
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     // surrounded by function call
     let _ = a_function({
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let val = ten + 2;
         unsafe {MUT_INT = 2;};
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         val
     });
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
 
     // surrounded by tup
     let _ = ({
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let val = ten + 3;
         unsafe {MUT_INT = 3;};
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         val
     }, 0i);
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     // surrounded by vec
     let _ = [{
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let val = ten + 4;
         unsafe {MUT_INT = 4;};
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         val
     }, 0, 0];
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     // surrounded by repeat vec
     let _ = [{
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let val = ten + 5;
         unsafe {MUT_INT = 5;};
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         val
     }, ..10];
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     // assignment expression
     let mut var = 0;
     var = {
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let val = ten + 6;
         unsafe {MUT_INT = 6;};
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         val
     };
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     // arithmetic expression
     var = 10 + -{
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let val = ten + 7;
         unsafe {MUT_INT = 7;};
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         val
     } * 5;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     // index expression
     let a_vector = [10i, ..20];
     let _ = a_vector[{
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let val = ten + 8;
         unsafe {MUT_INT = 8;};
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         val as uint
     }];
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index 9cda2c45131db1f4e7ae770f6d0738acc2c8c9e2..6c71971a0f82406525053b0c874d698da3958135 100644 (file)
@@ -10,6 +10,8 @@
 
 // ignore-android: FIXME(#10381)
 
+// ignore-lldb
+
 // compile-flags:--debuginfo=1
 
 // Make sure functions have proper names
index bb236a28a88008ce8f598ad141311be59c0e6695..2fd43d3e9ca67a1e36b53bae229697373e96401e 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print univariant->val
 // gdb-check:$3 = {{-9747455}}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print the_a->val
+// lldb-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
+
+// lldb-command:print the_b->val
+// lldb-check:[...]$1 = TheB(0, 286331153, 286331153)
+
+// lldb-command:print univariant->val
+// lldb-check:[...]$2 = TheOnlyCase(-9747455)
+
 #![allow(unused_variable)]
 #![feature(struct_variant, managed_boxes)]
 
@@ -62,7 +79,7 @@ fn main() {
 
     let univariant = box(GC) TheOnlyCase(-9747455);
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index d1f38be1d8947c2807756962089f93d65cd18ab2..6abd174b1aa67e164c8517bd3f799363e5d4da71 100644 (file)
@@ -13,6 +13,9 @@
 #![feature(managed_boxes)]
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print unique.ptr[3]->val
 // gdb-check:$4 = 13
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print unique.ptr[0]->val
+// lldb-check:[...]$0 = 10
+
+// lldb-command:print unique.ptr[1]->val
+// lldb-check:[...]$1 = 11
+
+// lldb-command:print unique.ptr[2]->val
+// lldb-check:[...]$2 = 12
+
+// lldb-command:print unique.ptr[3]->val
+// lldb-check:[...]$3 = 13
+
+
 #![allow(unused_variable)]
 
 use std::gc::{Gc, GC};
@@ -37,7 +58,7 @@ fn main() {
 
     let unique: Vec<Gc<i64>> = vec!(box(GC) 10, box(GC) 11, box(GC) 12, box(GC) 13);
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index cc18ea64f383eeedeb74cbd18cf239ac3b66632a..7f1b32936c8197c8fcfe7065cf2e6bab72f5cc64 100644 (file)
@@ -13,6 +13,9 @@
 #![feature(managed_boxes)]
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print managed_within_unique->y->val
 // gdb-check:$3 = -4
 
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *ordinary_unique
+// lldb-check:[...]$0 = (-1, -2)
+
+// lldb-command:print managed_within_unique->x
+// lldb-check:[...]$1 = -3
+
+// lldb-command:print managed_within_unique->y->val
+// lldb-check:[...]$2 = -4
+
 #![allow(unused_variable)]
 
 use std::gc::{GC, Gc};
@@ -41,7 +57,7 @@ fn main() {
 
     let managed_within_unique = box ContainsManaged { x: -3, y: box(GC) -4i };
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 1a5fac18a6973b6405bf19e50e65071536d9dd24..74f4882bd4bf494918a01cb3515fcf98735a90c5 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$15 = -10
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// STACK BY REF
+// lldb-command:print *self
+// lldb-check:[...]$0 = Variant2(117901063)
+// lldb-command:print arg1
+// lldb-check:[...]$1 = -1
+// lldb-command:print arg2
+// lldb-check:[...]$2 = -2
+// lldb-command:continue
+
+// STACK BY VAL
+// lldb-command:print self
+// lldb-check:[...]$3 = Variant2(117901063)
+// lldb-command:print arg1
+// lldb-check:[...]$4 = -3
+// lldb-command:print arg2
+// lldb-check:[...]$5 = -4
+// lldb-command:continue
+
+// OWNED BY REF
+// lldb-command:print *self
+// lldb-check:[...]$6 = Variant1 { x: 1799, y: 1799 }
+// lldb-command:print arg1
+// lldb-check:[...]$7 = -5
+// lldb-command:print arg2
+// lldb-check:[...]$8 = -6
+// lldb-command:continue
+
+// OWNED BY VAL
+// lldb-command:print self
+// lldb-check:[...]$9 = Variant1 { x: 1799, y: 1799 }
+// lldb-command:print arg1
+// lldb-check:[...]$10 = -7
+// lldb-command:print arg2
+// lldb-check:[...]$11 = -8
+// lldb-command:continue
+
+// OWNED MOVED
+// lldb-command:print *self
+// lldb-check:[...]$12 = Variant1 { x: 1799, y: 1799 }
+// lldb-command:print arg1
+// lldb-check:[...]$13 = -9
+// lldb-command:print arg2
+// lldb-check:[...]$14 = -10
+// lldb-command:continue
+
 #![feature(struct_variant)]
 
 enum Enum {
@@ -74,17 +127,17 @@ enum Enum {
 impl Enum {
 
     fn self_by_ref(&self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         arg1 + arg2
     }
 
     fn self_by_val(self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         arg1 + arg2
     }
 
-    fn self_owned(~self, arg1: int, arg2: int) -> int {
-        zzz();
+    fn self_owned(self: Box<Enum>, arg1: int, arg2: int) -> int {
+        zzz(); // #break
         arg1 + arg2
     }
 }
index 0bac86b1e66aa346c3db94632e614fb2c3999561..590a821fcb6e10017d1af6240eca4af91613c925 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$15 = -10
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// STACK BY REF
+// lldb-command:print *self
+// lldb-check:[...]$0 = Struct<(u32, i32)> { x: (8888, -8888) }
+// lldb-command:print arg1
+// lldb-check:[...]$1 = -1
+// lldb-command:print arg2
+// lldb-check:[...]$2 = -2
+// lldb-command:continue
+
+// STACK BY VAL
+// lldb-command:print self
+// lldb-check:[...]$3 = Struct<(u32, i32)> { x: (8888, -8888) }
+// lldb-command:print arg1
+// lldb-check:[...]$4 = -3
+// lldb-command:print arg2
+// lldb-check:[...]$5 = -4
+// lldb-command:continue
+
+// OWNED BY REF
+// lldb-command:print *self
+// lldb-check:[...]$6 = Struct<f64> { x: 1234.5 }
+// lldb-command:print arg1
+// lldb-check:[...]$7 = -5
+// lldb-command:print arg2
+// lldb-check:[...]$8 = -6
+// lldb-command:continue
+
+// OWNED BY VAL
+// lldb-command:print self
+// lldb-check:[...]$9 = Struct<f64> { x: 1234.5 }
+// lldb-command:print arg1
+// lldb-check:[...]$10 = -7
+// lldb-command:print arg2
+// lldb-check:[...]$11 = -8
+// lldb-command:continue
+
+// OWNED MOVED
+// lldb-command:print *self
+// lldb-check:[...]$12 = Struct<f64> { x: 1234.5 }
+// lldb-command:print arg1
+// lldb-check:[...]$13 = -9
+// lldb-command:print arg2
+// lldb-check:[...]$14 = -10
+// lldb-command:continue
+
+
 struct Struct<T> {
     x: T
 }
@@ -71,17 +125,17 @@ struct Struct<T> {
 impl<T> Struct<T> {
 
     fn self_by_ref(&self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         arg1 + arg2
     }
 
     fn self_by_val(self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         arg1 + arg2
     }
 
-    fn self_owned(~self, arg1: int, arg2: int) -> int {
-        zzz();
+    fn self_owned(self: Box<Struct<T>>, arg1: int, arg2: int) -> int {
+        zzz(); // #break
         arg1 + arg2
     }
 }
index 3d7cc96ca171fa43175bc65ef814d4d96e23e8e8..5ea89f1548915e520dca0b9accf293edf72759aa 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$15 = -10
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// STACK BY REF
+// lldb-command:print *self
+// lldb-check:[...]$0 = Struct { x: 100 }
+// lldb-command:print arg1
+// lldb-check:[...]$1 = -1
+// lldb-command:print arg2
+// lldb-check:[...]$2 = -2
+// lldb-command:continue
+
+// STACK BY VAL
+// lldb-command:print self
+// lldb-check:[...]$3 = Struct { x: 100 }
+// lldb-command:print arg1
+// lldb-check:[...]$4 = -3
+// lldb-command:print arg2
+// lldb-check:[...]$5 = -4
+// lldb-command:continue
+
+// OWNED BY REF
+// lldb-command:print *self
+// lldb-check:[...]$6 = Struct { x: 200 }
+// lldb-command:print arg1
+// lldb-check:[...]$7 = -5
+// lldb-command:print arg2
+// lldb-check:[...]$8 = -6
+// lldb-command:continue
+
+// OWNED BY VAL
+// lldb-command:print self
+// lldb-check:[...]$9 = Struct { x: 200 }
+// lldb-command:print arg1
+// lldb-check:[...]$10 = -7
+// lldb-command:print arg2
+// lldb-check:[...]$11 = -8
+// lldb-command:continue
+
+// OWNED MOVED
+// lldb-command:print *self
+// lldb-check:[...]$12 = Struct { x: 200 }
+// lldb-command:print arg1
+// lldb-check:[...]$13 = -9
+// lldb-command:print arg2
+// lldb-check:[...]$14 = -10
+// lldb-command:continue
+
 struct Struct {
     x: int
 }
@@ -71,17 +124,17 @@ struct Struct {
 impl Struct {
 
     fn self_by_ref(&self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         self.x + arg1 + arg2
     }
 
     fn self_by_val(self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         self.x + arg1 + arg2
     }
 
-    fn self_owned(~self, arg1: int, arg2: int) -> int {
-        zzz();
+    fn self_owned(self: Box<Struct>, arg1: int, arg2: int) -> int {
+        zzz(); // #break
         self.x + arg1 + arg2
     }
 }
index a2b73629a6738d0bc89787521d3068122102980b..1fc136ac1f695c95945871dbebc40f604cb1f5bb 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$15 = -10
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// STACK BY REF
+// lldb-command:print *self
+// lldb-check:[...]$0 = Struct { x: 100 }
+// lldb-command:print arg1
+// lldb-check:[...]$1 = -1
+// lldb-command:print arg2
+// lldb-check:[...]$2 = -2
+// lldb-command:continue
+
+// STACK BY VAL
+// lldb-command:print self
+// lldb-check:[...]$3 = Struct { x: 100 }
+// lldb-command:print arg1
+// lldb-check:[...]$4 = -3
+// lldb-command:print arg2
+// lldb-check:[...]$5 = -4
+// lldb-command:continue
+
+// OWNED BY REF
+// lldb-command:print *self
+// lldb-check:[...]$6 = Struct { x: 200 }
+// lldb-command:print arg1
+// lldb-check:[...]$7 = -5
+// lldb-command:print arg2
+// lldb-check:[...]$8 = -6
+// lldb-command:continue
+
+// OWNED BY VAL
+// lldb-command:print self
+// lldb-check:[...]$9 = Struct { x: 200 }
+// lldb-command:print arg1
+// lldb-check:[...]$10 = -7
+// lldb-command:print arg2
+// lldb-check:[...]$11 = -8
+// lldb-command:continue
+
+// OWNED MOVED
+// lldb-command:print *self
+// lldb-check:[...]$12 = Struct { x: 200 }
+// lldb-command:print arg1
+// lldb-check:[...]$13 = -9
+// lldb-command:print arg2
+// lldb-check:[...]$14 = -10
+// lldb-command:continue
+
 struct Struct {
     x: int
 }
@@ -71,23 +124,23 @@ struct Struct {
 trait Trait {
     fn self_by_ref(&self, arg1: int, arg2: int) -> int;
     fn self_by_val(self, arg1: int, arg2: int) -> int;
-    fn self_owned(~self, arg1: int, arg2: int) -> int;
+    fn self_owned(self: Box<Self>, arg1: int, arg2: int) -> int;
 }
 
 impl Trait for Struct {
 
     fn self_by_ref(&self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         self.x + arg1 + arg2
     }
 
     fn self_by_val(self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         self.x + arg1 + arg2
     }
 
-    fn self_owned(~self, arg1: int, arg2: int) -> int {
-        zzz();
+    fn self_owned(self: Box<Struct>, arg1: int, arg2: int) -> int {
+        zzz(); // #break
         self.x + arg1 + arg2
     }
 }
index fe7271716bb4fbdf0ba8192f12336e9b950ad4af..d4051e333c184319761c5e21e7853e2ed28f1529 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$15 = -10
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// STACK BY REF
+// lldb-command:print *self
+// lldb-check:[...]$0 = TupleStruct(100, -100.5)
+// lldb-command:print arg1
+// lldb-check:[...]$1 = -1
+// lldb-command:print arg2
+// lldb-check:[...]$2 = -2
+// lldb-command:continue
+
+// STACK BY VAL
+// lldb-command:print self
+// lldb-check:[...]$3 = TupleStruct(100, -100.5)
+// lldb-command:print arg1
+// lldb-check:[...]$4 = -3
+// lldb-command:print arg2
+// lldb-check:[...]$5 = -4
+// lldb-command:continue
+
+// OWNED BY REF
+// lldb-command:print *self
+// lldb-check:[...]$6 = TupleStruct(200, -200.5)
+// lldb-command:print arg1
+// lldb-check:[...]$7 = -5
+// lldb-command:print arg2
+// lldb-check:[...]$8 = -6
+// lldb-command:continue
+
+// OWNED BY VAL
+// lldb-command:print self
+// lldb-check:[...]$9 = TupleStruct(200, -200.5)
+// lldb-command:print arg1
+// lldb-check:[...]$10 = -7
+// lldb-command:print arg2
+// lldb-check:[...]$11 = -8
+// lldb-command:continue
+
+// OWNED MOVED
+// lldb-command:print *self
+// lldb-check:[...]$12 = TupleStruct(200, -200.5)
+// lldb-command:print arg1
+// lldb-check:[...]$13 = -9
+// lldb-command:print arg2
+// lldb-check:[...]$14 = -10
+// lldb-command:continue
+
 struct TupleStruct(int, f64);
 
 impl TupleStruct {
 
     fn self_by_ref(&self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         arg1 + arg2
     }
 
     fn self_by_val(self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         arg1 + arg2
     }
 
-    fn self_owned(~self, arg1: int, arg2: int) -> int {
-        zzz();
+    fn self_owned(self: Box<TupleStruct>, arg1: int, arg2: int) -> int {
+        zzz(); // #break
         arg1 + arg2
     }
 }
index 9e40f03c201626a8a791c6224089e8f77af0a28b..1d9427a3bfe68174e606bdce7b6b054a27ec6b9d 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print abc
 // gdb-check:$3 = 30303
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print abc
+// lldb-check:[...]$0 = 10101
+// lldb-command:continue
+
+// lldb-command:print abc
+// lldb-check:[...]$1 = 20202
+// lldb-command:continue
+
+// lldb-command:print abc
+// lldb-check:[...]$2 = 30303
+
 #![allow(unused_variable)]
 
 fn function_one() {
     let abc = 10101i;
-    zzz();
+    zzz(); // #break
 }
 
 fn function_two() {
     let abc = 20202i;
-    zzz();
+    zzz(); // #break
 }
 
 
 fn function_three() {
     let abc = 30303i;
-    zzz();
+    zzz(); // #break
 }
 
 
index ef1c69f9eb8cf50a2744ffcfc015a5f76c13afea..25d9dc02404338491f43a1fe1dc05c114bb31376 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print c
 // gdb-check:$3 = 30303
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print a
+// lldb-check:[...]$0 = 10101
+// lldb-command:continue
+
+// lldb-command:print b
+// lldb-check:[...]$1 = 20202
+// lldb-command:continue
+
+// lldb-command:print c
+// lldb-check:[...]$2 = 30303
+
 #![allow(unused_variable)]
 
 fn function_one() {
     let a = 10101i;
-    zzz();
+    zzz(); // #break
 }
 
 fn function_two() {
     let b = 20202i;
-    zzz();
+    zzz(); // #break
 }
 
 
 fn function_three() {
     let c = 30303i;
-    zzz();
+    zzz(); // #break
 }
 
 
index 8ee6d434016f0b946cdecc1e00a244d870deeee9..3462735f6d1093695c3e0e7eb333f1c967589eaa 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$12 = 20
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print x
+// lldb-check:[...]$0 = false
+// lldb-command:print y
+// lldb-check:[...]$1 = true
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$2 = 10
+// lldb-command:print y
+// lldb-check:[...]$3 = true
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$4 = 10.5
+// lldb-command:print y
+// lldb-check:[...]$5 = 20
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$6 = true
+// lldb-command:print y
+// lldb-check:[...]$7 = 2220
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$8 = 203203.5
+// lldb-command:print y
+// lldb-check:[...]$9 = 2220
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$10 = 10.5
+// lldb-command:print y
+// lldb-check:[...]$11 = 20
+// lldb-command:continue
+
 fn main() {
     let x = false;
     let y = true;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     let x = 10i;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     let x = 10.5f64;
     let y = 20i;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     {
         let x = true;
         let y = 2220i;
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let x = 203203.5f64;
 
-        zzz();
+        zzz(); // #break
         sentinel();
     }
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index 43d82e75c4dda0e516d160ce0f040702fe46390f..511786999abf34404c3157af71aef0ccc2225ed4 100644 (file)
@@ -8,6 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// LLDB can't handle zero-sized values
+// ignore-lldb
+
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
index de6d6814308d8d6e0751a013909682690692ed9d..f9e2f61564bee93c00eea8a1f5f78c2b6a805ae7 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print full
 // gdb-check:$3 = {RUST$ENCODED$ENUM$1$Empty = {454545, 0x87654321, 9988}}
 
-// gdb-command:print empty->discr
+// gdb-command:print empty_gdb->discr
 // gdb-check:$4 = (int *) 0x0
 
 // gdb-command:print droid
 // gdb-check:$5 = {RUST$ENCODED$ENUM$2$Void = {id = 675675, range = 10000001, internals = 0x43218765}}
 
-// gdb-command:print void_droid->internals
+// gdb-command:print void_droid_gdb->internals
 // gdb-check:$6 = (int *) 0x0
 
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print some
+// lldb-check:[...]$0 = Some(&0x12345678)
+
+// lldb-command:print none
+// lldb-check:[...]$1 = None
+
+// lldb-command:print full
+// lldb-check:[...]$2 = Full(454545, &0x87654321, 9988)
+
+// lldb-command:print empty
+// lldb-check:[...]$3 = Empty
+
+// lldb-command:print droid
+// lldb-check:[...]$4 = Droid { id: 675675, range: 10000001, internals: &0x43218765 }
+
+// lldb-command:print void_droid
+// lldb-check:[...]$5 = Void
+
+
 #![feature(struct_variant)]
 
 // If a struct has exactly two variants, one of them is empty, and the other one
@@ -77,8 +104,8 @@ fn main() {
 
     let full = Full(454545, unsafe { std::mem::transmute(0x87654321u) }, 9988);
 
-    let int_val = 0i;
-    let empty: &MoreFieldsRepr = unsafe { std::mem::transmute(&Empty) };
+    let empty = Empty;
+    let empty_gdb: &MoreFieldsRepr = unsafe { std::mem::transmute(&Empty) };
 
     let droid = Droid {
         id: 675675,
@@ -86,9 +113,10 @@ fn main() {
         internals: unsafe { std::mem::transmute(0x43218765u) }
     };
 
-    let void_droid: &NamedFieldsRepr = unsafe { std::mem::transmute(&Void) };
+    let void_droid = Void;
+    let void_droid_gdb: &NamedFieldsRepr = unsafe { std::mem::transmute(&Void) };
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 29087b18d5a96be140fb0507a896bcf5f3aabfca..215d961b71b0eb132be35f85acdaf3cf7e3b5466 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print deeplyNested
 // gdb-check:$8 = {a = {a = 1, b = {x = 2, y = 3, z = 4}, c = 5, d = {x = 6, y = 7, z = 8}}, b = {a = 9, b = {x = 10, y = 11, z = 12}, c = {x = 13, y = 14, z = 15}, d = 16}, c = {a = 17, b = {x = 18, y = 19, z = 20}, c = 21, d = {x = 22, y = 23, z = 24}}, d = {a = 25, b = {x = 26, y = 27, z = 28}, c = 29, d = {x = 30, y = 31, z = 32}}, e = {a = 33, b = {x = 34, y = 35, z = 36}, c = {x = 37, y = 38, z = 39}, d = 40}, f = {a = 41, b = {x = 42, y = 43, z = 44}, c = 45, d = {x = 46, y = 47, z = 48}}}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print packed
+// lldb-check:[...]$0 = Packed { x: 123, y: 234, z: 345 }
+
+// lldb-command:print packedInPacked
+// lldb-check:[...]$1 = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } }
+
+// lldb-command:print packedInUnpacked
+// lldb-check:[...]$2 = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } }
+
+// lldb-command:print unpackedInPacked
+// lldb-check:[...]$3 = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654 }, c: Unpacked { x: 543, y: 432, z: 321 }, d: 210 }
+
+// lldb-command:print packedInPackedWithDrop
+// lldb-check:[...]$4 = PackedInPackedWithDrop { a: 11, b: Packed { x: 22, y: 33, z: 44 }, c: 55, d: Packed { x: 66, y: 77, z: 88 } }
+
+// lldb-command:print packedInUnpackedWithDrop
+// lldb-check:[...]$5 = PackedInUnpackedWithDrop { a: -11, b: Packed { x: -22, y: -33, z: -44 }, c: -55, d: Packed { x: -66, y: -77, z: -88 } }
+
+// lldb-command:print unpackedInPackedWithDrop
+// lldb-check:[...]$6 = UnpackedInPackedWithDrop { a: 98, b: Unpacked { x: 87, y: 76, z: 65 }, c: Unpacked { x: 54, y: 43, z: 32 }, d: 21 }
+
+// lldb-command:print deeplyNested
+// lldb-check:[...]$7 = DeeplyNested { a: PackedInPacked { a: 1, b: Packed { x: 2, y: 3, z: 4 }, c: 5, d: Packed { x: 6, y: 7, z: 8 } }, b: UnpackedInPackedWithDrop { a: 9, b: Unpacked { x: 10, y: 11, z: 12 }, c: Unpacked { x: 13, y: 14, z: 15 }, d: 16 }, c: PackedInUnpacked { a: 17, b: Packed { x: 18, y: 19, z: 20 }, c: 21, d: Packed { x: 22, y: 23, z: 24 } }, d: PackedInUnpackedWithDrop { a: 25, b: Packed { x: 26, y: 27, z: 28 }, c: 29, d: Packed { x: 30, y: 31, z: 32 } }, e: UnpackedInPacked { a: 33, b: Unpacked { x: 34, y: 35, z: 36 }, c: Unpacked { x: 37, y: 38, z: 39 }, d: 40 }, f: PackedInPackedWithDrop { a: 41, b: Packed { x: 42, y: 43, z: 44 }, c: 45, d: Packed { x: 46, y: 47, z: 48 } } }
+
+
 #![allow(unused_variable)]
 
 #[packed]
@@ -216,7 +249,7 @@ fn main() {
         }
     };
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index bc8156c73853c62f0087c1e81ede353d88729edb..8201afe3a016463229a8dafc705c19db8ed8921c 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print sizeof(packedInPacked)
 // gdb-check:$6 = 40
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print packed
+// lldb-check:[...]$0 = Packed { x: 123, y: 234, z: 345 }
+
+// lldb-command:print packedInPacked
+// lldb-check:[...]$1 = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } }
+
+// lldb-command:print packedInUnpacked
+// lldb-check:[...]$2 = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } }
+
+// lldb-command:print unpackedInPacked
+// lldb-check:[...]$3 = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654, w: 543 }, c: Unpacked { x: 432, y: 321, z: 210, w: 109 }, d: -98 }
+
+// lldb-command:print sizeof(packed)
+// lldb-check:[...]$4 = 14
+
+// lldb-command:print sizeof(packedInPacked)
+// lldb-check:[...]$5 = 40
+
 #![allow(unused_variable)]
 
 #[packed]
@@ -101,7 +127,7 @@ fn main() {
         d: -98
     };
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 68b6764a5a1501d1e54dd5da2a874f4316450d5a..4eb251c60841a8ebc8e8d998a46f75ff80bc9937 100644 (file)
@@ -10,6 +10,8 @@
 
 // ignore-android: FIXME(#10381)
 
+// ignore-lldb
+
 // compile-flags:-g
 // gdb-command:run
 
index ea0867903b5af3fbef0d4c970aca5e090997364c..931955ec31738b699efc17e70b6fe84e432db3f2 100644 (file)
@@ -10,6 +10,7 @@
 
 // ignore-tidy-linelength
 // ignore-android: FIXME(#10381)
+// ignore-lldb
 
 #![feature(managed_boxes)]
 
index 45cbcf094f4f5ea10b2148089c29c92369600644..4268c0adcc396f6408b976ab139c88009c10161f 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$15 = -10
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// STACK BY REF
+// lldb-command:print *self
+// lldb-check:[...]$0 = Struct { x: 100 }
+// lldb-command:print arg1
+// lldb-check:[...]$1 = -1
+// lldb-command:print arg2
+// lldb-check:[...]$2 = -2
+// lldb-command:continue
+
+// STACK BY VAL
+// lldb-command:print self
+// lldb-check:[...]$3 = Struct { x: 100 }
+// lldb-command:print arg1
+// lldb-check:[...]$4 = -3
+// lldb-command:print arg2
+// lldb-check:[...]$5 = -4
+// lldb-command:continue
+
+// OWNED BY REF
+// lldb-command:print *self
+// lldb-check:[...]$6 = Struct { x: 200 }
+// lldb-command:print arg1
+// lldb-check:[...]$7 = -5
+// lldb-command:print arg2
+// lldb-check:[...]$8 = -6
+// lldb-command:continue
+
+// OWNED BY VAL
+// lldb-command:print self
+// lldb-check:[...]$9 = Struct { x: 200 }
+// lldb-command:print arg1
+// lldb-check:[...]$10 = -7
+// lldb-command:print arg2
+// lldb-check:[...]$11 = -8
+// lldb-command:continue
+
+// OWNED MOVED
+// lldb-command:print *self
+// lldb-check:[...]$12 = Struct { x: 200 }
+// lldb-command:print arg1
+// lldb-check:[...]$13 = -9
+// lldb-command:print arg2
+// lldb-check:[...]$14 = -10
+// lldb-command:continue
+
+
 struct Struct {
     x: int
 }
 
 trait Trait {
     fn self_by_ref(&self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         arg1 + arg2
     }
 
     fn self_by_val(self, arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         arg1 + arg2
     }
 
-    fn self_owned(~self, arg1: int, arg2: int) -> int {
-        zzz();
+    fn self_owned(self: Box<Self>, arg1: int, arg2: int) -> int {
+        zzz(); // #break
         arg1 + arg2
     }
 }
index 8ab3fd44203aaf5a3bf75e61b0ba3b1264cbefda..35f3dffa0b63748fe64c1e66d1353768e2385450 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
@@ -20,8 +23,8 @@
 // gdb-check:$1 = {x = 987}
 // gdb-command:print arg1
 // gdb-check:$2 = -1
-// gdb-command:print/d arg2
-// gdb-check:$3 = -2
+// gdb-command:print arg2
+// gdb-check:$3 = 2
 // gdb-command:continue
 
 // STACK BY VAL
 // gdb-check:$15 = -10.5
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// STACK BY REF
+// lldb-command:print *self
+// lldb-check:[...]$0 = Struct { x: 987 }
+// lldb-command:print arg1
+// lldb-check:[...]$1 = -1
+// lldb-command:print arg2
+// lldb-check:[...]$2 = 2
+// lldb-command:continue
+
+// STACK BY VAL
+// lldb-command:print self
+// lldb-check:[...]$3 = Struct { x: 987 }
+// lldb-command:print arg1
+// lldb-check:[...]$4 = -3
+// lldb-command:print arg2
+// lldb-check:[...]$5 = -4
+// lldb-command:continue
+
+// OWNED BY REF
+// lldb-command:print *self
+// lldb-check:[...]$6 = Struct { x: 879 }
+// lldb-command:print arg1
+// lldb-check:[...]$7 = -5
+// lldb-command:print arg2
+// lldb-check:[...]$8 = -6
+// lldb-command:continue
+
+// OWNED BY VAL
+// lldb-command:print self
+// lldb-check:[...]$9 = Struct { x: 879 }
+// lldb-command:print arg1
+// lldb-check:[...]$10 = -7
+// lldb-command:print arg2
+// lldb-check:[...]$11 = -8
+// lldb-command:continue
+
+// OWNED MOVED
+// lldb-command:print *self
+// lldb-check:[...]$12 = Struct { x: 879 }
+// lldb-command:print arg1
+// lldb-check:[...]$13 = -9
+// lldb-command:print arg2
+// lldb-check:[...]$14 = -10.5
+// lldb-command:continue
+
+
 struct Struct {
     x: int
 }
@@ -71,17 +125,17 @@ struct Struct {
 trait Trait {
 
     fn self_by_ref<T>(&self, arg1: int, arg2: T) -> int {
-        zzz();
+        zzz(); // #break
         arg1
     }
 
     fn self_by_val<T>(self, arg1: int, arg2: T) -> int {
-        zzz();
+        zzz(); // #break
         arg1
     }
 
-    fn self_owned<T>(~self, arg1: int, arg2: T) -> int {
-        zzz();
+    fn self_owned<T>(self: Box<Self>, arg1: int, arg2: T) -> int {
+        zzz(); // #break
         arg1
     }
 }
@@ -90,7 +144,7 @@ impl Trait for Struct {}
 
 fn main() {
     let stack = Struct { x: 987 };
-    let _ = stack.self_by_ref(-1, -2_i8);
+    let _ = stack.self_by_ref(-1, 2_u16);
     let _ = stack.self_by_val(-3, -4_i16);
 
     let owned = box Struct { x: 879 };
index c180d6b5bcfe7c5eadfb7af99544eb5d6bd80534..7a9c7c3b372f4f549a24caf2400cdf74a7abcdba 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$6 = 20
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print x
+// lldb-check:[...]$0 = false
+// lldb-command:print y
+// lldb-check:[...]$1 = true
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$2 = 10
+// lldb-command:print y
+// lldb-check:[...]$3 = true
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$4 = 10.5
+// lldb-command:print y
+// lldb-check:[...]$5 = 20
+// lldb-command:continue
+
 fn a_function(x: bool, y: bool) {
-    zzz();
+    zzz(); // #break
     sentinel();
 
     let x = 10i;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     let x = 10.5f64;
     let y = 20i;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index 88ef3c4879e90d41eafe019100e0987b0cd1945a..a43bb5e4017309bb28c01d27306320d48e90e851 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$6 = 20
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print x
+// lldb-check:[...]$0 = false
+// lldb-command:print y
+// lldb-check:[...]$1 = true
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$2 = 10
+// lldb-command:print y
+// lldb-check:[...]$3 = true
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$4 = 10.5
+// lldb-command:print y
+// lldb-check:[...]$5 = 20
+// lldb-command:continue
+
 fn main() {
     let x = false;
     let y = true;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     let x = 10i;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     let x = 10.5f64;
     let y = 20i;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index b84405ee7270e76271bd289cb26dfc27cedd923c..eee1d0e70ca5fd693c488f6d45e4321c0e2fd38c 100644 (file)
@@ -8,6 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// Need a fix for LLDB first...
+// ignore-lldb
+
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
index 107b64131e053d577b0e5a21ab81ae0414c7ea08..a012ee265d4a90661e79ab97e64a4befa7da94be 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-command:continue
 
 
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print x
+// lldb-check:[...]$0 = false
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$1 = false
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$2 = 10
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$3 = 10
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$4 = 10.5
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$5 = 10
+// lldb-command:continue
+
+// lldb-command:print x
+// lldb-check:[...]$6 = false
+// lldb-command:continue
+
 fn main() {
     let x = false;
 
-    zzz();
+    zzz(); // #break
     sentinel();
 
     {
-        zzz();
+        zzz(); // #break
         sentinel();
 
         let x = 10i;
 
-        zzz();
+        zzz(); // #break
         sentinel();
 
         {
-            zzz();
+            zzz(); // #break
             sentinel();
 
             let x = 10.5f64;
 
-            zzz();
+            zzz(); // #break
             sentinel();
         }
 
-        zzz();
+        zzz(); // #break
         sentinel();
     }
 
-    zzz();
+    zzz(); // #break
     sentinel();
 }
 
index c1f0e2c1f9ea78925f22d2d7a92e8534c6c8bb16..5076673c3a512c897fae9608400927eb858253e7 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 
 // gdb-check:$19 = {a = 10019, b = -10020, x = -10016, y = -10017.5, z = 10018}
 
 
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print no_padding16
+// lldb-check:[...]$0 = NoPadding16 { x: 10000, y: -10001 }
+
+// lldb-command:print no_padding32
+// lldb-check:[...]$1 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 }
+
+// lldb-command:print no_padding64
+// lldb-check:[...]$2 = NoPadding64 { x: -10005.5, y: 10006, z: 10007 }
+
+// lldb-command:print no_padding163264
+// lldb-check:[...]$3 = NoPadding163264 { a: -10008, b: 10009, c: 10010, d: 10011 }
+
+// lldb-command:print internal_padding
+// lldb-check:[...]$4 = InternalPadding { x: 10012, y: -10013 }
+
+// lldb-command:print padding_at_end
+// lldb-check:[...]$5 = PaddingAtEnd { x: -10014, y: 10015 }
+
 #![feature(struct_inherit)];
 #![allow(unused_variable)];
 #![allow(dead_code)];
@@ -188,7 +213,7 @@ fn main() {
         PADDING_AT_END.y = 28;
     }
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 9486ab2474eff07d81611bd69d097b564ee69f38..29d739d7f183abce044f55edc83ef0ea726fb676 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 
 // gdb-command:print 'simple-tuple::PADDING_AT_END'
 // gdb-check:$21 = {116, 117}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print/d noPadding8
+// lldb-check:[...]$0 = (-100, 100)
+// lldb-command:print noPadding16
+// lldb-check:[...]$1 = (0, 1, 2)
+// lldb-command:print noPadding32
+// lldb-check:[...]$2 = (3, 4.5, 5)
+// lldb-command:print noPadding64
+// lldb-check:[...]$3 = (6, 7.5, 8)
+
+// lldb-command:print internalPadding1
+// lldb-check:[...]$4 = (9, 10)
+// lldb-command:print internalPadding2
+// lldb-check:[...]$5 = (11, 12, 13, 14)
+
+// lldb-command:print paddingAtEnd
+// lldb-check:[...]$6 = (15, 16)
+
 #![allow(unused_variable)]
 #![allow(dead_code)]
 
@@ -107,7 +132,7 @@ fn main() {
         PADDING_AT_END = (116, 117);
     }
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index d7d962c07d6ded530ebc93efdbffab04b27338b0..e5f9651bb8bcf1b294b60837b42358cc7b3ac5a1 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-check:$5 = 5
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// STRUCT
+// lldb-command:print arg1
+// lldb-check:[...]$0 = 1
+// lldb-command:print arg2
+// lldb-check:[...]$1 = 2
+// lldb-command:continue
+
+// ENUM
+// lldb-command:print arg1
+// lldb-check:[...]$2 = -3
+// lldb-command:print arg2
+// lldb-check:[...]$3 = 4.5
+// lldb-command:print arg3
+// lldb-check:[...]$4 = 5
+// lldb-command:continue
+
 #![feature(struct_variant)]
 
 struct Struct {
@@ -41,7 +65,7 @@ struct Struct {
 impl Struct {
 
     fn static_method(arg1: int, arg2: int) -> int {
-        zzz();
+        zzz(); // #break
         arg1 + arg2
     }
 }
@@ -55,7 +79,7 @@ enum Enum {
 impl Enum {
 
     fn static_method(arg1: int, arg2: f64, arg3: uint) -> int {
-        zzz();
+        zzz(); // #break
         arg1
     }
 }
index 0cba56ad320ec834ce77cda38252487f0823a26c..d01119bce05338ce3c618c8d8feddd3f8259b671 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print union on
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print univariant
 // gdb-check:$3 = {{{x = 123, y = 456, z = 789}}}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print case1
+// lldb-check:[...]$0 = Case1(0, Struct { x: 2088533116, y: 2088533116, z: 31868 })
+// lldb-command:print case2
+// lldb-check:[...]$1 = Case2(0, 1229782938247303441, 4369)
+
+// lldb-command:print univariant
+// lldb-check:[...]$2 = TheOnlyCase(Struct { x: 123, y: 456, z: 789 })
+
 #![allow(unused_variable)]
 
 struct Struct {
@@ -66,7 +82,7 @@ fn main() {
 
     let univariant = TheOnlyCase(Struct { x: 123, y: 456, z: 789 });
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index e4c3f471880dfd78122731308aec5fbf2a5951df..3822b80e8650feac36b189a33cc7019f9b1a10ca 100644 (file)
@@ -8,9 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-tidy-linelength
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print padding_at_end_parent
 // gdb-check:$3 = {x = {x = 10, y = 11}, y = {x = 12, y = 13}, z = {x = 14, y = 15}}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print three_simple_structs
+// lldb-check:[...]$0 = ThreeSimpleStructs { x: Simple { x: 1 }, y: Simple { x: 2 }, z: Simple { x: 3 } }
+
+// lldb-command:print internal_padding_parent
+// lldb-check:[...]$1 = InternalPaddingParent { x: InternalPadding { x: 4, y: 5 }, y: InternalPadding { x: 6, y: 7 }, z: InternalPadding { x: 8, y: 9 } }
+
+// lldb-command:print padding_at_end_parent
+// lldb-check:[...]$2 = PaddingAtEndParent { x: PaddingAtEnd { x: 10, y: 11 }, y: PaddingAtEnd { x: 12, y: 13 }, z: PaddingAtEnd { x: 14, y: 15 } }
+
+// lldb-command:print mixed
+// lldb-check:[...]$3 = Mixed { x: PaddingAtEnd { x: 16, y: 17 }, y: InternalPadding { x: 18, y: 19 }, z: Simple { x: 20 }, w: 21 }
+
+// lldb-command:print bag
+// lldb-check:[...]$4 = Bag { x: Simple { x: 22 } }
+
+// lldb-command:print bag_in_bag
+// lldb-check:[...]$5 = BagInBag { x: Bag { x: Simple { x: 23 } } }
+
+// lldb-command:print tjo
+// lldb-check:[...]$6 = ThatsJustOverkill { x: BagInBag { x: Bag { x: Simple { x: 24 } } } }
+
+// lldb-command:print tree
+// lldb-check:[...]$7 = Tree { x: Simple { x: 25 }, y: InternalPaddingParent { x: InternalPadding { x: 26, y: 27 }, y: InternalPadding { x: 28, y: 29 }, z: InternalPadding { x: 30, y: 31 } }, z: BagInBag { x: Bag { x: Simple { x: 32 } } } }
+
 #![allow(unused_variable)]
 
 struct Simple {
@@ -140,7 +173,7 @@ fn main() {
         }
     };
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 70d4d709d23c81547ad410057f09d40027a8866e..c3a5abf2d389a67e25c5b431938c885d2a7e5fe0 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print union on
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print univariant
 // gdb-check:$4 = {{a = -1}}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print case1
+// lldb-check:[...]$0 = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 }
+
+// lldb-command:print case2
+// lldb-check:[...]$1 = Case2 { a: 0, b: 286331153, c: 286331153 }
+
+// lldb-command:print case3
+// lldb-check:[...]$2 = Case3 { a: 0, b: 6438275382588823897 }
+
+// lldb-command:print univariant
+// lldb-check:[...]$3 = TheOnlyCase { a: -1 }
+
 #![allow(unused_variable)]
 #![feature(struct_variant)]
 
@@ -71,7 +91,7 @@ fn main() {
 
     let univariant = TheOnlyCase { a: -1 };
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 16fbfc49d08ed625b8abe4be6fcb1b96683a4087..525fcd45cfb06cbeed3d2c53be09f0aa20651c74 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print nested
 // gdb-check:$4 = {a = {a = {x = 7890, y = 9870}}}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+// lldb-command:print simple
+// lldb-check:[...]$0 = WithDestructor { x: 10, y: 20 }
+
+// lldb-command:print noDestructor
+// lldb-check:[...]$1 = NoDestructorGuarded { a: NoDestructor { x: 10, y: 20 }, guard: -1 }
+
+// lldb-command:print withDestructor
+// lldb-check:[...]$2 = WithDestructorGuarded { a: WithDestructor { x: 10, y: 20 }, guard: -1 }
+
+// lldb-command:print nested
+// lldb-check:[...]$3 = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } }
+
 #![allow(unused_variable)]
 
 struct NoDestructor {
@@ -121,7 +140,7 @@ fn main() {
     //                            <-------NestedOuter-------->
     let nested = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } };
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 91e2445c4aa9d12d6d7ed9cd2aef088c97c8f498..ba055272a3fa78f94978f2d0818bb777616cdab8 100644 (file)
@@ -1 +1 @@
-some text to include in another file as string 1
+some text to include in another file as string 1
\ No newline at end of file
index be6022776c52160438438cc980ce31b0792d814d..a59d2057eb46b013c86bcda3feec70488790abf1 100644 (file)
@@ -1 +1 @@
-some text to include in another file as string 2
+some text to include in another file as string 2.
\ No newline at end of file
index 0cff667b47ca029a82df1676ad167d8cc7b0b197..6163f7dd48cd496a445ee85a703fb328eb6d9d79 100644 (file)
@@ -1 +1 @@
-some text to include in another file as string 3
+some text to include in another file as string 3..
\ No newline at end of file
index e91cd2f02d4888b5e800de6bb2d1a5f894010d5c..20747681b6ffaf39fb927bb66d536dbc423a6a4c 100644 (file)
@@ -11,6 +11,9 @@
 // except according to those terms.
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 
 // gdb-command:continue
 
 
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print no_padding1
+// lldb-check:[...]$0 = { x = (0, 1) y = 2 z = (3, 4, 5) }
+// lldb-command:print no_padding2
+// lldb-check:[...]$1 = { x = (6, 7) y = { = (8, 9) = 10 } }
+
+// lldb-command:print tuple_internal_padding
+// lldb-check:[...]$2 = { x = (11, 12) y = (13, 14) }
+// lldb-command:print struct_internal_padding
+// lldb-check:[...]$3 = { x = (15, 16) y = (17, 18) }
+// lldb-command:print both_internally_padded
+// lldb-check:[...]$4 = { x = (19, 20, 21) y = (22, 23) }
+
+// lldb-command:print single_tuple
+// lldb-check:[...]$5 = { x = (24, 25, 26) }
+
+// lldb-command:print tuple_padded_at_end
+// lldb-check:[...]$6 = { x = (27, 28) y = (29, 30) }
+// lldb-command:print struct_padded_at_end
+// lldb-check:[...]$7 = { x = (31, 32) y = (33, 34) }
+// lldb-command:print both_padded_at_end
+// lldb-check:[...]$8 = { x = (35, 36, 37) y = (38, 39) }
+
+// lldb-command:print mixed_padding
+// lldb-check:[...]$9 = { x = { = (40, 41, 42) = (43, 44) } y = (45, 46, 47, 48) }
+
 struct Struct {
     x: int
 }
 
 trait Trait {
     fn generic_static_default_method<T>(arg1: int, arg2: T) -> int {
-        zzz();
+        zzz(); // #break
         arg1
     }
 }
index e58ed4cea29a78c5999154c22326d3ab24f02e70..ca407aef1a45e8bd4cd67cfe040da74124c29037 100644 (file)
@@ -10,6 +10,8 @@
 
 // ignore-android: FIXME(#10381)
 
+// ignore-lldb
+
 // compile-flags:-g
 // gdb-command:run
 
index 3cc8b4e6486d6e7553c1801e06fa5483f335b1d5..4c4ad51c70bb026e5ff9b66082ff540ce9eccb97 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print padding_at_end2
 // gdb-check:$7 = {{21, 22}, 23}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print no_padding1
+// lldb-check:[...]$0 = ((0, 1), 2, 3)
+// lldb-command:print no_padding2
+// lldb-check:[...]$1 = (4, (5, 6), 7)
+// lldb-command:print no_padding3
+// lldb-check:[...]$2 = (8, 9, (10, 11))
+
+// lldb-command:print internal_padding1
+// lldb-check:[...]$3 = (12, (13, 14))
+// lldb-command:print internal_padding2
+// lldb-check:[...]$4 = (15, (16, 17))
+
+// lldb-command:print padding_at_end1
+// lldb-check:[...]$5 = (18, (19, 20))
+// lldb-command:print padding_at_end2
+// lldb-check:[...]$6 = ((21, 22), 23)
+
 #![allow(unused_variable)]
 
 fn main() {
@@ -46,7 +71,7 @@ fn main() {
     let padding_at_end1: (i32, (i32, i16)) = (18, (19, 20));
     let padding_at_end2: ((i32, i16), i32) = ((21, 22), 23);
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index cea063820b86754f7b11b07ee8a08919fb27d891..afcacd46e6653a258d2b9e59328293378957a89e 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-check:$6 = {-10014, 10015}
 
 
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print no_padding16
+// lldb-check:[...]$0 = NoPadding16(10000, -10001)
+
+// lldb-command:print no_padding32
+// lldb-check:[...]$1 = NoPadding32(-10002, -10003.5, 10004)
+
+// lldb-command:print no_padding64
+// lldb-check:[...]$2 = NoPadding64(-10005.5, 10006, 10007)
+
+// lldb-command:print no_padding163264
+// lldb-check:[...]$3 = NoPadding163264(-10008, 10009, 10010, 10011)
+
+// lldb-command:print internal_padding
+// lldb-check:[...]$4 = InternalPadding(10012, -10013)
+
+// lldb-command:print padding_at_end
+// lldb-check:[...]$5 = PaddingAtEnd(-10014, 10015)
+
 // This test case mainly makes sure that no field names are generated for tuple structs (as opposed
 // to all fields having the name "<unnamed_field>"). Otherwise they are handled the same a normal
 // structs.
@@ -55,7 +80,7 @@ fn main() {
     let internal_padding = InternalPadding(10012, -10013);
     let padding_at_end = PaddingAtEnd(-10014, 10015);
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 81c72d16886439bc468288a3087ff198286a8ffe..7cd0a8f6164e8102816c3951a09dd3feb99a386f 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print union on
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print univariant
 // gdb-check:$4 = {{-1}}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print case1
+// lldb-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868)
+
+// lldb-command:print case2
+// lldb-check:[...]$1 = Case2(0, 286331153, 286331153)
+
+// lldb-command:print case3
+// lldb-check:[...]$2 = Case3(0, 6438275382588823897)
+
+// lldb-command:print univariant
+// lldb-check:[...]$3 = TheOnlyCase(-1)
+
 #![allow(unused_variable)]
 
 // The first element is to ensure proper alignment, irrespective of the machines word size. Since
@@ -70,7 +90,7 @@ fn main() {
 
     let univariant = TheOnlyCase(-1);
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 3949a315adca2b79783cca5175e6f8ec672f06f5..4c945e62abcd8cb057b1848c57d968d446c484c8 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print *univariant
 // gdb-check:$3 = {{123234}}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print *the_a
+// lldb-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
+
+// lldb-command:print *the_b
+// lldb-check:[...]$1 = TheB(0, 286331153, 286331153)
+
+// lldb-command:print *univariant
+// lldb-check:[...]$2 = TheOnlyCase(123234)
+
 #![allow(unused_variable)]
 #![feature(struct_variant)]
 
@@ -60,7 +77,7 @@ fn main() {
 
     let univariant = box TheOnlyCase(123234);
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 3328b11228441ee31a5e66ea7218bb850d6e338c..b538fcd7d76b83a858c03378485ada6e62db6c67 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-check:$14 = 8
 // gdb-command:continue
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print variable
+// lldb-check:[...]$0 = 1
+// lldb-command:print constant
+// lldb-check:[...]$1 = 2
+// lldb-command:print a_struct
+// lldb-check:[...]$2 = Struct { a: -3, b: 4.5, c: 5 }
+// lldb-command:print *struct_ref
+// lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 }
+// lldb-command:print *owned
+// lldb-check:[...]$4 = 6
+// lldb-command:print managed->val
+// lldb-check:[...]$5 = 7
+// lldb-command:print closure_local
+// lldb-check:[...]$6 = 8
+// lldb-command:continue
+
+// lldb-command:print variable
+// lldb-check:[...]$7 = 1
+// lldb-command:print constant
+// lldb-check:[...]$8 = 2
+// lldb-command:print a_struct
+// lldb-check:[...]$9 = Struct { a: -3, b: 4.5, c: 5 }
+// lldb-command:print *struct_ref
+// lldb-check:[...]$10 = Struct { a: -3, b: 4.5, c: 5 }
+// lldb-command:print *owned
+// lldb-check:[...]$11 = 6
+// lldb-command:print managed->val
+// lldb-check:[...]$12 = 7
+// lldb-command:print closure_local
+// lldb-check:[...]$13 = 8
+// lldb-command:continue
+
 #![feature(managed_boxes)]
 #![allow(unused_variable)]
 
@@ -77,11 +117,11 @@ fn main() {
         let closure_local = 8;
 
         let nested_closure = || {
-            zzz();
+            zzz(); // #break
             variable = constant + a_struct.a + struct_ref.a + *owned + *managed + closure_local;
         };
 
-        zzz();
+        zzz(); // #break
 
         nested_closure();
     };
index 03525a3a034dc1b1f0c397a31538f310f3c70232..cd100415cbec6bc753983261ae900b6ae3ce3e6d 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print *owned
 // gdb-check:$3 = 5
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print constant
+// lldb-check:[...]$0 = 1
+// lldb-command:print a_struct
+// lldb-check:[...]$1 = Struct { a: -2, b: 3.5, c: 4 }
+// lldb-command:print *owned
+// lldb-check:[...]$2 = 5
+
 #![allow(unused_variable)]
 
 struct Struct {
@@ -42,7 +57,7 @@ fn main() {
     let owned = box 5;
 
     let closure: proc() = proc() {
-        zzz();
+        zzz(); // #break
         do_something(&constant, &a_struct.a, owned);
     };
 
index 453ac35463178429672c193d982f4c5febc73b7a..3fe17dc83e76591839d55b00b18b49ba99f7a3d7 100644 (file)
@@ -11,6 +11,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:finish
 // gdb-command:print managed->val
 // gdb-check:$6 = 7
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print variable
+// lldb-check:[...]$0 = 1
+// lldb-command:print constant
+// lldb-check:[...]$1 = 2
+// lldb-command:print a_struct
+// lldb-check:[...]$2 = Struct { a: -3, b: 4.5, c: 5 }
+// lldb-command:print *struct_ref
+// lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 }
+// lldb-command:print *owned
+// lldb-check:[...]$4 = 6
+// lldb-command:print managed->val
+// lldb-check:[...]$5 = 7
+
 #![feature(managed_boxes)]
 #![allow(unused_variable)]
 
@@ -54,7 +75,7 @@ fn main() {
     let managed = box(GC) 7;
 
     let closure = || {
-        zzz();
+        zzz(); // #break
         variable = constant + a_struct.a + struct_ref.a + *owned + *managed;
     };
 
index 783b198395339b2fc916defa8abf50f538ad8eb7..00398fd5c8234fbb2d059c3eee3361643b554454 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print *((int64_t[2]*)('vec-slices::MUT_VECT_SLICE'.data_ptr))
 // gdb-check:$15 = {64, 65}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print empty
+// lldb-check:[...]$0 = &[]
+
+// lldb-command:print singleton
+// lldb-check:[...]$1 = &[1]
+
+// lldb-command:print multiple
+// lldb-check:[...]$2 = &[2, 3, 4, 5]
+
+// lldb-command:print slice_of_slice
+// lldb-check:[...]$3 = &[3, 4]
+
+// lldb-command:print padded_tuple
+// lldb-check:[...]$4 = &[(6, 7), (8, 9)]
+
+// lldb-command:print padded_struct
+// lldb-check:[...]$5 = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }]
+
 #![allow(unused_variable)]
 
 struct AStruct {
@@ -81,7 +107,7 @@ fn main() {
         MUT_VECT_SLICE = VECT_SLICE;
     }
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index 155865f415b6398aab09a1f6557108892a66961c..7372a6e7ca019bc6e27bc424e7850f4dac134c9a 100644 (file)
@@ -12,6 +12,9 @@
 // ignore-android: FIXME(#10381)
 
 // compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
 // gdb-command:set print pretty off
 // gdb-command:rbreak zzz
 // gdb-command:run
 // gdb-command:print vec::VECT
 // gdb-check:$2 = {4, 5, 6}
 
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+// lldb-command:print a
+// lldb-check:[...]$0 = [1, 2, 3]
+
 #![allow(unused_variable)]
 
 static mut VECT: [i32, ..3] = [1, 2, 3];
@@ -34,7 +44,7 @@ fn main() {
         VECT[2] = 6;
     }
 
-    zzz();
+    zzz(); // #break
 }
 
 fn zzz() {()}
index e50825a401fc6da83d1173962c879b63bc0b9aa9..f13f598fda28c26032f3bf7bc96574e77392fb48 100644 (file)
 
 
 trait double {
-    fn double(~self) -> uint;
+    fn double(self: Box<Self>) -> uint;
 }
 
 impl double for uint {
-    fn double(~self) -> uint { *self * 2u }
+    fn double(self: Box<uint>) -> uint { *self * 2u }
 }
 
 pub fn main() {
index 7acd54788a8c2d0016072e9ae43373a41932058f..856ee686db30e89c988c547aa97b6d6b5197ed7b 100644 (file)
 
 
 trait double {
-    fn double(~self) -> uint;
+    fn double(self: Box<Self>) -> uint;
 }
 
 impl double for Box<uint> {
-    fn double(~self) -> uint { **self * 2u }
+    fn double(self: Box<Box<uint>>) -> uint { **self * 2u }
 }
 
 pub fn main() {
index a8b6b6f74f4ff7dc3d8ec088e65c57d97daaca1d..94da61483eaaecf1f58f57996f2491c8b97a13ca 100644 (file)
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 trait double {
-    fn double(~self) -> uint;
+    fn double(self: Box<Self>) -> uint;
 }
 
 impl double for uint {
-    fn double(~self) -> uint { *self * 2u }
+    fn double(self: Box<uint>) -> uint { *self * 2u }
 }
 
 pub fn main() {
index 4c4ebdc94f030232f0c7d40de09b7fb0718d8c0b..2e9751ce6acfccd405f527709718962891cf0898 100644 (file)
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 trait double {
-    fn double(~self) -> uint;
+    fn double(self: Box<Self>) -> uint;
 }
 
 impl double for uint {
-    fn double(~self) -> uint { *self * 2u }
+    fn double(self: Box<uint>) -> uint { *self * 2u }
 }
 
 pub fn main() {
index 595bb4f6b9e442b48bcfb2b97bbc85c27669056d..e566f218aa8f61b02486073e7774071f545be693 100644 (file)
@@ -10,7 +10,7 @@
 
 
 trait Foo {
-    fn f(~self);
+    fn f(self: Box<Self>);
 }
 
 struct S {
@@ -18,7 +18,7 @@ struct S {
 }
 
 impl Foo for S {
-    fn f(~self) {
+    fn f(self: Box<S>) {
         assert_eq!(self.x, 3);
     }
 }
index 6c2e17046d3c17498a02fa99d7ad000d782e7c77..32ac14ab18074ccdce1e5ae26191203bf5693874 100644 (file)
@@ -57,7 +57,7 @@ fn thing(x: A) -> thing {
 }
 
 impl thing {
-    pub fn bar(~self) -> int { self.x.a }
+    pub fn bar(self: Box<thing>) -> int { self.x.a }
     pub fn quux(&self) -> int { self.x.a }
     pub fn baz<'a>(&'a self) -> &'a A { &self.x }
     pub fn spam(self) -> int { self.x.a }
index 99ed4288a7ec109bd6d7b06d89a4dd484c5c9880..c7087f8e3a8ca5982663b681e72850ff75d27f26 100644 (file)
@@ -10,7 +10,7 @@
 
 
 trait Foo {
-    fn foo(~self) { bar(self as Box<Foo>); }
+    fn foo(self: Box<Self>) { bar(self as Box<Foo>); }
 }
 
 fn bar(_b: Box<Foo>) { }
index 540593c43fbfd6b84f59381b6f4158cf28c6c81f..14ddc5d660f0cea9d71ab409c065643ce2aa3c2e 100644 (file)
@@ -14,7 +14,7 @@
 
 
 trait FooTrait {
-    fn foo(~self) -> uint;
+    fn foo(self: Box<Self>) -> uint;
 }
 
 struct BarStruct {
@@ -22,7 +22,7 @@ struct BarStruct {
 }
 
 impl FooTrait for BarStruct {
-    fn foo(~self) -> uint {
+    fn foo(self: Box<BarStruct>) -> uint {
         self.x
     }
 }
index 8ab27cfb4ee232d7f9c050dea488469d47084bf4..b4a46f34015a2455e78c0a27b74ff7e08d9550ea 100644 (file)
@@ -19,7 +19,7 @@ fn change(mut self) -> Self {
         self
     }
 
-    fn change_again(mut ~self) -> Box<Self> {
+    fn change_again(mut self: Box<Self>) -> Box<Self> {
         self.set_to(45);
         self
     }
diff --git a/src/test/run-pass/ufcs-explicit-self.rs b/src/test/run-pass/ufcs-explicit-self.rs
new file mode 100644 (file)
index 0000000..9ffb56c
--- /dev/null
@@ -0,0 +1,57 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::owned::Box;
+
+struct Foo {
+    f: int,
+}
+
+impl Foo {
+    fn foo(self: Foo, x: int) -> int {
+        self.f + x
+    }
+    fn bar(self: &Foo, x: int) -> int {
+        self.f + x
+    }
+    fn baz(self: Box<Foo>, x: int) -> int {
+        self.f + x
+    }
+}
+
+struct Bar<T> {
+    f: T,
+}
+
+impl<T> Bar<T> {
+    fn foo(self: Bar<T>, x: int) -> int {
+        x
+    }
+    fn bar<'a>(self: &'a Bar<T>, x: int) -> int {
+        x
+    }
+    fn baz(self: Bar<T>, x: int) -> int {
+        x
+    }
+}
+
+fn main() {
+    let foo = box Foo {
+        f: 1,
+    };
+    println!("{} {} {}", foo.foo(2), foo.bar(2), foo.baz(2));
+    let bar = box Bar {
+        f: 1,
+    };
+    println!("{} {} {}", bar.foo(2), bar.bar(2), bar.baz(2));
+    let bar: Box<Bar<int>> = bar;
+    println!("{} {} {}", bar.foo(2), bar.bar(2), bar.baz(2));
+}
+
index 3700e02051a699ef6299206c076c6ec273174007..4d7830e1cdca1ee70435b871410ca31d1cb1a7a0 100644 (file)
@@ -14,11 +14,11 @@ struct X {
 }
 
 trait Changer {
-    fn change(mut ~self) -> Box<Self>;
+    fn change(mut self: Box<Self>) -> Box<Self>;
 }
 
 impl Changer for X {
-    fn change(mut ~self) -> Box<X> {
+    fn change(mut self: Box<X>) -> Box<X> {
         self.a = 55;
         self
     }