Skip to content

Commit

Permalink
Auto merge of rust-lang#34637 - GuillaumeGomez:syntax_codes, r=jonath…
Browse files Browse the repository at this point in the history
…andturner

Syntax codes

r? @jonathandturner

cc @steveklabnik

This is a first big shot. I'll do the second one later in the week once this one is merged.
  • Loading branch information
bors authored Jul 12, 2016
2 parents 3265bd5 + b777f14 commit 2539c15
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/libsyntax/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<Inte
if let s@Some(_) = attr.value_str() {
s
} else {
struct_span_err!(diag, attr.span, E0533,
struct_span_err!(diag, attr.span, E0558,
"export_name attribute has invalid format")
.help("use #[export_name=\"*\"]")
.emit();
Expand Down Expand Up @@ -373,7 +373,7 @@ pub fn find_inline_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> In
InlineAttr::None
}
}
_ => ia
_ => ia,
}
})
}
Expand Down
149 changes: 141 additions & 8 deletions src/libsyntax/diagnostic_list.rs
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -15,9 +15,146 @@
// In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
register_long_diagnostics! {

E0533: r##"
```compile_fail,E0533
#[export_name]
E0534: r##"
The `inline` attribute was malformed.
Erroneous code example:
```compile_fail,E0534
#[inline()] // error: expected one argument
pub fn something() {}
fn main() {}
```
The parenthesized `inline` attribute requires the parameter to be specified:
```ignore
#[inline(always)]
fn something() {}
// or:
#[inline(never)]
fn something() {}
```
Alternatively, a paren-less version of the attribute may be used to hint the
compiler about inlining opportunity:
```
#[inline]
fn something() {}
```
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 the `inline` attribute.
Erroneous code example:
```compile_fail,E0535
#[inline(unknown)] // error: invalid argument
pub fn something() {}
fn main() {}
```
The `inline` attribute only supports 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, https:
read://doc.rust-lang.org/reference.html#inline-attributes
"##,

E0536: r##"
The `not` cfg-predicate was malformed.
Erroneous code example:
```compile_fail,E0536
#[cfg(not())] // error: expected 1 cfg-pattern
pub fn something() {}
pub fn main() {}
```
The `not` predicate expects one cfg-pattern. Example:
```
#[cfg(not(target_os = "linux"))] // ok!
pub fn something() {}
pub fn main() {}
```
For more information about the cfg attribute, read:
https://doc.rust-lang.org/reference.html#conditional-compilation
"##,

E0537: r##"
An 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() {}
```
The `cfg` attribute supports only three kinds of predicates:
* any
* all
* not
Example:
```
#[cfg(not(target_os = "linux"))] // ok!
pub fn something() {}
pub fn main() {}
```
For more information about the cfg attribute, read:
https://doc.rust-lang.org/reference.html#conditional-compilation
"##,

E0558: r##"
The `export_name` attribute was malformed.
Erroneous code example:
```compile_fail,E0558
#[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() {}
Expand All @@ -27,10 +164,6 @@ fn main() {}
}

register_diagnostics! {
E0534, // expected one argument
E0535, // invalid argument
E0536, // expected 1 cfg-pattern
E0537, // invalid predicate
E0538, // multiple [same] items
E0539, // incorrect meta item
E0540, // multiple rustc_deprecated attributes
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion src/tools/tidy/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 2539c15

Please sign in to comment.