diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 60935770781..4e6cd6c9782 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -230,7 +230,7 @@ To find documentation-related issues, sort by the [A-docs label][adocs]. In many cases, you don't need a full `make doc`. You can use `rustdoc` directly to check small fixes. For example, `rustdoc src/doc/reference.md` will render reference to `doc/reference.html`. The CSS might be messed up, but you can -verify that HTML is right. +verify that the HTML is right. ## Issue Triage diff --git a/src/doc/book/traits.md b/src/doc/book/traits.md index e685cb129b9..9cbb514e280 100644 --- a/src/doc/book/traits.md +++ b/src/doc/book/traits.md @@ -47,6 +47,34 @@ As you can see, the `trait` block looks very similar to the `impl` block, but we don’t define a body, only a type signature. When we `impl` a trait, we use `impl Trait for Item`, rather than only `impl Item`. +`Self` may be used in a type annotation to refer to an instance of the type +implementing this trait passed as a parameter. `Self`, `&Self` or `&mut Self` +may be used depending on the level of ownership required. + +```rust +struct Circle { + x: f64, + y: f64, + radius: f64, +} + +trait HasArea { + fn area(&self) -> f64; + + fn is_larger(&self, &Self) -> bool; +} + +impl HasArea for Circle { + fn area(&self) -> f64 { + std::f64::consts::PI * (self.radius * self.radius) + } + + fn is_larger(&self, other: &Self) -> bool { + self.area() > other.area() + } +} +``` + ## Trait bounds on generic functions Traits are useful because they allow a type to make certain promises about its diff --git a/src/etc/CONFIGS.md b/src/etc/CONFIGS.md index cde7094cec4..542b7bf797b 100644 --- a/src/etc/CONFIGS.md +++ b/src/etc/CONFIGS.md @@ -6,6 +6,7 @@ These are some links to repos with configs which ease the use of rust. * [rust.vim](https://github.com/rust-lang/rust.vim) * [emacs rust-mode](https://github.com/rust-lang/rust-mode) +* [sublime-rust](https://github.com/rust-lang/sublime-rust) * [gedit-config](https://github.com/rust-lang/gedit-config) * [kate-config](https://github.com/rust-lang/kate-config) * [nano-config](https://github.com/rust-lang/nano-config) diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 2beb652aa01..3a158240c3a 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -263,6 +263,23 @@ impl Rc { } /// Checks if `Rc::try_unwrap` would return `Ok`. + /// + /// # Examples + /// + /// ``` + /// #![feature(rc_would_unwrap)] + /// + /// use std::rc::Rc; + /// + /// let x = Rc::new(3); + /// assert!(Rc::would_unwrap(&x)); + /// assert_eq!(Rc::try_unwrap(x), Ok(3)); + /// + /// let x = Rc::new(4); + /// let _y = x.clone(); + /// assert!(!Rc::would_unwrap(&x)); + /// assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4))); + /// ``` #[unstable(feature = "rc_would_unwrap", reason = "just added for niche usecase", issue = "28356")] diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 788c838cd3f..a7dc2875320 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -132,7 +132,7 @@ use boxed::Box; /// [`OsString`]: ../../std/ffi/struct.OsString.html /// /// Indexing is intended to be a constant-time operation, but UTF-8 encoding -/// does not allow us to do this. Furtheremore, it's not clear what sort of +/// does not allow us to do this. Furthermore, it's not clear what sort of /// thing the index should return: a byte, a codepoint, or a grapheme cluster. /// The [`as_bytes()`] and [`chars()`] methods return iterators over the first /// two, respectively. diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 3a2d6c8bcf7..282f281047e 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -299,26 +299,63 @@ sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// /// # Examples /// -/// A trivial implementation of `Mul`. When `Foo * Foo` happens, it ends up -/// calling `mul`, and therefore, `main` prints `Multiplying!`. +/// Implementing a `Mul`tipliable rational number struct: /// /// ``` /// use std::ops::Mul; /// -/// struct Foo; +/// // The uniqueness of rational numbers in lowest terms is a consequence of +/// // the fundamental theorem of arithmetic. +/// #[derive(Eq)] +/// #[derive(PartialEq, Debug)] +/// struct Rational { +/// nominator: usize, +/// denominator: usize, +/// } /// -/// impl Mul for Foo { -/// type Output = Foo; +/// impl Rational { +/// fn new(nominator: usize, denominator: usize) -> Self { +/// if denominator == 0 { +/// panic!("Zero is an invalid denominator!"); +/// } /// -/// fn mul(self, _rhs: Foo) -> Foo { -/// println!("Multiplying!"); -/// self +/// // Reduce to lowest terms by dividing by the greatest common +/// // divisor. +/// let gcd = gcd(nominator, denominator); +/// Rational { +/// nominator: nominator / gcd, +/// denominator: denominator / gcd, +/// } /// } /// } /// -/// fn main() { -/// Foo * Foo; +/// impl Mul for Rational { +/// // The multiplication of rational numbers is a closed operation. +/// type Output = Self; +/// +/// fn mul(self, rhs: Self) -> Self { +/// let nominator = self.nominator * rhs.nominator; +/// let denominator = self.denominator * rhs.denominator; +/// Rational::new(nominator, denominator) +/// } /// } +/// +/// // Euclid's two-thousand-year-old algorithm for finding the greatest common +/// // divisor. +/// fn gcd(x: usize, y: usize) -> usize { +/// let mut x = x; +/// let mut y = y; +/// while y != 0 { +/// let t = y; +/// y = x % y; +/// x = t; +/// } +/// x +/// } +/// +/// assert_eq!(Rational::new(1, 2), Rational::new(2, 4)); +/// assert_eq!(Rational::new(2, 3) * Rational::new(3, 4), +/// Rational::new(1, 2)); /// ``` /// /// Note that `RHS = Self` by default, but this is not mandatory. Here is an @@ -486,26 +523,34 @@ div_impl_float! { f32 f64 } /// /// # Examples /// -/// A trivial implementation of `Rem`. When `Foo % Foo` happens, it ends up -/// calling `rem`, and therefore, `main` prints `Remainder-ing!`. +/// This example implements `Rem` on a `SplitSlice` object. After `Rem` is +/// implemented, one can use the `%` operator to find out what the remaining +/// elements of the slice would be after splitting it into equal slices of a +/// given length. /// /// ``` /// use std::ops::Rem; /// -/// struct Foo; +/// #[derive(PartialEq, Debug)] +/// struct SplitSlice<'a, T: 'a> { +/// slice: &'a [T], +/// } /// -/// impl Rem for Foo { -/// type Output = Foo; +/// impl<'a, T> Rem for SplitSlice<'a, T> { +/// type Output = SplitSlice<'a, T>; /// -/// fn rem(self, _rhs: Foo) -> Foo { -/// println!("Remainder-ing!"); -/// self +/// fn rem(self, modulus: usize) -> Self { +/// let len = self.slice.len(); +/// let rem = len % modulus; +/// let start = len - rem; +/// SplitSlice {slice: &self.slice[start..]} /// } /// } /// -/// fn main() { -/// Foo % Foo; -/// } +/// // If we were to divide &[0, 1, 2, 3, 4, 5, 6, 7] into slices of size 3, +/// // the remainder would be &[6, 7] +/// assert_eq!(SplitSlice { slice: &[0, 1, 2, 3, 4, 5, 6, 7] } % 3, +/// SplitSlice { slice: &[6, 7] }); /// ``` #[lang = "rem"] #[stable(feature = "rust1", since = "1.0.0")] @@ -694,26 +739,41 @@ not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// /// # Examples /// -/// A trivial implementation of `BitAnd`. When `Foo & Foo` happens, it ends up -/// calling `bitand`, and therefore, `main` prints `Bitwise And-ing!`. +/// In this example, the `BitAnd` trait is implemented for a `BooleanVector` +/// struct. /// /// ``` /// use std::ops::BitAnd; /// -/// struct Foo; +/// #[derive(Debug)] +/// struct BooleanVector { +/// value: Vec, +/// }; /// -/// impl BitAnd for Foo { -/// type Output = Foo; +/// impl BitAnd for BooleanVector { +/// type Output = Self; /// -/// fn bitand(self, _rhs: Foo) -> Foo { -/// println!("Bitwise And-ing!"); -/// self +/// fn bitand(self, rhs: Self) -> Self { +/// BooleanVector { +/// value: self.value +/// .iter() +/// .zip(rhs.value.iter()) +/// .map(|(x, y)| *x && *y) +/// .collect(), +/// } /// } /// } /// -/// fn main() { -/// Foo & Foo; +/// impl PartialEq for BooleanVector { +/// fn eq(&self, other: &Self) -> bool { +/// self.value == other.value +/// } /// } +/// +/// let bv1 = BooleanVector { value: vec![true, true, false, false] }; +/// let bv2 = BooleanVector { value: vec![true, false, true, false] }; +/// let expected = BooleanVector { value: vec![true, false, false, false] }; +/// assert_eq!(bv1 & bv2, expected); /// ``` #[lang = "bitand"] #[stable(feature = "rust1", since = "1.0.0")] @@ -1490,28 +1550,44 @@ shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// /// # Examples /// -/// A trivial implementation of `Index`. When `Foo[Bar]` happens, it ends up -/// calling `index`, and therefore, `main` prints `Indexing!`. +/// This example implements `Index` on a read-only `NucleotideCount` container, +/// enabling individual counts to be retrieved with index syntax. /// /// ``` /// use std::ops::Index; /// -/// #[derive(Copy, Clone)] -/// struct Foo; -/// struct Bar; +/// enum Nucleotide { +/// A, +/// C, +/// G, +/// T, +/// } /// -/// impl Index for Foo { -/// type Output = Foo; +/// struct NucleotideCount { +/// a: usize, +/// c: usize, +/// g: usize, +/// t: usize, +/// } /// -/// fn index<'a>(&'a self, _index: Bar) -> &'a Foo { -/// println!("Indexing!"); -/// self +/// impl Index for NucleotideCount { +/// type Output = usize; +/// +/// fn index(&self, nucleotide: Nucleotide) -> &usize { +/// match nucleotide { +/// Nucleotide::A => &self.a, +/// Nucleotide::C => &self.c, +/// Nucleotide::G => &self.g, +/// Nucleotide::T => &self.t, +/// } /// } /// } /// -/// fn main() { -/// Foo[Bar]; -/// } +/// let nucleotide_count = NucleotideCount {a: 14, c: 9, g: 10, t: 12}; +/// assert_eq!(nucleotide_count[Nucleotide::A], 14); +/// assert_eq!(nucleotide_count[Nucleotide::C], 9); +/// assert_eq!(nucleotide_count[Nucleotide::G], 10); +/// assert_eq!(nucleotide_count[Nucleotide::T], 12); /// ``` #[lang = "index"] #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"] diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 925cdfec900..8cb485872b3 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -128,7 +128,9 @@ pub unsafe fn replace(dest: *mut T, mut src: T) -> T { /// let x = 12; /// let y = &x as *const i32; /// -/// unsafe { println!("{}", std::ptr::read(y)); } +/// unsafe { +/// assert_eq!(std::ptr::read(y), 12); +/// } /// ``` #[inline(always)] #[stable(feature = "rust1", since = "1.0.0")] @@ -178,7 +180,7 @@ pub unsafe fn read_and_drop(dest: *mut T) -> T { /// /// unsafe { /// std::ptr::write(y, z); -/// println!("{}", std::ptr::read(y)); +/// assert_eq!(std::ptr::read(y), 12); /// } /// ``` #[inline] @@ -220,7 +222,9 @@ pub unsafe fn write(dst: *mut T, src: T) { /// let x = 12; /// let y = &x as *const i32; /// -/// unsafe { println!("{}", std::ptr::read_volatile(y)); } +/// unsafe { +/// assert_eq!(std::ptr::read_volatile(y), 12); +/// } /// ``` #[inline] #[stable(feature = "volatile", since = "1.9.0")] @@ -266,7 +270,7 @@ pub unsafe fn read_volatile(src: *const T) -> T { /// /// unsafe { /// std::ptr::write_volatile(y, z); -/// println!("{}", std::ptr::read_volatile(y)); +/// assert_eq!(std::ptr::read_volatile(y), 12); /// } /// ``` #[inline] diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 478f662d096..189150d4264 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -23,9 +23,8 @@ use syntax::ast::NodeId; pub enum AccessLevel { // Exported items + items participating in various kinds of public interfaces, // but not directly nameable. For example, if function `fn f() -> T {...}` is - // public, then type `T` is exported. Its values can be obtained by other crates - // even if the type itseld is not nameable. - // FIXME: Mostly unimplemented. Only `type` aliases export items currently. + // public, then type `T` is reachable. Its values can be obtained by other crates + // even if the type itself is not nameable. Reachable, // Public items + items accessible to other crates with help of `pub use` reexports Exported, diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 9cae270984f..c1f162e5772 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -647,10 +647,13 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { struct_span_err!(self.bccx, span, E0503, "cannot use `{}` because it was mutably borrowed", &self.bccx.loan_path_to_string(copy_path)) - .span_note(loan_span, + .span_label(loan_span, &format!("borrow of `{}` occurs here", &self.bccx.loan_path_to_string(&loan_path)) ) + .span_label(span, + &format!("use of borrowed `{}`", + &self.bccx.loan_path_to_string(&loan_path))) .emit(); } } diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index fd5db97b5d8..225895adefa 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -914,9 +914,11 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } mc::AliasableStatic | mc::AliasableStaticMut => { - struct_span_err!( + let mut err = struct_span_err!( self.tcx.sess, span, E0388, - "{} in a static location", prefix) + "{} in a static location", prefix); + err.span_label(span, &format!("cannot write data in a static definition")); + err } mc::AliasableBorrowed => { struct_span_err!( diff --git a/src/librustc_metadata/diagnostics.rs b/src/librustc_metadata/diagnostics.rs index ae9f500c5de..099ec62b38d 100644 --- a/src/librustc_metadata/diagnostics.rs +++ b/src/librustc_metadata/diagnostics.rs @@ -14,7 +14,7 @@ register_long_diagnostics! { E0454: r##" A link name was given with an empty name. Erroneous code example: -``` +```compile_fail,E0454 #[link(name = "")] extern {} // error: #[link(name = "")] given with empty name ``` @@ -32,7 +32,7 @@ as frameworks are specific to that operating system. Erroneous code example: -```compile_fail" +```compile_fail,E0455 #[link(name = "FooCoreServices", kind = "framework")] extern {} // OS used to compile is Linux for example ``` @@ -50,7 +50,7 @@ See more: https://doc.rust-lang.org/book/conditional-compilation.html E0458: r##" An unknown "kind" was specified for a link attribute. Erroneous code example: -``` +```compile_fail,E0458 #[link(kind = "wonderful_unicorn")] extern {} // error: unknown kind: `wonderful_unicorn` ``` @@ -64,7 +64,7 @@ Please specify a valid "kind" value, from one of the following: E0459: r##" A link was used without a name parameter. Erroneous code example: -``` +```compile_fail,E0459 #[link(kind = "dylib")] extern {} // error: #[link(...)] specified without `name = "foo"` ``` @@ -80,7 +80,7 @@ you want. Example: E0463: r##" A plugin/crate was declared but cannot be found. Erroneous code example: -``` +```compile_fail,E0463 #![feature(plugin)] #![plugin(cookie_monster)] // error: can't find crate for `cookie_monster` extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie` diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 0c0582edcc0..5641a50ccac 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -251,20 +251,24 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>, err } ResolutionError::TypeNotMemberOfTrait(type_, trait_) => { - struct_span_err!(resolver.session, + let mut err = struct_span_err!(resolver.session, span, E0437, "type `{}` is not a member of trait `{}`", type_, - trait_) + trait_); + err.span_label(span, &format!("not a member of trait `Foo`")); + err } ResolutionError::ConstNotMemberOfTrait(const_, trait_) => { - struct_span_err!(resolver.session, + let mut err = struct_span_err!(resolver.session, span, E0438, "const `{}` is not a member of trait `{}`", const_, - trait_) + trait_); + err.span_label(span, &format!("not a member of trait `Foo`")); + err } ResolutionError::VariableNotBoundInPattern(variable_name, from, to) => { struct_span_err!(resolver.session, @@ -336,19 +340,23 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>, err } ResolutionError::StructVariantUsedAsFunction(path_name) => { - struct_span_err!(resolver.session, + let mut err = struct_span_err!(resolver.session, span, E0423, "`{}` is the name of a struct or struct variant, but this expression \ uses it like a function name", - path_name) + path_name); + err.span_label(span, &format!("struct called like a function")); + err } ResolutionError::SelfNotAvailableInStaticMethod => { - struct_span_err!(resolver.session, + let mut err = struct_span_err!(resolver.session, span, E0424, - "`self` is not available in a static method. Maybe a `self` \ - argument is missing?") + "`self` is not available in a static method"); + err.span_label(span, &format!("not available in static method")); + err.note(&format!("maybe a `self` argument is missing?")); + err } ResolutionError::UnresolvedName { path, message: msg, context, is_static_method, is_field, def } => { @@ -390,11 +398,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>, err } ResolutionError::UndeclaredLabel(name) => { - struct_span_err!(resolver.session, - span, - E0426, - "use of undeclared label `{}`", - name) + let mut err = struct_span_err!(resolver.session, + span, + E0426, + "use of undeclared label `{}`", + name); + err.span_label(span, &format!("undeclared label `{}`",&name)); + err } ResolutionError::SelfImportsOnlyAllowedWithin => { struct_span_err!(resolver.session, @@ -418,10 +428,14 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>, } ResolutionError::UnresolvedImport(name) => { let msg = match name { - Some((n, p)) => format!("unresolved import `{}`{}", n, p), + Some((n, _)) => format!("unresolved import `{}`", n), None => "unresolved import".to_owned(), }; - struct_span_err!(resolver.session, span, E0432, "{}", msg) + let mut err = struct_span_err!(resolver.session, span, E0432, "{}", msg); + if let Some((_, p)) = name { + err.span_label(span, &p); + } + err } ResolutionError::FailedToResolve(msg) => { let mut err = struct_span_err!(resolver.session, span, E0433, @@ -438,10 +452,12 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>, closure form instead") } ResolutionError::AttemptToUseNonConstantValueInConstant => { - struct_span_err!(resolver.session, + let mut err = struct_span_err!(resolver.session, span, E0435, - "attempt to use a non-constant value in a constant") + "attempt to use a non-constant value in a constant"); + err.span_label(span, &format!("non-constant used with constant")); + err } ResolutionError::BindingShadowsSomethingUnacceptable(what_binding, name, binding) => { let shadows_what = PathResolution::new(binding.def().unwrap()).kind_name(); diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index c0a9ee1c483..8c6d89c29bd 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -423,7 +423,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { if let Failed(err) = self.finalize_import(import) { errors = true; let (span, help) = match err { - Some((span, msg)) => (span, format!(". {}", msg)), + Some((span, msg)) => (span, msg), None => (import.span, String::new()), }; @@ -596,9 +596,9 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { }; let module_str = module_to_string(module); let msg = if &module_str == "???" { - format!("There is no `{}` in the crate root{}", name, lev_suggestion) + format!("no `{}` in the root{}", name, lev_suggestion) } else { - format!("There is no `{}` in `{}`{}", name, module_str, lev_suggestion) + format!("no `{}` in `{}`{}", name, module_str, lev_suggestion) }; Failed(Some((directive.span, msg))) } else { diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index af24a7b5117..52073359c0f 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -347,9 +347,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let ty::TyTrait(..) = mt.ty.sty { // This is "x = SomeTrait" being reduced from // "let &x = &SomeTrait" or "let box x = Box", an error. - span_err!(self.tcx.sess, span, E0033, - "type `{}` cannot be dereferenced", - self.ty_to_string(expected)); + let type_str = self.ty_to_string(expected); + struct_span_err!(self.tcx.sess, span, E0033, + "type `{}` cannot be dereferenced", type_str) + .span_label(span, &format!("type `{}` cannot be dereferenced", type_str)) + .emit(); return false } } diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index fb78d3a37ca..54e63497e62 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -161,6 +161,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { } CastError::CastToBool => { struct_span_err!(fcx.tcx.sess, self.span, E0054, "cannot cast as `bool`") + .span_label(self.span, &format!("unsupported cast")) .help("compare with zero instead") .emit(); } diff --git a/src/libstd/sys/unix/rwlock.rs b/src/libstd/sys/unix/rwlock.rs index 08aeb5fb8cc..c754d5b8359 100644 --- a/src/libstd/sys/unix/rwlock.rs +++ b/src/libstd/sys/unix/rwlock.rs @@ -45,10 +45,10 @@ impl RWLock { // We roughly maintain the deadlocking behavior by panicking to ensure // that this lock acquisition does not succeed. // - // We also check whether there this lock is already write locked. This + // We also check whether this lock is already write locked. This // is only possible if it was write locked by the current thread and // the implementation allows recursive locking. The POSIX standard - // doesn't require recursivly locking a rwlock to deadlock, but we can't + // doesn't require recursively locking a rwlock to deadlock, but we can't // allow that because it could lead to aliasing issues. if r == libc::EAGAIN { panic!("rwlock maximum reader count exceeded"); diff --git a/src/test/compile-fail/E0017.rs b/src/test/compile-fail/E0017.rs index 1223a01cbcb..44d2f158d20 100644 --- a/src/test/compile-fail/E0017.rs +++ b/src/test/compile-fail/E0017.rs @@ -20,6 +20,7 @@ static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 //~| ERROR E0017 //~| NOTE statics require immutable values //~| ERROR E0388 + //~| NOTE cannot write data in a static definition static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 //~| NOTE statics require immutable values //~| ERROR E0017 diff --git a/src/test/compile-fail/E0033.rs b/src/test/compile-fail/E0033.rs index 946600013f3..d320bcd4d0f 100644 --- a/src/test/compile-fail/E0033.rs +++ b/src/test/compile-fail/E0033.rs @@ -13,7 +13,13 @@ trait SomeTrait { } fn main() { - let trait_obj: &SomeTrait = SomeTrait; //~ ERROR E0425 - //~^ ERROR E0038 - let &invalid = trait_obj; //~ ERROR E0033 + let trait_obj: &SomeTrait = SomeTrait; + //~^ ERROR E0425 + //~| ERROR E0038 + //~| method `foo` has no receiver + //~| NOTE the trait `SomeTrait` cannot be made into an object + + let &invalid = trait_obj; + //~^ ERROR E0033 + //~| NOTE type `&SomeTrait` cannot be dereferenced } diff --git a/src/test/compile-fail/E0423.rs b/src/test/compile-fail/E0423.rs index f5fea77cf96..98b700984a7 100644 --- a/src/test/compile-fail/E0423.rs +++ b/src/test/compile-fail/E0423.rs @@ -12,4 +12,5 @@ fn main () { struct Foo { a: bool }; let f = Foo(); //~ ERROR E0423 + //~^ struct called like a function } diff --git a/src/test/compile-fail/E0424.rs b/src/test/compile-fail/E0424.rs index 445d0c5f3ed..911007113d3 100644 --- a/src/test/compile-fail/E0424.rs +++ b/src/test/compile-fail/E0424.rs @@ -14,7 +14,10 @@ impl Foo { fn bar(self) {} fn foo() { - self.bar(); //~ ERROR E0424 + self.bar(); + //~^ ERROR `self` is not available in a static method [E0424] + //~| NOTE not available in static method + //~| NOTE maybe a `self` argument is missing? } } diff --git a/src/test/compile-fail/E0426.rs b/src/test/compile-fail/E0426.rs index 2eb4c2d3b5e..be21421cb07 100644 --- a/src/test/compile-fail/E0426.rs +++ b/src/test/compile-fail/E0426.rs @@ -10,6 +10,8 @@ fn main () { loop { - break 'a; //~ ERROR E0426 + break 'a; + //~^ ERROR E0426 + //~| NOTE undeclared label `'a` } } diff --git a/src/test/compile-fail/E0435.rs b/src/test/compile-fail/E0435.rs index f6cba15a0bf..f687633d34d 100644 --- a/src/test/compile-fail/E0435.rs +++ b/src/test/compile-fail/E0435.rs @@ -11,4 +11,5 @@ fn main () { let foo = 42u32; const FOO : u32 = foo; //~ ERROR E0435 + //~| NOTE non-constant used with constant } diff --git a/src/test/compile-fail/E0437.rs b/src/test/compile-fail/E0437.rs index 7440a82773e..62ee8dc3464 100644 --- a/src/test/compile-fail/E0437.rs +++ b/src/test/compile-fail/E0437.rs @@ -12,6 +12,7 @@ trait Foo {} impl Foo for i32 { type Bar = bool; //~ ERROR E0437 + //~| NOTE not a member of trait `Foo` } fn main () { diff --git a/src/test/compile-fail/E0438.rs b/src/test/compile-fail/E0438.rs index b3d45307204..f549d62aebf 100644 --- a/src/test/compile-fail/E0438.rs +++ b/src/test/compile-fail/E0438.rs @@ -14,6 +14,7 @@ trait Foo {} impl Foo for i32 { const BAR: bool = true; //~ ERROR E0438 + //~| NOTE not a member of trait `Foo` } fn main () { diff --git a/src/test/compile-fail/E0441.rs b/src/test/compile-fail/E0441.rs new file mode 100644 index 00000000000..967ff643272 --- /dev/null +++ b/src/test/compile-fail/E0441.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd)] +#![feature(platform_intrinsics)] + +#[repr(simd)] +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); + +extern "platform-intrinsic" { + fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8; //~ ERROR E0441 +} + +fn main() {} diff --git a/src/test/compile-fail/E0442.rs b/src/test/compile-fail/E0442.rs new file mode 100644 index 00000000000..ddd927054be --- /dev/null +++ b/src/test/compile-fail/E0442.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd)] +#![feature(platform_intrinsics)] + +#[repr(simd)] +struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, + i8, i8, i8, i8, i8, i8, i8, i8); +#[repr(simd)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +struct i64x2(i64, i64); + +extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + //~^ ERROR E0442 + //~| ERROR E0442 + //~| ERROR E0442 +} + +fn main() {} diff --git a/src/test/compile-fail/E0443.rs b/src/test/compile-fail/E0443.rs new file mode 100644 index 00000000000..24d1ee01dd4 --- /dev/null +++ b/src/test/compile-fail/E0443.rs @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd)] +#![feature(platform_intrinsics)] + +#[repr(simd)] +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); +#[repr(simd)] +struct i64x8(i64, i64, i64, i64, i64, i64, i64, i64); + +extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443 +} + +fn main() {} diff --git a/src/test/compile-fail/E0444.rs b/src/test/compile-fail/E0444.rs new file mode 100644 index 00000000000..a424a3ca20e --- /dev/null +++ b/src/test/compile-fail/E0444.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd)] +#![feature(platform_intrinsics)] + +#[repr(simd)] +struct f64x2(f64, f64); + +extern "platform-intrinsic" { + fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444 +} + +fn main() {} diff --git a/src/test/compile-fail/E0445.rs b/src/test/compile-fail/E0445.rs new file mode 100644 index 00000000000..6b360c60a0f --- /dev/null +++ b/src/test/compile-fail/E0445.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { + fn dummy(&self) { } +} + +pub trait Bar : Foo {} //~ ERROR E0445 +pub struct Bar2(pub T); //~ ERROR E0445 +pub fn foo (t: T) {} //~ ERROR E0445 + +fn main() {} diff --git a/src/test/compile-fail/E0446.rs b/src/test/compile-fail/E0446.rs new file mode 100644 index 00000000000..c5766618284 --- /dev/null +++ b/src/test/compile-fail/E0446.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod Foo { + struct Bar(u32); + + pub fn bar() -> Bar { //~ ERROR E0446 + Bar(0) + } +} + +fn main() {} diff --git a/src/test/compile-fail/E0449.rs b/src/test/compile-fail/E0449.rs new file mode 100644 index 00000000000..ac365db33e5 --- /dev/null +++ b/src/test/compile-fail/E0449.rs @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Bar; + +trait Foo { + fn foo(); +} + +pub impl Bar {} //~ ERROR E0449 + +pub impl Foo for Bar { //~ ERROR E0449 + pub fn foo() {} //~ ERROR E0449 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0450.rs b/src/test/compile-fail/E0450.rs new file mode 100644 index 00000000000..3d76cb93773 --- /dev/null +++ b/src/test/compile-fail/E0450.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod Bar { + pub struct Foo(isize); +} + +fn main() { + let f = Bar::Foo(0); //~ ERROR E0450 +} diff --git a/src/test/compile-fail/E0451.rs b/src/test/compile-fail/E0451.rs new file mode 100644 index 00000000000..9e4a8713a33 --- /dev/null +++ b/src/test/compile-fail/E0451.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod Bar { + pub struct Foo { + pub a: isize, + b: isize, + } +} + +fn main() { + let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451 +} diff --git a/src/test/compile-fail/E0452.rs b/src/test/compile-fail/E0452.rs new file mode 100644 index 00000000000..1665bbdd4c2 --- /dev/null +++ b/src/test/compile-fail/E0452.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(foo = "")] //~ ERROR E0452 + +fn main() { +} diff --git a/src/test/compile-fail/E0453.rs b/src/test/compile-fail/E0453.rs new file mode 100644 index 00000000000..629b373cd7f --- /dev/null +++ b/src/test/compile-fail/E0453.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![forbid(non_snake_case)] + +#[allow(non_snake_case)] //~ ERROR E0453 +fn main() { +} diff --git a/src/test/compile-fail/E0454.rs b/src/test/compile-fail/E0454.rs new file mode 100644 index 00000000000..1439c3133d9 --- /dev/null +++ b/src/test/compile-fail/E0454.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(name = "")] extern {} //~ ERROR E0454 + +fn main() { +} diff --git a/src/test/compile-fail/E0458.rs b/src/test/compile-fail/E0458.rs new file mode 100644 index 00000000000..21bedc6b84c --- /dev/null +++ b/src/test/compile-fail/E0458.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458 + //~^ ERROR E0459 + +fn main() { +} diff --git a/src/test/compile-fail/E0459.rs b/src/test/compile-fail/E0459.rs new file mode 100644 index 00000000000..dc7ac714f22 --- /dev/null +++ b/src/test/compile-fail/E0459.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(kind = "dylib")] extern {} //~ ERROR E0459 + +fn main() { +} diff --git a/src/test/compile-fail/E0463.rs b/src/test/compile-fail/E0463.rs new file mode 100644 index 00000000000..3eff107365a --- /dev/null +++ b/src/test/compile-fail/E0463.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(plugin)] +#![plugin(cookie_monster)] //~ ERROR E0463 +extern crate cake_is_a_lie; + +fn main() { +} diff --git a/src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs b/src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs index 3fd71f71564..530822f6c5b 100644 --- a/src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs +++ b/src/test/compile-fail/borrowck/borrowck-box-insensitivity.rs @@ -71,6 +71,7 @@ fn copy_after_mut_borrow() { let _x = &mut a.x; //~^ NOTE borrow of `a.x` occurs here let _y = a.y; //~ ERROR cannot use + //~^ NOTE use of borrowed `a.x` } fn move_after_mut_borrow() { @@ -141,6 +142,7 @@ fn copy_after_mut_borrow_nested() { let _x = &mut a.x.x; //~^ NOTE borrow of `a.x.x` occurs here let _y = a.y; //~ ERROR cannot use + //~^ NOTE use of borrowed `a.x.x` } fn move_after_mut_borrow_nested() { diff --git a/src/test/compile-fail/cast-rfc0401.rs b/src/test/compile-fail/cast-rfc0401.rs index 05c531e91f1..7839fb45d1c 100644 --- a/src/test/compile-fail/cast-rfc0401.rs +++ b/src/test/compile-fail/cast-rfc0401.rs @@ -59,10 +59,12 @@ fn main() //~^ ERROR casting //~^^ HELP through a usize first let _ = 3_i32 as bool; - //~^ ERROR cannot cast as `bool` + //~^ ERROR cannot cast as `bool` [E0054] + //~| unsupported cast //~| HELP compare with zero let _ = E::A as bool; - //~^ ERROR cannot cast as `bool` + //~^ ERROR cannot cast as `bool` [E0054] + //~| unsupported cast //~| HELP compare with zero let _ = 0x61u32 as char; //~ ERROR only `u8` can be cast diff --git a/src/test/compile-fail/import-from-missing.rs b/src/test/compile-fail/import-from-missing.rs index bcd2cd816ed..220b255bde4 100644 --- a/src/test/compile-fail/import-from-missing.rs +++ b/src/test/compile-fail/import-from-missing.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use spam::{ham, eggs}; -//~^ ERROR unresolved import `spam::eggs`. There is no `eggs` in `spam` +use spam::{ham, eggs}; //~ ERROR unresolved import `spam::eggs` [E0432] + //~^ no `eggs` in `spam` mod spam { pub fn ham() { } diff --git a/src/test/compile-fail/import.rs b/src/test/compile-fail/import.rs index ff93cd0f066..1ca1c060410 100644 --- a/src/test/compile-fail/import.rs +++ b/src/test/compile-fail/import.rs @@ -9,13 +9,14 @@ // except according to those terms. use zed::bar; -use zed::baz; -//~^ ERROR unresolved import `zed::baz`. There is no `baz` in `zed` +use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432] + //~^ no `baz` in `zed`. Did you mean to use `bar`? mod zed { pub fn bar() { println!("bar"); } - use foo; //~ ERROR unresolved import + use foo; //~ ERROR unresolved import `foo` [E0432] + //~^ no `foo` in the root } fn main() { diff --git a/src/test/compile-fail/import2.rs b/src/test/compile-fail/import2.rs index 1f25bce2093..f5b03f9b2e9 100644 --- a/src/test/compile-fail/import2.rs +++ b/src/test/compile-fail/import2.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use baz::zed::bar; -//~^ ERROR unresolved import `baz::zed::bar`. Could not find `zed` in `baz` +use baz::zed::bar; //~ ERROR unresolved import `baz::zed::bar` [E0432] + //~^ Could not find `zed` in `baz` mod baz {} mod zed { diff --git a/src/test/compile-fail/issue-12612.rs b/src/test/compile-fail/issue-12612.rs index f76d12d93fd..20943bd0ea0 100644 --- a/src/test/compile-fail/issue-12612.rs +++ b/src/test/compile-fail/issue-12612.rs @@ -15,8 +15,8 @@ extern crate issue_12612_1 as foo; use foo::bar; mod test { - use bar::foo; - //~^ ERROR unresolved import `bar::foo`. Maybe a missing `extern crate bar`? + use bar::foo; //~ ERROR unresolved import `bar::foo` [E0432] + //~^ Maybe a missing `extern crate bar`? } fn main() {} diff --git a/src/test/compile-fail/issue-13404.rs b/src/test/compile-fail/issue-13404.rs index 355be1562df..0059e92e07f 100644 --- a/src/test/compile-fail/issue-13404.rs +++ b/src/test/compile-fail/issue-13404.rs @@ -9,8 +9,8 @@ // except according to those terms. use a::f; -use b::f; -//~^ ERROR: unresolved import `b::f`. There is no `f` in `b` +use b::f; //~ ERROR: unresolved import `b::f` [E0432] + //~^ no `f` in `b` mod a { pub fn f() {} } mod b { } diff --git a/src/test/compile-fail/issue-1697.rs b/src/test/compile-fail/issue-1697.rs index f2d858391ce..dc09af0ada6 100644 --- a/src/test/compile-fail/issue-1697.rs +++ b/src/test/compile-fail/issue-1697.rs @@ -10,6 +10,7 @@ // Testing that we don't fail abnormally after hitting the errors -use unresolved::*; //~ ERROR unresolved import `unresolved::*`. Maybe a missing `extern crate unres +use unresolved::*; //~ ERROR unresolved import `unresolved::*` [E0432] + //~^ Maybe a missing `extern crate unresolved`? fn main() {} diff --git a/src/test/compile-fail/issue-18252.rs b/src/test/compile-fail/issue-18252.rs index e3e56c7f97a..8e3faca02b7 100644 --- a/src/test/compile-fail/issue-18252.rs +++ b/src/test/compile-fail/issue-18252.rs @@ -13,5 +13,7 @@ enum Foo { } fn main() { - let f = Foo::Variant(42); //~ ERROR uses it like a function + let f = Foo::Variant(42); + //~^ ERROR uses it like a function + //~| struct called like a function } diff --git a/src/test/compile-fail/issue-19452.rs b/src/test/compile-fail/issue-19452.rs index 2270ba594ad..15d5d2b80c3 100644 --- a/src/test/compile-fail/issue-19452.rs +++ b/src/test/compile-fail/issue-19452.rs @@ -13,5 +13,7 @@ enum Homura { } fn main() { - let homura = Homura::Madoka; //~ ERROR uses it like a function + let homura = Homura::Madoka; + //~^ ERROR uses it like a function + //~| struct called like a function } diff --git a/src/test/compile-fail/issue-2356.rs b/src/test/compile-fail/issue-2356.rs index d7ec1ed6739..da92161967d 100644 --- a/src/test/compile-fail/issue-2356.rs +++ b/src/test/compile-fail/issue-2356.rs @@ -59,7 +59,9 @@ impl cat { impl cat { fn meow() { if self.whiskers > 3 { - //~^ ERROR: `self` is not available in a static method. Maybe a `self` argument is missing? + //~^ ERROR `self` is not available in a static method [E0424] + //~| NOTE not available in static method + //~| NOTE maybe a `self` argument is missing? println!("MEOW"); } } diff --git a/src/test/compile-fail/issue-25793.rs b/src/test/compile-fail/issue-25793.rs index 44b3ada97fe..ceefd583a5c 100644 --- a/src/test/compile-fail/issue-25793.rs +++ b/src/test/compile-fail/issue-25793.rs @@ -12,6 +12,7 @@ macro_rules! width( ($this:expr) => { $this.width.unwrap() //~^ ERROR cannot use `self.width` because it was mutably borrowed + //~| NOTE use of borrowed `*self` } ); diff --git a/src/test/compile-fail/issue-2937.rs b/src/test/compile-fail/issue-2937.rs index e4fae73b189..0d684ec5ae1 100644 --- a/src/test/compile-fail/issue-2937.rs +++ b/src/test/compile-fail/issue-2937.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use m::f as x; //~ ERROR unresolved import `m::f`. There is no `f` in `m` +use m::f as x; //~ ERROR unresolved import `m::f` [E0432] + //~^ no `f` in `m` mod m {} diff --git a/src/test/compile-fail/issue-30560.rs b/src/test/compile-fail/issue-30560.rs index 71c7e600965..b0cfd8714fc 100644 --- a/src/test/compile-fail/issue-30560.rs +++ b/src/test/compile-fail/issue-30560.rs @@ -9,8 +9,12 @@ // except according to those terms. type Alias = (); -use Alias::*; //~ ERROR Not a module -use std::io::Result::*; //~ ERROR Not a module +use Alias::*; +//~^ ERROR unresolved import `Alias::*` [E0432] +//~| Not a module `Alias` +use std::io::Result::*; +//~^ ERROR unresolved import `std::io::Result::*` [E0432] +//~| Not a module `Result` trait T {} use T::*; //~ ERROR items in traits are not importable diff --git a/src/test/compile-fail/issue-32833.rs b/src/test/compile-fail/issue-32833.rs index 22261d98a12..d610e8b4837 100644 --- a/src/test/compile-fail/issue-32833.rs +++ b/src/test/compile-fail/issue-32833.rs @@ -8,9 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use bar::Foo; //~ ERROR There is no `Foo` in `bar` [E0432] +use bar::Foo; //~ ERROR unresolved import `bar::Foo` [E0432] + //~^ no `Foo` in `bar` mod bar { - use Foo; //~ ERROR There is no `Foo` in the crate root [E0432] + use Foo; //~ ERROR unresolved import `Foo` [E0432] + //~^ no `Foo` in the root } fn main() {} diff --git a/src/test/compile-fail/issue-5035.rs b/src/test/compile-fail/issue-5035.rs index c2154e8a6c0..7a36012925e 100644 --- a/src/test/compile-fail/issue-5035.rs +++ b/src/test/compile-fail/issue-5035.rs @@ -14,7 +14,8 @@ impl K for isize {} //~ ERROR: `K` is not a trait //~| NOTE: not a trait //~| NOTE: aliases cannot be used for traits -use ImportError; //~ ERROR unresolved +use ImportError; //~ ERROR unresolved import `ImportError` [E0432] + //~^ no `ImportError` in the root impl ImportError for () {} // check that this is not an additional error (c.f. #35142) fn main() {} diff --git a/src/test/compile-fail/issue-8208.rs b/src/test/compile-fail/issue-8208.rs index 318089b3030..670b6bd46e7 100644 --- a/src/test/compile-fail/issue-8208.rs +++ b/src/test/compile-fail/issue-8208.rs @@ -8,14 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use self::*; //~ ERROR: unresolved import `self::*`. Cannot glob-import a module into itself. +use self::*; //~ ERROR: unresolved import `self::*` [E0432] + //~^ Cannot glob-import a module into itself. mod foo { - use foo::*; //~ ERROR: unresolved import `foo::*`. Cannot glob-import a module into itself. + use foo::*; //~ ERROR: unresolved import `foo::*` [E0432] + //~^ Cannot glob-import a module into itself. mod bar { use super::bar::*; - //~^ ERROR: unresolved import `super::bar::*`. Cannot glob-import a module into itself. + //~^ ERROR: unresolved import `super::bar::*` [E0432] + //~| Cannot glob-import a module into itself. } } diff --git a/src/test/compile-fail/privacy2.rs b/src/test/compile-fail/privacy2.rs index abf702204d1..376e95312b8 100644 --- a/src/test/compile-fail/privacy2.rs +++ b/src/test/compile-fail/privacy2.rs @@ -25,12 +25,14 @@ pub fn foo() {} fn test1() { use bar::foo; - //~^ ERROR unresolved import `bar::foo`. There is no `foo` in `bar` + //~^ ERROR unresolved import `bar::foo` [E0432] + //~| no `foo` in `bar` } fn test2() { use bar::glob::foo; - //~^ ERROR unresolved import `bar::glob::foo`. There is no `foo` in `bar::glob` + //~^ ERROR unresolved import `bar::glob::foo` [E0432] + //~| no `foo` in `bar::glob` } #[start] fn main(_: isize, _: *const *const u8) -> isize { 3 } diff --git a/src/test/compile-fail/privacy3.rs b/src/test/compile-fail/privacy3.rs index 89f38fa1434..b841717bd11 100644 --- a/src/test/compile-fail/privacy3.rs +++ b/src/test/compile-fail/privacy3.rs @@ -26,7 +26,8 @@ pub fn foo() {} fn test1() { use bar::gpriv; - //~^ ERROR unresolved import `bar::gpriv`. There is no `gpriv` in `bar` + //~^ ERROR unresolved import `bar::gpriv` [E0432] + //~| no `gpriv` in `bar` // This should pass because the compiler will insert a fake name binding // for `gpriv` diff --git a/src/test/compile-fail/regions-escape-loop-via-vec.rs b/src/test/compile-fail/regions-escape-loop-via-vec.rs index 89350f16167..8c026df7d97 100644 --- a/src/test/compile-fail/regions-escape-loop-via-vec.rs +++ b/src/test/compile-fail/regions-escape-loop-via-vec.rs @@ -12,11 +12,20 @@ fn broken() { let mut x = 3; let mut _y = vec!(&mut x); + //~^ NOTE borrow of `x` occurs here + //~| NOTE borrow of `x` occurs here + //~| NOTE borrow of `x` occurs here while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed + //~^ NOTE use of borrowed `x` let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed + //~^ NOTE use of borrowed `x` _y.push(&mut z); //~ ERROR `z` does not live long enough + //~^ NOTE does not live long enough x += 1; //~ ERROR cannot assign + //~^ NOTE assignment to borrowed `x` occurs here } + //~^ NOTE borrowed value only valid until here } +//~^ NOTE borrowed value must be valid until here fn main() { } diff --git a/src/test/compile-fail/resolve_self_super_hint.rs b/src/test/compile-fail/resolve_self_super_hint.rs index ed143fdff68..a23ac80fca6 100644 --- a/src/test/compile-fail/resolve_self_super_hint.rs +++ b/src/test/compile-fail/resolve_self_super_hint.rs @@ -11,16 +11,20 @@ mod a { extern crate collections; use collections::HashMap; -//~^ ERROR unresolved import `collections::HashMap`. Did you mean `self::collections`? + //~^ ERROR unresolved import `collections::HashMap` [E0432] + //~| Did you mean `self::collections`? mod b { use collections::HashMap; -//~^ ERROR unresolved import `collections::HashMap`. Did you mean `a::collections`? + //~^ ERROR unresolved import `collections::HashMap` [E0432] + //~| Did you mean `a::collections`? mod c { use collections::HashMap; -//~^ ERROR unresolved import `collections::HashMap`. Did you mean `a::collections`? + //~^ ERROR unresolved import `collections::HashMap` [E0432] + //~| Did you mean `a::collections`? mod d { use collections::HashMap; -//~^ ERROR unresolved import `collections::HashMap`. Did you mean `a::collections`? + //~^ ERROR unresolved import `collections::HashMap` [E0432] + //~| Did you mean `a::collections`? } } } diff --git a/src/test/compile-fail/super-at-top-level.rs b/src/test/compile-fail/super-at-top-level.rs index f59caef4631..7d11ff6c9b5 100644 --- a/src/test/compile-fail/super-at-top-level.rs +++ b/src/test/compile-fail/super-at-top-level.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use super::f; //~ ERROR unresolved import `super::f`. There are too many initial `super`s. +use super::f; //~ ERROR unresolved import `super::f` [E0432] + //~^ There are too many initial `super`s. fn main() { } diff --git a/src/test/compile-fail/unresolved-import.rs b/src/test/compile-fail/unresolved-import.rs index b60d19fcab4..d1254f3f524 100644 --- a/src/test/compile-fail/unresolved-import.rs +++ b/src/test/compile-fail/unresolved-import.rs @@ -10,13 +10,17 @@ // ignore-tidy-linelength -use foo::bar; //~ ERROR unresolved import `foo::bar`. Maybe a missing `extern crate foo`? +use foo::bar; //~ ERROR unresolved import `foo::bar` [E0432] + //~^ Maybe a missing `extern crate foo`? -use bar::Baz as x; //~ ERROR unresolved import `bar::Baz`. There is no `Baz` in `bar`. Did you mean to use `Bar`? +use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432] + //~^ no `Baz` in `bar`. Did you mean to use `Bar`? -use food::baz; //~ ERROR unresolved import `food::baz`. There is no `baz` in `food`. Did you mean to use `bag`? +use food::baz; //~ ERROR unresolved import `food::baz` + //~^ no `baz` in `food`. Did you mean to use `bag`? -use food::{beens as Foo}; //~ ERROR unresolved import `food::beens`. There is no `beens` in `food`. Did you mean to use `beans`? +use food::{beens as Foo}; //~ ERROR unresolved import `food::beens` [E0432] + //~^ no `beens` in `food`. Did you mean to use `beans`? mod bar { pub struct Bar; diff --git a/src/test/compile-fail/use-from-trait.rs b/src/test/compile-fail/use-from-trait.rs index 28e933bc7aa..58e37bbfa3e 100644 --- a/src/test/compile-fail/use-from-trait.rs +++ b/src/test/compile-fail/use-from-trait.rs @@ -18,10 +18,12 @@ use Trait::C; //~^ ERROR `C` is not directly importable use Foo::new; -//~^ ERROR unresolved import `Foo::new`. Not a module `Foo` +//~^ ERROR unresolved import `Foo::new` [E0432] +//~| Not a module `Foo` use Foo::C2; -//~^ ERROR unresolved import `Foo::C2`. Not a module `Foo` +//~^ ERROR unresolved import `Foo::C2` [E0432] +//~| Not a module `Foo` pub trait Trait { fn foo(); diff --git a/src/test/compile-fail/use-keyword.rs b/src/test/compile-fail/use-keyword.rs index 040db025567..6df20d414a7 100644 --- a/src/test/compile-fail/use-keyword.rs +++ b/src/test/compile-fail/use-keyword.rs @@ -14,9 +14,14 @@ mod a { mod b { use self as A; //~ ERROR `self` imports are only allowed within a { } list - //~^ ERROR unresolved import `self`. There is no `self` in the crate root - use super as B; //~ ERROR unresolved import `super`. There is no `super` in the crate root - use super::{self as C}; //~ERROR unresolved import `super`. There is no `super` in the crate + //~^ ERROR unresolved import `self` [E0432] + //~| no `self` in the root + use super as B; + //~^ ERROR unresolved import `super` [E0432] + //~| no `super` in the root + use super::{self as C}; + //~^ ERROR unresolved import `super` [E0432] + //~| no `super` in the root } } diff --git a/src/test/compile-fail/use-mod-2.rs b/src/test/compile-fail/use-mod-2.rs index f2384912cdb..5f8842a521a 100644 --- a/src/test/compile-fail/use-mod-2.rs +++ b/src/test/compile-fail/use-mod-2.rs @@ -10,10 +10,12 @@ mod foo { use self::{self}; - //~^ ERROR unresolved import `self`. There is no `self` in the crate root + //~^ ERROR unresolved import `self` [E0432] + //~| no `self` in the root use super::{self}; - //~^ ERROR unresolved import `super`. There is no `super` in the crate root + //~^ ERROR unresolved import `super` [E0432] + //~| no `super` in the root } fn main() {}