Skip to content

Commit ee08bc3

Browse files
committed
address feedback
1 parent 01192eb commit ee08bc3

4 files changed

Lines changed: 19 additions & 10 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ fn parse_directive_items<'p, S: Stage>(
118118
}}
119119

120120
macro or_malformed($($code:tt)*) {{
121-
let Some(ret) = (try {
122-
$($code)*
123-
}) else {
121+
let Some(ret) = (||{
122+
Some($($code)*)
123+
})() else {
124124

125125
malformed!()
126126
};

compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ pub(crate) struct OnConstParser {
1212
}
1313

1414
impl<S: Stage> AttributeParser<S> for OnConstParser {
15-
const ATTRIBUTES: AcceptMapping<Self, S> =
16-
&[(&[sym::diagnostic, sym::on_const], template!(Word), |this, cx, args| {
15+
const ATTRIBUTES: AcceptMapping<Self, S> = &[(
16+
&[sym::diagnostic, sym::on_const],
17+
template!(List: &[r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#]),
18+
|this, cx, args| {
1719
if !cx.features().diagnostic_on_const() {
1820
return;
1921
}
@@ -47,7 +49,10 @@ impl<S: Stage> AttributeParser<S> for OnConstParser {
4749
return;
4850
};
4951
merge_directives(cx, &mut this.directive, (span, directive));
50-
})];
52+
},
53+
)];
54+
55+
//FIXME Still checked in `check_attr.rs`
5156
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
5257

5358
fn finalize(self, _cx: &FinalizeContext<'_, '_, S>) -> Option<AttributeKind> {

compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unimplemented.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ impl OnUnimplementedParser {
5757

5858
impl<S: Stage> AttributeParser<S> for OnUnimplementedParser {
5959
const ATTRIBUTES: AcceptMapping<Self, S> = &[
60-
(&[sym::diagnostic, sym::on_unimplemented], template!(Word), |this, cx, args| {
61-
this.parse(cx, args, Mode::DiagnosticOnUnimplemented);
62-
}),
60+
(
61+
&[sym::diagnostic, sym::on_unimplemented],
62+
template!(List: &[r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#]),
63+
|this, cx, args| {
64+
this.parse(cx, args, Mode::DiagnosticOnUnimplemented);
65+
},
66+
),
6367
(
6468
&[sym::rustc_on_unimplemented],
6569
template!(List: &[r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#]),
@@ -68,6 +72,7 @@ impl<S: Stage> AttributeParser<S> for OnUnimplementedParser {
6872
},
6973
),
7074
];
75+
//FIXME attribute is not parsed for non-traits but diagnostics are issued in `check_attr.rs`
7176
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
7277

7378
fn finalize(self, _cx: &FinalizeContext<'_, '_, S>) -> Option<AttributeKind> {

compiler/rustc_attr_parsing/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
#![cfg_attr(bootstrap, feature(if_let_guard))]
8181
#![feature(decl_macro)]
8282
#![feature(iter_intersperse)]
83-
#![feature(try_blocks)]
8483
#![recursion_limit = "256"]
8584
// tidy-alphabetical-end
8685

0 commit comments

Comments
 (0)