Skip to content

Commit 8daad74

Browse files
committed
Auto merge of #86332 - rylev:fix-ice-docalias, r=GuillaumeGomez
Fix ICE when doc aliases were put on function params Fixes #86239 r? `@GuillaumeGomez`
2 parents 2336406 + 5f74ba5 commit 8daad74

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

compiler/rustc_passes/src/check_attr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ impl CheckAttrVisitor<'tcx> {
456456
_ => None,
457457
}
458458
}
459+
// we check the validity of params elsewhere
460+
Target::Param => return false,
459461
_ => None,
460462
} {
461463
return err_fn(meta.span(), &format!("isn't allowed on {}", err));

src/test/ui/rustdoc/check-doc-alias-attr-location.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#![crate_type="lib"]
1+
#![crate_type = "lib"]
22

33
pub struct Bar;
44
pub trait Foo {
55
type X;
6-
fn foo() -> Self::X;
6+
fn foo(x: u32) -> Self::X;
77
}
88

99
#[doc(alias = "foo")] //~ ERROR
@@ -19,7 +19,8 @@ impl Bar {
1919
impl Foo for Bar {
2020
#[doc(alias = "assoc")] //~ ERROR
2121
type X = i32;
22-
fn foo() -> Self::X {
22+
fn foo(#[doc(alias = "qux")] _x: u32) -> Self::X {
23+
//~^ ERROR
2324
0
2425
}
2526
}

src/test/ui/rustdoc/check-doc-alias-attr-location.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-in attributes in function parameters
2+
--> $DIR/check-doc-alias-attr-location.rs:22:12
3+
|
4+
LL | fn foo(#[doc(alias = "qux")] _x: u32) -> Self::X {
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
17
error: `#[doc(alias = "...")]` isn't allowed on extern block
28
--> $DIR/check-doc-alias-attr-location.rs:9:7
39
|
@@ -22,5 +28,5 @@ error: `#[doc(alias = "...")]` isn't allowed on type alias in implementation blo
2228
LL | #[doc(alias = "assoc")]
2329
| ^^^^^^^^^^^^^^^
2430

25-
error: aborting due to 4 previous errors
31+
error: aborting due to 5 previous errors
2632

0 commit comments

Comments
 (0)