From c622a427bff3ae51788c78c3e63ce316fef6f85c Mon Sep 17 00:00:00 2001 From: Stefan Schindler Date: Thu, 4 Aug 2016 12:06:49 +0200 Subject: [PATCH 01/26] Update the man page rustc.1 --- man/rustc.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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. From 91f970429998fa237eefb82cdeecd3a9d55f243c Mon Sep 17 00:00:00 2001 From: Stefan Schindler Date: Thu, 4 Aug 2016 12:12:10 +0200 Subject: [PATCH 02/26] Update rustdoc version --- man/rustdoc.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 625fc29356690ea0a482c1820c3769048f503f1d Mon Sep 17 00:00:00 2001 From: trixnz Date: Thu, 4 Aug 2016 23:15:58 +0200 Subject: [PATCH 03/26] Update error format for E0130 --- src/librustc_passes/ast_validation.rs | 2 ++ src/test/compile-fail/E0130.rs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) 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/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() { From 87872376514ad37e0737c8568b82225980bb7b27 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 5 Aug 2016 00:23:42 +0200 Subject: [PATCH 04/26] Add E0254 error explanation --- src/librustc_resolve/diagnostics.rs | 40 ++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 3e860150a35fd..af830d9207495 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -153,6 +153,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 +1276,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 From 8641bc267cad2e86f3c73060cc12be6f754207e2 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Thu, 4 Aug 2016 23:22:46 -0500 Subject: [PATCH 05/26] Updated E0081 to new format --- src/librustc_typeck/check/mod.rs | 5 +++-- src/test/compile-fail/issue-15524.rs | 15 +++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 6062bd048b3d2..3e715d14bc050 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1251,8 +1251,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); diff --git a/src/test/compile-fail/issue-15524.rs b/src/test/compile-fail/issue-15524.rs index bdf344dcdfe8d..867dafb5ea751 100644 --- a/src/test/compile-fail/issue-15524.rs +++ b/src/test/compile-fail/issue-15524.rs @@ -12,13 +12,16 @@ const N: isize = 1; enum Foo { A = 1, - B = 1, //~ ERROR discriminant value `1isize` already exists - //~^^ NOTE conflicting + B = 1, //~ ERROR discriminant value + //~^ NOTE enum already + //~^^^ NOTE first use 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 + //~^^^^^^^ NOTE first use + E = N, //~ ERROR discriminant value + //~^ NOTE enum already + //~^^^^^^^^^^ NOTE first use } fn main() {} From c61cfb09829d365a4f5298213fb8b523d7abfbd2 Mon Sep 17 00:00:00 2001 From: Dominik Boehi Date: Fri, 5 Aug 2016 06:30:41 +0200 Subject: [PATCH 06/26] Update E0106 error message to new format. This fixes rust/rust-lang#35245 --- src/librustc_typeck/astconv.rs | 8 ++++++-- src/test/compile-fail/E0106.rs | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 3b2bca4ab3912..5550287c2933c 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); } 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() { } From 764d5cfafb30acbe3fdb45b6c98b4e694a303558 Mon Sep 17 00:00:00 2001 From: kc1212 Date: Fri, 5 Aug 2016 22:52:57 +1200 Subject: [PATCH 07/26] Update E0379 to new format #35338 --- src/librustc_typeck/check/mod.rs | 4 +++- src/test/compile-fail/const-fn-mismatch.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 6062bd048b3d2..8eafcbc83a248 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() } } } 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() { } From 4c672e07b996b79dae2ff7cf20cdbd35a6f8233d Mon Sep 17 00:00:00 2001 From: trixnz Date: Fri, 5 Aug 2016 12:58:43 +0200 Subject: [PATCH 08/26] Fixed no-pattern-in-args test for new E0130 format --- src/test/compile-fail/no-patterns-in-args.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 From 7cd1779c314e85d8cd8b5512e47f34cdcf3c7b63 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 5 Aug 2016 13:17:39 +0200 Subject: [PATCH 09/26] Add new error code tests --- src/librustc_passes/diagnostics.rs | 8 ++++---- src/librustc_resolve/diagnostics.rs | 1 + src/test/compile-fail/E0253.rs | 19 +++++++++++++++++++ src/test/compile-fail/E0254.rs | 21 +++++++++++++++++++++ src/test/compile-fail/E0255.rs | 19 +++++++++++++++++++ src/test/compile-fail/E0259.rs | 14 ++++++++++++++ src/test/compile-fail/E0260.rs | 19 +++++++++++++++++++ src/test/compile-fail/E0261.rs | 17 +++++++++++++++++ src/test/compile-fail/E0262.rs | 13 +++++++++++++ src/test/compile-fail/E0263.rs | 13 +++++++++++++ src/test/compile-fail/E0264.rs | 18 ++++++++++++++++++ src/test/compile-fail/E0267.rs | 13 +++++++++++++ src/test/compile-fail/E0268.rs | 13 +++++++++++++ 13 files changed, 184 insertions(+), 4 deletions(-) create mode 100644 src/test/compile-fail/E0253.rs create mode 100644 src/test/compile-fail/E0254.rs create mode 100644 src/test/compile-fail/E0255.rs create mode 100644 src/test/compile-fail/E0259.rs create mode 100644 src/test/compile-fail/E0260.rs create mode 100644 src/test/compile-fail/E0261.rs create mode 100644 src/test/compile-fail/E0262.rs create mode 100644 src/test/compile-fail/E0263.rs create mode 100644 src/test/compile-fail/E0264.rs create mode 100644 src/test/compile-fail/E0267.rs create mode 100644 src/test/compile-fail/E0268.rs 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 af830d9207495..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() {} ``` 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 +} From bc258791eb4cc5802c261afc2b923b2875c0736d Mon Sep 17 00:00:00 2001 From: Shantanu Raj Date: Fri, 5 Aug 2016 17:14:47 +0530 Subject: [PATCH 10/26] Update E0207 to use struct_span_err, add span_label --- src/librustc_typeck/collect.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 4486748a1f056..dfffe3a4a905c 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2314,8 +2314,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(); + } From eaa2697be2135ba883b2dd6e13abd325628fc2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Medzi=C5=84ski?= Date: Fri, 5 Aug 2016 14:29:09 +0200 Subject: [PATCH 11/26] Updated error message E0282 --- src/librustc/traits/error_reporting.rs | 11 +++++++---- src/test/compile-fail/issue-23041.rs | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 67ad887530eb3..9f6e9ee3f005e 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -870,10 +870,13 @@ 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 `{}`; \ + type annotations or generic parameter binding required", + ty); + err.note("type annotations or generic parameter binding required"); + err.span_label(span, &format!("cannot infer type about `{}`", ty)); + err.emit() } fn note_obligation_cause(&self, diff --git a/src/test/compile-fail/issue-23041.rs b/src/test/compile-fail/issue-23041.rs index 1a9bb4c29f3e0..0dffd0fbee5ea 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 about `_` + //~| NOTE type annotations or generic parameter binding required } From 5eebb92c2fd62c2f20aa6c67d7f58f37ec521586 Mon Sep 17 00:00:00 2001 From: Roy Brunton Date: Fri, 5 Aug 2016 15:06:36 +0100 Subject: [PATCH 12/26] Update error message for E0166 --- src/librustc_typeck/check/mod.rs | 6 ++++-- src/test/compile-fail/E0166.rs | 4 +++- src/test/compile-fail/bad-bang-ann-3.rs | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 6062bd048b3d2..8817c6f8d1eda 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3392,8 +3392,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/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/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); } From b7468fa1896e4fc4bec0bea4fecc241ab8295129 Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Fri, 5 Aug 2016 16:54:05 +0200 Subject: [PATCH 13/26] Updated E0306 to new format. --- src/librustc_const_eval/eval.rs | 11 ++++--- src/test/compile-fail/E0306.rs | 14 +++++++-- .../compile-fail/const-integer-bool-ops.rs | 30 +++++++++++++++---- src/test/compile-fail/issue-27008.rs | 3 +- src/test/compile-fail/repeat_count.rs | 15 ++++++---- 5 files changed, 54 insertions(+), 19 deletions(-) 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/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/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/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/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` } From 40b7ace386144d584faa9d7eca27ffdc35ceb6b8 Mon Sep 17 00:00:00 2001 From: Matthias Rabault Date: Fri, 5 Aug 2016 17:43:44 +0200 Subject: [PATCH 14/26] Update E0229 to new format --- src/librustc/middle/astconv_util.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc/middle/astconv_util.rs b/src/librustc/middle/astconv_util.rs index e856eb84ff2c3..911f08fc1b31f 100644 --- a/src/librustc/middle/astconv_util.rs +++ b/src/librustc/middle/astconv_util.rs @@ -42,8 +42,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, From 2f5294e1d6ec900f1d650879954016146e5df748 Mon Sep 17 00:00:00 2001 From: Mikhail Modin Date: Fri, 5 Aug 2016 18:57:37 +0300 Subject: [PATCH 15/26] Fixes #35304 --- src/librustc_typeck/collect.rs | 7 ++++--- src/test/compile-fail/impl-duplicate-methods.rs | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index ec95afe15bd51..6429faf35ff80 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -772,9 +772,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) => { 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() {} From 3575812e449e8a174b67023ee0879f573f8a6d1f Mon Sep 17 00:00:00 2001 From: Omer Sheikh Date: Fri, 5 Aug 2016 20:54:04 +0500 Subject: [PATCH 16/26] Update E0107 message to new format --- src/librustc_typeck/astconv.rs | 22 +++++++++++++++++++--- src/test/compile-fail/E0107.rs | 8 ++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 3b2bca4ab3912..e3f4f82b0ef6d 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -2266,9 +2266,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/test/compile-fail/E0107.rs b/src/test/compile-fail/E0107.rs index d27b70865bbfb..6a5456c010953 100644 --- a/src/test/compile-fail/E0107.rs +++ b/src/test/compile-fail/E0107.rs @@ -17,8 +17,12 @@ enum Bar { } struct Baz<'a> { - foo: Foo, //~ ERROR E0107 - bar: Bar<'a>, //~ ERROR E0107 + foo: Foo, + //~^ ERROR E0107 + //~| expected 1 lifetime parameter + bar: Bar<'a>, + //~^ ERROR E0107 + //~| unexpected lifetime parameter } fn main() { From 00179a75c735a405fa0382b1ea3bb77eb7d1f0f8 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Fri, 5 Aug 2016 12:05:29 -0500 Subject: [PATCH 17/26] Updated style of unit test --- src/test/compile-fail/issue-15524.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/compile-fail/issue-15524.rs b/src/test/compile-fail/issue-15524.rs index 867dafb5ea751..3d6f224c24904 100644 --- a/src/test/compile-fail/issue-15524.rs +++ b/src/test/compile-fail/issue-15524.rs @@ -12,16 +12,18 @@ const N: isize = 1; enum Foo { A = 1, + //~^ NOTE first use + //~| NOTE first use + //~| NOTE first use B = 1, //~ ERROR discriminant value //~^ NOTE enum already - //~^^^ NOTE first use C = 0, D, //~ ERROR discriminant value //~^ NOTE enum already - //~^^^^^^^ NOTE first use + E = N, //~ ERROR discriminant value //~^ NOTE enum already - //~^^^^^^^^^^ NOTE first use + } fn main() {} From 7eca647e5ae5bef69999c41216e7a8508758d67a Mon Sep 17 00:00:00 2001 From: trixnz Date: Fri, 5 Aug 2016 19:53:14 +0200 Subject: [PATCH 18/26] Update error format for E0373 --- src/librustc_borrowck/borrowck/mod.rs | 5 ++- .../borrowck-escaping-closure-error-1.rs | 2 + .../borrowck-escaping-closure-error-2.rs | 2 + src/test/compile-fail/issue-4335.rs | 5 ++- .../region-borrow-params-issue-29793-small.rs | 40 +++++++++++++++++++ src/test/compile-fail/regions-nested-fns-2.rs | 5 ++- 6 files changed, 56 insertions(+), 3 deletions(-) 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/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/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/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 }); } From 2061d656e5ba2225a58e1073c9a0a22eef4f0ece Mon Sep 17 00:00:00 2001 From: Omer Sheikh Date: Fri, 5 Aug 2016 22:56:10 +0500 Subject: [PATCH 19/26] Add E0107 tests for multiple lifetime params --- src/test/compile-fail/E0107.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/test/compile-fail/E0107.rs b/src/test/compile-fail/E0107.rs index 6a5456c010953..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,13 +17,19 @@ enum Bar { C, } -struct Baz<'a> { +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() { From 802b5431b197189110a291d14ad1e323fec39877 Mon Sep 17 00:00:00 2001 From: trixnz Date: Fri, 5 Aug 2016 20:05:57 +0200 Subject: [PATCH 20/26] Update error format for E0326 --- src/librustc_typeck/check/compare_method.rs | 24 ++++++++++++++++++- .../associated-const-impl-wrong-type.rs | 4 ++-- 2 files changed, 25 insertions(+), 3 deletions(-) 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/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() {} From 51a270f5e7a1911118bb177b6d53dbba621748b8 Mon Sep 17 00:00:00 2001 From: Matthias Rabault Date: Fri, 5 Aug 2016 20:11:26 +0200 Subject: [PATCH 21/26] Fix E0229 unit tests --- src/test/compile-fail/E0229.rs | 4 +++- src/test/compile-fail/issue-23543.rs | 1 + src/test/compile-fail/issue-23544.rs | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) 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/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() {} From 291b6f16bb03c92fb383dfa12b8849808bace801 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Mon, 18 Jul 2016 14:31:26 +0200 Subject: [PATCH 22/26] Comment on the casts in the `seek` implementations on files --- src/libstd/sys/unix/fs.rs | 10 ++++++---- src/libstd/sys/windows/fs.rs | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) 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), From 58b618e5270a1bef26ad1ed95820c22e09b24ec5 Mon Sep 17 00:00:00 2001 From: Shantanu Raj Date: Sat, 6 Aug 2016 00:04:27 +0530 Subject: [PATCH 23/26] Update unit tests to accord for label in E0207 --- src/test/compile-fail/E0207.rs | 1 + src/test/compile-fail/impl-unused-rps-in-assoc-type.rs | 1 + src/test/compile-fail/issue-22886.rs | 1 + src/test/compile-fail/issue-35139.rs | 1 + 4 files changed, 4 insertions(+) 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/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/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-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; } From 422e0d590f2c2879325e00f989d37e8603652c9f Mon Sep 17 00:00:00 2001 From: TheZoq2 Date: Fri, 5 Aug 2016 21:00:23 +0200 Subject: [PATCH 24/26] Update E0004 to use labels --- src/librustc_const_eval/check_match.rs | 9 +++++++-- src/test/compile-fail/non-exhaustive-pattern-witness.rs | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index d3952de2fbe30..07e0cece469a3 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -423,10 +423,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/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) => () } } From e0035c9797bf1fa5c2f87935e4ba7d362888d299 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Fri, 5 Aug 2016 16:27:40 +0100 Subject: [PATCH 25/26] Update error message for E0323, E0324 and E0325 --- src/librustc_typeck/check/mod.rs | 31 ++++++++++++++----- .../compile-fail/impl-wrong-item-for-trait.rs | 7 ++++- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 6062bd048b3d2..f384ae2b88e1d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -993,7 +993,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 +1014,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 +1044,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 +1067,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() } } } 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; } From ff96b561fbde8f2d431e6d5c9644f74ece280588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Medzi=C5=84ski?= Date: Fri, 5 Aug 2016 23:16:54 +0200 Subject: [PATCH 26/26] Updated E0282 to new requirements --- src/librustc/traits/error_reporting.rs | 5 ++--- src/test/compile-fail/issue-23041.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 9f6e9ee3f005e..9950560b13a5a 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -871,11 +871,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn need_type_info(&self, span: Span, ty: Ty<'tcx>) { let mut err = struct_span_err!(self.tcx.sess, span, E0282, - "unable to infer enough type information about `{}`; \ - type annotations or generic parameter binding required", + "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 about `{}`", ty)); + err.span_label(span, &format!("cannot infer type for `{}`", ty)); err.emit() } diff --git a/src/test/compile-fail/issue-23041.rs b/src/test/compile-fail/issue-23041.rs index 0dffd0fbee5ea..1be082ba9bbba 100644 --- a/src/test/compile-fail/issue-23041.rs +++ b/src/test/compile-fail/issue-23041.rs @@ -14,6 +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 about `_` + //~| NOTE cannot infer type for `_` //~| NOTE type annotations or generic parameter binding required }