diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2017-09-12 12:18:11 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2017-09-17 09:41:43 -0700 |
| commit | 8821affd1523a719ffb9f6537d53f8725ab00592 (patch) | |
| tree | 50df34d96d1c8aa101bb8a2adf417ca79c0cffb1 /src/libsyntax | |
| parent | 132bde7cf1ee102b6eb370561bf9af9cfbfb4224 (diff) | |
| download | rust-8821affd1523a719ffb9f6537d53f8725ab00592.tar.gz rust-8821affd1523a719ffb9f6537d53f8725ab00592.zip | |
rustc: Move some attr methods to queries
Otherwise we may emit double errors related to the `#[export_name]` attribute, for example, and using a query should ensure that it's only emitted at most once.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr.rs | 24 | ||||
| -rw-r--r-- | src/libsyntax/diagnostic_list.rs | 23 |
2 files changed, 0 insertions, 47 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 03907eed900..36ab3737f38 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -506,30 +506,6 @@ pub fn find_crate_name(attrs: &[Attribute]) -> Option<Symbol> { first_attr_value_str_by_name(attrs, "crate_name") } -/// Find the value of #[export_name=*] attribute and check its validity. -pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<Symbol> { - attrs.iter().fold(None, |ia,attr| { - if attr.check_name("export_name") { - if let s@Some(_) = attr.value_str() { - s - } else { - struct_span_err!(diag, attr.span, E0558, - "export_name attribute has invalid format") - .span_label(attr.span, "did you mean #[export_name=\"*\"]?") - .emit(); - None - } - } else { - ia - } - }) -} - -pub fn contains_extern_indicator(diag: &Handler, attrs: &[Attribute]) -> bool { - contains_name(attrs, "no_mangle") || - find_export_name_attr(diag, attrs).is_some() -} - #[derive(Copy, Clone, PartialEq)] pub enum InlineAttr { None, diff --git a/src/libsyntax/diagnostic_list.rs b/src/libsyntax/diagnostic_list.rs index 46dec73c962..b29883670bd 100644 --- a/src/libsyntax/diagnostic_list.rs +++ b/src/libsyntax/diagnostic_list.rs @@ -219,29 +219,6 @@ Erroneous code example: Delete the offending feature attribute. "##, -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() {} -``` -"##, - E0565: r##" A literal was used in an attribute that doesn't support literals. |
