diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 9e076851bc3..a6f6faf2469 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 689f469533d..d5b29a628f0 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() { }