From 028c7963631433b59df3b8c138cd6c966ed26a76 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Jul 2016 16:24:19 +0200 Subject: [PATCH 1/8] Add E0533 error explanation --- src/libsyntax/diagnostic_list.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index eb30657bd56ea..3000d639fd648 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -1,4 +1,4 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -16,8 +16,22 @@ register_long_diagnostics! { E0533: r##" +The export_name attribute was badly formatted. + +Erroneous code example: + ```compile_fail,E0533 -#[export_name] +#[export_name] // error: export_name attribute has invalid format +pub fn something() {} + +fn main() {} +``` + +The export_name attribute expects a string in order to determine the name of +the exported symbol. Example: + +``` +#[export_name = "some function"] // ok! pub fn something() {} fn main() {} From 38a0177917c75d9291d8aed1f61f807de6f17d92 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Jul 2016 16:34:47 +0200 Subject: [PATCH 2/8] Add E0534 error explanation --- src/libsyntax/attr.rs | 2 +- src/libsyntax/diagnostic_list.rs | 35 +++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index e01bd2a93aacd..a4a8655ce37d8 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -373,7 +373,7 @@ pub fn find_inline_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> In InlineAttr::None } } - _ => ia + _ => ia, } }) } diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index 3000d639fd648..c823d03015789 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -38,10 +38,43 @@ fn main() {} ``` "##, +E0534: r##" +The inline attribute was badly used. + +Erroneous code example: + +```compile_fail,E0534 +#[inline()] // error: expected one argument +pub fn something() {} + +fn main() {} +``` + +The inline attribute can be used without arguments: + +``` +#[inline] // ok! +pub fn something() {} + +fn main() {} +``` + +Or with arguments (and parens have to be used for this case!): + +``` +#[inline(always)] // ok! +pub fn something() {} + +fn main() {} +``` + +For more information about the inline attribute, take a look here: +https://doc.rust-lang.org/reference.html#inline-attributes) +"##, + } register_diagnostics! { - E0534, // expected one argument E0535, // invalid argument E0536, // expected 1 cfg-pattern E0537, // invalid predicate From 9fe31a1b36b22582ffd589842c5c3f49ae1ac56d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Jul 2016 16:47:30 +0200 Subject: [PATCH 3/8] Add E0535 error explanation --- src/libsyntax/diagnostic_list.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index c823d03015789..beaf4ab5cdd07 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -72,10 +72,40 @@ For more information about the inline attribute, take a look here: https://doc.rust-lang.org/reference.html#inline-attributes) "##, +E0535: r##" +An unknown argument was given to inline attribute. + +Erroneous code example: + +```compile_fail,E0535 +#[inline(unknown)] // error: invalid argument +pub fn something() {} + +fn main() {} +``` + +The inline attribute only knows two arguments: + + * always + * never + +All other arguments given to the inline attribute will return this error. +Example: + +``` +#[inline(never)] // ok! +pub fn something() {} + +fn main() {} +``` + +For more information about the inline attribute, take a look here: +https://doc.rust-lang.org/reference.html#inline-attributes) +"##, + } register_diagnostics! { - E0535, // invalid argument E0536, // expected 1 cfg-pattern E0537, // invalid predicate E0538, // multiple [same] items From ebebb3164a0872016d68ff2b7a0fd73bab3ea465 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Jul 2016 16:53:17 +0200 Subject: [PATCH 4/8] Add E0536 error explanation --- src/libsyntax/diagnostic_list.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index beaf4ab5cdd07..dfec5a43cdeed 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -69,7 +69,7 @@ fn main() {} ``` For more information about the inline attribute, take a look here: -https://doc.rust-lang.org/reference.html#inline-attributes) +https://doc.rust-lang.org/reference.html#inline-attributes "##, E0535: r##" @@ -100,13 +100,37 @@ fn main() {} ``` For more information about the inline attribute, take a look here: -https://doc.rust-lang.org/reference.html#inline-attributes) +https://doc.rust-lang.org/reference.html#inline-attributes +"##, + +E0536: r##" +No cfg-pattern was found for `not` statement. + +Erroneous code example: + +```compile_fail,E0536 +#[cfg(not())] // error: expected 1 cfg-pattern +pub fn something() {} + +pub fn main() {} +``` + +The `not` statement expects at least one cfg-pattern. Example: + +``` +#[cfg(not(target_os = "linux"))] // ok! +pub fn something() {} + +pub fn main() {} +``` + +For more information about the cfg attribute, take a look here: +https://doc.rust-lang.org/reference.html#conditional-compilation "##, } register_diagnostics! { - E0536, // expected 1 cfg-pattern E0537, // invalid predicate E0538, // multiple [same] items E0539, // incorrect meta item From ed2bf577280e2dd4a7a18c1048d9408b30051cd6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 3 Jul 2016 16:58:43 +0200 Subject: [PATCH 5/8] Add E0537 error explanation --- src/libsyntax/diagnostic_list.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index dfec5a43cdeed..d19fd300886cd 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -128,10 +128,40 @@ For more information about the cfg attribute, take a look here: https://doc.rust-lang.org/reference.html#conditional-compilation "##, +E0537: r##" +A unknown predicate was used inside the cfg attribute. + +Erroneous code example: + +```compile_fail,E0537 +#[cfg(unknown())] // error: invalid predicate `unknown` +pub fn something() {} + +pub fn main() {} +``` + +There are only three predicates for the cfg attribute: + + * any + * all + * not + +Example: + +``` +#[cfg(not(target_os = "linux"))] // ok! +pub fn something() {} + +pub fn main() {} +``` + +For more information about the cfg attribute, take a look here: +https://doc.rust-lang.org/reference.html#conditional-compilation +"##, + } register_diagnostics! { - E0537, // invalid predicate E0538, // multiple [same] items E0539, // incorrect meta item E0540, // multiple rustc_deprecated attributes From 8dc79ecd13785c42464be7ad792c5a9fcd8ae1f4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 4 Jul 2016 00:16:53 +0200 Subject: [PATCH 6/8] Update make tidy --- src/tools/tidy/src/errors.rs | 2 +- src/tools/tidy/src/features.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/tidy/src/errors.rs b/src/tools/tidy/src/errors.rs index 41869288cc91c..3a70e54ff9745 100644 --- a/src/tools/tidy/src/errors.rs +++ b/src/tools/tidy/src/errors.rs @@ -25,7 +25,7 @@ pub fn check(path: &Path, bad: &mut bool) { &mut |path| super::filter_dirs(path) || path.ends_with("src/test"), &mut |file| { let filename = file.file_name().unwrap().to_string_lossy(); - if filename != "diagnostics.rs" { + if filename != "diagnostics.rs" && filename != "diagnostic_list.rs" { return } diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 0b989d92b3d1d..199e8a77df717 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -46,7 +46,8 @@ pub fn check(path: &Path, bad: &mut bool) { &mut |path| super::filter_dirs(path) || path.ends_with("src/test"), &mut |file| { let filename = file.file_name().unwrap().to_string_lossy(); - if !filename.ends_with(".rs") || filename == "features.rs" { + if !filename.ends_with(".rs") || filename == "features.rs" || + filename == "diagnostic_list.rs" { return } From 937f072cb4d443d44dd9ae2489d5d6fd588ec43f Mon Sep 17 00:00:00 2001 From: ggomez Date: Mon, 4 Jul 2016 14:20:45 +0200 Subject: [PATCH 7/8] Fix typos --- src/libsyntax/diagnostic_list.rs | 54 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index d19fd300886cd..260575d42e788 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -16,7 +16,7 @@ register_long_diagnostics! { E0533: r##" -The export_name attribute was badly formatted. +The `export_name` attribute was malformed. Erroneous code example: @@ -27,11 +27,11 @@ pub fn something() {} fn main() {} ``` -The export_name attribute expects a string in order to determine the name of +The `export_name` attribute expects a string in order to determine the name of the exported symbol. Example: ``` -#[export_name = "some function"] // ok! +#[export_name = "some_function"] // ok! pub fn something() {} fn main() {} @@ -39,7 +39,7 @@ fn main() {} "##, E0534: r##" -The inline attribute was badly used. +The `inline` attribute was malformed. Erroneous code example: @@ -50,30 +50,32 @@ pub fn something() {} fn main() {} ``` -The inline attribute can be used without arguments: +The parenthesized `inline` attribute requires the parameter to be specified: -``` -#[inline] // ok! -pub fn something() {} +```ignore +#[inline(always)] +fn something() {} -fn main() {} +// or: + +#[inline(never)] +fn something() {} ``` -Or with arguments (and parens have to be used for this case!): +Alternatively, a paren-less version of the attribute may be used to hint the +compiler about inlining opportunity: ``` -#[inline(always)] // ok! -pub fn something() {} - -fn main() {} +#[inline] +fn something() {} ``` -For more information about the inline attribute, take a look here: +For more information about the inline attribute, read: https://doc.rust-lang.org/reference.html#inline-attributes "##, E0535: r##" -An unknown argument was given to inline attribute. +An unknown argument was given to the `inline` attribute. Erroneous code example: @@ -84,12 +86,12 @@ pub fn something() {} fn main() {} ``` -The inline attribute only knows two arguments: +The `inline` attribute only supports two arguments: * always * never -All other arguments given to the inline attribute will return this error. +All other arguments given to the `inline` attribute will return this error. Example: ``` @@ -99,12 +101,12 @@ pub fn something() {} fn main() {} ``` -For more information about the inline attribute, take a look here: -https://doc.rust-lang.org/reference.html#inline-attributes +For more information about the inline attribute, https: +read://doc.rust-lang.org/reference.html#inline-attributes "##, E0536: r##" -No cfg-pattern was found for `not` statement. +The `not` cfg-predicate was malformed. Erroneous code example: @@ -115,7 +117,7 @@ pub fn something() {} pub fn main() {} ``` -The `not` statement expects at least one cfg-pattern. Example: +The `not` predicate expects one cfg-pattern. Example: ``` #[cfg(not(target_os = "linux"))] // ok! @@ -124,12 +126,12 @@ pub fn something() {} pub fn main() {} ``` -For more information about the cfg attribute, take a look here: +For more information about the cfg attribute, read: https://doc.rust-lang.org/reference.html#conditional-compilation "##, E0537: r##" -A unknown predicate was used inside the cfg attribute. +An unknown predicate was used inside the `cfg` attribute. Erroneous code example: @@ -140,7 +142,7 @@ pub fn something() {} pub fn main() {} ``` -There are only three predicates for the cfg attribute: +The `cfg` attribute supports only three kinds of predicates: * any * all @@ -155,7 +157,7 @@ pub fn something() {} pub fn main() {} ``` -For more information about the cfg attribute, take a look here: +For more information about the cfg attribute, read: https://doc.rust-lang.org/reference.html#conditional-compilation "##, From b777f145e6f71b3d4b9a7140bb8e039e1dd64a9a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 11 Jul 2016 23:27:27 +0200 Subject: [PATCH 8/8] Move E0533 to E0558 (because of external change) --- src/libsyntax/attr.rs | 2 +- src/libsyntax/diagnostic_list.rs | 46 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index a4a8655ce37d8..67f73d4dd4f71 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -324,7 +324,7 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option