Rollup merge of #100029 - hdelc:master, r=cjgillot
Prevent ICE for `doc_alias` on match arm, statement, expression Fixes #99777. This is a pretty minimal fix that should be safe, since rustdoc doesn't generate documentation for match arms, statements, or expressions. I mentioned in the linked issue that the `doc_alias` target checking should probably be improved to avoid future ICEs, but as a new contributor, I'm not confident enough with the HIR types to make a larger change.
This commit is contained in:
commit
f8e6617239
7 changed files with 109 additions and 60 deletions
|
@ -596,8 +596,6 @@ impl CheckAttrVisitor<'_> {
|
|||
|
||||
let span = meta.span();
|
||||
if let Some(location) = match target {
|
||||
Target::Impl => Some("implementation block"),
|
||||
Target::ForeignMod => Some("extern block"),
|
||||
Target::AssocTy => {
|
||||
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
|
||||
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
|
||||
|
@ -619,7 +617,34 @@ impl CheckAttrVisitor<'_> {
|
|||
}
|
||||
// we check the validity of params elsewhere
|
||||
Target::Param => return false,
|
||||
_ => None,
|
||||
Target::Expression
|
||||
| Target::Statement
|
||||
| Target::Arm
|
||||
| Target::ForeignMod
|
||||
| Target::Closure
|
||||
| Target::Impl => Some(target.name()),
|
||||
Target::ExternCrate
|
||||
| Target::Use
|
||||
| Target::Static
|
||||
| Target::Const
|
||||
| Target::Fn
|
||||
| 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue