diff --git a/man/rustc.1 b/man/rustc.1 index fa61afd3be582..edbc6cea02664 100644 --- a/man/rustc.1 +++ b/man/rustc.1 @@ -1,4 +1,4 @@ -.TH RUSTC "1" "August 2015" "rustc 1.2.0" "User Commands" +.TH RUSTC "1" "August 2016" "rustc 1.12.0" "User Commands" .SH NAME rustc \- The Rust compiler .SH SYNOPSIS @@ -299,7 +299,7 @@ To build an executable with debug info: See https://github.com/rust\-lang/rust/issues for issues. .SH "AUTHOR" -See \fIAUTHORS.txt\fR in the Rust source distribution. +See https://github.com/rust\-lang/rust/graphs/contributors or use `git log --all --format='%cN <%cE>' | sort -u` in the rust source distribution. .SH "COPYRIGHT" This work is dual\[hy]licensed under Apache\ 2.0 and MIT terms. diff --git a/man/rustdoc.1 b/man/rustdoc.1 index ae14c9d78287f..3fb5757f4ff24 100644 --- a/man/rustdoc.1 +++ b/man/rustdoc.1 @@ -1,4 +1,4 @@ -.TH RUSTDOC "1" "August 2015" "rustdoc 1.2.0" "User Commands" +.TH RUSTDOC "1" "August 2016" "rustdoc 1.12.0" "User Commands" .SH NAME rustdoc \- generate documentation from Rust source code .SH SYNOPSIS diff --git a/src/librustc/middle/astconv_util.rs b/src/librustc/middle/astconv_util.rs index 0a5f6884af9bb..86422835c8cbd 100644 --- a/src/librustc/middle/astconv_util.rs +++ b/src/librustc/middle/astconv_util.rs @@ -47,8 +47,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn prohibit_projection(self, span: Span) { - span_err!(self.sess, span, E0229, - "associated type bindings are not allowed here"); + let mut err = struct_span_err!(self.sess, span, E0229, + "associated type bindings are not allowed here"); + err.span_label(span, &format!("associate type not allowed here")).emit(); } pub fn prim_ty_to_ty(self, diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 67ad887530eb3..9950560b13a5a 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -870,10 +870,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, '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(&self, diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 1fe47cd485387..9115fd42be870 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -942,9 +942,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { but it borrows {}, \ which is owned by the current function", cmt_path_or_string) - .span_note(capture_span, + .span_label(capture_span, &format!("{} is borrowed here", cmt_path_or_string)) + .span_label(err.span, + &format!("may outlive borrowed value {}", + cmt_path_or_string)) .span_suggestion(err.span, &format!("to force the closure to take ownership of {} \ (and any other referenced variables), \ diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index d148d2a0885ed..2fe4ae627c1dc 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -424,10 +424,15 @@ fn check_exhaustive<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, format!("`{}` and {} more", head.join("`, `"), tail.len()) } }; - span_err!(cx.tcx.sess, sp, E0004, + + let label_text = match pattern_strings.len(){ + 1 => format!("pattern {} not covered", joined_patterns), + _ => format!("patterns {} not covered", joined_patterns) + }; + struct_span_err!(cx.tcx.sess, sp, E0004, "non-exhaustive patterns: {} not covered", joined_patterns - ); + ).span_label(sp, &label_text).emit(); }, } } diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index d424b57c93841..43d9725baaf00 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -1337,10 +1337,13 @@ pub fn eval_length<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, Ok(val as usize) }, Ok(const_val) => { - span_err!(tcx.sess, count_expr.span, E0306, - "expected usize for {}, found {}", - reason, - const_val.description()); + struct_span_err!(tcx.sess, count_expr.span, E0306, + "expected `usize` for {}, found {}", + reason, + const_val.description()) + .span_label(count_expr.span, &format!("expected `usize`")) + .emit(); + Err(ErrorReported) } Err(err) => { diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index d2cf48eddebac..eb5a5a3ae47ef 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -169,6 +169,8 @@ impl<'a> Visitor for AstValidator<'a> { self.check_decl_no_pat(decl, |span, is_recent| { let mut err = struct_span_err!(self.session, span, E0130, "patterns aren't allowed in foreign function declarations"); + err.span_label(span, &format!("pattern not allowed in foreign function")); + if is_recent { err.span_note(span, "this is a recent error, see \ issue #35203 for more details"); diff --git a/src/librustc_passes/diagnostics.rs b/src/librustc_passes/diagnostics.rs index 3e2dd477bccf0..7049040678e39 100644 --- a/src/librustc_passes/diagnostics.rs +++ b/src/librustc_passes/diagnostics.rs @@ -121,11 +121,11 @@ All statics and constants need to resolve to a value in an acyclic manner. For example, neither of the following can be sensibly compiled: -```compile_fail +```compile_fail,E0265 const X: u32 = X; ``` -```compile_fail +```compile_fail,E0265 const X: u32 = Y; const Y: u32 = X; ``` @@ -135,7 +135,7 @@ E0267: r##" This error indicates the use of a loop keyword (`break` or `continue`) inside a closure but outside of any loop. Erroneous code example: -```compile_fail +```compile_fail,E0267 let w = || { break; }; // error: `break` inside of a closure ``` @@ -159,7 +159,7 @@ This error indicates the use of a loop keyword (`break` or `continue`) outside of a loop. Without a loop to break out of or continue in, no sensible action can be taken. Erroneous code example: -```compile_fail +```compile_fail,E0268 fn some_func() { break; // error: `break` outside of loop } diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 3e860150a35fd..11ef75ee6a8fc 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -146,6 +146,7 @@ mod foo { } use foo::MyTrait::do_something; +// error: `do_something` is not directly importable fn main() {} ``` @@ -153,6 +154,45 @@ fn main() {} It's invalid to directly import methods belonging to a trait or concrete type. "##, +E0254: r##" +Attempt was made to import an item whereas an extern crate with this name has +already been imported. + +Erroneous code example: + +```compile_fail,E0254 +extern crate collections; + +mod foo { + pub trait collections { + fn do_something(); + } +} + +use foo::collections; // error: an extern crate named `collections` has already + // been imported in this module + +fn main() {} +``` + +To fix issue issue, you have to rename at least one of the two imports. +Example: + +```ignore +extern crate collections as libcollections; // ok! + +mod foo { + pub trait collections { + fn do_something(); + } +} + +use foo::collections; + +fn main() {} +``` +"##, + E0255: r##" You can't import a value whose name is the same as another value defined in the module. @@ -1237,7 +1277,6 @@ impl Foo for i32 {} register_diagnostics! { // E0153, unused error code // E0157, unused error code - E0254, // import conflicts with imported crate in this module // E0257, // E0258, E0402, // cannot use an outer type parameter in this context diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index a11df5ae05d6f..50ffa52e88ba4 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -310,8 +310,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { None => match rscope.anon_regions(default_span, 1) { Ok(rs) => rs[0], Err(params) => { - let mut err = struct_span_err!(self.tcx().sess, default_span, E0106, - "missing lifetime specifier"); + let ampersand_span = Span { hi: default_span.lo, ..default_span}; + + let mut err = struct_span_err!(self.tcx().sess, ampersand_span, E0106, + "missing lifetime specifier"); + err.span_label(ampersand_span, &format!("expected lifetime parameter")); + if let Some(params) = params { report_elision_failure(&mut err, params); } @@ -2269,9 +2273,25 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize, } fn report_lifetime_number_error(tcx: TyCtxt, span: Span, number: usize, expected: usize) { - span_err!(tcx.sess, span, E0107, - "wrong number of lifetime parameters: expected {}, found {}", - expected, number); + let label = if number < expected { + if expected == 1 { + format!("expected {} lifetime parameter", expected) + } else { + format!("expected {} lifetime parameters", expected) + } + } else { + let additional = number - expected; + if additional == 1 { + "unexpected lifetime parameter".to_string() + } else { + format!("{} unexpected lifetime parameters", additional) + } + }; + struct_span_err!(tcx.sess, span, E0107, + "wrong number of lifetime parameters: expected {}, found {}", + expected, number) + .span_label(span, &label) + .emit(); } // A helper struct for conveniently grouping a set of bounds which we pass to diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 9844377d0bd32..cc8af0ffa2b13 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -14,6 +14,8 @@ use rustc::ty; use rustc::traits::{self, ProjectionMode}; use rustc::ty::error::ExpectedFound; use rustc::ty::subst::{self, Subst, Substs, VecPerParamSpace}; +use rustc::hir::map::Node; +use rustc::hir::{ImplItemKind, TraitItem_}; use syntax::ast; use syntax_pos::Span; @@ -447,7 +449,7 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // Compute skolemized form of impl and trait const tys. let impl_ty = impl_c.ty.subst(tcx, impl_to_skol_substs); let trait_ty = trait_c.ty.subst(tcx, &trait_to_skol_substs); - let origin = TypeOrigin::Misc(impl_c_span); + let mut origin = TypeOrigin::Misc(impl_c_span); let err = infcx.commit_if_ok(|_| { // There is no "body" here, so just pass dummy id. @@ -482,11 +484,31 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, debug!("checking associated const for compatibility: impl ty {:?}, trait ty {:?}", impl_ty, trait_ty); + + // Locate the Span containing just the type of the offending impl + if let Some(impl_trait_node) = tcx.map.get_if_local(impl_c.def_id) { + if let Node::NodeImplItem(impl_trait_item) = impl_trait_node { + if let ImplItemKind::Const(ref ty, _) = impl_trait_item.node { + origin = TypeOrigin::Misc(ty.span); + } + } + } + let mut diag = struct_span_err!( tcx.sess, origin.span(), E0326, "implemented const `{}` has an incompatible type for trait", trait_c.name ); + + // Add a label to the Span containing just the type of the item + if let Some(orig_trait_node) = tcx.map.get_if_local(trait_c.def_id) { + if let Node::NodeTraitItem(orig_trait_item) = orig_trait_node { + if let TraitItem_::ConstTraitItem(ref ty, _) = orig_trait_item.node { + diag.span_label(ty.span, &format!("original trait requirement")); + } + } + } + infcx.note_type_err( &mut diag, origin, Some(infer::ValuePairs::Types(ExpectedFound { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 97788c9fb3399..bd0e1e22ba41a 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -847,7 +847,9 @@ fn check_trait_fn_not_const<'a,'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // good } hir::Constness::Const => { - span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const"); + struct_span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const") + .span_label(span, &format!("trait fns cannot be const")) + .emit() } } } @@ -993,7 +995,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // Check existing impl methods to see if they are both present in trait // and compatible with trait signature for impl_item in impl_items { - let ty_impl_item = ccx.tcx.impl_or_trait_item(ccx.tcx.map.local_def_id(impl_item.id)); + let ty_impl_item = tcx.impl_or_trait_item(tcx.map.local_def_id(impl_item.id)); let ty_trait_item = trait_items.iter() .find(|ac| ac.name() == ty_impl_item.name()); @@ -1014,11 +1016,18 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, trait_const, &impl_trait_ref); } else { - span_err!(tcx.sess, impl_item.span, E0323, + let mut err = struct_span_err!(tcx.sess, impl_item.span, E0323, "item `{}` is an associated const, \ which doesn't match its trait `{:?}`", impl_const.name, - impl_trait_ref) + impl_trait_ref); + err.span_label(impl_item.span, &format!("does not match trait")); + // We can only get the spans from local trait definition + // Same for E0324 and E0325 + if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) { + err.span_label(trait_span, &format!("original trait requirement")); + } + err.emit() } } hir::ImplItemKind::Method(ref sig, ref body) => { @@ -1037,11 +1046,16 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, &trait_method, &impl_trait_ref); } else { - span_err!(tcx.sess, impl_item.span, E0324, + let mut err = struct_span_err!(tcx.sess, impl_item.span, E0324, "item `{}` is an associated method, \ which doesn't match its trait `{:?}`", impl_method.name, - impl_trait_ref) + impl_trait_ref); + err.span_label(impl_item.span, &format!("does not match trait")); + if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) { + err.span_label(trait_span, &format!("original trait requirement")); + } + err.emit() } } hir::ImplItemKind::Type(_) => { @@ -1055,11 +1069,16 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, overridden_associated_type = Some(impl_item); } } else { - span_err!(tcx.sess, impl_item.span, E0325, + let mut err = struct_span_err!(tcx.sess, impl_item.span, E0325, "item `{}` is an associated type, \ which doesn't match its trait `{:?}`", impl_type.name, - impl_trait_ref) + impl_trait_ref); + err.span_label(impl_item.span, &format!("does not match trait")); + if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id()) { + err.span_label(trait_span, &format!("original trait requirement")); + } + err.emit() } } } @@ -1251,8 +1270,9 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, let mut err = struct_span_err!(ccx.tcx.sess, v.span, E0081, "discriminant value `{}` already exists", disr_vals[i]); let variant_i_node_id = ccx.tcx.map.as_local_node_id(variants[i].did).unwrap(); - span_note!(&mut err, ccx.tcx.map.span(variant_i_node_id), - "conflicting discriminant here"); + err.span_label(ccx.tcx.map.span(variant_i_node_id), + &format!("first use of `{}`", disr_vals[i])); + err.span_label(v.span , &format!("enum already has `{}`", disr_vals[i])); err.emit(); } disr_vals.push(current_disr_val); @@ -3415,8 +3435,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(ref e) = *expr_opt { self.check_expr(&e); } - span_err!(tcx.sess, expr.span, E0166, - "`return` in a function declared as diverging"); + struct_span_err!(tcx.sess, expr.span, E0166, + "`return` in a function declared as diverging") + .span_label(expr.span, &format!("diverging function cannot return")) + .emit(); } } self.write_ty(id, self.next_diverging_ty_var()); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index cb9c0496246d5..777552d4946ae 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -770,9 +770,10 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { let mut err = struct_span_err!(tcx.sess, impl_item.span, E0201, "duplicate definitions with name `{}`:", impl_item.name); - span_note!(&mut err, *entry.get(), - "previous definition of `{}` here", - impl_item.name); + err.span_label(*entry.get(), + &format!("previous definition of `{}` here", + impl_item.name)); + err.span_label(impl_item.span, &format!("duplicate definition")); err.emit(); } Vacant(entry) => { @@ -2317,8 +2318,12 @@ fn report_unused_parameter(ccx: &CrateCtxt, kind: &str, name: &str) { - span_err!(ccx.tcx.sess, span, E0207, - "the {} parameter `{}` is not constrained by the \ - impl trait, self type, or predicates", - kind, name); + struct_span_err!( + ccx.tcx.sess, span, E0207, + "the {} parameter `{}` is not constrained by the \ + impl trait, self type, or predicates", + kind, name) + .span_label(span, &format!("unconstrained lifetime parameter")) + .emit(); + } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index b315e6762633b..3b132744f7055 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -27,7 +27,7 @@ use sys_common::{AsInner, FromInner}; #[cfg(any(target_os = "linux", target_os = "emscripten"))] use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64, dirent64, readdir64_r, open64}; #[cfg(target_os = "android")] -use libc::{stat as stat64, fstat as fstat64, lstat as lstat64, off64_t, lseek64, +use libc::{stat as stat64, fstat as fstat64, lstat as lstat64, lseek64, dirent as dirent64, open as open64}; #[cfg(not(any(target_os = "linux", target_os = "emscripten", @@ -485,9 +485,11 @@ impl File { pub fn seek(&self, pos: SeekFrom) -> io::Result { let (whence, pos) = match pos { - SeekFrom::Start(off) => (libc::SEEK_SET, off as off64_t), - SeekFrom::End(off) => (libc::SEEK_END, off as off64_t), - SeekFrom::Current(off) => (libc::SEEK_CUR, off as off64_t), + // Casting to `i64` is fine, too large values will end up as + // negative which will cause an error in `lseek64`. + SeekFrom::Start(off) => (libc::SEEK_SET, off as i64), + SeekFrom::End(off) => (libc::SEEK_END, off), + SeekFrom::Current(off) => (libc::SEEK_CUR, off), }; let n = cvt(unsafe { lseek64(self.0.raw(), pos, whence) })?; Ok(n as u64) diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index 2683e57256dc7..4e6cef9a28d8f 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -324,6 +324,8 @@ impl File { pub fn seek(&self, pos: SeekFrom) -> io::Result { let (whence, pos) = match pos { + // Casting to `i64` is fine, `SetFilePointerEx` reinterprets this + // integer as `u64`. SeekFrom::Start(n) => (c::FILE_BEGIN, n as i64), SeekFrom::End(n) => (c::FILE_END, n), SeekFrom::Current(n) => (c::FILE_CURRENT, n), diff --git a/src/test/compile-fail/E0106.rs b/src/test/compile-fail/E0106.rs index f1cd530863d34..dab03f0bccfd0 100644 --- a/src/test/compile-fail/E0106.rs +++ b/src/test/compile-fail/E0106.rs @@ -9,13 +9,19 @@ // except according to those terms. struct Foo { - x: &bool, //~ ERROR E0106 + x: &bool, + //~^ ERROR E0106 + //~| NOTE expected lifetime parameter } enum Bar { A(u8), - B(&bool), //~ ERROR E0106 + B(&bool), + //~^ ERROR E0106 + //~| NOTE expected lifetime parameter } -type MyStr = &str; //~ ERROR E0106 +type MyStr = &str; + //~^ ERROR E0106 + //~| NOTE expected lifetime parameter fn main() { } diff --git a/src/test/compile-fail/E0107.rs b/src/test/compile-fail/E0107.rs index d27b70865bbfb..5f333e17c478e 100644 --- a/src/test/compile-fail/E0107.rs +++ b/src/test/compile-fail/E0107.rs @@ -9,6 +9,7 @@ // except according to those terms. struct Foo<'a>(&'a str); +struct Buzz<'a, 'b>(&'a str, &'b str); enum Bar { A, @@ -16,9 +17,19 @@ enum Bar { C, } -struct Baz<'a> { - foo: Foo, //~ ERROR E0107 - bar: Bar<'a>, //~ ERROR E0107 +struct Baz<'a, 'b, 'c> { + foo: Foo, + //~^ ERROR E0107 + //~| expected 1 lifetime parameter + buzz: Buzz<'a>, + //~^ ERROR E0107 + //~| expected 2 lifetime parameters + bar: Bar<'a>, + //~^ ERROR E0107 + //~| unexpected lifetime parameter + foo2: Foo<'a, 'b, 'c>, + //~^ ERROR E0107 + //~| 2 unexpected lifetime parameters } fn main() { diff --git a/src/test/compile-fail/E0130.rs b/src/test/compile-fail/E0130.rs index ef5961e133894..e9e027fd1dc19 100644 --- a/src/test/compile-fail/E0130.rs +++ b/src/test/compile-fail/E0130.rs @@ -9,7 +9,9 @@ // except according to those terms. extern { - fn foo((a, b): (u32, u32)); //~ ERROR E0130 + fn foo((a, b): (u32, u32)); + //~^ ERROR E0130 + //~| NOTE pattern not allowed in foreign function } fn main() { diff --git a/src/test/compile-fail/E0166.rs b/src/test/compile-fail/E0166.rs index 9fa41249aa50b..f8585d71b402a 100644 --- a/src/test/compile-fail/E0166.rs +++ b/src/test/compile-fail/E0166.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo() -> ! { return; } //~ ERROR E0166 +fn foo() -> ! { return; } + //~^ ERROR E0166 + //~| NOTE diverging function cannot return fn main() { } diff --git a/src/test/compile-fail/E0207.rs b/src/test/compile-fail/E0207.rs index bd87dbaf786a5..43ff085a4fa8e 100644 --- a/src/test/compile-fail/E0207.rs +++ b/src/test/compile-fail/E0207.rs @@ -11,6 +11,7 @@ struct Foo; impl Foo { //~ ERROR E0207 + //~| NOTE unconstrained lifetime parameter fn get(&self) -> T { ::default() } diff --git a/src/test/compile-fail/E0229.rs b/src/test/compile-fail/E0229.rs index 45d5c59592f75..6ff0baeeb4d4b 100644 --- a/src/test/compile-fail/E0229.rs +++ b/src/test/compile-fail/E0229.rs @@ -20,7 +20,9 @@ impl Foo for isize { fn boo(&self) -> usize { 42 } } -fn baz(x: &>::A) {} //~ ERROR E0229 +fn baz(x: &>::A) {} +//~^ ERROR associated type bindings are not allowed here [E0229] +//~| NOTE associate type not allowed here fn main() { } diff --git a/src/test/compile-fail/E0253.rs b/src/test/compile-fail/E0253.rs new file mode 100644 index 0000000000000..28fcf4452b3e8 --- /dev/null +++ b/src/test/compile-fail/E0253.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 { + pub trait MyTrait { + fn do_something(); + } +} + +use foo::MyTrait::do_something; //~ ERROR E0253 + +fn main() {} diff --git a/src/test/compile-fail/E0254.rs b/src/test/compile-fail/E0254.rs new file mode 100644 index 0000000000000..28f9aea96572c --- /dev/null +++ b/src/test/compile-fail/E0254.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. + +extern crate collections; + +mod foo { + pub trait collections { + fn do_something(); + } +} + +use foo::collections; //~ ERROR E0254 + +fn main() {} diff --git a/src/test/compile-fail/E0255.rs b/src/test/compile-fail/E0255.rs new file mode 100644 index 0000000000000..e05c6bede7e04 --- /dev/null +++ b/src/test/compile-fail/E0255.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. + +use bar::foo; + +fn foo() {} //~ ERROR E0255 + +mod bar { + pub fn foo() {} +} + +fn main() {} diff --git a/src/test/compile-fail/E0259.rs b/src/test/compile-fail/E0259.rs new file mode 100644 index 0000000000000..6b7e86138594b --- /dev/null +++ b/src/test/compile-fail/E0259.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. + +extern crate collections; +extern crate libc as collections; //~ ERROR E0259 + +fn main() {} diff --git a/src/test/compile-fail/E0260.rs b/src/test/compile-fail/E0260.rs new file mode 100644 index 0000000000000..d20829bf4d415 --- /dev/null +++ b/src/test/compile-fail/E0260.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. + +extern crate collections; + +mod collections { //~ ERROR E0260 + pub trait MyTrait { + fn do_something(); + } +} + +fn main() {} diff --git a/src/test/compile-fail/E0261.rs b/src/test/compile-fail/E0261.rs new file mode 100644 index 0000000000000..4196ad370b887 --- /dev/null +++ b/src/test/compile-fail/E0261.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. + +fn foo(x: &'a str) { } //~ ERROR E0261 + +struct Foo { + x: &'a str, //~ ERROR E0261 +} + +fn main() {} diff --git a/src/test/compile-fail/E0262.rs b/src/test/compile-fail/E0262.rs new file mode 100644 index 0000000000000..e09e4766d5174 --- /dev/null +++ b/src/test/compile-fail/E0262.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo<'static>(x: &'static str) { } //~ ERROR E0262 + +fn main() {} diff --git a/src/test/compile-fail/E0263.rs b/src/test/compile-fail/E0263.rs new file mode 100644 index 0000000000000..09f654c368c62 --- /dev/null +++ b/src/test/compile-fail/E0263.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { } //~ ERROR E0263 + +fn main() {} diff --git a/src/test/compile-fail/E0264.rs b/src/test/compile-fail/E0264.rs new file mode 100644 index 0000000000000..92332977e7676 --- /dev/null +++ b/src/test/compile-fail/E0264.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(lang_items)] + +extern "C" { + #[lang = "cake"] + fn cake(); //~ ERROR E0264 +} + +fn main() {} diff --git a/src/test/compile-fail/E0267.rs b/src/test/compile-fail/E0267.rs new file mode 100644 index 0000000000000..6287256e866c9 --- /dev/null +++ b/src/test/compile-fail/E0267.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let w = || { break; }; //~ ERROR E0267 +} diff --git a/src/test/compile-fail/E0268.rs b/src/test/compile-fail/E0268.rs new file mode 100644 index 0000000000000..41e88e2f492a9 --- /dev/null +++ b/src/test/compile-fail/E0268.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + break; //~ ERROR E0268 +} diff --git a/src/test/compile-fail/E0306.rs b/src/test/compile-fail/E0306.rs index 61cc8902036ec..9ffaef7472b78 100644 --- a/src/test/compile-fail/E0306.rs +++ b/src/test/compile-fail/E0306.rs @@ -8,9 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const A: [u32; "hello"] = []; //~ ERROR E0306 -const B: [u32; true] = []; //~ ERROR E0306 -const C: [u32; 0.0] = []; //~ ERROR E0306 +const A: [u32; "hello"] = []; +//~^ ERROR expected `usize` for array length, found string literal [E0306] +//~| NOTE expected `usize` + +const B: [u32; true] = []; +//~^ ERROR expected `usize` for array length, found boolean [E0306] +//~| NOTE expected `usize` + +const C: [u32; 0.0] = []; +//~^ ERROR expected `usize` for array length, found float [E0306] +//~| NOTE expected `usize` fn main() { } diff --git a/src/test/compile-fail/associated-const-impl-wrong-type.rs b/src/test/compile-fail/associated-const-impl-wrong-type.rs index 95508a31044b8..b3776091682da 100644 --- a/src/test/compile-fail/associated-const-impl-wrong-type.rs +++ b/src/test/compile-fail/associated-const-impl-wrong-type.rs @@ -11,7 +11,7 @@ #![feature(associated_consts)] trait Foo { - const BAR: u32; + const BAR: u32; //~ NOTE original trait requirement } struct SignedBar; @@ -19,7 +19,7 @@ struct SignedBar; impl Foo for SignedBar { const BAR: i32 = -1; //~^ ERROR implemented const `BAR` has an incompatible type for trait [E0326] - //~| expected u32, found i32 + //~| NOTE expected u32, found i32 } fn main() {} diff --git a/src/test/compile-fail/bad-bang-ann-3.rs b/src/test/compile-fail/bad-bang-ann-3.rs index de315a41361a7..1a5496f055150 100644 --- a/src/test/compile-fail/bad-bang-ann-3.rs +++ b/src/test/compile-fail/bad-bang-ann-3.rs @@ -11,7 +11,9 @@ // Tests that a function with a ! annotation always actually fails fn bad_bang(i: usize) -> ! { - return 7; //~ ERROR `return` in a function declared as diverging [E0166] + return 7; + //~^ ERROR `return` in a function declared as diverging [E0166] + //~| NOTE diverging function cannot return } fn main() { bad_bang(5); } diff --git a/src/test/compile-fail/borrowck/borrowck-escaping-closure-error-1.rs b/src/test/compile-fail/borrowck/borrowck-escaping-closure-error-1.rs index 87e40df7663ba..ec330247f238b 100644 --- a/src/test/compile-fail/borrowck/borrowck-escaping-closure-error-1.rs +++ b/src/test/compile-fail/borrowck/borrowck-escaping-closure-error-1.rs @@ -22,4 +22,6 @@ fn main() { let mut books = vec![1,2,3]; spawn(|| books.push(4)); //~^ ERROR E0373 + //~| NOTE `books` is borrowed here + //~| NOTE may outlive borrowed value `books` } diff --git a/src/test/compile-fail/borrowck/borrowck-escaping-closure-error-2.rs b/src/test/compile-fail/borrowck/borrowck-escaping-closure-error-2.rs index 67700be890b1f..81685c32f2f29 100644 --- a/src/test/compile-fail/borrowck/borrowck-escaping-closure-error-2.rs +++ b/src/test/compile-fail/borrowck/borrowck-escaping-closure-error-2.rs @@ -20,6 +20,8 @@ fn foo<'a>(x: &'a i32) -> Box { let mut books = vec![1,2,3]; Box::new(|| books.push(4)) //~^ ERROR E0373 + //~| NOTE `books` is borrowed here + //~| NOTE may outlive borrowed value `books` } fn main() { } diff --git a/src/test/compile-fail/const-fn-mismatch.rs b/src/test/compile-fail/const-fn-mismatch.rs index d813cf32954e3..92568b27f7c1d 100644 --- a/src/test/compile-fail/const-fn-mismatch.rs +++ b/src/test/compile-fail/const-fn-mismatch.rs @@ -20,7 +20,9 @@ trait Foo { } impl Foo for u32 { - const fn f() -> u32 { 22 } //~ ERROR E0379 + const fn f() -> u32 { 22 } + //~^ ERROR E0379 + //~| NOTE trait fns cannot be const } fn main() { } diff --git a/src/test/compile-fail/const-integer-bool-ops.rs b/src/test/compile-fail/const-integer-bool-ops.rs index 5dadd892f8352..398dc2f22150c 100644 --- a/src/test/compile-fail/const-integer-bool-ops.rs +++ b/src/test/compile-fail/const-integer-bool-ops.rs @@ -25,17 +25,35 @@ const X3: usize = -42 && -39; //~ ERROR E0080 const ARR3: [i32; X3] = [99; 6]; //~ NOTE: for array length here const Y: usize = 42.0 == 42.0; -const ARRR: [i32; Y] = [99; 1]; //~ ERROR: expected usize for array length +const ARRR: [i32; Y] = [99; 1]; +//~^ ERROR: expected `usize` for array length, found boolean [E0306] +//~| NOTE expected `usize` + const Y1: usize = 42.0 >= 42.0; -const ARRR1: [i32; Y] = [99; 1]; //~ ERROR: expected usize for array length +const ARRR1: [i32; Y] = [99; 1]; +//~^ ERROR: expected `usize` for array length, found boolean [E0306] +//~| NOTE expected `usize` + const Y2: usize = 42.0 <= 42.0; -const ARRR2: [i32; Y] = [99; 1]; //~ ERROR: expected usize for array length +const ARRR2: [i32; Y] = [99; 1]; +//~^ ERROR: expected `usize` for array length, found boolean [E0306] +//~| NOTE expected `usize` + const Y3: usize = 42.0 > 42.0; -const ARRR3: [i32; Y] = [99; 0]; //~ ERROR: expected usize for array length +const ARRR3: [i32; Y] = [99; 0]; +//~^ ERROR: expected `usize` for array length, found boolean [E0306] +//~| NOTE expected `usize` + const Y4: usize = 42.0 < 42.0; -const ARRR4: [i32; Y] = [99; 0]; //~ ERROR: expected usize for array length +const ARRR4: [i32; Y] = [99; 0]; +//~^ ERROR: expected `usize` for array length, found boolean [E0306] +//~| NOTE expected `usize` + const Y5: usize = 42.0 != 42.0; -const ARRR5: [i32; Y] = [99; 0]; //~ ERROR: expected usize for array length +const ARRR5: [i32; Y] = [99; 0]; +//~^ ERROR: expected `usize` for array length, found boolean [E0306] +//~| NOTE expected `usize` + fn main() { let _ = ARR; diff --git a/src/test/compile-fail/impl-duplicate-methods.rs b/src/test/compile-fail/impl-duplicate-methods.rs index 981eddc9dd96b..f6e9ab2d614bc 100644 --- a/src/test/compile-fail/impl-duplicate-methods.rs +++ b/src/test/compile-fail/impl-duplicate-methods.rs @@ -12,7 +12,9 @@ struct Foo; 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() {} diff --git a/src/test/compile-fail/impl-unused-rps-in-assoc-type.rs b/src/test/compile-fail/impl-unused-rps-in-assoc-type.rs index 23401db21d890..d48433ee928f1 100644 --- a/src/test/compile-fail/impl-unused-rps-in-assoc-type.rs +++ b/src/test/compile-fail/impl-unused-rps-in-assoc-type.rs @@ -19,6 +19,7 @@ trait Fun { struct Holder { x: String } impl<'a> Fun for Holder { //~ ERROR E0207 + //~| NOTE unconstrained lifetime parameter type Output = &'a str; fn call<'b>(&'b self) -> &'b str { &self.x[..] diff --git a/src/test/compile-fail/impl-wrong-item-for-trait.rs b/src/test/compile-fail/impl-wrong-item-for-trait.rs index 9b3e28cbc01ee..6452e50d0893e 100644 --- a/src/test/compile-fail/impl-wrong-item-for-trait.rs +++ b/src/test/compile-fail/impl-wrong-item-for-trait.rs @@ -12,7 +12,9 @@ trait Foo { fn bar(&self); - const MY_CONST: u32; + //~^ NOTE original trait requirement + //~| NOTE original trait requirement + const MY_CONST: u32; //~ NOTE original trait requirement } pub struct FooConstForMethod; @@ -21,6 +23,7 @@ impl Foo for FooConstForMethod { //~^ ERROR E0046 const bar: u64 = 1; //~^ ERROR E0323 + //~| NOTE does not match trait const MY_CONST: u32 = 1; } @@ -31,6 +34,7 @@ impl Foo for FooMethodForConst { fn bar(&self) {} fn MY_CONST() {} //~^ ERROR E0324 + //~| NOTE does not match trait } pub struct FooTypeForMethod; @@ -39,6 +43,7 @@ impl Foo for FooTypeForMethod { //~^ ERROR E0046 type bar = u64; //~^ ERROR E0325 + //~| NOTE does not match trait const MY_CONST: u32 = 1; } diff --git a/src/test/compile-fail/issue-15524.rs b/src/test/compile-fail/issue-15524.rs index bdf344dcdfe8d..3d6f224c24904 100644 --- a/src/test/compile-fail/issue-15524.rs +++ b/src/test/compile-fail/issue-15524.rs @@ -12,13 +12,18 @@ const N: isize = 1; enum Foo { A = 1, - B = 1, //~ ERROR discriminant value `1isize` already exists - //~^^ NOTE conflicting + //~^ NOTE first use + //~| NOTE first use + //~| NOTE first use + B = 1, //~ ERROR discriminant value + //~^ NOTE enum already C = 0, - D, //~ ERROR discriminant value `1isize` already exists - //~^^^^^ NOTE conflicting - E = N, //~ ERROR discriminant value `1isize` already exists - //~^^^^^^^ NOTE conflicting + D, //~ ERROR discriminant value + //~^ NOTE enum already + + E = N, //~ ERROR discriminant value + //~^ NOTE enum already + } fn main() {} diff --git a/src/test/compile-fail/issue-22886.rs b/src/test/compile-fail/issue-22886.rs index 4aa2571cad0cc..d258a4a8b3325 100644 --- a/src/test/compile-fail/issue-22886.rs +++ b/src/test/compile-fail/issue-22886.rs @@ -21,6 +21,7 @@ fn crash_please() { struct Newtype(Option>); impl<'a> Iterator for Newtype { //~ ERROR E0207 + //~| NOTE unconstrained lifetime parameter type Item = &'a Box; fn next(&mut self) -> Option<&Box> { diff --git a/src/test/compile-fail/issue-23041.rs b/src/test/compile-fail/issue-23041.rs index 1a9bb4c29f3e0..1be082ba9bbba 100644 --- a/src/test/compile-fail/issue-23041.rs +++ b/src/test/compile-fail/issue-23041.rs @@ -14,4 +14,6 @@ fn main() fn bar(x:i32) ->i32 { 3*x }; let b:Box = Box::new(bar as fn(_)->_); b.downcast_ref::_>(); //~ ERROR E0282 + //~| NOTE cannot infer type for `_` + //~| NOTE type annotations or generic parameter binding required } diff --git a/src/test/compile-fail/issue-23543.rs b/src/test/compile-fail/issue-23543.rs index 4ed44154c4748..f1c559b6b889f 100644 --- a/src/test/compile-fail/issue-23543.rs +++ b/src/test/compile-fail/issue-23543.rs @@ -16,6 +16,7 @@ pub trait D { fn f(self) where T: A; //~^ ERROR associated type bindings are not allowed here [E0229] + //~| NOTE associate type not allowed here } fn main() {} diff --git a/src/test/compile-fail/issue-23544.rs b/src/test/compile-fail/issue-23544.rs index 1d7c2187045ea..3959c22d1d489 100644 --- a/src/test/compile-fail/issue-23544.rs +++ b/src/test/compile-fail/issue-23544.rs @@ -14,6 +14,7 @@ pub trait D { fn f(self) where T: A; //~^ ERROR associated type bindings are not allowed here [E0229] + //~| NOTE associate type not allowed here } fn main() {} diff --git a/src/test/compile-fail/issue-27008.rs b/src/test/compile-fail/issue-27008.rs index ee6ec52761266..e89bff025e006 100644 --- a/src/test/compile-fail/issue-27008.rs +++ b/src/test/compile-fail/issue-27008.rs @@ -16,5 +16,6 @@ fn main() { //~| expected type `usize` //~| found type `S` //~| expected usize, found struct `S` - //~| ERROR expected usize for repeat count, found struct + //~| ERROR expected `usize` for repeat count, found struct [E0306] + //~| expected `usize` } diff --git a/src/test/compile-fail/issue-35139.rs b/src/test/compile-fail/issue-35139.rs index 67f0e7aaf9717..5c4f161a5004e 100644 --- a/src/test/compile-fail/issue-35139.rs +++ b/src/test/compile-fail/issue-35139.rs @@ -17,6 +17,7 @@ pub trait MethodType { pub struct MTFn; impl<'a> MethodType for MTFn { //~ ERROR E0207 + //~| NOTE unconstrained lifetime parameter type GetProp = fmt::Debug + 'a; } diff --git a/src/test/compile-fail/issue-4335.rs b/src/test/compile-fail/issue-4335.rs index 9a1b5d9b83d2c..09371fbafcb56 100644 --- a/src/test/compile-fail/issue-4335.rs +++ b/src/test/compile-fail/issue-4335.rs @@ -14,7 +14,10 @@ fn f<'r, T>(v: &'r T) -> Box T + 'r> { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. id(Box::new(|| *v)) //~^ ERROR E0373 - //~| ERROR cannot move out of borrowed content + //~| NOTE `v` is borrowed here + //~| NOTE may outlive borrowed value `v` + //~| ERROR E0507 + //~| NOTE cannot move out of borrowed content } fn main() { diff --git a/src/test/compile-fail/no-patterns-in-args.rs b/src/test/compile-fail/no-patterns-in-args.rs index 3edbdf4ebc958..b0278476998dd 100644 --- a/src/test/compile-fail/no-patterns-in-args.rs +++ b/src/test/compile-fail/no-patterns-in-args.rs @@ -10,10 +10,13 @@ extern { fn f1(mut arg: u8); //~ ERROR patterns aren't allowed in foreign function declarations - //~^ NOTE this is a recent error + //~^ NOTE pattern not allowed in foreign function + //~| NOTE this is a recent error fn f2(&arg: u8); //~ ERROR patterns aren't allowed in foreign function declarations + //~^ NOTE pattern not allowed in foreign function fn f3(arg @ _: u8); //~ ERROR patterns aren't allowed in foreign function declarations - //~^ NOTE this is a recent error + //~^ NOTE pattern not allowed in foreign function + //~| NOTE this is a recent error fn g1(arg: u8); // OK fn g2(_: u8); // OK // fn g3(u8); // Not yet diff --git a/src/test/compile-fail/non-exhaustive-pattern-witness.rs b/src/test/compile-fail/non-exhaustive-pattern-witness.rs index 0b12a9acbcb9e..eba61ede8cb20 100644 --- a/src/test/compile-fail/non-exhaustive-pattern-witness.rs +++ b/src/test/compile-fail/non-exhaustive-pattern-witness.rs @@ -19,6 +19,7 @@ struct Foo { fn struct_with_a_nested_enum_and_vector() { match (Foo { first: true, second: None }) { //~^ ERROR non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered +//~| NOTE pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered Foo { first: true, second: None } => (), Foo { first: true, second: Some(_) } => (), Foo { first: false, second: None } => (), @@ -35,6 +36,7 @@ enum Color { fn enum_with_single_missing_variant() { match Color::Red { //~^ ERROR non-exhaustive patterns: `Red` not covered + //~| NOTE pattern `Red` not covered Color::CustomRGBA { .. } => (), Color::Green => () } @@ -47,6 +49,7 @@ enum Direction { fn enum_with_multiple_missing_variants() { match Direction::North { //~^ ERROR non-exhaustive patterns: `East`, `South` and `West` not covered + //~| NOTE patterns `East`, `South` and `West` not covered Direction::North => () } } @@ -58,6 +61,7 @@ enum ExcessiveEnum { fn enum_with_excessive_missing_variants() { match ExcessiveEnum::First { //~^ ERROR `Second`, `Third`, `Fourth` and 8 more not covered + //~| NOTE patterns `Second`, `Third`, `Fourth` and 8 more not covered ExcessiveEnum::First => () } @@ -66,6 +70,7 @@ fn enum_with_excessive_missing_variants() { fn enum_struct_variant() { match Color::Red { //~^ ERROR non-exhaustive patterns: `CustomRGBA { a: true, .. }` not covered + //~| NOTE pattern `CustomRGBA { a: true, .. }` not covered Color::Red => (), Color::Green => (), Color::CustomRGBA { a: false, r: _, g: _, b: 0 } => (), @@ -82,6 +87,7 @@ fn vectors_with_nested_enums() { let x: &'static [Enum] = &[Enum::First, Enum::Second(false)]; match *x { //~^ ERROR non-exhaustive patterns: `[Second(true), Second(false)]` not covered + //~| NOTE pattern `[Second(true), Second(false)]` not covered [] => (), [_] => (), [Enum::First, _] => (), @@ -95,6 +101,7 @@ fn vectors_with_nested_enums() { fn missing_nil() { match ((), false) { //~^ ERROR non-exhaustive patterns: `((), false)` not covered + //~| NOTE pattern `((), false)` not covered ((), true) => () } } diff --git a/src/test/compile-fail/region-borrow-params-issue-29793-small.rs b/src/test/compile-fail/region-borrow-params-issue-29793-small.rs index 4fda8ec3f384e..6be2adbe2a0d1 100644 --- a/src/test/compile-fail/region-borrow-params-issue-29793-small.rs +++ b/src/test/compile-fail/region-borrow-params-issue-29793-small.rs @@ -16,6 +16,10 @@ fn escaping_borrow_of_closure_params_1() { let g = |x: usize, y:usize| { + //~^ NOTE reference must be valid for the scope of call-site for function + //~| NOTE ...but borrowed value is only valid for the scope of function body + //~| NOTE reference must be valid for the scope of call-site for function + //~| NOTE ...but borrowed value is only valid for the scope of function body let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR `x` does not live long enough //~| ERROR `y` does not live long enough @@ -31,6 +35,10 @@ fn escaping_borrow_of_closure_params_1() { fn escaping_borrow_of_closure_params_2() { let g = |x: usize, y:usize| { + //~^ NOTE reference must be valid for the scope of call-site for function + //~| NOTE ...but borrowed value is only valid for the scope of function body + //~| NOTE reference must be valid for the scope of call-site for function + //~| NOTE ...but borrowed value is only valid for the scope of function body let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR `x` does not live long enough //~| ERROR `y` does not live long enough @@ -64,7 +72,11 @@ fn escaping_borrow_of_fn_params_1() { fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 + //~| NOTE `x` is borrowed here + //~| NOTE may outlive borrowed value `x` //~| ERROR E0373 + //~| NOTE `y` is borrowed here + //~| NOTE may outlive borrowed value `y` return Box::new(f); }; @@ -75,7 +87,11 @@ fn escaping_borrow_of_fn_params_2() { fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 + //~| NOTE `x` is borrowed here + //~| NOTE may outlive borrowed value `x` //~| ERROR E0373 + //~| NOTE `y` is borrowed here + //~| NOTE may outlive borrowed value `y` Box::new(f) }; @@ -99,7 +115,11 @@ fn escaping_borrow_of_method_params_1() { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 + //~| NOTE `x` is borrowed here + //~| NOTE may outlive borrowed value `x` //~| ERROR E0373 + //~| NOTE `y` is borrowed here + //~| NOTE may outlive borrowed value `y` return Box::new(f); } } @@ -113,7 +133,11 @@ fn escaping_borrow_of_method_params_2() { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 + //~| NOTE `x` is borrowed here + //~| NOTE may outlive borrowed value `x` //~| ERROR E0373 + //~| NOTE `y` is borrowed here + //~| NOTE may outlive borrowed value `y` Box::new(f) } } @@ -141,7 +165,11 @@ fn escaping_borrow_of_trait_impl_params_1() { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 + //~| NOTE `x` is borrowed here + //~| NOTE may outlive borrowed value `x` //~| ERROR E0373 + //~| NOTE `y` is borrowed here + //~| NOTE may outlive borrowed value `y` return Box::new(f); } } @@ -156,7 +184,11 @@ fn escaping_borrow_of_trait_impl_params_2() { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 + //~| NOTE `x` is borrowed here + //~| NOTE may outlive borrowed value `x` //~| ERROR E0373 + //~| NOTE `y` is borrowed here + //~| NOTE may outlive borrowed value `y` Box::new(f) } } @@ -184,7 +216,11 @@ fn escaping_borrow_of_trait_default_params_1() { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 + //~| NOTE `x` is borrowed here + //~| NOTE may outlive borrowed value `x` //~| ERROR E0373 + //~| NOTE `y` is borrowed here + //~| NOTE may outlive borrowed value `y` return Box::new(f); } } @@ -198,7 +234,11 @@ fn escaping_borrow_of_trait_default_params_2() { fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 + //~| NOTE `x` is borrowed here + //~| NOTE may outlive borrowed value `x` //~| ERROR E0373 + //~| NOTE `y` is borrowed here + //~| NOTE may outlive borrowed value `y` Box::new(f) } } diff --git a/src/test/compile-fail/regions-nested-fns-2.rs b/src/test/compile-fail/regions-nested-fns-2.rs index 948dc8cd21968..40ba34b26ede6 100644 --- a/src/test/compile-fail/regions-nested-fns-2.rs +++ b/src/test/compile-fail/regions-nested-fns-2.rs @@ -13,8 +13,11 @@ fn ignore(_f: F) where F: for<'z> FnOnce(&'z isize) -> &'z isize {} fn nested() { let y = 3; ignore( - |z| { //~ ERROR E0373 + |z| { + //~^ ERROR E0373 + //~| NOTE may outlive borrowed value `y` if false { &y } else { z } + //~^ NOTE `y` is borrowed here }); } diff --git a/src/test/compile-fail/repeat_count.rs b/src/test/compile-fail/repeat_count.rs index 1758b28a32482..555dd0f0c3945 100644 --- a/src/test/compile-fail/repeat_count.rs +++ b/src/test/compile-fail/repeat_count.rs @@ -20,23 +20,27 @@ fn main() { //~| expected type `usize` //~| found type `()` //~| expected usize, found () - //~| ERROR expected usize for repeat count, found tuple [E0306] + //~| ERROR expected `usize` for repeat count, found tuple [E0306] + //~| expected `usize` let c = [0; true]; //~^ ERROR mismatched types //~| expected usize, found bool - //~| ERROR expected usize for repeat count, found boolean [E0306] + //~| ERROR expected `usize` for repeat count, found boolean [E0306] + //~| expected `usize` let d = [0; 0.5]; //~^ ERROR mismatched types //~| expected type `usize` //~| found type `{float}` //~| expected usize, found floating-point variable - //~| ERROR expected usize for repeat count, found float [E0306] + //~| ERROR expected `usize` for repeat count, found float [E0306] + //~| expected `usize` let e = [0; "foo"]; //~^ ERROR mismatched types //~| expected type `usize` //~| found type `&'static str` //~| expected usize, found &-ptr - //~| ERROR expected usize for repeat count, found string literal [E0306] + //~| ERROR expected `usize` for repeat count, found string literal [E0306] + //~| expected `usize` let f = [0; -4_isize]; //~^ ERROR constant evaluation error //~| expected usize, found isize @@ -55,5 +59,6 @@ fn main() { //~| expected type `usize` //~| found type `main::G` //~| expected usize, found struct `main::G` - //~| ERROR expected usize for repeat count, found struct [E0306] + //~| ERROR expected `usize` for repeat count, found struct [E0306] + //~| expected `usize` }