From 65249a5431bbc3bf6b0f0894aefcc28c76eb17bb Mon Sep 17 00:00:00 2001 From: Gavin Baker Date: Sun, 28 Aug 2016 22:55:39 +1000 Subject: [PATCH 1/9] E0459 Update error format #35933 - Fixes #35933 - Part of #35233 r? @jonathandturner --- src/librustc_metadata/creader.rs | 5 +++-- src/test/compile-fail/E0459.rs | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 46469efea6bc8..b84c3e8a5bc25 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -977,8 +977,9 @@ impl<'a> LocalCrateReader<'a> { let n = match n { Some(n) => n, None => { - span_err!(self.sess, m.span, E0459, - "#[link(...)] specified without `name = \"foo\"`"); + struct_span_err!(self.sess, m.span, E0459, + "#[link(...)] specified without `name = \"foo\"`") + .span_label(m.span, &format!("missing `name` argument")).emit(); InternedString::new("foo") } }; diff --git a/src/test/compile-fail/E0459.rs b/src/test/compile-fail/E0459.rs index dc7ac714f2239..41376bd9ef5a2 100644 --- a/src/test/compile-fail/E0459.rs +++ b/src/test/compile-fail/E0459.rs @@ -9,6 +9,7 @@ // except according to those terms. #[link(kind = "dylib")] extern {} //~ ERROR E0459 + //~| NOTE missing `name` argument fn main() { } From 0412fa8b8e00bebc2bb0ad17a7e558f13b8954a7 Mon Sep 17 00:00:00 2001 From: Gavin Baker Date: Sun, 28 Aug 2016 23:55:43 +1000 Subject: [PATCH 2/9] E0458 Update error format #35932 - Fixes #35932 - Part of #35233 r? @jonathandturner --- src/librustc_metadata/creader.rs | 5 +++-- src/test/compile-fail/E0458.rs | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index b84c3e8a5bc25..8f4e9f941c600 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -965,8 +965,9 @@ impl<'a> LocalCrateReader<'a> { Some("dylib") => cstore::NativeUnknown, Some("framework") => cstore::NativeFramework, Some(k) => { - span_err!(self.sess, m.span, E0458, - "unknown kind: `{}`", k); + struct_span_err!(self.sess, m.span, E0458, + "unknown kind: `{}`", k) + .span_label(m.span, &format!("unknown kind")).emit(); cstore::NativeUnknown } None => cstore::NativeUnknown diff --git a/src/test/compile-fail/E0458.rs b/src/test/compile-fail/E0458.rs index 21bedc6b84c2b..e87158ae3b03f 100644 --- a/src/test/compile-fail/E0458.rs +++ b/src/test/compile-fail/E0458.rs @@ -9,7 +9,9 @@ // except according to those terms. #[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458 - //~^ ERROR E0459 + //~| NOTE unknown kind + //~| ERROR E0459 + //~| NOTE missing `name` argument fn main() { } From 638b7c89e6c3de5c21cf10ea28b8b8ea259b5f27 Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Sun, 28 Aug 2016 12:51:00 +0200 Subject: [PATCH 3/9] Updated E0493 to new format. --- src/librustc_mir/transform/qualify_consts.rs | 4 ++++ src/test/compile-fail/E0493.rs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 9e076851bc37d..a6f6faf246969 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -252,11 +252,15 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { let mut err = struct_span_err!(self.tcx.sess, self.span, E0493, "{}", msg); + if self.mode != Mode::Const { help!(&mut err, "in Nightly builds, add `#![feature(drop_types_in_const)]` \ to the crate attributes to enable"); + } else { + err.span_label(self.span, &format!("constants cannot have destructors")); } + err.emit(); } diff --git a/src/test/compile-fail/E0493.rs b/src/test/compile-fail/E0493.rs index 689f469533d96..d5b29a628f0bd 100644 --- a/src/test/compile-fail/E0493.rs +++ b/src/test/compile-fail/E0493.rs @@ -16,7 +16,9 @@ impl Drop for Foo { fn drop(&mut self) {} } -const F : Foo = Foo { a : 0 }; //~ ERROR E0493 +const F : Foo = Foo { a : 0 }; +//~^ ERROR constants are not allowed to have destructors [E0493] +//~| NOTE constants cannot have destructors fn main() { } From ed5e5df596aff90b4147869e3464330f7833f81e Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Fri, 2 Sep 2016 11:44:46 +0200 Subject: [PATCH 4/9] E0493: showing a label where the destructor is defined. --- src/librustc_mir/transform/qualify_consts.rs | 29 ++++++++++++++++++++ src/test/compile-fail/E0493.rs | 9 ++++++ 2 files changed, 38 insertions(+) diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index a6f6faf246969..14a432cbb895b 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -18,6 +18,7 @@ use rustc_data_structures::bitvec::BitVector; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; use rustc::dep_graph::DepNode; use rustc::hir; +use rustc::hir::map as hir_map; use rustc::hir::def_id::DefId; use rustc::hir::intravisit::FnKind; use rustc::hir::map::blocks::FnLikeNode; @@ -258,12 +259,40 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { "in Nightly builds, add `#![feature(drop_types_in_const)]` \ to the crate attributes to enable"); } else { + self.find_drop_implementation_method_span() + .map(|span| err.span_label(span, &format!("destructor defined here"))); + err.span_label(self.span, &format!("constants cannot have destructors")); } err.emit(); } + fn find_drop_implementation_method_span(&self) -> Option { + self.tcx.lang_items + .drop_trait() + .and_then(|drop_trait_id| { + let mut span = None; + + self.tcx + .lookup_trait_def(drop_trait_id) + .for_each_relevant_impl(self.tcx, self.mir.return_ty, |impl_did| { + self.tcx.map + .as_local_node_id(impl_did) + .and_then(|impl_node_id| self.tcx.map.find(impl_node_id)) + .map(|node| { + if let hir_map::NodeItem(item) = node { + if let hir::ItemImpl(_, _, _, _, _, ref methods) = item.node { + span = methods.first().map(|method| method.span); + } + } + }); + }); + + span + }) + } + /// Check if an Lvalue with the current qualifications could /// be consumed, by either an operand or a Deref projection. fn try_consume(&mut self) -> bool { diff --git a/src/test/compile-fail/E0493.rs b/src/test/compile-fail/E0493.rs index d5b29a628f0bd..e06da5ca7c55c 100644 --- a/src/test/compile-fail/E0493.rs +++ b/src/test/compile-fail/E0493.rs @@ -14,6 +14,15 @@ struct Foo { impl Drop for Foo { fn drop(&mut self) {} + //~^ NOTE destructor defined here +} + +struct Bar { + a: u32 +} + +impl Drop for Bar { + fn drop(&mut self) {} } const F : Foo = Foo { a : 0 }; From 059094f3f264a683e624ae57b475264b5ce8511c Mon Sep 17 00:00:00 2001 From: Federico Ravasio Date: Fri, 2 Sep 2016 19:55:14 +0200 Subject: [PATCH 5/9] Moved test on E0493 from compile-fail to ui. --- src/test/{compile-fail => ui/span}/E0493.rs | 3 --- src/test/ui/span/E0493.stderr | 11 +++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) rename src/test/{compile-fail => ui/span}/E0493.rs (81%) create mode 100644 src/test/ui/span/E0493.stderr diff --git a/src/test/compile-fail/E0493.rs b/src/test/ui/span/E0493.rs similarity index 81% rename from src/test/compile-fail/E0493.rs rename to src/test/ui/span/E0493.rs index e06da5ca7c55c..ea4526b70f6a8 100644 --- a/src/test/compile-fail/E0493.rs +++ b/src/test/ui/span/E0493.rs @@ -14,7 +14,6 @@ struct Foo { impl Drop for Foo { fn drop(&mut self) {} - //~^ NOTE destructor defined here } struct Bar { @@ -26,8 +25,6 @@ impl Drop for Bar { } const F : Foo = Foo { a : 0 }; -//~^ ERROR constants are not allowed to have destructors [E0493] -//~| NOTE constants cannot have destructors fn main() { } diff --git a/src/test/ui/span/E0493.stderr b/src/test/ui/span/E0493.stderr new file mode 100644 index 0000000000000..afcc9a240eb4e --- /dev/null +++ b/src/test/ui/span/E0493.stderr @@ -0,0 +1,11 @@ +error[E0493]: constants are not allowed to have destructors + --> $DIR/E0493.rs:27:17 + | +16 | fn drop(&mut self) {} + | --------------------- destructor defined here +... +27 | const F : Foo = Foo { a : 0 }; + | ^^^^^^^^^^^^^ constants cannot have destructors + +error: aborting due to previous error + From eb1c7161dd79b55e022cd0c661f9018d406b3fe4 Mon Sep 17 00:00:00 2001 From: johnthagen Date: Fri, 2 Sep 2016 15:32:13 -0400 Subject: [PATCH 6/9] Update supported Windows versions to match Getting Started page. --- src/doc/book/nightly-rust.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/nightly-rust.md b/src/doc/book/nightly-rust.md index b3be71038a992..25570cb5503c9 100644 --- a/src/doc/book/nightly-rust.md +++ b/src/doc/book/nightly-rust.md @@ -54,7 +54,7 @@ binary downloads][install-page]. Oh, we should also mention the officially supported platforms: -* Windows (7, 8, Server 2008 R2) +* Windows (7+) * Linux (2.6.18 or later, various distributions), x86 and x86-64 * OSX 10.7 (Lion) or greater, x86 and x86-64 From 63520c1089f37762d6a3d357fc4d750a0475980a Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Fri, 2 Sep 2016 19:54:02 -0400 Subject: [PATCH 7/9] indicate where to copy config.toml.example --- src/bootstrap/config.toml.example | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index 2894adafef622..9e8910669a064 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -1,5 +1,7 @@ # Sample TOML configuration file for building Rust. # +# To configure rustbuild, copy this file to ../config.toml. +# # All options are commented out by default in this file, and they're commented # out with their default values. The build system by default looks for # `config.toml` in the current directory of a build for build configuration, but From a34485ff1925e81702bbb46bf2a5634fa008672b Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Sat, 3 Sep 2016 02:02:03 -0400 Subject: [PATCH 8/9] change wording --- src/bootstrap/config.toml.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index 9e8910669a064..20c91960e9ea5 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -1,6 +1,7 @@ # Sample TOML configuration file for building Rust. # -# To configure rustbuild, copy this file to ../config.toml. +# To configure rustbuild, copy this file to the directory from which you will be +# running the build, and name it config.toml. # # All options are commented out by default in this file, and they're commented # out with their default values. The build system by default looks for From 0efc4bf387f962f7ba56a9bc0179fcc72701f53c Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Sat, 3 Sep 2016 01:29:12 +0000 Subject: [PATCH 9/9] rustbuild: add config.toml option to disable codegen tests --- src/bootstrap/config.rs | 2 ++ src/bootstrap/config.toml.example | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 682a6f74126a8..c1af7bd794cbf 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -144,6 +144,7 @@ struct Rust { rpath: Option, optimize_tests: Option, debuginfo_tests: Option, + codegen_tests: Option, } /// TOML representation of how each build target is configured. @@ -232,6 +233,7 @@ impl Config { set(&mut config.rust_optimize, rust.optimize); set(&mut config.rust_optimize_tests, rust.optimize_tests); set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests); + set(&mut config.codegen_tests, rust.codegen_tests); set(&mut config.rust_rpath, rust.rpath); set(&mut config.debug_jemalloc, rust.debug_jemalloc); set(&mut config.use_jemalloc, rust.use_jemalloc); diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index 2894adafef622..ef24a948664f0 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -130,6 +130,10 @@ #optimize-tests = true #debuginfo-tests = true +# Flag indicating whether codegen tests will be run or not. If you get an error +# saying that the FileCheck executable is missing, you may want to disable this. +#codegen-tests = true + # ============================================================================= # Options for specific targets #