Skip to content

Commit ee7593e

Browse files
committed
Revert changes that belong to separate PR
1 parent da57ac3 commit ee7593e

7 files changed

+16
-39
lines changed

src/libsyntax/config.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,6 @@ impl<'a> StripUnconfigured<'a> {
9494
if !attr.check_name(sym::cfg_attr) {
9595
return vec![attr];
9696
}
97-
if attr.tokens.len() == 0 {
98-
self.sess.span_diagnostic.struct_span_err(attr.span, "bad `cfg_attr` attribute")
99-
.span_label(attr.span, "missing condition and attribute")
100-
.note("`cfg_attr` must be of the form: \
101-
`#[cfg_attr(condition, attribute, other_attribute, ...)]`")
102-
.note("for more information, visit \
103-
<https://doc.rust-lang.org/reference/conditional-compilation.html\
104-
#the-cfg_attr-attribute>")
105-
.emit();
106-
return vec![];
107-
}
10897

10998
let (cfg_predicate, expanded_attrs) = match attr.parse(self.sess, |parser| {
11099
parser.expect(&token::OpenDelim(token::Paren))?;
@@ -128,7 +117,7 @@ impl<'a> StripUnconfigured<'a> {
128117
Ok(result) => result,
129118
Err(mut e) => {
130119
e.emit();
131-
return vec![];
120+
return Vec::new();
132121
}
133122
};
134123

src/libsyntax/ext/derive.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ pub fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec<ast::Attribute>) ->
1717
return true;
1818
}
1919
if !attr.is_meta_item_list() {
20-
cx.struct_span_err(attr.span, "bad `derive` attribute")
21-
.span_label(attr.span, "missing traits to be derived")
22-
.note("`derive` must be of the form: \
23-
`#[derive(Trait1, Trait2, ...)]`")
24-
.emit();
20+
cx.span_err(attr.span,
21+
"attribute must be of the form `#[derive(Trait1, Trait2, ...)]`");
2522
return false;
2623
}
2724

src/libsyntax/parse/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ impl<'a> Parser<'a> {
618618
let (span, msg) = match (&self.token, self.subparser_name) {
619619
(&token::Token::Eof, Some(origin)) => {
620620
let sp = self.sess.source_map().next_point(self.span);
621-
(sp, format!( "expected expression, found end of {}", origin))
621+
(sp, format!("expected expression, found end of {}", origin))
622622
}
623623
_ => (self.span, format!(
624624
"expected expression, found {}",

src/test/ui/malformed/malformed-derive-entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct Test2;
77
#[derive()] //~ WARNING empty trait list
88
struct Test3;
99

10-
#[derive] //~ ERROR bad `derive` attribute
10+
#[derive] //~ ERROR attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
1111
struct Test4;
1212

1313
fn main() {}

src/test/ui/malformed/malformed-derive-entry.stderr

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ warning: empty trait list in `derive`
1616
LL | #[derive()]
1717
| ^^^^^^^^^^^
1818

19-
error: bad `derive` attribute
19+
error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
2020
--> $DIR/malformed-derive-entry.rs:10:1
2121
|
2222
LL | #[derive]
23-
| ^^^^^^^^^ missing traits to be derived
24-
|
25-
= note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]`
23+
| ^^^^^^^^^
2624

2725
error: aborting due to 3 previous errors
2826

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#[cfg_attr] //~ ERROR bad `cfg_attr` attribute
1+
#[cfg_attr] //~ ERROR expected `(`, found end of attribute
22
struct S1;
33

44
#[cfg_attr = ""] //~ ERROR expected `(`, found `=`
55
struct S2;
66

7-
#[derive] //~ ERROR bad `derive` attribute
7+
#[derive] //~ ERROR attribute must be of the form
88
struct S3;
99

10-
#[derive = ""] //~ ERROR bad `derive` attribute
10+
#[derive = ""] //~ ERROR attribute must be of the form
1111
struct S4;
1212

1313
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
1-
error: bad `cfg_attr` attribute
1+
error: expected `(`, found end of attribute
22
--> $DIR/malformed-special-attrs.rs:1:1
33
|
44
LL | #[cfg_attr]
5-
| ^^^^^^^^^^^ missing condition and attribute
6-
|
7-
= note: `cfg_attr` must be of the form: `#[cfg_attr(condition, attribute, other_attribute, ...)]`
8-
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
5+
| ^ expected `(`
96

107
error: expected `(`, found `=`
118
--> $DIR/malformed-special-attrs.rs:4:12
129
|
1310
LL | #[cfg_attr = ""]
1411
| ^ expected `(`
1512

16-
error: bad `derive` attribute
13+
error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
1714
--> $DIR/malformed-special-attrs.rs:7:1
1815
|
1916
LL | #[derive]
20-
| ^^^^^^^^^ missing traits to be derived
21-
|
22-
= note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]`
17+
| ^^^^^^^^^
2318

24-
error: bad `derive` attribute
19+
error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]`
2520
--> $DIR/malformed-special-attrs.rs:10:1
2621
|
2722
LL | #[derive = ""]
28-
| ^^^^^^^^^^^^^^ missing traits to be derived
29-
|
30-
= note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]`
23+
| ^^^^^^^^^^^^^^
3124

3225
error: aborting due to 4 previous errors
3326

0 commit comments

Comments
 (0)