about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan Levick <me@ryanlevick.com>2021-06-15 19:01:11 +0200
committerRyan Levick <me@ryanlevick.com>2021-06-15 19:01:11 +0200
commit5f74ba50bc8b95698343476d22d8037b832324b4 (patch)
treea8019a8a4fb9668505a7bcf74863d3dabac1931c
parent6936ca8c993a82c5b5d453c3203d3b7df74c1b4b (diff)
downloadrust-5f74ba50bc8b95698343476d22d8037b832324b4.tar.gz
rust-5f74ba50bc8b95698343476d22d8037b832324b4.zip
Fix ICE when doc aliases were put on function params
-rw-r--r--compiler/rustc_passes/src/check_attr.rs2
-rw-r--r--src/test/ui/rustdoc/check-doc-alias-attr-location.rs7
-rw-r--r--src/test/ui/rustdoc/check-doc-alias-attr-location.stderr8
3 files changed, 13 insertions, 4 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index b18ef302962..eca84c791fb 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -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));
diff --git a/src/test/ui/rustdoc/check-doc-alias-attr-location.rs b/src/test/ui/rustdoc/check-doc-alias-attr-location.rs
index 007d2ae6506..4738e5116b4 100644
--- a/src/test/ui/rustdoc/check-doc-alias-attr-location.rs
+++ b/src/test/ui/rustdoc/check-doc-alias-attr-location.rs
@@ -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
@@ -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
     }
 }
diff --git a/src/test/ui/rustdoc/check-doc-alias-attr-location.stderr b/src/test/ui/rustdoc/check-doc-alias-attr-location.stderr
index a66e9939eaf..2b25882be21 100644
--- a/src/test/ui/rustdoc/check-doc-alias-attr-location.stderr
+++ b/src/test/ui/rustdoc/check-doc-alias-attr-location.stderr
@@ -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
    |
@@ -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