File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
compiler/rustc_attr_parsing/src/attributes Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -424,13 +424,29 @@ impl<S: Stage> AttributeParser<S> for UsedParser {
424424 ArgParser :: NameValue ( _) => return ,
425425 } ;
426426
427+ let attr_span = cx. attr_span ;
428+
429+ // `#[used]` is interpreted as `#[used(linker)]` (though depending on target OS the
430+ // circumstances are more complicated). While we're checking `used_by`, also report
431+ // these cross-`UsedBy` duplicates to warn.
427432 let target = match used_by {
428433 UsedBy :: Compiler => & mut group. first_compiler ,
429- UsedBy :: Linker => & mut group. first_linker ,
430- UsedBy :: Any => & mut group. first_generic ,
434+ UsedBy :: Linker => {
435+ if let Some ( prev) = group. first_generic {
436+ cx. warn_unused_duplicate ( prev, attr_span) ;
437+ return ;
438+ }
439+ & mut group. first_linker
440+ }
441+ UsedBy :: Any => {
442+ if let Some ( prev) = group. first_linker {
443+ cx. warn_unused_duplicate ( prev, attr_span) ;
444+ return ;
445+ }
446+ & mut group. first_generic
447+ }
431448 } ;
432449
433- let attr_span = cx. attr_span ;
434450 if let Some ( prev) = * target {
435451 cx. warn_unused_duplicate ( prev, attr_span) ;
436452 } else {
You can’t perform that action at this time.
0 commit comments