]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #35592 - jonathandturner:rollup, r=jonathandturner
authorbors <bors@rust-lang.org>
Thu, 11 Aug 2016 20:14:28 +0000 (13:14 -0700)
committerGitHub <noreply@github.com>
Thu, 11 Aug 2016 20:14:28 +0000 (13:14 -0700)
Rollup of 23 pull requests

- Successful merges: #35279, #35331, #35358, #35375, #35445, #35448, #35482, #35486, #35505, #35528, #35530, #35532, #35536, #35537, #35541, #35552, #35554, #35555, #35557, #35562, #35565, #35569, #35576
- Failed merges: #35395, #35415, #35563

64 files changed:
.gitignore
src/libcollections/string.rs
src/libcore/macros.rs
src/libcore/result.rs
src/librustc/middle/effect.rs
src/librustc/middle/resolve_lifetime.rs
src/librustc/traits/error_reporting.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_const_eval/check_match.rs
src/librustc_mir/transform/qualify_consts.rs
src/librustc_passes/ast_validation.rs
src/librustc_resolve/lib.rs
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/intrinsic.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/collect.rs
src/librustc_typeck/lib.rs
src/libstd/ffi/c_str.rs
src/libstd/sys/unix/ext/net.rs
src/test/compile-fail/E0007.rs
src/test/compile-fail/E0008.rs
src/test/compile-fail/E0017.rs
src/test/compile-fail/E0038.rs
src/test/compile-fail/E0045.rs
src/test/compile-fail/E0072.rs
src/test/compile-fail/E0081.rs
src/test/compile-fail/E0091.rs
src/test/compile-fail/E0092.rs
src/test/compile-fail/E0128.rs
src/test/compile-fail/E0130.rs
src/test/compile-fail/E0133.rs
src/test/compile-fail/E0263.rs
src/test/compile-fail/asm-out-assign-imm.rs
src/test/compile-fail/assign-imm-local-twice.rs
src/test/compile-fail/associated-const-impl-wrong-type.rs
src/test/compile-fail/derived-errors/issue-31997-1.rs
src/test/compile-fail/issue-15524.rs
src/test/compile-fail/issue-18183.rs
src/test/compile-fail/issue-20692.rs
src/test/compile-fail/issue-26056.rs
src/test/compile-fail/issue-28776.rs
src/test/compile-fail/issue-3008-2.rs
src/test/compile-fail/issue-32326.rs
src/test/compile-fail/issue-3779.rs
src/test/compile-fail/liveness-assign-imm-local-in-loop.rs
src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs
src/test/compile-fail/liveness-assign-imm-local-with-init.rs
src/test/compile-fail/no-patterns-in-args.rs
src/test/compile-fail/object-safety-generics.rs
src/test/compile-fail/object-safety-mentions-Self.rs
src/test/compile-fail/object-safety-sized.rs
src/test/compile-fail/object-safety-supertrait-mentions-Self.rs
src/test/compile-fail/trait-safety-fn-body.rs
src/test/compile-fail/type-recursive.rs
src/test/compile-fail/unsafe-const-fn.rs
src/test/run-pass/issue-29053.rs [new file with mode: 0644]
src/tools/compiletest/src/common.rs
src/tools/compiletest/src/errors.rs
src/tools/compiletest/src/header.rs
src/tools/compiletest/src/json.rs
src/tools/compiletest/src/procsrv.rs
src/tools/compiletest/src/raise_fd_limit.rs
src/tools/compiletest/src/uidiff.rs
src/tools/compiletest/src/util.rs

index 5e8c40d03fbeff96ea8c04fe9f9717056b285663..6de43f471d8860229cb72c236b260d9303de1553 100644 (file)
@@ -57,6 +57,7 @@ __pycache__/
 .project
 .settings/
 .valgrindrc
+.vscode/
 /*-*-*-*/
 /*-*-*/
 /Makefile
index 70b514afd035f1d17d446c0dbbee6f158b1eb950..c06bde6222ac8410fe9ad6ebdd0c4464da9c2059 100644 (file)
@@ -1180,7 +1180,7 @@ unsafe fn insert_bytes(&mut self, idx: usize, bytes: &[u8]) {
     #[inline]
     #[unstable(feature = "insert_str",
                reason = "recent addition",
-               issue = "0")]
+               issue = "35553")]
     pub fn insert_str(&mut self, idx: usize, string: &str) {
         let len = self.len();
         assert!(idx <= len);
index b0c79a3a88547b0551436df2d562bc4ea6d0c6d9..c916ad930ff105988b7be772c07b45a595f3aa25 100644 (file)
@@ -229,14 +229,28 @@ macro_rules! try {
     })
 }
 
-/// Use the `format!` syntax to write data into a buffer.
+/// Write formatted data into a buffer
 ///
-/// This macro is typically used with a buffer of `&mut `[`Write`][write].
+/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
+/// of arguments to format.
+///
+/// `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write] or
+/// [`std::io::Write`][io_write] traits. These are sometimes called 'writers'.
+///
+/// Passed arguments will be formatted according to the specified format string and the resulting
+/// string will be passed to the writer.
 ///
 /// See [`std::fmt`][fmt] for more information on format syntax.
 ///
+/// Return value is completely dependent on the 'write_fmt' method.
+///
+/// Common return values are: [`Result`][enum_result], [`io::Result`][type_result]
+///
 /// [fmt]: ../std/fmt/index.html
-/// [write]: ../std/io/trait.Write.html
+/// [fmt_write]: ../std/fmt/trait.Write.html
+/// [io_write]: ../std/io/trait.Write.html
+/// [enum_result]: ../std/result/enum.Result.html
+/// [type_result]: ../std/io/type.Result.html
 ///
 /// # Examples
 ///
@@ -255,16 +269,31 @@ macro_rules! write {
     ($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
 }
 
-/// Use the `format!` syntax to write data into a buffer, appending a newline.
-/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`)
-/// alone (no additional CARRIAGE RETURN (`\r`/`U+000D`).
+/// Write formatted data into a buffer, with appending a newline.
+///
+/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
+/// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
 ///
-/// This macro is typically used with a buffer of `&mut `[`Write`][write].
+/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
+/// of arguments to format.
+///
+/// `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write] or
+/// [`std::io::Write`][io_write] traits. These are sometimes called 'writers'.
+///
+/// Passed arguments will be formatted according to the specified format string and the resulting
+/// string will be passed to the writer.
 ///
 /// See [`std::fmt`][fmt] for more information on format syntax.
 ///
+/// Return value is completely dependent on the 'write_fmt' method.
+///
+/// Common return values are: [`Result`][enum_result], [`io::Result`][type_result]
+///
 /// [fmt]: ../std/fmt/index.html
-/// [write]: ../std/io/trait.Write.html
+/// [fmt_write]: ../std/fmt/trait.Write.html
+/// [io_write]: ../std/io/trait.Write.html
+/// [enum_result]: ../std/result/enum.Result.html
+/// [type_result]: ../std/io/type.Result.html
 ///
 /// # Examples
 ///
index 94c6c636ce8fce6469f374dbfdb730f60051ea3b..c7ca70fc1622d8ea2d811d5a81d2c54bd9104e5e 100644 (file)
@@ -402,8 +402,8 @@ pub fn as_ref(&self) -> Result<&T, &E> {
     /// ```
     /// fn mutate(r: &mut Result<i32, i32>) {
     ///     match r.as_mut() {
-    ///         Ok(&mut ref mut v) => *v = 42,
-    ///         Err(&mut ref mut e) => *e = 0,
+    ///         Ok(v) => *v = 42,
+    ///         Err(e) => *e = 0,
     ///     }
     /// }
     ///
index 446767ecbcaba1e1cb1daf08da4c0602b2826fff..3ca6cf039979705cc09477902e3912c270daf7d2 100644 (file)
@@ -63,9 +63,11 @@ fn require_unsafe(&mut self, span: Span, description: &str) {
         match self.unsafe_context.root {
             SafeContext => {
                 // Report an error.
-                span_err!(self.tcx.sess, span, E0133,
-                          "{} requires unsafe function or block",
-                          description);
+                struct_span_err!(
+                    self.tcx.sess, span, E0133,
+                    "{} requires unsafe function or block", description)
+                    .span_label(span, &format!("unsafe call requires unsafe function or block"))
+                    .emit();
             }
             UnsafeBlock(block_id) => {
                 // OK, but record this.
index 7f6614a959c894634e2d3898ed0a89c083863f97..aa74fb2e02fa0b77feb0243f86779a503e48d615 100644 (file)
@@ -718,10 +718,14 @@ fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &[hir::LifetimeDe
                 let lifetime_j = &lifetimes[j];
 
                 if lifetime_i.lifetime.name == lifetime_j.lifetime.name {
-                    span_err!(self.sess, lifetime_j.lifetime.span, E0263,
-                        "lifetime name `{}` declared twice in \
-                                the same scope",
-                                lifetime_j.lifetime.name);
+                    struct_span_err!(self.sess, lifetime_j.lifetime.span, E0263,
+                                     "lifetime name `{}` declared twice in the same scope",
+                                     lifetime_j.lifetime.name)
+                        .span_label(lifetime_j.lifetime.span,
+                                    &format!("declared twice"))
+                        .span_label(lifetime_i.lifetime.span,
+                                   &format!("previous declaration here"))
+                        .emit();
                 }
             }
 
index 9950560b13a5a7cda70ccd0d38ccc2fedf6a6c46..62a31133a5499b33a21ba1898a01e9d0cfde226d 100644 (file)
@@ -654,6 +654,7 @@ pub fn recursive_type_with_infinite_size_error(self,
         let mut err = struct_span_err!(self.sess, span, E0072,
                                        "recursive type `{}` has infinite size",
                                        self.item_path_str(type_def_id));
+        err.span_label(span, &format!("recursive type has infinite size"));
         err.help(&format!("insert indirection (e.g., a `Box`, `Rc`, or `&`) \
                            at some point to make `{}` representable",
                           self.item_path_str(type_def_id)));
@@ -670,10 +671,15 @@ pub fn report_object_safety_error(self,
         let mut err = match warning_node_id {
             Some(_) => None,
             None => {
-                Some(struct_span_err!(
-                    self.sess, span, E0038,
-                    "the trait `{}` cannot be made into an object",
-                    self.item_path_str(trait_def_id)))
+                let trait_str = self.item_path_str(trait_def_id);
+                let mut db = struct_span_err!(
+                            self.sess, span, E0038,
+                            "the trait `{}` cannot be made into an object",
+                            trait_str);
+                db.span_label(span,
+                              &format!("the trait `{}` cannot be made \
+                              into an object", trait_str));
+                Some(db)
             }
         };
 
index 904cffac6b3cd88e06b21391382e9f198f3a22b1..e0cbd972bd37f9f3c62fc9d65e26b18bb47915af 100644 (file)
@@ -760,12 +760,16 @@ pub fn report_reassigned_immutable_variable(&self,
                                                 lp: &LoanPath<'tcx>,
                                                 assign:
                                                 &move_data::Assignment) {
-        struct_span_err!(
+        let mut err = struct_span_err!(
             self.tcx.sess, span, E0384,
             "re-assignment of immutable variable `{}`",
-            self.loan_path_to_string(lp))
-            .span_note(assign.span, "prior assignment occurs here")
-            .emit();
+            self.loan_path_to_string(lp));
+        err.span_label(span, &format!("re-assignment of immutable variable"));
+        if span != assign.span {
+            err.span_label(assign.span, &format!("first assignment to `{}`",
+                                              self.loan_path_to_string(lp)));
+        }
+        err.emit();
     }
 
     pub fn span_err(&self, s: Span, m: &str) {
index 366b58e06c4768050a0763d6f1d05b2b7e919b3e..5fe4830c365ef4c55871f518553092e98a01f52b 100644 (file)
@@ -235,12 +235,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
                 .flat_map(|arm| &arm.0)
                 .map(|pat| vec![wrap_pat(cx, &pat)])
                 .collect();
-            let match_span = Span {
-                lo: ex.span.lo,
-                hi: scrut.span.hi,
-                expn_id: ex.span.expn_id
-            };
-            check_exhaustive(cx, match_span, &matrix, source);
+            check_exhaustive(cx, scrut.span, &matrix, source);
         },
         _ => ()
     }
@@ -1115,9 +1110,15 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
 
         // x @ Foo(..) is legal, but x @ Foo(y) isn't.
         if sub.map_or(false, |p| pat_contains_bindings(&p)) {
-            span_err!(cx.tcx.sess, p.span, E0007, "cannot bind by-move with sub-bindings");
+            struct_span_err!(cx.tcx.sess, p.span, E0007,
+                             "cannot bind by-move with sub-bindings")
+                .span_label(p.span, &format!("binds an already bound by-move value by moving it"))
+                .emit();
         } else if has_guard {
-            span_err!(cx.tcx.sess, p.span, E0008, "cannot bind by-move into a pattern guard");
+            struct_span_err!(cx.tcx.sess, p.span, E0008,
+                      "cannot bind by-move into a pattern guard")
+                .span_label(p.span, &format!("moves value into pattern guard"))
+                .emit();
         } else if by_ref_span.is_some() {
             let mut err = struct_span_err!(cx.tcx.sess, p.span, E0009,
                                            "cannot bind by-move and by-ref in the same pattern");
index 539ec81889f01940b28a139c4c5d0aab26f19a03..c061f2d5620b2343735cdabc391ef1c0708411a1 100644 (file)
@@ -615,9 +615,12 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>) {
                     if !allow {
                         self.add(Qualif::NOT_CONST);
                         if self.mode != Mode::Fn {
-                            span_err!(self.tcx.sess, self.span, E0017,
-                                      "references in {}s may only refer \
-                                       to immutable values", self.mode);
+                            struct_span_err!(self.tcx.sess,  self.span, E0017,
+                                             "references in {}s may only refer \
+                                              to immutable values", self.mode)
+                                .span_label(self.span, &format!("{}s require immutable values",
+                                                                self.mode))
+                                .emit();
                         }
                     }
                 } else {
index 91d2500564fd3b7d246f406fcb8d117fb0fede0b..341c9d820e6519b060445ec621a56a3cc49faee4 100644 (file)
@@ -183,6 +183,7 @@ fn visit_foreign_item(&mut self, fi: &ForeignItem) {
                                                    E0130,
                                                    "patterns aren't allowed in foreign function \
                                                     declarations");
+                    err.span_label(span, &format!("pattern not allowed in foreign function"));
                     if is_recent {
                         err.span_note(span,
                                       "this is a recent error, see issue #35203 for more details");
index 93fd36d37af3ce8b4be43df3e396a380a467eff3..bdbdb294954883977837b68f3a3a91efacbd2374 100644 (file)
@@ -412,7 +412,10 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
             struct_span_err!(resolver.session, span, E0432, "{}", msg)
         }
         ResolutionError::FailedToResolve(msg) => {
-            struct_span_err!(resolver.session, span, E0433, "failed to resolve. {}", msg)
+            let mut err = struct_span_err!(resolver.session, span, E0433,
+                                           "failed to resolve. {}", msg);
+            err.span_label(span, &msg);
+            err
         }
         ResolutionError::CannotCaptureDynamicEnvironmentInFnItem => {
             struct_span_err!(resolver.session,
index b971ae02cd0bd27a87905137df7540a80142257b..140fabce76b4d5401414e96da5a6755f385147e2 100644 (file)
@@ -14,6 +14,8 @@
 use rustc::traits::{self, ProjectionMode};
 use rustc::ty::error::ExpectedFound;
 use rustc::ty::subst::{self, Subst, Substs, VecPerParamSpace};
+use rustc::hir::map::Node;
+use rustc::hir::{ImplItemKind, TraitItem_};
 
 use syntax::ast;
 use syntax_pos::Span;
@@ -461,7 +463,7 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
         // Compute skolemized form of impl and trait const tys.
         let impl_ty = impl_c.ty.subst(tcx, impl_to_skol_substs);
         let trait_ty = trait_c.ty.subst(tcx, &trait_to_skol_substs);
-        let origin = TypeOrigin::Misc(impl_c_span);
+        let mut origin = TypeOrigin::Misc(impl_c_span);
 
         let err = infcx.commit_if_ok(|_| {
             // There is no "body" here, so just pass dummy id.
@@ -496,11 +498,31 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
             debug!("checking associated const for compatibility: impl ty {:?}, trait ty {:?}",
                    impl_ty,
                    trait_ty);
+
+            // Locate the Span containing just the type of the offending impl
+            if let Some(impl_trait_node) = tcx.map.get_if_local(impl_c.def_id) {
+                if let Node::NodeImplItem(impl_trait_item) = impl_trait_node {
+                    if let ImplItemKind::Const(ref ty, _) = impl_trait_item.node {
+                        origin = TypeOrigin::Misc(ty.span);
+                    }
+                }
+            }
+
             let mut diag = struct_span_err!(
                 tcx.sess, origin.span(), E0326,
                 "implemented const `{}` has an incompatible type for trait",
                 trait_c.name
             );
+
+            // Add a label to the Span containing just the type of the item
+            if let Some(orig_trait_node) = tcx.map.get_if_local(trait_c.def_id) {
+                if let Node::NodeTraitItem(orig_trait_item) = orig_trait_node {
+                    if let TraitItem_::ConstTraitItem(ref ty, _) = orig_trait_item.node {
+                        diag.span_label(ty.span, &format!("original trait requirement"));
+                    }
+                }
+            }
+
             infcx.note_type_err(
                 &mut diag, origin,
                 Some(infer::ValuePairs::Types(ExpectedFound {
index 8a53c59b4c7fad08dafbe1215cb6d8bf52914885..9051b1c8069bde3583af62b07cb215efd70b5f3f 100644 (file)
@@ -97,8 +97,10 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
                 (0, Vec::new(), tcx.mk_nil())
             }
             op => {
-                span_err!(tcx.sess, it.span, E0092,
-                    "unrecognized atomic operation function: `{}`", op);
+                struct_span_err!(tcx.sess, it.span, E0092,
+                      "unrecognized atomic operation function: `{}`", op)
+                  .span_label(it.span, &format!("unrecognized atomic operation"))
+                  .emit();
                 return;
             }
         };
index f11bb3175dab0855793a01103f551254589b39e5..36fdba3706109682a0f4998040f50e00cd53c906 100644 (file)
@@ -1272,13 +1272,21 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
 
             // Check for duplicate discriminant values
             if let Some(i) = disr_vals.iter().position(|&x| x == current_disr_val) {
-                let mut err = struct_span_err!(ccx.tcx.sess, v.span, E0081,
-                    "discriminant value `{}` already exists", disr_vals[i]);
                 let variant_i_node_id = ccx.tcx.map.as_local_node_id(variants[i].did).unwrap();
-                err.span_label(ccx.tcx.map.span(variant_i_node_id),
-                               &format!("first use of `{}`", disr_vals[i]));
-                err.span_label(v.span , &format!("enum already has `{}`", disr_vals[i]));
-                err.emit();
+                let variant_i = ccx.tcx.map.expect_variant(variant_i_node_id);
+                let i_span = match variant_i.node.disr_expr {
+                    Some(ref expr) => expr.span,
+                    None => ccx.tcx.map.span(variant_i_node_id)
+                };
+                let span = match v.node.disr_expr {
+                    Some(ref expr) => expr.span,
+                    None => v.span
+                };
+                struct_span_err!(ccx.tcx.sess, span, E0081,
+                                 "discriminant value `{}` already exists", disr_vals[i])
+                    .span_label(i_span, &format!("first use of `{}`", disr_vals[i]))
+                    .span_label(span , &format!("enum already has `{}`", disr_vals[i]))
+                    .emit();
             }
             disr_vals.push(current_disr_val);
         }
@@ -4640,9 +4648,11 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
 
     for (i, b) in tps_used.iter().enumerate() {
         if !*b {
-            span_err!(ccx.tcx.sess, tps[i].span, E0091,
+            struct_span_err!(ccx.tcx.sess, tps[i].span, E0091,
                 "type parameter `{}` is unused",
-                tps[i].name);
+                tps[i].name)
+                .span_label(tps[i].span, &format!("unused type parameter"))
+                .emit();
         }
     }
 }
index f0ce4f6d2ec4225f9a022543cb8ca9ff6959cf6d..f68d902ef36ab9c8fe80e1d3d058cb48be35277a 100644 (file)
@@ -1903,9 +1903,12 @@ fn convert_default_type_parameter<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
     for leaf_ty in ty.walk() {
         if let ty::TyParam(p) = leaf_ty.sty {
             if p.space == space && p.idx >= index {
-                span_err!(ccx.tcx.sess, path.span, E0128,
-                          "type parameters with a default cannot use \
-                           forward declared identifiers");
+                struct_span_err!(ccx.tcx.sess, path.span, E0128,
+                                 "type parameters with a default cannot use \
+                                 forward declared identifiers")
+                    .span_label(path.span, &format!("defaulted type parameters \
+                                                    cannot be forward declared"))
+                    .emit();
 
                 return ccx.tcx.types.err
             }
index 5e733389e24c8b8e520eb61e5319e871d907d76a..a31961a157b35666c30ee131a2558ab967372075 100644 (file)
@@ -178,8 +178,10 @@ fn require_c_abi_if_variadic(tcx: TyCtxt,
                              abi: Abi,
                              span: Span) {
     if decl.variadic && abi != Abi::C {
-        span_err!(tcx.sess, span, E0045,
+        let mut err = struct_span_err!(tcx.sess, span, E0045,
                   "variadic function must have C calling convention");
+        err.span_label(span, &("variadics require C calling conventions").to_string())
+            .emit();
     }
 }
 
index e0501f9cc61d24c70781bab1cf2645d2ed143ffe..77b90c0846bbe44f2349b7a674223d6f47ea59f9 100644 (file)
@@ -99,11 +99,9 @@ pub struct CString {
 ///
 /// extern { fn my_string() -> *const c_char; }
 ///
-/// fn main() {
-///     unsafe {
-///         let slice = CStr::from_ptr(my_string());
-///         println!("string length: {}", slice.to_bytes().len());
-///     }
+/// unsafe {
+///     let slice = CStr::from_ptr(my_string());
+///     println!("string length: {}", slice.to_bytes().len());
 /// }
 /// ```
 ///
@@ -119,10 +117,8 @@ pub struct CString {
 ///     unsafe { work_with(data.as_ptr()) }
 /// }
 ///
-/// fn main() {
-///     let s = CString::new("data data data data").unwrap();
-///     work(&s);
-/// }
+/// let s = CString::new("data data data data").unwrap();
+/// work(&s);
 /// ```
 ///
 /// Converting a foreign C string into a Rust `String`
@@ -139,9 +135,7 @@ pub struct CString {
 ///     }
 /// }
 ///
-/// fn main() {
-///     println!("string: {}", my_string_safe());
-/// }
+/// println!("string: {}", my_string_safe());
 /// ```
 #[derive(Hash)]
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -188,11 +182,9 @@ impl CString {
     ///
     /// extern { fn puts(s: *const c_char); }
     ///
-    /// fn main() {
-    ///     let to_print = CString::new("Hello!").unwrap();
-    ///     unsafe {
-    ///         puts(to_print.as_ptr());
-    ///     }
+    /// let to_print = CString::new("Hello!").unwrap();
+    /// unsafe {
+    ///     puts(to_print.as_ptr());
     /// }
     /// ```
     ///
index b5287cce4843c13a511e4a16cdbae1d7410941a2..a4564b9543b3430cdd810b87ecf5c5bf65b434c2 100644 (file)
@@ -110,7 +110,7 @@ fn from_parts(addr: libc::sockaddr_un, mut len: libc::socklen_t) -> io::Result<S
         })
     }
 
-    /// Returns true iff the address is unnamed.
+    /// Returns true if and only if the address is unnamed.
     #[stable(feature = "unix_socket", since = "1.10.0")]
     pub fn is_unnamed(&self) -> bool {
         if let AddressKind::Unnamed = self.address() {
index bfc0f1afe3ad3d5bca94df7233a60cfeecd9ed9c..4be115b8afdace66329a8d4c5a97b31f32eb3346 100644 (file)
 fn main() {
     let x = Some("s".to_string());
     match x {
-        op_string @ Some(s) => {}, //~ ERROR E0007
-                                   //~| ERROR E0303
+        op_string @ Some(s) => {},
+        //~^ ERROR E0007
+        //~| NOTE binds an already bound by-move value by moving it
+        //~| ERROR E0303
         None => {},
     }
 }
index 97dd0f368bd12fd954cf8256b0d624e2cda35702..20cc1cbd2232df233d3e92734901b112247bc1a5 100644 (file)
@@ -10,7 +10,9 @@
 
 fn main() {
     match Some("hi".to_string()) {
-        Some(s) if s.len() == 0 => {}, //~ ERROR E0008
+        Some(s) if s.len() == 0 => {},
+        //~^ ERROR E0008
+        //~| NOTE moves value into pattern guard
         _ => {},
     }
 }
index 13f2c23d8c4a9912624fc6a67505262d3a963769..1223a01cbcb6f29fc0d14d04215597b02c5cd58b 100644 (file)
 const C: i32 = 2;
 
 const CR: &'static mut i32 = &mut C; //~ ERROR E0017
+                                     //~| NOTE constants require immutable values
                                      //~| ERROR E0017
+                                     //~| NOTE constants require immutable values
 static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
+                                              //~| NOTE statics require immutable values
                                               //~| ERROR E0017
+                                              //~| NOTE statics require immutable values
                                               //~| ERROR E0388
 static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
+                                             //~| NOTE statics require immutable values
                                              //~| ERROR E0017
-
+                                             //~| NOTE statics require immutable values
 fn main() {}
index 26d2f339763aa6c91639202dd6d118b8c0d14f23..6cf3f1ebf19e4526d1c8b6b37fe6af2a9b4bd894 100644 (file)
@@ -12,7 +12,10 @@ trait Trait {
     fn foo(&self) -> Self;
 }
 
-fn call_foo(x: Box<Trait>) { //~ ERROR E0038
+fn call_foo(x: Box<Trait>) {
+    //~^ ERROR E0038
+    //~| NOTE the trait `Trait` cannot be made into an object
+    //~| NOTE method `foo` references the `Self` type in its arguments or return type
     let y = x.foo();
 }
 
index 2a731596b4be8005c57ac9ba2ecdee156654b9d4..a3fea8e0db299b2a810f6b1790221e340d6b691d 100644 (file)
@@ -8,7 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern "Rust" { fn foo(x: u8, ...); } //~ ERROR E0045
+extern "Rust" { fn foo(x: u8, ...); }   //~ ERROR E0045
+                                        //~| NOTE variadics require C calling conventions
 
 fn main() {
 }
index 2f96ba1046d7487c1116e86621f8987e8e364293..e6de7921b30363a648723d5aaf14c71db276c9ef 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 struct ListNode { //~ ERROR E0072
+                  //~| NOTE recursive type has infinite size
     head: u8,
     tail: Option<ListNode>,
 }
index b63265564b334674ff9a86000f065cc92a10aef7..9911e093a898036d5fcae44fe656f6add46c2225 100644 (file)
@@ -9,8 +9,10 @@
 // except according to those terms.
 
 enum Enum {
-    P = 3,
-    X = 3, //~ ERROR E0081
+    P = 3, //~ NOTE first use of `3isize`
+    X = 3,
+    //~^ ERROR discriminant value `3isize` already exists
+    //~| NOTE enum already has `3isize`
     Y = 5
 }
 
index da988dbf819ac8c681a28d3bd4341c112c8e7d34..0d6c246de2a0e79f2c6e0f6d148165684820d556 100644 (file)
@@ -9,7 +9,9 @@
 // except according to those terms.
 
 type Foo<T> = u32; //~ ERROR E0091
+                   //~| NOTE unused type parameter
 type Foo2<A, B> = Box<A>; //~ ERROR E0091
+                          //~| NOTE unused type parameter
 
 fn main() {
 }
index b08164ac06d4235c0e95907f583406db6118efe9..c8bb31a7857ee1495ad17512b0af982cba14cac1 100644 (file)
@@ -11,7 +11,7 @@
 #![feature(intrinsics)]
 extern "rust-intrinsic" {
     fn atomic_foo(); //~ ERROR E0092
-}
+}                    //~| NOTE unrecognized atomic operation
 
 fn main() {
 }
index 37071012825ec9b67f9984e7f202300f80eee315..f5829b93859412c007daad508a71767652eb9140 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 struct Foo<T=U, U=()> { //~ ERROR E0128
+                        //~| NOTE defaulted type parameters cannot be forward declared
     field1: T,
     field2: U,
 }
index ef5961e133894d37c90103238f9cbb280d64fd58..e9e027fd1dc1972aea32aabfc7005274dd2c4f76 100644 (file)
@@ -9,7 +9,9 @@
 // except according to those terms.
 
 extern {
-    fn foo((a, b): (u32, u32)); //~ ERROR E0130
+    fn foo((a, b): (u32, u32));
+    //~^ ERROR E0130
+    //~| NOTE pattern not allowed in foreign function
 }
 
 fn main() {
index 630ee851d0af006e6d320ee229cd3c5d37fa4952..b8a4476fc59671b2b5e4f6b769ce5bad5ad9bfd9 100644 (file)
@@ -11,5 +11,7 @@
 unsafe fn f() { return; }
 
 fn main() {
-    f(); //~ ERROR E0133
+    f();
+    //~^ ERROR E0133
+    //~| NOTE unsafe call requires unsafe function or block
 }
index 09f654c368c62471c5224bd25fb4741afb4eb48c..11a8ff443a8459d452a2d53b89c633b0a4302e7b 100644 (file)
@@ -8,6 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { } //~ ERROR E0263
+fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) {
+    //~^ ERROR E0263
+    //~| NOTE declared twice
+    //~| NOTE previous declaration here
+}
 
 fn main() {}
index c1c72a5519bf10b5d81c389fad5481c8ee432db7..0541faa021356f0a0719423833dde86ee85b24c3 100644 (file)
           target_arch = "aarch64"))]
 pub fn main() {
     let x: isize;
-    x = 1; //~ NOTE prior assignment occurs here
+    x = 1; //~ NOTE first assignment
     foo(x);
     unsafe {
         asm!("mov $1, $0" : "=r"(x) : "r"(5));
         //~^ ERROR re-assignment of immutable variable `x`
+        //~| NOTE re-assignment of immutable
         //~| NOTE in this expansion of asm!
     }
     foo(x);
index 540272a8e2c58b511542504a666fdf20fb4be2c1..9a5d6289b589ecd3b5d556ffe3dff14b8d6b3f5c 100644 (file)
 
 fn test() {
     let v: isize;
-    v = 1; //~ NOTE prior assignment occurs here
+    v = 1; //~ NOTE first assignment
     println!("v={}", v);
     v = 2; //~ ERROR re-assignment of immutable variable
+           //~| NOTE re-assignment of immutable
     println!("v={}", v);
 }
 
index 95508a31044b87797dff021bc5a6a07b23cd2ff9..b3776091682da18b3f149c01f8786e830657df6d 100644 (file)
@@ -11,7 +11,7 @@
 #![feature(associated_consts)]
 
 trait Foo {
-    const BAR: u32;
+    const BAR: u32; //~ NOTE original trait requirement
 }
 
 struct SignedBar;
@@ -19,7 +19,7 @@ trait Foo {
 impl Foo for SignedBar {
     const BAR: i32 = -1;
     //~^ ERROR implemented const `BAR` has an incompatible type for trait [E0326]
-    //~| expected u32, found i32
+    //~| NOTE expected u32, found i32
 }
 
 fn main() {}
index 7d79c48c06ae2a789da006b3ebd8bbb5198cdefd..6a9d8db9654ac9d70e6ff0064f836daf732fcc78 100644 (file)
@@ -29,6 +29,7 @@ fn main() {
 
     let mut map = HashMap::new();
     //~^ ERROR E0433
+    //~| NOTE Use of undeclared type or module `HashMap`
 
     for line in input.lines() {
         let line = line.unwrap();
index 3d6f224c249040a1c1d168d0b5357ba9af7c06de..658a0c1546b9f337b27704fa31d060075e91bdfc 100644 (file)
 
 enum Foo {
     A = 1,
-    //~^ NOTE first use
-    //~| NOTE first use
-    //~| NOTE first use
-    B = 1, //~ ERROR discriminant value
-    //~^ NOTE enum already
+    //~^ NOTE first use of `1isize`
+    //~| NOTE first use of `1isize`
+    //~| NOTE first use of `1isize`
+    B = 1,
+    //~^ ERROR discriminant value `1isize` already exists
+    //~| NOTE enum already has `1isize`
     C = 0,
-    D, //~ ERROR discriminant value
-    //~^ NOTE enum already
+    D,
+    //~^ ERROR discriminant value `1isize` already exists
+    //~| NOTE enum already has `1isize`
 
-    E = N, //~ ERROR discriminant value
-    //~^ NOTE enum already
+    E = N,
+    //~^ ERROR discriminant value `1isize` already exists
+    //~| NOTE enum already has `1isize`
 
 }
 
index e6f3a2bdd33ad127a14960d350de8bba749b62af..b3fc3aea148ee3b6cdaf70e4e75a4af0c862a78b 100644 (file)
@@ -9,5 +9,6 @@
 // except according to those terms.
 
 pub struct Foo<Bar=Bar>; //~ ERROR E0128
+                         //~| NOTE defaulted type parameters cannot be forward declared
 pub struct Baz(Foo);
 fn main() {}
index 1c9e588cb2cd18c051d904b69947ff8c549c4b41..3e44053875552cbf8fbc194c2939969c89a65365 100644 (file)
@@ -15,10 +15,12 @@ fn f<T: Array>(x: &T) {
     //~^ ERROR `Array` cannot be made into an object
     //~| NOTE the trait cannot require that `Self : Sized`
     //~| NOTE requirements on the impl of `std::ops::CoerceUnsized<&Array>`
+    //~| NOTE the trait `Array` cannot be made into an object
     as
     &Array;
     //~^ ERROR `Array` cannot be made into an object
     //~| NOTE the trait cannot require that `Self : Sized`
+    //~| NOTE the trait `Array` cannot be made into an object
 }
 
 fn main() {}
index 4e9cbc4f283b4e12a2d3b950e99dfce3505f177f..ded685152d49b63c83a0371c41e6cabcc301e369 100644 (file)
@@ -28,6 +28,7 @@ impl<K> Map for K {
 fn main() {
     let _ = &()
         as &Map<Key=u32,MapValue=u32>;
-    //~^ ERROR the trait `Map` cannot be made into an object
+    //~^ ERROR E0038
     //~| NOTE the trait cannot use `Self` as a type parameter
+    //~| NOTE the trait `Map` cannot be made into an object
 }
index ce06c8bf220ee0317c3a94c55b2bfb4c12666a56..52b0eba96cbdf59631f784bc662fe72f14cfc001 100644 (file)
@@ -11,5 +11,7 @@
 use std::ptr;
 
 fn main() {
-    (&ptr::write)(1 as *mut _, 42); //~ ERROR E0133
+    (&ptr::write)(1 as *mut _, 42);
+    //~^ ERROR E0133
+    //~| NOTE unsafe call requires unsafe function or block
 }
index e6cc29634a1e8ebaf696f54192e82775336323a2..38b5fcbb3db0ee36b98b190945e09af7b1b33be4 100644 (file)
@@ -13,6 +13,7 @@
 enum foo { foo_(bar) }
 struct bar { x: bar }
 //~^ ERROR E0072
+//~| NOTE recursive type has infinite size
 
 fn main() {
 }
index 8af243afc22996b064c55ecc24e68aec2c7d82c4..afffe2a2c8d03d057a95eb4296f5dea955e1598e 100644 (file)
@@ -13,6 +13,7 @@
 // too big.
 
 enum Expr { //~ ERROR E0072
+            //~| NOTE recursive type has infinite size
     Plus(Expr, Expr),
     Literal(i64),
 }
index d96b1a1cbe35b1cd4f08bf56fa391ea88b25f733..71e9325ab75d135dfb7823e967f0f48d5b74466e 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 struct S { //~ ERROR E0072
+           //~| NOTE recursive type has infinite size
     element: Option<S>
 }
 
index f50a934510697669557cbe2a014b13dd2570bb57..9d246f8ea5e0e5bb08f01569508b805abee44ebc 100644 (file)
@@ -12,7 +12,7 @@ fn test() {
     let v: isize;
     loop {
         v = 1; //~ ERROR re-assignment of immutable variable
-        //~^ NOTE prior assignment occurs here
+        //~^ NOTE re-assignment of immutable variable
         v.clone(); // just to prevent liveness warnings
     }
 }
index df57bb9e4417ed17e6b77c2cf027e25adcf5db7f..e1eb3246137d22a9d711d93d5dd518ff22b1dd37 100644 (file)
@@ -10,8 +10,9 @@
 
 fn test() {
     let v: isize;
-    v = 2;  //~ NOTE prior assignment occurs here
+    v = 2;  //~ NOTE first assignment
     v += 1; //~ ERROR re-assignment of immutable variable
+            //~| NOTE re-assignment of immutable
     v.clone();
 }
 
index 28218bff60d68c96051741f5c3d66b2d9c3a9bb7..2468c91f34bbd018a4c324eed5c3e924f4a28b5c 100644 (file)
@@ -9,9 +9,10 @@
 // except according to those terms.
 
 fn test() {
-    let v: isize = 1; //~ NOTE prior assignment occurs here
+    let v: isize = 1; //~ NOTE first assignment
     v.clone();
     v = 2; //~ ERROR re-assignment of immutable variable
+           //~| NOTE re-assignment of immutable
     v.clone();
 }
 
index 3edbdf4ebc9584ce7d5770bd15064dd56fedf64f..b0278476998dd54b42a96a1a9b6089bb1a9db957 100644 (file)
 
 extern {
     fn f1(mut arg: u8); //~ ERROR patterns aren't allowed in foreign function declarations
-                        //~^ NOTE this is a recent error
+                        //~^ NOTE pattern not allowed in foreign function
+                        //~| NOTE this is a recent error
     fn f2(&arg: u8); //~ ERROR patterns aren't allowed in foreign function declarations
+                     //~^ NOTE pattern not allowed in foreign function
     fn f3(arg @ _: u8); //~ ERROR patterns aren't allowed in foreign function declarations
-                        //~^ NOTE this is a recent error
+                        //~^ NOTE pattern not allowed in foreign function
+                        //~| NOTE this is a recent error
     fn g1(arg: u8); // OK
     fn g2(_: u8); // OK
     // fn g3(u8); // Not yet
index 5097e3d7b10d4735cdc961e4b86d418b7a34fba0..6174d45b898d6971e00405c141930ba98590622c 100644 (file)
@@ -24,12 +24,14 @@ fn bar<T>(&self, t: T)
 fn make_bar<T:Bar>(t: &T) -> &Bar {
         //~^ ERROR E0038
         //~| NOTE method `bar` has generic type parameters
+        //~| NOTE the trait `Bar` cannot be made into an object
     t
 }
 
 fn make_bar_explicit<T:Bar>(t: &T) -> &Bar {
     //~^ ERROR E0038
-    //~^^ NOTE method `bar` has generic type parameters
+    //~| NOTE method `bar` has generic type parameters
+    //~| NOTE the trait `Bar` cannot be made into an object
     t as &Bar
 }
 
index edd31c1f79649fe98c89f8bc6b5e80f61c0a69eb..d85614fa5b538845359fa196638ff58dea68f82e 100644 (file)
@@ -27,12 +27,14 @@ trait Quux {
 fn make_bar<T:Bar>(t: &T) -> &Bar {
         //~^ ERROR E0038
         //~| NOTE method `bar` references the `Self` type in its arguments or return type
+        //~| NOTE the trait `Bar` cannot be made into an object
     loop { }
 }
 
 fn make_baz<T:Baz>(t: &T) -> &Baz {
         //~^ ERROR E0038
         //~| NOTE method `bar` references the `Self` type in its arguments or return type
+        //~| NOTE the trait `Baz` cannot be made into an object
     t
 }
 
index 501d61d20fed124453edb3b2bad2050c71f7d273..accd7fa87ac29bf435af31c3f2307f7995625b61 100644 (file)
@@ -18,6 +18,7 @@ trait Bar : Sized {
 fn make_bar<T:Bar>(t: &T) -> &Bar {
         //~^ ERROR E0038
         //~| NOTE the trait cannot require that `Self : Sized`
+        //~| NOTE the trait `Bar` cannot be made into an object
     t
 }
 
index 0a79ec30e4b942445b96da9bc08f970a4b023f01..74d1ad62f14c3be3fb4d8c0d0c21bb4a77c652e7 100644 (file)
@@ -25,6 +25,7 @@ fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> {
 fn make_baz<T:Baz>(t: &T) -> &Baz {
     //~^ ERROR E0038
     //~| NOTE the trait cannot use `Self` as a type parameter in the supertrait listing
+    //~| NOTE the trait `Baz` cannot be made into an object
     t
 }
 
index 499b58f70d77ab5360a63458ba97188b875c6ff5..0df7ee8cabed21a4adb3db8a14e1d1962127f669 100644 (file)
@@ -18,7 +18,9 @@ fn foo(self) { }
 unsafe impl UnsafeTrait for *mut isize {
     fn foo(self) {
         // Unsafe actions are not made legal by taking place in an unsafe trait:
-        *self += 1; //~ ERROR E0133
+        *self += 1;
+        //~^ ERROR E0133
+        //~| NOTE unsafe call requires unsafe function or block
     }
 }
 
index 4bb739800df368821aacde032015d05231cc3ea8..7b56c6c15ebb308b68b959338bacc1730a665cc5 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 struct t1 { //~ ERROR E0072
+            //~| NOTE recursive type has infinite size
     foo: isize,
     foolish: t1
 }
index 24ac41ce88437093797bfcd5ebe40057ff4ed72a..174939b09009cbd3ef0bef677506f6a3191146c8 100644 (file)
@@ -16,7 +16,9 @@
     !v
 }
 
-const VAL: u32 = dummy(0xFFFF); //~ ERROR E0133
+const VAL: u32 = dummy(0xFFFF);
+//~^ ERROR E0133
+//~| NOTE unsafe call requires unsafe function or block
 
 fn main() {
     assert_eq!(VAL, 0xFFFF0000);
diff --git a/src/test/run-pass/issue-29053.rs b/src/test/run-pass/issue-29053.rs
new file mode 100644 (file)
index 0000000..7265507
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2016 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.
+
+fn main() {
+    let x: &'static str = "x";
+
+    {
+        let y = "y".to_string();
+        let ref mut x = &*x;
+        *x = &*y;
+    }
+
+    assert_eq!(x, "x");
+}
index 2a35fab9676a71b9f45bea98a44a6409553df18a..6090cb4f52725784789fb5904c7ffc850e334ef1 100644 (file)
@@ -36,22 +36,22 @@ impl FromStr for Mode {
     type Err = ();
     fn from_str(s: &str) -> Result<Mode, ()> {
         match s {
-          "compile-fail" => Ok(CompileFail),
-          "parse-fail" => Ok(ParseFail),
-          "run-fail" => Ok(RunFail),
-          "run-pass" => Ok(RunPass),
-          "run-pass-valgrind" => Ok(RunPassValgrind),
-          "pretty" => Ok(Pretty),
-          "debuginfo-lldb" => Ok(DebugInfoLldb),
-          "debuginfo-gdb" => Ok(DebugInfoGdb),
-          "codegen" => Ok(Codegen),
-          "rustdoc" => Ok(Rustdoc),
-          "codegen-units" => Ok(CodegenUnits),
-          "incremental" => Ok(Incremental),
-          "run-make" => Ok(RunMake),
-          "ui" => Ok(Ui),
-          "mir-opt" => Ok(MirOpt),
-          _ => Err(()),
+            "compile-fail" => Ok(CompileFail),
+            "parse-fail" => Ok(ParseFail),
+            "run-fail" => Ok(RunFail),
+            "run-pass" => Ok(RunPass),
+            "run-pass-valgrind" => Ok(RunPassValgrind),
+            "pretty" => Ok(Pretty),
+            "debuginfo-lldb" => Ok(DebugInfoLldb),
+            "debuginfo-gdb" => Ok(DebugInfoGdb),
+            "codegen" => Ok(Codegen),
+            "rustdoc" => Ok(Rustdoc),
+            "codegen-units" => Ok(CodegenUnits),
+            "incremental" => Ok(Incremental),
+            "run-make" => Ok(RunMake),
+            "ui" => Ok(Ui),
+            "mir-opt" => Ok(MirOpt),
+            _ => Err(()),
         }
     }
 }
@@ -59,22 +59,23 @@ fn from_str(s: &str) -> Result<Mode, ()> {
 impl fmt::Display for Mode {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         fmt::Display::fmt(match *self {
-            CompileFail => "compile-fail",
-            ParseFail => "parse-fail",
-            RunFail => "run-fail",
-            RunPass => "run-pass",
-            RunPassValgrind => "run-pass-valgrind",
-            Pretty => "pretty",
-            DebugInfoGdb => "debuginfo-gdb",
-            DebugInfoLldb => "debuginfo-lldb",
-            Codegen => "codegen",
-            Rustdoc => "rustdoc",
-            CodegenUnits => "codegen-units",
-            Incremental => "incremental",
-            RunMake => "run-make",
-            Ui => "ui",
-            MirOpt => "mir-opt",
-        }, f)
+                              CompileFail => "compile-fail",
+                              ParseFail => "parse-fail",
+                              RunFail => "run-fail",
+                              RunPass => "run-pass",
+                              RunPassValgrind => "run-pass-valgrind",
+                              Pretty => "pretty",
+                              DebugInfoGdb => "debuginfo-gdb",
+                              DebugInfoLldb => "debuginfo-lldb",
+                              Codegen => "codegen",
+                              Rustdoc => "rustdoc",
+                              CodegenUnits => "codegen-units",
+                              Incremental => "incremental",
+                              RunMake => "run-make",
+                              Ui => "ui",
+                              MirOpt => "mir-opt",
+                          },
+                          f)
     }
 }
 
index c3da891933f6df1bb7fcf054063a6afa036d1032..29ca54fda8db9521eeb68b74686094bf84770a1b 100644 (file)
@@ -64,7 +64,11 @@ pub struct Error {
 }
 
 #[derive(PartialEq, Debug)]
-enum WhichLine { ThisLine, FollowPrevious(usize), AdjustBackward(usize) }
+enum WhichLine {
+    ThisLine,
+    FollowPrevious(usize),
+    AdjustBackward(usize),
+}
 
 /// Looks for either "//~| KIND MESSAGE" or "//~^^... KIND MESSAGE"
 /// The former is a "follow" that inherits its target from the preceding line;
@@ -91,25 +95,22 @@ pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<Error> {
 
     let tag = match cfg {
         Some(rev) => format!("//[{}]~", rev),
-        None => format!("//~")
+        None => format!("//~"),
     };
 
     rdr.lines()
-       .enumerate()
-       .filter_map(|(line_num, line)| {
-           parse_expected(last_nonfollow_error,
-                          line_num + 1,
-                          &line.unwrap(),
-                          &tag)
-               .map(|(which, error)| {
-                   match which {
-                       FollowPrevious(_) => {}
-                       _ => last_nonfollow_error = Some(error.line_num),
-                   }
-                   error
-               })
-       })
-       .collect()
+        .enumerate()
+        .filter_map(|(line_num, line)| {
+            parse_expected(last_nonfollow_error, line_num + 1, &line.unwrap(), &tag)
+                .map(|(which, error)| {
+                    match which {
+                        FollowPrevious(_) => {}
+                        _ => last_nonfollow_error = Some(error.line_num),
+                    }
+                    error
+                })
+        })
+        .collect()
 }
 
 fn parse_expected(last_nonfollow_error: Option<usize>,
@@ -117,7 +118,10 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
                   line: &str,
                   tag: &str)
                   -> Option<(WhichLine, Error)> {
-    let start = match line.find(tag) { Some(i) => i, None => return None };
+    let start = match line.find(tag) {
+        Some(i) => i,
+        None => return None,
+    };
     let (follow, adjusts) = if line[start + tag.len()..].chars().next().unwrap() == '|' {
         (true, 0)
     } else {
@@ -125,26 +129,25 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
     };
     let kind_start = start + tag.len() + adjusts + (follow as usize);
     let (kind, msg);
-    match
-        line[kind_start..].split_whitespace()
-                          .next()
-                          .expect("Encountered unexpected empty comment")
-                          .parse::<ErrorKind>()
-    {
+    match line[kind_start..]
+        .split_whitespace()
+        .next()
+        .expect("Encountered unexpected empty comment")
+        .parse::<ErrorKind>() {
         Ok(k) => {
             // If we find `//~ ERROR foo` or something like that:
             kind = Some(k);
             let letters = line[kind_start..].chars();
             msg = letters.skip_while(|c| c.is_whitespace())
-                         .skip_while(|c| !c.is_whitespace())
-                         .collect::<String>();
+                .skip_while(|c| !c.is_whitespace())
+                .collect::<String>();
         }
         Err(_) => {
             // Otherwise we found `//~ foo`:
             kind = None;
             let letters = line[kind_start..].chars();
             msg = letters.skip_while(|c| c.is_whitespace())
-                         .collect::<String>();
+                .collect::<String>();
         }
     }
     let msg = msg.trim().to_owned();
@@ -155,15 +158,25 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
                                                     preceding //~^ line.");
         (FollowPrevious(line_num), line_num)
     } else {
-        let which =
-            if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
+        let which = if adjusts > 0 {
+            AdjustBackward(adjusts)
+        } else {
+            ThisLine
+        };
         let line_num = line_num - adjusts;
         (which, line_num)
     };
 
     debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
-           line_num, tag, which, kind, msg);
-    Some((which, Error { line_num: line_num,
-                         kind: kind,
-                         msg: msg, }))
+           line_num,
+           tag,
+           which,
+           kind,
+           msg);
+    Some((which,
+          Error {
+        line_num: line_num,
+        kind: kind,
+        msg: msg,
+    }))
 }
index 7593033ffe3991f9c9791aedae294056a9f335bf..af33d76be1b0db0f430b4dcc5a4ee774a2c0d08d 100644 (file)
@@ -32,24 +32,21 @@ pub fn from_file(config: &Config, testfile: &Path) -> Self {
             should_fail: false,
         };
 
-        iter_header(testfile, None, &mut |ln| {
+        iter_header(testfile,
+                    None,
+                    &mut |ln| {
             props.ignore =
-                props.ignore ||
-                parse_name_directive(ln, "ignore-test") ||
+                props.ignore || parse_name_directive(ln, "ignore-test") ||
                 parse_name_directive(ln, &ignore_target(config)) ||
                 parse_name_directive(ln, &ignore_architecture(config)) ||
                 parse_name_directive(ln, &ignore_stage(config)) ||
                 parse_name_directive(ln, &ignore_env(config)) ||
-                (config.mode == common::Pretty &&
-                 parse_name_directive(ln, "ignore-pretty")) ||
+                (config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) ||
                 (config.target != config.host &&
                  parse_name_directive(ln, "ignore-cross-compile")) ||
-                ignore_gdb(config, ln) ||
-                ignore_lldb(config, ln);
+                ignore_gdb(config, ln) || ignore_lldb(config, ln);
 
-            props.should_fail =
-                props.should_fail ||
-                parse_name_directive(ln, "should-fail");
+            props.should_fail = props.should_fail || parse_name_directive(ln, "should-fail");
         });
 
         return props;
@@ -61,11 +58,11 @@ fn ignore_architecture(config: &Config) -> String {
             format!("ignore-{}", util::get_arch(&config.target))
         }
         fn ignore_stage(config: &Config) -> String {
-            format!("ignore-{}",
-                    config.stage_id.split('-').next().unwrap())
+            format!("ignore-{}", config.stage_id.split('-').next().unwrap())
         }
         fn ignore_env(config: &Config) -> String {
-            format!("ignore-{}", util::get_env(&config.target).unwrap_or("<unknown>"))
+            format!("ignore-{}",
+                    util::get_env(&config.target).unwrap_or("<unknown>"))
         }
         fn ignore_gdb(config: &Config, line: &str) -> bool {
             if config.mode != common::DebugInfoGdb {
@@ -79,13 +76,12 @@ fn ignore_gdb(config: &Config, line: &str) -> bool {
             if let Some(ref actual_version) = config.gdb_version {
                 if line.contains("min-gdb-version") {
                     let min_version = line.trim()
-                                          .split(' ')
-                                          .last()
-                                          .expect("Malformed GDB version directive");
+                        .split(' ')
+                        .last()
+                        .expect("Malformed GDB version directive");
                     // Ignore if actual version is smaller the minimum required
                     // version
-                    gdb_version_to_int(actual_version) <
-                        gdb_version_to_int(min_version)
+                    gdb_version_to_int(actual_version) < gdb_version_to_int(min_version)
                 } else {
                     false
                 }
@@ -106,13 +102,12 @@ fn ignore_lldb(config: &Config, line: &str) -> bool {
             if let Some(ref actual_version) = config.lldb_version {
                 if line.contains("min-lldb-version") {
                     let min_version = line.trim()
-                                          .split(' ')
-                                          .last()
-                                          .expect("Malformed lldb version directive");
+                        .split(' ')
+                        .last()
+                        .expect("Malformed lldb version directive");
                     // Ignore if actual version is smaller the minimum required
                     // version
-                    lldb_version_to_int(actual_version) <
-                        lldb_version_to_int(min_version)
+                    lldb_version_to_int(actual_version) < lldb_version_to_int(min_version)
                 } else {
                     false
                 }
@@ -126,7 +121,7 @@ fn ignore_lldb(config: &Config, line: &str) -> bool {
 #[derive(Clone, Debug)]
 pub struct TestProps {
     // Lines that should be expected, in order, on standard out
-    pub error_patterns: Vec<String> ,
+    pub error_patterns: Vec<String>,
     // Extra flags to pass to the compiler
     pub compile_flags: Vec<String>,
     // Extra flags to pass when the compiled code is run (such as --bench)
@@ -137,13 +132,13 @@ pub struct TestProps {
     // Other crates that should be compiled (typically from the same
     // directory as the test, but for backwards compatibility reasons
     // we also check the auxiliary directory)
-    pub aux_builds: Vec<String> ,
+    pub aux_builds: Vec<String>,
     // Environment settings to use for compiling
-    pub rustc_env: Vec<(String,String)> ,
+    pub rustc_env: Vec<(String, String)>,
     // Environment settings to use during execution
-    pub exec_env: Vec<(String,String)> ,
+    pub exec_env: Vec<(String, String)>,
     // Lines to check if they appear in the expected debugger output
-    pub check_lines: Vec<String> ,
+    pub check_lines: Vec<String>,
     // Build documentation for all specified aux-builds as well
     pub build_aux_docs: bool,
     // Flag to force a crate to be built with the host architecture
@@ -226,17 +221,17 @@ pub fn from_file(testfile: &Path) -> Self {
     /// tied to a particular revision `foo` (indicated by writing
     /// `//[foo]`), then the property is ignored unless `cfg` is
     /// `Some("foo")`.
-    pub fn load_from(&mut self, testfile: &Path, cfg: Option<&str>)  {
-        iter_header(testfile, cfg, &mut |ln| {
+    pub fn load_from(&mut self, testfile: &Path, cfg: Option<&str>) {
+        iter_header(testfile,
+                    cfg,
+                    &mut |ln| {
             if let Some(ep) = parse_error_pattern(ln) {
                 self.error_patterns.push(ep);
             }
 
             if let Some(flags) = parse_compile_flags(ln) {
-                self.compile_flags.extend(
-                    flags
-                        .split_whitespace()
-                        .map(|s| s.to_owned()));
+                self.compile_flags.extend(flags.split_whitespace()
+                    .map(|s| s.to_owned()));
             }
 
             if let Some(r) = parse_revisions(ln) {
@@ -279,7 +274,7 @@ pub fn load_from(&mut self, testfile: &Path, cfg: Option<&str>)  {
                 self.pretty_compare_only = parse_pretty_compare_only(ln);
             }
 
-            if let  Some(ab) = parse_aux_build(ln) {
+            if let Some(ab) = parse_aux_build(ln) {
                 self.aux_builds.push(ab);
             }
 
@@ -291,7 +286,7 @@ pub fn load_from(&mut self, testfile: &Path, cfg: Option<&str>)  {
                 self.rustc_env.push(ee);
             }
 
-            if let Some(cl) =  parse_check_line(ln) {
+            if let Some(cl) = parse_check_line(ln) {
                 self.check_lines.push(cl);
             }
 
@@ -302,21 +297,20 @@ pub fn load_from(&mut self, testfile: &Path, cfg: Option<&str>)  {
 
         for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
             match env::var(key) {
-                Ok(val) =>
+                Ok(val) => {
                     if self.exec_env.iter().find(|&&(ref x, _)| *x == key).is_none() {
                         self.exec_env.push((key.to_owned(), val))
-                    },
+                    }
+                }
                 Err(..) => {}
             }
         }
     }
 }
 
-fn iter_header(testfile: &Path,
-               cfg: Option<&str>,
-               it: &mut FnMut(&str)) {
+fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut FnMut(&str)) {
     if testfile.is_dir() {
-        return
+        return;
     }
     let rdr = BufReader::new(File::open(testfile).unwrap());
     for ln in rdr.lines() {
@@ -336,7 +330,7 @@ fn iter_header(testfile: &Path,
                     None => false,
                 };
                 if matches {
-                    it(&ln[close_brace+1..]);
+                    it(&ln[close_brace + 1..]);
                 }
             } else {
                 panic!("malformed condition directive: expected `//[foo]`, found `{}`",
@@ -409,18 +403,17 @@ fn parse_pretty_compare_only(line: &str) -> bool {
 fn parse_env(line: &str, name: &str) -> Option<(String, String)> {
     parse_name_value_directive(line, name).map(|nv| {
         // nv is either FOO or FOO=BAR
-        let mut strs: Vec<String> = nv
-                                      .splitn(2, '=')
-                                      .map(str::to_owned)
-                                      .collect();
+        let mut strs: Vec<String> = nv.splitn(2, '=')
+            .map(str::to_owned)
+            .collect();
 
         match strs.len() {
-          1 => (strs.pop().unwrap(), "".to_owned()),
-          2 => {
-              let end = strs.pop().unwrap();
-              (strs.pop().unwrap(), end)
-          }
-          n => panic!("Expected 1 or 2 strings, not {}", n)
+            1 => (strs.pop().unwrap(), "".to_owned()),
+            2 => {
+                let end = strs.pop().unwrap();
+                (strs.pop().unwrap(), end)
+            }
+            n => panic!("Expected 1 or 2 strings, not {}", n),
         }
     })
 }
@@ -442,11 +435,10 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
     line.contains(directive) && !line.contains(&("no-".to_owned() + directive))
 }
 
-pub fn parse_name_value_directive(line: &str, directive: &str)
-                                  -> Option<String> {
+pub fn parse_name_value_directive(line: &str, directive: &str) -> Option<String> {
     let keycolon = format!("{}:", directive);
     if let Some(colon) = line.find(&keycolon) {
-        let value = line[(colon + keycolon.len()) .. line.len()].to_owned();
+        let value = line[(colon + keycolon.len())..line.len()].to_owned();
         debug!("{}: {}", directive, value);
         Some(value)
     } else {
@@ -455,9 +447,8 @@ pub fn parse_name_value_directive(line: &str, directive: &str)
 }
 
 pub fn gdb_version_to_int(version_string: &str) -> isize {
-    let error_string = format!(
-        "Encountered GDB version string with unexpected format: {}",
-        version_string);
+    let error_string = format!("Encountered GDB version string with unexpected format: {}",
+                               version_string);
     let error_string = error_string;
 
     let components: Vec<&str> = version_string.trim().split('.').collect();
@@ -473,9 +464,8 @@ pub fn gdb_version_to_int(version_string: &str) -> isize {
 }
 
 pub fn lldb_version_to_int(version_string: &str) -> isize {
-    let error_string = format!(
-        "Encountered LLDB version string with unexpected format: {}",
-        version_string);
+    let error_string = format!("Encountered LLDB version string with unexpected format: {}",
+                               version_string);
     let error_string = error_string;
     let major: isize = version_string.parse().ok().expect(&error_string);
     return major;
index e5b628bb0029545022dab31220dc8e89ef668470..d9da1bdc3485837d8024036f23ff5be81f5e7c71 100644 (file)
@@ -12,7 +12,7 @@
 use rustc_serialize::json;
 use std::str::FromStr;
 use std::path::Path;
-use runtest::{ProcRes};
+use runtest::ProcRes;
 
 // These structs are a subset of the ones found in
 // `syntax::json`.
@@ -58,8 +58,8 @@ struct DiagnosticCode {
 
 pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> {
     output.lines()
-          .flat_map(|line| parse_line(file_name, line, output, proc_res))
-          .collect()
+        .flat_map(|line| parse_line(file_name, line, output, proc_res))
+        .collect()
 }
 
 fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> {
@@ -73,9 +73,11 @@ fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) ->
                 expected_errors
             }
             Err(error) => {
-                proc_res.fatal(Some(&format!(
-                    "failed to decode compiler output as json: `{}`\noutput: {}\nline: {}",
-                    error, line, output)));
+                proc_res.fatal(Some(&format!("failed to decode compiler output as json: \
+                                              `{}`\noutput: {}\nline: {}",
+                                             error,
+                                             line,
+                                             output)));
             }
         }
     } else {
@@ -87,16 +89,15 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
                         diagnostic: &Diagnostic,
                         default_spans: &[&DiagnosticSpan],
                         file_name: &str) {
-    let spans_in_this_file: Vec<_> =
-        diagnostic.spans.iter()
-                        .filter(|span| Path::new(&span.file_name) == Path::new(&file_name))
-                        .collect();
-
-    let primary_spans: Vec<_> =
-        spans_in_this_file.iter()
-                          .cloned()
-                          .filter(|span| span.is_primary)
-                          .collect();
+    let spans_in_this_file: Vec<_> = diagnostic.spans
+        .iter()
+        .filter(|span| Path::new(&span.file_name) == Path::new(&file_name))
+        .collect();
+
+    let primary_spans: Vec<_> = spans_in_this_file.iter()
+        .cloned()
+        .filter(|span| span.is_primary)
+        .collect();
     let primary_spans = if primary_spans.is_empty() {
         // subdiagnostics often don't have a span of their own;
         // inherit the span from the parent in that case
@@ -144,24 +145,20 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
         for span in primary_spans {
             let msg = with_code(span, first_line);
             let kind = ErrorKind::from_str(&diagnostic.level).ok();
-            expected_errors.push(
-                Error {
-                    line_num: span.line_start,
-                    kind: kind,
-                    msg: msg,
-                }
-            );
+            expected_errors.push(Error {
+                line_num: span.line_start,
+                kind: kind,
+                msg: msg,
+            });
         }
     }
     for next_line in message_lines {
         for span in primary_spans {
-            expected_errors.push(
-                Error {
-                    line_num: span.line_start,
-                    kind: None,
-                    msg: with_code(span, next_line),
-                }
-            );
+            expected_errors.push(Error {
+                line_num: span.line_start,
+                kind: None,
+                msg: with_code(span, next_line),
+            });
         }
     }
 
@@ -170,33 +167,28 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
         let start_line = primary_spans.iter().map(|s| s.line_start).min().expect("\
             every suggestion should have at least one span");
         for (index, line) in rendered.lines().enumerate() {
-            expected_errors.push(
-                Error {
-                    line_num: start_line + index,
-                    kind: Some(ErrorKind::Suggestion),
-                    msg: line.to_string()
-                }
-            );
+            expected_errors.push(Error {
+                line_num: start_line + index,
+                kind: Some(ErrorKind::Suggestion),
+                msg: line.to_string(),
+            });
         }
     }
 
     // Add notes for the backtrace
     for span in primary_spans {
         for frame in &span.expansion {
-            push_backtrace(expected_errors,
-                           frame,
-                           file_name);
+            push_backtrace(expected_errors, frame, file_name);
         }
     }
 
     // Add notes for any labels that appear in the message.
     for span in spans_in_this_file.iter()
-                                  .filter(|span| span.label.is_some())
-    {
+        .filter(|span| span.label.is_some()) {
         expected_errors.push(Error {
             line_num: span.line_start,
             kind: Some(ErrorKind::Note),
-            msg: span.label.clone().unwrap()
+            msg: span.label.clone().unwrap(),
         });
     }
 
@@ -210,13 +202,11 @@ fn push_backtrace(expected_errors: &mut Vec<Error>,
                   expansion: &DiagnosticSpanMacroExpansion,
                   file_name: &str) {
     if Path::new(&expansion.span.file_name) == Path::new(&file_name) {
-        expected_errors.push(
-            Error {
-                line_num: expansion.span.line_start,
-                kind: Some(ErrorKind::Note),
-                msg: format!("in this expansion of {}", expansion.macro_decl_name),
-            }
-        );
+        expected_errors.push(Error {
+            line_num: expansion.span.line_start,
+            kind: Some(ErrorKind::Note),
+            msg: format!("in this expansion of {}", expansion.macro_decl_name),
+        });
     }
 
     for previous_expansion in &expansion.span.expansion {
index 53b7cd059be275f8ccd64db3811a422ec8dd5ab6..ed690c08a1ed27e08dc0c6e3ae334d933012fe0b 100644 (file)
@@ -12,7 +12,7 @@
 use std::ffi::OsString;
 use std::io::prelude::*;
 use std::path::PathBuf;
-use std::process::{ExitStatus, Command, Child, Output, Stdio};
+use std::process::{Child, Command, ExitStatus, Output, Stdio};
 
 pub fn dylib_env_var() -> &'static str {
     if cfg!(windows) {
@@ -29,7 +29,7 @@ fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
     // search path for the child.
     let var = dylib_env_var();
     let mut path = env::split_paths(&env::var_os(var).unwrap_or(OsString::new()))
-                       .collect::<Vec<_>>();
+        .collect::<Vec<_>>();
     if let Some(p) = aux_path {
         path.insert(0, PathBuf::from(p))
     }
@@ -40,20 +40,25 @@ fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
     cmd.env(var, newpath);
 }
 
-pub struct Result {pub status: ExitStatus, pub out: String, pub err: String}
+pub struct Result {
+    pub status: ExitStatus,
+    pub out: String,
+    pub err: String,
+}
 
 pub fn run(lib_path: &str,
            prog: &str,
            aux_path: Option<&str>,
            args: &[String],
-           env: Vec<(String, String)> ,
-           input: Option<String>) -> Option<Result> {
+           env: Vec<(String, String)>,
+           input: Option<String>)
+           -> Option<Result> {
 
     let mut cmd = Command::new(prog);
     cmd.args(args)
-       .stdin(Stdio::piped())
-       .stdout(Stdio::piped())
-       .stderr(Stdio::piped());
+        .stdin(Stdio::piped())
+        .stdout(Stdio::piped())
+        .stderr(Stdio::piped());
     add_target_env(&mut cmd, lib_path, aux_path);
     for (key, val) in env {
         cmd.env(&key, &val);
@@ -64,31 +69,31 @@ pub fn run(lib_path: &str,
             if let Some(input) = input {
                 process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
             }
-            let Output { status, stdout, stderr } =
-                process.wait_with_output().unwrap();
+            let Output { status, stdout, stderr } = process.wait_with_output().unwrap();
 
             Some(Result {
                 status: status,
                 out: String::from_utf8(stdout).unwrap(),
-                err: String::from_utf8(stderr).unwrap()
+                err: String::from_utf8(stderr).unwrap(),
             })
-        },
-        Err(..) => None
+        }
+        Err(..) => None,
     }
 }
 
 pub fn run_background(lib_path: &str,
-           prog: &str,
-           aux_path: Option<&str>,
-           args: &[String],
-           env: Vec<(String, String)> ,
-           input: Option<String>) -> Option<Child> {
+                      prog: &str,
+                      aux_path: Option<&str>,
+                      args: &[String],
+                      env: Vec<(String, String)>,
+                      input: Option<String>)
+                      -> Option<Child> {
 
     let mut cmd = Command::new(prog);
     cmd.args(args)
-       .stdin(Stdio::piped())
-       .stdout(Stdio::piped())
-       .stderr(Stdio::piped());
+        .stdin(Stdio::piped())
+        .stdout(Stdio::piped())
+        .stderr(Stdio::piped());
     add_target_env(&mut cmd, lib_path, aux_path);
     for (key, val) in env {
         cmd.env(&key, &val);
@@ -101,7 +106,7 @@ pub fn run_background(lib_path: &str,
             }
 
             Some(process)
-        },
-        Err(..) => None
+        }
+        Err(..) => None,
     }
 }
index 0cf90ec95f38e3c838e40e08ce6e2f57580cb080..e2629ffd8f54a3e122b373462ed6b711cbb27661 100644 (file)
@@ -34,14 +34,21 @@ pub unsafe fn raise_fd_limit() {
     let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
     let mut maxfiles: libc::c_int = 0;
     let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
-    if libc::sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size,
-              null_mut(), 0) != 0 {
+    if libc::sysctl(&mut mib[0],
+                    2,
+                    &mut maxfiles as *mut _ as *mut _,
+                    &mut size,
+                    null_mut(),
+                    0) != 0 {
         let err = io::Error::last_os_error();
         panic!("raise_fd_limit: error calling sysctl: {}", err);
     }
 
     // Fetch the current resource limits
-    let mut rlim = libc::rlimit{rlim_cur: 0, rlim_max: 0};
+    let mut rlim = libc::rlimit {
+        rlim_cur: 0,
+        rlim_max: 0,
+    };
     if libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) != 0 {
         let err = io::Error::last_os_error();
         panic!("raise_fd_limit: error calling getrlimit: {}", err);
index 66573393971c4c6692ce2549017f28e7680b19db..fca01029c44652ba87d542ed43e478f5a2d6313a 100644 (file)
 
 pub fn diff_lines(actual: &str, expected: &str) -> Vec<String> {
     // mega simplistic diff algorithm that just prints the things added/removed
-    zip_all(actual.lines(), expected.lines()).enumerate().filter_map(|(i, (a,e))| {
-        match (a, e) {
-            (Some(a), Some(e)) => {
-                if lines_match(e, a) {
-                    None
-                } else {
-                    Some(format!("{:3} - |{}|\n    + |{}|\n", i, e, a))
+    zip_all(actual.lines(), expected.lines())
+        .enumerate()
+        .filter_map(|(i, (a, e))| {
+            match (a, e) {
+                (Some(a), Some(e)) => {
+                    if lines_match(e, a) {
+                        None
+                    } else {
+                        Some(format!("{:3} - |{}|\n    + |{}|\n", i, e, a))
+                    }
                 }
-            },
-            (Some(a), None) => {
-                Some(format!("{:3} -\n    + |{}|\n", i, a))
-            },
-            (None, Some(e)) => {
-                Some(format!("{:3} - |{}|\n    +\n", i, e))
-            },
-            (None, None) => panic!("Cannot get here")
-        }
-    }).collect()
+                (Some(a), None) => Some(format!("{:3} -\n    + |{}|\n", i, a)),
+                (None, Some(e)) => Some(format!("{:3} - |{}|\n    +\n", i, e)),
+                (None, None) => panic!("Cannot get here"),
+            }
+        })
+        .collect()
 }
 
 fn lines_match(expected: &str, mut actual: &str) -> bool {
@@ -38,13 +37,11 @@ fn lines_match(expected: &str, mut actual: &str) -> bool {
         match actual.find(part) {
             Some(j) => {
                 if i == 0 && j != 0 {
-                    return false
+                    return false;
                 }
                 actual = &actual[j + part.len()..];
             }
-            None => {
-                return false
-            }
+            None => return false,
         }
     }
     actual.is_empty() || expected.ends_with("[..]")
@@ -55,7 +52,7 @@ struct ZipAll<I1: Iterator, I2: Iterator> {
     second: I2,
 }
 
-impl<T, I1: Iterator<Item=T>, I2: Iterator<Item=T>> Iterator for ZipAll<I1, I2> {
+impl<T, I1: Iterator<Item = T>, I2: Iterator<Item = T>> Iterator for ZipAll<I1, I2> {
     type Item = (Option<T>, Option<T>);
     fn next(&mut self) -> Option<(Option<T>, Option<T>)> {
         let first = self.first.next();
@@ -63,12 +60,12 @@ fn next(&mut self) -> Option<(Option<T>, Option<T>)> {
 
         match (first, second) {
             (None, None) => None,
-            (a, b) => Some((a, b))
+            (a, b) => Some((a, b)),
         }
     }
 }
 
-fn zip_all<T, I1: Iterator<Item=T>, I2: Iterator<Item=T>>(a: I1, b: I2) -> ZipAll<I1, I2> {
+fn zip_all<T, I1: Iterator<Item = T>, I2: Iterator<Item = T>>(a: I1, b: I2) -> ZipAll<I1, I2> {
     ZipAll {
         first: a,
         second: b,
index 69b839c5b7d9d0e94cdf58623574ef3ecd8e9dc3..d2872a0a2b7caa18ef6d42a7c879a4297fde8018 100644 (file)
 use common::Config;
 
 /// Conversion table from triple OS name to Rust SYSNAME
-const OS_TABLE: &'static [(&'static str, &'static str)] = &[
-    ("android", "android"),
-    ("bitrig", "bitrig"),
-    ("darwin", "macos"),
-    ("dragonfly", "dragonfly"),
-    ("freebsd", "freebsd"),
-    ("ios", "ios"),
-    ("linux", "linux"),
-    ("mingw32", "windows"),
-    ("netbsd", "netbsd"),
-    ("openbsd", "openbsd"),
-    ("win32", "windows"),
-    ("windows", "windows"),
-    ("solaris", "solaris"),
-    ("emscripten", "emscripten"),
-];
+const OS_TABLE: &'static [(&'static str, &'static str)] = &[("android", "android"),
+                                                            ("bitrig", "bitrig"),
+                                                            ("darwin", "macos"),
+                                                            ("dragonfly", "dragonfly"),
+                                                            ("freebsd", "freebsd"),
+                                                            ("ios", "ios"),
+                                                            ("linux", "linux"),
+                                                            ("mingw32", "windows"),
+                                                            ("netbsd", "netbsd"),
+                                                            ("openbsd", "openbsd"),
+                                                            ("win32", "windows"),
+                                                            ("windows", "windows"),
+                                                            ("solaris", "solaris"),
+                                                            ("emscripten", "emscripten")];
 
-const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[
-    ("aarch64", "aarch64"),
-    ("amd64", "x86_64"),
-    ("arm", "arm"),
-    ("arm64", "aarch64"),
-    ("hexagon", "hexagon"),
-    ("i386", "x86"),
-    ("i686", "x86"),
-    ("mips", "mips"),
-    ("msp430", "msp430"),
-    ("powerpc", "powerpc"),
-    ("powerpc64", "powerpc64"),
-    ("s390x", "systemz"),
-    ("sparc", "sparc"),
-    ("x86_64", "x86_64"),
-    ("xcore", "xcore"),
-    ("asmjs", "asmjs"),
-];
+const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[("aarch64", "aarch64"),
+                                                              ("amd64", "x86_64"),
+                                                              ("arm", "arm"),
+                                                              ("arm64", "aarch64"),
+                                                              ("hexagon", "hexagon"),
+                                                              ("i386", "x86"),
+                                                              ("i686", "x86"),
+                                                              ("mips", "mips"),
+                                                              ("msp430", "msp430"),
+                                                              ("powerpc", "powerpc"),
+                                                              ("powerpc64", "powerpc64"),
+                                                              ("s390x", "systemz"),
+                                                              ("sparc", "sparc"),
+                                                              ("x86_64", "x86_64"),
+                                                              ("xcore", "xcore"),
+                                                              ("asmjs", "asmjs")];
 
 pub fn get_os(triple: &str) -> &'static str {
     for &(triple_os, os) in OS_TABLE {
         if triple.contains(triple_os) {
-            return os
+            return os;
         }
     }
     panic!("Cannot determine OS from triple");
@@ -59,7 +55,7 @@ pub fn get_os(triple: &str) -> &'static str {
 pub fn get_arch(triple: &str) -> &'static str {
     for &(triple_arch, arch) in ARCH_TABLE {
         if triple.contains(triple_arch) {
-            return arch
+            return arch;
         }
     }
     panic!("Cannot determine Architecture from triple");
@@ -74,17 +70,21 @@ pub fn make_new_path(path: &str) -> String {
     // Windows just uses PATH as the library search path, so we have to
     // maintain the current value while adding our own
     match env::var(lib_path_env_var()) {
-        Ok(curr) => {
-            format!("{}{}{}", path, path_div(), curr)
-        }
-        Err(..) => path.to_owned()
+        Ok(curr) => format!("{}{}{}", path, path_div(), curr),
+        Err(..) => path.to_owned(),
     }
 }
 
-pub fn lib_path_env_var() -> &'static str { "PATH" }
-fn path_div() -> &'static str { ";" }
+pub fn lib_path_env_var() -> &'static str {
+    "PATH"
+}
+fn path_div() -> &'static str {
+    ";"
+}
 
 pub fn logv(config: &Config, s: String) {
     debug!("{}", s);
-    if config.verbose { println!("{}", s); }
+    if config.verbose {
+        println!("{}", s);
+    }
 }