Skip to content

Commit

Permalink
Auto merge of rust-lang#86332 - rylev:fix-ice-docalias, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Fix ICE when doc aliases were put on function params

Fixes rust-lang#86239

r? `@GuillaumeGomez`
  • Loading branch information
bors committed Jun 16, 2021
2 parents 2336406 + 5f74ba5 commit 8daad74
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ impl CheckAttrVisitor<'tcx> {
_ => None,
}
}
// we check the validity of params elsewhere
Target::Param => return false,
_ => None,
} {
return err_fn(meta.span(), &format!("isn't allowed on {}", err));
Expand Down
7 changes: 4 additions & 3 deletions src/test/ui/rustdoc/check-doc-alias-attr-location.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![crate_type="lib"]
#![crate_type = "lib"]

pub struct Bar;
pub trait Foo {
type X;
fn foo() -> Self::X;
fn foo(x: u32) -> Self::X;
}

#[doc(alias = "foo")] //~ ERROR
Expand All @@ -19,7 +19,8 @@ impl Bar {
impl Foo for Bar {
#[doc(alias = "assoc")] //~ ERROR
type X = i32;
fn foo() -> Self::X {
fn foo(#[doc(alias = "qux")] _x: u32) -> Self::X {
//~^ ERROR
0
}
}
8 changes: 7 additions & 1 deletion src/test/ui/rustdoc/check-doc-alias-attr-location.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters
--> $DIR/check-doc-alias-attr-location.rs:22:12
|
LL | fn foo(#[doc(alias = "qux")] _x: u32) -> Self::X {
| ^^^^^^^^^^^^^^^^^^^^^

error: `#[doc(alias = "...")]` isn't allowed on extern block
--> $DIR/check-doc-alias-attr-location.rs:9:7
|
Expand All @@ -22,5 +28,5 @@ error: `#[doc(alias = "...")]` isn't allowed on type alias in implementation blo
LL | #[doc(alias = "assoc")]
| ^^^^^^^^^^^^^^^

error: aborting due to 4 previous errors
error: aborting due to 5 previous errors

0 comments on commit 8daad74

Please sign in to comment.