Skip to content

Commit f312e0a

Browse files
Add tests for new tyalias intra-doc link disambiguator
1 parent fb429dc commit f312e0a

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Ensure that no warning is emitted if the disambiguator is used for type alias.
2+
// Regression test for <https://github.com/rust-lang/rust/issues/146855>.
3+
4+
#![deny(rustdoc::broken_intra_doc_links)]
5+
6+
pub struct Foo;
7+
8+
#[allow(non_camel_case_types)]
9+
pub type f32 = Foo;
10+
11+
/// This function returns [`f32`].
12+
//~^ ERROR: `f32` is both a type alias and a primitive type
13+
//~| HELP: to link to the type alias, prefix with `tyalias@`
14+
//~| HELP: to link to the primitive type, prefix with `prim@`
15+
pub fn my_fn() -> f32 {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: `f32` is both a type alias and a primitive type
2+
--> $DIR/type-alias-primitive-suggestion.rs:11:29
3+
|
4+
LL | /// This function returns [`f32`].
5+
| ^^^ ambiguous link
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/type-alias-primitive-suggestion.rs:4:9
9+
|
10+
LL | #![deny(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
help: to link to the type alias, prefix with `tyalias@`
13+
|
14+
LL | /// This function returns [`tyalias@f32`].
15+
| ++++++++
16+
help: to link to the primitive type, prefix with `prim@`
17+
|
18+
LL | /// This function returns [`prim@f32`].
19+
| +++++
20+
21+
error: aborting due to 1 previous error
22+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Ensure that no warning is emitted if the disambiguator is used for type alias.
2+
// Regression test for <https://github.com/rust-lang/rust/issues/146855>.
3+
4+
//@ check-pass
5+
6+
#![deny(rustdoc::broken_intra_doc_links)]
7+
8+
pub struct Foo;
9+
10+
#[allow(non_camel_case_types)]
11+
pub type f32 = Foo;
12+
13+
/// This function returns [`tyalias@f32`] and not [`prim@f32`].
14+
pub fn my_fn() -> f32 {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Ensure that no warning is emitted if the disambiguator is used for type alias.
2+
// Regression test for <https://github.com/rust-lang/rust/issues/146855>.
3+
4+
#![crate_name = "foo"]
5+
6+
pub struct Foo;
7+
8+
#[allow(non_camel_case_types)]
9+
pub type f32 = Foo;
10+
11+
/// This function returns [`tyalias@f32`] and not [bla][`prim@f32`].
12+
//@ has 'foo/fn.my_fn.html'
13+
//@ has - '//a[@href="type.f32.html"]' "f32"
14+
//@ has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.f32.html"]' "bla"
15+
pub fn my_fn() -> f32 {}

0 commit comments

Comments
 (0)