Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ceb2512

Browse files
committedJan 16, 2019
Auto merge of #57321 - petrochenkov:atokens, r=nikomatsakis
Implement basic input validation for built-in attributes Correct top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is enforced for built-in attributes, built-in attributes must also fit into the "meta-item" syntax (aka the "classic attribute syntax"). For some subset of attributes (found by crater run), errors are lowered to deprecation warnings. NOTE: This PR previously included #57367 as well.
2 parents cccaf9a + d3411d3 commit ceb2512

File tree

106 files changed

+1398
-1625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+1398
-1625
lines changed
 

‎src/librustc/diagnostics.rs

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,27 +1180,6 @@ fn main() {
11801180
```
11811181
"##,
11821182

1183-
E0296: r##"
1184-
This error indicates that the given recursion limit could not be parsed. Ensure
1185-
that the value provided is a positive integer between quotes.
1186-
1187-
Erroneous code example:
1188-
1189-
```compile_fail,E0296
1190-
#![recursion_limit]
1191-
1192-
fn main() {}
1193-
```
1194-
1195-
And a working example:
1196-
1197-
```
1198-
#![recursion_limit="1000"]
1199-
1200-
fn main() {}
1201-
```
1202-
"##,
1203-
12041183
E0308: r##"
12051184
This error occurs when the compiler was unable to infer the concrete type of a
12061185
variable. It can occur for several cases, the most common of which is a
@@ -2093,20 +2072,6 @@ trait Foo { }
20932072
```
20942073
"##,
20952074

2096-
E0702: r##"
2097-
This error indicates that a `#[non_exhaustive]` attribute had a value. The
2098-
`#[non_exhaustive]` should be empty.
2099-
2100-
Examples of erroneous code:
2101-
2102-
```compile_fail,E0702
2103-
# #![feature(non_exhaustive)]
2104-
2105-
#[non_exhaustive(anything)]
2106-
struct Foo;
2107-
```
2108-
"##,
2109-
21102075
E0718: r##"
21112076
This error indicates that a `#[lang = ".."]` attribute was placed
21122077
on the wrong type of item.
@@ -2138,6 +2103,7 @@ register_diagnostics! {
21382103
E0280, // requirement is not satisfied
21392104
E0284, // cannot resolve type
21402105
// E0285, // overflow evaluation builtin bounds
2106+
// E0296, // replaced with a generic attribute input check
21412107
// E0300, // unexpanded macro
21422108
// E0304, // expected signed integer constant
21432109
// E0305, // expected constant
@@ -2180,4 +2146,5 @@ register_diagnostics! {
21802146
E0709, // multiple different lifetimes used in arguments of `async fn`
21812147
E0710, // an unknown tool name found in scoped lint
21822148
E0711, // a feature has been declared with conflicting stability attributes
2149+
// E0702, // replaced with a generic attribute input check
21832150
}

‎src/librustc/hir/check_attr.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,6 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
142142
return;
143143
}
144144
}
145-
146-
if attr.meta_item_list().is_some() || attr.value_str().is_some() {
147-
struct_span_err!(self.tcx.sess,
148-
attr.span,
149-
E0702,
150-
"attribute should be empty")
151-
.span_label(item.span, "not empty")
152-
.emit();
153-
}
154145
}
155146

156147
/// Check if the `#[marker]` attribute on an `item` is valid.
@@ -165,12 +156,6 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
165156
return;
166157
}
167158
}
168-
169-
if !attr.is_word() {
170-
self.tcx.sess
171-
.struct_span_err(attr.span, "attribute should be empty")
172-
.emit();
173-
}
174159
}
175160

176161
/// Check if the `#[repr]` attributes on `item` are valid.

0 commit comments

Comments
 (0)
Please sign in to comment.