File tree Expand file tree Collapse file tree 4 files changed +95
-0
lines changed Expand file tree Collapse file tree 4 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
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 { }
16
+
17
+ /// This function returns [type@f32].
18
+ //~^ ERROR: `f32` is both a type alias and a primitive type
19
+ //~| HELP: to link to the type alias, prefix with `tyalias@`
20
+ //~| HELP: to link to the primitive type, prefix with `prim@`
21
+ pub fn my_fn2 ( ) -> f32 { }
Original file line number Diff line number Diff line change
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: `f32` is both a type alias and a primitive type
22
+ --> $DIR/type-alias-primitive-suggestion.rs:17:28
23
+ |
24
+ LL | /// This function returns [type@f32].
25
+ | ^^^^^^^^ ambiguous link
26
+ |
27
+ help: to link to the type alias, prefix with `tyalias@`
28
+ |
29
+ LL - /// This function returns [type@f32].
30
+ LL + /// This function returns [tyalias@f32].
31
+ |
32
+ help: to link to the primitive type, prefix with `prim@`
33
+ |
34
+ LL - /// This function returns [type@f32].
35
+ LL + /// This function returns [prim@f32].
36
+ |
37
+
38
+ error: aborting due to 2 previous errors
39
+
Original file line number Diff line number Diff line change
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 { }
Original file line number Diff line number Diff line change
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
+ #![ deny( rustdoc:: broken_intra_doc_links) ]
6
+
7
+ pub struct Foo ;
8
+
9
+ #[ allow( non_camel_case_types) ]
10
+ pub type f32 = Foo ;
11
+
12
+ /// This function returns [`tyalias@f32`] and not [bla][`prim@f32`].
13
+ //@ has 'foo/fn.my_fn.html'
14
+ //@ has - '//a[@href="type.f32.html"]' "f32"
15
+ //@ has - '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.f32.html"]' "bla"
16
+ pub fn my_fn ( ) -> f32 { 0. }
17
+
18
+ /// This function returns [`typealias@f32`].
19
+ //@ has 'foo/fn.my_other_fn.html'
20
+ //@ has - '//a[@href="type.f32.html"]' "f32"
21
+ pub fn my_other_fn ( ) -> f32 { 0. }
You can’t perform that action at this time.
0 commit comments