/// 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
}
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,
.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);
},
_ => ()
}
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();
}
}
(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));
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
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 =
} 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();
}
}
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;
}
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();
}
}
}
/// 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();
}
}
(&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;
}
_ => {
}
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() {
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) => {
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,
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();
}
}
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 {}",
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;
}
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)) => {
_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
}
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) => {
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;
+ }
}
_ => ()
}
/// 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 }
}
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",
#![feature(box_syntax)]
const CON : Box<i32> = box 0; //~ ERROR E0010
+ //~| NOTE allocation not allowed in
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`
}
}
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
_ => {}
}
}
fn main() {
let mut x = Foo { x: -7 };
- x.drop(); //~ ERROR E0040
+ x.drop();
+ //~^ ERROR E0040
+ //~| NOTE call to destructor method
}
struct Bar;
-impl Foo for Bar {} //~ ERROR E0046
+impl Foo for Bar {}
+//~^ ERROR E0046
+//~| NOTE missing `foo` in implementation
fn main() {
}
// except according to those terms.
fn main() {
- let x = |_| {}; //~ ERROR E0101
+ let x = |_| {};
+ //~^ ERROR E0101
+ //~| NOTE cannot resolve type of expression
}
// except according to those terms.
fn main() {
- let x = []; //~ ERROR E0102
+ let x = [];
+ //~^ ERROR E0102
+ //~| NOTE cannot resolve type of variable
}
// 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() {
}
// 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() {
}
// 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()
}
// 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
}
// 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() {
// 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() {
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,
}
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,
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() {
}
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`
}
// 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
}
// 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() {
}
// 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() {
}
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() {
}
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() {
}
// <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.
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() {}
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
}
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
}
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() {}
impl Foo for FooConstForMethod {
//~^ ERROR E0046
+ //~| NOTE missing `bar` in implementation
const bar: u64 = 1;
//~^ ERROR E0323
//~| NOTE does not match trait
impl Foo for FooMethodForConst {
//~^ ERROR E0046
+ //~| NOTE missing `MY_CONST` in implementation
fn bar(&self) {}
fn MY_CONST() {}
//~^ ERROR E0324
impl Foo for FooTypeForMethod {
//~^ ERROR E0046
+ //~| NOTE missing `bar` in implementation
type bar = u64;
//~^ ERROR E0325
//~| NOTE does not match trait
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
}
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
}
// 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() {}
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!
}
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
}
}
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 {
}
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,))
}
// 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 }
}
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() {
}
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() {}
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`
}
}
// 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]
fn main() {
// Unconstrained type:
format!("{:?}", None);
- //~^ ERROR type annotations or generic parameter binding required
+ //~^ ERROR unable to infer enough type information about `_` [E0282]
}
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
}
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() {
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() {
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
}
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();
}
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() {}
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`
}
}
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() {}
// 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() {
}
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
}
}
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
}
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
}
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() {}
// 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
}
}
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
}
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};
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
}
--- /dev/null
+// 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));
+}