From 7efeade2685232ed01f65b69e6d8ad710eceb351 Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Sun, 30 Jul 2017 23:22:09 -0700 Subject: [PATCH 1/3] de-orphan extended information Bizarrely, librustc_passes, librustc_plugin, librustc_mir, and libsyntax weren't getting their error explanations registered. Resolves #35284. --- src/librustc_driver/lib.rs | 4 ++++ src/librustc_mir/lib.rs | 2 ++ src/librustc_passes/lib.rs | 2 ++ src/librustc_plugin/lib.rs | 2 ++ src/libsyntax/lib.rs | 2 +- 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index d6b1eb86937b0..4c337993468e6 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1207,6 +1207,10 @@ pub fn diagnostics_registry() -> errors::registry::Registry { all_errors.extend_from_slice(&rustc_trans::DIAGNOSTICS); all_errors.extend_from_slice(&rustc_const_eval::DIAGNOSTICS); all_errors.extend_from_slice(&rustc_metadata::DIAGNOSTICS); + all_errors.extend_from_slice(&rustc_passes::DIAGNOSTICS); + all_errors.extend_from_slice(&rustc_plugin::DIAGNOSTICS); + all_errors.extend_from_slice(&rustc_mir::DIAGNOSTICS); + all_errors.extend_from_slice(&syntax::DIAGNOSTICS); Registry::new(&all_errors) } diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 912c2043390f4..ea8624930e5f5 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -57,3 +57,5 @@ pub fn provide(providers: &mut Providers) { shim::provide(providers); transform::provide(providers); } + +__build_diagnostic_array! { librustc_mir, DIAGNOSTICS } diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 3949152e84896..ed5ea69d04ea3 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -45,3 +45,5 @@ pub mod loops; pub mod mir_stats; pub mod no_asm; pub mod static_recursion; + +__build_diagnostic_array! { librustc_passes, DIAGNOSTICS } diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 1de31c5d79154..e17a3c82b5020 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -84,3 +84,5 @@ pub mod diagnostics; pub mod registry; pub mod load; pub mod build; + +__build_diagnostic_array! { librustc_plugin, DIAGNOSTICS } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index a8338fccb6b10..43345b02bf614 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -148,4 +148,4 @@ pub mod ext { #[cfg(test)] mod test_snippet; -// __build_diagnostic_array! { libsyntax, DIAGNOSTICS } +__build_diagnostic_array! { libsyntax, DIAGNOSTICS } From 86b7546204c4220e40ccc3b1631ad407c1357911 Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Sun, 6 Aug 2017 21:36:06 -0700 Subject: [PATCH 2/3] fixing doctest failures in resurfaced extended information After repatriating error explanations to the global registry, some lurking doctest failures surfaced and needed to be chased down. Sadly, a few doctests needed to be ignored due to a not-yet-understood regression in the doctest `compile_fail` functionality (filed #43707). --- src/librustc_mir/diagnostics.rs | 14 ++++++++++--- src/librustc_passes/diagnostics.rs | 2 +- src/libsyntax/diagnostic_list.rs | 32 ++++++++++++++++++++---------- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/librustc_mir/diagnostics.rs b/src/librustc_mir/diagnostics.rs index 6f3db0b388def..6530b356e33f4 100644 --- a/src/librustc_mir/diagnostics.rs +++ b/src/librustc_mir/diagnostics.rs @@ -122,10 +122,8 @@ On the other hand, static and constant pointers can point either to a known numeric address or to the address of a symbol. ``` +static MY_STATIC: u32 = 42; static MY_STATIC_ADDR: &'static u32 = &MY_STATIC; -// ... and also -static MY_STATIC_ADDR2: *const u32 = &MY_STATIC; - const CONST_ADDR: *const u8 = 0x5f3759df as *const u8; ``` @@ -160,6 +158,16 @@ Remember: you can't use a function call inside a const's initialization expression! However, you can totally use it anywhere else: ``` +enum Test { + V1 +} + +impl Test { + fn func(&self) -> i32 { + 12 + } +} + fn main() { const FOO: Test = Test::V1; diff --git a/src/librustc_passes/diagnostics.rs b/src/librustc_passes/diagnostics.rs index 464dd72e56986..907a258a12dc6 100644 --- a/src/librustc_passes/diagnostics.rs +++ b/src/librustc_passes/diagnostics.rs @@ -221,7 +221,7 @@ while break {} To fix this, add a label specifying which loop is being broken out of: ``` -`foo: while break `foo {} +'foo: while break 'foo {} ``` "## } diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index 508feca9731f2..6598ecb94448b 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -42,7 +42,7 @@ The `inline` attribute was malformed. Erroneous code example: -```compile_fail,E0534 +```ignore (compile_fail not working here; see Issue #43707) #[inline()] // error: expected one argument pub fn something() {} @@ -80,7 +80,7 @@ An unknown argument was given to the `inline` attribute. Erroneous code example: -```compile_fail,E0535 +```ignore (compile_fail not working here; see Issue #43707) #[inline(unknown)] // error: invalid argument pub fn something() {} @@ -190,7 +190,9 @@ A literal was used in an attribute that doesn't support literals. Erroneous code example: -```compile_fail,E0565 +```ignore (compile_fail not working here; see Issue #43707) +#![feature(attr_literals)] + #[inline("always")] // error: unsupported literal pub fn something() {} ``` @@ -209,7 +211,7 @@ A file wasn't found for an out-of-line module. Erroneous code example: -```compile_fail,E0583 +```ignore (compile_fail not working here; see Issue #43707) mod file_that_doesnt_exist; // error: file not found for module fn main() {} @@ -251,23 +253,33 @@ An inclusive range was used with no end. Erroneous code example: ```compile_fail,E0586 -let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; -let x = &tmp[1...]; // error: inclusive range was used with no end +#![feature(inclusive_range_syntax)] + +fn main() { + let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; + let x = &tmp[1...]; // error: inclusive range was used with no end +} ``` An inclusive range needs an end in order to *include* it. If you just need a start and no end, use a non-inclusive range (with `..`): ``` -let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; -let x = &tmp[1..]; // ok! +fn main() { + let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; + let x = &tmp[1..]; // ok! +} ``` Or put an end to your inclusive range: ``` -let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; -let x = &tmp[1...3]; // ok! +#![feature(inclusive_range_syntax)] + +fn main() { + let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1]; + let x = &tmp[1...3]; // ok! +} ``` "##, From 75b7a6f1a662dab0752d189ab635580a21b06e42 Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Sun, 6 Aug 2017 21:50:41 -0700 Subject: [PATCH 3/3] comment out record of now-unused error code E0563 The sole appearance of this code was deleted in 6383de15; the existing practice in these cases seems to be to comment out its mention in `register_diagnostics!`. --- src/librustc_typeck/diagnostics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 3037e8d4a1602..1323997315e78 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4709,7 +4709,7 @@ register_diagnostics! { // between structures with the same definition E0521, // redundant default implementations of trait E0533, // `{}` does not name a unit variant, unit struct or a constant - E0563, // cannot determine a type for this `impl Trait`: {} +// E0563, // cannot determine a type for this `impl Trait`: {} // removed in 6383de15 E0564, // only named lifetimes are allowed in `impl Trait`, // but `{}` was found in the type `{}` E0567, // auto traits can not have type parameters