]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #35456 - birkenfeld:issue-33784, r=nikomatsakis
authorbors <bors@rust-lang.org>
Mon, 8 Aug 2016 14:47:51 +0000 (07:47 -0700)
committerGitHub <noreply@github.com>
Mon, 8 Aug 2016 14:47:51 +0000 (07:47 -0700)
typeck: suggest (x.field)(...) to call struct fields even when x is a reference

Fixes: #33784
Note: This is a reopen of #33785.

75 files changed:
src/libcore/iter/traits.rs
src/librustc/traits/error_reporting.rs
src/librustc_const_eval/check_match.rs
src/librustc_mir/transform/qualify_consts.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/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/os.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/E0101.rs
src/test/compile-fail/E0102.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/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/E0223.rs
src/test/compile-fail/E0225.rs
src/test/compile-fail/E0243.rs
src/test/compile-fail/E0244.rs
src/test/compile-fail/associated-types-in-ambiguous-context.rs
src/test/compile-fail/coherence-impls-copy.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-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-23024.rs
src/test/compile-fail/issue-23041.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-27340.rs
src/test/compile-fail/issue-34209.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/qualified-path-params-2.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]

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 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 2fe4ae627c1dc7be3ea12168369e8df3cb17939f..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);
         },
         _ => ()
     }
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 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 50ffa52e88ba497e5c6833635470a78a7ed6a4b8..b4e9fb5c65bb3576417b53469e454c262a249830 100644 (file)
@@ -1215,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
@@ -2095,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 =
@@ -2255,20 +2260,27 @@ 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();
     }
 }
 
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 8da061208730fc85dfd52f5d9cc43300495e5e73..4bb36aa639c541b1e0ae46517a27b654b46d4f40 100644 (file)
@@ -1136,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() {
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 92b91028b98b0b1401cc32faed14763e25b75ffd..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) => {
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 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 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 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 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 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 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 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() {
 }
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 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 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 6452e50d0893ea9b3bc44ea22f1857eeb435b0c0..e0ea1a4cac58bb83102cacf447fb478961897928 100644 (file)
@@ -21,6 +21,7 @@ trait Foo {
 
 impl Foo for FooConstForMethod {
     //~^ ERROR E0046
+    //~| NOTE missing `bar` in implementation
     const bar: u64 = 1;
     //~^ ERROR E0323
     //~| NOTE does not match trait
@@ -31,6 +32,7 @@ impl Foo for FooConstForMethod {
 
 impl Foo for FooMethodForConst {
     //~^ ERROR E0046
+    //~| NOTE missing `MY_CONST` in implementation
     fn bar(&self) {}
     fn MY_CONST() {}
     //~^ ERROR E0324
@@ -41,6 +43,7 @@ fn MY_CONST() {}
 
 impl Foo for FooTypeForMethod {
     //~^ ERROR E0046
+    //~| NOTE missing `bar` in implementation
     type bar = u64;
     //~^ ERROR E0325
     //~| NOTE does not match trait
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 df2a70160f866e58bafe4a9c4b06518e7493f747..50f1323d39c557bc0ef7494eb6d9651d7d6d8821 100644 (file)
@@ -18,6 +18,11 @@ 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
+    //~| NOTE expected 1 type arguments, found 0
     //~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`)
+    //~| NOTE in this expansion of println!
+    //~| NOTE in this expansion of println!
+    //~| NOTE in this expansion of println!
+    //~| NOTE in this expansion of println!
 }
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 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 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() {}
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 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 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 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));
+}