Skip to content

Commit

Permalink
Add exhaustive location checking for doc_alias attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
hdelc committed Aug 2, 2022
1 parent 6b37a79 commit c643007
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,30 @@ impl CheckAttrVisitor<'_> {
}
// we check the validity of params elsewhere
Target::Param => return false,
Target::Expression => Some("expression"),
Target::Statement => Some("statement"),
Target::Arm => Some("match arm"),
_ => None,
Target::Expression | Target::Statement | Target::Arm => Some(target.name()),
Target::ExternCrate
| Target::Use
| Target::Static
| Target::Const
| Target::Fn
| Target::Closure
| Target::Mod
| Target::GlobalAsm
| Target::TyAlias
| Target::OpaqueTy
| Target::Enum
| Target::Variant
| Target::Struct
| Target::Field
| Target::Union
| Target::Trait
| Target::TraitAlias
| Target::Method(..)
| Target::ForeignFn
| Target::ForeignStatic
| Target::ForeignTy
| Target::GenericParam(..)
| Target::MacroDef => None,
} {
tcx.sess.emit_err(errors::DocAliasBadLocation { span, attr_str, location });
return false;
Expand Down

0 comments on commit c643007

Please sign in to comment.