Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d200683

Browse files
authoredJul 8, 2024
Rollup merge of rust-lang#127459 - its-the-shrimp:rustdocjson_add_alias_tests, r=aDotInTheVoid
rustdoc-json: add type/trait alias tests Not sure if this tests everything there is to test in them though. Updates rust-lang#81359
2 parents 6a31edc + 8e7314f commit d200683

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
 

‎tests/rustdoc-json/trait_alias.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ignore-tidy-linelength
2+
#![feature(trait_alias)]
3+
4+
// @set StrLike = "$.index[*][?(@.name=='StrLike')].id"
5+
// @is "$.index[*][?(@.name=='StrLike')].visibility" \"public\"
6+
// @has "$.index[*][?(@.name=='StrLike')].inner.trait_alias"
7+
// @is "$.index[*][?(@.name=='StrLike')].span.filename" $FILE
8+
pub trait StrLike = AsRef<str>;
9+
10+
// @is "$.index[*][?(@.name=='f')].inner.function.decl.output.impl_trait[0].trait_bound.trait.id" $StrLike
11+
pub fn f() -> impl StrLike {
12+
"heya"
13+
}
14+
15+
// @!is "$.index[*][?(@.name=='g')].inner.function.decl.output.impl_trait[0].trait_bound.trait.id" $StrLike
16+
pub fn g() -> impl AsRef<str> {
17+
"heya"
18+
}

‎tests/rustdoc-json/type_alias.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @set IntVec = "$.index[*][?(@.name=='IntVec')].id"
2+
// @is "$.index[*][?(@.name=='IntVec')].visibility" \"public\"
3+
// @has "$.index[*][?(@.name=='IntVec')].inner.type_alias"
4+
// @is "$.index[*][?(@.name=='IntVec')].span.filename" $FILE
5+
pub type IntVec = Vec<u32>;
6+
7+
// @is "$.index[*][?(@.name=='f')].inner.function.decl.output.resolved_path.id" $IntVec
8+
pub fn f() -> IntVec {
9+
vec![0; 32]
10+
}
11+
12+
// @!is "$.index[*][?(@.name=='g')].inner.function.decl.output.resolved_path.id" $IntVec
13+
pub fn g() -> Vec<u32> {
14+
vec![0; 32]
15+
}

0 commit comments

Comments
 (0)
Failed to load comments.