]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #35425 - apasel422:refcell, r=alexcrichton
authorbors <bors@rust-lang.org>
Tue, 9 Aug 2016 09:11:50 +0000 (02:11 -0700)
committerGitHub <noreply@github.com>
Tue, 9 Aug 2016 09:11:50 +0000 (02:11 -0700)
Implement `RefCell::{try_borrow, try_borrow_mut}`

CC #35070

r? @alexcrichton

146 files changed:
man/rustc.1
man/rustdoc.1
src/libcollections/slice.rs
src/libcollections/string.rs
src/libcore/iter/traits.rs
src/libcore/raw.rs
src/libcore/slice.rs
src/librustc/middle/astconv_util.rs
src/librustc/traits/error_reporting.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_const_eval/check_match.rs
src/librustc_const_eval/diagnostics.rs
src/librustc_const_eval/eval.rs
src/librustc_mir/transform/qualify_consts.rs
src/librustc_passes/ast_validation.rs
src/librustc_passes/consts.rs
src/librustc_passes/diagnostics.rs
src/librustc_passes/lib.rs
src/librustc_passes/loops.rs
src/librustc_passes/no_asm.rs
src/librustc_passes/static_recursion.rs
src/librustc_resolve/diagnostics.rs
src/librustc_resolve/lib.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/callee.rs
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/coherence/mod.rs
src/librustc_typeck/coherence/orphan.rs
src/librustc_typeck/collect.rs
src/librustc_typeck/lib.rs
src/libstd/ffi/c_str.rs
src/libstd/sys/unix/fs.rs
src/libstd/sys/unix/os.rs
src/libstd/sys/unix/rwlock.rs
src/libstd/sys/windows/fs.rs
src/test/compile-fail/E0010.rs
src/test/compile-fail/E0027.rs
src/test/compile-fail/E0029.rs
src/test/compile-fail/E0040.rs
src/test/compile-fail/E0046.rs
src/test/compile-fail/E0069.rs
src/test/compile-fail/E0101.rs
src/test/compile-fail/E0102.rs
src/test/compile-fail/E0106.rs
src/test/compile-fail/E0107.rs
src/test/compile-fail/E0116.rs
src/test/compile-fail/E0117.rs
src/test/compile-fail/E0118.rs
src/test/compile-fail/E0131.rs
src/test/compile-fail/E0166.rs
src/test/compile-fail/E0185.rs
src/test/compile-fail/E0186.rs
src/test/compile-fail/E0204.rs
src/test/compile-fail/E0205.rs
src/test/compile-fail/E0206.rs
src/test/compile-fail/E0207.rs
src/test/compile-fail/E0223.rs
src/test/compile-fail/E0225.rs
src/test/compile-fail/E0229.rs
src/test/compile-fail/E0243.rs
src/test/compile-fail/E0244.rs
src/test/compile-fail/E0253.rs [new file with mode: 0644]
src/test/compile-fail/E0254.rs [new file with mode: 0644]
src/test/compile-fail/E0255.rs [new file with mode: 0644]
src/test/compile-fail/E0259.rs [new file with mode: 0644]
src/test/compile-fail/E0260.rs [new file with mode: 0644]
src/test/compile-fail/E0261.rs [new file with mode: 0644]
src/test/compile-fail/E0262.rs [new file with mode: 0644]
src/test/compile-fail/E0263.rs [new file with mode: 0644]
src/test/compile-fail/E0264.rs [new file with mode: 0644]
src/test/compile-fail/E0267.rs [new file with mode: 0644]
src/test/compile-fail/E0268.rs [new file with mode: 0644]
src/test/compile-fail/E0271.rs [new file with mode: 0644]
src/test/compile-fail/E0275.rs [new file with mode: 0644]
src/test/compile-fail/E0276.rs [new file with mode: 0644]
src/test/compile-fail/E0277.rs [new file with mode: 0644]
src/test/compile-fail/E0281.rs [new file with mode: 0644]
src/test/compile-fail/E0282.rs [new file with mode: 0644]
src/test/compile-fail/E0283.rs [new file with mode: 0644]
src/test/compile-fail/E0296.rs [new file with mode: 0644]
src/test/compile-fail/E0297.rs [new file with mode: 0644]
src/test/compile-fail/E0301.rs [new file with mode: 0644]
src/test/compile-fail/E0302.rs [new file with mode: 0644]
src/test/compile-fail/E0303.rs [new file with mode: 0644]
src/test/compile-fail/E0306.rs
src/test/compile-fail/associated-types-in-ambiguous-context.rs
src/test/compile-fail/bad-bang-ann-3.rs
src/test/compile-fail/borrowck/borrowck-escaping-closure-error-1.rs
src/test/compile-fail/borrowck/borrowck-escaping-closure-error-2.rs
src/test/compile-fail/coherence-impls-copy.rs
src/test/compile-fail/const-fn-mismatch.rs
src/test/compile-fail/const-integer-bool-ops.rs
src/test/compile-fail/double-import.rs
src/test/compile-fail/generic-type-less-params-with-defaults.rs
src/test/compile-fail/generic-type-more-params-with-defaults.rs
src/test/compile-fail/impl-duplicate-methods.rs
src/test/compile-fail/impl-unused-rps-in-assoc-type.rs
src/test/compile-fail/impl-wrong-item-for-trait.rs
src/test/compile-fail/issue-12187-1.rs
src/test/compile-fail/issue-12187-2.rs
src/test/compile-fail/issue-14092.rs
src/test/compile-fail/issue-15524.rs
src/test/compile-fail/issue-22886.rs
src/test/compile-fail/issue-23024.rs
src/test/compile-fail/issue-23041.rs
src/test/compile-fail/issue-23543.rs
src/test/compile-fail/issue-23544.rs
src/test/compile-fail/issue-23729.rs
src/test/compile-fail/issue-23827.rs
src/test/compile-fail/issue-24356.rs
src/test/compile-fail/issue-26886.rs
src/test/compile-fail/issue-27008.rs
src/test/compile-fail/issue-27340.rs
src/test/compile-fail/issue-33784.rs [new file with mode: 0644]
src/test/compile-fail/issue-34209.rs
src/test/compile-fail/issue-35139.rs
src/test/compile-fail/issue-4335.rs
src/test/compile-fail/issue-5062.rs
src/test/compile-fail/issue-6458-2.rs
src/test/compile-fail/issue-6458-3.rs
src/test/compile-fail/issue-6458-4.rs
src/test/compile-fail/issue-6458.rs
src/test/compile-fail/issue-7813.rs
src/test/compile-fail/method-ambig-one-trait-unknown-int-type.rs
src/test/compile-fail/non-exhaustive-pattern-witness.rs
src/test/compile-fail/qualified-path-params-2.rs
src/test/compile-fail/region-borrow-params-issue-29793-small.rs
src/test/compile-fail/regions-nested-fns-2.rs
src/test/compile-fail/repeat_count.rs
src/test/compile-fail/self-impl.rs
src/test/compile-fail/traits-multidispatch-convert-ambig-dest.rs
src/test/compile-fail/typeck-builtin-bound-type-parameters.rs
src/test/compile-fail/typeck_type_placeholder_item.rs
src/test/compile-fail/typeck_type_placeholder_lifetime_1.rs
src/test/compile-fail/typeck_type_placeholder_lifetime_2.rs
src/test/compile-fail/unboxed-closure-sugar-wrong-trait.rs
src/test/compile-fail/unconstrained-none.rs
src/test/compile-fail/unconstrained-ref.rs
src/test/compile-fail/use-mod.rs
src/test/compile-fail/vector-no-ann.rs
src/test/run-pass/issue-20847.rs [new file with mode: 0644]
src/test/run-pass/slice_binary_search.rs [new file with mode: 0644]

index fa61afd3be582215f26ea7262452c8c177e56f5b..edbc6cea0266499c582036320c4b954489dd328f 100644 (file)
@@ -1,4 +1,4 @@
-.TH RUSTC "1" "August 2015" "rustc 1.2.0" "User Commands"
+.TH RUSTC "1" "August 2016" "rustc 1.12.0" "User Commands"
 .SH NAME
 rustc \- The Rust compiler
 .SH SYNOPSIS
@@ -299,7 +299,7 @@ To build an executable with debug info:
 See https://github.com/rust\-lang/rust/issues for issues.
 
 .SH "AUTHOR"
-See \fIAUTHORS.txt\fR in the Rust source distribution.
+See https://github.com/rust\-lang/rust/graphs/contributors or use `git log --all --format='%cN <%cE>' | sort -u` in the rust source distribution.
 
 .SH "COPYRIGHT"
 This work is dual\[hy]licensed under Apache\ 2.0 and MIT terms.
index ae14c9d78287f3833965b734fb4a846c4b163155..3fb5757f4ff24be21f2cac4ea3312fef2d257b23 100644 (file)
@@ -1,4 +1,4 @@
-.TH RUSTDOC "1" "August 2015" "rustdoc 1.2.0" "User Commands"
+.TH RUSTDOC "1" "August 2016" "rustdoc 1.12.0" "User Commands"
 .SH NAME
 rustdoc \- generate documentation from Rust source code
 .SH SYNOPSIS
index ff2b8cdea22789076a31416392827ecfee6ba742..5cdf4ee88c00cd511016b2620908251d1f0dc126 100644 (file)
@@ -973,8 +973,8 @@ pub fn binary_search(&self, x: &T) -> Result<usize, usize>
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
-    pub fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
-        where F: FnMut(&T) -> Ordering
+    pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
+        where F: FnMut(&'a T) -> Ordering
     {
         core_slice::SliceExt::binary_search_by(self, f)
     }
@@ -1009,8 +1009,8 @@ pub fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
     /// ```
     #[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
     #[inline]
-    pub fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
-        where F: FnMut(&T) -> B,
+    pub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<usize, usize>
+        where F: FnMut(&'a T) -> B,
               B: Ord
     {
         core_slice::SliceExt::binary_search_by_key(self, b, f)
index 06952253ef3b09540017a1211dccd8e75b21bfe5..70b514afd035f1d17d446c0dbbee6f158b1eb950 100644 (file)
@@ -1874,6 +1874,27 @@ fn from(s: String) -> Cow<'a, str> {
     }
 }
 
+#[stable(feature = "cow_str_from_iter", since = "1.12.0")]
+impl<'a> FromIterator<char> for Cow<'a, str> {
+    fn from_iter<I: IntoIterator<Item = char>>(it: I) -> Cow<'a, str> {
+        Cow::Owned(FromIterator::from_iter(it))
+    }
+}
+
+#[stable(feature = "cow_str_from_iter", since = "1.12.0")]
+impl<'a, 'b> FromIterator<&'b str> for Cow<'a, str> {
+    fn from_iter<I: IntoIterator<Item = &'b str>>(it: I) -> Cow<'a, str> {
+        Cow::Owned(FromIterator::from_iter(it))
+    }
+}
+
+#[stable(feature = "cow_str_from_iter", since = "1.12.0")]
+impl<'a> FromIterator<String> for Cow<'a, str> {
+    fn from_iter<I: IntoIterator<Item = String>>(it: I) -> Cow<'a, str> {
+        Cow::Owned(FromIterator::from_iter(it))
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl Into<Vec<u8>> for String {
     fn into(self) -> Vec<u8> {
index 292d72dd362ad5c203497361cd9cda2febfaebc7..4cbabe3f5edafc1036216b05470c7cd7d5478169 100644 (file)
@@ -548,7 +548,7 @@ fn len(&self) -> usize {
     /// assert_eq!(one_element.next(), None);
     /// ```
     #[inline]
-    #[unstable(feature = "exact_size_is_empty", issue = "0")]
+    #[unstable(feature = "exact_size_is_empty", issue = "35428")]
     fn is_empty(&self) -> bool {
         self.len() == 0
     }
index 6b2122451db8fbf164190d84d485a09067229113..a7d0d3899b181d2dd3add95f7bbb46c2bb83ced3 100644 (file)
 /// only designed to be used by unsafe code that needs to manipulate
 /// the low-level details.
 ///
-/// There is no `Repr` implementation for `TraitObject` because there
-/// is no way to refer to all trait objects generically, so the only
+/// There is no way to refer to all trait objects generically, so the only
 /// way to create values of this type is with functions like
-/// `std::mem::transmute`. Similarly, the only way to create a true
+/// [`std::mem::transmute`][transmute]. Similarly, the only way to create a true
 /// trait object from a `TraitObject` value is with `transmute`.
 ///
+/// [transmute]: ../intrinsics/fn.transmute.html
+///
 /// Synthesizing a trait object with mismatched types—one where the
 /// vtable does not correspond to the type of the value to which the
 /// data pointer points—is highly likely to lead to undefined
 /// ```
 /// #![feature(raw)]
 ///
-/// use std::mem;
-/// use std::raw;
+/// use std::{mem, raw};
 ///
 /// // an example trait
 /// trait Foo {
 ///     fn bar(&self) -> i32;
 /// }
+///
 /// impl Foo for i32 {
 ///     fn bar(&self) -> i32 {
 ///          *self + 1
@@ -74,7 +75,6 @@
 /// // the data pointer is the address of `value`
 /// assert_eq!(raw_object.data as *const i32, &value as *const _);
 ///
-///
 /// let other_value: i32 = 456;
 ///
 /// // construct a new object, pointing to a different `i32`, being
 /// let synthesized: &Foo = unsafe {
 ///      mem::transmute(raw::TraitObject {
 ///          data: &other_value as *const _ as *mut (),
-///          vtable: raw_object.vtable
+///          vtable: raw_object.vtable,
 ///      })
 /// };
 ///
-/// // it should work just like we constructed a trait object out of
+/// // it should work just as if we had constructed a trait object out of
 /// // `other_value` directly
 /// assert_eq!(synthesized.bar(), 457);
 /// ```
index d8a11581c3b69be0de75868e938add9a8d135a20..3141c289e931ce0b5e001213edec511ca0dbe996 100644 (file)
@@ -105,11 +105,11 @@ fn rsplitn<P>(&self,  n: usize, pred: P) -> RSplitN<Self::Item, P>
     fn binary_search(&self, x: &Self::Item) -> Result<usize, usize>
         where Self::Item: Ord;
     #[stable(feature = "core", since = "1.6.0")]
-    fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
-        where F: FnMut(&Self::Item) -> Ordering;
+    fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
+        where F: FnMut(&'a Self::Item) -> Ordering;
     #[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
-    fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
-        where F: FnMut(&Self::Item) -> B,
+    fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<usize, usize>
+        where F: FnMut(&'a Self::Item) -> B,
               B: Ord;
     #[stable(feature = "core", since = "1.6.0")]
     fn len(&self) -> usize;
@@ -301,8 +301,8 @@ fn as_ptr(&self) -> *const T {
         self as *const [T] as *const T
     }
 
-    fn binary_search_by<F>(&self, mut f: F) -> Result<usize, usize> where
-        F: FnMut(&T) -> Ordering
+    fn binary_search_by<'a, F>(&'a self, mut f: F) -> Result<usize, usize>
+        where F: FnMut(&'a T) -> Ordering
     {
         let mut base = 0usize;
         let mut s = self;
@@ -514,8 +514,8 @@ fn copy_from_slice(&mut self, src: &[T]) where T: Copy {
     }
 
     #[inline]
-    fn binary_search_by_key<B, F>(&self, b: &B, mut f: F) -> Result<usize, usize>
-        where F: FnMut(&Self::Item) -> B,
+    fn binary_search_by_key<'a, B, F>(&'a self, b: &B, mut f: F) -> Result<usize, usize>
+        where F: FnMut(&'a Self::Item) -> B,
               B: Ord
     {
         self.binary_search_by(|k| f(k).cmp(b))
index 0a5f6884af9bb33fd28d122cbfd7926fe7e670bf..86422835c8cbd0b8d5f1583827eec4503874b17a 100644 (file)
@@ -47,8 +47,9 @@ pub fn prohibit_type_params(self, segments: &[ast::PathSegment]) {
 
     pub fn prohibit_projection(self, span: Span)
     {
-        span_err!(self.sess, span, E0229,
-                  "associated type bindings are not allowed here");
+        let mut err = struct_span_err!(self.sess, span, E0229,
+                                       "associated type bindings are not allowed here");
+        err.span_label(span, &format!("associate type not allowed here")).emit();
     }
 
     pub fn prim_ty_to_ty(self,
index 67ad887530eb318ccabe450784dc9480e11e5297..9950560b13a5a7cda70ccd0d38ccc2fedf6a6c46 100644 (file)
@@ -870,10 +870,12 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
 
 
     fn need_type_info(&self, span: Span, ty: Ty<'tcx>) {
-        span_err!(self.tcx.sess, span, E0282,
-                  "unable to infer enough type information about `{}`; \
-                   type annotations or generic parameter binding required",
-                  ty);
+        let mut err = struct_span_err!(self.tcx.sess, span, E0282,
+                                       "unable to infer enough type information about `{}`",
+                                       ty);
+        err.note("type annotations or generic parameter binding required");
+        err.span_label(span, &format!("cannot infer type for `{}`", ty));
+        err.emit()
     }
 
     fn note_obligation_cause<T>(&self,
index 1fe47cd4853876ae544d568f32e65ac0481ffab2..9115fd42be870e02aec87792b163d02ca5657720 100644 (file)
@@ -942,9 +942,12 @@ fn report_out_of_scope_escaping_closure_capture(&self,
                           but it borrows {}, \
                           which is owned by the current function",
                          cmt_path_or_string)
-            .span_note(capture_span,
+            .span_label(capture_span,
                        &format!("{} is borrowed here",
                                 cmt_path_or_string))
+            .span_label(err.span,
+                       &format!("may outlive borrowed value {}",
+                                cmt_path_or_string))
             .span_suggestion(err.span,
                              &format!("to force the closure to take ownership of {} \
                                        (and any other referenced variables), \
index d148d2a0885ed3375f59da34e09b648967462fc4..599e3ec871a8327cdcc08f18083a042806bd7945 100644 (file)
@@ -235,7 +235,12 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
                 .flat_map(|arm| &arm.0)
                 .map(|pat| vec![wrap_pat(cx, &pat)])
                 .collect();
-            check_exhaustive(cx, ex.span, &matrix, source);
+            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);
         },
         _ => ()
     }
@@ -424,10 +429,15 @@ fn check_exhaustive<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>,
                             format!("`{}` and {} more", head.join("`, `"), tail.len())
                         }
                     };
-                    span_err!(cx.tcx.sess, sp, E0004,
+
+                    let label_text = match pattern_strings.len(){
+                        1 => format!("pattern {} not covered", joined_patterns),
+                        _ => format!("patterns {} not covered", joined_patterns)
+                    };
+                    struct_span_err!(cx.tcx.sess, sp, E0004,
                         "non-exhaustive patterns: {} not covered",
                         joined_patterns
-                    );
+                    ).span_label(sp, &label_text).emit();
                 },
             }
         }
index 45414c33c075448640ef116443fcaf58f23d4e0d..9cdc76f25a63f1a6b77cc446269daa3054b592f7 100644 (file)
@@ -25,8 +25,8 @@
 
 For example, the following `match` block has too many arms:
 
-```compile_fail
-match foo {
+```compile_fail,E0001
+match Some(0) {
     Some(bar) => {/* ... */}
     None => {/* ... */}
     _ => {/* ... */} // All possible cases have already been handled
@@ -108,7 +108,7 @@ fn foo(x: Option<String>) {
 required in order to assign values to match expressions, or alternatively,
 determine the flow of execution. Erroneous code example:
 
-```compile_fail
+```compile_fail,E0004
 enum Terminator {
     HastaLaVistaBaby,
     TalkToMyHand,
@@ -153,7 +153,7 @@ enum Terminator {
 Patterns used to bind names must be irrefutable, that is, they must guarantee
 that a name will be extracted in all cases. Erroneous code example:
 
-```compile_fail
+```compile_fail,E0005
 let x = Some(1);
 let Some(y) = x;
 // error: refutable pattern in local binding: `None` not covered
@@ -187,7 +187,7 @@ enum Terminator {
 moved into a variable called `op_string` while simultaneously requiring the
 inner `String` to be moved into a variable called `s`.
 
-```compile_fail
+```compile_fail,E0007
 let x = Some("s".to_string());
 
 match x {
@@ -205,7 +205,7 @@ enum Terminator {
 referenced in the pattern guard code. Doing so however would prevent the name
 from being available in the body of the match arm. Consider the following:
 
-```compile_fail
+```compile_fail,E0008
 match Some("hi".to_string()) {
     Some(s) if s.len() == 0 => {}, // use s.
     _ => {},
@@ -229,7 +229,7 @@ enum Terminator {
 Though this example seems innocuous and easy to solve, the problem becomes clear
 when it encounters functions which consume the value:
 
-```compile_fail
+```compile_fail,E0008
 struct A{}
 
 impl A {
@@ -283,7 +283,7 @@ fn main() {
 
 Erroneous code example:
 
-```compile_fail
+```compile_fail,E0009
 struct X { x: (), }
 
 let x = Some((X { x: () }, X { x: () }));
@@ -351,25 +351,25 @@ struct X { x: (), }
 match was successful. If the match is irrefutable (when it cannot fail to
 match), use a regular `let`-binding instead. For instance:
 
-```compile_fail
+```compile_fail,E0162
 struct Irrefutable(i32);
 let irr = Irrefutable(0);
 
 // This fails to compile because the match is irrefutable.
 if let Irrefutable(x) = irr {
     // This body will always be executed.
-    foo(x);
+    // ...
 }
 ```
 
 Try this instead:
 
-```ignore
+```
 struct Irrefutable(i32);
 let irr = Irrefutable(0);
 
 let Irrefutable(x) = irr;
-foo(x);
+println!("{}", x);
 ```
 "##,
 
@@ -378,7 +378,7 @@ struct X { x: (), }
 match was successful. If the match is irrefutable (when it cannot fail to
 match), use a regular `let`-binding inside a `loop` instead. For instance:
 
-```compile_fail
+```compile_fail,E0165
 struct Irrefutable(i32);
 let irr = Irrefutable(0);
 
@@ -455,7 +455,7 @@ enum Method { GET, POST }
 loop variable, consider using a `match` or `if let` inside the loop body. For
 instance:
 
-```compile_fail
+```compile_fail,E0297
 let xs : Vec<Option<i32>> = vec!(Some(1), None);
 
 // This fails because `None` is not covered.
@@ -497,7 +497,7 @@ enum Method { GET, POST }
 exhaustive. For instance, the following would not match any arm if mutable
 borrows were allowed:
 
-```compile_fail
+```compile_fail,E0301
 match Some(()) {
     None => { },
     option if option.take().is_none() => {
@@ -515,10 +515,10 @@ enum Method { GET, POST }
 exhaustive. For instance, the following would not match any arm if assignments
 were allowed:
 
-```compile_fail
+```compile_fail,E0302
 match Some(()) {
     None => { },
-    option if { option = None; false } { },
+    option if { option = None; false } => { },
     Some(_) => { } // When the previous match failed, the option became `None`.
 }
 ```
@@ -529,14 +529,18 @@ enum Method { GET, POST }
 Updates to the borrow checker in a future version of Rust may remove this
 restriction, but for now patterns must be rewritten without sub-bindings.
 
-```ignore
-// Before.
+Before:
+
+```compile_fail,E0303
 match Some("hi".to_string()) {
     ref op_string_ref @ Some(s) => {},
     None => {},
 }
+```
+
+After:
 
-// After.
+```
 match Some("hi".to_string()) {
     Some(ref s) => {
         let op_string_ref = &Some(s);
@@ -556,7 +560,7 @@ enum Method { GET, POST }
 constant expression that had to be evaluated. Attempting to divide by 0
 or causing integer overflow are two ways to induce this error. For example:
 
-```compile_fail
+```compile_fail,E0080
 enum Enum {
     X = (1 << 500),
     Y = (1 / 0)
@@ -575,7 +579,7 @@ enum Enum {
 In an array literal `[x; N]`, `N` is the number of elements in the array. This
 must be an unsigned integer. Erroneous code example:
 
-```compile_fail
+```compile_fail,E0306
 let x = [0i32; true]; // error: expected positive integer for repeat count,
                       //        found boolean
 ```
index d424b57c938411168550c1e229c9ff022fca94bf..43d9725baaf004e9e970fb466452d714186a1c87 100644 (file)
@@ -1337,10 +1337,13 @@ pub fn eval_length<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             Ok(val as usize)
         },
         Ok(const_val) => {
-            span_err!(tcx.sess, count_expr.span, E0306,
-                      "expected usize for {}, found {}",
-                      reason,
-                      const_val.description());
+            struct_span_err!(tcx.sess, count_expr.span, E0306,
+                             "expected `usize` for {}, found {}",
+                             reason,
+                             const_val.description())
+                .span_label(count_expr.span, &format!("expected `usize`"))
+                .emit();
+
             Err(ErrorReported)
         }
         Err(err) => {
index 1d00938fb25eb3d2c636fb0097ddf906d020c77d..5455ca62ea46e6eb3a426af70db3a8b5946881a0 100644 (file)
@@ -686,8 +686,10 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>) {
             Rvalue::Box(_) => {
                 self.add(Qualif::NOT_CONST);
                 if self.mode != Mode::Fn {
-                    span_err!(self.tcx.sess, self.span, E0010,
-                              "allocations are not allowed in {}s", self.mode);
+                    struct_span_err!(self.tcx.sess, self.span, E0010,
+                                     "allocations are not allowed in {}s", self.mode)
+                        .span_label(self.span, &format!("allocation not allowed in {}s", self.mode))
+                        .emit();
                 }
             }
 
index d2cf48eddebac2de42b84571262075df045d4af7..91d2500564fd3b7d246f406fcb8d117fb0fede0b 100644 (file)
@@ -38,16 +38,18 @@ fn check_label(&self, label: Ident, span: Span, id: NodeId) {
             self.err_handler().span_err(span, &format!("invalid label name `{}`", label.name));
         }
         if label.name.as_str() == "'_" {
-            self.session.add_lint(
-                lint::builtin::LIFETIME_UNDERSCORE, id, span,
-                format!("invalid label name `{}`", label.name)
-            );
+            self.session.add_lint(lint::builtin::LIFETIME_UNDERSCORE,
+                                  id,
+                                  span,
+                                  format!("invalid label name `{}`", label.name));
         }
     }
 
     fn invalid_visibility(&self, vis: &Visibility, span: Span, note: Option<&str>) {
         if vis != &Visibility::Inherited {
-            let mut err = struct_span_err!(self.session, span, E0449,
+            let mut err = struct_span_err!(self.session,
+                                           span,
+                                           E0449,
                                            "unnecessary visibility qualifier");
             if let Some(note) = note {
                 err.span_note(span, note);
@@ -71,10 +73,10 @@ fn check_decl_no_pat<ReportFn: Fn(Span, bool)>(&self, decl: &FnDecl, report_err:
 impl<'a> Visitor for AstValidator<'a> {
     fn visit_lifetime(&mut self, lt: &Lifetime) {
         if lt.name.as_str() == "'_" {
-            self.session.add_lint(
-                lint::builtin::LIFETIME_UNDERSCORE, lt.id, lt.span,
-                format!("invalid lifetime name `{}`", lt.name)
-            );
+            self.session.add_lint(lint::builtin::LIFETIME_UNDERSCORE,
+                                  lt.id,
+                                  lt.span,
+                                  format!("invalid lifetime name `{}`", lt.name));
         }
 
         visit::walk_lifetime(self, lt)
@@ -82,9 +84,12 @@ fn visit_lifetime(&mut self, lt: &Lifetime) {
 
     fn visit_expr(&mut self, expr: &Expr) {
         match expr.node {
-            ExprKind::While(_, _, Some(ident)) | ExprKind::Loop(_, Some(ident)) |
-            ExprKind::WhileLet(_, _, _, Some(ident)) | ExprKind::ForLoop(_, _, _, Some(ident)) |
-            ExprKind::Break(Some(ident)) | ExprKind::Continue(Some(ident)) => {
+            ExprKind::While(_, _, Some(ident)) |
+            ExprKind::Loop(_, Some(ident)) |
+            ExprKind::WhileLet(_, _, _, Some(ident)) |
+            ExprKind::ForLoop(_, _, _, Some(ident)) |
+            ExprKind::Break(Some(ident)) |
+            ExprKind::Continue(Some(ident)) => {
                 self.check_label(ident.node, ident.span, expr.id);
             }
             _ => {}
@@ -97,10 +102,13 @@ fn visit_ty(&mut self, ty: &Ty) {
         match ty.node {
             TyKind::BareFn(ref bfty) => {
                 self.check_decl_no_pat(&bfty.decl, |span, _| {
-                    let mut err = struct_span_err!(self.session, span, E0561,
-                                            "patterns aren't allowed in function pointer types");
-                    err.span_note(span, "this is a recent error, see \
-                                         issue #35203 for more details");
+                    let mut err = struct_span_err!(self.session,
+                                                   span,
+                                                   E0561,
+                                                   "patterns aren't allowed in function pointer \
+                                                    types");
+                    err.span_note(span,
+                                  "this is a recent error, see issue #35203 for more details");
                     err.emit();
                 });
             }
@@ -114,10 +122,10 @@ fn visit_path(&mut self, path: &Path, id: NodeId) {
         if path.global && path.segments.len() > 0 {
             let ident = path.segments[0].identifier;
             if token::Ident(ident).is_path_segment_keyword() {
-                self.session.add_lint(
-                    lint::builtin::SUPER_OR_SELF_IN_GLOBAL_PATH, id, path.span,
-                    format!("global paths cannot start with `{}`", ident)
-                );
+                self.session.add_lint(lint::builtin::SUPER_OR_SELF_IN_GLOBAL_PATH,
+                                      id,
+                                      path.span,
+                                      format!("global paths cannot start with `{}`", ident));
             }
         }
 
@@ -129,8 +137,8 @@ fn visit_item(&mut self, item: &Item) {
             ItemKind::Use(ref view_path) => {
                 let path = view_path.node.path();
                 if !path.segments.iter().all(|segment| segment.parameters.is_empty()) {
-                    self.err_handler().span_err(path.span, "type or lifetime parameters \
-                                                            in import path");
+                    self.err_handler()
+                        .span_err(path.span, "type or lifetime parameters in import path");
                 }
             }
             ItemKind::Impl(_, _, _, Some(..), _, ref impl_items) => {
@@ -140,15 +148,18 @@ fn visit_item(&mut self, item: &Item) {
                 }
             }
             ItemKind::Impl(_, _, _, None, _, _) => {
-                self.invalid_visibility(&item.vis, item.span, Some("place qualifiers on individual \
-                                                                    impl items instead"));
+                self.invalid_visibility(&item.vis,
+                                        item.span,
+                                        Some("place qualifiers on individual impl items instead"));
             }
             ItemKind::DefaultImpl(..) => {
                 self.invalid_visibility(&item.vis, item.span, None);
             }
             ItemKind::ForeignMod(..) => {
-                self.invalid_visibility(&item.vis, item.span, Some("place qualifiers on individual \
-                                                                    foreign items instead"));
+                self.invalid_visibility(&item.vis,
+                                        item.span,
+                                        Some("place qualifiers on individual foreign items \
+                                              instead"));
             }
             ItemKind::Enum(ref def, _) => {
                 for variant in &def.variants {
@@ -167,11 +178,14 @@ fn visit_foreign_item(&mut self, fi: &ForeignItem) {
         match fi.node {
             ForeignItemKind::Fn(ref decl, _) => {
                 self.check_decl_no_pat(decl, |span, is_recent| {
-                    let mut err = struct_span_err!(self.session, span, E0130,
-                                        "patterns aren't allowed in foreign function declarations");
+                    let mut err = struct_span_err!(self.session,
+                                                   span,
+                                                   E0130,
+                                                   "patterns aren't allowed in foreign function \
+                                                    declarations");
                     if is_recent {
-                        err.span_note(span, "this is a recent error, see \
-                                             issue #35203 for more details");
+                        err.span_note(span,
+                                      "this is a recent error, see issue #35203 for more details");
                     }
                     err.emit();
                 });
@@ -182,16 +196,21 @@ fn visit_foreign_item(&mut self, fi: &ForeignItem) {
         visit::walk_foreign_item(self, fi)
     }
 
-    fn visit_variant_data(&mut self, vdata: &VariantData, _: Ident,
-                          _: &Generics, _: NodeId, span: Span) {
+    fn visit_variant_data(&mut self,
+                          vdata: &VariantData,
+                          _: Ident,
+                          _: &Generics,
+                          _: NodeId,
+                          span: Span) {
         if vdata.fields().is_empty() {
             if vdata.is_tuple() {
-                self.err_handler().struct_span_err(span, "empty tuple structs and enum variants \
-                                                          are not allowed, use unit structs and \
-                                                          enum variants instead")
-                                         .span_help(span, "remove trailing `()` to make a unit \
-                                                           struct or unit enum variant")
-                                         .emit();
+                self.err_handler()
+                    .struct_span_err(span,
+                                     "empty tuple structs and enum variants are not allowed, use \
+                                      unit structs and enum variants instead")
+                    .span_help(span,
+                               "remove trailing `()` to make a unit struct or unit enum variant")
+                    .emit();
             }
         }
 
@@ -200,10 +219,10 @@ struct or unit enum variant")
 
     fn visit_vis(&mut self, vis: &Visibility) {
         match *vis {
-            Visibility::Restricted{ref path, ..} => {
+            Visibility::Restricted { ref path, .. } => {
                 if !path.segments.iter().all(|segment| segment.parameters.is_empty()) {
-                    self.err_handler().span_err(path.span, "type or lifetime parameters \
-                                                            in visibility path");
+                    self.err_handler()
+                        .span_err(path.span, "type or lifetime parameters in visibility path");
                 }
             }
             _ => {}
index 1030a4b0116de5a07572ffa53fa974d909f4b6b7..fc55118c9f4c518ed0fa989067cf40f95f580f9e 100644 (file)
@@ -25,7 +25,7 @@
 // by borrowck::gather_loans
 
 use rustc::dep_graph::DepNode;
-use rustc::ty::cast::{CastKind};
+use rustc::ty::cast::CastKind;
 use rustc_const_eval::{ConstEvalErr, lookup_const_fn_by_id, compare_lit_exprs};
 use rustc_const_eval::{eval_const_expr_partial, lookup_const_by_id};
 use rustc_const_eval::ErrKind::{IndexOpFeatureGated, UnimplementedConstVal, MiscCatchAll, Math};
@@ -71,12 +71,12 @@ struct CheckCrateVisitor<'a, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     mode: Mode,
     qualif: ConstQualif,
-    rvalue_borrows: NodeMap<hir::Mutability>
+    rvalue_borrows: NodeMap<hir::Mutability>,
 }
 
 impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
-    fn with_mode<F, R>(&mut self, mode: Mode, f: F) -> R where
-        F: FnOnce(&mut CheckCrateVisitor<'a, 'gcx>) -> R,
+    fn with_mode<F, R>(&mut self, mode: Mode, f: F) -> R
+        where F: FnOnce(&mut CheckCrateVisitor<'a, 'gcx>) -> R
     {
         let (old_mode, old_qualif) = (self.mode, self.qualif);
         self.mode = mode;
@@ -87,17 +87,17 @@ fn with_mode<F, R>(&mut self, mode: Mode, f: F) -> R where
         r
     }
 
-    fn with_euv<F, R>(&mut self, item_id: Option<ast::NodeId>, f: F) -> R where
-        F: for<'b, 'tcx> FnOnce(&mut euv::ExprUseVisitor<'b, 'gcx, 'tcx>) -> R,
+    fn with_euv<F, R>(&mut self, item_id: Option<ast::NodeId>, f: F) -> R
+        where F: for<'b, 'tcx> FnOnce(&mut euv::ExprUseVisitor<'b, 'gcx, 'tcx>) -> R
     {
         let param_env = match item_id {
             Some(item_id) => ty::ParameterEnvironment::for_item(self.tcx, item_id),
-            None => self.tcx.empty_parameter_environment()
+            None => self.tcx.empty_parameter_environment(),
         };
 
-        self.tcx.infer_ctxt(None, Some(param_env), ProjectionMode::AnyFinal).enter(|infcx| {
-            f(&mut euv::ExprUseVisitor::new(self, &infcx))
-        })
+        self.tcx
+            .infer_ctxt(None, Some(param_env), ProjectionMode::AnyFinal)
+            .enter(|infcx| f(&mut euv::ExprUseVisitor::new(self, &infcx)))
     }
 
     fn global_expr(&mut self, mode: Mode, expr: &hir::Expr) -> ConstQualif {
@@ -111,13 +111,17 @@ fn global_expr(&mut self, mode: Mode, expr: &hir::Expr) -> ConstQualif {
         }
         if let Err(err) = eval_const_expr_partial(self.tcx, expr, ExprTypeChecked, None) {
             match err.kind {
-                UnimplementedConstVal(_) => {},
-                IndexOpFeatureGated => {},
-                ErroneousReferencedConstant(_) => {},
-                _ => self.tcx.sess.add_lint(CONST_ERR, expr.id, expr.span,
-                                         format!("constant evaluation error: {}. This will \
-                                                 become a HARD ERROR in the future",
-                                                 err.description().into_oneline())),
+                UnimplementedConstVal(_) => {}
+                IndexOpFeatureGated => {}
+                ErroneousReferencedConstant(_) => {}
+                _ => {
+                    self.tcx.sess.add_lint(CONST_ERR,
+                                           expr.id,
+                                           expr.span,
+                                           format!("constant evaluation error: {}. This will \
+                                                    become a HARD ERROR in the future",
+                                                   err.description().into_oneline()))
+                }
             }
         }
         self.with_mode(mode, |this| {
@@ -143,9 +147,7 @@ fn fn_like(&mut self,
         }
 
         let mode = match fk {
-            FnKind::ItemFn(_, _, _, hir::Constness::Const, _, _, _) => {
-                Mode::ConstFn
-            }
+            FnKind::ItemFn(_, _, _, hir::Constness::Const, _, _, _) => Mode::ConstFn,
             FnKind::Method(_, m, _, _) => {
                 if m.constness == hir::Constness::Const {
                     Mode::ConstFn
@@ -153,7 +155,7 @@ fn fn_like(&mut self,
                     Mode::Var
                 }
             }
-            _ => Mode::Var
+            _ => Mode::Var,
         };
 
         let qualif = self.with_mode(mode, |this| {
@@ -175,11 +177,7 @@ fn add_qualif(&mut self, qualif: ConstQualif) {
     }
 
     /// Returns true if the call is to a const fn or method.
-    fn handle_const_fn_call(&mut self,
-                            _expr: &hir::Expr,
-                            def_id: DefId,
-                            ret_ty: Ty<'gcx>)
-                            -> bool {
+    fn handle_const_fn_call(&mut self, _expr: &hir::Expr, def_id: DefId, ret_ty: Ty<'gcx>) -> bool {
         if let Some(fn_like) = lookup_const_fn_by_id(self.tcx, def_id) {
             let qualif = self.fn_like(fn_like.kind(),
                                       fn_like.decl(),
@@ -285,13 +283,15 @@ fn visit_pat(&mut self, p: &hir::Pat) {
                     Ok(Ordering::Less) |
                     Ok(Ordering::Equal) => {}
                     Ok(Ordering::Greater) => {
-                        span_err!(self.tcx.sess, start.span, E0030,
-                            "lower range bound must be less than or equal to upper");
+                        span_err!(self.tcx.sess,
+                                  start.span,
+                                  E0030,
+                                  "lower range bound must be less than or equal to upper");
                     }
                     Err(ErrorReported) => {}
                 }
             }
-            _ => intravisit::walk_pat(self, p)
+            _ => intravisit::walk_pat(self, p),
         }
     }
 
@@ -301,13 +301,13 @@ fn visit_block(&mut self, block: &hir::Block) {
             match stmt.node {
                 hir::StmtDecl(ref decl, _) => {
                     match decl.node {
-                        hir::DeclLocal(_) => {},
+                        hir::DeclLocal(_) => {}
                         // Item statements are allowed
-                        hir::DeclItem(_) => continue
+                        hir::DeclItem(_) => continue,
                     }
                 }
-                hir::StmtExpr(_, _) => {},
-                hir::StmtSemi(_, _) => {},
+                hir::StmtExpr(_, _) => {}
+                hir::StmtSemi(_, _) => {}
             }
             self.add_qualif(ConstQualif::NOT_CONST);
         }
@@ -340,7 +340,7 @@ fn visit_expr(&mut self, ex: &hir::Expr) {
                 // The count is checked elsewhere (typeck).
                 let count = match node_ty.sty {
                     ty::TyArray(_, n) => n,
-                    _ => bug!()
+                    _ => bug!(),
                 };
                 // [element; 0] is always zero-sized.
                 if count == 0 {
@@ -354,7 +354,8 @@ fn visit_expr(&mut self, ex: &hir::Expr) {
                 for pat in arms.iter().flat_map(|arm| &arm.pats) {
                     let pat_borrow = self.rvalue_borrows.remove(&pat.id);
                     match (borrow, pat_borrow) {
-                        (None, _) | (_, Some(hir::MutMutable)) => {
+                        (None, _) |
+                        (_, Some(hir::MutMutable)) => {
                             borrow = pat_borrow;
                         }
                         _ => {}
@@ -365,7 +366,7 @@ fn visit_expr(&mut self, ex: &hir::Expr) {
                 }
                 intravisit::walk_expr(self, ex);
             }
-            _ => intravisit::walk_expr(self, ex)
+            _ => intravisit::walk_expr(self, ex),
         }
 
         // Handle borrows on (or inside the autorefs of) this expression.
@@ -405,17 +406,18 @@ fn visit_expr(&mut self, ex: &hir::Expr) {
         if self.mode == Mode::Var && !self.qualif.intersects(ConstQualif::NOT_CONST) {
             match eval_const_expr_partial(self.tcx, ex, ExprTypeChecked, None) {
                 Ok(_) => {}
-                Err(ConstEvalErr { kind: UnimplementedConstVal(_), ..}) |
-                Err(ConstEvalErr { kind: MiscCatchAll, ..}) |
-                Err(ConstEvalErr { kind: MiscBinaryOp, ..}) |
-                Err(ConstEvalErr { kind: NonConstPath, ..}) |
-                Err(ConstEvalErr { kind: UnresolvedPath, ..}) |
-                Err(ConstEvalErr { kind: ErroneousReferencedConstant(_), ..}) |
-                Err(ConstEvalErr { kind: Math(ConstMathErr::Overflow(Op::Shr)), ..}) |
-                Err(ConstEvalErr { kind: Math(ConstMathErr::Overflow(Op::Shl)), ..}) |
-                Err(ConstEvalErr { kind: IndexOpFeatureGated, ..}) => {},
+                Err(ConstEvalErr { kind: UnimplementedConstVal(_), .. }) |
+                Err(ConstEvalErr { kind: MiscCatchAll, .. }) |
+                Err(ConstEvalErr { kind: MiscBinaryOp, .. }) |
+                Err(ConstEvalErr { kind: NonConstPath, .. }) |
+                Err(ConstEvalErr { kind: UnresolvedPath, .. }) |
+                Err(ConstEvalErr { kind: ErroneousReferencedConstant(_), .. }) |
+                Err(ConstEvalErr { kind: Math(ConstMathErr::Overflow(Op::Shr)), .. }) |
+                Err(ConstEvalErr { kind: Math(ConstMathErr::Overflow(Op::Shl)), .. }) |
+                Err(ConstEvalErr { kind: IndexOpFeatureGated, .. }) => {}
                 Err(msg) => {
-                    self.tcx.sess.add_lint(CONST_ERR, ex.id,
+                    self.tcx.sess.add_lint(CONST_ERR,
+                                           ex.id,
                                            msg.span,
                                            msg.description().into_oneline().into_owned())
                 }
@@ -434,8 +436,7 @@ fn visit_expr(&mut self, ex: &hir::Expr) {
 /// every nested expression. If the expression is not part
 /// of a const/static item, it is qualified for promotion
 /// instead of producing errors.
-fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
-                        e: &hir::Expr, node_ty: Ty<'tcx>) {
+fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node_ty: Ty<'tcx>) {
     match node_ty.sty {
         ty::TyStruct(def, _) |
         ty::TyEnum(def, _) if def.has_dtor() => {
@@ -635,12 +636,9 @@ fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Exp
         Some(&ty::adjustment::AdjustUnsafeFnPointer) |
         Some(&ty::adjustment::AdjustMutToConstPointer) => {}
 
-        Some(&ty::adjustment::AdjustDerefRef(
-            ty::adjustment::AutoDerefRef { autoderefs, .. }
-        )) => {
-            if (0..autoderefs as u32).any(|autoderef| {
-                    v.tcx.is_overloaded_autoderef(e.id, autoderef)
-            }) {
+        Some(&ty::adjustment::AdjustDerefRef(ty::adjustment::AutoDerefRef { autoderefs, .. })) => {
+            if (0..autoderefs as u32)
+                .any(|autoderef| v.tcx.is_overloaded_autoderef(e.id, autoderef)) {
                 v.add_qualif(ConstQualif::NOT_CONST);
             }
         }
@@ -648,12 +646,13 @@ fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Exp
 }
 
 pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
-    tcx.visit_all_items_in_krate(DepNode::CheckConst, &mut CheckCrateVisitor {
-        tcx: tcx,
-        mode: Mode::Var,
-        qualif: ConstQualif::NOT_CONST,
-        rvalue_borrows: NodeMap()
-    });
+    tcx.visit_all_items_in_krate(DepNode::CheckConst,
+                                 &mut CheckCrateVisitor {
+                                     tcx: tcx,
+                                     mode: Mode::Var,
+                                     qualif: ConstQualif::NOT_CONST,
+                                     rvalue_borrows: NodeMap(),
+                                 });
     tcx.sess.abort_if_errors();
 }
 
@@ -675,7 +674,7 @@ fn consume(&mut self,
 
                 Categorization::Rvalue(..) |
                 Categorization::Upvar(..) |
-                Categorization::Local(..) => break
+                Categorization::Local(..) => break,
             }
         }
     }
@@ -685,8 +684,7 @@ fn borrow(&mut self,
               cmt: mc::cmt<'tcx>,
               _loan_region: ty::Region,
               bk: ty::BorrowKind,
-              loan_cause: euv::LoanCause)
-    {
+              loan_cause: euv::LoanCause) {
         // Kind of hacky, but we allow Unsafe coercions in constants.
         // These occur when we convert a &T or *T to a *U, as well as
         // when making a thin pointer (e.g., `*T`) into a fat pointer
@@ -695,7 +693,7 @@ fn borrow(&mut self,
             euv::LoanCause::AutoUnsafe => {
                 return;
             }
-            _ => { }
+            _ => {}
         }
 
         let mut cur = &cmt;
@@ -715,7 +713,8 @@ fn borrow(&mut self,
                         // type of the expression.  `&mut [1]` has exactly the
                         // same representation as &mut 1.
                         match cmt.ty.sty {
-                            ty::TyArray(_, _) | ty::TySlice(_) => break,
+                            ty::TyArray(_, _) |
+                            ty::TySlice(_) => break,
                             _ => {}
                         }
                     }
@@ -732,27 +731,20 @@ fn borrow(&mut self,
                 }
 
                 Categorization::Upvar(..) |
-                Categorization::Local(..) => break
+                Categorization::Local(..) => break,
             }
         }
     }
 
-    fn decl_without_init(&mut self,
-                         _id: ast::NodeId,
-                         _span: Span) {}
+    fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
     fn mutate(&mut self,
               _assignment_id: ast::NodeId,
               _assignment_span: Span,
               _assignee_cmt: mc::cmt,
-              _mode: euv::MutateMode) {}
+              _mode: euv::MutateMode) {
+    }
 
-    fn matched_pat(&mut self,
-                   _: &hir::Pat,
-                   _: mc::cmt,
-                   _: euv::MatchMode) {}
+    fn matched_pat(&mut self, _: &hir::Pat, _: mc::cmt, _: euv::MatchMode) {}
 
-    fn consume_pat(&mut self,
-                   _consume_pat: &hir::Pat,
-                   _cmt: mc::cmt,
-                   _mode: euv::ConsumeMode) {}
+    fn consume_pat(&mut self, _consume_pat: &hir::Pat, _cmt: mc::cmt, _mode: euv::ConsumeMode) {}
 }
index 3e2dd477bccf089f0e40b0598246ce9c120b39e2..7049040678e39f706499e9a7cc920dfe89f797aa 100644 (file)
@@ -121,11 +121,11 @@ fn main() {
 
 For example, neither of the following can be sensibly compiled:
 
-```compile_fail
+```compile_fail,E0265
 const X: u32 = X;
 ```
 
-```compile_fail
+```compile_fail,E0265
 const X: u32 = Y;
 const Y: u32 = X;
 ```
@@ -135,7 +135,7 @@ fn main() {
 This error indicates the use of a loop keyword (`break` or `continue`) inside a
 closure but outside of any loop. Erroneous code example:
 
-```compile_fail
+```compile_fail,E0267
 let w = || { break; }; // error: `break` inside of a closure
 ```
 
@@ -159,7 +159,7 @@ fn main() {
 of a loop. Without a loop to break out of or continue in, no sensible action can
 be taken. Erroneous code example:
 
-```compile_fail
+```compile_fail,E0268
 fn some_func() {
     break; // error: `break` outside of loop
 }
index 650613f4844f526facb139225cc39d3a8a46e1e4..e59c4a6fc4186bfbb9664dcf7042a630ce574de9 100644 (file)
 #![feature(rustc_private)]
 
 extern crate core;
-#[macro_use] extern crate rustc;
+#[macro_use]
+extern crate rustc;
 extern crate rustc_const_eval;
 extern crate rustc_const_math;
 
-#[macro_use] extern crate log;
-#[macro_use] extern crate syntax;
+#[macro_use]
+extern crate log;
+#[macro_use]
+extern crate syntax;
 extern crate syntax_pos;
 extern crate rustc_errors as errors;
 
index dd0f16baaa395d524e6e91bf2abdcb3dbe5e0d65..4e251793f6917ae645fc6c14c7581aa26c3f658d 100644 (file)
 
 #[derive(Clone, Copy, PartialEq)]
 enum Context {
-    Normal, Loop, Closure
+    Normal,
+    Loop,
+    Closure,
 }
 
 #[derive(Copy, Clone)]
 struct CheckLoopVisitor<'a> {
     sess: &'a Session,
-    cx: Context
+    cx: Context,
 }
 
 pub fn check_crate(sess: &Session, map: &Map) {
     let _task = map.dep_graph.in_task(DepNode::CheckLoops);
     let krate = map.krate();
-    krate.visit_all_items(&mut CheckLoopVisitor { sess: sess, cx: Normal });
+    krate.visit_all_items(&mut CheckLoopVisitor {
+        sess: sess,
+        cx: Normal,
+    });
 }
 
 impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
@@ -53,14 +58,14 @@ fn visit_expr(&mut self, e: &hir::Expr) {
             }
             hir::ExprBreak(_) => self.require_loop("break", e.span),
             hir::ExprAgain(_) => self.require_loop("continue", e.span),
-            _ => intravisit::walk_expr(self, e)
+            _ => intravisit::walk_expr(self, e),
         }
     }
 }
 
 impl<'a> CheckLoopVisitor<'a> {
-    fn with_context<F>(&mut self, cx: Context, f: F) where
-        F: FnOnce(&mut CheckLoopVisitor<'a>),
+    fn with_context<F>(&mut self, cx: Context, f: F)
+        where F: FnOnce(&mut CheckLoopVisitor<'a>)
     {
         let old_cx = self.cx;
         self.cx = cx;
@@ -72,12 +77,10 @@ fn require_loop(&self, name: &str, span: Span) {
         match self.cx {
             Loop => {}
             Closure => {
-                span_err!(self.sess, span, E0267,
-                                   "`{}` inside of a closure", name);
+                span_err!(self.sess, span, E0267, "`{}` inside of a closure", name);
             }
             Normal => {
-                span_err!(self.sess, span, E0268,
-                                   "`{}` outside of loop", name);
+                span_err!(self.sess, span, E0268, "`{}` outside of loop", name);
             }
         }
     }
index 314513a974ecdb826b728523403a5056c635a062..af3065d64e8db08bc7fd8ee36cca33a93971fff3 100644 (file)
 use syntax::visit;
 
 pub fn check_crate(sess: &Session, krate: &ast::Crate) {
-    if sess.target.target.options.allow_asm { return; }
+    if sess.target.target.options.allow_asm {
+        return;
+    }
 
-    visit::walk_crate(&mut CheckNoAsm { sess: sess, }, krate);
+    visit::walk_crate(&mut CheckNoAsm { sess: sess }, krate);
 }
 
 #[derive(Copy, Clone)]
@@ -32,9 +34,13 @@ struct CheckNoAsm<'a> {
 impl<'a> Visitor for CheckNoAsm<'a> {
     fn visit_expr(&mut self, e: &ast::Expr) {
         match e.node {
-            ast::ExprKind::InlineAsm(_) => span_err!(self.sess, e.span, E0472,
-                                                     "asm! is unsupported on this target"),
-            _ => {},
+            ast::ExprKind::InlineAsm(_) => {
+                span_err!(self.sess,
+                          e.span,
+                          E0472,
+                          "asm! is unsupported on this target")
+            }
+            _ => {}
         }
         visit::walk_expr(self, e)
     }
index d0938ad09a0da1bced4e17ef57d5c1c1096c97fe..8b2943a33c006aaced7fd7cee377a241ff187467 100644 (file)
 
 use rustc::dep_graph::DepNode;
 use rustc::hir::map as ast_map;
-use rustc::session::{Session, CompileResult};
+use rustc::session::{CompileResult, Session};
 use rustc::hir::def::{Def, DefMap};
 use rustc::util::nodemap::NodeMap;
 
-use syntax::{ast};
+use syntax::ast;
 use syntax::feature_gate::{GateIssue, emit_feature_err};
 use syntax_pos::Span;
 use rustc::hir::intravisit::{self, Visitor};
@@ -41,18 +41,17 @@ fn visit_item(&mut self, it: &'ast hir::Item) {
         match it.node {
             hir::ItemStatic(..) |
             hir::ItemConst(..) => {
-                let mut recursion_visitor =
-                    CheckItemRecursionVisitor::new(self, &it.span);
+                let mut recursion_visitor = CheckItemRecursionVisitor::new(self, &it.span);
                 recursion_visitor.visit_item(it);
-            },
+            }
             hir::ItemEnum(ref enum_def, ref generics) => {
                 // We could process the whole enum, but handling the variants
                 // with discriminant expressions one by one gives more specific,
                 // less redundant output.
                 for variant in &enum_def.variants {
                     if let Some(_) = variant.node.disr_expr {
-                        let mut recursion_visitor =
-                            CheckItemRecursionVisitor::new(self, &variant.span);
+                        let mut recursion_visitor = CheckItemRecursionVisitor::new(self,
+                                                                                   &variant.span);
                         recursion_visitor.populate_enum_discriminants(enum_def);
                         recursion_visitor.visit_variant(variant, generics, it.id);
                     }
@@ -67,8 +66,7 @@ fn visit_trait_item(&mut self, ti: &'ast hir::TraitItem) {
         match ti.node {
             hir::ConstTraitItem(_, ref default) => {
                 if let Some(_) = *default {
-                    let mut recursion_visitor =
-                        CheckItemRecursionVisitor::new(self, &ti.span);
+                    let mut recursion_visitor = CheckItemRecursionVisitor::new(self, &ti.span);
                     recursion_visitor.visit_trait_item(ti);
                 }
             }
@@ -80,8 +78,7 @@ fn visit_trait_item(&mut self, ti: &'ast hir::TraitItem) {
     fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) {
         match ii.node {
             hir::ImplItemKind::Const(..) => {
-                let mut recursion_visitor =
-                    CheckItemRecursionVisitor::new(self, &ii.span);
+                let mut recursion_visitor = CheckItemRecursionVisitor::new(self, &ii.span);
                 recursion_visitor.visit_impl_item(ii);
             }
             _ => {}
@@ -117,7 +114,8 @@ struct CheckItemRecursionVisitor<'a, 'ast: 'a> {
 }
 
 impl<'a, 'ast: 'a> CheckItemRecursionVisitor<'a, 'ast> {
-    fn new(v: &'a CheckCrateVisitor<'a, 'ast>, span: &'a Span)
+    fn new(v: &'a CheckCrateVisitor<'a, 'ast>,
+           span: &'a Span)
            -> CheckItemRecursionVisitor<'a, 'ast> {
         CheckItemRecursionVisitor {
             root_span: span,
@@ -129,7 +127,8 @@ fn new(v: &'a CheckCrateVisitor<'a, 'ast>, span: &'a Span)
         }
     }
     fn with_item_id_pushed<F>(&mut self, id: ast::NodeId, f: F)
-          where F: Fn(&mut Self) {
+        where F: Fn(&mut Self)
+    {
         if self.idstack.iter().any(|&x| x == id) {
             let any_static = self.idstack.iter().any(|&x| {
                 if let ast_map::NodeItem(item) = self.ast_map.get(x) {
@@ -146,7 +145,9 @@ fn with_item_id_pushed<F>(&mut self, id: ast::NodeId, f: F)
                 if !self.sess.features.borrow().static_recursion {
                     emit_feature_err(&self.sess.parse_sess.span_diagnostic,
                                      "static_recursion",
-                                     *self.root_span, GateIssue::Language, "recursive static");
+                                     *self.root_span,
+                                     GateIssue::Language,
+                                     "recursive static");
                 }
             } else {
                 span_err!(self.sess, *self.root_span, E0265, "recursive constant");
@@ -170,7 +171,9 @@ fn populate_enum_discriminants(&self, enum_definition: &'ast hir::EnumDef) {
         // has no variants.
         let mut discriminant_map = self.discriminant_map.borrow_mut();
         match enum_definition.variants.first() {
-            None => { return; }
+            None => {
+                return;
+            }
             Some(variant) if discriminant_map.contains_key(&variant.node.data.id()) => {
                 return;
             }
@@ -203,14 +206,19 @@ fn visit_item(&mut self, it: &'ast hir::Item) {
         self.with_item_id_pushed(it.id, |v| intravisit::walk_item(v, it));
     }
 
-    fn visit_enum_def(&mut self, enum_definition: &'ast hir::EnumDef,
-                      generics: &'ast hir::Generics, item_id: ast::NodeId, _: Span) {
+    fn visit_enum_def(&mut self,
+                      enum_definition: &'ast hir::EnumDef,
+                      generics: &'ast hir::Generics,
+                      item_id: ast::NodeId,
+                      _: Span) {
         self.populate_enum_discriminants(enum_definition);
         intravisit::walk_enum_def(self, enum_definition, generics, item_id);
     }
 
-    fn visit_variant(&mut self, variant: &'ast hir::Variant,
-                     _: &'ast hir::Generics, _: ast::NodeId) {
+    fn visit_variant(&mut self,
+                     variant: &'ast hir::Variant,
+                     _: &'ast hir::Generics,
+                     _: ast::NodeId) {
         let variant_id = variant.node.data.id();
         let maybe_expr;
         if let Some(get_expr) = self.discriminant_map.borrow().get(&variant_id) {
@@ -246,18 +254,14 @@ fn visit_expr(&mut self, e: &'ast hir::Expr) {
                     Some(Def::Const(def_id)) => {
                         if let Some(node_id) = self.ast_map.as_local_node_id(def_id) {
                             match self.ast_map.get(node_id) {
-                                ast_map::NodeItem(item) =>
-                                    self.visit_item(item),
-                                ast_map::NodeTraitItem(item) =>
-                                    self.visit_trait_item(item),
-                                ast_map::NodeImplItem(item) =>
-                                    self.visit_impl_item(item),
-                                ast_map::NodeForeignItem(_) => {},
+                                ast_map::NodeItem(item) => self.visit_item(item),
+                                ast_map::NodeTraitItem(item) => self.visit_trait_item(item),
+                                ast_map::NodeImplItem(item) => self.visit_impl_item(item),
+                                ast_map::NodeForeignItem(_) => {}
                                 _ => {
-                                    span_bug!(
-                                        e.span,
-                                        "expected item, found {}",
-                                        self.ast_map.node_to_string(node_id));
+                                    span_bug!(e.span,
+                                              "expected item, found {}",
+                                              self.ast_map.node_to_string(node_id));
                                 }
                             }
                         }
@@ -268,9 +272,9 @@ fn visit_expr(&mut self, e: &'ast hir::Expr) {
                     // might be (if any).
                     Some(Def::Variant(enum_id, variant_id)) => {
                         if let Some(enum_node_id) = self.ast_map.as_local_node_id(enum_id) {
-                            if let hir::ItemEnum(ref enum_def, ref generics) =
-                                self.ast_map.expect_item(enum_node_id).node
-                            {
+                            if let hir::ItemEnum(ref enum_def, ref generics) = self.ast_map
+                                .expect_item(enum_node_id)
+                                .node {
                                 self.populate_enum_discriminants(enum_def);
                                 let enum_id = self.ast_map.as_local_node_id(enum_id).unwrap();
                                 let variant_id = self.ast_map.as_local_node_id(variant_id).unwrap();
@@ -283,10 +287,10 @@ fn visit_expr(&mut self, e: &'ast hir::Expr) {
                             }
                         }
                     }
-                    _ => ()
+                    _ => (),
                 }
-            },
-            _ => ()
+            }
+            _ => (),
         }
         intravisit::walk_expr(self, e);
     }
index 3e860150a35fdfbe3f2379e81cc727f3783f4778..11ef75ee6a8fc4fcc90596feebccca7687c16fb0 100644 (file)
@@ -146,6 +146,7 @@ pub trait MyTrait {
 }
 
 use foo::MyTrait::do_something;
+// error: `do_something` is not directly importable
 
 fn main() {}
 ```
@@ -153,6 +154,45 @@ fn main() {}
 It's invalid to directly import methods belonging to a trait or concrete type.
 "##,
 
+E0254: r##"
+Attempt was made to import an item whereas an extern crate with this name has
+already been imported.
+
+Erroneous code example:
+
+```compile_fail,E0254
+extern crate collections;
+
+mod foo {
+    pub trait collections {
+        fn do_something();
+    }
+}
+
+use foo::collections; // error: an extern crate named `collections` has already
+                      //        been imported in this module
+
+fn main() {}
+```
+
+To fix issue issue, you have to rename at least one of the two imports.
+Example:
+
+```ignore
+extern crate collections as libcollections; // ok!
+
+mod foo {
+    pub trait collections {
+        fn do_something();
+    }
+}
+
+use foo::collections;
+
+fn main() {}
+```
+"##,
+
 E0255: r##"
 You can't import a value whose name is the same as another value defined in the
 module.
@@ -1237,7 +1277,6 @@ impl Foo for i32 {}
 register_diagnostics! {
 //  E0153, unused error code
 //  E0157, unused error code
-    E0254, // import conflicts with imported crate in this module
 //  E0257,
 //  E0258,
     E0402, // cannot use an outer type parameter in this context
index befe328591121e2bb45b82c28b998c3448e6ea04..9f1f07004f4aecc9978fefb658e20a85a3b3fbbf 100644 (file)
@@ -3375,7 +3375,11 @@ fn report_conflict(&self,
             (true, _) | (_, true) => struct_span_err!(self.session, span, E0260, "{}", msg),
             _ => match (old_binding.is_import(), binding.is_import()) {
                 (false, false) => struct_span_err!(self.session, span, E0428, "{}", msg),
-                (true, true) => struct_span_err!(self.session, span, E0252, "{}", msg),
+                (true, true) => {
+                    let mut e = struct_span_err!(self.session, span, E0252, "{}", msg);
+                    e.span_label(span, &format!("already imported"));
+                    e
+                },
                 _ => {
                     let mut e = struct_span_err!(self.session, span, E0255, "{}", msg);
                     e.span_label(span, &format!("`{}` was already imported", name));
index a11df5ae05d6fca6e56f74db4e67c04ede6d847a..b4e9fb5c65bb3576417b53469e454c262a249830 100644 (file)
@@ -310,8 +310,12 @@ pub fn opt_ast_region_to_region(&self,
             None => match rscope.anon_regions(default_span, 1) {
                 Ok(rs) => rs[0],
                 Err(params) => {
-                    let mut err = struct_span_err!(self.tcx().sess, default_span, E0106,
-                                                   "missing lifetime specifier");
+                    let ampersand_span = Span { hi: default_span.lo, ..default_span};
+
+                    let mut err = struct_span_err!(self.tcx().sess, ampersand_span, E0106,
+                                                 "missing lifetime specifier");
+                    err.span_label(ampersand_span, &format!("expected lifetime parameter"));
+
                     if let Some(params) = params {
                         report_elision_failure(&mut err, params);
                     }
@@ -1211,10 +1215,12 @@ fn report_ambiguous_associated_type(&self,
                                         type_str: &str,
                                         trait_str: &str,
                                         name: &str) {
-        span_err!(self.tcx().sess, span, E0223,
-                  "ambiguous associated type; specify the type using the syntax \
-                   `<{} as {}>::{}`",
-                  type_str, trait_str, name);
+        struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type")
+            .span_label(span, &format!("ambiguous associated type"))
+            .note(&format!("specify the type using the syntax `<{} as {}>::{}`",
+                  type_str, trait_str, name))
+            .emit();
+
     }
 
     // Search for a bound on a type parameter which includes the associated item
@@ -2091,8 +2097,11 @@ pub fn conv_existential_bounds_from_partitioned_bounds(&self,
 
         if !trait_bounds.is_empty() {
             let b = &trait_bounds[0];
-            span_err!(self.tcx().sess, b.trait_ref.path.span, E0225,
-                      "only the builtin traits can be used as closure or object bounds");
+            let span = b.trait_ref.path.span;
+            struct_span_err!(self.tcx().sess, span, E0225,
+                             "only the builtin traits can be used as closure or object bounds")
+                .span_label(span, &format!("non-builtin trait used as bounds"))
+                .emit();
         }
 
         let region_bound =
@@ -2251,27 +2260,50 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
         } else {
             "expected"
         };
-        span_err!(tcx.sess, span, E0243,
-                  "wrong number of type arguments: {} {}, found {}",
-                  expected, required, supplied);
+        struct_span_err!(tcx.sess, span, E0243, "wrong number of type arguments")
+            .span_label(
+                span,
+                &format!("{} {} type arguments, found {}", expected, required, supplied)
+            )
+            .emit();
     } else if supplied > accepted {
-        let expected = if required < accepted {
-            "expected at most"
+        let expected = if required == 0 {
+            "expected no".to_string()
+        } else if required < accepted {
+            format!("expected at most {}", accepted)
         } else {
-            "expected"
+            format!("expected {}", accepted)
         };
-        span_err!(tcx.sess, span, E0244,
-                  "wrong number of type arguments: {} {}, found {}",
-                  expected,
-                  accepted,
-                  supplied);
+
+        struct_span_err!(tcx.sess, span, E0244, "wrong number of type arguments")
+            .span_label(
+                span,
+                &format!("{} type arguments, found {}", expected, supplied)
+            )
+            .emit();
     }
 }
 
 fn report_lifetime_number_error(tcx: TyCtxt, span: Span, number: usize, expected: usize) {
-    span_err!(tcx.sess, span, E0107,
-              "wrong number of lifetime parameters: expected {}, found {}",
-              expected, number);
+    let label = if number < expected {
+        if expected == 1 {
+            format!("expected {} lifetime parameter", expected)
+        } else {
+            format!("expected {} lifetime parameters", expected)
+        }
+    } else {
+        let additional = number - expected;
+        if additional == 1 {
+            "unexpected lifetime parameter".to_string()
+        } else {
+            format!("{} unexpected lifetime parameters", additional)
+        }
+    };
+    struct_span_err!(tcx.sess, span, E0107,
+                     "wrong number of lifetime parameters: expected {}, found {}",
+                     expected, number)
+        .span_label(span, &label)
+        .emit();
 }
 
 // A helper struct for conveniently grouping a set of bounds which we pass to
index aae6e3ad36dfe7ee2ba7b1ec173cd2d3f8193a82..fe68690d4e97447efbc826717314234bbffb86ec 100644 (file)
@@ -93,13 +93,12 @@ pub fn check_pat(&self, pat: &'gcx hir::Pat, expected: Ty<'tcx>) {
                         end.span
                     };
 
-                    // Note: spacing here is intentional, we want a space before "start" and "end".
-                    span_err!(tcx.sess, span, E0029,
-                              "only char and numeric types are allowed in range patterns\n \
-                               start type: {}\n end type: {}",
-                              self.ty_to_string(lhs_ty),
-                              self.ty_to_string(rhs_ty)
-                    );
+                    struct_span_err!(tcx.sess, span, E0029,
+                        "only char and numeric types are allowed in range patterns")
+                        .span_label(span, &format!("ranges require char or numeric types"))
+                        .note(&format!("start type: {}", self.ty_to_string(lhs_ty)))
+                        .note(&format!("end type: {}", self.ty_to_string(rhs_ty)))
+                        .emit();
                     return;
                 }
 
@@ -700,9 +699,11 @@ pub fn check_struct_pat_fields(&self,
             for field in variant.fields
                 .iter()
                 .filter(|field| !used_fields.contains_key(&field.name)) {
-                span_err!(tcx.sess, span, E0027,
-                    "pattern does not mention field `{}`",
-                    field.name);
+                struct_span_err!(tcx.sess, span, E0027,
+                                "pattern does not mention field `{}`",
+                                field.name)
+                                .span_label(span, &format!("missing field `{}`", field.name))
+                                .emit();
             }
         }
     }
index bd2c05ba66d47188d77729c08c5cf874832c79b9..e73c3aa352b5605beec6fe6d8b1f164554360fbf 100644 (file)
@@ -28,7 +28,9 @@
 /// method that is called)
 pub fn check_legal_trait_for_method_call(ccx: &CrateCtxt, span: Span, trait_id: DefId) {
     if ccx.tcx.lang_items.drop_trait() == Some(trait_id) {
-        span_err!(ccx.tcx.sess, span, E0040, "explicit use of destructor method");
+        struct_span_err!(ccx.tcx.sess, span, E0040, "explicit use of destructor method")
+            .span_label(span, &format!("call to destructor method"))
+            .emit();
     }
 }
 
index 9844377d0bd32f5241c1e0cb948f48597c1d5673..b971ae02cd0bd27a87905137df7540a80142257b 100644 (file)
@@ -59,19 +59,33 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
         (&ty::ExplicitSelfCategory::Static,
          &ty::ExplicitSelfCategory::Static) => {}
         (&ty::ExplicitSelfCategory::Static, _) => {
-            span_err!(tcx.sess, impl_m_span, E0185,
+            let mut err = struct_span_err!(tcx.sess, impl_m_span, E0185,
                 "method `{}` has a `{}` declaration in the impl, \
                         but not in the trait",
                         trait_m.name,
                         impl_m.explicit_self);
+            err.span_label(impl_m_span, &format!("`{}` used in impl",
+                                                 impl_m.explicit_self));
+            if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
+                err.span_label(span, &format!("trait declared without `{}`",
+                                              impl_m.explicit_self));
+            }
+            err.emit();
             return;
         }
         (_, &ty::ExplicitSelfCategory::Static) => {
-            span_err!(tcx.sess, impl_m_span, E0186,
+            let mut err = struct_span_err!(tcx.sess, impl_m_span, E0186,
                 "method `{}` has a `{}` declaration in the trait, \
                         but not in the impl",
                         trait_m.name,
                         trait_m.explicit_self);
+            err.span_label(impl_m_span, &format!("expected `{}` in impl",
+                                                  trait_m.explicit_self));
+            if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
+                err.span_label(span, & format!("`{}` used in trait",
+                                               trait_m.explicit_self));
+            }
+            err.emit();
             return;
         }
         _ => {
index 346449d0a51331465bde2b99b5eec3048bb74e7c..54521782474fe05ac1e8b15ae5e0fec19a193def 100644 (file)
@@ -162,26 +162,34 @@ pub fn report_method_error(&self,
                     },
                     rcvr_ty);
 
-                // If the item has the name of a field, give a help note
-                if let (&ty::TyStruct(def, substs), Some(expr)) = (&rcvr_ty.sty, rcvr_expr) {
-                    if let Some(field) = def.struct_variant().find_field_named(item_name) {
-                        let expr_string = match tcx.sess.codemap().span_to_snippet(expr.span) {
-                            Ok(expr_string) => expr_string,
-                            _ => "s".into() // Default to a generic placeholder for the
-                                            // expression when we can't generate a string
-                                            // snippet
-                        };
-
-                        let field_ty = field.ty(tcx, substs);
-
-                        if self.is_fn_ty(&field_ty, span) {
-                            err.span_note(span,
-                                          &format!("use `({0}.{1})(...)` if you meant to call \
-                                                   the function stored in the `{1}` field",
-                                                   expr_string, item_name));
-                        } else {
-                            err.span_note(span, &format!("did you mean to write `{0}.{1}`?",
-                                                         expr_string, item_name));
+                // If the method name is the name of a field with a function or closure type,
+                // give a helping note that it has to be called as (x.f)(...).
+                if let Some(expr) = rcvr_expr {
+                    for (ty, _) in self.autoderef(span, rcvr_ty) {
+                        if let ty::TyStruct(def, substs) = ty.sty {
+                            if let Some(field) = def.struct_variant().find_field_named(item_name) {
+                                let snippet = tcx.sess.codemap().span_to_snippet(expr.span);
+                                let expr_string = match snippet {
+                                    Ok(expr_string) => expr_string,
+                                    _ => "s".into() // Default to a generic placeholder for the
+                                                    // expression when we can't generate a
+                                                    // string snippet
+                                };
+
+                                let field_ty = field.ty(tcx, substs);
+
+                                if self.is_fn_ty(&field_ty, span) {
+                                    err.span_note(span, &format!(
+                                        "use `({0}.{1})(...)` if you meant to call the function \
+                                         stored in the `{1}` field",
+                                        expr_string, item_name));
+                                } else {
+                                    err.span_note(span, &format!(
+                                        "did you mean to write `{0}.{1}`?",
+                                        expr_string, item_name));
+                                }
+                                break;
+                            }
                         }
                     }
                 }
index 97788c9fb33997e8c8dd54e23d98a462708647d4..4bb36aa639c541b1e0ae46517a27b654b46d4f40 100644 (file)
@@ -847,7 +847,9 @@ fn check_trait_fn_not_const<'a,'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
             // good
         }
         hir::Constness::Const => {
-            span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const");
+            struct_span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const")
+                .span_label(span, &format!("trait fns cannot be const"))
+                .emit()
         }
     }
 }
@@ -993,7 +995,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
     // Check existing impl methods to see if they are both present in trait
     // and compatible with trait signature
     for impl_item in impl_items {
-        let ty_impl_item = ccx.tcx.impl_or_trait_item(ccx.tcx.map.local_def_id(impl_item.id));
+        let ty_impl_item = tcx.impl_or_trait_item(tcx.map.local_def_id(impl_item.id));
         let ty_trait_item = trait_items.iter()
             .find(|ac| ac.name() == ty_impl_item.name());
 
@@ -1014,11 +1016,18 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                                            trait_const,
                                            &impl_trait_ref);
                     } else {
-                        span_err!(tcx.sess, impl_item.span, E0323,
+                         let mut err = struct_span_err!(tcx.sess, impl_item.span, E0323,
                                   "item `{}` is an associated const, \
                                   which doesn't match its trait `{:?}`",
                                   impl_const.name,
-                                  impl_trait_ref)
+                                  impl_trait_ref);
+                         err.span_label(impl_item.span, &format!("does not match trait"));
+                         // We can only get the spans from local trait definition
+                         // Same for E0324 and E0325
+                         if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) {
+                            err.span_label(trait_span, &format!("original trait requirement"));
+                         }
+                         err.emit()
                     }
                 }
                 hir::ImplItemKind::Method(ref sig, ref body) => {
@@ -1037,11 +1046,16 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                                             &trait_method,
                                             &impl_trait_ref);
                     } else {
-                        span_err!(tcx.sess, impl_item.span, E0324,
+                        let mut err = struct_span_err!(tcx.sess, impl_item.span, E0324,
                                   "item `{}` is an associated method, \
                                   which doesn't match its trait `{:?}`",
                                   impl_method.name,
-                                  impl_trait_ref)
+                                  impl_trait_ref);
+                         err.span_label(impl_item.span, &format!("does not match trait"));
+                         if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) {
+                            err.span_label(trait_span, &format!("original trait requirement"));
+                         }
+                         err.emit()
                     }
                 }
                 hir::ImplItemKind::Type(_) => {
@@ -1055,11 +1069,16 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                             overridden_associated_type = Some(impl_item);
                         }
                     } else {
-                        span_err!(tcx.sess, impl_item.span, E0325,
+                        let mut err = struct_span_err!(tcx.sess, impl_item.span, E0325,
                                   "item `{}` is an associated type, \
                                   which doesn't match its trait `{:?}`",
                                   impl_type.name,
-                                  impl_trait_ref)
+                                  impl_trait_ref);
+                         err.span_label(impl_item.span, &format!("does not match trait"));
+                         if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) {
+                            err.span_label(trait_span, &format!("original trait requirement"));
+                         }
+                         err.emit()
                     }
                 }
             }
@@ -1117,11 +1136,16 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
     }
 
     if !missing_items.is_empty() {
-        span_err!(tcx.sess, impl_span, E0046,
+        struct_span_err!(tcx.sess, impl_span, E0046,
             "not all trait items implemented, missing: `{}`",
             missing_items.iter()
                   .map(|name| name.to_string())
                   .collect::<Vec<_>>().join("`, `"))
+            .span_label(impl_span, &format!("missing `{}` in implementation",
+                missing_items.iter()
+                    .map(|name| name.to_string())
+                    .collect::<Vec<_>>().join("`, `"))
+            ).emit();
     }
 
     if !invalidated_items.is_empty() {
@@ -1251,8 +1275,9 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
                 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();
-                span_note!(&mut err, ccx.tcx.map.span(variant_i_node_id),
-                    "conflicting discriminant here");
+                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();
             }
             disr_vals.push(current_disr_val);
@@ -3406,8 +3431,10 @@ fn check_expr_with_expectation_and_lvalue_pref(&self,
                             // FIXME(#32730) propagate obligations
                             .map(|InferOk { obligations, .. }| assert!(obligations.is_empty()));
                         if eq_result.is_err() {
-                            span_err!(tcx.sess, expr.span, E0069,
-                                      "`return;` in a function whose return type is not `()`");
+                            struct_span_err!(tcx.sess, expr.span, E0069,
+                                     "`return;` in a function whose return type is not `()`")
+                                .span_label(expr.span, &format!("return type is not ()"))
+                                .emit();
                         }
                     }
                 }
@@ -3415,8 +3442,10 @@ fn check_expr_with_expectation_and_lvalue_pref(&self,
                     if let Some(ref e) = *expr_opt {
                         self.check_expr(&e);
                     }
-                    span_err!(tcx.sess, expr.span, E0166,
-                        "`return` in a function declared as diverging");
+                    struct_span_err!(tcx.sess, expr.span, E0166,
+                        "`return` in a function declared as diverging")
+                        .span_label(expr.span, &format!("diverging function cannot return"))
+                        .emit();
                 }
             }
             self.write_ty(id, self.next_diverging_ty_var());
index 9786132dc537b53c57c0a4b47abde6fe863536ac..42893e40024e891aa14eb5ec8dd7684f3a93edb8 100644 (file)
@@ -441,13 +441,19 @@ fn report_error(&self, e: FixupError) {
         if !self.tcx.sess.has_errors() {
             match self.reason {
                 ResolvingExpr(span) => {
-                    span_err!(self.tcx.sess, span, E0101,
-                        "cannot determine a type for this expression: {}", e);
+                    struct_span_err!(
+                        self.tcx.sess, span, E0101,
+                        "cannot determine a type for this expression: {}", e)
+                        .span_label(span, &format!("cannot resolve type of expression"))
+                        .emit();
                 }
 
                 ResolvingLocal(span) => {
-                    span_err!(self.tcx.sess, span, E0102,
-                        "cannot determine a type for this local variable: {}", e);
+                    struct_span_err!(
+                        self.tcx.sess, span, E0102,
+                        "cannot determine a type for this local variable: {}", e)
+                        .span_label(span, &format!("cannot resolve type of variable"))
+                        .emit();
                 }
 
                 ResolvingPattern(span) => {
index 2d14b0dacf24cdad759aaf5f63222a698082bd63..cdf2ca14d4c78366a4a8284d9ac63eace14c2b01 100644 (file)
@@ -311,24 +311,36 @@ fn check_implementations_of_copy(&self) {
             match param_env.can_type_implement_copy(tcx, self_type, span) {
                 Ok(()) => {}
                 Err(CopyImplementationError::InfrigingField(name)) => {
-                       span_err!(tcx.sess, span, E0204,
-                                 "the trait `Copy` may not be \
-                                          implemented for this type; field \
-                                          `{}` does not implement `Copy`",
-                                         name)
+                       struct_span_err!(tcx.sess, span, E0204,
+                                 "the trait `Copy` may not be implemented for \
+                                 this type")
+                           .span_label(span, &format!(
+                                 "field `{}` does not implement `Copy`", name)
+                               )
+                           .emit()
+
                 }
                 Err(CopyImplementationError::InfrigingVariant(name)) => {
-                       span_err!(tcx.sess, span, E0205,
+                       struct_span_err!(tcx.sess, span, E0205,
                                  "the trait `Copy` may not be \
-                                          implemented for this type; variant \
+                                          implemented for this type")
+                           .span_label(span, &format!("variant \
                                           `{}` does not implement `Copy`",
-                                         name)
+                                         name))
+                           .emit()
                 }
                 Err(CopyImplementationError::NotAnAdt) => {
-                       span_err!(tcx.sess, span, E0206,
-                                 "the trait `Copy` may not be implemented \
-                                  for this type; type is not a structure or \
-                                  enumeration")
+                    let item = tcx.map.expect_item(impl_node_id);
+                    let span = if let ItemImpl(_, _, _, _, ref ty, _) = item.node {
+                        ty.span
+                    } else {
+                        span
+                    };
+
+                    struct_span_err!(tcx.sess, span, E0206,
+                                     "the trait `Copy` may not be implemented for this type")
+                        .span_label(span, &format!("type is not a structure or enumeration"))
+                        .emit();
                 }
                 Err(CopyImplementationError::HasDestructor) => {
                     span_err!(tcx.sess, span, E0184,
index 15d4026254fa57ec1c8f2ee03cb25e99c81916a9..e426f0cb643b7ab99159ed0ec331e438f5b23514 100644 (file)
@@ -33,10 +33,12 @@ struct OrphanChecker<'cx, 'tcx:'cx> {
 impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
     fn check_def_id(&self, item: &hir::Item, def_id: DefId) {
         if def_id.krate != LOCAL_CRATE {
-            span_err!(self.tcx.sess, item.span, E0116,
+            struct_span_err!(self.tcx.sess, item.span, E0116,
                       "cannot define inherent `impl` for a type outside of the \
-                       crate where the type is defined; define and implement \
-                       a trait or new type instead");
+                       crate where the type is defined")
+                .span_label(item.span, &format!("impl for type defined outside of crate."))
+                .span_note(item.span, &format!("define and implement a trait or new type instead"))
+                .emit();
         }
     }
 
@@ -66,7 +68,7 @@ fn check_primitive_impl(&self,
     fn check_item(&self, item: &hir::Item) {
         let def_id = self.tcx.map.local_def_id(item.id);
         match item.node {
-            hir::ItemImpl(_, _, _, None, _, _) => {
+            hir::ItemImpl(_, _, _, None, ref ty, _) => {
                 // For inherent impls, self type must be a nominal type
                 // defined in this crate.
                 debug!("coherence2::orphan check: inherent impl {}",
@@ -209,11 +211,11 @@ fn check_item(&self, item: &hir::Item) {
                         return;
                     }
                     _ => {
-                        struct_span_err!(self.tcx.sess, item.span, E0118,
+                        struct_span_err!(self.tcx.sess, ty.span, E0118,
                                          "no base type found for inherent implementation")
-                        .span_help(item.span,
-                                   "either implement a trait on it or create a newtype to wrap it \
-                                    instead")
+                        .span_label(ty.span, &format!("impl requires a base type"))
+                        .note(&format!("either implement a trait on it or create a newtype \
+                                        to wrap it instead"))
                         .emit();
                         return;
                     }
@@ -228,12 +230,14 @@ fn check_item(&self, item: &hir::Item) {
                 match traits::orphan_check(self.tcx, def_id) {
                     Ok(()) => { }
                     Err(traits::OrphanCheckErr::NoLocalInputType) => {
-                        span_err!(
+                        struct_span_err!(
                             self.tcx.sess, item.span, E0117,
-                            "the impl does not reference any \
-                             types defined in this crate; \
-                             only traits defined in the current crate can be \
-                             implemented for arbitrary types");
+                             "only traits defined in the current crate can be \
+                             implemented for arbitrary types")
+                        .span_label(item.span, &format!("impl doesn't use types inside crate"))
+                        .note(&format!("the impl does not reference any \
+                                        types defined in this crate"))
+                        .emit();
                         return;
                     }
                     Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => {
index cb9c0496246d5ee4286dd1c254f7138cdbd88b25..9b1a6c78335f189470f69c1d31b59706e37c21b3 100644 (file)
@@ -367,8 +367,13 @@ fn ty_infer(&self,
                 _substs: Option<&mut Substs<'tcx>>,
                 _space: Option<ParamSpace>,
                 span: Span) -> Ty<'tcx> {
-        span_err!(self.tcx().sess, span, E0121,
-                  "the type placeholder `_` is not allowed within types on item signatures");
+        struct_span_err!(
+            self.tcx().sess,
+            span,
+            E0121,
+            "the type placeholder `_` is not allowed within types on item signatures"
+        ).span_label(span, &format!("not allowed in type signatures"))
+        .emit();
         self.tcx().types.err
     }
 
@@ -770,9 +775,10 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
                         let mut err = struct_span_err!(tcx.sess, impl_item.span, E0201,
                                                        "duplicate definitions with name `{}`:",
                                                        impl_item.name);
-                        span_note!(&mut err, *entry.get(),
-                                   "previous definition of `{}` here",
-                                   impl_item.name);
+                        err.span_label(*entry.get(),
+                                   &format!("previous definition of `{}` here",
+                                        impl_item.name));
+                        err.span_label(impl_item.span, &format!("duplicate definition"));
                         err.emit();
                     }
                     Vacant(entry) => {
@@ -2317,8 +2323,12 @@ fn report_unused_parameter(ccx: &CrateCtxt,
                            kind: &str,
                            name: &str)
 {
-    span_err!(ccx.tcx.sess, span, E0207,
-              "the {} parameter `{}` is not constrained by the \
-               impl trait, self type, or predicates",
-              kind, name);
+    struct_span_err!(
+        ccx.tcx.sess, span, E0207,
+        "the {} parameter `{}` is not constrained by the \
+        impl trait, self type, or predicates",
+        kind, name)
+        .span_label(span, &format!("unconstrained lifetime parameter"))
+        .emit();
+
 }
index 6f0892cdcdf1619f62e74198f5af4940c129a215..65e00705121a7e6dcc5745d3034f10d5c0550053 100644 (file)
@@ -211,11 +211,15 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
             match tcx.map.find(main_id) {
                 Some(hir_map::NodeItem(it)) => {
                     match it.node {
-                        hir::ItemFn(_, _, _, _, ref ps, _)
-                        if ps.is_parameterized() => {
-                            span_err!(ccx.tcx.sess, main_span, E0131,
-                                      "main function is not allowed to have type parameters");
-                            return;
+                        hir::ItemFn(_, _, _, _, ref generics, _) => {
+                            if let Some(gen_span) = generics.span() {
+                                struct_span_err!(ccx.tcx.sess, gen_span, E0131,
+                                         "main function is not allowed to have type parameters")
+                                    .span_label(gen_span,
+                                                &format!("main cannot have type parameters"))
+                                    .emit();
+                                return;
+                            }
                         }
                         _ => ()
                     }
index f800a6e228e9ba0f96bcf56f20e4ef63964cb3e8..e0501f9cc61d24c70781bab1cf2645d2ed143ffe 100644 (file)
@@ -373,6 +373,15 @@ pub fn nul_position(&self) -> usize { self.0 }
 
     /// Consumes this error, returning the underlying vector of bytes which
     /// generated the error in the first place.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::ffi::CString;
+    ///
+    /// let nul_error = CString::new("foo\0bar").unwrap_err();
+    /// assert_eq!(nul_error.into_vec(), b"foo\0bar");
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn into_vec(self) -> Vec<u8> { self.1 }
 }
index b315e6762633b3fd982566c5a311360a3ad4065b..3b132744f7055ce176e0f0689aca601b53a454c6 100644 (file)
@@ -27,7 +27,7 @@
 #[cfg(any(target_os = "linux", target_os = "emscripten"))]
 use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64, dirent64, readdir64_r, open64};
 #[cfg(target_os = "android")]
-use libc::{stat as stat64, fstat as fstat64, lstat as lstat64, off64_t, lseek64,
+use libc::{stat as stat64, fstat as fstat64, lstat as lstat64, lseek64,
            dirent as dirent64, open as open64};
 #[cfg(not(any(target_os = "linux",
               target_os = "emscripten",
@@ -485,9 +485,11 @@ pub fn flush(&self) -> io::Result<()> { Ok(()) }
 
     pub fn seek(&self, pos: SeekFrom) -> io::Result<u64> {
         let (whence, pos) = match pos {
-            SeekFrom::Start(off) => (libc::SEEK_SET, off as off64_t),
-            SeekFrom::End(off) => (libc::SEEK_END, off as off64_t),
-            SeekFrom::Current(off) => (libc::SEEK_CUR, off as off64_t),
+            // Casting to `i64` is fine, too large values will end up as
+            // negative which will cause an error in `lseek64`.
+            SeekFrom::Start(off) => (libc::SEEK_SET, off as i64),
+            SeekFrom::End(off) => (libc::SEEK_END, off),
+            SeekFrom::Current(off) => (libc::SEEK_CUR, off),
         };
         let n = cvt(unsafe { lseek64(self.0.raw(), pos, whence) })?;
         Ok(n as u64)
index 4c3558f91f5f22e65cf3c3892f45af47576e9a60..33c526532c7a842896f3b897510a22d7716fc5b6 100644 (file)
@@ -37,6 +37,7 @@
 
 
 extern {
+    #[cfg(not(target_os = "dragonfly"))]
     #[cfg_attr(any(target_os = "linux", target_os = "emscripten"),
                link_name = "__errno_location")]
     #[cfg_attr(any(target_os = "bitrig",
index fbd4e1d120817ebc21a0b5e4e08d2f8593ff02d2..08aeb5fb8ccdeae96abf30a8569e9824dfc34856 100644 (file)
@@ -50,7 +50,9 @@ pub unsafe fn read(&self) {
         // the implementation allows recursive locking. The POSIX standard
         // doesn't require recursivly locking a rwlock to deadlock, but we can't
         // allow that because it could lead to aliasing issues.
-        if r == libc::EDEADLK || *self.write_locked.get() {
+        if r == libc::EAGAIN {
+            panic!("rwlock maximum reader count exceeded");
+        } else if r == libc::EDEADLK || *self.write_locked.get() {
             if r == 0 {
                 self.raw_unlock();
             }
index 2683e57256dc79afc29a2872a31861f77a788d53..4e6cef9a28d8f32147d5db051c5e95c2f5469a69 100644 (file)
@@ -324,6 +324,8 @@ pub fn flush(&self) -> io::Result<()> { Ok(()) }
 
     pub fn seek(&self, pos: SeekFrom) -> io::Result<u64> {
         let (whence, pos) = match pos {
+            // Casting to `i64` is fine, `SetFilePointerEx` reinterprets this
+            // integer as `u64`.
             SeekFrom::Start(n) => (c::FILE_BEGIN, n as i64),
             SeekFrom::End(n) => (c::FILE_END, n),
             SeekFrom::Current(n) => (c::FILE_CURRENT, n),
index 9ae9e795466d28a65554944e7d8a87a5ba669278..8a666168c86fd22207a7067c426fe0c89329dfd6 100644 (file)
@@ -11,5 +11,6 @@
 #![feature(box_syntax)]
 
 const CON : Box<i32> = box 0; //~ ERROR E0010
+                              //~| NOTE allocation not allowed in
 
 fn main() {}
index b2f20442b77ad4a116c65497cd6675b664e189ed..ca496a24701fba48141189c332229ad1248707e5 100644 (file)
@@ -17,6 +17,8 @@ fn main() {
     let d = Dog { name: "Rusty".to_string(), age: 8 };
 
     match d {
-        Dog { age: x } => {} //~ ERROR E0027
+        Dog { age: x } => {}
+        //~^ ERROR pattern does not mention field `name`
+        //~| NOTE missing field `name`
     }
 }
index 9cbdec9952053ad51affc0d47fe17cdce3a8eaa2..ec84e2a3f8a3650c8e910752e5fdeba1fb71a4fc 100644 (file)
@@ -12,7 +12,11 @@ fn main() {
     let s = "hoho";
 
     match s {
-        "hello" ... "world" => {} //~ ERROR E0029
+        "hello" ... "world" => {}
+        //~^ ERROR only char and numeric types are allowed in range patterns
+        //~| NOTE ranges require char or numeric types
+        //~| NOTE start type: &'static str
+        //~| NOTE end type: &'static str
         _ => {}
     }
 }
index f998778a50d66b0cf8fab95bdc60c9410fa1e097..80ff57c36359561f28aac3410823d551f6afe16e 100644 (file)
@@ -20,5 +20,7 @@ fn drop(&mut self) {
 
 fn main() {
     let mut x = Foo { x: -7 };
-    x.drop(); //~ ERROR E0040
+    x.drop();
+    //~^ ERROR E0040
+    //~| NOTE call to destructor method
 }
index 63bd0a5ca285826a84c5458c37845d4fa215bc3c..a8b56b2b9ab37248a596f3f37df0d5e15290ff34 100644 (file)
@@ -14,7 +14,9 @@ trait Foo {
 
 struct Bar;
 
-impl Foo for Bar {} //~ ERROR E0046
+impl Foo for Bar {}
+//~^ ERROR E0046
+//~| NOTE missing `foo` in implementation
 
 fn main() {
 }
index d164d86348784255b86e9bf57dd5efb746eb1de7..00facc91728027608eb85702b2517cd21e561ca1 100644 (file)
@@ -9,7 +9,9 @@
 // except according to those terms.
 
 fn foo() -> u8 {
-    return; //~ ERROR E0069
+    return;
+    //~^ ERROR `return;` in a function whose return type is not `()`
+    //~| NOTE return type is not ()
 }
 
 fn main() {
index 7651626d44f859f44e9b5fdf4320a733c10c9487..0005da048e4a5706fb37ebed9292f51b3902f04d 100644 (file)
@@ -9,5 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let x = |_| {}; //~ ERROR E0101
+    let x = |_| {};
+    //~^ ERROR E0101
+    //~| NOTE cannot resolve type of expression
 }
index c4ddbab3e861a2034ad8f36e1a047c59195db179..1d64798bb838202e6f1696addb1f96adaab34a7a 100644 (file)
@@ -9,5 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let x = []; //~ ERROR E0102
+    let x = [];
+    //~^ ERROR E0102
+    //~| NOTE cannot resolve type of variable
 }
index f1cd530863d341e4e291856688ed9cb7652d032d..dab03f0bccfd0b88befcaa5d581470af50a530a1 100644 (file)
@@ -9,13 +9,19 @@
 // except according to those terms.
 
 struct Foo {
-    x: &bool, //~ ERROR E0106
+    x: &bool,
+    //~^ ERROR E0106
+    //~| NOTE expected lifetime parameter
 }
 enum Bar {
     A(u8),
-    B(&bool), //~ ERROR E0106
+    B(&bool),
+   //~^ ERROR E0106
+   //~| NOTE expected lifetime parameter
 }
-type MyStr = &str; //~ ERROR E0106
+type MyStr = &str;
+        //~^ ERROR E0106
+        //~| NOTE expected lifetime parameter
 
 fn main() {
 }
index d27b70865bbfbccd7c925e6c03f1004f7de707bf..5f333e17c478efeabaeec150842e1bd4530df4ff 100644 (file)
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 struct Foo<'a>(&'a str);
+struct Buzz<'a, 'b>(&'a str, &'b str);
 
 enum Bar {
     A,
@@ -16,9 +17,19 @@ enum Bar {
     C,
 }
 
-struct Baz<'a> {
-    foo: Foo, //~ ERROR E0107
-    bar: Bar<'a>, //~ ERROR E0107
+struct Baz<'a, 'b, 'c> {
+    foo: Foo,
+    //~^ ERROR E0107
+    //~| expected 1 lifetime parameter
+    buzz: Buzz<'a>,
+    //~^ ERROR E0107
+    //~| expected 2 lifetime parameters
+    bar: Bar<'a>,
+    //~^ ERROR E0107
+    //~| unexpected lifetime parameter
+    foo2: Foo<'a, 'b, 'c>,
+    //~^ ERROR E0107
+    //~| 2 unexpected lifetime parameters
 }
 
 fn main() {
index 4020aa9475aaa3273ac0170565a91ff19d4c233e..f885241eec4c7f1b00a7451fa11d091afb60fc95 100644 (file)
@@ -8,7 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-impl Vec<u8> {} //~ ERROR E0116
+impl Vec<u8> {}
+//~^ ERROR E0116
+//~| NOTE impl for type defined outside of crate.
+//~| NOTE define and implement a trait or new type instead
 
 fn main() {
 }
index 16d713bba92ab3c11b0f848d0c22a16268efc708..e9375e673253fb863edb4135df4256446645d4ec 100644 (file)
@@ -9,6 +9,8 @@
 // except according to those terms.
 
 impl Drop for u32 {} //~ ERROR E0117
+//~^ NOTE impl doesn't use types inside crate
+//~| NOTE the impl does not reference any types defined in this crate
 
 fn main() {
 }
index d37ff34b861f41d272970920bf135f222773d5ff..3fc478f1e403e3adf57ed00c48e547b1c1f1dfbb 100644 (file)
@@ -9,6 +9,8 @@
 // except according to those terms.
 
 impl (u8, u8) { //~ ERROR E0118
+//~^ NOTE impl requires a base type
+//~| NOTE either implement a trait on it or create a newtype to wrap it instead
     fn get_state(&self) -> String {
         String::new()
     }
index aa11577ccdf1ed1f1a0578dcfd050079d1b2c7ac..e6e924e2d966fd9cc8a335060afe22098ed44b7a 100644 (file)
@@ -8,5 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn main<T>() { //~ ERROR E0131
+fn main<T>() {
+    //~^ ERROR E0131
+    //~| NOTE main cannot have type parameters
 }
index 9fa41249aa50b06a78d8286e4963c8ababc4f31f..f8585d71b402a080c052a5d09a79a45542b5079f 100644 (file)
@@ -8,7 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn foo() -> ! { return; } //~ ERROR E0166
+fn foo() -> ! { return; }
+    //~^ ERROR E0166
+    //~| NOTE diverging function cannot return
 
 fn main() {
 }
index 0e33687a84dfb6857fae8f563c874600bc434f73..be54c3754ea1fe98e7aef7f4aaef686d8282f629 100644 (file)
@@ -9,13 +9,14 @@
 // except according to those terms.
 
 trait Foo {
-    fn foo();
+    fn foo(); //~ trait declared without `&self`
 }
 
 struct Bar;
 
 impl Foo for Bar {
     fn foo(&self) {} //~ ERROR E0185
+    //~^ `&self` used in impl
 }
 
 fn main() {
index aa0a38bedcb543e932123f4bb59d0798c6658a19..55a3490cac4a620b9206e243cd81687e084edb8d 100644 (file)
@@ -9,13 +9,14 @@
 // except according to those terms.
 
 trait Foo {
-    fn foo(&self);
+    fn foo(&self); //~ `&self` used in trait
 }
 
 struct Bar;
 
 impl Foo for Bar {
     fn foo() {} //~ ERROR E0186
+    //~^ expected `&self` in impl
 }
 
 fn main() {
index 2fa2afa12eb431bcb3c5bacf9d7aab579b3e18b6..0f108a17c95db3127edf399eab121a8566916427 100644 (file)
@@ -12,9 +12,14 @@ struct Foo {
     foo: Vec<u32>,
 }
 
-impl Copy for Foo { } //~ ERROR E0204
+impl Copy for Foo { }
+//~^ ERROR E0204
+//~| NOTE field `foo` does not implement `Copy`
 
-#[derive(Copy)] //~ ERROR E0204
+#[derive(Copy)]
+//~^ ERROR E0204
+//~| NOTE field `ty` does not implement `Copy`
+//~| NOTE in this expansion of #[derive(Copy)]
 struct Foo2<'a> {
     ty: &'a mut bool,
 }
index e4781bba08aab14cd52e81981269d3c9a625896e..37ac57af524a6d1f5ba06d7752019b94e5e613e7 100644 (file)
@@ -13,9 +13,14 @@ enum Foo {
     Baz,
 }
 
-impl Copy for Foo { } //~ ERROR E0205
+impl Copy for Foo { }
+//~^ ERROR E0205
+//~| NOTE variant `Bar` does not implement `Copy`
 
-#[derive(Copy)] //~ ERROR E0205
+#[derive(Copy)]
+//~^ ERROR E0205
+//~| NOTE variant `Bar` does not implement `Copy`
+//~| NOTE in this expansion of #[derive(Copy)]
 enum Foo2<'a> {
     Bar(&'a mut bool),
     Baz,
index 31b01da3d75b566e75f87e498eb1a893c91a926b..888e42ed3a18cea72870207b7b9cbc459fea7417 100644 (file)
 
 type Foo = i32;
 
-impl Copy for Foo { } //~ ERROR E0206
-                      //~^ ERROR E0117
+impl Copy for Foo { }
+//~^ ERROR the trait `Copy` may not be implemented for this type
+//~| NOTE type is not a structure or enumeration
+//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
+//~| NOTE impl doesn't use types inside crate
+//~| NOTE the impl does not reference any types defined in this crate
 
 #[derive(Copy, Clone)]
 struct Bar;
 
-impl Copy for &'static Bar { } //~ ERROR E0206
+impl Copy for &'static Bar { }
+//~^ ERROR the trait `Copy` may not be implemented for this type
+//~| NOTE type is not a structure or enumeration
 
 fn main() {
 }
index bd87dbaf786a518407bc28a07c8e5c8528e5ef8f..43ff085a4fa8e36c49c7d26447fbdc8629ad96fa 100644 (file)
@@ -11,6 +11,7 @@
 struct Foo;
 
 impl<T: Default> Foo { //~ ERROR E0207
+                       //~| NOTE unconstrained lifetime parameter
     fn get(&self) -> T {
         <T as Default>::default()
     }
index bbf7d762ef00bb3e1fcb16915aa9487fc4cde1a6..56057b372599dc284593b08489ae84eeab283dd1 100644 (file)
@@ -11,5 +11,8 @@
 trait MyTrait { type X; }
 
 fn main() {
-    let foo: MyTrait::X; //~ ERROR E0223
+    let foo: MyTrait::X;
+    //~^ ERROR ambiguous associated type
+    //~| NOTE ambiguous associated type
+    //~| NOTE specify the type using the syntax `<Type as MyTrait>::X`
 }
index 190350c5a557117deaa9b870c2136a672635e530..b013788ceff8506f95d52844f4f56c7279d76604 100644 (file)
@@ -9,5 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let _: Box<std::io::Read + std::io::Write>; //~ ERROR E0225
+    let _: Box<std::io::Read + std::io::Write>;
+    //~^ ERROR only the builtin traits can be used as closure or object bounds [E0225]
+    //~| NOTE non-builtin trait used as bounds
 }
index 45d5c59592f759cc120685f4d3e92c1782efd29d..6ff0baeeb4d4bd25c16e420febcebf7f2fb41af3 100644 (file)
@@ -20,7 +20,9 @@ impl Foo for isize {
     fn boo(&self) -> usize { 42 }
 }
 
-fn baz<I>(x: &<I as Foo<A=Bar>>::A) {} //~ ERROR E0229
+fn baz<I>(x: &<I as Foo<A=Bar>>::A) {}
+//~^ ERROR associated type bindings are not allowed here [E0229]
+//~| NOTE associate type not allowed here
 
 fn main() {
 }
index 8cc245c10cbe9cdd60c5a16101e4e5304b63e3c2..77c9856c261ff595054194d558447438c19b990f 100644 (file)
@@ -9,7 +9,9 @@
 // except according to those terms.
 
 struct Foo<T> { x: T }
-struct Bar { x: Foo } //~ ERROR E0243
+struct Bar { x: Foo }
+                //~^ ERROR E0243
+                //~| NOTE expected 1 type arguments, found 0
 
 fn main() {
 }
index 4c57447109296bb24514811682a3de4648c83626..5678a7fd450d8f95a1bcebb635c99a59ba238a55 100644 (file)
@@ -9,7 +9,10 @@
 // except according to those terms.
 
 struct Foo { x: bool }
-struct Bar<S, T> { x: Foo<S, T> } //~ ERROR E0244
+struct Bar<S, T> { x: Foo<S, T> }
+                      //~^ ERROR E0244
+                      //~| NOTE expected no type arguments, found 2
+
 
 fn main() {
 }
diff --git a/src/test/compile-fail/E0253.rs b/src/test/compile-fail/E0253.rs
new file mode 100644 (file)
index 0000000..28fcf44
--- /dev/null
@@ -0,0 +1,19 @@
+// 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.
+
+mod foo {
+    pub trait MyTrait {
+        fn do_something();
+    }
+}
+
+use foo::MyTrait::do_something; //~ ERROR E0253
+
+fn main() {}
diff --git a/src/test/compile-fail/E0254.rs b/src/test/compile-fail/E0254.rs
new file mode 100644 (file)
index 0000000..28f9aea
--- /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.
+
+extern crate collections;
+
+mod foo {
+    pub trait collections {
+        fn do_something();
+    }
+}
+
+use foo::collections; //~ ERROR E0254
+
+fn main() {}
diff --git a/src/test/compile-fail/E0255.rs b/src/test/compile-fail/E0255.rs
new file mode 100644 (file)
index 0000000..e05c6be
--- /dev/null
@@ -0,0 +1,19 @@
+// 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.
+
+use bar::foo;
+
+fn foo() {} //~ ERROR E0255
+
+mod bar {
+     pub fn foo() {}
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0259.rs b/src/test/compile-fail/E0259.rs
new file mode 100644 (file)
index 0000000..6b7e861
--- /dev/null
@@ -0,0 +1,14 @@
+// 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.
+
+extern crate collections;
+extern crate libc as collections; //~ ERROR E0259
+
+fn main() {}
diff --git a/src/test/compile-fail/E0260.rs b/src/test/compile-fail/E0260.rs
new file mode 100644 (file)
index 0000000..d20829b
--- /dev/null
@@ -0,0 +1,19 @@
+// 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.
+
+extern crate collections;
+
+mod collections { //~ ERROR E0260
+    pub trait MyTrait {
+        fn do_something();
+    }
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0261.rs b/src/test/compile-fail/E0261.rs
new file mode 100644 (file)
index 0000000..4196ad3
--- /dev/null
@@ -0,0 +1,17 @@
+// 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 foo(x: &'a str) { } //~ ERROR E0261
+
+struct Foo {
+    x: &'a str, //~ ERROR E0261
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0262.rs b/src/test/compile-fail/E0262.rs
new file mode 100644 (file)
index 0000000..e09e476
--- /dev/null
@@ -0,0 +1,13 @@
+// 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 foo<'static>(x: &'static str) { } //~ ERROR E0262
+
+fn main() {}
diff --git a/src/test/compile-fail/E0263.rs b/src/test/compile-fail/E0263.rs
new file mode 100644 (file)
index 0000000..09f654c
--- /dev/null
@@ -0,0 +1,13 @@
+// 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 foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { } //~ ERROR E0263
+
+fn main() {}
diff --git a/src/test/compile-fail/E0264.rs b/src/test/compile-fail/E0264.rs
new file mode 100644 (file)
index 0000000..9233297
--- /dev/null
@@ -0,0 +1,18 @@
+// 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.
+
+#![feature(lang_items)]
+
+extern "C" {
+    #[lang = "cake"]
+    fn cake(); //~ ERROR E0264
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/E0267.rs b/src/test/compile-fail/E0267.rs
new file mode 100644 (file)
index 0000000..6287256
--- /dev/null
@@ -0,0 +1,13 @@
+// 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 w = || { break; }; //~ ERROR E0267
+}
diff --git a/src/test/compile-fail/E0268.rs b/src/test/compile-fail/E0268.rs
new file mode 100644 (file)
index 0000000..41e88e2
--- /dev/null
@@ -0,0 +1,13 @@
+// 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() {
+    break; //~ ERROR E0268
+}
diff --git a/src/test/compile-fail/E0271.rs b/src/test/compile-fail/E0271.rs
new file mode 100644 (file)
index 0000000..d322c8b
--- /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.
+
+trait Trait { type AssociatedType; }
+
+fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
+    println!("in foo");
+}
+
+impl Trait for i8 { type AssociatedType = &'static str; }
+
+fn main() {
+    foo(3_i8); //~ ERROR E0271
+}
diff --git a/src/test/compile-fail/E0275.rs b/src/test/compile-fail/E0275.rs
new file mode 100644 (file)
index 0000000..8dfd1d9
--- /dev/null
@@ -0,0 +1,18 @@
+// 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.
+
+trait Foo {}
+
+struct Bar<T>(T);
+
+impl<T> Foo for T where Bar<T>: Foo {} //~ ERROR E0275
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0276.rs b/src/test/compile-fail/E0276.rs
new file mode 100644 (file)
index 0000000..62e43b0
--- /dev/null
@@ -0,0 +1,20 @@
+// 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.
+
+trait Foo {
+    fn foo<T>(x: T);
+}
+
+impl Foo for bool {
+    fn foo<T>(x: T) where T: Copy {} //~ ERROR E0276
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/E0277.rs b/src/test/compile-fail/E0277.rs
new file mode 100644 (file)
index 0000000..7737f12
--- /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.
+
+trait Foo {
+    fn bar(&self);
+}
+
+fn some_func<T: Foo>(foo: T) {
+    foo.bar();
+}
+
+fn main() {
+    some_func(5i32); //~ ERROR E0277
+}
diff --git a/src/test/compile-fail/E0281.rs b/src/test/compile-fail/E0281.rs
new file mode 100644 (file)
index 0000000..d468cd3
--- /dev/null
@@ -0,0 +1,16 @@
+// 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 foo<F: Fn()>(x: F) { }
+
+fn main() {
+    foo(|y| { }); //~ ERROR E0281
+                  //~^ ERROR E0281
+}
diff --git a/src/test/compile-fail/E0282.rs b/src/test/compile-fail/E0282.rs
new file mode 100644 (file)
index 0000000..dfc7026
--- /dev/null
@@ -0,0 +1,13 @@
+// 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 = "hello".chars().rev().collect(); //~ ERROR E0282
+}
diff --git a/src/test/compile-fail/E0283.rs b/src/test/compile-fail/E0283.rs
new file mode 100644 (file)
index 0000000..844c47f
--- /dev/null
@@ -0,0 +1,29 @@
+// 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.
+
+trait Generator {
+    fn create() -> u32;
+}
+
+struct Impl;
+
+impl Generator for Impl {
+    fn create() -> u32 { 1 }
+}
+
+struct AnotherImpl;
+
+impl Generator for AnotherImpl {
+    fn create() -> u32 { 2 }
+}
+
+fn main() {
+    let cont: u32 = Generator::create(); //~ ERROR E0283
+}
diff --git a/src/test/compile-fail/E0296.rs b/src/test/compile-fail/E0296.rs
new file mode 100644 (file)
index 0000000..562fd00
--- /dev/null
@@ -0,0 +1,13 @@
+// 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.
+
+#![recursion_limit] //~ ERROR E0296
+
+fn main() {}
diff --git a/src/test/compile-fail/E0297.rs b/src/test/compile-fail/E0297.rs
new file mode 100644 (file)
index 0000000..43166c1
--- /dev/null
@@ -0,0 +1,15 @@
+// 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 xs : Vec<Option<i32>> = vec!(Some(1), None);
+
+    for Some(x) in xs {} //~ ERROR E0297
+}
diff --git a/src/test/compile-fail/E0301.rs b/src/test/compile-fail/E0301.rs
new file mode 100644 (file)
index 0000000..06e9828
--- /dev/null
@@ -0,0 +1,17 @@
+// 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() {
+    match Some(()) {
+        None => { },
+        option if option.take().is_none() => {}, //~ ERROR E0301
+        Some(_) => { }
+    }
+}
diff --git a/src/test/compile-fail/E0302.rs b/src/test/compile-fail/E0302.rs
new file mode 100644 (file)
index 0000000..6a5ad40
--- /dev/null
@@ -0,0 +1,17 @@
+// 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() {
+    match Some(()) {
+        None => { },
+        option if { option = None; false } => { }, //~ ERROR E0302
+        Some(_) => { }
+    }
+}
diff --git a/src/test/compile-fail/E0303.rs b/src/test/compile-fail/E0303.rs
new file mode 100644 (file)
index 0000000..67947fd
--- /dev/null
@@ -0,0 +1,17 @@
+// 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() {
+    match Some("hi".to_string()) {
+        ref op_string_ref @ Some(s) => {}, //~ ERROR E0303
+                                           //~^ ERROR E0009
+        None => {},
+    }
+}
index 61cc8902036ec9966fdfc35d36134f23570900f6..9ffaef7472b7830d4c5b259589c4109cd66350ff 100644 (file)
@@ -8,9 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-const A: [u32; "hello"] = []; //~ ERROR E0306
-const B: [u32; true] = []; //~ ERROR E0306
-const C: [u32; 0.0] = []; //~ ERROR E0306
+const A: [u32; "hello"] = [];
+//~^ ERROR expected `usize` for array length, found string literal [E0306]
+//~| NOTE expected `usize`
+
+const B: [u32; true] = [];
+//~^ ERROR expected `usize` for array length, found boolean [E0306]
+//~| NOTE expected `usize`
+
+const C: [u32; 0.0] = [];
+//~^ ERROR expected `usize` for array length, found float [E0306]
+//~| NOTE expected `usize`
 
 fn main() {
 }
index becbc27138b770e700d524844357252c7c017c95..ff886e63dc59ef1aebab668fe16ce51d5edcd29c 100644 (file)
@@ -15,15 +15,21 @@ trait Get {
 
 fn get<T:Get,U:Get>(x: T, y: U) -> Get::Value {}
 //~^ ERROR ambiguous associated type
+//~| NOTE ambiguous associated type
+//~| NOTE specify the type using the syntax `<Type as Get>::Value`
 
 trait Grab {
     type Value;
     fn grab(&self) -> Grab::Value;
     //~^ ERROR ambiguous associated type
+    //~| NOTE ambiguous associated type
+    //~| NOTE specify the type using the syntax `<Type as Grab>::Value`
 }
 
 type X = std::ops::Deref::Target;
 //~^ ERROR ambiguous associated type
+//~| NOTE ambiguous associated type
+//~| NOTE specify the type using the syntax `<Type as std::ops::Deref>::Target`
 
 fn main() {
 }
index de315a41361a7900667705cb9eb7882a7c871548..1a5496f0551507354ffcb5219f7fbca94911b742 100644 (file)
@@ -11,7 +11,9 @@
 // Tests that a function with a ! annotation always actually fails
 
 fn bad_bang(i: usize) -> ! {
-    return 7; //~ ERROR `return` in a function declared as diverging [E0166]
+    return 7;
+    //~^ ERROR `return` in a function declared as diverging [E0166]
+    //~| NOTE diverging function cannot return
 }
 
 fn main() { bad_bang(5); }
index 87e40df7663baacabd7c522321104fc0e7c82a61..ec330247f238b07c77a7f6a6b955dcaced8651b0 100644 (file)
@@ -22,4 +22,6 @@ fn main() {
     let mut books = vec![1,2,3];
     spawn(|| books.push(4));
     //~^ ERROR E0373
+    //~| NOTE `books` is borrowed here
+    //~| NOTE may outlive borrowed value `books`
 }
index 67700be890b1faa8a9c9090fdb0ea8382ddfd854..81685c32f2f29b6285b5fdadd05532746cc4c5b0 100644 (file)
@@ -20,6 +20,8 @@ fn foo<'a>(x: &'a i32) -> Box<FnMut()+'a> {
     let mut books = vec![1,2,3];
     Box::new(|| books.push(4))
     //~^ ERROR E0373
+    //~| NOTE `books` is borrowed here
+    //~| NOTE may outlive borrowed value `books`
 }
 
 fn main() { }
index 9c210c132a3131084733aead1eabdf7b34870d8c..f686a146042cee4351a2c1874605d7a3ab7e000a 100644 (file)
@@ -27,23 +27,34 @@ impl Clone for TestE { fn clone(&self) -> Self { *self } }
 impl Copy for MyType {}
 
 impl Copy for &'static mut MyType {}
-//~^ ERROR E0206
+//~^ ERROR the trait `Copy` may not be implemented for this type
+//~| NOTE type is not a structure or enumeration
 impl Clone for MyType { fn clone(&self) -> Self { *self } }
 
 impl Copy for (MyType, MyType) {}
-//~^ ERROR E0206
-//~| ERROR E0117
+//~^ ERROR the trait `Copy` may not be implemented for this type
+//~| NOTE type is not a structure or enumeration
+//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
+//~| NOTE impl doesn't use types inside crate
+//~| NOTE the impl does not reference any types defined in this crate
 
 impl Copy for &'static NotSync {}
-//~^ ERROR E0206
+//~^ ERROR the trait `Copy` may not be implemented for this type
+//~| NOTE type is not a structure or enumeration
 
 impl Copy for [MyType] {}
-//~^ ERROR E0206
-//~| ERROR E0117
+//~^ ERROR the trait `Copy` may not be implemented for this type
+//~| NOTE type is not a structure or enumeration
+//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
+//~| NOTE impl doesn't use types inside crate
+//~| NOTE the impl does not reference any types defined in this crate
 
 impl Copy for &'static [NotSync] {}
-//~^ ERROR E0206
-//~| ERROR E0117
+//~^ ERROR the trait `Copy` may not be implemented for this type
+//~| NOTE type is not a structure or enumeration
+//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
+//~| NOTE impl doesn't use types inside crate
+//~| NOTE the impl does not reference any types defined in this crate
 
 fn main() {
 }
index d813cf32954e3349edcbfe5c1e21a7d3bb6af584..92568b27f7c1da143e24a4fd2a982f3df13026d7 100644 (file)
@@ -20,7 +20,9 @@ trait Foo {
 }
 
 impl Foo for u32 {
-    const fn f() -> u32 { 22 } //~ ERROR E0379
+    const fn f() -> u32 { 22 }
+    //~^ ERROR E0379
+    //~| NOTE trait fns cannot be const
 }
 
 fn main() { }
index 5dadd892f83520cca532436ce88986e7b4649476..398dc2f22150cc8c90fc1daf0ee9030990b00c86 100644 (file)
 const ARR3: [i32; X3] = [99; 6]; //~ NOTE: for array length here
 
 const Y: usize = 42.0 == 42.0;
-const ARRR: [i32; Y] = [99; 1]; //~ ERROR: expected usize for array length
+const ARRR: [i32; Y] = [99; 1];
+//~^ ERROR: expected `usize` for array length, found boolean [E0306]
+//~| NOTE expected `usize`
+
 const Y1: usize = 42.0 >= 42.0;
-const ARRR1: [i32; Y] = [99; 1]; //~ ERROR: expected usize for array length
+const ARRR1: [i32; Y] = [99; 1];
+//~^ ERROR: expected `usize` for array length, found boolean [E0306]
+//~| NOTE expected `usize`
+
 const Y2: usize = 42.0 <= 42.0;
-const ARRR2: [i32; Y] = [99; 1]; //~ ERROR: expected usize for array length
+const ARRR2: [i32; Y] = [99; 1];
+//~^ ERROR: expected `usize` for array length, found boolean [E0306]
+//~| NOTE expected `usize`
+
 const Y3: usize = 42.0 > 42.0;
-const ARRR3: [i32; Y] = [99; 0]; //~ ERROR: expected usize for array length
+const ARRR3: [i32; Y] = [99; 0];
+//~^ ERROR: expected `usize` for array length, found boolean [E0306]
+//~| NOTE expected `usize`
+
 const Y4: usize = 42.0 < 42.0;
-const ARRR4: [i32; Y] = [99; 0]; //~ ERROR: expected usize for array length
+const ARRR4: [i32; Y] = [99; 0];
+//~^ ERROR: expected `usize` for array length, found boolean [E0306]
+//~| NOTE expected `usize`
+
 const Y5: usize = 42.0 != 42.0;
-const ARRR5: [i32; Y] = [99; 0]; //~ ERROR: expected usize for array length
+const ARRR5: [i32; Y] = [99; 0];
+//~^ ERROR: expected `usize` for array length, found boolean [E0306]
+//~| NOTE expected `usize`
+
 
 fn main() {
     let _ = ARR;
index 7b915647884f2ac169a6e45f43b1b1f0083c8c2d..bd190a6df8e39f97153e0b76862e97f42ef3e452 100644 (file)
@@ -7,8 +7,6 @@
 // <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.
-#![feature(no_core)]
-#![no_core]
 
 // This tests that conflicting imports shows both `use` lines
 // when reporting the error.
@@ -23,5 +21,6 @@ pub fn foo() {} // implementation 2
 
 use sub1::foo; //~ NOTE previous import of `foo` here
 use sub2::foo; //~ ERROR a value named `foo` has already been imported in this module [E0252]
+               //~| NOTE already imported
 
 fn main() {}
index 37737fda4749e5004ce1e666560e0da343143158..d9ac715fa9548447340e9f33633299676fb352ae 100644 (file)
@@ -16,5 +16,7 @@ struct Vec<T, A = Heap>(
     marker::PhantomData<(T,A)>);
 
 fn main() {
-    let _: Vec; //~ ERROR wrong number of type arguments: expected at least 1, found 0
+    let _: Vec;
+    //~^ ERROR E0243
+    //~| NOTE expected at least 1 type arguments, found 0
 }
index ad7e4f190c5b9df7fe358c88f9b51461e8024479..8f733ddfce187f7c73b58d82e652be928597b0be 100644 (file)
@@ -17,5 +17,6 @@ struct Vec<T, A = Heap>(
 
 fn main() {
     let _: Vec<isize, Heap, bool>;
-    //~^ ERROR wrong number of type arguments: expected at most 2, found 3
+    //~^ ERROR E0244
+    //~| NOTE expected at most 2 type arguments, found 3
 }
index 981eddc9dd96b20d502cf8523615be8bf7e3233f..f6e9ab2d614bce630b7f8dae5a1d8f56e2f8576e 100644 (file)
@@ -12,7 +12,9 @@
 
 impl Foo {
     fn orange(&self) {} //~ NOTE previous definition of `orange` here
-    fn orange(&self) {} //~ ERROR duplicate definitions with name `orange`
+    fn orange(&self) {}
+    //~^ ERROR duplicate definition
+    //~| NOTE duplicate definition
 }
 
 fn main() {}
index 23401db21d89063643045ccf10d4fcac92783807..d48433ee928f1eb2b7c84d6133045766b3e14f3e 100644 (file)
@@ -19,6 +19,7 @@ trait Fun {
 struct Holder { x: String }
 
 impl<'a> Fun for Holder { //~ ERROR E0207
+                          //~| NOTE unconstrained lifetime parameter
     type Output = &'a str;
     fn call<'b>(&'b self) -> &'b str {
         &self.x[..]
index 9b3e28cbc01ee4eaa4cf98d746a6a9731c914a3c..e0ea1a4cac58bb83102cacf447fb478961897928 100644 (file)
 
 trait Foo {
     fn bar(&self);
-    const MY_CONST: u32;
+    //~^ NOTE original trait requirement
+    //~| NOTE original trait requirement
+    const MY_CONST: u32; //~ NOTE original trait requirement
 }
 
 pub struct FooConstForMethod;
 
 impl Foo for FooConstForMethod {
     //~^ ERROR E0046
+    //~| NOTE missing `bar` in implementation
     const bar: u64 = 1;
     //~^ ERROR E0323
+    //~| NOTE does not match trait
     const MY_CONST: u32 = 1;
 }
 
@@ -28,17 +32,21 @@ impl Foo for FooConstForMethod {
 
 impl Foo for FooMethodForConst {
     //~^ ERROR E0046
+    //~| NOTE missing `MY_CONST` in implementation
     fn bar(&self) {}
     fn MY_CONST() {}
     //~^ ERROR E0324
+    //~| NOTE does not match trait
 }
 
 pub struct FooTypeForMethod;
 
 impl Foo for FooTypeForMethod {
     //~^ ERROR E0046
+    //~| NOTE missing `bar` in implementation
     type bar = u64;
     //~^ ERROR E0325
+    //~| NOTE does not match trait
     const MY_CONST: u32 = 1;
 }
 
index 5322966ae2ea0544a78d19a242c8d592a74187d2..001e4b51bebc4f619beaa84665fb38a7d6ecf525 100644 (file)
@@ -14,5 +14,7 @@ fn new<T>() -> &'static T {
 
 fn main() {
     let &v = new();
-    //~^ ERROR type annotations or generic parameter binding required
+    //~^ ERROR unable to infer enough type information about `_` [E0282]
+    //~| NOTE cannot infer type for `_`
+    //~| NOTE type annotations or generic parameter binding
 }
index dabc0acba370e07a4344f577306d9752f6fcbf22..7cbee402b368253cb59845e912ed357307f77f33 100644 (file)
@@ -14,5 +14,7 @@ fn new<'r, T>() -> &'r T {
 
 fn main() {
     let &v = new();
-    //~^ ERROR type annotations or generic parameter binding required
+    //~^ ERROR unable to infer enough type information about `_` [E0282]
+    //~| NOTE cannot infer type for `_`
+    //~| NOTE type annotations or generic parameter binding
 }
index c87dcb8ae79b21119b3b01b4ccd13b1afa1d4949..dd02fa7ac151c10186bd633726d7dc2567896f8f 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn fn1(0: Box) {} //~ ERROR: wrong number of type arguments: expected 1, found 0
+fn fn1(0: Box) {}
+        //~^ ERROR E0243
+        //~| NOTE expected 1 type arguments, found 0
 
 fn main() {}
index bdf344dcdfe8da8377ba866e99756a1fb1ad3b39..3d6f224c249040a1c1d168d0b5357ba9af7c06de 100644 (file)
 
 enum Foo {
     A = 1,
-    B = 1, //~ ERROR discriminant value `1isize` already exists
-    //~^^ NOTE conflicting
+    //~^ NOTE first use
+    //~| NOTE first use
+    //~| NOTE first use
+    B = 1, //~ ERROR discriminant value
+    //~^ NOTE enum already
     C = 0,
-    D, //~ ERROR discriminant value `1isize` already exists
-    //~^^^^^ NOTE conflicting
-    E = N, //~ ERROR discriminant value `1isize` already exists
-    //~^^^^^^^ NOTE conflicting
+    D, //~ ERROR discriminant value
+    //~^ NOTE enum already
+
+    E = N, //~ ERROR discriminant value
+    //~^ NOTE enum already
+
 }
 
 fn main() {}
index 4aa2571cad0cc9418709407687ff5ba9ac19056d..d258a4a8b3325b18149d8dd641a3c6d49534a46b 100644 (file)
@@ -21,6 +21,7 @@ fn crash_please() {
 struct Newtype(Option<Box<usize>>);
 
 impl<'a> Iterator for Newtype { //~ ERROR E0207
+                                //~| NOTE unconstrained lifetime parameter
     type Item = &'a Box<usize>;
 
     fn next(&mut self) -> Option<&Box<usize>> {
index df2a70160f866e58bafe4a9c4b06518e7493f747..e266f004317e7f46d1adb52b8bb96498bc56acad 100644 (file)
@@ -18,6 +18,6 @@ fn h(x:i32) -> i32 {3*x}
     vfnfer.push(box h);
     println!("{:?}",(vfnfer[0] as Fn)(3));
     //~^ ERROR the precise format of `Fn`-family traits'
-    //~| ERROR wrong number of type arguments: expected 1, found 0
+    //~| ERROR E0243
     //~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`)
 }
index 1a9bb4c29f3e0183ad2f0a6a0cf45e5dd44f0214..1be082ba9bbbad454982a42a82d8ce3e7c4b6361 100644 (file)
@@ -14,4 +14,6 @@ fn main()
     fn bar(x:i32) ->i32 { 3*x };
     let b:Box<Any> = Box::new(bar as fn(_)->_);
     b.downcast_ref::<fn(_)->_>(); //~ ERROR E0282
+                                  //~| NOTE cannot infer type for `_`
+                                  //~| NOTE type annotations or generic parameter binding required
 }
index 4ed44154c4748ce51514dc0201904507127a0a2d..f1c559b6b889f207cdc7e4542cd60de3895775a3 100644 (file)
@@ -16,6 +16,7 @@ pub trait D {
     fn f<T>(self)
         where T<Bogus = Foo>: A;
         //~^ ERROR associated type bindings are not allowed here [E0229]
+        //~| NOTE associate type not allowed here
 }
 
 fn main() {}
index 1d7c2187045ea28efdfe5925b5214437cc863a55..3959c22d1d489384a9baccac9b838ad467fcd2af 100644 (file)
@@ -14,6 +14,7 @@ pub trait D {
     fn f<T>(self)
         where T<Bogus = Self::AlsoBogus>: A;
         //~^ ERROR associated type bindings are not allowed here [E0229]
+        //~| NOTE associate type not allowed here
 }
 
 fn main() {}
index f98cf6575d6ec5b2340b65bd2b8cd27462762b81..b1047ce18cccdf552ce6bd2ceee305fe78fe5a81 100644 (file)
@@ -18,7 +18,8 @@ struct Recurrence {
         }
 
         impl Iterator for Recurrence {
-            //~^ ERROR not all trait items implemented, missing: `Item` [E0046]
+            //~^ ERROR E0046
+            //~| NOTE missing `Item` in implementation
             #[inline]
             fn next(&mut self) -> Option<u64> {
                 if self.pos < 2 {
index 6c42c88bee6d09ee72a5e3870dd28faa54f3882a..2062e2373129bd77d698d0aa555743dd85d0494d 100644 (file)
@@ -34,7 +34,8 @@ extern "rust-call" fn call_mut(&mut self, (comp,): (C,)) -> Prototype {
 }
 
 impl<C: Component> FnOnce<(C,)> for Prototype {
-    //~^ ERROR not all trait items implemented, missing: `Output` [E0046]
+    //~^ ERROR E0046
+    //~| NOTE missing `Output` in implementation
     extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype {
         Fn::call(&self, (comp,))
     }
index ede81bea32ae3bfaea3db5168a4ea23f2ed19a1d..d39fd539dcebc301350cc85ba5e606408c774f20 100644 (file)
@@ -28,7 +28,8 @@ fn deref(&self) -> &i8 { &self.0 }
 
         // Causes ICE
         impl Deref for Thing {
-            //~^ ERROR not all trait items implemented, missing: `Target` [E0046]
+            //~^ ERROR E0046
+            //~| NOTE missing `Target` in implementation
             fn deref(&self) -> i8 { self.0 }
         }
 
index c849716f21a378d20c55d75d46520a1faa195a3f..46e82363c8bd832597d76b525427754b9c0a0a51 100644 (file)
@@ -11,7 +11,9 @@
 use std::sync::{self, Arc}; //~ NOTE previous import
                             //~^ NOTE previous import
 use std::sync::Arc; //~ ERROR a type named
+                    //~| NOTE already imported
 use std::sync; //~ ERROR a module named
+               //~| NOTE already imported
 
 fn main() {
 }
index ee6ec52761266607887eef14302a41e2102c6278..e89bff025e006bf6fed83b4939302027ecadf66f 100644 (file)
@@ -16,5 +16,6 @@ fn main() {
     //~| expected type `usize`
     //~| found type `S`
     //~| expected usize, found struct `S`
-    //~| ERROR expected usize for repeat count, found struct
+    //~| ERROR expected `usize` for repeat count, found struct [E0306]
+    //~| expected `usize`
 }
index 6a97ae82ddf317685d0f72e11c6cf2938693d29a..ce3fa487d4e02fa0b892acf8d676340b50a18a22 100644 (file)
@@ -10,7 +10,7 @@
 
 struct Foo;
 #[derive(Copy, Clone)]
-//~^ ERROR the trait `Copy` may not be implemented for this type; field `0` does not implement
+//~^ ERROR the trait `Copy` may not be implemented for this type
 struct Bar(Foo);
 
 fn main() {}
diff --git a/src/test/compile-fail/issue-33784.rs b/src/test/compile-fail/issue-33784.rs
new file mode 100644 (file)
index 0000000..4229be2
--- /dev/null
@@ -0,0 +1,46 @@
+// 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.
+
+use std::ops::Deref;
+
+struct Obj<F> where F: FnMut() -> u32 {
+    fn_ptr: fn() -> (),
+    closure: F,
+}
+
+struct C {
+    c_fn_ptr: fn() -> (),
+}
+
+struct D(C);
+
+impl Deref for D {
+    type Target = C;
+    fn deref(&self) -> &C {
+        &self.0
+    }
+}
+
+
+fn empty() {}
+
+fn main() {
+    let o = Obj { fn_ptr: empty, closure: || 42 };
+    let p = &o;
+    p.closure(); //~ ERROR no method named `closure` found
+    //~^ NOTE use `(p.closure)(...)` if you meant to call the function stored in the `closure` field
+    let q = &p;
+    q.fn_ptr(); //~ ERROR no method named `fn_ptr` found
+    //~^ NOTE use `(q.fn_ptr)(...)` if you meant to call the function stored in the `fn_ptr` field
+    let r = D(C { c_fn_ptr: empty });
+    let s = &r;
+    s.c_fn_ptr(); //~ ERROR no method named `c_fn_ptr` found
+    //~^ NOTE use `(s.c_fn_ptr)(...)` if you meant to call the function stored in the `c_fn_ptr`
+}
index 6fae18dec10a67e602338a3f15de815a623b1589..5e3b777cc0b62cd845cb9af92176b3c64a590d8c 100644 (file)
@@ -15,7 +15,9 @@ enum S {
 fn bug(l: S) {
     match l {
         S::B{ } => { },
-        //~^ ERROR ambiguous associated type; specify the type using the syntax `<S as Trait>::B`
+        //~^ ERROR ambiguous associated type
+        //~| NOTE ambiguous associated type
+        //~| NOTE specify the type using the syntax `<S as Trait>::B`
     }
 }
 
index 67f0e7aaf9717ee68161684dccc9d3ee6caf026c..5c4f161a5004ed9c20c190da2fe38468d8a98eac 100644 (file)
@@ -17,6 +17,7 @@ pub trait MethodType {
 pub struct MTFn;
 
 impl<'a> MethodType for MTFn { //~ ERROR E0207
+                               //~| NOTE unconstrained lifetime parameter
     type GetProp = fmt::Debug + 'a;
 }
 
index 9a1b5d9b83d2c27a910164b0d687567dca23b43f..09371fbafcb560f98e91acab4a483709a4745a6b 100644 (file)
@@ -14,7 +14,10 @@ fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> {
     // FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
     id(Box::new(|| *v))
         //~^ ERROR E0373
-        //~| ERROR cannot move out of borrowed content
+        //~| NOTE `v` is borrowed here
+        //~| NOTE may outlive borrowed value `v`
+        //~| ERROR E0507
+        //~| NOTE cannot move out of borrowed content
 }
 
 fn main() {
index 392d38a6144f19d5364d12ec0363d41881d8d44e..f5aa4fadbed88605886670d9165c9e4ce41fd759 100644 (file)
@@ -9,4 +9,4 @@
 // except according to those terms.
 
 fn main() { format!("{:?}", None); }
-    //~^ ERROR type annotations or generic parameter binding required
+    //~^ ERROR unable to infer enough type information about `_` [E0282]
index acf1d766b6a11a65107d768ba7ee1e094b32e1e7..71f28054579157b40e159f1d924e72b8b4913bcc 100644 (file)
@@ -11,5 +11,5 @@
 fn main() {
     // Unconstrained type:
     format!("{:?}", None);
-    //~^ ERROR type annotations or generic parameter binding required
+    //~^ ERROR unable to infer enough type information about `_` [E0282]
 }
index 3f81e51efe2ef40badd39877f31a4780da6a7b9a..e397805565bbdcd95c036d8f1ce6ff45dbe560be 100644 (file)
@@ -12,5 +12,7 @@
 
 fn main() {
     mem::transmute(0);
-    //~^ ERROR type annotations or generic parameter binding required
+    //~^ ERROR unable to infer enough type information about `_` [E0282]
+    //~| NOTE cannot infer type for `_`
+    //~| NOTE type annotations or generic parameter binding
 }
index 7f408be9c02d4c77dc3c9da9b97371b254748c1a..c3f3a718ad0e21cf5c6a91ec11b62fe5031d442f 100644 (file)
@@ -10,7 +10,9 @@
 
 fn foo(b: bool) -> Result<bool,String> {
     Err("bar".to_string());
-    //~^ ERROR type annotations or generic parameter binding required
+    //~^ ERROR unable to infer enough type information about `_` [E0282]
+    //~| NOTE cannot infer type for `_`
+    //~| NOTE type annotations or generic parameter binding
 }
 
 fn main() {
index c1f9dd6a4b8935a501acc71b898a311694592130..a64522a0e5b7543bfc038c051d3247a759a9088a 100644 (file)
@@ -17,7 +17,9 @@ pub fn foo<State>(_: TypeWithState<State>) {}
 
 pub fn bar() {
    foo(TypeWithState(marker::PhantomData));
-   //~^ ERROR type annotations or generic parameter binding required
+   //~^ ERROR unable to infer enough type information about `_` [E0282]
+   //~| NOTE cannot infer type for `_`
+   //~| NOTE type annotations or generic parameter binding
 }
 
 fn main() {
index 327fb6adf1d54f20374bff64a5e94c733c316003..e3cb1d0c7daafac93b6be3ec2842647bf4ca1e8c 100644 (file)
@@ -10,5 +10,7 @@
 
 fn main() {
     let v = &[];
-    let it = v.iter(); //~ ERROR type annotations or generic parameter binding required
+    let it = v.iter(); //~ ERROR unable to infer enough type information about `_` [E0282]
+                       //~| NOTE cannot infer type for `_`
+                       //~| NOTE type annotations or generic parameter binding
 }
index 59d75c5a787a6ec3815c66ee7473c8b776349f54..4f86909765ef1f84f0efd972291286990f8b9617 100644 (file)
@@ -32,7 +32,7 @@ fn foo(&self) -> isize {2}
 fn m1() {
     // we couldn't infer the type of the vector just based on calling foo()...
     let mut x = Vec::new();
-    //~^ ERROR type annotations or generic parameter binding required
+    //~^ ERROR unable to infer enough type information about `_` [E0282]
     x.foo();
 }
 
index 0b12a9acbcb9e9d56de662b81d4234bda7fc35a7..eba61ede8cb20e673e945fbe6c19e8c6043f0422 100644 (file)
@@ -19,6 +19,7 @@ struct Foo {
 fn struct_with_a_nested_enum_and_vector() {
     match (Foo { first: true, second: None }) {
 //~^ ERROR non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered
+//~| NOTE pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered
         Foo { first: true, second: None } => (),
         Foo { first: true, second: Some(_) } => (),
         Foo { first: false, second: None } => (),
@@ -35,6 +36,7 @@ enum Color {
 fn enum_with_single_missing_variant() {
     match Color::Red {
     //~^ ERROR non-exhaustive patterns: `Red` not covered
+    //~| NOTE pattern `Red` not covered
         Color::CustomRGBA { .. } => (),
         Color::Green => ()
     }
@@ -47,6 +49,7 @@ enum Direction {
 fn enum_with_multiple_missing_variants() {
     match Direction::North {
     //~^ ERROR non-exhaustive patterns: `East`, `South` and `West` not covered
+    //~| NOTE patterns `East`, `South` and `West` not covered
         Direction::North => ()
     }
 }
@@ -58,6 +61,7 @@ enum ExcessiveEnum {
 fn enum_with_excessive_missing_variants() {
     match ExcessiveEnum::First {
     //~^ ERROR `Second`, `Third`, `Fourth` and 8 more not covered
+    //~| NOTE patterns `Second`, `Third`, `Fourth` and 8 more not covered
 
         ExcessiveEnum::First => ()
     }
@@ -66,6 +70,7 @@ fn enum_with_excessive_missing_variants() {
 fn enum_struct_variant() {
     match Color::Red {
     //~^ ERROR non-exhaustive patterns: `CustomRGBA { a: true, .. }` not covered
+    //~| NOTE pattern `CustomRGBA { a: true, .. }` not covered
         Color::Red => (),
         Color::Green => (),
         Color::CustomRGBA { a: false, r: _, g: _, b: 0 } => (),
@@ -82,6 +87,7 @@ fn vectors_with_nested_enums() {
     let x: &'static [Enum] = &[Enum::First, Enum::Second(false)];
     match *x {
     //~^ ERROR non-exhaustive patterns: `[Second(true), Second(false)]` not covered
+    //~| NOTE pattern `[Second(true), Second(false)]` not covered
         [] => (),
         [_] => (),
         [Enum::First, _] => (),
@@ -95,6 +101,7 @@ fn vectors_with_nested_enums() {
 fn missing_nil() {
     match ((), false) {
     //~^ ERROR non-exhaustive patterns: `((), false)` not covered
+    //~| NOTE pattern `((), false)` not covered
         ((), true) => ()
     }
 }
index 5c661bfcdc0c99c99d0c248d40280b72246fc33c..e685ebc272098b1264366b8a59b0905305a4829e 100644 (file)
@@ -25,7 +25,11 @@ impl S {
     fn f<T>() {}
 }
 
-type A = <S as Tr>::A::f<u8>; //~ ERROR type parameters are not allowed on this type
-//~^ ERROR ambiguous associated type; specify the type using the syntax `<<S as Tr>::A as Trait>::f`
+type A = <S as Tr>::A::f<u8>;
+//~^ ERROR type parameters are not allowed on this type
+//~| NOTE type parameter not allowed
+//~| ERROR ambiguous associated type
+//~| NOTE ambiguous associated type
+//~| NOTE specify the type using the syntax `<<S as Tr>::A as Trait>::f`
 
 fn main() {}
index 4fda8ec3f384ebaa2185e6c365d1bbefd54730be..6be2adbe2a0d1ac0eb200159b11af647bc1f875b 100644 (file)
 
 fn escaping_borrow_of_closure_params_1() {
     let g = |x: usize, y:usize| {
+        //~^ NOTE reference must be valid for the scope of call-site for function
+        //~| NOTE ...but borrowed value is only valid for the scope of function body
+        //~| NOTE reference must be valid for the scope of call-site for function
+        //~| NOTE ...but borrowed value is only valid for the scope of function body
         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
         //~^ ERROR `x` does not live long enough
         //~| ERROR `y` does not live long enough
@@ -31,6 +35,10 @@ fn escaping_borrow_of_closure_params_1() {
 
 fn escaping_borrow_of_closure_params_2() {
     let g = |x: usize, y:usize| {
+        //~^ NOTE reference must be valid for the scope of call-site for function
+        //~| NOTE ...but borrowed value is only valid for the scope of function body
+        //~| NOTE reference must be valid for the scope of call-site for function
+        //~| NOTE ...but borrowed value is only valid for the scope of function body
         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
         //~^ ERROR `x` does not live long enough
         //~| ERROR `y` does not live long enough
@@ -64,7 +72,11 @@ fn escaping_borrow_of_fn_params_1() {
     fn g<'a>(x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
         //~^ ERROR E0373
+        //~| NOTE `x` is borrowed here
+        //~| NOTE may outlive borrowed value `x`
         //~| ERROR E0373
+        //~| NOTE `y` is borrowed here
+        //~| NOTE may outlive borrowed value `y`
         return Box::new(f);
     };
 
@@ -75,7 +87,11 @@ fn escaping_borrow_of_fn_params_2() {
     fn g<'a>(x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
         let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
         //~^ ERROR E0373
+        //~| NOTE `x` is borrowed here
+        //~| NOTE may outlive borrowed value `x`
         //~| ERROR E0373
+        //~| NOTE `y` is borrowed here
+        //~| NOTE may outlive borrowed value `y`
         Box::new(f)
     };
 
@@ -99,7 +115,11 @@ impl S {
         fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
             //~^ ERROR E0373
+            //~| NOTE `x` is borrowed here
+            //~| NOTE may outlive borrowed value `x`
             //~| ERROR E0373
+            //~| NOTE `y` is borrowed here
+            //~| NOTE may outlive borrowed value `y`
             return Box::new(f);
         }
     }
@@ -113,7 +133,11 @@ impl S {
         fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
             //~^ ERROR E0373
+            //~| NOTE `x` is borrowed here
+            //~| NOTE may outlive borrowed value `x`
             //~| ERROR E0373
+            //~| NOTE `y` is borrowed here
+            //~| NOTE may outlive borrowed value `y`
             Box::new(f)
         }
     }
@@ -141,7 +165,11 @@ impl T for S {
         fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
             //~^ ERROR E0373
+            //~| NOTE `x` is borrowed here
+            //~| NOTE may outlive borrowed value `x`
             //~| ERROR E0373
+            //~| NOTE `y` is borrowed here
+            //~| NOTE may outlive borrowed value `y`
             return Box::new(f);
         }
     }
@@ -156,7 +184,11 @@ impl T for S {
         fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
             //~^ ERROR E0373
+            //~| NOTE `x` is borrowed here
+            //~| NOTE may outlive borrowed value `x`
             //~| ERROR E0373
+            //~| NOTE `y` is borrowed here
+            //~| NOTE may outlive borrowed value `y`
             Box::new(f)
         }
     }
@@ -184,7 +216,11 @@ trait T {
         fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
             //~^ ERROR E0373
+            //~| NOTE `x` is borrowed here
+            //~| NOTE may outlive borrowed value `x`
             //~| ERROR E0373
+            //~| NOTE `y` is borrowed here
+            //~| NOTE may outlive borrowed value `y`
             return Box::new(f);
         }
     }
@@ -198,7 +234,11 @@ trait T {
         fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> {
             let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`)
             //~^ ERROR E0373
+            //~| NOTE `x` is borrowed here
+            //~| NOTE may outlive borrowed value `x`
             //~| ERROR E0373
+            //~| NOTE `y` is borrowed here
+            //~| NOTE may outlive borrowed value `y`
             Box::new(f)
         }
     }
index 948dc8cd219689301a9b30ba2702422a39294451..40ba34b26ede673a1c0fb4f88e34f3d8b68e627e 100644 (file)
@@ -13,8 +13,11 @@ fn ignore<F>(_f: F) where F: for<'z> FnOnce(&'z isize) -> &'z isize {}
 fn nested() {
     let y = 3;
     ignore(
-        |z| { //~ ERROR E0373
+        |z| {
+            //~^ ERROR E0373
+            //~| NOTE may outlive borrowed value `y`
             if false { &y } else { z }
+            //~^ NOTE `y` is borrowed here
         });
 }
 
index 1758b28a32482555bb6911420f996ced91ed6330..555dd0f0c3945fd52c15de1690550b973f2cb1e7 100644 (file)
@@ -20,23 +20,27 @@ fn main() {
     //~| expected type `usize`
     //~| found type `()`
     //~| expected usize, found ()
-    //~| ERROR expected usize for repeat count, found tuple [E0306]
+    //~| ERROR expected `usize` for repeat count, found tuple [E0306]
+    //~| expected `usize`
     let c = [0; true];
     //~^ ERROR mismatched types
     //~| expected usize, found bool
-    //~| ERROR expected usize for repeat count, found boolean [E0306]
+    //~| ERROR expected `usize` for repeat count, found boolean [E0306]
+    //~| expected `usize`
     let d = [0; 0.5];
     //~^ ERROR mismatched types
     //~| expected type `usize`
     //~| found type `{float}`
     //~| expected usize, found floating-point variable
-    //~| ERROR expected usize for repeat count, found float [E0306]
+    //~| ERROR expected `usize` for repeat count, found float [E0306]
+    //~| expected `usize`
     let e = [0; "foo"];
     //~^ ERROR mismatched types
     //~| expected type `usize`
     //~| found type `&'static str`
     //~| expected usize, found &-ptr
-    //~| ERROR expected usize for repeat count, found string literal [E0306]
+    //~| ERROR expected `usize` for repeat count, found string literal [E0306]
+    //~| expected `usize`
     let f = [0; -4_isize];
     //~^ ERROR constant evaluation error
     //~| expected usize, found isize
@@ -55,5 +59,6 @@ struct G {
     //~| expected type `usize`
     //~| found type `main::G`
     //~| expected usize, found struct `main::G`
-    //~| ERROR expected usize for repeat count, found struct [E0306]
+    //~| ERROR expected `usize` for repeat count, found struct [E0306]
+    //~| expected `usize`
 }
index d058c6a5a3b93fbb6c6bf3f6d232d8e9fdc0806f..860e69fcaec4d46b6f0b43d12d17f4adc0ef8989 100644 (file)
@@ -31,9 +31,13 @@ impl SuperFoo for Bar {
 impl Bar {
     fn f() {
         let _: <Self>::Baz = true;
-//~^ERROR: ambiguous associated type; specify the type using the syntax `<Bar as Trait>::Baz`
+        //~^ ERROR ambiguous associated type
+        //~| NOTE ambiguous associated type
+        //~| NOTE specify the type using the syntax `<Bar as Trait>::Baz`
         let _: Self::Baz = true;
-//~^ERROR: ambiguous associated type; specify the type using the syntax `<Bar as Trait>::Baz`
+        //~^ ERROR ambiguous associated type
+        //~| NOTE ambiguous associated type
+        //~| NOTE specify the type using the syntax `<Bar as Trait>::Baz`
     }
 }
 
index c77494912bc751fc1715fb9de7544bffe274131b..e6545063dbd4414e4a246986693933f4751bbe3a 100644 (file)
@@ -34,7 +34,9 @@ fn test<T,U>(_: T, _: U)
 
 fn a() {
     test(22, std::default::Default::default());
-    //~^ ERROR type annotations or generic parameter binding required
+    //~^ ERROR unable to infer enough type information about `_` [E0282]
+    //~| NOTE cannot infer type for `_`
+    //~| NOTE type annotations or generic parameter binding
 }
 
 fn main() {}
index fb6c43a19059a42885a94ada94ab2f894e54dd1a..41242a44f58b80c1c852473ca2c8bbf39d38e4e2 100644 (file)
@@ -9,20 +9,27 @@
 // except according to those terms.
 
 fn foo1<T:Copy<U>, U>(x: T) {}
-//~^ ERROR: wrong number of type arguments: expected 0, found 1
+//~^ ERROR E0244
+//~| NOTE expected no type arguments, found 1
 
 trait Trait: Copy<Send> {}
-//~^ ERROR: wrong number of type arguments: expected 0, found 1
+//~^ ERROR E0244
+//~| NOTE expected no type arguments, found 1
 
 struct MyStruct1<T: Copy<T>>;
-//~^ ERROR wrong number of type arguments: expected 0, found 1
+//~^ ERROR E0244
+//~| NOTE expected no type arguments, found 1
 
 struct MyStruct2<'a, T: Copy<'a>>;
 //~^ ERROR: wrong number of lifetime parameters: expected 0, found 1
+//~| NOTE unexpected lifetime parameter
+
 
 fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
-//~^ ERROR: wrong number of type arguments: expected 0, found 1
-//~^^ ERROR: wrong number of lifetime parameters: expected 0, found 1
+//~^ ERROR E0244
+//~| NOTE expected no type arguments, found 1
+//~| ERROR: wrong number of lifetime parameters: expected 0, found 1
+//~| NOTE unexpected lifetime parameter
 
 fn main() {
 }
index d4f3cdfd8b7e248eefedc4d3896d13a0101ff235..42db3b47a04f3af15e6c3faf07ed8e2107a9b528 100644 (file)
 
 fn test() -> _ { 5 }
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 fn test2() -> (_, _) { (5, 5) }
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
 //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
+//~| NOTE not allowed in type signatures
 
 static TEST3: _ = "test";
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 static TEST4: _ = 145;
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 static TEST5: (_, _) = (1, 2);
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
 //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
+//~| NOTE not allowed in type signatures
 
 fn test6(_: _) { }
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 fn test7(x: _) { let _x: usize = x; }
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 fn test8(_f: fn() -> _) { }
 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+//~| NOTE not allowed in type signatures
 
 struct Test9;
 
 impl Test9 {
     fn test9(&self) -> _ { () }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     fn test10(&self, _x : _) { }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 }
 
 impl Clone for Test9 {
     fn clone(&self) -> _ { Test9 }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     fn clone_from(&mut self, other: _) { *self = Test9; }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 }
 
 struct Test10 {
     a: _,
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
     b: (_, _),
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
     //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
+    //~| NOTE not allowed in type signatures
 }
 
 pub fn main() {
     fn fn_test() -> _ { 5 }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     fn fn_test2() -> (_, _) { (5, 5) }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
     //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
+    //~| NOTE not allowed in type signatures
 
     static FN_TEST3: _ = "test";
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     static FN_TEST4: _ = 145;
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     static FN_TEST5: (_, _) = (1, 2);
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
     //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
+    //~| NOTE not allowed in type signatures
 
     fn fn_test6(_: _) { }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     fn fn_test7(x: _) { let _x: usize = x; }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     fn fn_test8(_f: fn() -> _) { }
     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| NOTE not allowed in type signatures
 
     struct FnTest9;
 
     impl FnTest9 {
         fn fn_test9(&self) -> _ { () }
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
 
         fn fn_test10(&self, _x : _) { }
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
     }
 
     impl Clone for FnTest9 {
         fn clone(&self) -> _ { FnTest9 }
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
 
         fn clone_from(&mut self, other: _) { *self = FnTest9; }
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
     }
 
     struct FnTest10 {
         a: _,
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
         b: (_, _),
         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
         //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
+        //~| NOTE not allowed in type signatures
+        //~| NOTE not allowed in type signatures
     }
 
 }
index 2cb46cc352beca366f166325584e56cfecc78199..f60d925a74864b918978de7a9ecc12ed9d8f4663 100644 (file)
@@ -17,5 +17,6 @@ struct Foo<'a, T:'a> {
 
 pub fn main() {
     let c: Foo<_, _> = Foo { r: &5 };
-    //~^ ERROR wrong number of type arguments: expected 1, found 2
+    //~^ ERROR E0244
+    //~| NOTE expected 1 type arguments, found 2
 }
index 8178335de5931a21d590311714e36a5bb6a65fbf..ec2675ece74b0dea088c6325650d63c22dd86682 100644 (file)
@@ -17,5 +17,6 @@ struct Foo<'a, T:'a> {
 
 pub fn main() {
     let c: Foo<_, usize> = Foo { r: &5 };
-    //~^ ERROR wrong number of type arguments: expected 1, found 2
+    //~^ ERROR E0244
+    //~| NOTE expected 1 type arguments, found 2
 }
index 04bbfc445edeaab920911845a249d8f4a30d7220..1209757610251cd8477b890325a24bdaf7727b2a 100644 (file)
@@ -13,7 +13,8 @@
 trait Trait {}
 
 fn f<F:Trait(isize) -> isize>(x: F) {}
-//~^ ERROR wrong number of type arguments: expected 0, found 1
+//~^ ERROR E0244
+//~| NOTE expected no type arguments, found 1
 //~| ERROR associated type `Output` not found
 
 fn main() {}
index c14de98e03f14ab6b7bfc3539c8888cb06e750d2..380cdd266cd6e86eff564624814a54a7586148c2 100644 (file)
@@ -11,5 +11,7 @@
 // Issue #5062
 
 fn main() {
-    None; //~ ERROR type annotations or generic parameter binding required
+    None; //~ ERROR unable to infer enough type information about `_` [E0282]
+          //~| NOTE cannot infer type for `_`
+          //~| NOTE type annotations or generic parameter binding
 }
index 02a3f2b9ab8d28ad31faceed2344b574ade04563..ba94bf613d217d8e18c3ff27775e91b2a82185ee 100644 (file)
@@ -13,5 +13,7 @@ struct S<'a, T:'a> {
 }
 
 fn main() {
-    S { o: &None }; //~ ERROR type annotations or generic parameter binding required
+    S { o: &None }; //~ ERROR unable to infer enough type information about `_` [E0282]
+                    //~| NOTE cannot infer type for `_`
+                    //~| NOTE type annotations or generic parameter binding
 }
index bbb063770c148274fd1ee99df28074b7f544c446..6be878dce1fb93acb3acc874225b9169582997aa 100644 (file)
@@ -15,7 +15,8 @@
     Bar,
     self
 //~^ NOTE another `self` import appears here
-//~^^ ERROR a module named `bar` has already been imported in this module
+//~| ERROR a module named `bar` has already been imported in this module
+//~| NOTE already imported
 };
 
 use {self};
index 419b8c4e1b0151847753672e2b21eba3ee067309..25709f35246e3b37f70ae690f6869b133718bbc0 100644 (file)
@@ -11,5 +11,7 @@
 
 fn main() {
     let _foo = Vec::new();
-    //~^ ERROR type annotations or generic parameter binding required
+    //~^ ERROR unable to infer enough type information about `_` [E0282]
+    //~| NOTE cannot infer type for `_`
+    //~| NOTE type annotations or generic parameter binding
 }
diff --git a/src/test/run-pass/issue-20847.rs b/src/test/run-pass/issue-20847.rs
new file mode 100644 (file)
index 0000000..d2c3356
--- /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.
+
+#![feature(fn_traits)]
+
+use std::ops::Fn;
+
+fn say(x: u32, y: u32) {
+    println!("{} {}", x, y);
+}
+
+fn main() {
+    Fn::call(&say, (1, 2));
+}
diff --git a/src/test/run-pass/slice_binary_search.rs b/src/test/run-pass/slice_binary_search.rs
new file mode 100644 (file)
index 0000000..80b370d
--- /dev/null
@@ -0,0 +1,29 @@
+// 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.
+
+// Test binary_search_by_key lifetime. Issue #34683
+
+#[derive(Debug)]
+struct Assignment {
+    topic: String,
+    partition: i32,
+}
+
+fn main() {
+    let xs = vec![
+        Assignment { topic: "abc".into(), partition: 1 },
+        Assignment { topic: "def".into(), partition: 2 },
+        Assignment { topic: "ghi".into(), partition: 3 },
+    ];
+
+    let key: &str = "def";
+    let r = xs.binary_search_by_key(&key, |e| &e.topic);
+    assert_eq!(Ok(1), r.map(|i| i));
+}