@@ -109,27 +109,29 @@ impl RustcMirAttrs {
109
109
. flat_map ( |attr| attr. meta_item_list ( ) . into_iter ( ) . flat_map ( |v| v. into_iter ( ) ) ) ;
110
110
111
111
for attr in rustc_mir_attrs {
112
- let attr_result = if attr. has_name ( sym:: borrowck_graphviz_postflow) {
113
- Self :: set_field ( & mut ret. basename_and_suffix , tcx, & attr, |s| {
114
- let path = PathBuf :: from ( s. to_string ( ) ) ;
115
- match path. file_name ( ) {
116
- Some ( _) => Ok ( path) ,
117
- None => {
118
- tcx. dcx ( ) . emit_err ( PathMustEndInFilename { span : attr. span ( ) } ) ;
112
+ let attr_result = match attr. name ( ) {
113
+ Some ( name @ sym:: borrowck_graphviz_postflow) => {
114
+ Self :: set_field ( & mut ret. basename_and_suffix , tcx, name, & attr, |s| {
115
+ let path = PathBuf :: from ( s. to_string ( ) ) ;
116
+ match path. file_name ( ) {
117
+ Some ( _) => Ok ( path) ,
118
+ None => {
119
+ tcx. dcx ( ) . emit_err ( PathMustEndInFilename { span : attr. span ( ) } ) ;
120
+ Err ( ( ) )
121
+ }
122
+ }
123
+ } )
124
+ }
125
+ Some ( name @ sym:: borrowck_graphviz_format) => {
126
+ Self :: set_field ( & mut ret. formatter , tcx, name, & attr, |s| match s {
127
+ sym:: gen_kill | sym:: two_phase => Ok ( s) ,
128
+ _ => {
129
+ tcx. dcx ( ) . emit_err ( UnknownFormatter { span : attr. span ( ) } ) ;
119
130
Err ( ( ) )
120
131
}
121
- }
122
- } )
123
- } else if attr. has_name ( sym:: borrowck_graphviz_format) {
124
- Self :: set_field ( & mut ret. formatter , tcx, & attr, |s| match s {
125
- sym:: gen_kill | sym:: two_phase => Ok ( s) ,
126
- _ => {
127
- tcx. dcx ( ) . emit_err ( UnknownFormatter { span : attr. span ( ) } ) ;
128
- Err ( ( ) )
129
- }
130
- } )
131
- } else {
132
- Ok ( ( ) )
132
+ } )
133
+ }
134
+ _ => Ok ( ( ) ) ,
133
135
} ;
134
136
135
137
result = result. and ( attr_result) ;
@@ -141,13 +143,12 @@ impl RustcMirAttrs {
141
143
fn set_field < T > (
142
144
field : & mut Option < T > ,
143
145
tcx : TyCtxt < ' _ > ,
146
+ name : Symbol ,
144
147
attr : & ast:: MetaItemInner ,
145
148
mapper : impl FnOnce ( Symbol ) -> Result < T , ( ) > ,
146
149
) -> Result < ( ) , ( ) > {
147
- // Unwrapping the name is safe because this is only called when `has_name` has succeeded.
148
150
if field. is_some ( ) {
149
- tcx. dcx ( )
150
- . emit_err ( DuplicateValuesFor { span : attr. span ( ) , name : attr. name ( ) . unwrap ( ) } ) ;
151
+ tcx. dcx ( ) . emit_err ( DuplicateValuesFor { span : attr. span ( ) , name } ) ;
151
152
152
153
return Err ( ( ) ) ;
153
154
}
0 commit comments